]> jspc29.x-matter.uni-frankfurt.de Git - radhard.git/commitdiff
analyzer: added automatic threshold setting for fixed threshold histo, fixed veto...
authorTobias Bus <tbus@jspc48.x-matter.uni-frankfurt.de>
Fri, 1 Sep 2017 14:54:43 +0000 (16:54 +0200)
committerTobias Bus <tbus@jspc48.x-matter.uni-frankfurt.de>
Fri, 1 Sep 2017 14:54:43 +0000 (16:54 +0200)
MABS_run_analyzer/ChargeSpektrum.c
MABS_run_analyzer/HistogramType.h
MABS_run_analyzer/Run.c
MABS_run_analyzer/Run.h
MABS_run_analyzer/help.h

index 36350d046ee8a75cc2fd5348bf805f7f83010782..77b121c77c8318bc0803997e17f2df427dc1c98d 100644 (file)
@@ -60,12 +60,13 @@ void ChargeSpektrum(TString runnumber = "")
 //                 if (runi == 2)
 //                     runs[runi]->setSubMatrixBorders(100,120,100,120);
                 //runs[runi]->setFixedThresholdValueElectrons(1440);   
-                runs[runi]->setFixedThresholdValueADU(runs[runi]->labbook.posSeedDB*0.7);
+//             float_t cutval = runs[runi]->histogramwoRTS->Sum->GetBinCenter(runs[runi]->histogramwoRTS->Sum->FindLastBinAbove(3,1));
+//                 runs[runi]->setFixedThresholdValueADU(cutval*0.6);
                 //runs[runi]->setNoisethresholdborderADU(800);
              //runs[runi]->setNoisethresholdborderE(220);
 
 //                                 runs[runi]->analyzeFrame(6384);
-//                 runs[runi]->analyzeFrame(6605);
+//                 runs[runi]->analyzeFrame(1970548);
 //                   runs[runi]->analyzeFrame(1994914);
 //                 runs[runi]->analyzeFrame(680);
 //                 runs[runi]->analyzeFrame(685);
@@ -103,9 +104,13 @@ void ChargeSpektrum(TString runnumber = "")
                         gROOT->SetBatch(kFALSE);
                     
                     // Uncomment below to do classical analysis withour RTS
-                    compareHistogramClassVector.push_back(runs[runi]->histogramwoRTS->normalized);
+                    compareHistogramClassVector.push_back(runs[runi]->histogramwoRTS);
+                    compareHistogramClassVector.push_back(runs[runi]->histogramfixedthreshold);
+                    
 //                     compareHistogramClassVector2.push_back(runs[runi]->histogramwoRTS);
-//                     compareHistogramClassVector.push_back(runs[runi]->histogram->normalized);
+                     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);
@@ -119,12 +124,20 @@ void ChargeSpektrum(TString runnumber = "")
 //                     compareHistogramVector.push_back(runs[runi]->histogramfixedthreshold->Seed);
 //                     compareHistogramVector.push_back(runs[runi]->histogramfixedthreshold->normalized->Seed);
 //                     runs[runi]->plot1DHistogram( runs[runi]->histogramfixedthreshold->normalized->Seed, "gaus", true, false, false, 500);
-                    runs[runi]->plot1DHistogram( runs[runi]->histogramwoRTS->normalized->Seed, "GaussTail");
+                    //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]->histogramfixedthreshold->normalized->Seed, "gaus", true, false, false, runs[runi]->histogramfixedthreshold->normalized->fixedThresholdValue);
 //                     runs[runi]->plot1DHistogram( runs[runi]->histogramfixedthreshold->normalized->Sum, "gaus", true, false, false, 500);
                     
                     // plot RTS pixel histogram
-//                     runs[runi]->plot1DHistogram( runs[runi]->histogramwoRTS->pixeltimefiredDistrib, "", 0);
+                     runs[runi]->plot1DHistogram( runs[runi]->histogramwoRTS->pixeltimefiredDistrib, "", 0);
                     
                   
                     
index c1fbe66feef3cab74dcf9c2fb5cf2a93e4a619d1..51ecb57d325face0066093de68082954d08e6012 100644 (file)
@@ -228,7 +228,7 @@ public:
     * It is set as a multiply of the standard deviation
     *      
     */
-    Float_t RTSthreshold = 4;
+    Float_t RTSthreshold = 10;
     
     //*****************
     // GETTER AND SETTER
index 978587f53cc81f79deecdcd4f8e069fe78ad729d..ffdcc1f22e04a49ce9ee11bd951360ddabb3d286 100644 (file)
@@ -179,7 +179,7 @@ Run::Run(Int_t runnumber, Int_t loopi, TString customtitle)
             
              histogramwoRTSAggresive = new HistogramType(" more RTS cleaned", &cursystemparam, &cursensorinfo, humanreadablestr, &labbook, this, rootcolors[plotStyle], rootlinestyle[plotStyle]);
              histogramwoRTSAggresive->maskRTSpixel = true;
-             histogramwoRTSAggresive->RTSthreshold = 1.5;
+             histogramwoRTSAggresive->RTSthreshold = 4;
              HistogramClassVector.push_back(histogramwoRTSAggresive);
             //             histogramwoRTSAggresivethreshold = new HistogramType(" Threshold, more RTS cleaned", &cursystemparam, &cursensorinfo, humanreadablestr, &labbook, this, rootcolors[plotStyle], rootlinestyle[plotStyle] );
 //             histogramwoRTSAggresivethreshold->maskRTSpixel = true;
@@ -255,7 +255,7 @@ void Run::setSystemSpecificParameters()
     systemparam systemparamPXI (800*16,800,75,150,150);
     systemparam systemparamFSBB (2800,2800/4,25,10,100);
     systemparam systemparamUSBMi19 (400/*maxbin*/,400/1/*nbins*/, 25/*vetothreshold*/, 10/*maxbinnoise*/, 100/*nbinsnoise*/);
-    systemparam systemparamPipper2 (1000,200,15,10,100);
+    systemparam systemparamPipper2 (1000,200,25,10,100);
     if (labbook.system.EqualTo("USB")  && labbook.chipGen.EqualTo("Mi34") )
         cursystemparam = systemparamUSB;
     else if (labbook.system.EqualTo("USB")  && labbook.chipGen.EqualTo("FSBB") )
@@ -1027,8 +1027,8 @@ void Run::updateDatabase() {
         constructUpdateString(&sqlupdatequery, "Avg.Noise+", histogramclassToUseForDB->normalized->calibrated->avgNoisePlus, 3, 0, 1000);
     if (histogramclassToUseForDB->normalized->calibrated != 0)
         constructUpdateString(&sqlupdatequery, "Avg.Noise-", histogramclassToUseForDB->normalized->calibrated->avgNoiseMinus, 3, 0, 1000);
-    constructUpdateString(&sqlupdatequery, "CCE_1",      histogramclassToUseForDB->normalized->CCE_in_Perc_1, 2, 0 , 100);
-    constructUpdateString(&sqlupdatequery, "CCE_25",     histogramclassToUseForDB->normalized->CCE_in_Perc_25, 2, 0 , 100);
+    constructUpdateString(&sqlupdatequery, "CCE_1",      histogramclassToUseForDB->normalized->CCE_in_Perc_1, 2, 0 , 110);
+    constructUpdateString(&sqlupdatequery, "CCE_25",     histogramclassToUseForDB->normalized->CCE_in_Perc_25, 2, 0 , 110);
     constructUpdateString(&sqlupdatequery, "StoN",     histogramclassToUseForDB->normalized->StoN, 3, 0 , 100);
     constructUpdateString(&sqlupdatequery, "Avg.NoiseADC",  histogramclassToUseForDB->normalized->avgNoise, 2, 0 , 1000);
     constructUpdateString(&sqlupdatequery, "Avg.NoiseADC+",  histogramclassToUseForDB->normalized->avgNoisePlus, 2, 0 , 1000);
@@ -1252,7 +1252,7 @@ Bool_t Run::binF0()
 
 Bool_t Run::binSeedSumVeto()
 {        
-    /// collected charge in cluster
+    /// 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];
@@ -1298,20 +1298,21 @@ Bool_t Run::binSeedSumVeto()
                         a_pixelSum[clusteri]  = 0;
                         a_notSeedSum[clusteri] = 0;
                     }
+                    //cout << colorpurple << framei << endlr;
                     
                     // 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] = 0;
-//                         for (Int_t clusteri=completeclustersize-sqrt(completeclustersize); clusteri<completeclustersize; clusteri++) 
-//                             processed->fFrameInfo.p[clusteri][hiti] = 0;
-//                         for (Int_t clusteri=0; clusteri<completeclustersize; clusteri=clusteri+sqrt(completeclustersize)) 
-//                             processed->fFrameInfo.p[clusteri][hiti] = 0;
-//                         for (Int_t clusteri=4; clusteri<completeclustersize; clusteri=clusteri+sqrt(completeclustersize)) 
-//                             processed->fFrameInfo.p[clusteri][hiti] = 0;
-//                     }
+                    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;
+                    }
                        
-                    // DEBUG
+//                     DEBUG
 //                     for (Int_t clusteri=0; clusteri<sqrt(completeclustersize); clusteri++)  {
 //                         for (Int_t clusterj=0; clusterj<sqrt(completeclustersize); clusterj++) 
 //                             cout << " " << processed->fFrameInfo.p[clusteri*5+clusterj][hiti];
@@ -1327,18 +1328,19 @@ Bool_t Run::binSeedSumVeto()
                     TMath::Sort(completeclustersize,clusterArray,index,1);
                     for (Int_t clusteri=0; clusteri<completeclustersize; clusteri++)
                     {
-                        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[clusteri][hiti];
-                            for (Int_t clusterj=clusteri; clusterj<completeclustersize; clusterj++) { // not used yet
-                                a_notSeedSum[clusterj] += clusterArray[index[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]];
+                               }
+                           }
+                       }
                     }
                     histogram->Sum->Fill(pixelSum);  
                     for (Int_t clusterj=0; clusterj<completeclustersize; clusterj++) {
@@ -1356,16 +1358,7 @@ Bool_t Run::binSeedSumVeto()
                     if (TMath::Abs(notSeedSum) < cursystemparam.vetothreshold && (labbook.source.Contains("Fe")||labbook.source.Contains("Cd")))
                         histogram->Veto->Fill(processed->fFrameInfo.p[12][hiti]);    // histogram with the single pixel
                     
-                    
-                    // bin the fixed threshold for charge histogram class
-                    if (histogramfixedthreshold != 0) {
-                        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]);
-                        }
-                    }
-                    
+                                        
                     if (processed->fFrameInfo.pixelthreshold[hiti]>0)
                     {
                         histogramthreshold->numberofhits++;                        
@@ -1440,6 +1433,79 @@ Bool_t Run::binSeedSumVeto()
             } // end loop over hits in frame
         }
     } // end loop over all frames
+    
+    // histogramfixedthreshold relies on "histogram", therefore histogram has to be completly filled before a threshold can be Set
+    for (Int_t framei=0; framei<processed->fHitTree->GetEntries(); framei++) // loop over all frames
+    {
+        processed->fHitTree->GetEntry(framei);
+        {
+            for(Int_t hiti=0; (unsigned int)hiti<processed->fFrameInfo.hits;hiti++)
+            {
+                uint pixel_column_x = processed->fFrameInfo.pixel[hiti]%cursensorinfo.columns;    //  column of seed
+                uint pixel_row_y = processed->fFrameInfo.pixel[hiti]/cursensorinfo.columns;       //  row of seed
+                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;                    
+                    // sum histogram
+                    for (Int_t clusteri=0; clusteri<completeclustersize; clusteri++) {
+                        a_pixelSum[clusteri]  = 0;
+                        a_notSeedSum[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 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++)
+                    {
+                        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]];
+                               }
+                           }
+                       }                     
+                    }
+                    
+                    // bin the fixed threshold for charge histogram class
+                    if (histogramfixedthreshold != 0) {
+                       if (histogramfixedthreshold->fixedThresholdValue <= 0) {
+                         float_t cutval = histogram->Sum->GetBinCenter(histogram->Sum->FindLastBinAbove(3,1));
+                         setFixedThresholdValueADU(cutval*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]);
+                        }
+                    }
+               }
+           }
+       }
+    }
+    
+    
+    
     //     gROOT->SetBatch(kTRUE);
     for (vector<HistogramType*>::iterator curHistogramClass = HistogramClassVector.begin(); curHistogramClass != HistogramClassVector.end(); curHistogramClass++)  {
         Double_t* parameters = (Double_t *)calloc(11, sizeof(Double_t)); // allocate 11 parameters for safety, maximum 10 used at the moment     
index 7457e8c2594266a46ed71b3518fc31ef34c9d8a1..8112a85d77647ee0e57ecd5c5037bf2edc6c2470 100644 (file)
@@ -424,9 +424,9 @@ public:
      */
     Bool_t plotClusterDistribution(HistogramType*);
     
-    TCanvas* plot1DHistogram(HistogramType* histogramtypepointer, TH1FO* onehistogram, TString fitFuncType = "landau", Bool_t verbose = false, Bool_t logscale =false, Bool_t withOverflow=false, Float_t fitstart=-1, TString titlestr = "", TString legendstr = "");
     TCanvas* plot1DHistogram(TH1FO* onehistogram, TString fitFuncType = "landau", Bool_t verbose = false, Bool_t logscale =false, Bool_t withOverflow=false, Float_t fitstart=-1, TString titlestr = "", TString legendstr = "");
-    
+    TCanvas* plot1DHistogram(HistogramType* histogramtypepointer, TH1FO* onehistogram, TString fitFuncType = "landau", Bool_t verbose = false, Bool_t logscale =false, Bool_t withOverflow=false, Float_t fitstart=-1, TString titlestr = "", TString legendstr = "");
+        
     pixelinfo pixelinfoMi34[32];
         
     /// analyze only half of matrix
index d0aae5cfd431a1c52150f490c9e264f61aa7aebf..880334e7bdad81862e2bf1d3b37eecb0b38d9412 100644 (file)
@@ -196,6 +196,7 @@ const TString colorwhite = "\033[1;29m";
 const TString colorred = "\033[1;31m";
 const TString coloryellow = "\033[1;33m";
 const TString colorgreen = "\033[1;32m";
+const TString colorpurple = "\033[1;35m";
 const TString colorcyan = "\033[1;36m";
 const TString colorreset = "\033[0m";  
 const TString endlr = "\033[0m\n";