From: Benjamin Linnik Date: Mon, 18 Dec 2017 12:35:04 +0000 (+0100) Subject: Analyzer: Cleanup, maybe someone sometime will be able to compile this correctly... X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=e328dd4103e9e3f5ffbb3216191c4b343e0bb066;p=radhard.git Analyzer: Cleanup, maybe someone sometime will be able to compile this correctly, at this point being each 'cpp' class file is merged into one cpp file and compiled after --- diff --git a/MABS_run_analyzer/ChargeSpektrum.c b/MABS_run_analyzer/ChargeSpektrum.c index bbcdeb3..8d09813 100644 --- a/MABS_run_analyzer/ChargeSpektrum.c +++ b/MABS_run_analyzer/ChargeSpektrum.c @@ -10,11 +10,14 @@ * */ -Bool_t isBatch = kFALSE; - -#include "MAPS.c" -#include "Run.c" #include "help.h" +#include "Run.h" +#include "MAPS.h" + +// #include "Run.cpp" +#include "HistogramType.cpp" +#include "MAPS.cpp" + Run** runs; Int_t numberRuns; @@ -24,8 +27,6 @@ Int_t numberRuns; void ChargeSpektrum(TString runnumber = "") { cout << endl << endl; - if (gROOT->IsBatch()) - isBatch = kTRUE; numberRuns=0; std::vector runList; @@ -33,7 +34,7 @@ void ChargeSpektrum(TString runnumber = "") std::vector runListCustomTitle; std::vector sumuprunList; // not used yet, add runs to each other, combine statistics - #include "SetStyle.c" + setStyle(); InterpreteUserInput(runnumber, &runList, &runListForceAnalysis, &runListCustomTitle, &sumuprunList, &analysisType); runs = new Run*[numberRuns]; @@ -149,7 +150,7 @@ void ChargeSpektrum(TString runnumber = "") compareHistogramClassVectorMABSBot.push_back(runs[runi]->histogramwoRTS); // gROOT->SetBatch(kTRUE); - if (!isBatch) + if (!(gROOT->IsBatch())) gROOT->SetBatch(kFALSE); // **************************************************************** diff --git a/MABS_run_analyzer/ChargeSpektrumFunctions.c b/MABS_run_analyzer/ChargeSpektrumFunctions.c index de32326..8ce3fd7 100644 --- a/MABS_run_analyzer/ChargeSpektrumFunctions.c +++ b/MABS_run_analyzer/ChargeSpektrumFunctions.c @@ -659,6 +659,93 @@ Bool_t CompareHistograms(vector* ptCompareHistogramVector, TString title return 1; } +/** @brief sets the style for the ROOT plots + * + * This code block is used to init the global ROOT plotting style, it is included in the ChargeSpectrum main function + */ +Bool_t setStyle() +{ + //////////////////////////////////////////////////////////////////////////// + // // + // who: Pete Alonzi (lpa2a@virginia.edu) // + // what: rootlogon file (~/.rootlogon.C) // + // when: last update: 2009_June_11 // + // where: galileo.phys.virginia.edu // + // why: change the default root canvas to acceptable configuration // + // // + // This file is run when you open root. // + // Just place it in your home directory and it works automatically. // + // If you make a change to this file simply start // + // a new root session and the changes will be implemented. // + // // + // If you did not install roofit then there will be an error // + // message when you login, it can be ignored. // + // // + //////////////////////////////////////////////////////////////////////////// + + // Definition of new styles + TStyle *Nab_collaboration = new TStyle("RadHard_AutoTitle","How we like it"); + TStyle *Nab_collaboration_work = new TStyle("RadHard_NoTitle","How we like it without title"); + + // Set the default parameters for style Nab_collaboration + Nab_collaboration->SetCanvasBorderMode(0); // Removes Canvas Border + Nab_collaboration->SetPadBorderMode(0); // Removes Pad Border + Nab_collaboration->SetCanvasColor(0); // Changes Canvas color to white + Nab_collaboration->SetPadColor(0); // Changes Pad color to white + Nab_collaboration->SetStatColor(0); // Changes Stats bg color to white + Nab_collaboration->SetTitleFillColor(0); // Changes Title bg color to white + Nab_collaboration->SetLabelFont(42,"xyz"); // Changes Label Font + Nab_collaboration->SetTitleFont(42,"xyz"); // Changes Axis Title Font + Nab_collaboration->SetPadTickX(1); // Sets tic marks on both horizontal axes + Nab_collaboration->SetPadTickY(1); // Sets tic marks on both vertical axes + Nab_collaboration->SetTickLength(0.018,"xyz"); // Sets tic length + Nab_collaboration->SetOptStat(0); // Turns off Statistics display + Nab_collaboration->SetOptTitle(-1); // Turns off Title display + Nab_collaboration->SetHistLineWidth(2); // Changes Histogram Line width + Nab_collaboration->SetFrameBorderMode(0); // Removes the Frame Border + Nab_collaboration->SetFrameFillStyle(0); + Nab_collaboration->SetCanvasDefH(494); // Sets Default Canva Height + Nab_collaboration->SetCanvasDefW(800); // Sets Default Canvas Width + Nab_collaboration->SetPalette(1); + + + // The next for commands set the default margin size + // n.b. the margins do not take axis labels into account! grr!! + Nab_collaboration->SetPadTopMargin(0.1); // Set Margin Top + Nab_collaboration->SetPadRightMargin(0.1); // Set Margin Right + Nab_collaboration->SetPadBottomMargin(0.1); // Set Margin Bottom + Nab_collaboration->SetPadLeftMargin(0.1); // Set Margin Left + + //make a nice palette + int NRGBs = 7, NCont = 999; + Nab_collaboration->SetNumberContours(NCont); + Double_t stops[7] = { 0.00, 0.10, 0.25, 0.45, 0.60, 0.75, 1.00 }; + Double_t red[7] = { 1.00, 0.00, 0.00, 0.00, 0.97, 0.97, 0.10 }; + Double_t green[7] = { 1.00, 0.97, 0.30, 0.40, 0.97, 0.00, 0.00 }; + Double_t blue[7] = { 1.00, 0.97, 0.97, 0.00, 0.00, 0.00, 0.00 }; + TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); + + // Make Nab_collaboration_work a copy of Nab_collaboration and remove stats + Nab_collaboration->Copy(*Nab_collaboration_work); + //Nab_collaboration_work->SetOptStat(1); + Nab_collaboration_work->SetOptTitle(0); + Nab_collaboration_work->SetPadTopMargin(0.1); + Nab_collaboration_work->SetPadRightMargin(0.1); + + // Select Which Style to + gROOT->SetStyle("RadHard_AutoTitle"); + // gROOT->SetStyle("Nab_Collaboration"); + + + // Use the RooFit functions + // using namespace RooFit; + + // Force Root to run Nab_collaboration/Nab_collaboration_work style + gROOT->ForceStyle(); + + return 1; +} + Bool_t CompareLeageCurrent(vector* ptCompareHistogramClassVector) { diff --git a/MABS_run_analyzer/HistogramType.c b/MABS_run_analyzer/HistogramType.cpp similarity index 99% rename from MABS_run_analyzer/HistogramType.c rename to MABS_run_analyzer/HistogramType.cpp index 0bc88e2..82aed94 100644 --- a/MABS_run_analyzer/HistogramType.c +++ b/MABS_run_analyzer/HistogramType.cpp @@ -8,7 +8,6 @@ #define __HISTOGRAMTYPE__C #include "HistogramType.h" -#include using namespace std; diff --git a/MABS_run_analyzer/HistogramType.h b/MABS_run_analyzer/HistogramType.h index 4434506..ccb8d9e 100644 --- a/MABS_run_analyzer/HistogramType.h +++ b/MABS_run_analyzer/HistogramType.h @@ -13,37 +13,16 @@ #include #include #include +#include +#include #include "help.h" - +class TH1FO; class HistogramType; - - -/** - * @brief A class which stores one Histogram, derived from TH1F, see Cern root documentation for more information - * - */ -class TH1FO: public TH1F { -public: - HistogramType* itsHistogramType = 0; - -// TH1FO* Clone(const char *newname="") { -// TObject *newTObject = this->Clone(newname); -// TH1FO *newTH1FO = (TH1FO *)newTObject; -// newTH1FO->itsHistogramType = this->itsHistogramType; -// return newTH1FO; -// } -// - // Overload = operator - TH1FO operator=(const TH1FO &h1) { - TH1FO h2; - h2 = h1; - h2.itsHistogramType = h1.itsHistogramType; - return h2; - }; - TH1FO& operator=(const TH1F &h1); -}; - +class Run; +struct systemparam; +struct sensorinfostruct; +struct labbooksctruct; /** * @file HistogramType.h @@ -79,7 +58,7 @@ private: /// init one custom histogram void initHistogramCustom(TH1FO* &histogrampointer, TString prefix, Int_t color, Int_t style, Double_t xLow, Double_t xUp, Int_t nBins, TString xaxistitle, TString yaxistitle); /// init a histogram pointer array - void initHistogramArray(vector* histogramarraypointer, int numberofhisto, TString prefix, Int_t color, Int_t style); + void initHistogramArray(std::vector* histogramarraypointer, int numberofhisto, TString prefix, Int_t color, Int_t style); //***************** // GENERAL HISTOGRAM PROPERTIES //***************** @@ -162,9 +141,9 @@ public: /// Sum spectrum, the charge of whole cluster is summed up in binned into this TH1F histogram // TH1FO* Sum9 = 0; /// Sum spectrum array, the charge of whole cluster is summed up in binned into this TH1F histogram - vector * a_Sum; - vector a_Sum9; - vector a_Sum25; + std::vector * a_Sum; + std::vector a_Sum9; + std::vector a_Sum25; /// Veto spectrum, used to find better calibration peak, only entries where Sum over not seed pixels is below @c Run::vetothreshold are binned into this histogram TH1FO* Veto = 0; /// Noise histogram @@ -201,19 +180,19 @@ public: Double_t integralSeedErr=0; /// fitted position of the most probable value in the over cluster summed spectrum Float_t posSum=0; - vector * a_posSum; - vector a_posSum9; - vector a_posSum25; + std::vector * a_posSum; + std::vector a_posSum9; + std::vector a_posSum25; /// fintegral over the sum peak, normalized to number of events Double_t integralSum=0; - vector * a_integralSum; - vector a_integralSum9; - vector a_integralSum25; + std::vector * a_integralSum; + std::vector a_integralSum9; + std::vector a_integralSum25; /// fintegral error over the Seed peak, poisson dist. assumed -> sqrt(N) for each bin Double_t integralSumErr=0; - vector * a_integralSumErr; - vector a_integralSumErr9; - vector a_integralSumErr25; + std::vector * a_integralSumErr; + std::vector a_integralSumErr9; + std::vector a_integralSumErr25; /// fitted position of the calibration peak of Fe55-beta-photons in the seed spectrum, from a run best suited to the current Float_t posVeto=0; /// fintegral over the veto peak, normalized to number of events @@ -239,12 +218,12 @@ public: /// Integral value, after integrating from #noisethresholdborder to maxbin. Double_t sr90IntegralVal = -1; Double_t sr90IntegralErr = -1; - vector * a_sr90IntegralVal; - vector a_sr90IntegralVal9; - vector a_sr90IntegralVal25; - vector * a_sr90IntegralErr; - vector a_sr90IntegralErr9; - vector a_sr90IntegralErr25; + std::vector * a_sr90IntegralVal; + std::vector a_sr90IntegralVal9; + std::vector a_sr90IntegralVal25; + std::vector * a_sr90IntegralErr; + std::vector a_sr90IntegralErr9; + std::vector a_sr90IntegralErr25; /// Peak and sigma of Seed to Sum ratio Float_t posSeedPerc = 0; @@ -312,8 +291,8 @@ public: Bool_t isnormalized = false; /// Stats if the histograms in this class where created without RTS pixel Bool_t maskRTSpixel = false; - /** @brief This vector holds the pixel numbers with RTS noise, found by Run::FindRTSPixelToMask */ - vector RTSpixel; + /** @brief This std::vector holds the pixel numbers with RTS noise, found by Run::FindRTSPixelToMask */ + std::vector RTSpixel; /// stores information from the SQL database of a given run labbooksctruct* labbook; diff --git a/MABS_run_analyzer/MAPS.c b/MABS_run_analyzer/MAPS.cpp similarity index 99% rename from MABS_run_analyzer/MAPS.c rename to MABS_run_analyzer/MAPS.cpp index 0c320ab..0b2ed66 100644 --- a/MABS_run_analyzer/MAPS.c +++ b/MABS_run_analyzer/MAPS.cpp @@ -7,7 +7,7 @@ */ #ifndef __MAPS__C #define __MAPS__C -#include"MAPS.h" +#include "MAPS.h" #include "Run.h" using namespace std; diff --git a/MABS_run_analyzer/Run.c b/MABS_run_analyzer/Run.cpp similarity index 99% rename from MABS_run_analyzer/Run.c rename to MABS_run_analyzer/Run.cpp index db029d6..347b872 100644 --- a/MABS_run_analyzer/Run.c +++ b/MABS_run_analyzer/Run.cpp @@ -1011,21 +1011,21 @@ void Run::constructUpdateString(string *sqlupdatequery, const string databaseval if (std::isnan(value)) { cout << colorred << "Error in updating SQL value for '" << databasevaluename << ", it is 'NaN'." << endlr; return; } - if (std::isinf(value)) { - cout << colorred << "Error in updating SQL value for '" << databasevaluename << ", it is 'NaN'." << endlr; - return; } - if (!(abs(value)>=0.0)) { - cout << colorred << "Error in updating SQL value for '" << databasevaluename << ", it is 'NaN'." << endlr; - return; } - if (value > maxval) { - cout << colorred << "Error in updating SQL value for '" << databasevaluename << ", it is out of range: " << value << " > " << maxval << "." << endlr; - return; } - if (value < minval) { - cout << colorred << "Error in updating SQL value for '" << databasevaluename << ", it is out of range: " << value << " < " << maxval << "." << endlr; - return; } - if ((*sqlupdatequery).length() > 0) - *sqlupdatequery+= ", "; - *sqlupdatequery += "`" + databasevaluename + "`="+ to_str_w_prec(value, precision); + if (std::isinf(value)) { + cout << colorred << "Error in updating SQL value for '" << databasevaluename << ", it is 'NaN'." << endlr; + return; } + if (!(abs(value)>=0.0)) { + cout << colorred << "Error in updating SQL value for '" << databasevaluename << ", it is 'NaN'." << endlr; + return; } + if (value > maxval) { + cout << colorred << "Error in updating SQL value for '" << databasevaluename << ", it is out of range: " << value << " > " << maxval << "." << endlr; + return; } + if (value < minval) { + cout << colorred << "Error in updating SQL value for '" << databasevaluename << ", it is out of range: " << value << " < " << maxval << "." << endlr; + return; } + if ((*sqlupdatequery).length() > 0) + *sqlupdatequery+= ", "; + *sqlupdatequery += "`" + databasevaluename + "`="+ to_str_w_prec(value, precision); } void Run::updateDatabase() { @@ -1073,7 +1073,7 @@ void Run::updateDatabase() { constructUpdateString(&sqlupdatequery, "LeakageCurfA", histogramwoRTS->calibrated->medianLeakageCurrent); constructUpdateString(&sqlupdatequery, "LeakageCurfA+", histogramwoRTS->calibrated->medianLeakageCurrentPlus); constructUpdateString(&sqlupdatequery, "LeakageCurfA-", histogramwoRTS->calibrated->medianLeakageCurrentMinus); - constructUpdateString(&sqlupdatequery, "CalibrationPeak", Fe55run.posVeto, 4, 0, 1000); + constructUpdateString(&sqlupdatequery, "CalibrationPeak", Fe55run.posVeto, 4, -1, 1000); } } if (histogramclassToUseForDB->normalized->calibrated != 0) diff --git a/MABS_run_analyzer/Run.h b/MABS_run_analyzer/Run.h index 9f4c9e3..eac0fd2 100644 --- a/MABS_run_analyzer/Run.h +++ b/MABS_run_analyzer/Run.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -39,26 +40,14 @@ class MAPS; class Run; -#include "MAPS.c" -#include "HistogramType.c" /** - * @file Run.h - * @brief Has all the raw and processed information from MAPS about a specific run - * - * This class makes SQL requests to the server, gets database results to a given runnumber, - * stores information about a specific run, writes the analyzed data and results back - * to the databases and stores the analyzed data as histograms. - * - */ -/** - * @brief Has all the raw and processed information from MAPS about a specific run - * - * This class makes SQL requests to the server, gets database results to a given runnumber, - * stores information about a specific run, writes the analyzed data and results back - * to the databases and stores the analyzed data as histograms. - * - */ - +* @brief Has all the raw and processed information from MAPS about a specific run +* +* This class makes SQL requests to the server, gets database results to a given runnumber, +* stores information about a specific run, writes the analyzed data and results back +* to the databases and stores the analyzed data as histograms. +* +*/ class Run { private: @@ -70,43 +59,43 @@ private: TSQLResult *res; /// number of rows the SQL database found to a given request int nrows=0; - + /** @brief is set to true, if custom label is used */ Bool_t customLabel = false; TCanvas* noisecanvas = NULL; - + /** @brief formats and checks SQL statements */ template string prepareSQLStatement( T ); /** - * @brief tries to get veto peak position from other, but close runs - */ + * @brief tries to get veto peak position from other, but close runs + */ void getVetoPeakPositionFromFe55Run(); /** - * @brief takes a float and a precision and returns the number as a string with given precision - */ + * @brief takes a float and a precision and returns the number as a string with given precision + */ string to_str_w_prec(const Float_t, const int); /** - * @brief takes a float value and a precision and appends it to an SQL statement used to update the database - */ + * @brief takes a float value and a precision and appends it to an SQL statement used to update the database + */ void constructUpdateString(string *sqlupdatequery, const string databasevaluename, const Double_t value, const int precision, const Double_t minval, const Double_t maxval, const TString defaultval); - + /** - * @brief writes values back to the SQL database - */ + * @brief writes values back to the SQL database + */ void updateDatabase(); /** - * @brief removes all numbers from given string - */ + * @brief removes all numbers from given string + */ string removeNumbers(std::string x); - + /** - * @brief removes all punctuation from given string - */ + * @brief removes all punctuation from given string + */ string removePunctuation(std::string x); /// if the submatrix is devided in two parts (#devided==true), then here are the rows where the border starts and ends, @@ -130,82 +119,82 @@ private: // number of pixel, which have fired uint numberofactivepixel=0; - + /** - * @brief Generates a human readable string with information about the run - * - * The labbook data is used to make a string with useful information about the run - */ + * @brief Generates a human readable string with information about the run + * + * The labbook data is used to make a string with useful information about the run + */ Bool_t generateReadableRunCode(); - + /// is set to true if an entry was found in the SQL database Bool_t runexistsAsRootFile = 0; /// is set to true if the RAW Data is consistent Bool_t runRAWok = 0; - + TRandom* random1; /// host name of the machine, used to find correct mount points char hostname[1024]; /** - * @brief fills noise histograms in #Run::histogramstruct */ + * @brief fills noise histograms in #Run::histogramstruct */ Bool_t binNoise(HistogramType* oneHistogramClass); /** - * @brief fills leakage histograms in #Run::histogramstruct */ + * @brief fills leakage histograms in #Run::histogramstruct */ Bool_t binLeakageCurrent(HistogramType* oneHistogramClass); /** - * @brief fills Seedm, Sum and Veto #Run::histogramstruct */ + * @brief fills Seedm, Sum and Veto #Run::histogramstruct */ Bool_t binSeedSumVeto(); /** - * @brief fills averageF0Hist with average F0 values */ + * @brief fills averageF0Hist with average F0 values */ Bool_t binF0(); /** - * @brief fills the average cluster distribution into a 2 dimension histogram #Run::histogramstruct */ + * @brief fills the average cluster distribution into a 2 dimension histogram #Run::histogramstruct */ Bool_t binCluster(); /// noise quantiles: mean value, sigma in postive direction and sigma in negative direction Double_t noisequantiles[3]; /// noise quantiles: mean value, sigma in postive direction and sigma in negative direction Double_t leakagequantiles[3]; - + /** - * @brief Checks if a file exists - */ + * @brief Checks if a file exists + */ Bool_t checkFileExists(TString); - + Int_t* rootlinestyle; - + /** @brief calls #initCluster for each structure of type @c Run::histogram - * - * For the initialization parameters calculated by #findRotatedClusterDimension() are used. - */ + * + * For the initialization parameters calculated by #findRotatedClusterDimension() are used. + */ void initClusters(Float_t xcoord_min_step, Float_t xcoord_abs_min, Float_t xcoord_abs_max, Float_t ycoord_min_step, Float_t ycoord_abs_min, Float_t ycoord_abs_max); /** - * @brief Find dimensions and borders of rotated cluster - * - * This function ias needed to find out the - * final cluster size and its dimensions, to properly initialize the - * TH2F cluster bins - */ + * @brief Find dimensions and borders of rotated cluster + * + * This function ias needed to find out the + * final cluster size and its dimensions, to properly initialize the + * TH2F cluster bins + */ Bool_t findRotatedClusterDimension(Float_t rotateangle = 45); void initRootParameters(); - + /** - * @brief Fills typical histograms in HistomTyoe - * - * - */ + * @brief Fills typical histograms in HistomTyoe + * + * + */ void fillAHistogramsinclass(HistogramType* histogramtypepointer, Int_t hiti, Int_t completeclustersize, Float_t pixelSum, Float_t notSeedSum, Float_t* pt_a_pixelSum, Float_t* pt_a_notSeedSum, Float_t pixelSum25, Float_t notSeedSum25, Float_t* pt_a_pixelSum25, Float_t* pt_a_notSeedSum25, Float_t pixelSum9, Float_t notSeedSum9, Float_t* pt_a_pixelSum9, Float_t* pt_a_notSeedum9); /** @brief set this variable to true, to use the dynamical noise calculation in MAPS:analyzeRun() */ Bool_t dynamicalNoise = 1; /** @brief set this variable to true, to use the common mode noise filter in MAPS:analyzeRun() */ Bool_t commonModeFilter = 1; - + /** @brief overwrite value from which the integral should be taken, overwrite noise cut in electrons */ Float_t noisethresholdborderE = -1; @@ -218,7 +207,7 @@ private: /** @brief finds and and masks RTS pixel if maskRTSpixel isset to true */ Bool_t FindRTSPixelToMask(HistogramType* histogramtypepointer, Bool_t verbose = kFALSE); - + public: /** @brief empty constructor */ Run (void); @@ -228,7 +217,7 @@ public: Run ( Int_t, Int_t , TString customtitle = ""); /** @brief writes values back to the database, destroys the #MAPS object */ ~Run (void); - + systemparam cursystemparam; void setPlotStyle(Int_t); @@ -236,27 +225,27 @@ public: /** @brief sets a custom description to be used as a label when plotting the run */ Bool_t setLabel(TString newlabel); - + /** @brief Compare histograms - * - * Compare histograms given in the vector - * #Run::plothistogramtypepointerarray which holds structures - * of type #Run::histogram into one canvas - * * - * Use a line such as - * @code runs[runi]->plothistogramtypepointerarray.push_back(&runs[runi]->histogramfixedthreshold); - * @endcode - * to add histograms to compare, after adding a few, execute - * @code runs[runi]->plotCompareHistograms(); - * @endcode - * in ChargeSpectrum.c - * - */ + * + * Compare histograms given in the vector + * #Run::plothistogramtypepointerarray which holds structures + * of type #Run::histogram into one canvas + * * + * Use a line such as + * @code runs[runi]->plothistogramtypepointerarray.push_back(&runs[runi]->histogramfixedthreshold); + * @endcode + * to add histograms to compare, after adding a few, execute + * @code runs[runi]->plotCompareHistograms(); + * @endcode + * in ChargeSpectrum.c + * + */ Bool_t plotCompareHistograms( ); - + /** @brief Writes a given 2D-histogram into a file */ Bool_t writeHistogramToFile(TH1F* onehistogram); - + /** @brief Writes a given histogram into a file */ Bool_t write2DHistogramToFile(TH2F* onehistogram); @@ -265,36 +254,36 @@ public: /** @brief Makes a gnuplot file to plot the histogram data created in @c Run::writeAllHistogramsToFile() */ void MakeGnuplotFile(); - + /// is set to true if an error occured Bool_t error = 0; /** - * @brief analysis the RAW data - * - * Seed, sum and Veto spectrum are generated - * Clusters are found - * All analysis can be started after initialization of #MAPS - */ + * @brief analysis the RAW data + * + * Seed, sum and Veto spectrum are generated + * Clusters are found + * All analysis can be started after initialization of #MAPS + */ Bool_t analyzeRun(Bool_t force = 0); /** - * @brief initialize the RAW root file - */ + * @brief initialize the RAW root file + */ Bool_t initRun(); /** - * @brief analysis the RAW data of a given frame - * - * F0, F1 matrix are generated - */ + * @brief analysis the RAW data of a given frame + * + * F0, F1 matrix are generated + */ Bool_t analyzeFrame(Int_t frame); Int_t getClustersize(); Bool_t runAllreadyAnalyzed(); - + /** @brief Prints all data gathered from the database */ Bool_t debugDBreadout(); @@ -302,12 +291,12 @@ public: Bool_t useDynamicalNoise(Bool_t); /** @brief Turn on or off the the time dependant filling of the Noise branch in the TTree @c MAPS::regetDynNoise() - * - * If set to off: Only the Initial Noise is put into the TTree - * If set to on: Every 100 frames the TTree is filled with the current noise and pedestials of the pixels, allows time dependant noise analysis - * You have to rerun the analysis to make this change be applied, that means recreate the ROOT file. - * - */ + * + * If set to off: Only the Initial Noise is put into the TTree + * If set to on: Every 100 frames the TTree is filled with the current noise and pedestials of the pixels, allows time dependant noise analysis + * You have to rerun the analysis to make this change be applied, that means recreate the ROOT file. + * + */ Bool_t fillTTreeWithMoreThenInitialNoiseValues(Bool_t); /** @brief Turn on or off the use of common mode noise filter @c MAPS::regetDynNoise() */ @@ -319,25 +308,25 @@ public: /** @brief set a threshold value in ADU to use in the histogram Run::histogramfixedthreshold, this value is used in @c MAPS::initMapsRun() */ Bool_t setFixedThresholdValueADU(HistogramType*, Float_t); Bool_t setFixedThresholdValueADU(Float_t); - + /** - * @brief set pathwhere images and data to save to - */ + * @brief set pathwhere images and data to save to + */ Bool_t setResultsPath(TString path); /** - * @brief set dynamical noise mode, exponential decaying noise windows (modified moving average), simple moving average (SMA) - */ + * @brief set dynamical noise mode, exponential decaying noise windows (modified moving average), simple moving average (SMA) + */ Bool_t setDynamicalNoiseMode(TString mode); /** - * @brief set noise threshold border in ADU - */ + * @brief set noise threshold border in ADU + */ Bool_t setNoisethresholdborderADU(Float_t noisethresholdborder); - + /** - * @brief set noise threshold border in e - */ + * @brief set noise threshold border in e + */ Bool_t setNoisethresholdborderE(Float_t noisethresholdborder); /// stores information from the SQL database of a given run @@ -364,7 +353,7 @@ public: /** @brief sets #Run::submatrix_x_start, #Run::submatrix_x_end, #Run::submatrix_y_start and #Run::submatrix_y_end to default values */ void setMatrixSpecificParameters(); - + /** @brief sets system dependant variables after run data got from db, USB or PXI */ void setSystemSpecificParameters(); @@ -390,13 +379,13 @@ public: /// /** @brief A vector able to hold pointer of type #Run::histogramstruct - * - * You push in pointer of the type Run::histogramstruct in ChargeSpectrum.C and then - * compare different histograms of the same run. - * - * See Run::plotCompareHistograms( ) for more information and usage. - * - */ + * + * You push in pointer of the type Run::histogramstruct in ChargeSpectrum.C and then + * compare different histograms of the same run. + * + * See Run::plotCompareHistograms( ) for more information and usage. + * + */ vector compareHistogramClassVector; vector compareHistogramClassVector2; @@ -406,11 +395,11 @@ public: /** @brief The average F0 value of the run over the complete chip in dependance of the time */ TH1FO* averageF0Hist = 0; - + /** @brief The average F0 value of the run over some frames, for each pixel */ TH1FO* averageF0PixelwiseStart = 0; // Over first 1000 frames for each pixel TH1FO* averageF0PixelwiseEnd = 0; // Over last 1000 frames for each pixel - + TH1FO* averageF0DistrStart = 0; // Over first 1000 frames TH1FO* averageF0DistrEnd = 0; // Over last 1000 frames TH1FO* averageF0Distr = 0; // Over first 1000 frames and last 1000 frames @@ -418,28 +407,28 @@ public: TH1FO* averageF1DistrStart = 0; // Over first 1000 frames TH1FO* averageF1DistrEnd = 0; // Over last 1000 frames TH1FO* averageF1Distr = 0; // Over first 1000 frames and last 1000 frames - + /** @brief Plots all histograms from #Run::HistogramType into one canvas - * - * @param HistogramType pointer to a histogram structure of type #Run::histogramstruct - */ + * + * @param HistogramType pointer to a histogram structure of type #Run::histogramstruct + */ Bool_t plotAllHistograms(HistogramType*); - + /** @brief Plots average cluster charge distribution - * - * Creates a graphical view of the average charge distribution in a - * cluster - * - * @param HistogramType Pointer to a structure of type #Run::histogramstruct - * - */ + * + * Creates a graphical view of the average charge distribution in a + * cluster + * + * @param HistogramType Pointer to a structure of type #Run::histogramstruct + * + */ Bool_t plotClusterDistribution(HistogramType*); TCanvas* plot1DHistogram(TH1FO* onehistogram, TString fitFuncType = "landau", Bool_t verbose = false, Bool_t logscale =false, Bool_t withOverflow=false, Float_t fitstart=-1, TString titlestr = "", TString legendstr = ""); TCanvas* plot1DHistogram(HistogramType* histogramtypepointer, TH1FO* onehistogram, TString fitFuncType = "landau", Bool_t verbose = false, Bool_t logscale =false, Bool_t withOverflow=false, Float_t fitstart=-1, TString titlestr = "", TString legendstr = ""); - + pixelinfo pixelinfoMi34[32]; - + /// analyze only half of matrix Bool_t dividedmatrix = false; /// if #dividedmatrix ist set to true, which part to analyze? @@ -448,18 +437,18 @@ public: /// set to TRUE if fits should be drawn and calculated Bool_t doFits = true; /// fit curve ro use, gauss or landau - + /** @brief related Fe55 run - * - * if the analyzed run is not a Fe55 calibration run, find a related Fe55 run - * and fill this structure - * - * The run can be used to calibrate the run by using the position of the - * Fe55 calibration peak. ADU can be converted to e- - */ + * + * if the analyzed run is not a Fe55 calibration run, find a related Fe55 run + * and fill this structure + * + * The run can be used to calibrate the run by using the position of the + * Fe55 calibration peak. ADU can be converted to e- + */ struct OtherRun { -// /// runnumber from where the position of the veto peak was taken + // /// runnumber from where the position of the veto peak was taken Int_t posVetorunnumber = 0; /// fitted position of the calibration peak of Fe55-beta-photons in the seed spectrum, from a run best suited to the current Float_t posVeto=-1; @@ -467,15 +456,15 @@ public: Float_t temperature = -1; }; /** @brief related Fe55 run - * - * if the analyzed run is not a Fe55 calibration run, find a related Fe55 run - * and fill this structure - * - * The run can be used to calibrate the run by using the position of the - * Fe55 calibration peak. ADU can be converted to e- - */ + * + * if the analyzed run is not a Fe55 calibration run, find a related Fe55 run + * and fill this structure + * + * The run can be used to calibrate the run by using the position of the + * Fe55 calibration peak. ADU can be converted to e- + */ OtherRun Fe55run; - + /** @brief specific string wich encodes the database information of the run */ TString runcode=""; @@ -484,7 +473,7 @@ public: /** @brief other information to include in the #Run::humanreadable, not set automatically or gathered by the database */ TString humanreadablesuffix=""; - + /// processed run class MAPS *processed; diff --git a/MABS_run_analyzer/SetStyle.c b/MABS_run_analyzer/SetStyle.c deleted file mode 100644 index 1c10c97..0000000 --- a/MABS_run_analyzer/SetStyle.c +++ /dev/null @@ -1,91 +0,0 @@ -/** - * @file SetStyle.c - * @brief sets the style for the ROOT plots - * - * This code block is used to init the ROOT plotting style, it is included in the ChargeSpectrum main function - */ - -/** @brief sets the style for the ROOT plots - * - * This code block is used to init the ROOT plotting style, it is included in the ChargeSpectrum main function - */ -{ - //////////////////////////////////////////////////////////////////////////// - // // - // who: Pete Alonzi (lpa2a@virginia.edu) // - // what: rootlogon file (~/.rootlogon.C) // - // when: last update: 2009_June_11 // - // where: galileo.phys.virginia.edu // - // why: change the default root canvas to acceptable configuration // - // // - // This file is run when you open root. // - // Just place it in your home directory and it works automatically. // - // If you make a change to this file simply start // - // a new root session and the changes will be implemented. // - // // - // If you did not install roofit then there will be an error // - // message when you login, it can be ignored. // - // // - //////////////////////////////////////////////////////////////////////////// - - // Definition of new styles - TStyle *Nab_collaboration = new TStyle("RadHard_AutoTitle","How we like it"); - TStyle *Nab_collaboration_work = new TStyle("RadHard_NoTitle","How we like it without title"); - - // Set the default parameters for style Nab_collaboration - Nab_collaboration->SetCanvasBorderMode(0); // Removes Canvas Border - Nab_collaboration->SetPadBorderMode(0); // Removes Pad Border - Nab_collaboration->SetCanvasColor(0); // Changes Canvas color to white - Nab_collaboration->SetPadColor(0); // Changes Pad color to white - Nab_collaboration->SetStatColor(0); // Changes Stats bg color to white - Nab_collaboration->SetTitleFillColor(0); // Changes Title bg color to white - Nab_collaboration->SetLabelFont(42,"xyz"); // Changes Label Font - Nab_collaboration->SetTitleFont(42,"xyz"); // Changes Axis Title Font - Nab_collaboration->SetPadTickX(1); // Sets tic marks on both horizontal axes - Nab_collaboration->SetPadTickY(1); // Sets tic marks on both vertical axes - Nab_collaboration->SetTickLength(0.018,"xyz"); // Sets tic length - Nab_collaboration->SetOptStat(0); // Turns off Statistics display - Nab_collaboration->SetOptTitle(-1); // Turns off Title display - Nab_collaboration->SetHistLineWidth(2); // Changes Histogram Line width - Nab_collaboration->SetFrameBorderMode(0); // Removes the Frame Border - Nab_collaboration->SetFrameFillStyle(0); - Nab_collaboration->SetCanvasDefH(494); // Sets Default Canva Height - Nab_collaboration->SetCanvasDefW(800); // Sets Default Canvas Width - Nab_collaboration->SetPalette(1); - - - // The next for commands set the default margin size - // n.b. the margins do not take axis labels into account! grr!! - Nab_collaboration->SetPadTopMargin(0.1); // Set Margin Top - Nab_collaboration->SetPadRightMargin(0.1); // Set Margin Right - Nab_collaboration->SetPadBottomMargin(0.1); // Set Margin Bottom - Nab_collaboration->SetPadLeftMargin(0.1); // Set Margin Left - - //make a nice palette - int NRGBs = 7, NCont = 999; - Nab_collaboration->SetNumberContours(NCont); - Double_t stops[7] = { 0.00, 0.10, 0.25, 0.45, 0.60, 0.75, 1.00 }; - Double_t red[7] = { 1.00, 0.00, 0.00, 0.00, 0.97, 0.97, 0.10 }; - Double_t green[7] = { 1.00, 0.97, 0.30, 0.40, 0.97, 0.00, 0.00 }; - Double_t blue[7] = { 1.00, 0.97, 0.97, 0.00, 0.00, 0.00, 0.00 }; - TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); - - // Make Nab_collaboration_work a copy of Nab_collaboration and remove stats - Nab_collaboration->Copy(*Nab_collaboration_work); - //Nab_collaboration_work->SetOptStat(1); - Nab_collaboration_work->SetOptTitle(0); - Nab_collaboration_work->SetPadTopMargin(0.1); - Nab_collaboration_work->SetPadRightMargin(0.1); - - // Select Which Style to - gROOT->SetStyle("RadHard_AutoTitle"); - // gROOT->SetStyle("Nab_Collaboration"); - - - // Use the RooFit functions - // using namespace RooFit; - - // Force Root to run Nab_collaboration/Nab_collaboration_work style - gROOT->ForceStyle(); - -} diff --git a/MABS_run_analyzer/help.h b/MABS_run_analyzer/help.h index bdfd649..e31691a 100644 --- a/MABS_run_analyzer/help.h +++ b/MABS_run_analyzer/help.h @@ -1,6 +1,9 @@ #ifndef HELP_H #define HELP_H +#include +#include + #include #include #include @@ -10,23 +13,27 @@ #include #include #include -#include // std::sort - -#include "TStopwatch.h" +#include // sort +#include #include #include #include #include #include #include +#include +#include + #include "TThread.h" +#include "HistogramType.h" -#define MAXHITS 1000000 -#define MAXPIXELS 100000 +#define MAXHITS 1000000 +#define MAXPIXELS 100000 +using namespace std; //#################################################################### @@ -37,7 +44,6 @@ * One example of such a constant are the colors for the console * */ - Int_t print_progress(Float_t ProgressInPercent) { Int_t nCharacter = printf("\r ["); @@ -45,13 +51,13 @@ Int_t print_progress(Float_t ProgressInPercent) { for( iBlock=0; iBlockClone(newname); + // TH1FO *newTH1FO = (TH1FO *)newTObject; + // newTH1FO->itsHistogramType = this->itsHistogramType; + // return newTH1FO; + // } + // + // Overload = operator + TH1FO operator=(const TH1FO &h1) { + TH1FO h2; + h2 = h1; + h2.itsHistogramType = h1.itsHistogramType; + return h2; + }; + TH1FO& operator=(const TH1F &h1); +}; /** @@ -229,7 +260,7 @@ struct labbooksctruct TString matrix = ""; /// ionizing radiation dose of the measured chip in MRad Float_t radDoseIon = -1; - /// non-ionizing radiation dose of the chip in \f$ 10^{10} \frac{\text{neq}}{\text{cm}^2} \f$ + /// non-ionizing radiation dose of the chip in \f$ 10^{10} \frac{neq}{cm^2} \f$ Float_t radDoseNonIon = -1; /// position of th seed peak found in the database in ADU for this specific run Float_t posSeedDB = -1; @@ -293,35 +324,6 @@ struct pixelinfo /// TODO: add more }; -void preparecanvas() { -// TCanvas* canvas = new TCanvas("Canvas1", 700, 500); -// histogram->SetTitle(titlestr); -// histogram->SetLineStyle(rootlinestyle[plotStyle]); -// histogram->SetLineColor(rootcolors[plotStyle]); -// histogram->SetLineWidth(3); -// histogram->Draw(); -// TLegend* leg = new TLegend(0.5,0.8,0.89,0.89);//(0.6,0.7,0.89,0.89); -// leg->SetFillColor(0); -// leg->SetBorderSize(0); -// if (legendstr.Length() < 1) -// legendstr = humanreadablestr; -// leg->AddEntry(histogram, legendstr, "l"); -// -// leg->SetTextSize(0.03); -// leg->Draw(); -// -// canvas -> SaveAs( savepathresults + "/" + runcode + " " + histogram->GetName() + ".eps"); -// -// TImage *img = TImage::Create(); -// img->FromPad(canvas); -// img->WriteImage(savepathresults + "/" + runcode + " " + histogram->GetName() + ".png"); -// -// TFile *f = new TFile(savepathresults + "/" + runcode + " " + histogram->GetName() + ".root","UPDATE"); -// f->WriteTObject(canvas); -// f->WriteTObject(img); -// return 0; -} - void MSaveBigPNG(TCanvas* old_canv, TString filename="", double scale=1) { gROOT->SetBatch(kTRUE); // gROOT->ForceStyle(kTRUE); @@ -361,8 +363,9 @@ void MSaveBigPNG(TCanvas* old_canv, TString filename="", double scale=1) { gStyle->SetLineWidth(orig_lt); gStyle->SetHistLineWidth(orig_lt); gStyle->SetFuncWidth(orig_lt); + - if (!isBatch) { + if (!(gROOT->IsBatch())) { // gROOT->ForceStyle(kFALSE); gROOT->SetBatch(kFALSE); } @@ -568,65 +571,6 @@ void removeForbiddenChar(TString* s) } } -void *sortThread(void *ptr) -{ -// TStopwatch timer; -// args_t *args = (args_t *)ptr; -// timer.Start(); -// TThread::Lock(); -// TGraph *gr = new TGraph(); -// TThread::UnLock(); -// gr->SetMarkerStyle(20); -// gr->SetMarkerSize(0.7); -// gr->SetMarkerColor(args->color); -// gr->SetLineColor(args->color); -// gr->SetLineWidth(2); -// -// Int_t k = 0; -// Double_t diffpi; -// Long64_t npi = 0; -// Double_t pi = TMath::Pi(); -// const Int_t NR = 20000; -// const Int_t NR2 = NR/2; -// Double_t rn[NR]; -// Long64_t i = 0; -// while (i<=args->n) { -// i += NR2; -// args->r->RndmArray(NR,rn); -// for (Int_t j=0;jSetPoint(k,i,diffpi); -// if (k ==0) { -// TThread::Lock(); -// gr->Draw("lp"); -// TThread::UnLock(); -// } -// c1->Modified(); -// c1->Update(); -// k++; -// } -// // yield execution to another thread that is ready to run -// // MSDN : -// // Sleep(0) causes the thread to relinquish the remainder of its -// // time slice to any other thread of equal priority that is ready to run. -// // If there are no other threads of equal priority ready to run, -// // the function returns immediately, and the thread continues execution. -// gSystem->Sleep(0); -// } -// timer.Stop(); -// Double_t cpu = timer.CpuTime(); -// cputot += cpu; -// Double_t nanos = 1.e9*cpu/Double_t(args->n); -// legend->AddEntry(gr,Form("%-14s: %6.1f ns/call",args->name,nanos),"lp"); -// c1->Modified(); -// c1->Update(); -// TThread::Printf("RANDOM = %s : RT=%7.3f s, Cpu=%7.3f s\n",args->name,timer.RealTime(),cpu); - return 0; -} //#################################################################### #endif