]> jspc29.x-matter.uni-frankfurt.de Git - radhard.git/commitdiff
Run analyzer: Added cluster threshold hit finding method
authorBenjamin Linnik <blinnik@jspc28.x-matter.uni-frankfurt.de>
Fri, 8 May 2015 07:51:13 +0000 (09:51 +0200)
committerBenjamin Linnik <blinnik@jspc28.x-matter.uni-frankfurt.de>
Fri, 8 May 2015 07:51:13 +0000 (09:51 +0200)
MABS_run_analyzer/ChargeSpektrum.c
MABS_run_analyzer/MAPS.c
MABS_run_analyzer/MAPS.h
MABS_run_analyzer/Run.c
MABS_run_analyzer/Run.h
MABS_run_analyzer/help.h

index 52e6147e0f798b3745011daa8f835fbe19ca9b4c..dccc79728e581964b9dbccca9b1ac60d4319eec0 100644 (file)
@@ -32,11 +32,11 @@ void plotAllRuns();
 
 Run** runs;
 Int_t numberRuns;
+Bool_t isBatch = kFALSE;
 
 void ChargeSpektrum(Int_t runnumber = -1)
 {
     cout << endl << endl; 
-    Bool_t isBatch = kFALSE;
     if (gROOT->IsBatch())
         isBatch = kTRUE;
     
@@ -85,7 +85,7 @@ void ChargeSpektrum(Int_t runnumber = -1)
         runs[runi]->setResultsPath("./results/");
         runs[runi]->setPlotStyle(runi);
         runs[runi]->useDynamicalNoise(true);
-        runs[runi]->analyzeRun(false); // creates or opens .root file, can analyze the RAW data
+        runs[runi]->analyzeRun(true); // creates or opens .root file, can analyze the RAW data
 //         gROOT->SetBatch(kTRUE);
 //           runs[runi]->plotSeed();
 //         runs[runi]->plotSum();
@@ -93,43 +93,12 @@ void ChargeSpektrum(Int_t runnumber = -1)
 //         runs[runi]->plotNoise();
         if (!isBatch)
             gROOT->SetBatch(kFALSE);
-//          runs[runi]->plotAllHistograms();
-//         runs[runi]->plotAllHistogramsCalibrated(); 
-//         runs[runi]->writeAllHistogramsToFile(); 
+        runs[runi]->plotAllHistograms();
+        runs[runi]->plotAllHistogramsThresholdCluster();
+//          runs[runi]->plotAllHistogramsCalibrated(); 
+        runs[runi]->writeAllHistogramsToFile(); 
     }
-
-    
-     plotAllRuns();
-    
-    //     TTimeStamp* time = new TTimeStamp();
-    //     TCanvas* canvas = new TCanvas(Form("%d",time->GetNanoSec()), "Summary", 800, 600);
-    //     canvas->SetGridy(kTRUE);
-    //     canvas->SetGridx(kTRUE);
-    //     TLegend* leg = new TLegend(0.5,0.8,0.89,0.89);
-    //     leg->SetFillColor(0);
-    //     leg->SetBorderSize(0);
-    //     for(Int_t runi=0;runi<numberRuns;runi++) // loop over runs read from file
-    //     {
-    //         runs[runi]->histogram.Seed->Draw("SAME");
-    //         leg->AddEntry(runs[runi]->histogram.Seed, runs[runi]->histogram.Seed->GetTitle(), "l");
-    //     }
-    //     leg->SetTextSize(0.03);
-    //     leg->Draw();
-    //     canvas->Modified();
-    //     canvas->cd(); 
-    //     canvas->SetSelected(canvas);
-    
-//     canvas -> SaveAs( savepathresults + "/" + runcode + " " + histogram->GetName() + ".eps");
-//     
-//     TImage *img = TImage::Create();
-//     img->FromPad(canvas);
-//     img->WriteImage(savepathresults + "/" + runcode + " " + histogram->GetName() + ".png");
-//     
-//     TFile *f = new TFile(savepathresults + "/" + runcode + " " + histogram->GetName() + ".root","UPDATE");
-//     f->WriteTObject(canvas);
-//     f->WriteTObject(img);
-    
-    
+//     plotAllRuns();  
 }
 
 Int_t* ReadRunList()
@@ -165,51 +134,61 @@ void plotAllRuns()
 {
     Float_t lastbin;
     TTimeStamp* time = new TTimeStamp();
-    TCanvas* canvas = new TCanvas(Form("%d",time->GetNanoSec()), "Summary", 1600, 1000);
-    canvas->Divide(2,2);
-    Float_t height = numberRuns * 0.04;
-    TLegend* leg1 = new TLegend(0.3,1.0-height,0.89,0.89);//(0.6,0.7,0.89,0.89);
-    TLegend* leg2 = new TLegend(0.6,1.0-height,0.89,0.89);//(0.6,0.7,0.89,0.89);
-    leg1->SetTextSize(0.02);
-    leg2->SetTextSize(0.02);
-    leg1->SetFillColor(0); leg1->SetBorderSize(0);
-    leg2->SetFillColor(0); leg2->SetBorderSize(0);
-    TString  legendEntry;
-    
-    for(Int_t runi=0;runi<numberRuns;runi++) // loop over runs read from file
-    {
-        canvas->cd(1);
-        runs[runi]->histogram.Seed->Draw("SAME");
-        lastbin = runs[runi]->histogram.Seed->GetBinCenter(runs[runi]->histogram.Seed->FindLastBinAbove(2,1));
-        runs[runi]->histogram.Seed->SetAxisRange(0,lastbin*1.1,"X");
-        gPad->SetLogy(1);
-        legendEntry = Form("%s", runs[runi]->histogram.Seed->GetTitle());
-        leg1->AddEntry(runs[runi]->histogram.Veto, legendEntry, "l");
-        leg1->Draw("SAME");
-        canvas->cd(2);
-        runs[runi]->histogram.Sum->Draw("SAME");
-        lastbin = runs[runi]->histogram.Sum->GetBinCenter(runs[runi]->histogram.Sum->FindLastBinAbove(2,1));
-        runs[runi]->histogram.Sum->SetAxisRange(0,lastbin*1.1,"X");
-        canvas->cd(3);
-        runs[runi]->histogram.Veto->Draw("SAME");
-        runs[runi]->histogram.Veto->SetAxisRange(runs[runi]->histogram.posVeto*0.7,runs[runi]->histogram.posVeto*1.4,"X");
-        canvas->cd(4);
-        runs[runi]->histogram.Noise->Draw("SAME");
-        legendEntry = Form("%s, Noise: %.2f", runs[runi]->labbook.matrix.Data(), runs[runi]->histogram.avgNoise);
-        leg2->AddEntry(runs[runi]->histogram.Veto, legendEntry, "l");
-        leg2->Draw("SAME");
-    }
-    
-    //         canvas -> Print( runs[0]->savepathresults + "/" + canvastitle + ".eps");
-    
-    TImageDump *img = new TImageDump(runs[0]->savepathresults + "/" + Form("%s - %s",runs[0]->runcode.Data(), runs[numberRuns-1]->runcode.Data()) + ".png");
-    canvas->Paint();
-    img->Close();
     
-    TFile *f = new TFile(runs[0]->savepathresults + "/" + Form("%s - %s",runs[0]->runcode.Data(),runs[numberRuns-1]->runcode.Data()) + ".root","RECREATE");
-    f->cd();
-    f->Append(canvas);
-    f->Append(img);
-    f->Write();
+    cout << "-2" << endl;
+    TCanvas* canvas = new TCanvas(Form("%d",time->GetNanoSec()), "Summary", 1600, 1000);
+//     cout << "-1" << endl;
+//     if (isBatch)
+//         canvas->SetCanvasSize(1600,1000);
+//     
+//     cout << "0" << endl;
+//     canvas->Divide(2,2);
+//     Float_t height = numberRuns * 0.04;
+//     cout << "1" << endl;
+//     TLegend* leg1 = new TLegend(0.3,1.0-height,0.89,0.89);//(0.6,0.7,0.89,0.89);
+//     TLegend* leg2 = new TLegend(0.6,1.0-height,0.89,0.89);//(0.6,0.7,0.89,0.89);
+//     cout << "2" << endl;
+//     leg1->SetTextSize(0.02);
+//     leg2->SetTextSize(0.02);
+//     cout << "3" << endl;
+//     leg1->SetFillColor(0); leg1->SetBorderSize(0);
+//     leg2->SetFillColor(0); leg2->SetBorderSize(0);
+//     cout << "4" << endl;
+//     TString  legendEntry;
+//     
+//     for(Int_t runi=0;runi<numberRuns;runi++) // loop over runs read from file
+//     {
+//         canvas->cd(1);
+//         runs[runi]->histogram.Seed->Draw("SAME");
+//         lastbin = runs[runi]->histogram.Seed->GetBinCenter(runs[runi]->histogram.Seed->FindLastBinAbove(2,1));
+//         runs[runi]->histogram.Seed->SetAxisRange(0,lastbin*1.1,"X");
+//         gPad->SetLogy(1);
+//         legendEntry = Form("%s", runs[runi]->histogram.Seed->GetTitle());
+//         leg1->AddEntry(runs[runi]->histogram.Veto, legendEntry, "l");
+//         leg1->Draw("SAME");
+//         canvas->cd(2);
+//         runs[runi]->histogram.Sum->Draw("SAME");
+//         lastbin = runs[runi]->histogram.Sum->GetBinCenter(runs[runi]->histogram.Sum->FindLastBinAbove(2,1));
+//         runs[runi]->histogram.Sum->SetAxisRange(0,lastbin*1.1,"X");
+//         canvas->cd(3);
+//         runs[runi]->histogram.Veto->Draw("SAME");
+//         runs[runi]->histogram.Veto->SetAxisRange(runs[runi]->histogram.posVeto*0.7,runs[runi]->histogram.posVeto*1.4,"X");
+//         canvas->cd(4);
+//         runs[runi]->histogram.Noise->Draw("SAME");
+//         legendEntry = Form("%s, Noise: %.2f", runs[runi]->labbook.matrix.Data(), runs[runi]->histogram.avgNoise);
+//         leg2->AddEntry(runs[runi]->histogram.Veto, legendEntry, "l");
+//         leg2->Draw("SAME");
+//     }
+//     
+//     //         canvas -> Print( runs[0]->savepathresults + "/" + canvastitle + ".eps");
+//     TImageDump *img = new TImageDump(runs[0]->savepathresults + "/" + Form("%s - %s",runs[0]->runcode.Data(), runs[numberRuns-1]->runcode.Data()) + ".png");
+//     canvas->Paint();
+//     img->Close();
+//     
+//     TFile *f = new TFile(runs[0]->savepathresults + "/" + Form("%s - %s",runs[0]->runcode.Data(),runs[numberRuns-1]->runcode.Data()) + ".root","RECREATE");
+//     f->cd();
+//     f->Append(canvas);
+//     f->Append(img);
+//     f->Write();
 }
 
index 24e0844cf5f6c05b78cb661279e3cc9dc7dd2400..cf53a83896f418909eefb66297f9e16b06988386 100644 (file)
@@ -53,6 +53,7 @@ Bool_t MAPS::initNewRootFile() {
                 fHitTree->Branch("frame"    , &fFrameInfo.frame ,     "frame/i"         , 32000);
                 fHitTree->Branch("hits"     , &fFrameInfo.hits  ,     "hits/i"          , 32000);
                 fHitTree->Branch("pixel"    , &fFrameInfo.pixel[0]  , "pixel[hits]/i"   , 32000);
+                fHitTree->Branch("pixelthreshold", &fFrameInfo.pixelthreshold[0],"pixelthreshold[hits]/i", 32000);
                 for(int i=0; i<25; i++) {
                     fHitTree->Branch( Form("p%i",i+1)   , &fFrameInfo.p[i][0]   , Form("p%i [hits]/F",i+1)  , 32000);
                 }
@@ -88,6 +89,7 @@ Bool_t MAPS::initOldRootFile() {
     fHitTree->SetBranchAddress("frame" , &fFrameInfo.frame );
     fHitTree->SetBranchAddress("hits" , &fFrameInfo.hits );
     fHitTree->SetBranchAddress ("pixel", &fFrameInfo.pixel[0]);
+    fHitTree->SetBranchAddress ("pixelthreshold", &fFrameInfo.pixelthreshold[0]);
     for(int i=0; i<25; i++) {
         fHitTree->SetBranchAddress( Form("p%i",i+1)   , &fFrameInfo.p[i][0]);
     }
@@ -1133,13 +1135,19 @@ void MAPS::hitana() {
         TArrayI HITS;
         /// counts total number of hits
         Int_t HITNR = 0;
-        Int_t *Hitlist; // 
+        /// Array which holds the hit pixels indices, in other words: it holds the pixel number of the fired pixels
+        Int_t *Hitlist;
         Int_t A;
         Int_t B;
         Int_t DUMMY=0;
-        Float_t CLUSTER[25];
+        /// F0 - F1 of specific pixel in cluster
+        Float_t pixelchargeincluster[25]={ 0 };
+        ///noise of specific pixel in cluster
+        Float_t noiseincluster[25]={ 0 };
         Int_t CHANCE;
         Bool_t bordercluster=false;
+        Float_t noisesumincluster=0;
+        Float_t chargesumincluster=0;
         
         for(Int_t i=0; i<fPixels; i++)
         {
@@ -1169,11 +1177,13 @@ void MAPS::hitana() {
         //Begin: loop over all potential seed pixels:
         //Determine 'hit-vicinity':
         fHits = 0;
-        
+        /// Array which holds the hit pixels indices, in other words: it holds the pixel number of the fired pixels
         for(Int_t hit=0; hit<HITNR; hit++)
         {
             A = (Hitlist[hit])/fColumns;            // A: row of seed
             B = (Hitlist[hit])%fColumns;            // B: column of seed
+            noisesumincluster=0;
+            chargesumincluster=0;
             
             // Consider boundaries => Remove hits where the seed pixel is within 2 pixels beside the edge
             //  Hitlist[hit]%fColumn = x-coordinate of the seed pixel, Hitlist[hit]/fColumns = y-coordinate of the seed pixel
@@ -1190,25 +1200,29 @@ void MAPS::hitana() {
                     // und das Seed Pixel am Rand - in erster oder zweiten Reihe des Matrix liegt
                     if          ( (row==0) && (A<2) )                   {
 //                         cout << "WARNING: Clusters are filled with dummy values, please check MAPS.c hitana() cluster fill procedure." << endl;
-                        CLUSTER[(row*5)+column]=DUMMY;
+                        pixelchargeincluster[(row*5)+column]=DUMMY;
+                        noiseincluster[(row*5)+column]=DUMMY;
                     }
                     // wenn zweite Reihe des Clusters gefüllt werden soll
                     // und das Seed Pixel am Rand - in erster Reihe des Matrix liegt
                     else if     ( (row==1) && (A<1) )                   {
 //                         cout << "WARNING: Clusters are filled with dummy values, please check MAPS.c hitana() cluster fill procedure." << endl;
-                        CLUSTER[(row*5)+column]=DUMMY;
+                        pixelchargeincluster[(row*5)+column]=DUMMY;
+                        noiseincluster[(row*5)+column]=DUMMY;
                     }
                     // wenn vierte Reihe des Clusters gefüllt werden soll
                     // und das Seed Pixel am Rand - in letzter Reihe des Matrix liegt
                     else if     ( (row==3) && (A>= (fRows-1)) )         {
 //                         cout << "WARNING: Clusters are filled with dummy values, please check MAPS.c hitana() cluster fill procedure." << endl;
-                        CLUSTER[(row*5)+column]=DUMMY;
+                        pixelchargeincluster[(row*5)+column]=DUMMY;
+                        noiseincluster[(row*5)+column]=DUMMY;
                     }
                     // wenn vierte Reihe des Clusters gefüllt werden soll
                     // und das Seed Pixel am Rand - in vorletzter Reihe des Matrix liegt
                     else if     ( (row==4) && (A>= (fRows-2)) )         {
 //                         cout << "WARNING: Clusters are filled with dummy values, please check MAPS.c hitana() cluster fill procedure." << endl;
-                        CLUSTER[(row*5)+column]=DUMMY;
+                        pixelchargeincluster[(row*5)+column]=DUMMY;
+                        noiseincluster[(row*5)+column]=DUMMY;
                     }
                     else
                     {
@@ -1216,32 +1230,42 @@ void MAPS::hitana() {
                         // und das Seed Pixel am Rand - in erster oder zweiten Spalte des Matrix liegt
                         if      ( (column==0) && (B<2) )                {
 //                             cout << "WARNING: Clusters are filled with dummy values, please check MAPS.c hitana() cluster fill procedure." << endl;
-                            CLUSTER[(row*5)+column]=DUMMY;
+                            pixelchargeincluster[(row*5)+column]=DUMMY;
+                            noiseincluster[(row*5)+column]=DUMMY;
                         }                        
                         // wenn zweite Spalte des Clusters gefüllt werden soll
                         // und das Seed Pixel am Rand - in erster Spalte der Matrix liegt
                         else if ( (column==1) && (B==0) )               {
 //                             cout << "WARNING: Clusters are filled with dummy values, please check MAPS.c hitana() cluster fill procedure." << endl;
-                            CLUSTER[(row*5)+column]=DUMMY;
+                            pixelchargeincluster[(row*5)+column]=DUMMY;
+                            noiseincluster[(row*5)+column]=DUMMY;
                         }
                         // wenn dritte Spalte des Clusters gefüllt werden soll
                         // und das Seed Pixel am Rand - in letzter Spalte der Matrix liegt
                         else if ( (column==3) && (B==fColumns-1))       {
 //                             cout << "WARNING: Clusters are filled with dummy values, please check MAPS.c hitana() cluster fill procedure." << endl;
-                            CLUSTER[(row*5)+column]=DUMMY;
+                            pixelchargeincluster[(row*5)+column]=DUMMY;
+                            noiseincluster[(row*5)+column]=DUMMY;
                         }
                         // wenn letzte Spalte des Clusters gefüllt werden soll
                         // und das Seed Pixel am Rand - in vorletzter Spalte der Matrix liegt
                         else if ( (column==4) && (B>fColumns-3))        {
 //                             cout << "WARNING: Clusters are filled with dummy values, please check MAPS.c hitana() cluster fill procedure." << endl;
-                            CLUSTER[(row*5)+column]=DUMMY;
+                            pixelchargeincluster[(row*5)+column]=DUMMY;
+                            noiseincluster[(row*5)+column]=DUMMY;
                         }
                         else                                            {
-                            CLUSTER[(row*5)+column] = 1.*fCdsmatrix [Hitlist[hit]+(row-2)*fColumns+(column-2)] - fPedestals [Hitlist[hit]+(row-2)*fColumns+(column-2)];
+                            noiseincluster[(row*5)+column] = fNoise[Hitlist[hit]+(row-2)*fColumns+(column-2)];
+                            pixelchargeincluster[(row*5)+column] = 1.*fCdsmatrix [Hitlist[hit]+(row-2)*fColumns+(column-2)] - fPedestals [Hitlist[hit]+(row-2)*fColumns+(column-2)];
+                            noisesumincluster+=TMath::Power(noiseincluster[(row*5)+column],2);
+                            chargesumincluster+=pixelchargeincluster[(row*5)+column];
                         }
                     }
                 }
             }
+            noisesumincluster=TMath::Sqrt(noisesumincluster);
+//             cout << coloryellow << "Noise     für Cluster: " << noisesumincluster << endlr;
+//             cout << coloryellow << "ChargeSum für Cluster: " << chargesumincluster << endlr;
 //             debug
 //             for(Int_t row=0; row<5; row++)
 //             {
@@ -1249,7 +1273,7 @@ void MAPS::hitana() {
 //                 {
 //                     std::cout.width(10);
 //                     std::cout << std::fixed;
-//                     std::cout << std::left << std::setprecision(2) << CLUSTER[row*5+column];
+//                     std::cout << std::left << std::setprecision(2) << pixelchargeincluster[row*5+column];
 //                 }
 //                 cout << endl;
 //             }
@@ -1258,13 +1282,13 @@ void MAPS::hitana() {
             //Check seeds (whether highest entry in cluster):
             for(Int_t i=6; i<19; i++) // why not over full cluster? (I=0 i<25 TODO
             {
-                if          ( (i!=12) && (CLUSTER[i] > CLUSTER[12]) )               {
+                if          ( (i!=12) && (pixelchargeincluster[i] > pixelchargeincluster[12]) )               {
                     CHANCE=0;                    
-//                     cout << "kill cluster: " << Hitlist[hit] << " with ADC: " << CLUSTER[12] << endl;
+//                     cout << "kill cluster: " << Hitlist[hit] << " with ADC: " << pixelchargeincluster[12] << endl;
                     break;
                 }
                 // maybe this is unnecessary, if upper if clause is a >= comparison
-                else if     ( (i!=12) && (CLUSTER[i] == CLUSTER[12]) && i>12 )      {
+                else if     ( (i!=12) && (pixelchargeincluster[i] == pixelchargeincluster[12]) && i>12 )      {
                     cout << "WARNING: next pixel value identical to precessor" << endl;
                     CHANCE=0;    //NOTE: potential error source
                     break;
@@ -1316,14 +1340,20 @@ void MAPS::hitana() {
                     fFrameInfo.pixel[fHits] = Hitlist[hit];
                     for(int clupos=0; clupos<25; clupos++)
                     {
-                        fFrameInfo.p [clupos][fHits] = CLUSTER[clupos];
+                        fFrameInfo.p [clupos][fHits] = pixelchargeincluster[clupos];
                     }
                     
-                    fHits++;
-                    
+                    // if cluster charge > clusternoise * const
+                    if (1.0*chargesumincluster > noisesumincluster*3.0)
+                        fFrameInfo.pixelthreshold[fHits] = Hitlist[hit];
+                    else
+                        fFrameInfo.pixelthreshold[fHits] = 0;
+                        
                     if(fSave) {
                         hint1->Fill( Hitlist[hit]%fColumns, (int)(Hitlist[hit]/fColumns) );
                     }
+                    fHits++;
+                    
                 }
                 
             }
index b9e52b67ecc85130567451b8644224fada841a79..de141998c2f5e4029be5cc0584a8ccb8b64246e2 100644 (file)
@@ -120,16 +120,15 @@ private:
     std::queue<Float_t>* noiselastframes;
     std::queue<Float_t>* CDSlastframes;
     
+    /// Array wich indicates if a pixel in the current frame is a seed pixel (value=2), a cluster pixel (value=1), a border cluster (negative values) or not hit at all (value=0)
+    Int_t*      fHittedPixel;
     
     Int_t       fHits;
     /// Array mit der Größe Pixel * Frames, enthält CDS Werte
     Float_t*    fDynFrameArr; 
     /// Irgendein Array mit Grüße fPixels
     Int_t*      fDynCounter; 
-    
-    /// Array wich indicates if a pixel in the current frame is a seed pixel (value=2), a cluster pixel (value=1) or not hit at all (value=0)
-    Int_t*      fHittedPixel;
-        
+            
     /// Array of file handlers for each RAW files, filled in @c checkDataFiles()
     ifstream*   fInn;
     /// ROOT output file with hit, noise, cluster and pedestial information
index b1dceee79b45017bf7a4354a9719eb8e2827bcc2..0d82e87c5d08fc5cbaa36fe492537b311c00383e 100644 (file)
@@ -107,6 +107,7 @@ Run::Run(Int_t runnumber)
             initRootParameters();
             cout << colorwhite << "initHistograms():" << endlr;
             initHistograms(&histogram);
+            initHistograms(&histogramthreshold, " threshold");
             runexistsinDB = 1;
             debugDBreadout();
         }
@@ -158,8 +159,7 @@ Bool_t Run::useDynamicalNoise(Bool_t var)
     cout<<" Dynamical Noise calc. : " << colorwhite << (var?"1":"0") << colorreset << "  <-- only used if RAW files are analyzed, force analysis to make sure" << endl;    
     dynamicalNoise = var;
     return 0;
-}
-    
+}    
 
 Bool_t Run::setResultsPath(TString path)
 {
@@ -214,10 +214,10 @@ Bool_t Run::analyzeRun(Bool_t force)
             cout << "Skipped analysis of run " << labbook.runnumber << ", I think the root file for this run allready exists." << endl;
             cout << colorwhite << "initOldRootFile():" << endlr;
         }
-        error = processed->initOldRootFile();
         
         if (!error)
         {
+            error = processed->initOldRootFile();
             cout << colorwhite << "binNoise():" << endlr;
             binNoise();
             cout << colorwhite << "binSeedSumVeto():" << endlr;
@@ -598,7 +598,7 @@ Bool_t Run::binSeedSumVeto()
             for(Int_t hiti=0; (unsigned int)hiti<processed->fFrameInfo.hits;hiti++)
             {
                 // histogram with the single pixel
-                histogram.Seed->Fill(processed->fFrameInfo.p[12][hiti]);
+                histogram.Seed->Fill(processed->fFrameInfo.p[12][hiti]);                 
                 
                 // sum histogram
                 pixelSum = 0;
@@ -609,11 +609,19 @@ Bool_t Run::binSeedSumVeto()
                     if (clusteri != 12)
                         notSeedSum += processed->fFrameInfo.p[clusteri][hiti];
                 }
-                histogram.Sum->Fill(pixelSum);
+                histogram.Sum->Fill(pixelSum);                
                 
                 // veto spectrum
                 if (TMath::Abs(notSeedSum) < systemparamcur.vetothreshold && labbook.source.Contains("Fe"))
                     histogram.Veto->Fill(processed->fFrameInfo.p[12][hiti]);    // histogram with the single pixel
+                   
+                if (processed->fFrameInfo.pixelthreshold[hiti]>0)
+                {
+                    histogramthreshold.Seed->Fill(processed->fFrameInfo.p[12][hiti]);
+                    histogramthreshold.Sum->Fill(pixelSum);
+                    if (TMath::Abs(notSeedSum) < systemparamcur.vetothreshold && labbook.source.Contains("Fe"))
+                        histogramthreshold.Veto->Fill(processed->fFrameInfo.p[12][hiti]);    // histogram with the single pixel
+                }
             }
         }
     }
@@ -622,6 +630,10 @@ Bool_t Run::binSeedSumVeto()
         histogram.posVeto=FitPerform(histogram.Veto, "gaus");
     histogram.posSeed=FitPerform(histogram.Seed);
     histogram.posSum=FitPerform(histogram.Sum, "gaus");
+    if (labbook.source.Contains("Fe"))
+        histogramthreshold.posVeto=FitPerform(histogram.Veto, "gaus");
+    histogramthreshold.posSeed=FitPerform(histogram.Seed);
+    histogramthreshold.posSum=FitPerform(histogram.Sum, "gaus");
     gROOT->SetBatch(kFALSE);
     return 0;
 }
@@ -690,6 +702,8 @@ Bool_t Run::plotAllHistograms(histogramstruct* histogramstructpointer)
         TString canvastitle = Form("%s", runcode.Data());
         if (histogramstructpointer->calibrated)
             canvastitle += "_el";
+        if (histogramstructpointer->thresholdcluster)
+            canvastitle += "_trsh";
         TString canvasname = Form("%s%d",runcode.Data(),random);
         TCanvas* canvas = new TCanvas(canvasname, canvastitle, 1200, 800);
         canvas->Divide(2,2);
@@ -705,10 +719,10 @@ Bool_t Run::plotAllHistograms(histogramstruct* histogramstructpointer)
         lastbin = histogramstructpointer->Sum->GetBinCenter(histogramstructpointer->Sum->FindLastBinAbove(2,1));
         histogramstructpointer->Sum->SetAxisRange(0,lastbin*1.1,"X");
         canvas->cd(3);
-        histogram.Veto->Draw();
+        histogramstructpointer->Veto->Draw();
         if (labbook.source.Contains("Fe"))
-            plotVerticalLine(histogram.Veto, histogram.posVeto);
-        histogram.Veto->SetAxisRange(histogram.posVeto*0.7,histogram.posVeto*1.4,"X");
+            plotVerticalLine(histogramstructpointer->Veto, histogramstructpointer->posVeto);
+        histogramstructpointer->Veto->SetAxisRange(histogramstructpointer->posVeto*0.7,histogramstructpointer->posVeto*1.4,"X");
         canvas->cd(4);
         histogramstructpointer->Noise->Draw();
         TString  legendEntry = Form("Noise: %.2f + %.2f - %.2f",histogramstructpointer->avgNoise, histogramstructpointer->avgNoisePlus, histogramstructpointer->avgNoiseMinus);
@@ -759,6 +773,16 @@ Bool_t Run::plotAllHistogramsCalibrated()
     return 1;
 }
 
+Bool_t Run::plotAllHistogramsThresholdCluster()
+{
+    if (!error)
+    {
+        plotAllHistograms(&histogramthreshold);
+        return 0;
+    }
+    return 1;
+}
+
 Float_t Run::FitPerform(TH1F* histogrampointer, TString fitFuncType, Bool_t verbose)
 {
     Float_t posMax = 0;
@@ -980,7 +1004,7 @@ Bool_t Run::writeAllHistogramsToFile()
     TString filename= savepathresults + "/" + runcode + " histograms.dat";
     fstream* fout = new fstream(filename,ios::out);
     
-    TString header = Form("#bin [ADU]\tbin [e]\tSeed\tSum\tVeto\tbin noise [ADU]\tbin noise [e]\tnoise\n");
+    TString header = Form("#bin [ADU]\tbin [e]\tSeed\tSum\tVeto\tSeed thrsh\tSum thrsh\tbin noise [ADU]\tbin noise [e]\tnoise\n");
     header += Form("#posVeto, run: %.1f, DB: %.1f, Fe55 DB (%d, %.1f): %.1f\n", histogram.posVeto, labbook.posVetoDB, Fe55run.posVetorunnumber, Fe55run.temperature, Fe55run.posVeto);
     header += Form("#posSeed, run: %.1f, DB: %.1f\n", histogram.posSeed, labbook.posSeedDB);
     header += Form("#posSum, run: %.1f, DB: %.1f\n", histogram.posSum, labbook.posSumDB);
@@ -992,7 +1016,7 @@ Bool_t Run::writeAllHistogramsToFile()
     TString outline;
     for(Int_t bin=0;bin<histogram.Seed->GetNbinsX();bin++)
     {
-        outline=Form("%.1f\t%.1f\t%.1f\t%.1f\t%.1f", histogram.Seed->GetBinCenter(bin), histogramCalibrated.calibrated?histogramCalibrated.Seed->GetBinCenter(bin):0, histogram.Seed->GetBinContent(bin), histogram.Sum->GetBinContent(bin), histogram.Veto->GetBinContent(bin));
+        outline=Form("%.1f\t%.1f\t%.1f\t%.1f\t%.1f\t%.1f\t%.1f", histogram.Seed->GetBinCenter(bin), histogramCalibrated.calibrated?histogramCalibrated.Seed->GetBinCenter(bin):0, histogram.Seed->GetBinContent(bin), histogram.Sum->GetBinContent(bin), histogram.Veto->GetBinContent(bin), histogramthreshold.Seed->GetBinContent(bin), histogramthreshold.Sum->GetBinContent(bin));
         if (bin < systemparamcur.nbinsnoise)
             outline+=Form("\t%.1f\t%.1f\t%.1f", histogram.Noise->GetBinCenter(bin),histogramCalibrated.calibrated?histogramCalibrated.Noise->GetBinCenter(bin):0,histogram.Noise->GetBinContent(bin));
         *fout<<outline<<endl;
@@ -1103,13 +1127,16 @@ void Run::MakeGnuplotFile()
     //system("okular "+ ergebnisfile + ".png &");
 }
 
-void Run::initHistograms(histogramstruct* histogramstructpointer)
+void Run::initHistograms(histogramstruct* histogramstructpointer, TString suffix)
 {
-    initHistogram(histogramstructpointer->Seed, "Seed");
-    initHistogram(histogramstructpointer->Sum, "Sum");
-    initHistogram(histogramstructpointer->Veto, "Veto");
+    if (suffix.Contains("threshold"))
+        histogramstructpointer->thresholdcluster = 1;
+    
+    initHistogram(histogramstructpointer->Seed, "Seed" + suffix);
+    initHistogram(histogramstructpointer->Sum, "Sum" + suffix);
+    initHistogram(histogramstructpointer->Veto, "Veto" + suffix);
     
-    TString prefix = "Noise";
+    TString prefix = "Noise" + suffix;
     TString humanreadablestr = Form("%s, %s spectrum, Mi%s, chip %s, %s, T=%.1f",prefix.Data(), labbook.source.Data(), labbook.chipGen.Data(), labbook.chip.Data(), labbook.matrix.Data(), labbook.temp);
     histogramstructpointer->Noise=new TH1F(prefix.Data(), humanreadablestr.Data(), systemparamcur.nbinsnoise, 0, systemparamcur.maxbinnoise);  
     histogramstructpointer->Noise->SetLineStyle(rootlinestyle[plotStyle]);
index b37c152856829e520c45cba1e57d98db3d49c0fd..08e9d51bcd0a794fc4290ec8948dfe9875d8470a 100644 (file)
@@ -249,12 +249,15 @@ public:
     
     void setPlotStyle(Int_t);
     
-    /** @brief Plots all histograms from #histogram into one canvas */
+    /** @brief Plot all histograms from #histogram into one canvas */
     Bool_t plotAllHistograms();
     
-    /** @brief Plots all histograms from #histogram into one canvas */
+    /** @brief Plot all histograms from #histogram into one canvas */
     Bool_t plotAllHistogramsCalibrated();
     
+    /** @brief Plot all histograms from #histogramthreshold into one canvas */
+    Bool_t plotAllHistogramsThresholdCluster();      
+    
     /** @brief Writes a given histogram into a file */
     Bool_t writeHistogramToFile(TH1F* onehistogram);
     
@@ -402,15 +405,19 @@ public:
         
         /// set to true, if bins are in electrons, otherwise in ADU
         Bool_t calibrated = false;
+        
+        /// set to true, if threshold clusters are used
+        Bool_t thresholdcluster = false;
     };
     histogramstruct histogram;
     histogramstruct histogramCalibrated;
+    histogramstruct histogramthreshold;
     
     /** @brief Plots all histograms from #histogram into one canvas */
     Bool_t plotAllHistograms(histogramstruct*);
     
     /// init all histograms, set binwidth, bin amount and names
-    void initHistograms(histogramstruct*);
+    void initHistograms(histogramstruct*, TString suffix = "");
     
     pixelinfo pixelinfoMi34[32];
         
index 138635c5b0a293f7cdc998633b56852862315c2b..51aa0f013ae942b7e72db1977874d22a7a6cd84b 100644 (file)
@@ -105,7 +105,11 @@ struct frameInfo{
 // --Data and Analysis--
        UInt_t  frame;
        UInt_t  hits;   
-       UInt_t  pixel           [MAXHITS];
+    /// holds pixel number of hitted seed pixel in frame
+    UInt_t     pixel           [MAXHITS];
+    /// holds pixel number of hitted cluster seed pixel over the threshold in frame
+    UInt_t  pixelthreshold       [MAXHITS];
+    /// holds charge collected by cluster for a given hit in frame, p[12][7] f.e. holds seed pixel charge of hit number 8 in frame
        Float_t p               [25][MAXHITS];
 };