]> jspc29.x-matter.uni-frankfurt.de Git - radhard.git/commitdiff
Analyzer: Restructuring, cleaning, bettering
authorBenjamin Linnik <blinnik@jspc61.x-matter.uni-frankfurt.de>
Thu, 5 Oct 2017 13:40:32 +0000 (15:40 +0200)
committerBenjamin Linnik <blinnik@jspc61.x-matter.uni-frankfurt.de>
Thu, 5 Oct 2017 13:40:32 +0000 (15:40 +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 19e523b67f70da465063243aeaeb4b980c159075..584f251b00204ec5e0313a36df1d66a9dd3e8242 100644 (file)
@@ -29,23 +29,26 @@ 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);
+    InterpreteUserInput(runnumber, &runList, &runListForceAnalysis, &runListCustomTitle, &sumuprunList, &analysisis);
     runs = new Run*[numberRuns];
     
     // set file path and other variables to be set
     Init();
     cout << "Found " << numberRuns << " run(s) in 'runlist.txt' or given as parameters." << endl;
-    TNtupleO *datainput2;
-    datainput2 =new TNtupleO("Position Veto", "data", "x:y:xerr:yerr");
+    TNtupleO *datainputPosVeto;
+    datainputPosVeto =new TNtupleO("Position Veto", "data", "x:y:xerr:yerr");
+    TNtupleO *datainputIntSeed;
+    datainputIntSeed =new TNtupleO("Integral Seed", "data", "x:y:xerr:yerr");
     TNtupleO *datainput3;
     datainput3 =new TNtupleO("ntuple3", "data", "x:y:xerr:yerr");
-    TNtupleO *datainput4;
-    datainput4 =new TNtupleO("ntuple4", "data", "x:y:xerr:yerr");
+    TNtupleO *prop2ndpixelfire;
+    prop2ndpixelfire =new TNtupleO("Prop. 2nd pixel", "data", "x:y:xerr:yerr");
     for(Int_t runi=0; runi<numberRuns; runi++) // loop over runs read from file or given as aparameters
     {
         if (runList[runi]>0)
@@ -68,13 +71,7 @@ void ChargeSpektrum(TString runnumber = "")
 //                 runs[runi]->setFixedThresholdValueADU(cutval*0.6);
                 //runs[runi]->setNoisethresholdborderADU(800);
              //runs[runi]->setNoisethresholdborderE(220);
-
-//                                 runs[runi]->analyzeFrame(6384);
-//                 runs[runi]->analyzeFrame(1970548);
-//                   runs[runi]->analyzeFrame(1994914);
 //                 runs[runi]->analyzeFrame(680);
-//                 runs[runi]->analyzeFrame(685);
-//                 runs[runi]->analyzeFrame(690);
 //                   continue;
                     
 
@@ -106,200 +103,177 @@ void ChargeSpektrum(TString runnumber = "")
                     //         gROOT->SetBatch(kTRUE);
                     if (!isBatch)
                         gROOT->SetBatch(kFALSE);
+                                        
+                    if (analysisis.Contains("clas")) { // classic analysis
+                        compareHistogramClassVector.push_back(runs[runi]->histogram->normalized);
+                    }           
                     
-                    // Uncomment below to do classical analysis withour RTS
-                    compareHistogramClassVector.push_back(runs[runi]->histogramwoRTS->normalized);
-                    compareHistogramClassVector.push_back(runs[runi]->histogram->normalized);
-                    
-                    compareHistogramClassVector2.push_back(runs[runi]->histogramwoRTS->normalized);
-                    
-                    
-//                     compareHistogramVector.push_back(runs[runi]->histogramfixedthreshold->SeedPerc);
-                    
-                    compareHistogramVector2.push_back(runs[runi]->histogramwoRTS->normalized->Seed);
-                    compareHistogramVector3.push_back(runs[runi]->histogramwoRTS->normalized->Sum);
-                    
-                    
-                    runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS->pixeltimefiredDistrib);
-                    runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS->LeakageCurrentInPixelSorted);
-                    
-//                     compareHistogramClassVector2.push_back(runs[runi]->histogram->normalized);
-//                     
-//                     compareHistogramVector3.push_back(runs[runi]->histogram->normalized->Seed);
-//                     compareHistogramVector4.push_back(runs[runi]->histogram->normalized->Sum);
-//                     
-//                     
-//                     compareHistogramVector5.push_back(runs[runi]->histogramfixedthreshold->calibrated->Seed);
-                    
-//                     compareHistogramClassVector2.push_back(runs[runi]->histogramwoRTS);
-//                      compareHistogramClassVector2.push_back(runs[runi]->histogram->normalized);
-//                  compareHistogramClassVector2.push_back(runs[runi]->histogramwoRTS->normalized);
-//                  compareHistogramClassVector2.push_back(runs[runi]->histogramwoRTSAggresive->normalized);
-//                    compareHistogramClassVector2.push_back(runs[runi]->histogramwoRTS->normalized);
-//                     compareHistogramClassVector.push_back(runs[runi]->histogramwoRTS->normalized);
-//                     compareHistogramClassVector.push_back(runs[runi]->histogramfixedthreshold->normalized);
-                    //                     compareHistogramClassVector.push_back(runs[runi]->histogramfixedthreshold->normalized);
-//                     runs[runi]->plot1DHistogram(runs[runi]->histogram->Seed);
-//                     runs[runi]->plot1DHistogram( runs[runi]->histogram->Seed, "gaus", true, false, false, runs[runi]->histogram->fixedThresholdValue);
-                    
-                    
-                    
-//                     Double_t AverageCharge[9];
-//                     Double_t TotalHits[9];
-//                     for (UInt_t sumi = 0; sumi < 9; sumi++) {
-//                         AverageCharge[sumi] = 0;
-//                         TotalHits[sumi] = 0;
-//                         for (UInt_t bini = 1; bini <= runs[runi]->histogramfixedthreshold->a_Sum[sumi]->GetXaxis()->GetNbins();++bini) {
-//                             AverageCharge[sumi] += runs[runi]->histogramfixedthreshold->a_Sum[sumi]->GetBinContent(bini)*runs[runi]->histogramfixedthreshold->a_Sum[sumi]->GetBinCenter(bini);
-//                             TotalHits[sumi] += runs[runi]->histogramfixedthreshold->a_Sum[sumi]->GetBinContent(bini);
-//                         }
-//                         AverageCharge[sumi] /= TotalHits[sumi]/runs[runi]->histogramfixedthreshold->gain;
-//                     }
-                    
-                    
-                    
-                    
-//                     TNtupleO *datainput;
-//                     datainput =new TNtupleO("Position Seed", "data", "x:y:xerr:yerr");
-//                     datainput->itsHistogramType = runs[runi]->histogramfixedthreshold;
-//                     datainput->xaxisTitle = "Number of pixel in cluster";
-//                     datainput->yaxisTitle = "Position Seed";
-//                     for (UInt_t sumi = 0; sumi < 9; sumi++) {
-// //                         if (!(sumi%2))
-// //                             compareHistogramVector2.push_back(runs[runi]->histogram->normalized->a_Sum[sumi]);
-//                         datainput->Fill(sumi+1,runs[runi]->histogramfixedthreshold->a_posSum[sumi],0,0);
-// //                         runs[runi]->plot1DHistogram( runs[runi]->histogram->a_Sum[sumi], "gaus", true, false, false, runs[runi]->histogram->fixedThresholdValue);
-//                     }
-//                     ntupleVector.push_back(datainput);
-//                     
-//                     
-//                     datainput2->itsHistogramType = runs[runi]->histogramfixedthreshold;
-//                     datainput2->xaxisTitle = "Voltage";
-//                     datainput2->yaxisTitle = "Position Veto";
-//                     datainput2->Fill(runs[runi]->labbook.depletionV,runs[runi]->histogramfixedthreshold->posVeto,0,0);
-//                     
-//                     
-//                     
-//                     datainput3->itsHistogramType = runs[runi]->histogramfixedthreshold;
-//                     datainput3->xaxisTitle = "Voltage";
-//                     datainput3->yaxisTitle = "Position Sum";
-// //                     datainput3->Fill(runs[runi]->labbook.depletionV,runs[runi]->histogramfixedthreshold->posSum,0,0);
-//                     
-//                     
-//                     
-//                     
-//                     datainput4->itsHistogramType = runs[runi]->histogramfixedthreshold;
-//                     datainput4->xaxisTitle = "Voltage";
-//                     datainput4->yaxisTitle = "Cluster multiplicity";
-//                     datainput4->Fill(runs[runi]->labbook.depletionV,runs[runi]->histogramfixedthreshold->clustermultiplicity,0,0);
-                    
-                    
-//                     TNtupleO *datainput;
-//                     datainput =new TNtupleO("ntuple", "data", "x:y:xerr:yerr");
-//                     datainput->itsHistogramType = runs[runi]->histogram;
-//                     datainput->xaxisTitle = "Number of pixel in cluster";
-//                     datainput->yaxisTitle = "Average charge collected [e]";
-//                     for (UInt_t sumi = 0; sumi < 9; sumi++) {
-//                         if (!(sumi%2))
-//                             compareHistogramVector2.push_back(runs[runi]->histogram->normalized->a_Sum[sumi]);
-//                         datainput->Fill(sumi+1,AverageCharge[sumi],0,0);
-//                         //                         runs[runi]->plot1DHistogram( runs[runi]->histogram->a_Sum[sumi], "gaus", true, false, false, runs[runi]->histogram->fixedThresholdValue);
-//                     }
-//                     ntupleVector.push_back(datainput);
+                    if (analysisis.Contains("fixthresh") || analysisis.Contains("fixedthresh")) { // fixed threshold analysis
+                        compareHistogramClassVector4.push_back(runs[runi]->histogram);
+                        compareHistogramClassVector4.push_back(runs[runi]->histogramfixedthreshold);
+                        plotAllRuns(&compareHistogramClassVector4);
+                        compareHistogramClassVector4.clear();
+                    }   
                     
+                    if (analysisis.Contains("cali")) { // calibrated analysis
+                        compareHistogramClassVector2.push_back(runs[runi]->histogram->calibrated->normalized);
+                    }   
                     
+                    if (analysisis.Contains("depl")) { // depletion analysis
+                        compareHistogramVector.push_back(runs[runi]->histogramfixedthreshold->SeedPerc);
+                                               
+                        datainputPosVeto->itsHistogramType = runs[runi]->histogramfixedthreshold;
+                        datainputPosVeto->xaxisTitle = "Voltage";
+                        datainputPosVeto->yaxisTitle = "Position Veto";
+                        datainputPosVeto->Fill(runs[runi]->labbook.depletionV,runs[runi]->histogramfixedthreshold->posVeto,0,0);
+                        if (runi+1 == runnumber)
+                            ntupleVector.push_back(datainputPosVeto); 
+                        
+                        prop2ndpixelfire->itsHistogramType = runs[runi]->histogramfixedthreshold;
+                        prop2ndpixelfire->xaxisTitle = "Voltage";
+                        prop2ndpixelfire->yaxisTitle = "Propability for second pixel to fire";
+                        prop2ndpixelfire->Fill(runs[runi]->labbook.depletionV,runs[runi]->histogramfixedthreshold->clustermultiplicity->GetBinContent(2),0,0);
+                        cout << colorcyan << " Cluster Mult.:" << runs[runi]->histogramfixedthreshold->clustermultiplicity << endlr;
+                        if (runi+1 == runnumber)
+                            ntupleVector3.push_back(prop2ndpixelfire);
+                        
+                        
+                        Double_t AverageCharge[9];
+                        Double_t TotalHits[9];
+                        for (UInt_t sumi = 0; sumi < 9; sumi++) {
+                            AverageCharge[sumi] = 0;
+                            TotalHits[sumi] = 0;
+                            for (Int_t bini = 1; bini <= (*runs[runi]->histogramfixedthreshold->a_Sum)[sumi]->GetXaxis()->GetNbins();++bini) {
+                                AverageCharge[sumi] += (*runs[runi]->histogramfixedthreshold->a_Sum)[sumi]->GetBinContent(bini)*(*runs[runi]->histogramfixedthreshold->a_Sum)[sumi]->GetBinCenter(bini);
+                                TotalHits[sumi] += (*runs[runi]->histogramfixedthreshold->a_Sum)[sumi]->GetBinContent(bini);
+                            }
+                            AverageCharge[sumi] /= TotalHits[sumi]/runs[runi]->histogramfixedthreshold->gain;
+                        }
+                        
+                        TNtupleO *numpixelincl;
+                        numpixelincl =new TNtupleO("Average charge collected", "data", "x:y:xerr:yerr");
+                        numpixelincl->itsHistogramType = runs[runi]->histogram;
+                        numpixelincl->xaxisTitle = "Number of pixel in cluster";
+                        numpixelincl->yaxisTitle = "Average charge collected [e]";
+                        for (UInt_t sumi = 0; sumi < 9; sumi++) {
+                            if (!(sumi%2))
+                                compareHistogramVector2.push_back((*runs[runi]->histogram->normalized->a_Sum)[sumi]);
+                            numpixelincl->Fill(sumi+1,AverageCharge[sumi],0,0);
+                        }
+                        ntupleVector2.push_back(numpixelincl);
+                    }
                     
-//                     TNtupleO *datainput;
-//                     datainput =new TNtupleO("ntuple", "data", "x:y:xerr:yerr");
-//                     datainput->itsHistogramType = runs[runi]->histogram;
-//                     datainput->xaxisTitle = "Number of pixel in cluster";
-//                     datainput->yaxisTitle = "Average charge collected [ADU]";
-//                     for (UInt_t sumi = 0; sumi < 9; sumi++) {
-//                         if (!(sumi%2))
-//                             compareHistogramVector2.push_back(runs[runi]->histogram->normalized->a_Sum[sumi]);
-//                         datainput->Fill(sumi+1,runs[runi]->histogram->a_integralSum[sumi],0,runs[runi]->histogram->a_integralSumErr[sumi]);
-//                         runs[runi]->plot1DHistogram( runs[runi]->histogram->a_Sum[sumi], "gaus", true, false, false, runs[runi]->histogram->fixedThresholdValue);
-//                     }
-//                     ntupleVector.push_back(datainput);
+                    if (analysisis.Contains("rts")) { // rts studies
+                        // Uncomment below to do classical analysis withour RTS
+                        compareHistogramClassVector3.push_back(runs[runi]->histogramwoRTS);
+                        compareHistogramClassVector3.push_back(runs[runi]->histogram);
+                        // plot and clear compareHistogramClassVector7 vector, delete these two lines if you want to compare among different runs
+                        plotAllRuns(&compareHistogramClassVector3);
+                        compareHistogramClassVector3.clear();
+                        
+                        compareHistogramVector4.push_back(runs[runi]->histogramwoRTS->normalized->Seed);
+                        compareHistogramVector5.push_back((*runs[runi]->histogramwoRTS->normalized->Sum));
+                        
+                        runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS->pixeltimefiredDistrib);
+                        runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS->LeakageCurrentInPixelSorted);
+                    }
                     
-//                     ntuple.Clear();
+                    if (analysisis.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]->histogramfixedthreshold->normalized->Seed, "gaus", true, false, false, runs[runi]->histogram->fixedThresholdValue);
+                        
+                        
+                        compareHistogramVector6.push_back(runs[runi]->histogram->Seed);
+                        compareHistogramVector6.push_back(runs[runi]->histogramfixedthreshold->Seed);
+                        CompareHistograms(&compareHistogramVector6);
+                        compareHistogramVector6.clear();
+                        
+                        datainputIntSeed->itsHistogramType = runs[runi]->histogram->normalized;
+                        datainputIntSeed->xaxisTitle = "Voltage";
+                        datainputIntSeed->yaxisTitle = "Integral of Seed";
+                        datainputIntSeed->Fill(runs[runi]->labbook.depletionV,runs[runi]->histogram->integralSeed,0,runs[runi]->histogram->integralSeedErr);
+                        if (runi+1 == runnumber)
+                            ntupleVector4.push_back(datainputIntSeed);                        
+                    }
                     
-//                     ntuple->Fill(2,2,1,1);
-//                     ntuple->Fill(3,3,1,1);
-//                     ntuple->Fill(4,4,1,1);
-//                     ntuple->Fill(5,5,1,1);
-//                     
-//                     
+                    if (analysisis.Contains("cluster")) { // analyze cluster formation
+                        // show cluster multiplicity
+                        compareHistogramVector9.push_back(runs[runi]->histogram->normalized->clustermultiplicity);
+//                         runs[runi]->plot1DHistogram( runs[runi]->histogram->clustermultiplicity);                        
+                        
+                        compareHistogramVector7.push_back(runs[runi]->histogram->Sum9);
+                        compareHistogramVector7.push_back(runs[runi]->histogram->Sum25);
+                        CompareHistograms(&compareHistogramVector7);
+                        compareHistogramVector7.clear();
+                        
+                        
+                        compareHistogramVector8.push_back(runs[runi]->histogram->Seed);
+                        compareHistogramVector8.push_back(runs[runi]->histogram->a_Sum9[1]);
+                        compareHistogramVector8.push_back(runs[runi]->histogram->Sum9);
+                        compareHistogramVector8.push_back(runs[runi]->histogram->a_Sum25[1]);
+                        compareHistogramVector8.push_back(runs[runi]->histogram->Sum25);
+                        CompareHistograms(&compareHistogramVector8);
+                        compareHistogramVector8.clear();
+                        
+                        Double_t AverageCharge25[25];
+                        Double_t TotalHits25[25];
+                        for (UInt_t sumi = 0; sumi < 25; sumi++) {
+                            AverageCharge25[sumi] = 0;
+                            TotalHits25[sumi] = 0;
+                            for (Int_t bini = 1; bini <= runs[runi]->histogramfixedthreshold->a_Sum25[sumi]->GetXaxis()->GetNbins();++bini) {
+                                AverageCharge25[sumi] += runs[runi]->histogramfixedthreshold->a_Sum25[sumi]->GetBinContent(bini)*runs[runi]->histogramfixedthreshold->a_Sum25[sumi]->GetBinCenter(bini);
+                                TotalHits25[sumi] += runs[runi]->histogramfixedthreshold->a_Sum25[sumi]->GetBinContent(bini);
+                            }
+//                             AverageCharge25[sumi] /= TotalHits25[sumi]/runs[runi]->histogramfixedthreshold->gain;
+                        }
+                        
+                        TNtupleO *numpixelincl2;
+                        numpixelincl2 =new TNtupleO("Average charge collected", "data", "x:y:xerr:yerr");
+                        numpixelincl2->itsHistogramType = runs[runi]->histogram;
+                        numpixelincl2->Title = "5x5 cluster";
+                        numpixelincl2->xaxisTitle = "Number of pixel in cluster";
+                        numpixelincl2->yaxisTitle = "Average charge collected [ADU]";
+                        for (UInt_t sumi = 0; sumi < 25; sumi++) {
+                            numpixelincl2->Fill(sumi+1,AverageCharge25[sumi],0,0);
+                        }
+                        ntupleVector5.push_back(numpixelincl2);
+                        
+                        Double_t AverageCharge9[9];
+                        Double_t TotalHits9[9];
+                        for (UInt_t sumi = 0; sumi < 9; sumi++) {
+                            AverageCharge9[sumi] = 0;
+                            TotalHits9[sumi] = 0;
+                            for (Int_t bini = 1; bini <= runs[runi]->histogramfixedthreshold->a_Sum9[sumi]->GetXaxis()->GetNbins();++bini) {
+                                AverageCharge9[sumi] += runs[runi]->histogramfixedthreshold->a_Sum9[sumi]->GetBinContent(bini)*runs[runi]->histogramfixedthreshold->a_Sum9[sumi]->GetBinCenter(bini);
+                                TotalHits9[sumi] += runs[runi]->histogramfixedthreshold->a_Sum9[sumi]->GetBinContent(bini);
+                            }
+//                             AverageCharge9[sumi] /= TotalHits9[sumi]/runs[runi]->histogramfixedthreshold->gain;
+                        }
+                        
+                        TNtupleO *numpixelincl;
+                        numpixelincl =new TNtupleO("Average charge collected", "data", "x:y:xerr:yerr");
+                        numpixelincl->itsHistogramType = runs[runi]->histogram;
+                        numpixelincl->Title = "3x3 cluster";
+                        numpixelincl->xaxisTitle = "Number of pixel in cluster";
+                        numpixelincl->yaxisTitle = "Average charge collected [ADU]";
+                        for (UInt_t sumi = 0; sumi < 9; sumi++) {
+                            numpixelincl->Fill(sumi+1,AverageCharge9[sumi],0,0);
+                        }
+                        ntupleVector5.push_back(numpixelincl);
+                        
+                    }
                     
-//                     compareHistogramVector.push_back(runs[runi]->histogram->Seed);
-//                     compareHistogramVector.push_back(runs[runi]->histogramwoRTS->Seed);
-//                     compareHistogramVector.push_back(runs[runi]->histogramwoRTSAggresive->Seed);
-//                     compareHistogramVector.push_back(runs[runi]->histogramfixedthreshold->Seed);
-//                     compareHistogramVector.push_back(runs[runi]->histogramfixedthreshold->normalized->Seed);
-// Float_t integratestart = 0;
-// runs[runi]->plot1DHistogram( runs[runi]->histogram->normalized->Seed, "landau", true, false, false);
-// integratestart = runs[runi]->histogram->FindNoisethresholdborder(runs[runi]->histogram->Sum, false, false);
-// cout << "integratestart: " << integratestart << endlr;
-// runs[runi]->plot1DHistogram( runs[runi]->histogram->normalized->Sum, "landau", true, false, false, integratestart);
-// integratestart = runs[runi]->histogram->FindNoisethresholdborder(runs[runi]->histogram->a_Sum[2], false, false);
-// cout << "integratestart: " << integratestart << endlr;
-// runs[runi]->plot1DHistogram( runs[runi]->histogram->normalized->a_Sum[2], "landau", true, false, false, integratestart);
-// integratestart = runs[runi]->histogram->FindNoisethresholdborder(runs[runi]->histogram->a_Sum[5], false, false);
-// cout << "integratestart: " << integratestart << endlr;
-// runs[runi]->plot1DHistogram( runs[runi]->histogram->normalized->a_Sum[5], "landau", true, false, false, integratestart);
-                    //runs[runi]->plot1DHistogram( runs[runi]->histogramwoRTS->normalized->Seed, "GaussTail");
-                   //runs[runi]->plot1DHistogram( runs[runi]->histogramwoRTS->a_Sum[0]);
-//                     compareHistogramVector.push_back(runs[runi]->histogramwoRTS->a_Sum[0]); // Seed
-//                 compareHistogramVector.push_back(runs[runi]->histogramwoRTS->a_Sum[1]); // Seed + next bigger charge pixel
-//                 compareHistogramVector.push_back(runs[runi]->histogramwoRTS->a_Sum[2]); // Seed + 2
-//                 compareHistogramVector.push_back(runs[runi]->histogramwoRTS->a_Sum[8]); // Sum over 9 pixel in cluster
-//                 compareHistogramVector.push_back(runs[runi]->histogramwoRTS->a_Sum[24]); // Sum over 25 pixel in cluster
-                   
-                   
-//                     runs[runi]->plot1DHistogram( runs[runi]->histogram->normalized->Seed, "gaus", true, false, false, runs[runi]->histogramfixedthreshold->normalized->fixedThresholdValue);
-//                     runs[runi]->plot1DHistogram( runs[runi]->histogram->normalized->Sum, "gaus", true, false, false, runs[runi]->histogramfixedthreshold->normalized->fixedThresholdValue);
-                     
-                     
-//                      runs[runi]->plot1DHistogram( runs[runi]->histogramfixedthreshold->normalized->Seed, "GaussTail", true, false, false, runs[runi]->histogramfixedthreshold->normalized->fixedThresholdValue);
-//                      runs[runi]->plot1DHistogram( runs[runi]->histogramfixedthreshold->normalized->Sum, "GaussTail", true, false, false, runs[runi]->histogramfixedthreshold->normalized->fixedThresholdValue);
                     
-                    // plot RTS pixel histogram
-                     //runs[runi]->plot1DHistogram( runs[runi]->histogramwoRTS->pixeltimefiredDistrib, "", 0);
                     
-                     
-//                      runs[runi]->plot1DHistogram( runs[runi]->histogram->normalized->Seed);
-//                      runs[runi]->plot1DHistogram( runs[runi]->histogram->normalized->Sum);
                     
-                     runs[runi]->writeAllHistogramsToFile();
-                     
-                     // plot and clear compareHistogramClassVector vector, delete these two lines if you want to compare among different runs
-                     plotAllRuns(&compareHistogramClassVector);
-                     compareHistogramClassVector.clear();
+                    // write all histograms to a dat file, can be imported by ORIGIN or Excel. Leave this line ;)
+                    runs[runi]->writeAllHistogramsToFile();
                      
-                     CompareHistograms(&compareHistogramVector);
-                     compareHistogramVector.clear();
                 }
                 //cout << runs[runi]->histogram
             }
         }
     } // loop over all runs end
-    
-    ntupleVector2.push_back(datainput2);
-    ntupleVector2.push_back(datainput3);
-    
-    ntupleVector3.push_back(datainput4);
-    
-    
-    
-    
-// if (numberRuns>0)
-//     runs[0]->setLabel("Not irradiated, -20 {}^{0}C");
-// if (numberRuns>1)
-//     runs[1]->setLabel("     +20 {}^{0}C");
-// if (numberRuns>2)
-//     runs[2]->setLabel("Irradiated with Lead, Dose 4, -20 {}^{0}C");
-// if (numberRuns>3) 
-//     runs[3]->setLabel("    +20 {}^{0}C");
 
 printSummaryTable(&compareHistogramClassVector);
 printSummaryTable(&compareHistogramClassVector2);
@@ -312,14 +286,25 @@ CompareHistograms(&compareHistogramVector5);
 CompareHistograms(&compareHistogramVector6);
 CompareHistograms(&compareHistogramVector7);
 CompareHistograms(&compareHistogramVector8);
+CompareHistograms(&compareHistogramVector9);
 plotAllRuns(&compareHistogramClassVector);
 plotAllRuns(&compareHistogramClassVector2);
 plotAllRuns(&compareHistogramClassVector3);
 plotAllRuns(&compareHistogramClassVector4);
 plotAllRuns(&compareHistogramClassVector5);
+plotAllRuns(&compareHistogramClassVector6);
+plotAllRuns(&compareHistogramClassVector7);
+plotAllRuns(&compareHistogramClassVector8);
+plotAllRuns(&compareHistogramClassVector9);
 plot1DData(&ntupleVector);
 plot1DData(&ntupleVector2);
 plot1DData(&ntupleVector3);
+plot1DData(&ntupleVector4);
+plot1DData(&ntupleVector5);
+plot1DData(&ntupleVector6);
+plot1DData(&ntupleVector7);
+plot1DData(&ntupleVector8);
+plot1DData(&ntupleVector9);
 CompareLeageCurrent(&compareHistogramClassVector4);
 CompareLeageCurrent(&compareHistogramClassVector5);
 writeObservableToFile();
index f8263d0a7a86f52b76c56185302eca84feccff96..ff3cb471232c492b57795f5c8dc68d4505e470c8 100644 (file)
@@ -24,7 +24,7 @@ using namespace std;
 
 Int_t* ReadRunList();
 Int_t ReadRunList(std::vector<int>*);
-void InterpreteUserInput(TString, std::vector<int>*, std::vector<Bool_t>*, std::vector<Bool_t>*, std::vector<Bool_t>*);
+void InterpreteUserInput(TString, std::vector<int>*, std::vector<Bool_t>*, std::vector<Bool_t>*, std::vector<Bool_t>*, TString* analysisis);
 Bool_t plotAllRuns();
 Bool_t plotAllRuns(vector<HistogramType*>*);
 // vector wich is used to save a good title by the function FindGoodTitle()
@@ -98,9 +98,9 @@ Bool_t printSummaryTable(vector<HistogramType*>*);
 Bool_t testifMixingCalibration(vector<HistogramType*>*);
 /** @brief Turns a value into a string with fixed precision */
 string to_str_w_prec(const Float_t a_value, int precision = 1);
-vector<HistogramType*> compareHistogramClassVector, compareHistogramClassVector2, compareHistogramClassVector3, compareHistogramClassVector4, compareHistogramClassVector5, compareHistogramClassVector6, compareHistogramClassVector7, compareHistogramClassVector8, compareHistogramClassVectorMABSBot;
-vector<TH1FO*> compareHistogramVector, compareHistogramVector2, compareHistogramVector3, compareHistogramVector4, compareHistogramVector5, compareHistogramVector6, compareHistogramVector7, compareHistogramVector8;
-vector<TNtupleO*> ntupleVector, ntupleVector2, ntupleVector3, ntupleVector4
+vector<HistogramType*> compareHistogramClassVector, compareHistogramClassVector2, compareHistogramClassVector3, compareHistogramClassVector4, compareHistogramClassVector5, compareHistogramClassVector6, compareHistogramClassVector7, compareHistogramClassVector8, compareHistogramClassVector9, compareHistogramClassVectorMABSBot;
+vector<TH1FO*> compareHistogramVector, compareHistogramVector2, compareHistogramVector3, compareHistogramVector4, compareHistogramVector5, compareHistogramVector6, compareHistogramVector7, compareHistogramVector8, compareHistogramVector9;
+vector<TNtupleO*> ntupleVector, ntupleVector2, ntupleVector3, ntupleVector4, ntupleVector5, ntupleVector6, ntupleVector7, ntupleVector8, ntupleVector9;
 TString ownpath = "";
 TString savepathresults;
 
@@ -127,13 +127,13 @@ void Init()
 {
     //FindGoodTitle();
     TTimeStamp timestamp = TTimeStamp();
-    savepathresults = Form("./results/%d%06d/", (int)timestamp.GetDate(kFALSE), (int)timestamp.GetTime(kFALSE));
+    savepathresults = Form("./results/%d%06d", (int)timestamp.GetDate(kFALSE), (int)timestamp.GetTime(kFALSE));
     
 }
 
 // in the command line one can add labels, by printing a equal sign '=' and a string escaped by the question sign '§', for example:
 // root -l -b -q  'ChargeSpektrum.c+("40100=§5 V§,40097=§10 V§,40091=§20 V§,40103=§30 V§,40106=§40 V§")'
-void InterpreteUserInput(TString runnumber, std::vector<int> *runList, std::vector<Bool_t> *runListForceAnalysis, std::vector<TString> *runListCustomTitle, std::vector<TString> *sumuprunList)
+void InterpreteUserInput(TString runnumber, std::vector<int> *runList, std::vector<Bool_t> *runListForceAnalysis, std::vector<TString> *runListCustomTitle, std::vector<TString> *sumuprunList, TString *analysisis)
 {
     if (runnumber.Length() > 0)
     {
@@ -231,6 +231,11 @@ void InterpreteUserInput(TString runnumber, std::vector<int> *runList, std::vect
                 exit(1);
             }
         }
+        if (runnumber.Contains(";")) {
+            *analysisis = runnumber(runnumber.First(";")+1,runnumber.Length());
+            analysisis->ToLower();
+//             cout << colorcyan << "*analysisis: " << *analysisis << endlr;
+        }
     }
     else
     {
@@ -272,51 +277,95 @@ plot1DData(std::vector<TNtupleO*>* ntuplepvectorpointer, Bool_t verbose, Bool_t
         if (ntuplepvectorpointer->size() > 0) {
             TNtupleO* ntuplepointer = ntuplepvectorpointer->at(0);
             if (ntuplepointer->GetEntries() > 0) {
-    //             TNtuple* ntuplepointer = &(ntuplepvectorpointer->at(0));
-                TString canvastitle = Form("%s", ntuplepointer->GetName());
-                TString canvasname =  Form("%s", ntuplepointer->GetName());
-    //             titlestr = ntuplepointer->GetTitle();
                 
+                vector<HistogramType*> compareHistogramClassVector;
+                Float_t x_minimum =999999999;
+                Float_t x_maximum =0;
+                Float_t y_minimum =999999999;
+                Float_t y_maximum =0;
+                for (UInt_t ntuplei=0; ntuplei < ntuplepvectorpointer->size(); ntuplei++)
+                {
+                    TNtupleO* curTuple = ntuplepvectorpointer->at(ntuplei);
+                    if (curTuple->itsHistogramType != 0)
+                        compareHistogramClassVector.push_back(curTuple->itsHistogramType);
+                    x_minimum = x_minimum > curTuple->GetMinimum("x")?curTuple->GetMinimum("x"):x_minimum;
+                    x_maximum = x_maximum < curTuple->GetMaximum("x")?curTuple->GetMaximum("x"):x_maximum;
+                    y_minimum = y_minimum > curTuple->GetMinimum("y")?curTuple->GetMinimum("y"):y_minimum;
+                    y_maximum = y_maximum < curTuple->GetMaximum("y")?curTuple->GetMaximum("y"):y_maximum;
+                }                
+                FindGoodTitle(&compareHistogramClassVector);                    
+                gROOT->SetStyle("RadHard_NoTitle");
+                
+                TString  legendEntry;
+                
+                TPaveText *owntitle = new TPaveText(0.15,0.9,0.930401,0.995,"nbNDC");
+                owntitle->SetFillStyle(0);
+                owntitle->SetBorderSize(0);
+                owntitle->SetTextAlign(22);
+                owntitle->SetTextSize(0.04);
+                owntitle->SetTextFont(42);
+                
+                // legend entries
+                Float_t height = ntuplepvectorpointer->size() * 0.03;
+                //         TLegend* leg1 = new TLegend(0.3,0.89-height,0.95,0.89);//(0.6,0.7,0.89,0.89);
+                TLegend* leg1 = new TLegend(0.7,0.89-height,0.95,0.89);//(0.6,0.7,0.89,0.89);
+                leg1->SetTextSize(0.025);
+                leg1->SetFillStyle(1001);
+                leg1->SetTextFont(132);
+                leg1->SetFillColor(0);
+                leg1->SetBorderSize(0);
+                 
+                TString canvastitle = Form("%s", ntuplepointer->GetName());          
+                TTimeStamp* time = new TTimeStamp();
+                TString canvasname = Form("%s_%d",ntuplepointer->GetName(),(int)time->GetNanoSec()/100000);  
+                //TString canvasname = Form("%d",time->GetNanoSec());            
                 if (titlestr.Length()>0)
-                    ntuplepointer->SetTitle(titlestr);
+                    canvastitle = titlestr;
+                TCanvas* canvas = new TCanvas(canvasname, canvastitle, 1200, 700);  
+                TPad *grid = new TPad("grid","",0,0,1,1);
+                grid->Draw();
+                grid->cd();
+                grid->SetGrid();
+                grid->SetFillStyle(4000);  
+                
                 if (logscale) {
                     gPad->SetLogy(1);            
-                }
-                
-                TCanvas* canvas = new TCanvas(canvasname, canvastitle, 900, 700);  
-                canvas->SetGrid();
+                }                
                 
                 for(UInt_t runi=0;runi<ntuplepvectorpointer->size();runi++) // loop over runs or other stacked elements in vector<TNtuple*>
                 {
-    //                 TNtuple* ntuplepointer = &(ntuplepvectorpointer->at(runi));
                     TNtupleO* ntuplepointer = ntuplepvectorpointer->at(runi);
+                    ntuplepointer->SetLineColor(compareHistogramClassVector.at(runi)->color);   
+                    ntuplepointer->SetLineWidth(2);   
                     ntuplepointer->Draw("x:y:xerr:yerr","","goff");
                     
+                    if (legendStringsVector.size() > 0)
+                        legendEntry = Form("%s %s", ntuplepointer->Title.Data(), legendStringsVector.at(runi).Data());
+                    leg1->AddEntry(ntuplepointer, legendEntry, "l");
+                    leg1->Draw("SAME");
+                    
                     TGraphErrors *gr = new TGraphErrors(ntuplepointer->GetEntries(),ntuplepointer->GetV1(),ntuplepointer->GetV2(),ntuplepointer->GetV3(),ntuplepointer->GetV4());
                     if ( ntuplepointer->Title.Length() > 0 ) { gr->SetTitle(ntuplepointer->Title); } else { gr->SetTitle("");}
                     if ( ntuplepointer->xaxisTitle.Length() > 0 ) { gr->GetXaxis()->SetTitle(ntuplepointer->xaxisTitle); } else { gr->GetXaxis()->SetTitle("");}
                     if ( ntuplepointer->yaxisTitle.Length() > 0 ) { gr->GetYaxis()->SetTitle(ntuplepointer->yaxisTitle); } else { gr->GetYaxis()->SetTitle("");}
                     if (ntuplepointer->itsHistogramType != 0) gr->SetMarkerColor(ntuplepointer->itsHistogramType->color); else gr->SetMarkerColor(runi); gr->SetMarkerStyle(21);
                     if (!runi) gr->Draw("ALP"); else gr->Draw("LP");
-                }
-                
-                TPaveText *owntitle = new TPaveText(0.15,0.9,0.930401,0.995,"nbNDC");
-                owntitle->SetFillStyle(0);
-                owntitle->SetBorderSize(0);
-                owntitle->SetTextAlign(22);
-                owntitle->SetTextSize(0.05);
-                owntitle->SetTextFont(42);
+                    gr->GetXaxis()->SetRangeUser(x_minimum*0.9,x_maximum*1.1);
+                    gr->GetYaxis()->SetRangeUser(y_minimum*0.9,y_maximum*1.1);
                     
-                owntitle->Clear();
-                if (titlestr.Length()>0) {
-                    owntitle->AddText(titlestr);
+                    owntitle->Clear();
+                    owntitle->AddText(trimRunnumberAtBegin(ntuplepvectorpointer->at(runi)->GetName()));
+                    if (headerStringsVector.size() > 0) {
+                        owntitle->Clear();
+                        owntitle->AddText(Form("%s", headerStringsVector.at(1).Data()));
+                        owntitle->AddText(headerStringsVector.at(2));
+                    }
                     owntitle->Draw("SAME");
-                }
-                
+                }                
                 canvas->Update();        
         //         canvas -> SaveAs( savepathresults + "/" + runcode + " " + onehistogram->GetName() + ".eps");
                 
-                TImageDump *img = new TImageDump(savepathresults + ntuplepointer->GetName() + ".png");
+                TImageDump *img = new TImageDump(savepathresults + folderadd + "/" + ntuplepointer->GetName() + ".png");
                 canvas->Paint();
                 img->Close();
                                 
@@ -335,8 +384,8 @@ Bool_t writeNTupleVectorToFile(std::vector<TNtupleO*>* ntuplepvectorpointer)
     {
         if (ntuplepvectorpointer->size() > 0) {
             TNtupleO* ntuplepointer = ntuplepvectorpointer->at(0);
-            system("mkdir "+ savepathresults + " -p");
-            TString filename = savepathresults + Form("Observable_%s.dat", ntuplepointer->GetName());
+            system("mkdir "+ savepathresults + folderadd + "/" + " -p");
+            TString filename = savepathresults + folderadd + "/" + Form("Observable_%s.dat", ntuplepointer->GetName());
             
             TString header = "";
             for(UInt_t runi=0;runi<ntuplepvectorpointer->size();runi++) // loop over runs or other stacked elements in vector<TNtupleO*>
@@ -378,9 +427,9 @@ Bool_t writeOneHistogramTypeToFile(vector<HistogramType*>* ptCompareHistogramCla
 {
     if (ptCompareHistogramClassVector->size() > 0)
     { 
-        system("mkdir "+ runs[0]->savepathresults + " -p");
+        system("mkdir "+ savepathresults + folderadd + "/" + " -p");
         
-        TString filename = Form("%s/Spectrum_%d_%s", runs[0]->savepathresults.Data(), ptCompareHistogramClassVector->at(0)->labbook->runnumber, ptCompareHistogramClassVector->at(0)->histogramdescription.Data());
+        TString filename = Form("%s%s/Spectrum_%d_%s", savepathresults.Data(),  folderadd.Data(), ptCompareHistogramClassVector->at(0)->labbook->runnumber, ptCompareHistogramClassVector->at(0)->histogramdescription.Data());
         
         TString header = "";
         for(UInt_t runi=0;runi<ptCompareHistogramClassVector->size();runi++) // loop over runs read from file
@@ -413,7 +462,7 @@ Bool_t writeOneHistogramTypeToFile(vector<HistogramType*>* ptCompareHistogramCla
             outline ="";
             for(UInt_t runi=0;runi<ptCompareHistogramClassVector->size();runi++) // loop over runs read from file
             {
-                outline+=Form("%.1f\t%.1f\t%.1f\t%.1f\t", ptCompareHistogramClassVector->at(runi)->Seed->GetBinCenter(bin), ptCompareHistogramClassVector->at(runi)->Seed->GetBinContent(bin), ptCompareHistogramClassVector->at(runi)->Sum->GetBinContent(bin), ptCompareHistogramClassVector->at(runi)->Veto->GetBinContent(bin));
+                outline+=Form("%.1f\t%.1f\t%.1f\t%.1f\t", ptCompareHistogramClassVector->at(runi)->Seed->GetBinCenter(bin), ptCompareHistogramClassVector->at(runi)->Seed->GetBinContent(bin), (*ptCompareHistogramClassVector->at(runi)->Sum)->GetBinContent(bin), ptCompareHistogramClassVector->at(runi)->Veto->GetBinContent(bin));
             }
             *fout<<outline<<endl;
         }
@@ -429,9 +478,9 @@ Bool_t writeObservableToFile()
 {
     if (numberRuns>0)
     {
-        system("mkdir "+ runs[0]->savepathresults + " -p");
+        system("mkdir "+ savepathresults + folderadd + "/" + " -p");
         
-        TString filename = runs[0]->savepathresults + "/Spectra";
+        TString filename = savepathresults + folderadd + "/Spectra";
         TString header = "";
         for(Int_t runi=0;runi<numberRuns;runi++) // loop over runs read from file
         {
@@ -478,7 +527,7 @@ Bool_t CompareHistograms(vector<TH1FO*>* ptCompareHistogramVector, TString title
         // legend entries
         Float_t height = ptCompareHistogramVector->size() * 0.03;
 //         TLegend* leg1 = new TLegend(0.3,0.89-height,0.95,0.89);//(0.6,0.7,0.89,0.89);
-        TLegend* leg1 = new TLegend(0.3,0.89-height,0.6,0.89);//(0.6,0.7,0.89,0.89);
+        TLegend* leg1 = new TLegend(0.7,0.89-height,0.95,0.89);//(0.6,0.7,0.89,0.89);
         leg1->SetTextSize(0.025);
         leg1->SetFillStyle(1001);
         leg1->SetTextFont(132);
@@ -491,12 +540,12 @@ Bool_t CompareHistograms(vector<TH1FO*>* ptCompareHistogramVector, TString title
         owntitle->SetFillStyle(0);
         owntitle->SetBorderSize(0);
         owntitle->SetTextAlign(22);
-        owntitle->SetTextSize(0.05);
+        owntitle->SetTextSize(0.04);
         owntitle->SetTextFont(42);
         
         Float_t lastbin1=0;   
         Float_t heighestval1=0; 
-        TString canvastitle = Form("Compare_%s", trimRunnumberAtBegin(ptCompareHistogramVector->at(0)->GetName()).Data());
+        TString canvastitle = Form("%s", trimRunnumberAtBegin(ptCompareHistogramVector->at(0)->GetName()).Data());
         TTimeStamp* time = new TTimeStamp();
         TString canvasname = Form("%s_%d",ptCompareHistogramVector->at(0)->GetName(),(int)time->GetNanoSec()/100000);  
         //TString canvasname = Form("%d",time->GetNanoSec());        
@@ -509,10 +558,9 @@ Bool_t CompareHistograms(vector<TH1FO*>* ptCompareHistogramVector, TString title
         for (UInt_t histogrami=0; histogrami < ptCompareHistogramVector->size(); histogrami++)
         {
             TH1F* curhistogramclone = (TH1F*) ptCompareHistogramVector->at(histogrami)->Clone();
-            lastbin1 = (curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(heighestval1/50,1))>lastbin1)?curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(heighestval1/50,1)):lastbin1;     
+            lastbin1 = (curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(heighestval1/20,1))>lastbin1)?curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(heighestval1/20,1)):lastbin1;     
         }    
-        cout << "lastbin1: " << lastbin1 << endl;
-        TCanvas* canvas = new TCanvas(canvasname, canvastitle, 1200, 800);
+        TCanvas* canvas = new TCanvas(canvasname, canvastitle, 1200, 700);
         TPad *grid = new TPad("grid","",0,0,1,1);
         grid->Draw();
         grid->cd();
@@ -530,13 +578,20 @@ Bool_t CompareHistograms(vector<TH1FO*>* ptCompareHistogramVector, TString title
             
             //             legendEntry = Form("%s %s", getRunnumberAtBegin(curhistogramclone->GetName()).Data(), curhistogramclone->GetTitle());
             legendEntry = Form("%s", curhistogramclone->GetTitle());
-            if (legendStringsVector.size() > 0)
+            if (legendStringsVector.size() > 0) {
                 legendEntry = Form("%s", legendStringsVector.at(histogrami).Data());
+            }
             leg1->AddEntry(curhistogramclone, legendEntry, "l");
             leg1->Draw("SAME");
             
             curhistogramclone->SetAxisRange(0,lastbin1*1.1,"X");
+//             curhistogramclone->GetYaxis()->UnZoom();
             curhistogramclone->GetYaxis()->SetRangeUser(1,heighestval1*1.4);
+            if (curhistogramclone->GetNbinsX() < 20) {
+                curhistogramclone->GetXaxis()->UnZoom();
+                curhistogramclone->GetYaxis()->UnZoom();
+            }
+//             canvas->Update();
             
             owntitle->Clear();
             owntitle->AddText(trimRunnumberAtBegin(curhistogramclone->GetName()));
@@ -552,13 +607,13 @@ Bool_t CompareHistograms(vector<TH1FO*>* ptCompareHistogramVector, TString title
         }
         canvas->Update();
 //         gPad->Modified(); gPad->Update();
-        MSaveBigPNG(canvas, savepathresults + "/" + canvastitle + ".png");
+        MSaveBigPNG(canvas, savepathresults + folderadd + "/" + canvastitle + ".png");
         
-        TImageDump *img = new TImageDump(savepathresults + "/" + canvastitle + ".png");
+        TImageDump *img = new TImageDump(savepathresults + folderadd + "/" + canvastitle + ".png");
         canvas->Paint();
         img->Close();
         
-        TFile *f = new TFile(savepathresults + "/" + canvastitle + ".root","RECREATE");
+        TFile *f = new TFile(savepathresults + folderadd + "/" + canvastitle + ".root","RECREATE");
         f->cd();
         f->Append(canvas);
         //f->Append(img);
@@ -579,7 +634,7 @@ Bool_t CompareLeageCurrent(vector<HistogramType*>* ptCompareHistogramClassVector
         
         // legend entries
         Float_t height = ptCompareHistogramClassVector->size() * 0.055;
-        TLegend* leg1 = new TLegend(0.50,0.89-height,0.95,0.89);//(0.6,0.7,0.89,0.89);
+        TLegend* leg1 = new TLegend(0.7,0.89-height,0.95,0.89);//(0.6,0.7,0.89,0.89);
         leg1->SetTextSize(0.035);
         leg1->SetFillStyle(0);
         leg1->SetTextFont(132);
@@ -591,7 +646,7 @@ Bool_t CompareLeageCurrent(vector<HistogramType*>* ptCompareHistogramClassVector
         owntitle->SetFillStyle(0);
         owntitle->SetBorderSize(0);
         owntitle->SetTextAlign(22);
-        owntitle->SetTextSize(0.05);
+        owntitle->SetTextSize(0.04);
         owntitle->SetTextFont(42);
         
         TString canvastitle = "SummaryLeakeCurrent"+ptCompareHistogramClassVector->at(0)->histogramdescription;    
@@ -602,7 +657,7 @@ Bool_t CompareLeageCurrent(vector<HistogramType*>* ptCompareHistogramClassVector
         }
         TTimeStamp* time = new TTimeStamp(); 
         TString canvasname = Form("%d",(int)time->GetNanoSec()/100000);
-        TCanvas* canvas = new TCanvas(canvasname, canvastitle, 1200, 800);
+        TCanvas* canvas = new TCanvas(canvasname, canvastitle, 1200, 700);
         
         int numberofhistogramclasses = ptCompareHistogramClassVector->size();
         double lowestxvalue = 1e50;
@@ -687,13 +742,13 @@ Bool_t CompareLeageCurrent(vector<HistogramType*>* ptCompareHistogramClassVector
         //         leg1->Draw("SAME");        
         
         canvas->Update();
-        MSaveBigPNG(canvas,savepathresults + "/" + canvastitle + ".png",1);
+        MSaveBigPNG(canvas,savepathresults + folderadd + "/" + canvastitle + ".png",1);
         
-        TImageDump *img = new TImageDump(savepathresults + "/" + canvastitle + ".png");
+        TImageDump *img = new TImageDump(savepathresults + folderadd + "/" + canvastitle + ".png");
         canvas->Paint();
         img->Close();
         
-        TFile *f = new TFile(savepathresults + "/" + canvastitle + ".root","RECREATE");
+        TFile *f = new TFile(savepathresults + folderadd + "/" + canvastitle + ".root","RECREATE");
         f->cd();
         f->Append(canvas);
         //f->Append(img);
@@ -754,7 +809,7 @@ Bool_t plotAllRuns(vector<HistogramType*>* ptCompareHistogramClassVector)
         
         // legend entries
         Float_t height = ptCompareHistogramClassVector->size() * 0.055;
-        TLegend* leg1 = new TLegend(0.6,0.89-height,0.95,0.89);//(0.6,0.7,0.89,0.89);
+        TLegend* leg1 = new TLegend(0.7,0.89-height,0.95,0.89);//(0.6,0.7,0.89,0.89);
         leg1->SetTextSize(0.035);
         leg1->SetFillStyle(0);
         leg1->SetTextFont(132);
@@ -784,7 +839,7 @@ Bool_t plotAllRuns(vector<HistogramType*>* ptCompareHistogramClassVector)
         Float_t heighestval2=0;
         Float_t heighestval3=0;
         Float_t heighestval4=0;     
-        TString canvastitle = "Summary"+ptCompareHistogramClassVector->at(0)->histogramdescription;    
+        TString canvastitle = ptCompareHistogramClassVector->at(0)->histogramdescription;    
         for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++)
         {
             HistogramType* curhistogramclassp = ptCompareHistogramClassVector->at(histogrami);
@@ -794,7 +849,7 @@ Bool_t plotAllRuns(vector<HistogramType*>* ptCompareHistogramClassVector)
         
         TString canvasname = Form("Summary_%s_%d",ptCompareHistogramClassVector->at(0)->run->runcode.Data(),(int)time->GetNanoSec()/100000);  
         //TString canvasname = Form("%d",time->GetNanoSec());
-        TCanvas* canvas = new TCanvas(canvasname, canvastitle, 1200, 800);
+        TCanvas* canvas = new TCanvas(canvasname, canvastitle, 1200, 700);
         canvas->Divide(2,2);
         THStack *hs = new THStack("hs","Sum spectra");
         
@@ -808,7 +863,7 @@ Bool_t plotAllRuns(vector<HistogramType*>* ptCompareHistogramClassVector)
             heighestval1 = (curhistogramclone->GetMaximum()>heighestval1?curhistogramclone->GetMaximum():heighestval1);  
             
             
-            curhistogramclone = (TH1F*) curhistogramclassp->Sum->Clone();
+            curhistogramclone = (TH1F*) (*curhistogramclassp->Sum)->Clone();
             posMaxValHist = curhistogramclone->GetXaxis()->GetXmax();
             curhistogramclone->GetXaxis()->UnZoom();
             curhistogramclone->GetXaxis()->SetRange(curhistogramclone->GetXaxis()->FindBin(curhistogramclassp->noisethresholdborder),curhistogramclone->GetXaxis()->FindBin(posMaxValHist));   // look only for maxima with x greater than noiseborder, cut away noise        
@@ -832,7 +887,7 @@ Bool_t plotAllRuns(vector<HistogramType*>* ptCompareHistogramClassVector)
             TH1F* curhistogramclone = (TH1F*) curhistogramclassp->Seed->Clone();            
             lastbin1 = (curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(heighestval1/20,1))>lastbin1)?curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(heighestval1/20,1)):lastbin1;       
             
-            curhistogramclone = (TH1F*) curhistogramclassp->Sum->Clone();
+            curhistogramclone = (TH1F*) (*curhistogramclassp->Sum)->Clone();
             lastbin2 = (curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(heighestval2/20,1))>lastbin2)?curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(heighestval2/20,1)):lastbin2;
             
             curhistogramclone = (TH1F*) curhistogramclassp->Veto->Clone();
@@ -860,7 +915,7 @@ Bool_t plotAllRuns(vector<HistogramType*>* ptCompareHistogramClassVector)
             leg1->Draw("SAME");
             curhistogramclone->SetAxisRange(0,lastbin1*1.1,"X");
             curhistogramclone->SetAxisRange(0,heighestval1*1.1,"Y");
-            curhistogramclone->GetYaxis()->SetRangeUser(1,heighestval1*1.0);
+            curhistogramclone->GetYaxis()->SetRangeUser(1,heighestval1*1.2);
 //             gPad->SetLogy(1);
             gPad->SetGrid(1);
             gPad->SetGridy(1);
@@ -872,7 +927,7 @@ Bool_t plotAllRuns(vector<HistogramType*>* ptCompareHistogramClassVector)
             owntitle->Draw("SAME");
             
             canvas->cd(2);
-            curhistogramclone = (TH1F*) curhistogramclassp->Sum->Clone();
+            curhistogramclone = (TH1F*) (*curhistogramclassp->Sum)->Clone();
             curhistogramclone->SetLineColor(rootcolors[histogrami%13]);
             curhistogramclone->Draw("SAME");
             hs->Add(curhistogramclone);
@@ -943,15 +998,15 @@ Bool_t plotAllRuns(vector<HistogramType*>* ptCompareHistogramClassVector)
         //                 canvas->cd(2); hs->Draw("nostack same");// T.DrawTextNDC(.5,.95,"Option \"nostack\"");
         //         canvas->BuildLegend();
         canvas->Update();
-        MSaveBigPNG(canvas,savepathresults + "/Big_" + canvastitle + ".png",2);
+        MSaveBigPNG(canvas,savepathresults + folderadd + "/Big_" + canvastitle + ".png",2);
         
-        TImageDump *img = new TImageDump(savepathresults + "/" + canvastitle + ".png");
+        TImageDump *img = new TImageDump(savepathresults + folderadd + "/" + canvastitle + ".png");
         canvas->Paint();
         img->Close();
         
         MSaveBigPNG(canvas,"lastrun.png");
         
-        TFile *f = new TFile(savepathresults + "/" + canvastitle + ".root","RECREATE");
+        TFile *f = new TFile(savepathresults + folderadd + "/" + canvastitle + ".root","RECREATE");
         f->cd();
         f->Append(canvas);
         //f->Append(img);
@@ -986,8 +1041,9 @@ Bool_t FindGoodTitle(vector<TH1FO*>* ptCompareHistogramVector) {
     for (UInt_t histogrami=0; histogrami < ptCompareHistogramVector->size(); histogrami++)
     {
         TH1FO* curHistogram = ptCompareHistogramVector->at(histogrami);
-        if (curHistogram->itsHistogramType != 0)
+        if (curHistogram->itsHistogramType != 0) {            
             compareHistogramClassVector.push_back(curHistogram->itsHistogramType);
+        }
     }
     return FindGoodTitle(&compareHistogramClassVector, ptCompareHistogramVector);    
 }
@@ -1019,7 +1075,7 @@ Bool_t FindGoodTitle(vector<HistogramType*>* ptCompareHistogramClassVector, vect
     if (ptCompareHistogramVector != 0)
         if (ptCompareHistogramVector->size() == ptCompareHistogramClassVector->size())
         {
-            mayBeSameRun = kTRUE;
+            mayBeSameRun = kTRUE; // no different classes were provided, only some TH1F histograms. Classes were constructed afterwards
 //             same_RunNumber = kTRUE;
         }
         
@@ -1034,197 +1090,191 @@ Bool_t FindGoodTitle(vector<HistogramType*>* ptCompareHistogramClassVector, vect
     if (ptCompareHistogramClassVector->at(0) == 0 )
         return 1;
     
+    HistogramType* firsthistogramclassp = ptCompareHistogramClassVector->at(0);
+    labbooksctruct firstlabbook = firsthistogramclassp->run->labbook;
+    pixelinfo firstpixelinfo = firsthistogramclassp->run->curpixelinfo;
+    TH1FO* firsthistogramp = 0;
+    
     if (ptCompareHistogramClassVector->size() == 1) {
-        HistogramType* curhistogramclassp = ptCompareHistogramClassVector->at(0);
-        labbooksctruct curlabbook = curhistogramclassp->run->labbook;
-        pixelinfo curpixelinfo = curhistogramclassp->run->curpixelinfo;
-                
-        TString title1 = Form(" %s, %s, %s, %.0fx%.0f #mum^{2} pitch, %s\nT=%.0f {}^{o}C, %.1f MRad, %.1f*10^{13} n_{eq}/cm^{2}, %.2f Mhz", curlabbook.source.Data(),
-                              curlabbook.chipGen.Data(), curlabbook.matrix.Data(), curpixelinfo.pitchX, curpixelinfo.pitchY, curpixelinfo.comment.Data(),
-                              curlabbook.tempSens, curlabbook.radDoseIon, curlabbook.radDoseNonIon, curlabbook.clock);
-        if (curlabbook.depletionV > 0)
-            title1 += Form(", U_{dep}=%.1f V", curlabbook.depletionV);
+        TString title1 = Form(" %s, %s, %s, %.0fx%.0f #mum^{2} pitch, %s\nT=%.0f {}^{o}C, %.1f MRad, %.1f*10^{13} n_{eq}/cm^{2}, %.2f Mhz", firstlabbook.source.Data(),
+                              firstlabbook.chipGen.Data(), firstlabbook.matrix.Data(), firstpixelinfo.pitchX, firstpixelinfo.pitchY, firstpixelinfo.comment.Data(),
+                              firstlabbook.tempSens, firstlabbook.radDoseIon, firstlabbook.radDoseNonIon, firstlabbook.clock);
+        if (firstlabbook.depletionV >= 0)
+            title1 += Form(", U_{dep}=%.1f V", firstlabbook.depletionV);
         
-        TString title2 = Form("%s", curlabbook.comment.Data());
+        TString title2 = Form("%s", firstlabbook.comment.Data());
         
         headerStringsVector.push_back(title1);
         TObjArray *humanreadablestrings = trimRunnumberAtBegin(title1).Tokenize("\n");
         headerStringsVector.push_back(((TObjString *)(humanreadablestrings->At(0)))->String());
         headerStringsVector.push_back(((TObjString *)(humanreadablestrings->At(1)))->String());
         headerStringsVector.push_back(title2);
-        
-        return false;        
-    }
-    
-    HistogramType* firsthistogramclassp = ptCompareHistogramClassVector->at(0);
-    labbooksctruct firstlabbook = firsthistogramclassp->run->labbook;
-    pixelinfo firstpixelinfo = firsthistogramclassp->run->curpixelinfo;
-    TH1FO* firsthistogramp = 0;
-    if (mayBeSameRun)
-        firsthistogramp = ptCompareHistogramVector->at(0);
-    
-    for (UInt_t histogrami=1; histogrami < ptCompareHistogramClassVector->size(); histogrami++)    {
-        HistogramType* curhistogramclassp = ptCompareHistogramClassVector->at(histogrami);
-        labbooksctruct curlabbook = curhistogramclassp->run->labbook;
-        pixelinfo curpixelinfo = curhistogramclassp->run->curpixelinfo;
-        TH1FO* curhistogramp = 0;
+              
+    } else {
         if (mayBeSameRun)
-            curhistogramp = ptCompareHistogramVector->at(histogrami);
+            firsthistogramp = ptCompareHistogramVector->at(0);
         
-        if (!curlabbook.source.EqualTo(firstlabbook.source))
-            same_Source = kFALSE;       
-        if (!curlabbook.chipGen.EqualTo(firstlabbook.chipGen))
-            same_ChipGen = kFALSE;           
-        if (!curlabbook.matrix.EqualTo(firstlabbook.matrix)) {
-            same_Matrix = kFALSE;    
-        }
-        if (firstlabbook.tempSens > 0) { // allow 10 % difference
-            if (curlabbook.tempSens > firstlabbook.tempSens*1.1 || curlabbook.tempSens < firstlabbook.tempSens*0.9)
-                same_Temp = kFALSE;
-        } else {            
-            if (curlabbook.tempSens < firstlabbook.tempSens*1.1 || curlabbook.tempSens > firstlabbook.tempSens*0.9)
-                same_Temp = kFALSE;      
+        for (UInt_t histogrami=1; histogrami < ptCompareHistogramClassVector->size(); histogrami++)    {
+            HistogramType* curhistogramclassp = ptCompareHistogramClassVector->at(histogrami);
+            labbooksctruct curlabbook = curhistogramclassp->run->labbook;
+            pixelinfo curpixelinfo = curhistogramclassp->run->curpixelinfo;
+            TH1FO* curhistogramp = 0;
+            if (mayBeSameRun)
+                curhistogramp = ptCompareHistogramVector->at(histogrami);
+            
+            if (!curlabbook.source.EqualTo(firstlabbook.source))
+                same_Source = kFALSE;       
+            if (!curlabbook.chipGen.EqualTo(firstlabbook.chipGen))
+                same_ChipGen = kFALSE;           
+            if (!curlabbook.matrix.EqualTo(firstlabbook.matrix)) {
+                same_Matrix = kFALSE;    
+            }
+            if (firstlabbook.tempSens > 0) { // allow 10 % difference
+                if (curlabbook.tempSens > firstlabbook.tempSens*1.1 || curlabbook.tempSens < firstlabbook.tempSens*0.9)
+                    same_Temp = kFALSE;
+            } else {            
+                if (curlabbook.tempSens < firstlabbook.tempSens*1.1 || curlabbook.tempSens > firstlabbook.tempSens*0.9)
+                    same_Temp = kFALSE;      
+            }
+            if (curlabbook.radDoseIon != firstlabbook.radDoseIon)
+                same_IonRad = kFALSE;  
+            if (curlabbook.radDoseNonIon != firstlabbook.radDoseNonIon)
+                same_NonIonRad = kFALSE;        
+            if (!curlabbook.chip.EqualTo(firstlabbook.chip))
+                same_ChipNum = kFALSE;  
+            if (curlabbook.clock != firstlabbook.clock)
+                same_Clock = kFALSE;
+            if (curlabbook.depletionV != firstlabbook.depletionV)
+                same_Depletion= kFALSE;
+    //         if (curlabbook.system != firstlabbook.system)
+    //             same_System = kFALSE;
+            if (curlabbook.runnumber != firstlabbook.runnumber)
+                same_RunNumber= kFALSE;
+            
+            if ( curhistogramp != 0 ) // different histogram types
+                if (!(trimRunnumberAtBegin(curhistogramp->GetName()).EqualTo(trimRunnumberAtBegin(firsthistogramp->GetName()))))
+                    same_HistType = kFALSE;
         }
-        if (curlabbook.radDoseIon != firstlabbook.radDoseIon)
-            same_IonRad = kFALSE;  
-        if (curlabbook.radDoseNonIon != firstlabbook.radDoseNonIon)
-            same_NonIonRad = kFALSE;        
-        if (!curlabbook.chip.EqualTo(firstlabbook.chip))
-            same_ChipNum = kFALSE;  
-        if (curlabbook.clock != firstlabbook.clock)
-            same_Clock = kFALSE;
-        if (curlabbook.depletionV != firstlabbook.depletionV)
-            same_Depletion= kFALSE;
-//         if (curlabbook.system != firstlabbook.system)
-//             same_System = kFALSE;
-        if (curlabbook.runnumber != firstlabbook.runnumber)
-            same_RunNumber= kFALSE;
         
-        if ( curhistogramp != 0 )
-            if (!(trimRunnumberAtBegin(curhistogramp->GetName()).EqualTo(trimRunnumberAtBegin(firsthistogramp->GetName()))))
-                same_HistType = kFALSE;
-    }
-    
-    // construct header string
-    TString title1 = "";
+//         // DEBUG
+//         cout << colorcyan << "same_Source:    " << same_Source << endlr;
+//         cout << colorcyan << "same_NonIonRad: " << same_NonIonRad << endlr;
+//         cout << colorcyan << "same_IonRad:    " << same_IonRad << endlr;
+//         cout << colorcyan << "same_ChipNum:   " << same_ChipNum << endlr;
+//         cout << colorcyan << "same_ChipGen:   " << same_ChipGen << endlr;
+//         cout << colorcyan << "same_Matrix:    " << same_Matrix << endlr;
+//         cout << colorcyan << "same_Temp:      " << same_Temp << endlr;
+//         cout << colorcyan << "same_Clock:     " << same_Clock << endlr;
+//         cout << colorcyan << "same_Depletion: " << same_Depletion << endlr;
+//         cout << colorcyan << "same_HistType:  " << same_HistType << endlr;
+//         cout << colorcyan << "same_RunNumber: " << same_RunNumber << endlr;
+//         cout << colorcyan << "mayBeSameRun:   " << mayBeSameRun << endlr;
+        
+        // construct header string
+        TString title1 = "";
+        if (same_RunNumber)
+            title1.Append(Form(", %d", firstlabbook.runnumber));
+        if (same_HistType && mayBeSameRun)
+            title1.Append(Form(", %s", trimRunnumberAtBegin(firsthistogramp->GetName()).Data()));
+        if (same_Source)
+            title1.Append(Form(", %s", firstlabbook.source.Data()));
+        if (same_ChipGen)
+            title1.Append(Form(", %s", firstlabbook.chipGen.Data()));
+        if (same_Matrix)
+            title1.Append(Form(", %s, %.0fx%.0f #mum^{2} pitch, %s", firstlabbook.matrix.Data(), firstpixelinfo.pitchX, firstpixelinfo.pitchY, firstpixelinfo.comment.Data()));
+        title1.Append(Form("\n"));
+        if (same_Temp)
+            title1.Append(Form("T=%.0f {}^{o}C", firstlabbook.tempSens));
+        if (same_IonRad && firstlabbook.radDoseIon != 0)
+            title1.Append(Form(", %.1f MRad", firstlabbook.radDoseIon));
+        if (same_NonIonRad && firstlabbook.radDoseNonIon != 0)
+            title1.Append(Form(", %.1f*10^{13} n_{eq}/cm^{2}", firstlabbook.radDoseNonIon));
+        if (same_Clock)
+            title1.Append(Form(", %.2f Mhz", firstlabbook.clock));    
+        if (same_Depletion && firstlabbook.depletionV >= 0)
+            title1.Append(Form(", U_{dep}=%.1f V", firstlabbook.depletionV));
+        
+    //     cout << colorred << title1 << endlr;
+        if (title1.Length() > 3)
+            title1 = title1.Remove(0,2); // remove trailing " ,"
+        headerStringsVector.push_back(title1);
+    //    TObjArray *humanreadablestrings = trimRunnumberAtBegin(title1).Tokenize("\n");
+        TObjArray *humanreadablestrings = title1.Tokenize("\n");
+        headerStringsVector.push_back(((TObjString *)(humanreadablestrings->At(0)))->String());
+        headerStringsVector.push_back(((TObjString *)(humanreadablestrings->At(1)))->String());
+        
+        // legend creation
+        for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++)    {
+            TString legendstr = "";
+            HistogramType* curhistogramclassp = ptCompareHistogramClassVector->at(histogrami);
+            labbooksctruct curlabbook = curhistogramclassp->run->labbook;
+            pixelinfo curpixelinfo = curhistogramclassp->run->curpixelinfo;
+            TH1FO* curhistogramp = 0;
+            if (mayBeSameRun)
+                curhistogramp = ptCompareHistogramVector->at(histogrami);
+            
+//             if (!same_RunNumber) { if (legendstr.Length()) legendstr.Append(", ");
+//                 legendstr.Append(Form("%d", curhistogramclassp->labbook->runnumber)); }
+            if (!same_HistType && mayBeSameRun) { if (legendstr.Length()) legendstr.Append(", ");
+                legendstr.Append(Form("%s", trimRunnumberAtBegin(curhistogramp->GetName()).Data())); }
+            if (!same_Source) { if (legendstr.Length()) legendstr.Append(", ");
+                legendstr.Append(Form("%s", curlabbook.source.Data())); }
+            if (!same_ChipGen) { if (legendstr.Length()) legendstr.Append(", ");
+                legendstr.Append(Form("%s", curlabbook.chipGen.Data())); }
+            if (!same_ChipNum) { if (legendstr.Length()) legendstr.Append(", ");
+                legendstr.Append(Form("Chip# %s", curlabbook.chip.Data())); }
+            if (!same_Matrix) { if (legendstr.Length()) legendstr.Append(", ");
+                legendstr.Append(Form("%s, %.0fx%.0f #mum^{2} pitch, %s", curlabbook.matrix.Data(), curpixelinfo.pitchX, curpixelinfo.pitchY, curpixelinfo.comment.Data())); }
+            if (!same_Temp) { if (legendstr.Length()) legendstr.Append(", ");
+                legendstr.Append(Form("T=%.0f {}^{o}C", curlabbook.tempSens)); }
+            if (!same_IonRad && curlabbook.radDoseIon != 0) { if (legendstr.Length()) legendstr.Append(", ");
+                legendstr.Append(Form("%.1f MRad", firstlabbook.radDoseIon)); }
+            if (!same_NonIonRad && curlabbook.radDoseNonIon != 0) { if (legendstr.Length()) legendstr.Append(", ");
+                legendstr.Append(Form("%.1f*10^{13} n_{eq}/cm^{2}", curlabbook.radDoseNonIon)); }
+            if (!same_Clock) { if (legendstr.Length()) legendstr.Append(", ");
+                legendstr.Append(Form("%.2f Mhz", curlabbook.clock)); }
+            if (!same_Depletion && curlabbook.depletionV >= 0) { if (legendstr.Length()) legendstr.Append(", ");
+                legendstr.Append(Form("U_{dep}=%.1f V", curlabbook.depletionV)); }    
+            legendStringsVector.push_back(legendstr);
+            
+//             cout << colorred << legendstr << endlr;
+        }   
+    } // end else ptCompareHistogramClassVector->size() == 1
+        
+    // Folder name suffix
+    folderadd = "";
     if (same_RunNumber)
-        title1.Append(Form(", %d", firstlabbook.runnumber));
-    if (same_HistType && mayBeSameRun)
-        title1.Append(Form(", %s", trimRunnumberAtBegin(firsthistogramp->GetName()).Data()));
+        folderadd.Append(Form(" %d", firstlabbook.runnumber));
+    if (same_HistType && mayBeSameRun && firsthistogramp != 0)
+        folderadd.Append(Form(" %s", trimRunnumberAtBegin(firsthistogramp->GetName()).Data()));
     if (same_Source)
-        title1.Append(Form(", %s", firstlabbook.source.Data()));
+        folderadd.Append(Form(" %s", firstlabbook.source.Data()));
     if (same_ChipGen)
-        title1.Append(Form(", %s", firstlabbook.chipGen.Data()));
+        folderadd.Append(Form(" %s", firstlabbook.chipGen.Data()));
     if (same_Matrix)
-        title1.Append(Form(", %s, %.0fx%.0f #mum^{2} pitch, %s", firstlabbook.matrix.Data(), firstpixelinfo.pitchX, firstpixelinfo.pitchY, firstpixelinfo.comment.Data()));
-    title1.Append(Form("\n"));
+        folderadd.Append(Form("-%s", firstlabbook.matrix.Data()));
+    if (!same_Matrix)
+        for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++)
+            folderadd.Append(Form(" -%s", ptCompareHistogramClassVector->at(histogrami)->labbook->matrix.Data()));   
+    if (same_Depletion && firstlabbook.depletionV >= 0)
+        folderadd.Append(Form(" %.1fV", firstlabbook.depletionV));
+    if (!same_Depletion && firstlabbook.depletionV >= 0)
+        for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++)
+            folderadd.Append(Form(" %.1fV", ptCompareHistogramClassVector->at(histogrami)->labbook->depletionV)); 
     if (same_Temp)
-        title1.Append(Form("T=%.0f {}^{o}C", firstlabbook.tempSens));
+        folderadd.Append(Form(" %.0fC", firstlabbook.tempSens));
     if (same_IonRad && firstlabbook.radDoseIon != 0)
-        title1.Append(Form(", %.1f MRad", firstlabbook.radDoseIon));
+        folderadd.Append(Form("%.1fMRad", firstlabbook.radDoseIon));
     if (same_NonIonRad && firstlabbook.radDoseNonIon != 0)
-        title1.Append(Form(", %.1f*10^{13} n_{eq}/cm^{2}", firstlabbook.radDoseNonIon));
+        folderadd.Append(Form(" %.1fe13neq", firstlabbook.radDoseNonIon));
     if (same_Clock)
-        title1.Append(Form(", %.2f Mhz", firstlabbook.clock));    
-    if (same_Depletion && firstlabbook.depletionV >= 0)
-        title1.Append(Form(", U_{dep}=%.1f V", firstlabbook.depletionV));
-    
-//     cout << colorred << title1 << endlr;
-    title1 = title1.Remove(0,2); // remove trailing " ,"
-    headerStringsVector.push_back(title1);
-//    TObjArray *humanreadablestrings = trimRunnumberAtBegin(title1).Tokenize("\n");
-    TObjArray *humanreadablestrings = title1.Tokenize("\n");
-    headerStringsVector.push_back(((TObjString *)(humanreadablestrings->At(0)))->String());
-    headerStringsVector.push_back(((TObjString *)(humanreadablestrings->At(1)))->String());
-    
-    // legend creation
-    for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++)    {
-        TString legendstr = "";
-        HistogramType* curhistogramclassp = ptCompareHistogramClassVector->at(histogrami);
-        labbooksctruct curlabbook = curhistogramclassp->run->labbook;
-        pixelinfo curpixelinfo = curhistogramclassp->run->curpixelinfo;
-        TH1FO* curhistogramp = 0;
-        if (mayBeSameRun)
-            curhistogramp = ptCompareHistogramVector->at(histogrami);
-        
-        if (!same_RunNumber) { if (legendstr.Length()) legendstr.Append(", ");
-            legendstr.Append(Form("%d", curhistogramclassp->labbook->runnumber)); }
-        if (!same_HistType && mayBeSameRun) { if (legendstr.Length()) legendstr.Append(", ");
-            legendstr.Append(Form("%s", trimRunnumberAtBegin(curhistogramp->GetName()).Data())); }
-        if (!same_Source) { if (legendstr.Length()) legendstr.Append(", ");
-            legendstr.Append(Form("%s", curlabbook.source.Data())); }
-        if (!same_ChipGen) { if (legendstr.Length()) legendstr.Append(", ");
-            legendstr.Append(Form("%s", curlabbook.chipGen.Data())); }
-        if (!same_ChipNum) { if (legendstr.Length()) legendstr.Append(", ");
-            legendstr.Append(Form("Chip# %s", curlabbook.chip.Data())); }
-        if (!same_Matrix) { if (legendstr.Length()) legendstr.Append(", ");
-            legendstr.Append(Form("%s, %.0fx%.0f #mum^{2} pitch, %s", curlabbook.matrix.Data(), curpixelinfo.pitchX, curpixelinfo.pitchY, curpixelinfo.comment.Data())); }
-        if (!same_Temp) { if (legendstr.Length()) legendstr.Append(", ");
-            legendstr.Append(Form("T=%.0f {}^{o}C", curlabbook.tempSens)); }
-        if (!same_IonRad && curlabbook.radDoseIon != 0) { if (legendstr.Length()) legendstr.Append(", ");
-            legendstr.Append(Form("%.1f MRad", firstlabbook.radDoseIon)); }
-        if (!same_NonIonRad && curlabbook.radDoseNonIon != 0) { if (legendstr.Length()) legendstr.Append(", ");
-            legendstr.Append(Form("%.1f*10^{13} n_{eq}/cm^{2}", curlabbook.radDoseNonIon)); }
-        if (!same_Clock) { if (legendstr.Length()) legendstr.Append(", ");
-            legendstr.Append(Form("%.2f Mhz", curlabbook.clock)); }
-        if (!same_Depletion && curlabbook.depletionV >= 0) { if (legendstr.Length()) legendstr.Append(", ");
-            legendstr.Append(Form("U_{dep}=%.1f V", curlabbook.depletionV)); }    
-        legendStringsVector.push_back(legendstr);
-        
-//         cout << colorred << legendstr << endlr;
-    }    
-    
-//     // Folder name suffix
-//     TString folderadd = "";
-//     if (same_RunNumber)
-//         folderadd.Append(Form(", %d", firstlabbook.runnumber));
-//     if (same_HistType && mayBeSameRun)
-//         folderadd.Append(Form(", %s", trimRunnumberAtBegin(firsthistogramp->GetName()).Data()));
-//     if (same_Source)
-//         folderadd.Append(Form(", %s", firstlabbook.source.Data()));
-//     if (same_ChipGen)
-//         folderadd.Append(Form(", %s", firstlabbook.chipGen.Data()));
-//     if (same_Matrix)
-//         folderadd.Append(Form(", %s, %.0fx%.0f #mum^{2} pitch, %s", firstlabbook.matrix.Data(), firstpixelinfo.pitchX, firstpixelinfo.pitchY, firstpixelinfo.comment.Data()));
-//     title1.Append(Form("\n"));
-//     if (same_Temp)
-//         title1.Append(Form("T=%.0f {}^{o}C", firstlabbook.tempSens));
-//     if (same_IonRad && firstlabbook.radDoseIon != 0)
-//         title1.Append(Form(", %.1f MRad", firstlabbook.radDoseIon));
-//     if (same_NonIonRad && firstlabbook.radDoseNonIon != 0)
-//         title1.Append(Form(", %.1f*10^{13} n_{eq}/cm^{2}", firstlabbook.radDoseNonIon));
-//     if (same_Clock)
-//         title1.Append(Form(", %.2f Mhz", firstlabbook.clock));    
-//     if (same_Depletion && firstlabbook.depletionV >= 0)
-//         title1.Append(Form(", U_{dep}=%.1f V", firstlabbook.depletionV));
-//     title1 = title1.Remove(0,2); // remove trailing " ,"
-    
-    
-    
-    
-    
-    HistogramType* curhistogramclassp = ptCompareHistogramClassVector->at(0);
-    labbooksctruct curlabbook = curhistogramclassp->run->labbook;
-    pixelinfo curpixelinfo = curhistogramclassp->run->curpixelinfo;
-    if (same_Source)
-        folderadd.Append(Form(" %s", curlabbook.source.Data()));
-    if (same_ChipGen)
-        folderadd.Append(Form(" %s", curlabbook.chipGen.Data()));
-    if (!same_Matrix)
-        for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++)
-            folderadd.Append(Form(" %s", ptCompareHistogramClassVector->at(histogrami)->labbook->matrix.Data()));        
-    if (same_Temp)
-        folderadd.Append(Form(" %.0fC", curlabbook.tempSens));
-    if (same_IonRad && curlabbook.radDoseIon != 0)
-        folderadd.Append(Form(" %.1f MRad", firstlabbook.radDoseIon));
-    if (same_NonIonRad && curlabbook.radDoseNonIon != 0)
-        folderadd.Append(Form(" %.1fe13 neq", curlabbook.radDoseNonIon));
+        folderadd.Append(Form(" %.2fMhz", firstlabbook.clock));    
     if (!same_Clock)
         for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++)
-            folderadd.Append(Form(" %.2f Mhz", ptCompareHistogramClassVector->at(histogrami)->labbook->clock)); 
-    if (!same_Depletion && curlabbook.depletionV >= 0)
-        for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++)
-            folderadd.Append(Form(" %.1fV", ptCompareHistogramClassVector->at(histogrami)->labbook->depletionV));
+            folderadd.Append(Form(" %.2fMhz", ptCompareHistogramClassVector->at(histogrami)->labbook->clock)); 
+        
+    system("mkdir \""+ savepathresults + folderadd + "/\"" + " -p");
+//     cout << colorred << savepathresults << folderadd << endlr;
     
     return false;        
 }
@@ -1244,8 +1294,7 @@ Bool_t printSummaryTable(vector<HistogramType*>* ptCompareHistogramClassVector)
     { 
         if (testifMixingCalibration(ptCompareHistogramClassVector)) return 1;
         
-        system("mkdir "+ runs[0]->savepathresults + " -p");
-        TString filename = runs[0]->savepathresults + "/Summary"+ptCompareHistogramClassVector->at(0)->histogramdescription;
+        TString filename = savepathresults + folderadd + "/" + "/Summary"+ptCompareHistogramClassVector->at(0)->histogramdescription;
         TString filecontent = "";
         for(Int_t runi=0;runi<numberRuns;runi++) // loop over runs read from file
         {
@@ -1362,3 +1411,4 @@ string to_str_w_prec(const Float_t a_value, const int precision)
     }
     return out.str();
 }
+
index 4f3c13260bca7aedfb33bbe1f122697d4e488a45..7a63b529561b6487af567e3e1e79f1fe1278972d 100644 (file)
@@ -44,12 +44,15 @@ void HistogramType::initHistograms(Int_t gotcolor, Int_t gotstyle) {
     style = gotstyle;
     //Seed2=new TH1F(Form("%d %s",labbook->runnumber, ("Seed" + histogramdescription).Data()), Form("%s, %s",("Seed" + histogramdescription).Data(), humanreadablestr.Data()), cursystempar->nbins, 0, cursystempar->maxbin);  
     initHistogram(Seed, "Seed" + histogramdescription, color, style);
-    initHistogram(Sum, "Sum" + histogramdescription, color, style);
-    initHistogramArray(&a_Sum, 25, "Sum" + histogramdescription, color, style);
+    initHistogram(Sum9, "Sum_{9}" + histogramdescription, color, style);
+    initHistogram(Sum25, "Sum_{25}" + histogramdescription, color, style);
+    initHistogramArray(&a_Sum9, 9, "Sum_{9}" + histogramdescription, color, style);
+    initHistogramArray(&a_Sum25, 25, "Sum_{25}" + histogramdescription, color, style);
     initHistogram(Veto, "Veto" + histogramdescription, color, style);
     initHistogram(Noise, "Noise" + histogramdescription, color, style);
     initHistogram(NoiseEnd, "Noise at end" + histogramdescription, 16, style);
     initHistogramCustom(SeedPerc, "Seed Percentage" + histogramdescription, color, style, 0, 120, 121, Form("Entries [1/%%]"), "Q_coll [%]");
+    initHistogramCustom(clustermultiplicity, "Cluster multiplicity" + histogramdescription, color, style, 0.5, 6.5, 6, Form("Entries"), "Number of pixel fired");
     initHistogramCustom(pixeltimefired, "Pixel fired, used for " + histogramdescription, color, style, 0, cursensorinfo->columns*cursensorinfo->rows, cursensorinfo->columns*cursensorinfo->rows, "Pixel index", "Counts");
     initHistogramCustom(pixeltimefiredDistrib, "Fire counter" + histogramdescription, color, style, 0, labbook->frames_foundDB/100, labbook->frames_foundDB/100, "times fired", "Counts");
     initHistogramCustom(LeakageCurrentInPixel, "Leakage current per pixel" + histogramdescription, color, style, 0, cursensorinfo->columns*cursensorinfo->rows, cursensorinfo->columns*cursensorinfo->rows, "Pixel index", "Average CDS");
@@ -61,6 +64,22 @@ void HistogramType::initHistograms(Int_t gotcolor, Int_t gotstyle) {
     Noise->SetBins(cursystempar->nbinsnoise, 0, cursystempar->maxbinnoise);
     NoiseEnd->SetBins(cursystempar->nbinsnoise, 0, cursystempar->maxbinnoise);
 //     LeakageCurrentInPixelSorted->SetBins(cursystempar->nbinsnoise*10, 0, cursystempar->maxbinnoise*30);
+    
+    if( labbook->chipGen=="FSBB" || labbook->chipGen=="Pipper2") {
+        Sum = &Sum9;
+        a_Sum = &a_Sum9;
+        a_posSum = &a_posSum9;
+        a_integralSum = &a_integralSum9;
+        a_integralSumErr = &a_integralSumErr9;
+        a_sr90IntegralVal = &a_sr90IntegralVal9;
+    } else {
+        Sum = &Sum25;
+        a_Sum = &a_Sum25;
+        a_posSum = &a_posSum25;
+        a_integralSum = &a_integralSum25;
+        a_integralSumErr = &a_integralSumErr25;
+        a_sr90IntegralVal = &a_sr90IntegralVal25;
+    }        
 }
 
 void HistogramType::initHistogram(TH1FO* &histogrampointer, TString prefix, Int_t color, Int_t style) {
@@ -136,24 +155,33 @@ Bool_t HistogramType::calibrateHistograms( Float_t gotgain ) {
     gain = gotgain;
     calibrated = new HistogramType(histogramdescription+" calibrated", cursystempar, cursensorinfo, humanreadablestr, labbook, run, color, style);
     if (Seed != 0) calibrateHistogram(calibrated->Seed, Seed);
-    if (Sum != 0) calibrateHistogram(calibrated->Sum, Sum);
-    for (unsigned int i=0; i < a_Sum.size(); ++i) {
-        calibrated->a_Sum.push_back(a_Sum[i]);
-        calibrateHistogram(calibrated->a_Sum[i], a_Sum[i]);
+    if (Sum9 != 0) calibrateHistogram(calibrated->Sum9, Sum9);
+    if (Sum25 != 0) calibrateHistogram(calibrated->Sum25, Sum25);
+    for (unsigned int i=0; i < a_Sum9.size(); ++i) {
+        calibrated->a_Sum9.push_back(a_Sum9[i]);
+        calibrateHistogram(calibrated->a_Sum9[i], a_Sum9[i]);
+    }
+    for (unsigned int i=0; i < a_Sum25.size(); ++i) {
+        calibrated->a_Sum25.push_back(a_Sum25[i]);
+        calibrateHistogram(calibrated->a_Sum25[i], a_Sum25[i]);
     }
     if (Veto != 0) calibrateHistogram(calibrated->Veto, Veto);
     if (Noise != 0) calibrateHistogram(calibrated->Noise, Noise);
     if (pixeltimefired != 0) calibrated->pixeltimefired = pixeltimefired;
-    if (pixeltimefiredDistrib != 0) calibrated->pixeltimefiredDistrib = (TH1FO*)pixeltimefiredDistrib->Clone();
+    if (pixeltimefiredDistrib != 0) calibrated->pixeltimefiredDistrib = pixeltimefiredDistrib;
     if (SeedPerc != 0) calibrated->SeedPerc = SeedPerc;
+    if (clustermultiplicity != 0) calibrated->clustermultiplicity = clustermultiplicity;
     if (histAvgCluster != 0) calibrate2DHistogramCounts(calibrated->histAvgCluster, histAvgCluster);
     if (LeakageCurrentInPixel != 0) calibrateHistogramYAxis(calibrated->LeakageCurrentInPixel, LeakageCurrentInPixel);
     if (LeakageCurrentInPixelSorted != 0) calibrateHistogramYAxis(calibrated->LeakageCurrentInPixelSorted, LeakageCurrentInPixelSorted);
     
     calibrated->posSeed = posSeed * gain;
     calibrated->posSum = posSum * gain;    
-    for (unsigned int i=0; i < a_posSum.size(); ++i){
-        calibrated->a_posSum.push_back(a_posSum[i] * gain);
+    for (unsigned int i=0; i < a_posSum9.size(); ++i){
+        calibrated->a_posSum9.push_back(a_posSum9[i] * gain);
+    } 
+    for (unsigned int i=0; i < a_posSum25.size(); ++i){
+        calibrated->a_posSum25.push_back(a_posSum25[i] * gain);
     }
     calibrated->posVeto = posVeto * gain;
     calibrated->integralSeed = integralSeed;
@@ -161,9 +189,13 @@ Bool_t HistogramType::calibrateHistograms( Float_t gotgain ) {
     calibrated->integralVeto = integralVeto;
     calibrated->integralSum = integralVeto;
     calibrated->integralSumErr = integralSumErr;    
-    for (unsigned int i=0; i < a_integralSum.size(); ++i){
-        calibrated->a_integralSum.push_back( a_integralSum[i]);    
-        calibrated->a_integralSumErr.push_back( a_integralSumErr[i] );    
+    for (unsigned int i=0; i < a_integralSum9.size(); ++i){
+        calibrated->a_integralSum9.push_back( a_integralSum9[i]);    
+        calibrated->a_integralSumErr9.push_back( a_integralSumErr9[i] );    
+    }
+    for (unsigned int i=0; i < a_integralSum25.size(); ++i){
+        calibrated->a_integralSum25.push_back( a_integralSum25[i]);    
+        calibrated->a_integralSumErr25.push_back( a_integralSumErr25[i] );    
     }
     calibrated->posSeedPerc = posSeedPerc;
     calibrated->sigmaSeedPerc = sigmaSeedPerc;
@@ -252,24 +284,33 @@ Bool_t HistogramType::normalizeHistograms( Int_t got_frames_found ) {
     
     normalized = new HistogramType(histogramdescription+" normalized", cursystempar, cursensorinfo, humanreadablestr, labbook, run, color, style);
     if (Seed != 0) normalizeHistogram(normalized->Seed, Seed);
-    if (Sum != 0) normalizeHistogram(normalized->Sum, Sum);
-    for (unsigned int i=0; i < a_Sum.size(); ++i){
-        normalized->a_Sum.push_back(a_Sum[i]);
-        normalizeHistogram(normalized->a_Sum[i], a_Sum[i]);
+    if (Sum9 != 0) normalizeHistogram(normalized->Sum9, Sum9);
+    if (Sum25 != 0) normalizeHistogram(normalized->Sum25, Sum25);
+    for (unsigned int i=0; i < a_Sum9.size(); ++i){
+        normalized->a_Sum9.push_back(a_Sum9[i]);
+        normalizeHistogram(normalized->a_Sum9[i], a_Sum9[i]);
+    }
+    for (unsigned int i=0; i < a_Sum25.size(); ++i){
+        normalized->a_Sum25.push_back(a_Sum25[i]);
+        normalizeHistogram(normalized->a_Sum25[i], a_Sum25[i]);
     }
     if (Veto != 0) normalizeHistogram(normalized->Veto, Veto);
     if (pixeltimefired != 0) normalizeHistogram(normalized->pixeltimefired, pixeltimefired);
     if (pixeltimefiredDistrib != 0) normalizeHistogramXAxis(normalized->pixeltimefiredDistrib, pixeltimefiredDistrib);
     if (SeedPerc != 0) normalizeHistogram(normalized->SeedPerc, SeedPerc);
-    if (normalized->Noise != 0)normalized->Noise = (TH1FO*)Noise->Clone();
+    if (clustermultiplicity != 0) normalized->clustermultiplicity = clustermultiplicity;
+    if (normalized->Noise != 0)normalized->Noise = Noise;
     if (normalized->histAvgCluster != 0) normalized->histAvgCluster = (TH2F*)histAvgCluster->Clone();
     if (normalized->LeakageCurrentInPixel != 0)normalized->LeakageCurrentInPixel = (TH1FO*)LeakageCurrentInPixel->Clone();
     if (normalized->LeakageCurrentInPixelSorted != 0)normalized->LeakageCurrentInPixelSorted = (TH1FO*)LeakageCurrentInPixelSorted->Clone();
     normalized->frames_found = frames_found;
     normalized->posSeed = posSeed;
     normalized->posSum = posSum;
-    for (unsigned int i=0; i < a_posSum.size(); ++i){
-        normalized->a_posSum.push_back(a_posSum[i]);
+    for (unsigned int i=0; i < a_posSum9.size(); ++i){
+        normalized->a_posSum9.push_back(a_posSum9[i]);
+    }
+    for (unsigned int i=0; i < a_posSum25.size(); ++i){
+        normalized->a_posSum25.push_back(a_posSum25[i]);
     }
     normalized->posVeto = posVeto;
     normalized->integralSeed = integralSeed/frames_found*pow10(6);
@@ -277,9 +318,13 @@ Bool_t HistogramType::normalizeHistograms( Int_t got_frames_found ) {
     normalized->integralVeto= integralVeto/frames_found*pow10(6);
     normalized->integralVeto= integralVeto/frames_found*pow10(6);
     normalized->integralSum = integralSum/frames_found*pow10(6);
-    for (unsigned int i=0; i < a_integralSum.size(); ++i){
-        normalized->a_integralSum.push_back(a_integralSum[i]/frames_found*pow10(6));
-        normalized->a_integralSumErr.push_back(a_integralSumErr[i]* sqrt(pow10(6)/frames_found));
+    for (unsigned int i=0; i < a_integralSum9.size(); ++i){
+        normalized->a_integralSum9.push_back(a_integralSum9[i]/frames_found*pow10(6));
+        normalized->a_integralSumErr9.push_back(a_integralSumErr9[i]* sqrt(pow10(6)/frames_found));
+    }
+    for (unsigned int i=0; i < a_integralSum25.size(); ++i){
+        normalized->a_integralSum25.push_back(a_integralSum25[i]/frames_found*pow10(6));
+        normalized->a_integralSumErr25.push_back(a_integralSumErr25[i]* sqrt(pow10(6)/frames_found));
     }
     normalized->integralSumErr = integralSumErr * sqrt(pow10(6)/frames_found);
     normalized->posSeedPerc = posSeedPerc;
@@ -414,7 +459,7 @@ Double_t* HistogramType::FitPerform(TH1FO* histogrampointer, TString fitFuncType
 //                cout << fittries <<  ": New range: " <<  histogrampointer->GetXaxis()->GetBinCenter(min+fittries*min/20) << " to " << posMaxValHist << endl;
                 fit_result_ptr = histogrampointer->Fit(fitFunc, "NQWS", "", histogrampointer->GetXaxis()->GetBinCenter(min+fittries*min/20), posMaxValHist);    
 //                 cout << colorred << gMinuit->fCstatu.Data() << endlr;            
-            } while (gMinuit->fCstatu.Contains("FAILED") && fittries++ < 8);
+            } while (gMinuit->fCstatu.Contains("FAILED") && fittries++ < 5);
             posMax = histogrampointer->GetXaxis()->GetBinCenter(histogrampointer->GetMaximumBin()); // Methode 1
             integralPeak = histogrampointer->IntegralAndError(min+fittries*min/20, histogrampointer->GetXaxis()->FindBin(posMaxValHist), integralPeakError, "width");
 //             if (verbose)
@@ -469,7 +514,7 @@ Double_t* HistogramType::FitPerform(TH1FO* histogrampointer, TString fitFuncType
                         failed = true;
                     }
                 }                
-            } while (fittries < 10);   
+            } while (fittries < 6);   
             // get parameters
             for (Int_t pari=0; pari<3; pari++) {
                 //cout << colorcyan << fitFunc->GetParameter(pari) << endlr;
@@ -769,7 +814,7 @@ Double_t* HistogramType::FitPerform(TH1FO* histogrampointer, TString fitFuncType
             else
                 fittries = 100;
 //              cout << colorcyan << gMinuit->fCstatu.Data() << " fit tries: " << fittries << endlr;            
-        } while (fittries < 10);
+        } while (fittries < 6);
         if (failed)
         {
             failed = false;
@@ -1127,11 +1172,11 @@ Bool_t HistogramType::integrateSr90Spectras(Int_t frames_found, Float_t threshol
         noisethresholdborder = thresholdborder;
     }
     
-    for(UInt_t sumi=0;sumi<a_Sum.size();sumi++) // loop over all sum spectras
+    for(UInt_t sumi=0;sumi<a_Sum25.size();sumi++) // loop over all sum spectras
     {
-        cur_sr90IntegralVal = a_Sum[sumi]->IntegralAndError(thresholdbincurcandidate,a_Sum[sumi]->GetNbinsX()+1, cur_sr90IntegralErr, "width");
-        a_sr90IntegralVal.push_back(cur_sr90IntegralVal);
-        a_sr90IntegralErr.push_back(cur_sr90IntegralErr);
+        cur_sr90IntegralVal = a_Sum25[sumi]->IntegralAndError(thresholdbincurcandidate,a_Sum25[sumi]->GetNbinsX()+1, cur_sr90IntegralErr, "width");
+        a_sr90IntegralVal25.push_back(cur_sr90IntegralVal);
+        a_sr90IntegralErr25.push_back(cur_sr90IntegralErr);
     }    
     
     return 0;
index e56e10cea89700f943480a30d931f0e8095c85c4..eb6fa09b1de84804565e4128a0a23af767ce1156 100644 (file)
@@ -22,6 +22,13 @@ 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;
@@ -32,6 +39,7 @@ public:
     TH1FO&  operator=(const TH1F &h1);
 };
 
+
 /**
  * @file HistogramType.h
  * @brief A class to store the histograms used in Run
@@ -143,11 +151,15 @@ public:
     /// Seed spectrum, only the seed pixel is considered when this histogram is build
     TH1FO* Seed = 0;
     /// Sum spectrum, the charge of whole cluster is summed up in binned into this TH1F histogram
-    TH1FO* Sum = 0;
+    TH1FO** Sum = 0;
+    TH1FO* Sum9 = 0;
+    TH1FO* Sum25 = 0;
     /// 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<TH1FO*> a_Sum;
+    vector<TH1FO*> * a_Sum;
+    vector<TH1FO*> a_Sum9;
+    vector<TH1FO*> 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
@@ -182,20 +194,26 @@ public:
     Double_t integralSeedErr=0;
     /// fitted position of the most probable value in the over cluster summed spectrum
     Float_t posSum=0;
-    vector<Float_t> a_posSum;
+    vector<Float_t> * a_posSum;
+    vector<Float_t> a_posSum9;
+    vector<Float_t> a_posSum25;
     /// fintegral over the sum peak, normalized to number of events
     Double_t integralSum=0;
-    vector<Double_t> a_integralSum;
+    vector<Double_t> * a_integralSum;
+    vector<Double_t> a_integralSum9;
+    vector<Double_t> a_integralSum25;
     /// fintegral error over the Seed peak, poisson dist. assumed -> sqrt(N) for each bin
     Double_t integralSumErr=0;
-    vector<Double_t> a_integralSumErr;
+    vector<Double_t> * a_integralSumErr;
+    vector<Double_t> a_integralSumErr9;
+    vector<Double_t> 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
     Double_t integralVeto=0;
 
-    /// what is the propability that a second pixel is over the threshold
-    Double_t clustermultiplicity=0;
+    /// what is the propability that other pixel are over the threshold and fire.
+    TH1FO* clustermultiplicity=0;
     
     /// Average Noise value
     Float_t avgNoise = 0;
@@ -214,8 +232,12 @@ public:
     /// Integral value, after integrating  from #noisethresholdborder to maxbin.
     Double_t sr90IntegralVal = -1;
     Double_t sr90IntegralErr = -1;
-    vector<Double_t> a_sr90IntegralVal;
-    vector<Double_t> a_sr90IntegralErr;
+    vector<Double_t> * a_sr90IntegralVal;
+    vector<Double_t> a_sr90IntegralVal9;
+    vector<Double_t> a_sr90IntegralVal25;
+    vector<Double_t> * a_sr90IntegralErr;
+    vector<Double_t> a_sr90IntegralErr9;
+    vector<Double_t> a_sr90IntegralErr25;
     
     /// Peak and sigma of Seed to Sum ratio
     Float_t posSeedPerc = 0;
@@ -270,6 +292,8 @@ public:
     /// number of hits/clusters  used to generate all distributions
     Double_t numberofhits = 0;
     /// Charge collection efficciency of the cluster in percent
+    Float_t CCE_in_Perc_9=0;
+    /// Charge collection efficciency of the cluster in percent
     Float_t CCE_in_Perc_25=0;
     /// Charge collection efficciency of the seed pixel in percent
     Float_t CCE_in_Perc_1=0;
index 26c5074cd4ae341783962f9aa42b0fc9df6e0197..78f1d5526acbb2e137823b8fc42b8ab6e9e8852c 100644 (file)
@@ -814,16 +814,20 @@ Bool_t Run::setLabel(TString newlabel)
     for (vector<HistogramType*>::iterator curHistogramClass = HistogramClassVector.begin(); curHistogramClass != HistogramClassVector.end(); curHistogramClass++)  {
         (*curHistogramClass)->Seed->SetTitle(newlabel);
         (*curHistogramClass)->Veto->SetTitle(newlabel);
-        (*curHistogramClass)->Sum->SetTitle(newlabel);
+        (*curHistogramClass)->Sum9->SetTitle(newlabel);
+        (*curHistogramClass)->Sum25->SetTitle(newlabel);
         (*curHistogramClass)->normalized->Seed->SetTitle(newlabel);
         (*curHistogramClass)->normalized->Veto->SetTitle(newlabel);
-        (*curHistogramClass)->normalized->Sum->SetTitle(newlabel);
+        (*curHistogramClass)->normalized->Sum9->SetTitle(newlabel);
+        (*curHistogramClass)->normalized->Sum25->SetTitle(newlabel);
         (*curHistogramClass)->calibrated->Seed->SetTitle(newlabel);
         (*curHistogramClass)->calibrated->Veto->SetTitle(newlabel);
-        (*curHistogramClass)->calibrated->Sum->SetTitle(newlabel);
+        (*curHistogramClass)->calibrated->Sum9->SetTitle(newlabel);
+        (*curHistogramClass)->calibrated->Sum25->SetTitle(newlabel);
         (*curHistogramClass)->normalized->calibrated->Seed->SetTitle(newlabel);
         (*curHistogramClass)->normalized->calibrated->Veto->SetTitle(newlabel);
-        (*curHistogramClass)->normalized->calibrated->Sum->SetTitle(newlabel);
+        (*curHistogramClass)->normalized->calibrated->Sum9->SetTitle(newlabel);
+        (*curHistogramClass)->normalized->calibrated->Sum25->SetTitle(newlabel);
     }
     customLabel = true;
     return 0;
@@ -1272,14 +1276,18 @@ Bool_t Run::binSeedSumVeto()
 {        
     /// size of cluster array, 5 x 5 = 25
     Int_t completeclustersize = processed->clustersize*processed->clustersize;
-    Float_t a_pixelSum[completeclustersize];
-    Float_t a_notSeedSum[completeclustersize];
-    Float_t pixelSum = 0;
-    Float_t notSeedSum = 0;
-    for (Int_t clusteri=0; clusteri<completeclustersize; clusteri++) {
-        a_pixelSum[clusteri]  = 0;
-        a_notSeedSum[clusteri] = 0;
-    }
+    Float_t a_pixelSum9[completeclustersize];
+    Float_t a_notSeedSum9[completeclustersize];
+    Float_t a_pixelSum25[completeclustersize];
+    Float_t a_notSeedSum25[completeclustersize];
+    Float_t pixelSum9 = 0;
+    Float_t notSeedSum9 = 0;
+    Float_t pixelSum25 = 0;
+    Float_t notSeedSum25 = 0;
+    Float_t pixelSum;
+    Float_t notSeedSum;
+    Float_t* a_pixelSum;
+    Float_t* a_notSeedSum;
     
     Bool_t RTSpixel = false;
     
@@ -1309,24 +1317,32 @@ Bool_t Run::binSeedSumVeto()
                     }
                     if (pixel_column_x >= submatrix_x_start && pixel_column_x < submatrix_x_end && pixel_row_y >= submatrix_y_start && pixel_row_y < submatrix_y_end) // Diode sitzt oben im SeedPixel, da nach PitchY angeordnet
                     {                        
-                        pixelSum = 0;
-                        notSeedSum = 0;     
+                        pixelSum25 = 0;
+                        notSeedSum25 = 0;     
                         for (Int_t clusteri=0; clusteri<completeclustersize; clusteri++) {
-                            a_pixelSum[clusteri]  = 0;
-                            a_notSeedSum[clusteri] = 0;
-                        }
-                        //cout << colorpurple << framei << endlr;
+                            a_pixelSum25[clusteri]  = 0;
+                            a_notSeedSum25[clusteri] = 0;
+                        }                        
                         
-                        // look only at 3x3 cluster around seed
-                        if( labbook.chipGen=="FSBB" || labbook.chipGen=="Pipper2") {
-                            for (Int_t clusteri=0; clusteri<sqrt(completeclustersize); clusteri++) 
-                                processed->fFrameInfo.p[clusteri][hiti] += -9999;
-                            for (Int_t clusteri=completeclustersize-sqrt(completeclustersize); clusteri<completeclustersize; clusteri++) 
-                                processed->fFrameInfo.p[clusteri][hiti] += -9999;
-                            for (Int_t clusteri=0; clusteri<completeclustersize; clusteri=clusteri+sqrt(completeclustersize)) 
-                                processed->fFrameInfo.p[clusteri][hiti] += -9999;
-                            for (Int_t clusteri=4; clusteri<completeclustersize; clusteri=clusteri+sqrt(completeclustersize)) 
-                                processed->fFrameInfo.p[clusteri][hiti] += -9999;
+                        Float_t clusterArray25[completeclustersize];// temp variable clusterArray necessary, because Sort only accepts 1-dim arrays
+                        for (Int_t clusteri=0; clusteri<completeclustersize; clusteri++) {
+                            clusterArray25[clusteri] = processed->fFrameInfo.p[clusteri][hiti];
+                        }
+                        Int_t index25[completeclustersize];
+                        TMath::Sort(completeclustersize,clusterArray25,index25,1);
+                        for (Int_t clusteri=0; clusteri<completeclustersize; clusteri++)
+                        {
+                            pixelSum25 += clusterArray25[index25[clusteri]];                            
+                            for (Int_t clusterj=clusteri; clusterj<completeclustersize; clusterj++) {
+                                a_pixelSum25[clusterj] += clusterArray25[index25[clusteri]];
+                            }
+                            
+                            if (index25[clusteri] != 12) {
+                                notSeedSum25 += processed->fFrameInfo.p[index25[clusteri]][hiti];
+                                for (Int_t clusterj=clusteri; clusterj<completeclustersize; clusterj++) {
+                                    a_notSeedSum25[clusterj] += clusterArray25[index25[clusteri]];
+                                }
+                            }
                         }
                             
         //                     DEBUG
@@ -1337,39 +1353,78 @@ Bool_t Run::binSeedSumVeto()
         //                     }
         //                     cout << "......." << endl;
                             
-                        Float_t clusterArray[completeclustersize];// temp variable clusterArray necessary, because Sort only accepts 1-dim arrays
-                        for (Int_t clusteri=0; clusteri<completeclustersize; clusteri++) {
-                            clusterArray[clusteri] = processed->fFrameInfo.p[clusteri][hiti];
-                        }
-                        Int_t index[completeclustersize];
-                        TMath::Sort(completeclustersize,clusterArray,index,1);
-                        for (Int_t clusteri=0; clusteri<completeclustersize; clusteri++)
+                        Float_t clusterArray9[9];// temp variable clusterArray necessary, because Sort only accepts 1-dim arrays
+                        clusterArray9[0]=clusterArray25[6];
+                        clusterArray9[1]=clusterArray25[7];
+                        clusterArray9[2]=clusterArray25[8];
+                        clusterArray9[3]=clusterArray25[11];
+                        clusterArray9[4]=clusterArray25[12];
+                        clusterArray9[5]=clusterArray25[13];
+                        clusterArray9[6]=clusterArray25[16];
+                        clusterArray9[7]=clusterArray25[17];
+                        clusterArray9[8]=clusterArray25[18];
+//                         if( labbook.chipGen=="FSBB" || labbook.chipGen=="Pipper2") {
+                        
+                        pixelSum9 = 0;
+                        notSeedSum9 = 0;     
+                        for (Int_t clusteri=0; clusteri<9; clusteri++) {
+                            a_pixelSum9[clusteri]  = 0;
+                            a_notSeedSum9[clusteri] = 0;
+                        } 
+                        
+                        Int_t index9[9];
+                        TMath::Sort(9,clusterArray9,index9,1);
+                        for (Int_t clusteri=0; clusteri<9; clusteri++)
                         {
-                            if (clusterArray[index[clusteri]] > -9000) {
-                                pixelSum += clusterArray[index[clusteri]];                            
-                                for (Int_t clusterj=clusteri; clusterj<completeclustersize; clusterj++) {
-                                    a_pixelSum[clusterj] += clusterArray[index[clusteri]];
-                                }
-                                
-                                if (index[clusteri] != 12) {
-                                    notSeedSum += processed->fFrameInfo.p[index[clusteri]][hiti];
-                                    for (Int_t clusterj=clusteri; clusterj<completeclustersize; clusterj++) { // not used yet
-                                        a_notSeedSum[clusterj] += clusterArray[index[clusteri]];
-                                    }
+                            pixelSum9 += clusterArray9[index9[clusteri]];            
+                            for (Int_t clusterj=clusteri; clusterj<completeclustersize; clusterj++) {
+                                a_pixelSum9[clusterj] += clusterArray9[index9[clusteri]];
+                            }
+                            
+                            if (index9[clusteri] != 12) {
+                                notSeedSum9 += processed->fFrameInfo.p[index9[clusteri]][hiti];
+                                for (Int_t clusterj=clusteri; clusterj<completeclustersize; clusterj++) { // not used yet
+                                    a_notSeedSum9[clusterj] += clusterArray9[index9[clusteri]];
                                 }
                             }
                         }
+                        if( labbook.chipGen=="FSBB" || labbook.chipGen=="Pipper2") {
+                            pixelSum     = pixelSum9;
+                            notSeedSum   = notSeedSum9;
+                            a_pixelSum   = &a_pixelSum9[0];
+                            a_notSeedSum = &a_notSeedSum9[0];
+                        } else {
+                            pixelSum     = pixelSum25;
+                            notSeedSum   = notSeedSum25;
+                            a_pixelSum   = &a_pixelSum25[0];
+                            a_notSeedSum = &a_notSeedSum25[0];
+                        }
+                        
                         if (filli == 0) { // first fill round                            
                             histogram->numberofhits++;                            
                             // histogram with the single pixel
                             histogram->Seed->Fill(processed->fFrameInfo.p[12][hiti]);
-                            histogram->Sum->Fill(pixelSum);  
+                            histogram->Sum9->Fill(pixelSum9);  
+                            histogram->Sum25->Fill(pixelSum25);  
                             for (Int_t clusterj=0; clusterj<completeclustersize; clusterj++) {
-                                histogram->a_Sum[clusterj]->Fill(a_pixelSum[clusterj]);  
+                                histogram->a_Sum25[clusterj]->Fill(a_pixelSum25[clusterj]);  
+                            }
+                            for (Int_t clusterj=0; clusterj<9; clusterj++) {
+                                histogram->a_Sum9[clusterj]->Fill(a_pixelSum9[clusterj]);  
                             }
                             
-                            if (a_pixelSum[1]-a_pixelSum[0] > labbook.NoiseAvgADC_DB*5)
-                                histogram->clustermultiplicity++;
+                            if (a_pixelSum[5]-a_pixelSum[0]-a_pixelSum[1]-a_pixelSum[2]-a_pixelSum[3]-a_pixelSum[4] > labbook.NoiseAvgADC_DB*5)
+                                histogram->clustermultiplicity->Fill(6);
+                            else if (a_pixelSum[4]-a_pixelSum[0]-a_pixelSum[1]-a_pixelSum[2]-a_pixelSum[3] > labbook.NoiseAvgADC_DB*5)
+                                histogram->clustermultiplicity->Fill(5);
+                            else if (a_pixelSum[3]-a_pixelSum[0]-a_pixelSum[1]-a_pixelSum[2] > labbook.NoiseAvgADC_DB*5)
+                                histogram->clustermultiplicity->Fill(4);
+                            else if (a_pixelSum[2]-a_pixelSum[0]-a_pixelSum[1] > labbook.NoiseAvgADC_DB*5)
+                                histogram->clustermultiplicity->Fill(3);
+                            else if (a_pixelSum[1]-a_pixelSum[0] > labbook.NoiseAvgADC_DB*5)
+                                histogram->clustermultiplicity->Fill(2);
+                            else
+                                histogram->clustermultiplicity->Fill(1);
                             
                             // seed percentage spectrum
                             histogram->SeedPerc->Fill(processed->fFrameInfo.p[12][hiti]/pixelSum*100); 
@@ -1382,7 +1437,7 @@ Bool_t Run::binSeedSumVeto()
                             if (processed->fFrameInfo.pixelthreshold[hiti]>0)
                             {
                                 histogramthreshold->numberofhits++;                        
-                                fillAHistogramsinclass(histogramthreshold, hiti, completeclustersize, pixelSum, notSeedSum, &a_pixelSum[0], &a_notSeedSum[0]);
+                                fillAHistogramsinclass(histogramthreshold, hiti, completeclustersize, pixelSum, notSeedSum, &a_pixelSum[0], &a_notSeedSum[0], pixelSum25, notSeedSum25, &a_pixelSum25[0], &a_notSeedSum25[0], pixelSum9, notSeedSum9, &a_pixelSum9[0], &a_notSeedSum9[0]);
                                     
                                 // bin the RTS cleaned histogram class
                                 if (histogramwoRTSthreshold != 0) {
@@ -1394,7 +1449,7 @@ Bool_t Run::binSeedSumVeto()
                                         }
                                     }
                                     if (!RTSpixel) {                                
-                                        fillAHistogramsinclass(histogramwoRTSthreshold, hiti, completeclustersize, pixelSum, notSeedSum, &a_pixelSum[0], &a_notSeedSum[0]);
+                                        fillAHistogramsinclass(histogramwoRTSthreshold, hiti, completeclustersize, pixelSum, notSeedSum, &a_pixelSum[0], &a_notSeedSum[0], pixelSum25, notSeedSum25, &a_pixelSum25[0], &a_notSeedSum25[0], pixelSum9, notSeedSum9, &a_pixelSum9[0], &a_notSeedSum9[0]);
                                     }
                                 }
                                 // bin the more agressive RTS histogram class
@@ -1408,7 +1463,7 @@ Bool_t Run::binSeedSumVeto()
                                         }
                                     }
                                     if (!RTSpixel) {
-                                        fillAHistogramsinclass(histogramwoRTSAggresivethreshold, hiti, completeclustersize, pixelSum, notSeedSum, &a_pixelSum[0], &a_notSeedSum[0]);
+                                        fillAHistogramsinclass(histogramwoRTSAggresivethreshold, hiti, completeclustersize, pixelSum, notSeedSum, &a_pixelSum[0], &a_notSeedSum[0], pixelSum25, notSeedSum25, &a_pixelSum25[0], &a_notSeedSum25[0], pixelSum9, notSeedSum9, &a_pixelSum9[0], &a_notSeedSum9[0]);
                                     }
                                 }
                                 
@@ -1425,7 +1480,7 @@ Bool_t Run::binSeedSumVeto()
                                     
                                 }
                                 if (!RTSpixel) {
-                                    fillAHistogramsinclass(histogramwoRTS, hiti, completeclustersize, pixelSum, notSeedSum, &a_pixelSum[0], &a_notSeedSum[0]);
+                                    fillAHistogramsinclass(histogramwoRTS, hiti, completeclustersize, pixelSum, notSeedSum, &a_pixelSum[0], &a_notSeedSum[0], pixelSum25, notSeedSum25, &a_pixelSum25[0], &a_notSeedSum25[0], pixelSum9, notSeedSum9, &a_pixelSum9[0], &a_notSeedSum9[0]);
                                 }                    
                             }           
                             // bin the more agressive RTS histogram class
@@ -1440,7 +1495,7 @@ Bool_t Run::binSeedSumVeto()
                                     }
                                 }
                                 if (!RTSpixel) {
-                                    fillAHistogramsinclass(histogramwoRTSAggresive, hiti, completeclustersize, pixelSum, notSeedSum, &a_pixelSum[0], &a_notSeedSum[0]);
+                                    fillAHistogramsinclass(histogramwoRTSAggresive, hiti, completeclustersize, pixelSum, notSeedSum, &a_pixelSum[0], &a_notSeedSum[0], pixelSum25, notSeedSum25, &a_pixelSum25[0], &a_notSeedSum25[0], pixelSum9, notSeedSum9, &a_pixelSum9[0], &a_notSeedSum9[0]);
                                 }                        
                             }
                         } else if (filli == 1) { // second fill round, some histograms are allready filled
@@ -1449,13 +1504,14 @@ Bool_t Run::binSeedSumVeto()
                             // bin the fixed threshold for charge histogram class
                             if (histogramfixedthreshold != 0 && histogram != 0) {
                                 if (histogramfixedthreshold->fixedThresholdValue <= 0) {
-                                    float_t cutval = histogram->Sum->GetBinCenter(histogram->Sum->FindLastBinAbove(3,1));
-                                    setFixedThresholdValueADU(cutval*0.5); // change back to *0.8
+                                    Float_t highestval = histogram->Seed->GetMaximum();
+                                    float_t cutval = (*histogram->Sum)->GetBinCenter((*histogram->Sum)->FindLastBinAbove(highestval/4,1));
+                                    setFixedThresholdValueADU(cutval*0.6); // change back to *0.8
                                 }
                                 if (pixelSum > histogramfixedthreshold->fixedThresholdValue) // charge is more then histogramfixedthreshold->fixedThresholdValue in whole cluster
                                 {
                                     histogramfixedthreshold->numberofhits++;                            
-                                    fillAHistogramsinclass(histogramfixedthreshold, hiti, completeclustersize, pixelSum, notSeedSum, &a_pixelSum[0], &a_notSeedSum[0]);
+                                    fillAHistogramsinclass(histogramfixedthreshold, hiti, completeclustersize, pixelSum, notSeedSum, &a_pixelSum[0], &a_notSeedSum[0], pixelSum25, notSeedSum25, &a_pixelSum25[0], &a_notSeedSum25[0], pixelSum9, notSeedSum9, &a_pixelSum9[0], &a_notSeedSum9[0]);
                                 }
                             }
                             
@@ -1497,7 +1553,7 @@ Bool_t Run::binSeedSumVeto()
                                 
                                 if (histogramGoodVeto->pixelHadGoodVeto->GetBinContent(pixelno+1) > 1) {
                                     histogramGoodVeto->numberofhits++;                            
-                                    fillAHistogramsinclass(histogramGoodVeto, hiti, completeclustersize, pixelSum, notSeedSum, &a_pixelSum[0], &a_notSeedSum[0]);
+                                    fillAHistogramsinclass(histogramGoodVeto, hiti, completeclustersize, pixelSum, notSeedSum, &a_pixelSum[0], &a_notSeedSum[0], pixelSum25, notSeedSum25, &a_pixelSum25[0], &a_notSeedSum25[0], pixelSum9, notSeedSum9, &a_pixelSum9[0], &a_notSeedSum9[0]);
                                 }
                             }
                         
@@ -1538,20 +1594,29 @@ Bool_t Run::binSeedSumVeto()
         (*curHistogramClass)->integralSeed = parameters[6];
         (*curHistogramClass)->posSeed = parameters[1];
         (*curHistogramClass)->integralSeedErr = parameters[9];
-        parameters = (*curHistogramClass)->FitPerform((*curHistogramClass)->Sum, "gaus", 0, false, (*curHistogramClass)->fixedThresholdValue); //TODO change back to gauss
+        parameters = (*curHistogramClass)->FitPerform((*(*curHistogramClass)->Sum), "gaus", 0, false, (*curHistogramClass)->fixedThresholdValue); //TODO change back to gauss
         (*curHistogramClass)->posSum = parameters[1];
         (*curHistogramClass)->integralSum = parameters[6];
         (*curHistogramClass)->integralSumErr = parameters[9];
         
-        (*curHistogramClass)->clustermultiplicity /=(*curHistogramClass)->numberofhits;
+        for (Int_t bini = 1; bini <= (*curHistogramClass)->clustermultiplicity->GetNbinsX(); bini++) {
+            (*curHistogramClass)->clustermultiplicity->SetBinContent(bini, (*curHistogramClass)->clustermultiplicity->GetBinContent(bini)/(*curHistogramClass)->numberofhits); }
         
-        for (u_int sumi = 0; sumi < (*curHistogramClass)->a_Sum.size(); sumi++) {
+        for (u_int sumi = 0; sumi < (*curHistogramClass)->a_Sum9.size(); sumi++) {
+            //             Float_t integratestart = (*curHistogramClass)->FindNoisethresholdborder((*curHistogramClass)->a_Sum[sumi], false, false);
+            //             parameters = (*curHistogramClass)->FitPerform((*curHistogramClass)->a_Sum[sumi], "gaus", 0, false, integratestart); //TODO change back to gauss
+            parameters = (*curHistogramClass)->FitPerform((*curHistogramClass)->a_Sum9[sumi], "gaus", 0, false, (*curHistogramClass)->fixedThresholdValue); //TODO change back to gauss
+            (*curHistogramClass)->a_posSum9.push_back(parameters[1]);
+            (*curHistogramClass)->a_integralSum9.push_back(parameters[6]);
+            (*curHistogramClass)->a_integralSumErr9.push_back(parameters[9]);
+        }
+        for (u_int sumi = 0; sumi < (*curHistogramClass)->a_Sum25.size(); sumi++) {
             //             Float_t integratestart = (*curHistogramClass)->FindNoisethresholdborder((*curHistogramClass)->a_Sum[sumi], false, false);
 //             parameters = (*curHistogramClass)->FitPerform((*curHistogramClass)->a_Sum[sumi], "gaus", 0, false, integratestart); //TODO change back to gauss
-            parameters = (*curHistogramClass)->FitPerform((*curHistogramClass)->a_Sum[sumi], "gaus", 0, false, (*curHistogramClass)->fixedThresholdValue); //TODO change back to gauss
-            (*curHistogramClass)->a_posSum.push_back(parameters[1]);
-            (*curHistogramClass)->a_integralSum.push_back(parameters[6]);
-            (*curHistogramClass)->a_integralSumErr.push_back(parameters[9]);
+            parameters = (*curHistogramClass)->FitPerform((*curHistogramClass)->a_Sum25[sumi], "gaus", 0, false, (*curHistogramClass)->fixedThresholdValue); //TODO change back to gauss
+            (*curHistogramClass)->a_posSum25.push_back(parameters[1]);
+            (*curHistogramClass)->a_integralSum25.push_back(parameters[6]);
+            (*curHistogramClass)->a_integralSumErr25.push_back(parameters[9]);
         }
         
         parameters =(*curHistogramClass)->FitPerform((*curHistogramClass)->SeedPerc, "landau");
@@ -1570,18 +1635,33 @@ Bool_t Run::binSeedSumVeto()
     return 0;
 }
 
-void Run::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) {
+void Run::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) {
     histogramtypepointer->Seed->Fill(processed->fFrameInfo.p[12][hiti]);
-    histogramtypepointer->Sum->Fill(pixelSum);                           
+    histogramtypepointer->Sum9->Fill(pixelSum9);                           
+    histogramtypepointer->Sum25->Fill(pixelSum25);                           
     for (Int_t clusterj=0; clusterj<completeclustersize; clusterj++) {
-        histogramtypepointer->a_Sum[clusterj]->Fill(pt_a_pixelSum[clusterj]);  
+        histogramtypepointer->a_Sum25[clusterj]->Fill(pt_a_pixelSum25[clusterj]);  
+    }                        
+    for (u_int clusterj=0; clusterj<histogramtypepointer->a_Sum9.size(); clusterj++) {
+        histogramtypepointer->a_Sum9[clusterj]->Fill(pt_a_pixelSum9[clusterj]);  
     }
     histogramtypepointer->SeedPerc->Fill(processed->fFrameInfo.p[12][hiti]/pixelSum*100);  
-    if (TMath::Abs(notSeedSum) < cursystemparam.vetothreshold && (labbook.source.Contains("Fe")||labbook.source.Contains("Cd")))
+    if (TMath::Abs(notSeedSum) < cursystemparam.vetothreshold && (labbook.source.Contains("Fe")||labbook.source.Contains("Cd"))) {
         histogramtypepointer->Veto->Fill(processed->fFrameInfo.p[12][hiti]);    // histogram with the single pixel
-        
-    if (pt_a_pixelSum[1]-pt_a_pixelSum[0] > labbook.NoiseAvgADC_DB*5)
-        histogramtypepointer->clustermultiplicity++;
+    }    
+
+    if (pt_a_pixelSum[5]-pt_a_pixelSum[0]-pt_a_pixelSum[1]-pt_a_pixelSum[2]-pt_a_pixelSum[3]-pt_a_pixelSum[4] > labbook.NoiseAvgADC_DB*5)
+        histogramtypepointer->clustermultiplicity->Fill(6);
+    else if (pt_a_pixelSum[4]-pt_a_pixelSum[0]-pt_a_pixelSum[1]-pt_a_pixelSum[2]-pt_a_pixelSum[3] > labbook.NoiseAvgADC_DB*5)
+        histogramtypepointer->clustermultiplicity->Fill(5);
+    else if (pt_a_pixelSum[3]-pt_a_pixelSum[0]-pt_a_pixelSum[1]-pt_a_pixelSum[2] > labbook.NoiseAvgADC_DB*5)
+        histogramtypepointer->clustermultiplicity->Fill(4);
+    else if (pt_a_pixelSum[2]-pt_a_pixelSum[0]-pt_a_pixelSum[1] > labbook.NoiseAvgADC_DB*5)
+        histogramtypepointer->clustermultiplicity->Fill(3);
+    else if (pt_a_pixelSum[1]-pt_a_pixelSum[0] > labbook.NoiseAvgADC_DB*5)
+        histogramtypepointer->clustermultiplicity->Fill(2);
+    else
+        histogramtypepointer->clustermultiplicity->Fill(1);
 }
 
 
@@ -1883,7 +1963,7 @@ Bool_t Run::plotCompareHistograms()
             curhistogramclone->SetAxisRange(0,lastbin1*1.1,"X");
             gPad->SetLogy(1);
             canvas->cd(2);
-            curhistogramclone = (TH1F*) curhistogramclassp->Sum->Clone();
+            curhistogramclone = (TH1F*) (*curhistogramclassp->Sum)->Clone();
             curhistogramclone->SetLineColor(rootcolors[histogrami]);
             curhistogramclone->Draw("SAME");
             leg1->Draw("SAME");
@@ -1943,12 +2023,12 @@ Bool_t Run::plotAllHistograms(HistogramType* HistogramTypepointer)
         owntitle->AddText(trimRunnumberAtBegin(HistogramTypepointer->Seed->GetName()));
         owntitle->Draw("SAME");        
         canvas->cd(2);
-        HistogramTypepointer->Sum->Draw();
-        plotVerticalLine(HistogramTypepointer->Sum, HistogramTypepointer->posSum);
-        lastbin = HistogramTypepointer->Sum->GetBinCenter(HistogramTypepointer->Sum->FindLastBinAbove(2,1));
-        HistogramTypepointer->Sum->SetAxisRange(0,lastbin*1.1,"X");
+        (*HistogramTypepointer->Sum)->Draw();
+        plotVerticalLine((*HistogramTypepointer->Sum), HistogramTypepointer->posSum);
+        lastbin = (*HistogramTypepointer->Sum)->GetBinCenter((*HistogramTypepointer->Sum)->FindLastBinAbove(2,1));
+        (*HistogramTypepointer->Sum)->SetAxisRange(0,lastbin*1.1,"X");
         owntitle2->Clear();
-        owntitle2->AddText(trimRunnumberAtBegin(HistogramTypepointer->Sum->GetName()));
+        owntitle2->AddText(trimRunnumberAtBegin((*HistogramTypepointer->Sum)->GetName()));
         owntitle2->Draw("SAME");
         canvas->cd(3);
         HistogramTypepointer->Veto->Draw();
@@ -2339,8 +2419,8 @@ Bool_t Run::writeAllHistogramsToFile()
     {
         outline=Form("%.1f\t%.1f\t", histogram->Seed->GetBinCenter(bin), histogram->calibrated!=0?histogram->calibrated->Seed->GetBinCenter(bin):0);
         for (vector<HistogramType*>::iterator curHistogramClass = HistogramClassVector.begin(); curHistogramClass != HistogramClassVector.end(); curHistogramClass++)  {
-            outline+=Form("%.1f\t%.1f\t%.1f\t", (*curHistogramClass)->Seed->GetBinContent(bin), (*curHistogramClass)->Sum->GetBinContent(bin), (*curHistogramClass)->Veto->GetBinContent(bin));
-            outline+=Form("%.1f\t%.1f\t%.1f\t", (*curHistogramClass)->normalized->Seed->GetBinContent(bin), (*curHistogramClass)->normalized->Sum->GetBinContent(bin), (*curHistogramClass)->normalized->Veto->GetBinContent(bin));
+            outline+=Form("%.1f\t%.1f\t%.1f\t", (*curHistogramClass)->Seed->GetBinContent(bin), (*(*curHistogramClass)->Sum)->GetBinContent(bin), (*curHistogramClass)->Veto->GetBinContent(bin));
+            outline+=Form("%.1f\t%.1f\t%.1f\t", (*curHistogramClass)->normalized->Seed->GetBinContent(bin), (*(*curHistogramClass)->normalized->Sum)->GetBinContent(bin), (*curHistogramClass)->normalized->Veto->GetBinContent(bin));
         }
         if (bin <= cursystemparam.nbinsnoise)
             outline+=Form("%.1f\t%.1f\t%.1f", histogram->Noise->GetBinCenter(bin),histogram->calibrated!=0?histogram->calibrated->Noise->GetBinCenter(bin):0,histogram->Noise->GetBinContent(bin));
index 8112a85d77647ee0e57ecd5c5037bf2edc6c2470..8b6231e25109cdc7131e7874a4193817f04ffbc6 100644 (file)
@@ -70,9 +70,7 @@ private:
     TSQLResult *res;
     /// number of rows the SQL database found to a given request
     int nrows=0;
-    
-    Int_t plotStyle=0;
-    
+        
     /** @brief is set to true, if custom label is used */
     Bool_t customLabel = false;
     
@@ -201,7 +199,7 @@ private:
      * 
      * 
      */
-    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);
+    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;
@@ -234,6 +232,7 @@ public:
     systemparam cursystemparam; 
     
     void setPlotStyle(Int_t);
+    Int_t plotStyle=0;
     
     /** @brief sets a custom description to be used as a label when plotting the run */
     Bool_t setLabel(TString newlabel);