]> jspc29.x-matter.uni-frankfurt.de Git - radhard.git/commitdiff
Run analyzer: Added routine writeObservableToFile() and the vector compareHistogramVe...
authorBenjamin Linnik <blinnik@jspc28.x-matter.uni-frankfurt.de>
Mon, 21 Sep 2015 15:00:29 +0000 (17:00 +0200)
committerBenjamin Linnik <blinnik@jspc28.x-matter.uni-frankfurt.de>
Mon, 21 Sep 2015 15:00:29 +0000 (17:00 +0200)
MABS_run_analyzer/ChargeSpektrum.c
MABS_run_analyzer/ChargeSpektrumFunctions.c
MABS_run_analyzer/HistogramType.c
MABS_run_analyzer/HistogramType.h
MABS_run_analyzer/Run.c
MABS_run_analyzer/Run.h

index 316b814fa1e7061dca71d8be307d0c788aa4d89e..9029615ef043f250b49e077e1d6c32bc634d410a 100644 (file)
@@ -153,6 +153,7 @@ void ChargeSpektrum(TString runnumber = "")
                     runs[runi]->plot1DHistogram(runs[runi]->histogram->calibrated, runs[runi]->histogram->Seed, "landau");
                     runs[runi]->plot1DHistogram(runs[runi]->histogram->calibrated, runs[runi]->histogram->calibrated->Seed, "landau");
                     compareHistogramClassVector.push_back(runs[runi]->histogram->calibrated);
+                    compareHistogramVector.push_back(runs[runi]->histogram->Seed);
 //                     runs[runi]->integrateSr90Spectra(&runs[runi]->histogramfixedthresholdCalibrated, runs[runi]->histogramfixedthresholdCalibrated.Seed, 0); 
 //                     runs[runi]->plot1DHistogram(&runs[runi]->histogramfixedthresholdCalibrated, runs[runi]->histogramfixedthresholdCalibrated.Seed, "landau");
 //                     runs[runi]->plot1DHistogram(&runs[runi]->histogramthresholdCalibrated, runs[runi]->histogramthresholdCalibrated.Seed, "landau");
@@ -170,6 +171,7 @@ void ChargeSpektrum(TString runnumber = "")
         }
     }
     plotAllRuns();
+    writeObservableToFile();
 //     plotAllRuns("seed threshold calibrated");
 //     setCustomPath("Excel/");
 //     writeObservableToFile("seed threshold calibrated");
index 9362888fdf24baa970739861501cf044b7c783bf..eabe580ee3847a0ce02462c23d27856d1b36da1c 100644 (file)
 Int_t* ReadRunList();
 Int_t ReadRunList(std::vector<int>*);
 Bool_t plotAllRuns();
-Bool_t plotAllRuns(TString);
-Bool_t writeObservableToFile(TString);
+/** @brief A function to plot TH1F histograms of different runs into one file
+ * 
+ * You push in #ChargeSpectrum.c a pointer of the type TH1F into the vector #compareHistogramVector and then 
+ * you can compare different histograms of the different runs.
+ * 
+ * Call #writeObservableToFile() in #ChargeSpectrum.c to create a file with all the TH1F histogram data
+ *     
+ */
 Bool_t writeObservableToFile();
-void writeObservableToFileHistSelect(TString);
 /** @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 
@@ -23,6 +28,7 @@ void writeObservableToFileHistSelect(TString);
  *     
  */
 vector<HistogramType*> compareHistogramClassVector;
+vector<TH1F*> compareHistogramVector;
 
 TString ownpath = "";
 
@@ -68,113 +74,45 @@ Int_t ReadRunList(std::vector<int>* runlist)
 }
 
 
-// void plotNoiseComparison()
-// {
-//     
-// }
-
-Bool_t writeObservableToFile(TString histogramtype)
-{
-    if (histogramtype.Contains("threshold"))
-    {
-        if (histogramtype.Contains("calibrated"))
-        {
-            for(Int_t runi=0;runi<numberRuns;runi++)/* loop over runs read from file */
-            {
-                if (runs[runi]->histogramthreshold->iscalibrated)
-                    runs[runi]->plothistogramclasspointer = runs[runi]->histogramthreshold->calibrated;
-                else
-                    return 1;
-            }
-        }
-        else
-        {
-            for(Int_t runi=0;runi<numberRuns;runi++)/* loop over runs read from file */ 
-                runs[runi]->plothistogramclasspointer = runs[runi]->histogramthreshold;
-        }
-        
-    }
-    else if (histogramtype.Contains("calibrated") || histogramtype.Contains("electron")) {
-        for(Int_t runi=0;runi<numberRuns;runi++) /* loop over runs read from file */ {
-            if (runs[runi]->histogram->iscalibrated)
-                runs[runi]->plothistogramclasspointer = runs[runi]->histogram->calibrated;
-            else return 1;        } }
-            else {
-                for(Int_t runi=0;runi<numberRuns;runi++) /* loop over runs read from file */ {
-                    runs[runi]->plothistogramclasspointer = runs[runi]->histogram; } }
-                    writeObservableToFileHistSelect(histogramtype);
-                    return 0;
-}
-void writeObservableToFileHistSelect(TString histogramtype)
-{
-    if (histogramtype.Contains("Seed") || histogramtype.Contains("seed")) {
-        for(Int_t runi=0;runi<numberRuns;runi++)/* loop over runs read from file */ {
-            runs[runi]->plothistogrampointer = runs[runi]->plothistogramclasspointer->Seed; } }
-            else if (histogramtype.Contains("Sum") || histogramtype.Contains("sum")) {
-                for(Int_t runi=0;runi<numberRuns;runi++)/* loop over runs read from file */ {
-                    runs[runi]->plothistogrampointer = runs[runi]->plothistogramclasspointer->Sum; } }
-                    else if (histogramtype.Contains("Veto") || histogramtype.Contains("veto")) {
-                        for(Int_t runi=0;runi<numberRuns;runi++) /* loop over runs read from file */ {
-                            runs[runi]->plothistogrampointer = runs[runi]->plothistogramclasspointer->Veto; } }
-                            else {
-                                for(Int_t runi=0;runi<numberRuns;runi++) /* loop over runs read from file */ {
-                                    runs[runi]->plothistogrampointer = runs[runi]->plothistogramclasspointer->Seed; } }
-                                    writeObservableToFile();
-}
-
 Bool_t writeObservableToFile()
 {
-    system("mkdir "+ runs[0]->savepathresults + " -p");
-    TString headerInfo = "";
-    for(Int_t runi=0;runi<numberRuns;runi++) // loop over runs read from file
-    {
-        headerInfo+=runs[runi]->runcode+"\t\t\t";
-    }
-    TH1F* plothistogrampointer = runs[0]->plothistogrampointer;
-    TString runnumberListe="";
-    TString header="";
-    for(Int_t runi=0;runi<numberRuns;runi++) // loop over runs read from file
-    {
-        if (runs[runi] != nullptr)
-        {
-            if (!runs[runi]->error)
-            {
-                plothistogrampointer = runs[runi]->plothistogrampointer;
-                runnumberListe+=Form("%d_",runs[runi]->labbook.runnumber);
-                header+=Form("%d\t%s\t\t\t", runs[runi]->labbook.runnumber, plothistogrampointer->GetName());
-            }
-        }
-    }
-    TString filename= runs[0]->savepathresults + "/" + ownpath + runnumberListe + Form("%s",plothistogrampointer->GetName())+"histograms.dat";
-       fstream* fout = new fstream(filename,ios::out);
-    *fout << headerInfo << endl;
-    *fout << header << endl;
-    for(Int_t bini=0;bini<plothistogrampointer->GetNbinsX();bini++)
+    if (numberRuns>0)
     {
+        system("mkdir "+ runs[0]->savepathresults + " -p");
+        
+        TString filename = runs[0]->savepathresults + "/Spectra";
+        TString header = "";
         for(Int_t runi=0;runi<numberRuns;runi++) // loop over runs read from file
         {
             if (runs[runi] != nullptr)
             {
                 if (!runs[runi]->error)
                 {
-                    plothistogrampointer = runs[runi]->plothistogrampointer;
-                    TString outline;
-                                       Double_t binContentNorm=plothistogrampointer->GetBinContent(bini)/runs[runi]->labbook.frames_foundDB*10000000;
-                                       Double_t binSumme=0.0;
-                                       for(Int_t binSummei=bini;binSummei<plothistogrampointer->GetNbinsX();binSummei++)//Sum up from bini beginning (cut condition for detection eff.)
-                                       {
-                                               Double_t binContentNormInSumme=plothistogrampointer->GetBinContent(binSummei)/runs[runi]->labbook.frames_foundDB*10000000;
-                                               binSumme=binSumme+binContentNormInSumme;
-                                       }
-                                       outline=Form("%.1f\t%.1f\t%.1f\t%.1f\t",plothistogrampointer->GetBinCenter(bini),plothistogrampointer->GetBinContent(bini),binContentNorm,binSumme);
-                    *fout<<outline;
+                    filename+= Form("_%d",runs[runi]->labbook.runnumber);
+                    header  += Form("#%s %lu frames\n", runs[runi]->runcode.Data(), runs[runi]->frames_found);
                 }
             }
         }
-        *fout<<endl;
-    }
-    fout->close();
-    
+        filename+=".dat";
+        fstream* fout = new fstream(filename,ios::out);
+        header += Form("#");
+        for (vector<TH1F*>::iterator curHistogram = compareHistogramVector.begin(); curHistogram != compareHistogramVector.end(); curHistogram++)  {
+            header += Form("bin\t%s\t",(*curHistogram)->GetName());
+        }
+        *fout << header << endl;
+        TString outline;
+        for(Int_t bin=1;bin<=runs[0]->cursystemparam.nbins;bin++)
+        {
+            outline ="";
+            for (vector<TH1F*>::iterator curHistogram = compareHistogramVector.begin(); curHistogram != compareHistogramVector.end(); curHistogram++)  {
+                outline+=Form("%.1f\t%.1f\t", (*curHistogram)->GetBinCenter(bin), (*curHistogram)->GetBinContent(bin));
+            }
+            *fout<<outline<<endl;
+        }
+        fout->close();
+        return 0;
+        
+    }    
     return 0;
 }
 
index 1402d7dc63fb65823c1d88ce356a94676102446f..590d37f91c6721c763307f18b8fea292f4edaed0 100644 (file)
@@ -19,10 +19,11 @@ HistogramType::~HistogramType( void) {
     
 }
 
-HistogramType::HistogramType(TString suffix, systemparam* gotsystempar, sensorinfostruct* gotsensorinfo, TString gothumanreadablestr, Int_t gotcolor, Int_t gotstyle ) {
+HistogramType::HistogramType(TString suffix, systemparam* gotsystempar, sensorinfostruct* gotsensorinfo, TString gothumanreadablestr, Int_t gotrunnumber, Int_t gotcolor, Int_t gotstyle ) {
     histogramdescription = suffix;
     humanreadablestr = gothumanreadablestr;
     cursystempar = gotsystempar;
+    runnumber = gotrunnumber;
     cursensorinfo = gotsensorinfo;
     initHistograms(gotcolor, gotstyle);
 };
@@ -48,7 +49,7 @@ void HistogramType::initHistograms(Int_t gotcolor, Int_t gotstyle) {
 }
 
 void HistogramType::initHistogram(TH1F* &histogrampointer, TString prefix, Int_t color, Int_t style) {
-    histogrampointer=new TH1F(prefix.Data(), Form("%s, %s",prefix.Data(), humanreadablestr.Data()), cursystempar->nbins, 0, cursystempar->maxbin);  
+    histogrampointer=new TH1F(Form("%d %s",runnumber, prefix.Data()), Form("%s, %s",prefix.Data(), humanreadablestr.Data()), cursystempar->nbins, 0, cursystempar->maxbin);  
     histogrampointer->SetLineStyle(style);
     histogrampointer->SetLineColor(color);
     histogrampointer->SetStats(kTRUE);        
index c6f542abd43ff6d6ee1c173af0e401f98fe505b3..ac60cc084daa2d41618b79cb8817e20e5333eddf 100644 (file)
@@ -90,7 +90,7 @@ public:
     
     ~HistogramType(void);
     /** @brief constructor */
-    HistogramType(TString suffix, systemparam* gotsystempar, sensorinfostruct* gotsensorinfo, TString gothumanreadablestr, Int_t gotcolor=0, Int_t gotstyle=0);
+    HistogramType(TString suffix, systemparam* gotsystempar, sensorinfostruct* gotsensorinfo, TString gothumanreadablestr="", Int_t gotrunnumber=0, Int_t gotcolor=0, Int_t gotstyle=0);
         
     //*****************
     // TH HISTOGRAMS 
@@ -149,6 +149,8 @@ public:
     //*****************
     /// A string representing the current run database information in a human readable format
     TString humanreadablestr="";
+    /// Runnumber provided by Run.c from the database, used for names of histograms
+    Int_t runnumber = 0;
     /// type in here what the histogram is intended for or how it is calculated, will be added to filenames
     TString histogramdescription = "";    
     /// The gain used to rescale the histograms
index f5a3304a25e8cbe5053f6eefb07db50a238f5c85..ecb0af7d513db43a54bec2ba97da459ea675007e 100644 (file)
@@ -149,16 +149,16 @@ Run::Run(Int_t runnumber, Int_t loopi)
             
             cout << colorwhite << "init Histogram classes:" << endlr;
             // default histogram class, no special cuts applied
-            histogram = new HistogramType("", &cursystemparam, &cursensorinfo, humanreadablestr, rootcolors[plotStyle], rootlinestyle[plotStyle] );
+            histogram = new HistogramType("", &cursystemparam, &cursensorinfo, humanreadablestr, labbook.runnumber, rootcolors[plotStyle], rootlinestyle[plotStyle] );
             HistogramClassVector.push_back(histogram);
             // dynamical cluster threshold cut
-            histogramthreshold = new HistogramType(" Threshold", &cursystemparam, &cursensorinfo, humanreadablestr, rootcolors[plotStyle], rootlinestyle[plotStyle] );
+            histogramthreshold = new HistogramType(" Threshold", &cursystemparam, &cursensorinfo, humanreadablestr, labbook.runnumber, rootcolors[plotStyle], rootlinestyle[plotStyle] );
             HistogramClassVector.push_back(histogramthreshold);
             // fixed threshold cut
-            histogramfixedthreshold = new HistogramType(" fixed Threshold", &cursystemparam, &cursensorinfo, humanreadablestr, rootcolors[plotStyle], rootlinestyle[plotStyle] );
+            histogramfixedthreshold = new HistogramType(" fixed Threshold", &cursystemparam, &cursensorinfo, humanreadablestr, labbook.runnumber, rootcolors[plotStyle], rootlinestyle[plotStyle] );
             HistogramClassVector.push_back(histogramfixedthreshold);
             // dennis megacut
-            dennismegacut = new HistogramType(" Dennis Mega Cut", &cursystemparam, &cursensorinfo, humanreadablestr, rootcolors[plotStyle], rootlinestyle[plotStyle] );
+            dennismegacut = new HistogramType(" Dennis Mega Cut", &cursystemparam, &cursensorinfo, humanreadablestr, labbook.runnumber, rootcolors[plotStyle], rootlinestyle[plotStyle] );
             HistogramClassVector.push_back(dennismegacut);
             
             debugDBreadout();
index bfea9abd50a4dbe20de529aa9752b7703017e598..c71d41dd66b0b45134e8e5a334e3c67cf5a919b7 100644 (file)
@@ -121,10 +121,7 @@ private:
     u_int submatrix_y_start;
     /// If you set this variable to a value, #Run::binSeedSumVeto() and #Run::binCluster() will only account for hits in given range
     u_int submatrix_y_end;
-    
-    /// number of frames found in given folder
-    ULong_t frames_found = 0;
-    
+        
     /**
      * @brief Generates a human readable string with information about the run
      * 
@@ -372,6 +369,8 @@ public:
     TString storepathOutLinux = "/d/garlic/Mi34/rootFiles";
     /// path to the RAW files on LINUX systems
     TString savepathresults = ".";
+    /// number of frames found in given folder
+    ULong_t frames_found = 0;
     
     TFile* rootfile;
     
@@ -393,9 +392,7 @@ public:
     HistogramType* histogram;
     HistogramType* histogramthreshold;
     HistogramType* histogramfixedthreshold;
-    HistogramType* plothistogramclasspointer;
     HistogramType* dennismegacut;
-    TH1F* plothistogrampointer;
     /// 
     /** @brief A vector able to hold pointer of type #Run::histogramstruct
      *