]> jspc29.x-matter.uni-frankfurt.de Git - radhard.git/commitdiff
Run analyzer: added improved summary table
authorBenjamin Linnik <blinnik@jspc28.x-matter.uni-frankfurt.de>
Wed, 2 Dec 2015 11:55:19 +0000 (12:55 +0100)
committerBenjamin Linnik <blinnik@jspc28.x-matter.uni-frankfurt.de>
Wed, 2 Dec 2015 11:55:19 +0000 (12:55 +0100)
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 b9091b1db301b050fbf041692a9202d35a8d6d2b..752677ea8c7a312c73d5bea116c3ea84546c69a6 100644 (file)
@@ -259,6 +259,7 @@ Bool_t printSummaryTable(vector<HistogramType*>* ptCompareHistogramClassVector)
         for (vector<HistogramType*>::iterator curHistogramClass = ptCompareHistogramClassVector->begin(); curHistogramClass != ptCompareHistogramClassVector->end(); curHistogramClass++)
             printIntegral += (*curHistogramClass)->sr90IntegralVal;
         if (printIntegral != 0)  cout << left << setw(width) << setfill(' ') << "Integral";
+        cout << left << setw(width) << setfill(' ') << "Seed Peak";
         cout << left << setw(width) << setfill(' ') << "Noise";
         cout << endl;
         for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++)
@@ -272,6 +273,7 @@ Bool_t printSummaryTable(vector<HistogramType*>* ptCompareHistogramClassVector)
             if (printCCE != 0) cout << left << setw(width) << setfill(' ') << printTableElement(curhistogramclassp->CCE_in_Perc_25,ptCompareHistogramClassVector->at(0)->CCE_in_Perc_25);
             if (printStoN != 0)  cout << left << setw(width) << setfill(' ') << printTableElement(curhistogramclassp->StoN,ptCompareHistogramClassVector->at(0)->StoN);
             if (printIntegral != 0)  cout << left << setw(width) << setfill(' ') << printTableElement(curhistogramclassp->sr90IntegralVal,ptCompareHistogramClassVector->at(0)->sr90IntegralVal);
+            cout << left << setw(width) << setfill(' ') << printTableElement(curhistogramclassp->posSeed,ptCompareHistogramClassVector->at(0)->posSeed);
             cout << left << setw(width) << setfill(' ') << printTableElement(curhistogramclassp->avgNoise,ptCompareHistogramClassVector->at(0)->avgNoise);
             cout << "" << endl;
         }
index 2ba9f9e85eba6abfbf3e9ebd88de0e7189de77f3..c5d852001932687d743b81724532917c7add5ee2 100644 (file)
@@ -49,12 +49,12 @@ void HistogramType::initHistograms(Int_t gotcolor, Int_t gotstyle) {
 }
 
 void HistogramType::initHistogram(TH1F* &histogrampointer, TString prefix, Int_t color, Int_t style) {
-    histogrampointer=new TH1F(Form("%d %s",labbook->runnumber, prefix.Data()), Form("%d %s, %s",labbook->runnumber,prefix.Data(), humanreadablestr.Data()), cursystempar->nbins, 0, cursystempar->maxbin);  
+    histogrampointer=new TH1F(Form("%d %s",labbook->runnumber, prefix.Data()), Form("%s, %s",prefix.Data(), humanreadablestr.Data()), cursystempar->nbins, 0, cursystempar->maxbin);  
     histogrampointer->SetLineStyle(style);
     histogrampointer->SetLineColor(color);
     histogrampointer->SetStats(kTRUE);        
     histogrampointer->SetStats(111111111);
-    histogrampointer->SetLineWidth(2); // TODO: set to 3 again
+    histogrampointer->SetLineWidth(3); // TODO: set to 3 again
     histogrampointer->GetXaxis()->SetTitle("Q_coll [ADU]");
     histogrampointer->GetYaxis()->SetTitle(Form("Entries [1/%.1f ADU]",histogrampointer->GetBinWidth(1)));
     histogrampointer->GetXaxis()->CenterTitle();
@@ -142,9 +142,7 @@ Float_t HistogramType::FitPerform(TH1F* histogrampointer, TString fitFuncType, B
     Float_t posMaxValHist = histogrampointer->GetXaxis()->GetXmax();
     // posMaxValHist/10 for USB system, the value is 90
     Float_t noiseborder = 90;
-    if (noisethresholdborder>0)
-        noiseborder = noisethresholdborder;
-    else if (noisethresholdborder > 0)
+    if (noisethresholdborder>=0)
         noiseborder = noisethresholdborder;
     
     if (fitFuncType.Contains("gaus")) 
@@ -155,10 +153,16 @@ Float_t HistogramType::FitPerform(TH1F* histogrampointer, TString fitFuncType, B
         
         if (TString(histogrampointer->GetName()).Contains("Veto")) 
         {
+//             if (verbose)
+//                 cout << "Range: " << histogrampointer->GetXaxis()->FindBin(noiseborder) << " to " << histogrampointer->GetXaxis()->FindBin(posMaxValHist) << endl;
             Float_t peak1 = histogrampointer->GetMaximumBin();
             Float_t peak2;
+//             if (verbose)
+//                 cout << "histogrampointer->GetBinCenter(peak1) " << histogrampointer->GetBinCenter(peak1) << endl;
             if (histogrampointer->GetBinCenter(peak1)<3.3*noiseborder) // vermutlich ist veto peak nicht am höchsten
             {
+//                 if (verbose)
+//                     cout << "histogrampointer->GetBinCenter(peak1) " << histogrampointer->GetBinCenter(peak1) << " < 3 * noiseborder " << noiseborder << endl;
                 Float_t avg = 0;
                 for(Int_t bin=histogrampointer->GetXaxis()->FindBin(noiseborder);bin<histogrampointer->FindLastBinAbove(0);bin++)
                     avg += histogrampointer->GetBinContent(bin);
@@ -174,23 +178,45 @@ Float_t HistogramType::FitPerform(TH1F* histogrampointer, TString fitFuncType, B
             Float_t min = histogrampointer->GetMinimumBin();
             histogrampointer->GetXaxis()->SetRange(min,histogrampointer->FindLastBinAbove(0));   // look only for maxima with x greater than noiseborder, cut away noise
             // DEBUG 
-            //                 if (verbose)
-            //                 {
-            //                 cout << coloryellow << "peak1 " << histogrampointer->GetXaxis()->GetBinCenter(peak1) << endlr;
-            //                 cout << coloryellow << "peak1val " << histogrampointer->GetBinContent(peak1) << endlr;
-            //                 cout << coloryellow << "peak2 " << histogrampointer->GetXaxis()->GetBinCenter(peak2) << endlr;
-            //                 cout << coloryellow << "peak2val " << histogrampointer->GetBinContent(peak2) << endlr;
-            //                 cout << coloryellow << "min " << histogrampointer->GetXaxis()->GetBinCenter( min ) << endlr;
-            //                 }
-            histogrampointer->Fit(fitFunc, "N,Q,W", "", histogrampointer->GetXaxis()->GetBinCenter(min), posMaxValHist);
+//             if (verbose)
+//             {
+//                 cout << coloryellow << "noisethresholdborder " << noisethresholdborder << endlr;
+//                 cout << coloryellow << "peak1 " << histogrampointer->GetXaxis()->GetBinCenter(peak1) << endlr;
+//                 cout << coloryellow << "peak1val " << histogrampointer->GetBinContent(peak1) << endlr;
+//                 cout << coloryellow << "peak2 " << histogrampointer->GetXaxis()->GetBinCenter(peak2) << endlr;
+//                 cout << coloryellow << "peak2val " << histogrampointer->GetBinContent(peak2) << endlr;
+//                 cout << coloryellow << "min " << histogrampointer->GetXaxis()->GetBinCenter( min ) << endlr;
+//                 cout << coloryellow << "lastbin " << histogrampointer->FindLastBinAbove(0) << endl;
+//                 cout << coloryellow << "posMaxValHist " << posMaxValHist << endl;                
+//             }
+//             cout << colorred << gMinuit->fCstatu.Data() << endlr;
+//             cout << colorred << gMinuit->GetStatus() << endlr;
+//             cout << colorred << fitFunc->GetChisquare() << endlr;
+            //histogrampointer->Fit(fitFunc, "N,Q,W", "", 70, 500);
+            int fittries = 0;
+            do {
+//                 cout << fittries <<  ": New range: " <<  histogrampointer->GetXaxis()->GetBinCenter(min+fittries*min/20) << " to " << posMaxValHist << endl;
+                histogrampointer->Fit(fitFunc, "N,Q,W", "", histogrampointer->GetXaxis()->GetBinCenter(min+fittries++*min/20), posMaxValHist);    
+//                 cout << colorred << gMinuit->fCstatu.Data() << endlr;            
+            } while (gMinuit->fCstatu.Contains("FAILED") && fittries < 8);
             posMax = histogrampointer->GetXaxis()->GetBinCenter(histogrampointer->GetMaximumBin()); // Methode 1
+//             if (verbose)
+//             {
+//                 cout << coloryellow << "min " << histogrampointer->GetXaxis()->GetBinCenter( min ) << endlr;
+//                 cout << coloryellow << "posMax " << posMax << endlr;
+//             }
             histogrampointer->GetXaxis()->SetRange(histogrampointer->GetXaxis()->FindBin(noiseborder),histogrampointer->GetXaxis()->FindBin(posMaxValHist));   // look only for maxima with x greater than noiseborder, cut away noise
+//             TCanvas* canvas = new TCanvas("2121", "212121212", 900, 700);
+//             histogrampointer->Draw();
+//             fitFunc->DrawCopy("same");
         } else {
             histogrampointer->Fit(fitFunc, "N,Q,W", "", noiseborder, posMaxValHist);
             posMax = fitFunc->GetMaximumX(); // Methode 2
         }
         Float_t sigma = fitFunc->GetParameter(2);
         posMax2 = fitFunc->GetMaximumX(); // Methode 2
+//         if (verbose)
+//             cout << coloryellow << "posMax2 " << posMax2 << endlr;
         Float_t peakposdifperc = abs(posMax-posMax2)/min(posMax,posMax2);
         if (sigma > 260 || peakposdifperc>0.3)
         {
@@ -225,13 +251,13 @@ Float_t HistogramType::FitPerform(TH1F* histogrampointer, TString fitFuncType, B
                 }
             }
         }       
-        //             fitFunc->DrawCopy("same");
-        TString  legendEntry = TString(Form("%s","Gaus fit"));
-        TLegend* leg = new TLegend(0.5,0.5,0.89,0.89);//(0.6,0.7,0.89,0.89);
-        //   leg->SetHeader();//"Legend Title");
-        leg->SetFillStyle(0);
-        leg->AddEntry((TObject*) 0, legendEntry, "");
-        leg->SetTextSize(0.05);
+        
+//         TString  legendEntry = TString(Form("%s","Gaus fit"));
+//         TLegend* leg = new TLegend(0.5,0.5,0.89,0.89);//(0.6,0.7,0.89,0.89);
+//         //   leg->SetHeader();//"Legend Title");
+//         leg->SetFillStyle(0);
+//         leg->AddEntry((TObject*) 0, legendEntry, "");
+//         leg->SetTextSize(0.05);
         //               leg->Draw();
 //         
     }
@@ -342,6 +368,7 @@ Bool_t HistogramType::FindNoisethresholdborder(TH1F* histogrampointer, Bool_t ve
     smoothedcurce->SetAxisRange(0,histogrampointer->GetBinCenter(histogrampointer->GetNbinsX()));
     
     if (verbose) {
+        cout << colorwhite << histogrampointer->GetName() << endlr;
         TString canvastitle = Form("%s Noisethreshold border", histogrampointer->GetName());
         TString canvasname =  Form("%s Noisethreshold border", histogrampointer->GetName());
         TCanvas* canvas = new TCanvas(canvasname, canvastitle, 900, 700);
@@ -351,30 +378,56 @@ Bool_t HistogramType::FindNoisethresholdborder(TH1F* histogrampointer, Bool_t ve
         canvas->Update();
     }
     
+    //     Int_t bini =smoothedcurce->GetMaximumBin();
+    //     thresholdbincurcandidate = bini;
+    //     if (verbose)
+    //         cout << "GetMaximumBin: smoothedcurce->GetBinContent(" << bini << "): " << smoothedcurce->GetBinContent(bini) << endl;
+    Int_t bini = 0;
+    Int_t falling = 0;
+    Int_t noisepeakcandidate = 0;
+    
+    do {
+        Float_t curval=smoothedcurce->GetBinContent(bini++);
+        if (curval*0.95 <= smoothedcurce->GetBinContent(bini))
+        {
+            falling = 0;
+            noisepeakcandidate = bini;
+        }
+        else
+        {
+            falling++;
+            if (verbose)
+                cout << "falling at " <<  smoothedcurce->GetXaxis()->GetBinCenter(bini) << "   as " << curval  << " < " << smoothedcurce->GetBinContent(bini) << endl; // debug
+        }
+    } while (falling < 2 && bini<smoothedcurce->GetNbinsX());        
+    if (verbose) {
+        cout << "Noise peak at: smoothedcurce->GetBinContent(" << noisepeakcandidate << "): " << smoothedcurce->GetBinContent(noisepeakcandidate) << endl;
+    }
     Int_t thresholdbincurcandidate = 0;
-    Int_t rising = 0;
-    Int_t bini =smoothedcurce->GetMaximumBin();
-    thresholdbincurcandidate = bini;
-    //         cout << "GetMaximumBin: smoothedcurce->GetXaxis()->GetBinCenter(" << bini << "): " << curval << endl;
+    bini = noisepeakcandidate;
     
+    Int_t rising = 0;
     do {
         Float_t curval=smoothedcurce->GetBinContent(bini++);
         if (curval*0.95 <= smoothedcurce->GetBinContent(bini))
         {
             rising++;
-            //                 cout << "rising at " <<  smoothedcurce->GetXaxis()->GetBinCenter(bini) << "   as " << curval  << " < " << smoothedcurce->GetBinContent(bini) << endl; // debug
+            if (verbose)
+                cout << "rising at bin " << bini << ":" <<  smoothedcurce->GetXaxis()->GetBinCenter(bini) << "   as " << curval  << " < " << smoothedcurce->GetBinContent(bini) << endl; // debug
         }
         else
         {
             rising = 0;
             thresholdbincurcandidate = bini;
+            if (verbose)
+                cout << "falling at bin " << bini << ":" <<  smoothedcurce->GetXaxis()->GetBinCenter(bini) << "   as " << curval  << " < " << smoothedcurce->GetBinContent(bini) << endl; // debug
         }
     } while (rising < 3 && bini<smoothedcurce->GetNbinsX());
     thresholdbincurcandidate *= rebinningfactor;
     
     noisethresholdborder = histogrampointer->GetXaxis()->GetBinUpEdge(thresholdbincurcandidate);
     if (verbose) {
-        cout << "     Noise threshold at " << noisethresholdborder;
+        cout << "     Noise threshold at " << noisethresholdborder << endl;
     }
     return 0;
 }
index 1d1ff18326b1f6fe9fcce22043a0fd32a18eac67..700cc993c6b841054cee214935f92e079a4f4b0d 100644 (file)
@@ -11,6 +11,7 @@
 #include <TLegend.h>
 #include <TMath.h>
 #include <TStyle.h>
+#include <TMinuit.h>
 
 #include "help.h"
 
index 793118aeaa295ed81585928cae3bce0d8dc24945..5969c4a43fa93546711cad6d93b9cead63562af2 100644 (file)
@@ -844,6 +844,7 @@ Bool_t Run::binSeedSumVeto()
 //             (*curHistogramClass)->Sum->SetBinContent(bini,(*curHistogramClass)->Sum->GetBinContent(bini)/(frames_found*1.0));
         }
     }
+    histogramfixedthreshold->noisethresholdborder=0;
     //     gROOT->SetBatch(kFALSE);    
     return 0;
 }
@@ -1406,7 +1407,7 @@ TCanvas* Run::plot1DHistogram(HistogramType* HistogramTypepointer, TH1F* onehist
         TCanvas* canvas = new TCanvas(canvasname, canvastitle, 900, 700);
         onehistogram->SetTitle(titlestr);
         onehistogram->Draw();
-        Float_t maxValue = HistogramTypepointer->FitPerform(onehistogram, fitFuncType);
+        Float_t maxValue = HistogramTypepointer->FitPerform(onehistogram, fitFuncType, true);
         plotVerticalLine(onehistogram, maxValue);
         TLegend* leg = new TLegend(0.4,0.8,0.89,0.89);//(0.6,0.7,0.89,0.89);
         leg->SetFillColor(0);
index 6a2d78b79bbffc52377d8a597aa1cd2443461523..7ff0f13c208119080274114de2ad9746219d62ce 100644 (file)
@@ -427,7 +427,5 @@ public:
     
     /// sensor information to use in analysis, is the system read out by USB or PXI? Number of rows differ
     sensorinfostruct cursensorinfo;
-    
-    
 };
 #endif
\ No newline at end of file