]> jspc29.x-matter.uni-frankfurt.de Git - radhard.git/commitdiff
Run analyzer: Noise routine adjusted for pixel with zero CDS, warn user if pixel...
authorBenjamin Linnik <blinnik@jspc28.x-matter.uni-frankfurt.de>
Wed, 17 Jun 2015 11:54:18 +0000 (13:54 +0200)
committerBenjamin Linnik <blinnik@jspc28.x-matter.uni-frankfurt.de>
Wed, 17 Jun 2015 11:54:18 +0000 (13:54 +0200)
MABS_run_analyzer/ChargeSpektrum.c
MABS_run_analyzer/MAPS.c
MABS_run_analyzer/Run.c
MABS_run_analyzer/Run.h

index 603e8e884aa4158fb36babb485476911bbf07a06..4ca874d7e2e4f7d2010ea3e8f5045efe1984388e 100644 (file)
 #include "CSVRow.h"
 #include "CSVRow.C"
 #include <TTimeStamp.h>
-#include <fstream>
 
-Int_t* ReadRunList();
-Int_t ReadRunList(std::vector<int>*);
-Bool_t plotAllRuns();
-Bool_t plotAllRuns(TString);
-Bool_t writeObservableToFile(TString);
-Bool_t writeObservableToFile();
-void writeObservableToFileHistSelect(TString);
 Run** runs;
 Int_t numberRuns;
 Bool_t isBatch = kFALSE;
 
-const TString colorwhite = "\033[1;29m";
-const TString colorred = "\033[1;31m";
-const TString coloryellow = "\033[1;33m";
-const TString colorreset = "\033[0m";  
-const TString endlr = "\033[0m\n";  
-
-void ChargeSpektrum(Int_t runnumber)
-{
-    cout << endl << colorred << "Given parameters have wrong format, please enter integer run numbers devided by '" << colorreset  << colorwhite << "," << colorreset  << colorred << "' and surrounded by '" << colorreset  << colorwhite << "\"" << colorreset  << colorred << "'." << endlr;
-    cout << "For example run: root -l 'ChargeSpektrum.c+(\"342815,342816\")'" << endl;
-    exit(1);
-}
-
-void ChargeSpektrum(Int_t runnumber, Int_t runnumber2)
-{
-    cout << endl << colorred << "Given parameters have wrong format, please enter integer run numbers devided by '" << colorreset << colorwhite << "," << colorreset << colorred << "' and surrounded by '" << colorreset << colorwhite << "\"" << colorreset  << colorred << "'." << endlr;
-    cout << "For example run: " << colorwhite << "root -l 'ChargeSpektrum.c+(\"342815,342816\")'" << endl;
-    exit(1);
-}
+#include "ChargeSpektrumFunctions.c"
 
 void ChargeSpektrum(TString runnumber = "")
 {
@@ -171,254 +145,30 @@ void ChargeSpektrum(TString runnumber = "")
 //                 runs[runi]->analyzeFrame(8319);
                 
                 // creates or opens .root file, can analyze the RAW data
-                runs[runi]->error=runs[runi]->analyzeRun(false); // creates or opens .root file, can analyze the RAW data
+                runs[runi]->error=runs[runi]->analyzeRun(true); // creates or opens .root file, can analyze the RAW data
                 if (!runs[runi]->error)
                 {
             //         gROOT->SetBatch(kTRUE);
                     //           runs[runi]->plotSeed();
-                    runs[runi]->plotSeedThresholdCalibrated();
+//                     runs[runi]->plotSeedThresholdCalibrated();
 //                     runs[runi]->plotSeedThreshold();
-//                     runs[runi]->plotSeed();
+                    runs[runi]->plotSeed();
             //         runs[runi]->plotSum();
             //         runs[runi]->plotVeto();
                     //         runs[runi]->plotNoise();
                     if (!isBatch)
                         gROOT->SetBatch(kFALSE);
-//                             runs[runi]->plotAllHistograms();
-                    runs[runi]->plotAllHistogramsThresholdCluster();
+                            runs[runi]->plotAllHistograms();
+//                     runs[runi]->plotAllHistogramsThresholdCluster();
 //                     runs[runi]->plotAllHistogramsThresholdClusterCalibrated();
-            //          runs[runi]->plotAllHistogramsCalibrated(); 
+                     runs[runi]->plotAllHistogramsCalibrated(); 
                     runs[runi]->writeAllHistogramsToFile(); 
                 }
             }
         }
     }
 //     plotAllRuns("");
-    plotAllRuns("threshold calibrated");
+    plotAllRuns("seed calibrated");
 //     writeObservableToFile("seed threshold calibrated");
     writeObservableToFile("seed threshold calibrated");
 }
-
-Int_t ReadRunList(std::vector<int>* runlist)
-{
-    std::ifstream file("runlist.txt");
-    Int_t row;    
-    while (file >> row) 
-    {
-        try 
-        {
-            if (row > 0)
-            {
-                runlist->push_back(row);
-                numberRuns++;
-            }
-        }
-        catch(...)
-        {
-            cout << "File ended";
-        }
-    }
-    return numberRuns;
-}
-
-
-// void plotNoiseComparison()
-// {
-//     
-// }
-
-Bool_t writeObservableToFile(TString histogramtype)
-{
-    if (histogramtype.Contains("threshold"))
-    {
-        if (histogramtype.Contains("calibrated"))
-        {
-            for(Int_t runi=0;runi<numberRuns;runi++)/* loop over runs read from file */
-            {
-                if (runs[runi]->histogramthresholdCalibrated.calibrated)
-                    runs[runi]->plothistogramstructpointer = &runs[runi]->histogramthresholdCalibrated;
-                else
-                    return 1;
-            }
-        }
-        else
-        {
-            for(Int_t runi=0;runi<numberRuns;runi++)/* loop over runs read from file */ 
-                runs[runi]->plothistogramstructpointer = &runs[runi]->histogramthreshold;
-        }
-        
-    }
-    else if (histogramtype.Contains("calibrated") || histogramtype.Contains("electron")) {
-        for(Int_t runi=0;runi<numberRuns;runi++) /* loop over runs read from file */ {
-            if (runs[runi]->histogramCalibrated.calibrated)
-                runs[runi]->plothistogramstructpointer = &runs[runi]->histogramCalibrated;
-            else return 1;        } }
-    else {
-        for(Int_t runi=0;runi<numberRuns;runi++) /* loop over runs read from file */ {
-            runs[runi]->plothistogramstructpointer = &runs[runi]->histogram; } }
-    writeObservableToFileHistSelect(histogramtype);
-    return 0;
-}
-void writeObservableToFileHistSelect(TString histogramtype)
-{
-    if (histogramtype.Contains("Seed") || histogramtype.Contains("seed")) {
-        for(Int_t runi=0;runi<numberRuns;runi++)/* loop over runs read from file */ {
-            runs[runi]->plothistogrampointer = &runs[runi]->plothistogramstructpointer->Seed; } }
-    else if (histogramtype.Contains("Sum") || histogramtype.Contains("sum")) {
-        for(Int_t runi=0;runi<numberRuns;runi++)/* loop over runs read from file */ {
-            runs[runi]->plothistogrampointer = &runs[runi]->plothistogramstructpointer->Sum; } }
-    else if (histogramtype.Contains("Veto") || histogramtype.Contains("veto")) {
-        for(Int_t runi=0;runi<numberRuns;runi++) /* loop over runs read from file */ {
-            runs[runi]->plothistogrampointer = &runs[runi]->plothistogramstructpointer->Veto; } }
-    else {
-        for(Int_t runi=0;runi<numberRuns;runi++) /* loop over runs read from file */ {
-            runs[runi]->plothistogrampointer = &runs[runi]->plothistogramstructpointer->Seed; } }
-    writeObservableToFile();
-}
-
-Bool_t writeObservableToFile()
-{
-    system("mkdir "+ runs[0]->savepathresults + " -p");
-    TString headerInfo = "";
-    for(Int_t runi=0;runi<numberRuns;runi++) // loop over runs read from file
-    {
-        headerInfo+=runs[runi]->runcode+"\t\t\t";
-    }
-    TH1F* plothistogrampointer = *runs[0]->plothistogrampointer;
-    TString runnumberListe=Form("%s_",plothistogrampointer->GetName());
-    TString header="";
-       for(Int_t runi=0;runi<numberRuns;runi++) // loop over runs read from file
-    {
-        if (runs[runi] != nullptr)
-        {
-            if (!runs[runi]->error)
-            {
-                plothistogrampointer = *runs[runi]->plothistogrampointer;
-                runnumberListe+=Form("%d_",runs[runi]->labbook.runnumber);
-                header+=Form("%d\t%s\t", runs[runi]->labbook.runnumber, plothistogrampointer->GetName());
-            }
-        }
-       }
-    TString filename= runs[0]->savepathresults + "/" + runnumberListe + "histograms.dat";
-    fstream* fout = new fstream(filename,ios::out);
-    *fout << headerInfo << endl;
-    *fout << header << endl;
-    for(Int_t bini=0;bini<plothistogrampointer->GetNbinsX();bini++)
-    {
-               for(Int_t runi=0;runi<numberRuns;runi++) // loop over runs read from file
-        {
-            if (runs[runi] != nullptr)
-            {
-                if (!runs[runi]->error)
-                {
-                    plothistogrampointer = *runs[runi]->plothistogrampointer;
-                    TString outline;
-                    outline=Form("%.1f\t%.1f\t",plothistogrampointer->GetBinCenter(bini),plothistogrampointer->GetBinContent(bini));
-                    *fout<<outline;
-                }
-            }
-               }
-               *fout<<endl;
-       }
-    fout->close();
-       
-    return 0;
-}
-
-Bool_t plotAllRuns(TString histogramtype)
-{
-    if (histogramtype.Contains("threshold"))
-    {
-        if (histogramtype.Contains("calibrated"))
-        {
-            for(Int_t runi=0;runi<numberRuns;runi++)/* loop over runs read from file */
-                if (runs[runi]->histogramthresholdCalibrated.calibrated)
-                    runs[runi]->plothistogramstructpointer = &runs[runi]->histogramthresholdCalibrated;
-                else
-                    return 1;
-        }
-        else
-        {
-            for(Int_t runi=0;runi<numberRuns;runi++)/* loop over runs read from file */ 
-                runs[runi]->plothistogramstructpointer = &runs[runi]->histogramthreshold;
-        }
-        
-    }
-    else if (histogramtype.Contains("calibrated") || histogramtype.Contains("electron")) {
-        for(Int_t runi=0;runi<numberRuns;runi++) /* loop over runs read from file */ {
-            if (runs[runi]->histogramCalibrated.calibrated)
-                runs[runi]->plothistogramstructpointer = &runs[runi]->histogramCalibrated;
-            else
-                return 1;  } }
-    else {
-        for(Int_t runi=0;runi<numberRuns;runi++) /* loop over runs read from file */ {
-            runs[runi]->plothistogramstructpointer = &runs[runi]->histogram; } }
-    plotAllRuns();
-    return 0;
-}
-
-Bool_t plotAllRuns()
-{
-    if (numberRuns > 1)
-    {
-        Float_t lastbin;
-        TTimeStamp* time = new TTimeStamp();
-        
-        TCanvas* canvas = new TCanvas(Form("%d",time->GetNanoSec()), "Summary", 1600, 1000);
-        if (isBatch)
-            canvas->SetCanvasSize(3200,2000);
-        
-        canvas->Divide(2,2);
-        Float_t height = numberRuns * 0.04;
-        TLegend* leg1 = new TLegend(0.3,0.89-height,0.89,0.89);//(0.6,0.7,0.89,0.89);
-        TLegend* leg2 = new TLegend(0.6,0.89-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
-        {
-            if (runs[runi] != nullptr)
-            {
-                if (!runs[runi]->error)
-                {
-                    canvas->cd(1);
-                    runs[runi]->plothistogramstructpointer->Seed->Draw("SAME");
-                    lastbin = runs[runi]->plothistogramstructpointer->Seed->GetBinCenter(runs[runi]->plothistogramstructpointer->Seed->FindLastBinAbove(2,1));
-                    runs[runi]->plothistogramstructpointer->Seed->SetAxisRange(0,lastbin*1.1,"X");
-                    gPad->SetLogy(1);
-                    legendEntry = Form("%s", runs[runi]->plothistogramstructpointer->Seed->GetTitle());
-                    leg1->AddEntry(runs[runi]->plothistogramstructpointer->Veto, legendEntry, "l");
-                    leg1->Draw("SAME");
-                    canvas->cd(2);
-                    runs[runi]->plothistogramstructpointer->Sum->Draw("SAME");
-                    lastbin = runs[runi]->plothistogramstructpointer->Sum->GetBinCenter(runs[runi]->plothistogramstructpointer->Sum->FindLastBinAbove(2,1));
-                    runs[runi]->plothistogramstructpointer->Sum->SetAxisRange(0,lastbin*1.1,"X");
-                    canvas->cd(3);
-                    runs[runi]->plothistogramstructpointer->Veto->Draw("SAME");
-                    runs[runi]->plothistogramstructpointer->Veto->SetAxisRange(runs[runi]->plothistogramstructpointer->posVeto*0.7,runs[runi]->plothistogramstructpointer->posVeto*1.4,"X");
-                    canvas->cd(4);
-                    runs[runi]->plothistogramstructpointer->Noise->Draw("SAME");
-                    legendEntry = Form("%s, Noise: %.2f", runs[runi]->labbook.matrix.Data(), runs[runi]->plothistogramstructpointer->avgNoise);
-                    leg2->AddEntry(runs[runi]->plothistogramstructpointer->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();
-    }
-    return 0;
-}
-
index 495bda47d0131f6041bafc585052604a2f9d238d..9f6e39c212520be0541e2184ccec29ca4f9aa844 100644 (file)
@@ -164,7 +164,7 @@ MAPS::~MAPS(void) {
 void MAPS::save() {
     if(fSave && fOk)
     {
-        cout<<"----------------------------------------------------------------"<<endl;
+        cout<< endl << "----------------------------------------------------------------"<<endl;
         cout << "  Frames with suspicious pedestial value: " << std::cout.width(10)<< std::right << fPedestalhighFrames << " out of " << fEventsSum << " (" << (1.0*fPedestalhighFrames/fEventsSum*100) << " %)" << endl;
         cout << "  Pixel with suspicious pedestial value: " << std::cout.width(10) << std::right << fPedestalhighPixel << " out of " << fEventsSum*fPixels<< " (" << (1.0*fPedestalhighPixel/(fEventsSum*fPixels)*100) << " %)" << endl;
         cout << "  Frames with suspicious noise value: " << std::cout.width(10) << std::right<< fNoiseHighFrames << " out of " << fEventsSum << " (" << (1.0*fNoiseHighFrames/fEventsSum*100) << " %)" << endl;
@@ -317,6 +317,7 @@ bool MAPS::checkConf( Int_t &PixelData ) {
 
         FileEvNbInConfig       = littleEndian32( RAWDATA, 4*3);        ///< Event number per file
         FileTotalEvNbInConfig  = littleEndian32( RAWDATA, 4*4);        ///< Total events in RUN - should be less if RUN was stopped before endl
+//         FileTotalEvNbInConfig = 100000000;
         DataSz         = littleEndian32( RAWDATA, 4*6);        ///< Datas size = BDB_VFAS_RAM_SZ_W32 X Adc number ( VFasRunNb field )
         NrAdcBoards    = littleEndian32( RAWDATA, 4*9);        ///< Number of Adc boards installed in the system
 
@@ -908,13 +909,23 @@ bool MAPS::InitialDynNoise(Int_t startframe, Int_t frames) {
             }
         }
         // calculate average noise of each pixel
+        Int_t npixelwithnoisezero = 0;
         for(Int_t pixeli=0; pixeli<fPixels; pixeli++)
         {
             fNoise[pixeli] = TMath::Sqrt(fNoise[pixeli]/(frames-nframescutawaythirdnoiseestimate[pixeli]-1)); // don't forget the "-1" !!!
+            if ( fNoise[pixeli] == 0 )
+                npixelwithnoisezero++;            
         }
         npixelscutawaythirdnoiseestimate = SumOverArray(nframescutawaythirdnoiseestimate, fPixels);
         cout << "In third estimate of dynamic noise, cutted away " << npixelscutawaythirdnoiseestimate << " pixels in total in " << frames << " frames. (" << (npixelscutawaythirdnoiseestimate*100./fPixels/frames) << " %)" << endl;
         
+        if (npixelwithnoisezero > 0)
+        {            
+            cout<< colorred <<"-----------------------"<<endl;
+            cout << npixelwithnoisezero << " pixels have a noise value of zero, it could be that they haven't been read out correctly or the CDS is always zero!" << endl;
+            cout<< "-----------------------"<<endlr;
+        }
+        
         if( fSave  )
         {
             Float_t PEDESTAL;
@@ -927,11 +938,12 @@ bool MAPS::InitialDynNoise(Int_t startframe, Int_t frames) {
             
             for(Int_t pixeli=0; pixeli<fPixels; pixeli++)
             {
-                
                 PEDESTAL = fPedestals[pixeli];                
                 NOISE = fNoise[pixeli];
                 PIXEL = pixeli;
-                fNoiseTree->Fill();
+                
+                if (PEDESTAL > 0 && NOISE > 0)
+                    fNoiseTree->Fill();
             }
 //             getNoise(startframe, frames);
         }
index ff8cf4f7226f981856cff9c75a34f2dc6a53ac96..2f239019858c6fe4941106b0e8347ce111c2b0c0 100644 (file)
@@ -146,7 +146,7 @@ Bool_t Run::debugDBreadout()
 {
     cout << endlr;
     cout << " _____ " << colorwhite << "database values" << colorreset << " ________ " << endlr;
-    cout << "| runnumber:       " << std::right << colorwhite << labbook.runnumber <<  endlr;
+    cout << "| runnumber:       " << std::right << colorgreen << labbook.runnumber <<  endlr;
     cout << "| system:          " << std::right << colorwhite << labbook.system  <<  endlr;
     cout << "| temp:            " << std::right << colorwhite << labbook.temp  <<  endlr;
     cout << "| tempSens:        " << std::right << colorwhite << labbook.tempSens  <<  endlr;
@@ -1132,43 +1132,47 @@ void Run::plotVerticalLine(TH1F* histogrampointer, Float_t xVal) {
 
 TCanvas* Run::plot1DHistogram(TH1F* onehistogram, TString fitFuncType, TString titlestr, TString legendstr)
 {
-    Int_t random = random1->Rndm()*100000;
-    if (titlestr.Length() < 1)
-        titlestr = Form("%s",onehistogram->GetTitle());
-    TString canvastitle = Form("%s %s", onehistogram->GetName(), runcode.Data());
-    TString canvasname =  Form("%s %s %d", onehistogram->GetName(), runcode.Data(), random);
-    TCanvas* canvas = new TCanvas(canvasname, canvastitle, 900, 700);
-    onehistogram->SetTitle(titlestr);
-    onehistogram->Draw();
-    Float_t maxValue = FitPerform(onehistogram, fitFuncType);
-    plotVerticalLine(onehistogram, maxValue);
-    TLegend* leg = new TLegend(0.8,0.8,0.89,0.89);//(0.6,0.7,0.89,0.89);
-    leg->SetFillColor(0);
-    leg->SetBorderSize(0);
-    if (legendstr.Length() < 1)
-        legendstr = Form("%s",onehistogram->GetTitle());
-    leg->AddEntry(onehistogram, legendstr, "l");
+    if (onehistogram != nullptr)
+    {
+        Int_t random = random1->Rndm()*100000;
+        if (titlestr.Length() < 1)
+            titlestr = Form("%s",onehistogram->GetTitle());
+        TString canvastitle = Form("%s %s", onehistogram->GetName(), runcode.Data());
+        TString canvasname =  Form("%s %s %d", onehistogram->GetName(), runcode.Data(), random);
+        TCanvas* canvas = new TCanvas(canvasname, canvastitle, 900, 700);
+        onehistogram->SetTitle(titlestr);
+        onehistogram->Draw();
+        Float_t maxValue = FitPerform(onehistogram, fitFuncType);
+        plotVerticalLine(onehistogram, maxValue);
+        TLegend* leg = new TLegend(0.8,0.8,0.89,0.89);//(0.6,0.7,0.89,0.89);
+        leg->SetFillColor(0);
+        leg->SetBorderSize(0);
+        if (legendstr.Length() < 1)
+            legendstr = Form("%s",onehistogram->GetTitle());
+        leg->AddEntry(onehistogram, legendstr, "l");
+            
+        leg->SetTextSize(0.03);
+        leg->Draw();
         
-    leg->SetTextSize(0.03);
-    leg->Draw();
-    
-    canvas -> SaveAs( savepathresults + "/" + runcode + " " + onehistogram->GetName() + ".eps");
+        canvas -> SaveAs( savepathresults + "/" + runcode + " " + onehistogram->GetName() + ".eps");
+            
+        TImageDump *img = new TImageDump(savepathresults + "/" + runcode + " " + onehistogram->GetName() + ".png");
+        canvas->Paint();
+        img->Close();
         
-    TImageDump *img = new TImageDump(savepathresults + "/" + runcode + " " + onehistogram->GetName() + ".png");
-    canvas->Paint();
-    img->Close();
-    
-    TFile *f = new TFile(savepathresults + "/" + runcode + " " + onehistogram->GetName() + ".root","RECREATE");
-    f->cd();
-    f->Append(canvas);
-    f->Append(img);
-    f->Write();
-    
-    gStyle->SetPaperSize(10.,10.);
-    canvas->Print(savepathresults + "/" + runcode + " " + onehistogram->GetName() + ".tex");
-    
-    writeHistogramToFile(onehistogram);
-    return canvas;
+        TFile *f = new TFile(savepathresults + "/" + runcode + " " + onehistogram->GetName() + ".root","RECREATE");
+        f->cd();
+        f->Append(canvas);
+        f->Append(img);
+        f->Write();
+        
+        gStyle->SetPaperSize(10.,10.);
+        canvas->Print(savepathresults + "/" + runcode + " " + onehistogram->GetName() + ".tex");
+        
+        writeHistogramToFile(onehistogram);
+        return canvas;
+    }
+    return nullptr;
 }
 
 Bool_t Run::writeHistogramToFile(TH1F* onehistogram)
index 7f7314a7cf40791a88161dbcc3b42d127640cb67..690676e3b5683f4bde12b442fc3034eef1a7ec7f 100644 (file)
@@ -253,6 +253,8 @@ private:
     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 colorcyan = "\033[1;36m";
     const TString colorreset = "\033[0m";  
     const TString endlr = "\033[0m\n";