]> jspc29.x-matter.uni-frankfurt.de Git - radhard.git/commitdiff
Analyzer: Reorganized code, better result paths
authorBenjamin Linnik <blinnik@jspc61.x-matter.uni-frankfurt.de>
Mon, 13 Nov 2017 14:11:49 +0000 (15:11 +0100)
committerBenjamin Linnik <blinnik@jspc61.x-matter.uni-frankfurt.de>
Mon, 13 Nov 2017 14:11:49 +0000 (15:11 +0100)
MABS_run_analyzer/ChargeSpektrum.c
MABS_run_analyzer/ChargeSpektrumFunctions.c
MABS_run_analyzer/Run.c
MABS_run_analyzer/help.h

index 71f7107efff1ef170e404419cdc948673a5a5975..0dd2d86cb51ca2cf1ff99869b3861391ec892a84 100644 (file)
@@ -29,13 +29,12 @@ void ChargeSpektrum(TString runnumber = "")
     
     numberRuns=0;
     std::vector<int> runList;
-    TString analysisis; // what kind of analyse to make, can be more than one
     std::vector<Bool_t> runListForceAnalysis;
     std::vector<TString> runListCustomTitle;
     std::vector<TString> sumuprunList; // not used yet, add runs to each other, combine statistics
     
     #include "SetStyle.c"
-    InterpreteUserInput(runnumber, &runList, &runListForceAnalysis, &runListCustomTitle, &sumuprunList, &analysisis);
+    InterpreteUserInput(runnumber, &runList, &runListForceAnalysis, &runListCustomTitle, &sumuprunList, &analysisType);
     runs = new Run*[numberRuns];
     
     // set file path and other variables to be set
@@ -88,7 +87,10 @@ void ChargeSpektrum(TString runnumber = "")
             runs[runi] = new Run(runList[runi], runi);
             if (!runs[runi]->error)
             {
-                runs[runi]->setResultsPath(savepathresults);
+                vector<TH1FO*> CompareHistogramVector;
+                CompareHistogramVector.push_back(runs[runi]->histogram->Seed);
+                FindGoodTitle(&CompareHistogramVector);
+                runs[runi]->setResultsPath(savepathresults + folderadd);
                 runs[runi]->error=runs[runi]->initRun();
                 runs[runi]->setDynamicalNoiseMode("simple");
                 runs[runi]->useDynamicalNoise(true);
@@ -107,7 +109,7 @@ void ChargeSpektrum(TString runnumber = "")
              //runs[runi]->setNoisethresholdborderE(220);
 //                 runs[runi]->analyzeFrame(680);
 //                   continue;
-               runs[runi]->setFixedThresholdValueADU(30);
+//             runs[runi]->setFixedThresholdValueADU(30);
                     
 
                 // creates or opens .root file, can analyze the RAW data
@@ -141,13 +143,13 @@ void ChargeSpektrum(TString runnumber = "")
                     
                     // use only lower case when matching anaylsis types
                     
-                    if (analysisis.Contains("clas")) { // classic analysis
+                    if (analysisType.Contains("clas")) { // classic analysis
                         compareHistogramClassVectorClassic.push_back(runs[runi]->histogram->normalized);
                         if (runi+1 == runnumber)
                             compareHistogramClassVectorVector.push_back(compareHistogramClassVectorClassic);
                     }           
                     
-                    if (analysisis.Contains("dynthresh") || analysisis.Contains("dynamicalthresh")) { // fixed threshold analysis
+                    if (analysisType.Contains("dynthresh") || analysisType.Contains("dynamicalthresh")) { // fixed threshold analysis
                         vector<HistogramType*> compareHistogramClassVectorDynamicalThreshold;
                         compareHistogramClassVectorDynamicalThreshold.push_back(runs[runi]->histogram);
                         compareHistogramClassVectorDynamicalThreshold.push_back(runs[runi]->histogramdynamicalthreshold);
@@ -155,17 +157,17 @@ void ChargeSpektrum(TString runnumber = "")
                         compareHistogramClassVectorDynamicalThreshold.clear();
                     }   
                     
-                    if (analysisis.Contains("cali")) { // calibrated analysis
+                    if (analysisType.Contains("cali")) { // calibrated analysis
                         compareHistogramClassVectorCalibrated.push_back(runs[runi]->histogram->calibrated->normalized);
                         if (runi+1 == runnumber)
                             compareHistogramClassVectorVector.push_back(compareHistogramClassVectorCalibrated);
                     }  
                     
-                    if (analysisis.Contains("signal")) { // F0 analysis for some frames, quantitatively
+                    if (analysisType.Contains("signal")) { // F0 analysis for some frames, quantitatively
                         runs[runi]->processed->plotSignal(100,1000);
                     } 
                     
-                    if (analysisis.Contains("depl")) { // depletion analysis
+                    if (analysisType.Contains("depl")) { // depletion analysis
                         compareHistogramVectorDepletion.push_back(runs[runi]->histogramdynamicalthreshold->normalized->SeedPerc);
                                                
                         datainputPosVeto->itsHistogramType = runs[runi]->histogramdynamicalthreshold;
@@ -176,18 +178,16 @@ void ChargeSpektrum(TString runnumber = "")
                             ntupleVectorDepltetion1.push_back(datainputPosVeto); 
                             ntupleVectorVector.push_back(ntupleVectorDepltetion1);
                         }
-                                               
+                        
                         prop2ndpixelfire->itsHistogramType = runs[runi]->histogramdynamicalthreshold;
                         prop2ndpixelfire->xaxisTitle = "Voltage";
                         prop2ndpixelfire->yaxisTitle = "Propability for second pixel to fire";
                         prop2ndpixelfire->Fill(runs[runi]->labbook.depletionV,runs[runi]->histogramdynamicalthreshold->clustermultiplicity->GetBinContent(2),0,0);
-                        cout << colorcyan << " Cluster Mult.:" << runs[runi]->histogramdynamicalthreshold->clustermultiplicity << endlr;
                         if (runi+1 == runnumber) {
                             ntupleVectorDepltetion2.push_back(prop2ndpixelfire);
                             ntupleVectorVector.push_back(ntupleVectorDepltetion2);
                         }
                         
-                        
                         Double_t AverageCharge[9];
                         Double_t TotalHits[9];
                         for (UInt_t sumi = 0; sumi < 9; sumi++) {
@@ -218,7 +218,7 @@ void ChargeSpektrum(TString runnumber = "")
                         }
                     }
                     
-                    if (analysisis.Contains("rts")) { // rts studies                        
+                    if (analysisType.Contains("rts")) { // rts studies                        
                         vector<HistogramType*> compareHistogramClassVectorRTS;                        
                         compareHistogramClassVectorRTS.push_back(runs[runi]->histogramwoRTS);
                         compareHistogramClassVectorRTS.push_back(runs[runi]->histogram);
@@ -238,7 +238,7 @@ void ChargeSpektrum(TString runnumber = "")
                         }
                     }
                     
-                    if (analysisis.Contains("seedf")) { // seedfit: seed integral anaylsis
+                    if (analysisType.Contains("seedf")) { // seedfit: seed integral anaylsis
                         runs[runi]->plot1DHistogram( runs[runi]->histogram->normalized->Seed, "gaus", true, false, false, runs[runi]->histogram->fixedThresholdValue);
                         runs[runi]->plot1DHistogram( runs[runi]->histogramdynamicalthreshold->normalized->Seed, "gaus", true, false, false, runs[runi]->histogram->fixedThresholdValue);
                         
@@ -258,7 +258,7 @@ void ChargeSpektrum(TString runnumber = "")
                         }
                     }
                     
-                    if (analysisis.Contains("sumf")) { // seedfit: seed integral anaylsis
+                    if (analysisType.Contains("sumf")) { // seedfit: seed integral anaylsis
                         runs[runi]->plot1DHistogram(*(runs[runi]->histogram->normalized->Sum), "gaus", true, false, false, runs[runi]->histogram->fixedThresholdValue);
                         runs[runi]->plot1DHistogram(*(runs[runi]->histogramdynamicalthreshold->normalized->Sum), "gaus", true, false, false, runs[runi]->histogram->fixedThresholdValue);
                         
@@ -278,7 +278,7 @@ void ChargeSpektrum(TString runnumber = "")
                         }                 
                     }
                     
-                    if (analysisis.Contains("cluster")) { // analyze cluster formation
+                    if (analysisType.Contains("cluster")) { // analyze cluster formation
                         // show cluster multiplicity
                         compareHistogramVectorClusterMultiplicity.push_back(runs[runi]->histogram->normalized->clustermultiplicity);
 //                         runs[runi]->plot1DHistogram( runs[runi]->histogram->clustermultiplicity);                        
@@ -352,7 +352,7 @@ void ChargeSpektrum(TString runnumber = "")
                         
                     }
                     
-                    if (analysisis.Contains("temp")) { // analyze temperatur dependance
+                    if (analysisType.Contains("temp")) { // analyze temperatur dependance
                         compareHistogramClassVectorTemp.push_back(runs[runi]->histogramfixedthreshold->normalized);
                         
                         Double_t AverageChargeTempSeed = 0;
@@ -388,7 +388,7 @@ void ChargeSpektrum(TString runnumber = "")
                                     
                     }
                                         
-                    if (analysisis.Contains("f0")) { // analyze cluster formation
+                    if (analysisType.Contains("f0")) { // analyze cluster formation
                         // Plot F0 signal
                         vector<TH1FO*> compareHistogramVectorF0;
                         compareHistogramVectorF0.push_back(runs[runi]->averageF0DistrEnd);
index db281ea00a3243e506b31f2ddd725b5f166d0fe5..4a18cb318f8fc6c82bc9ad8ddcf3dda18249010e 100644 (file)
@@ -70,7 +70,7 @@ Bool_t writeOneHistogramTypeToFile(vector<HistogramType*>*);
 /** @brief A function to setup file path and other variables
  *     
  */
-void Init();
+void Init(TString);
 
 
 /** @brief A function to plot ntuplöe data into a canvas
@@ -106,6 +106,7 @@ vector< vector<TH1FO*> >  compareHistogramVectorVector;
 vector< vector<TNtupleO*> >  ntupleVectorVector;
 TString ownpath = "";
 TString savepathresults;
+TString analysisType = "";
 
 void setCustomPath(TString setOwnpath)
 {
@@ -128,9 +129,9 @@ void ChargeSpektrum(Int_t runnumber, Int_t runnumber2)
 
 void Init()
 {
-    //FindGoodTitle();
+//     FindGoodTitle();
     TTimeStamp timestamp = TTimeStamp();
-    savepathresults = Form("./results/%d%06d", (int)timestamp.GetDate(kFALSE), (int)timestamp.GetTime(kFALSE));
+    savepathresults = Form("./results/%d%06d %s", (int)timestamp.GetDate(kFALSE), (int)timestamp.GetTime(kFALSE), analysisType.Data());
     
 }
 
@@ -387,7 +388,7 @@ Bool_t writeNTupleVectorToFile(std::vector<TNtupleO*>* ntuplepvectorpointer)
     {
         if (ntuplepvectorpointer->size() > 0) {
             TNtupleO* ntuplepointer = ntuplepvectorpointer->at(0);
-            system("mkdir "+ savepathresults + folderadd + "/" + " -p");
+            system("mkdir \""+ savepathresults + folderadd + "/\"" + " -p");
             TString filename = savepathresults + folderadd + "/" + Form("Observable_%s.dat", ntuplepointer->GetName());
             
             TString header = "";
@@ -430,7 +431,7 @@ Bool_t writeOneHistogramTypeToFile(vector<HistogramType*>* ptCompareHistogramCla
 {
     if (ptCompareHistogramClassVector->size() > 0)
     { 
-        system("mkdir "+ savepathresults + folderadd + "/" + " -p");
+        system("mkdir \""+ savepathresults + folderadd + "/\"" + " -p");
         
         TString filename = Form("%s%s/Spectrum_%d_%s", savepathresults.Data(),  folderadd.Data(), ptCompareHistogramClassVector->at(0)->labbook->runnumber, ptCompareHistogramClassVector->at(0)->histogramdescription.Data());
         
@@ -481,7 +482,7 @@ Bool_t writeObservableToFile(vector<TH1FO*>* ptCompareHistogramVector)
 {
     if (numberRuns>0)
     {
-        system("mkdir "+ savepathresults + folderadd + "/" + " -p");
+        system("mkdir \""+ savepathresults + folderadd + "/\"" + " -p");
         
         TString filename = savepathresults + folderadd + "/Spectra";
         TString header = "";
@@ -1272,6 +1273,8 @@ Bool_t FindGoodTitle(vector<HistogramType*>* ptCompareHistogramClassVector, vect
         for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++)
             folderadd.Append(Form(" %.2fMhz", ptCompareHistogramClassVector->at(histogrami)->labbook->clock)); 
         
+    removeForbiddenChar(&folderadd);
+        
     system("mkdir \""+ savepathresults + folderadd + "/\"" + " -p");
 //     cout << colorred << savepathresults << folderadd << endlr;
     
index bc0b94c1b9610e3e9c52f106c940ff87df4be5a1..c92aaec32d94509fbf7440cf18b61d6ae72796de 100644 (file)
@@ -369,7 +369,7 @@ Bool_t Run::setFixedThresholdValueADU(HistogramType* HistogramTypepointer, Float
 Bool_t Run::setResultsPath(TString path)
 {
     cout << "Changing save directory to '" << path << "'" << endl;
-    if (system("mkdir '"+ path + "' -p"))
+    if (system("mkdir \""+ path + "\" -p"))
     {
         cout << "\033[1;31mError changing directory, save path is: '\033[1;37m" << savepathresults << "\033[1;31m'\033[0m" << endl;
         return 1;
@@ -2447,7 +2447,7 @@ TCanvas* Run::plot1DHistogram(HistogramType* HistogramTypepointer, TH1FO* onehis
 
 Bool_t Run::writeHistogramToFile(TH1F* onehistogram)
 {
-    system("mkdir "+ savepathresults + " -p");
+    system("mkdir \""+ savepathresults + "\" -p");
     TString filename= savepathresults + "/" + runcode + " " + onehistogram->GetName() + " hist.dat";
     fstream* fout = new fstream(filename,ios::out);        
     
@@ -2466,7 +2466,7 @@ Bool_t Run::writeHistogramToFile(TH1F* onehistogram)
 
 Bool_t Run::write2DHistogramToFile(TH2F* onehistogram)
 {
-    system("mkdir "+ savepathresults + " -p");
+    system("mkdir \""+ savepathresults + "\" -p");
     TString filename= savepathresults + "/" + runcode + " " + onehistogram->GetName() + " hist.dat";
     fstream* fout = new fstream(filename,ios::out);        
     
@@ -2487,7 +2487,7 @@ Bool_t Run::write2DHistogramToFile(TH2F* onehistogram)
 
 Bool_t Run::writeAllHistogramsToFile()
 {
-    system("mkdir "+ savepathresults + " -p");
+    system("mkdir \""+ savepathresults + "\" -p");
     TString filename= savepathresults + "/" + runcode + " histograms.dat";
     fstream* fout = new fstream(filename,ios::out);
     
@@ -2543,7 +2543,7 @@ Bool_t Run::writeAllHistogramsToFile()
 
 void Run::MakeGnuplotFile()
 {
-    system("mkdir "+ savepathresults + " -p");
+    system("mkdir \""+ savepathresults + "\" -p");
     TString filename= savepathresults + "/" + runcode+"_gnuplot.plt";
     fstream* fout = new fstream(filename,ios::out);
     
index 4fc72e72604be856b2cf34d7203a31fe8004804c..910038d71cb3786e0dc0bed772fc28167972fd70 100644 (file)
@@ -557,6 +557,17 @@ TH1F * ShowOverflow(TH1F *h)
 
 bool compareFloatvalues (Float_t i,Float_t j) { return (i<j); }
 
+/** @brief removes charackters not allowed in filenames
+ * 
+ */
+void removeForbiddenChar(TString* s)
+{
+    string illegalChars = "\\/:?\"<>|";  
+    for (string::iterator it = illegalChars.begin() ; it < illegalChars.end() ; ++it){
+        s->ReplaceAll(*it, ' ');
+    }
+}
+
 void *sortThread(void *ptr) 
 {
 //     TStopwatch timer;