]> jspc29.x-matter.uni-frankfurt.de Git - radhard.git/commitdiff
had a bug, now working, but I can do better
authorBenjamin Linnik <blinnik@jspc61.x-matter.uni-frankfurt.de>
Fri, 12 Aug 2016 17:16:57 +0000 (19:16 +0200)
committerBenjamin Linnik <blinnik@jspc61.x-matter.uni-frankfurt.de>
Fri, 12 Aug 2016 17:16:57 +0000 (19:16 +0200)
MABS_run_analyzer/ChargeSpektrum.c
MABS_run_analyzer/HistogramType.c
MABS_run_analyzer/HistogramType.h
MABS_run_analyzer/MAPS.c
MABS_run_analyzer/Run.c
MABS_run_analyzer/help.h

index a4983e5c2dca2dac1fc8acebeb832ca290ed1340..103f58e31131831348bc778061ad843bb3cc7cb7 100644 (file)
@@ -103,6 +103,7 @@ void ChargeSpektrum(TString runnumber = "")
 //                         compareHistogramVector.push_back(runs[runi]->histogramwoRTS->normalized->Seed);
                         runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS, runs[runi]->histogramwoRTS->pixeltimefired, "", 0);
                         runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS, runs[runi]->histogramwoRTS->pixeltimefiredsorted, "", 0, true, true);
+                        runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS, runs[runi]->histogramwoRTS->LeakageCurrent, "", 0);
 //                         runs[runi]->plot1DHistogram(runs[runi]->histogram, runs[runi]->histogram->pixeltimefired, "gaus", 1);
 //                     compareHistogramVector2.push_back(runs[runi]->histogramthreshold->normalized->Seed);
                     //compareHistogramClassVector.push_back(runs[runi]->histogram);
index 97af3b9376a5f2cf53f180724e1fdaa0302135aa..9c3d5bd6b3ffa27c27512b8ae3b06ca770c4248b 100644 (file)
@@ -45,13 +45,15 @@ void HistogramType::initHistograms(Int_t gotcolor, Int_t gotstyle) {
     initHistogram(Sum, "Sum" + 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(pixeltimefired, "Pixel fired" + histogramdescription, color, style, 0, cursensorinfo->columns*cursensorinfo->rows-1, cursensorinfo->columns*cursensorinfo->rows, "Pixel index", "Counts");
-    initHistogramCustom(pixeltimefiredsorted, "Fire counter" + histogramdescription, color, style, 0, labbook->frames_foundDB/250-1, labbook->frames_foundDB/250, "times fired", "Counts");
-    initHistogramCustom(LeakageCurrent, "Leakage current per pixel" + histogramdescription, color, style, 0, cursensorinfo->columns*cursensorinfo->rows, cursensorinfo->columns*cursensorinfo->rows, "Pixel index", "Average CDS");
+    initHistogramCustom(pixeltimefired, "Pixel fired", color, style, 0, cursensorinfo->columns*cursensorinfo->rows-1, cursensorinfo->columns*cursensorinfo->rows, "Pixel index", "Counts");
+    initHistogramCustom(pixeltimefiredsorted, "Fire counter", color, style, 0, labbook->frames_foundDB/250-1, labbook->frames_foundDB/250, "times fired", "Counts");
+    initHistogramCustom(LeakageCurrent, "Leakage current per pixel", color, style, 0, cursensorinfo->columns*cursensorinfo->rows, cursensorinfo->columns*cursensorinfo->rows, "Pixel index", "Average CDS");
     
     SeedPerc->GetXaxis()->SetRangeUser(0,50);
     Noise->SetBins(cursystempar->nbinsnoise, 0, cursystempar->maxbinnoise);
+    NoiseEnd->SetBins(cursystempar->nbinsnoise, 0, cursystempar->maxbinnoise);
 }
 
 void HistogramType::initHistogram(TH1F* &histogrampointer, TString prefix, Int_t color, Int_t style) {
index 5fe99f7b8aee42cf386a833b8e1a7b77edb7a7f6..47cf7b7c706bbd0fd6354b64bd2eb2e60f6d100a 100644 (file)
@@ -116,6 +116,8 @@ public:
     TH1F* Veto = 0;
     /// Noise histogram
     TH1F* Noise = 0;
+    /// Noise histogram at the end of a run
+    TH1F* NoiseEnd = 0;
     /// histogram with cluster data, rotated if staggered
     TH2F* histAvgCluster = 0;
     /// Percentage of charge gathered by seed pixel (Seed to Sum ratio)
index 7ae4452d3c898da288fcae180f7c838a127762bc..bad44f6ad134376d1081d2f208507a660da188ae 100644 (file)
@@ -64,10 +64,10 @@ Bool_t MAPS::initNewRootFile() {
             fHitTree->Branch( Form("p%i",i+1)   , &fFrameInfo.p[i][0]   , Form("p%i [hits]/F",i+1)  , 32000);
         }
         // Noise TTree
-        fNoiseTree      = new TTree("noise", "noise");
+        fNoiseTree      = new TTree("noisefolder", "noisefolder");
         fNoiseTree->Branch("frame"      , &fFrameInfo.frame    , "frame/i"     , 32000);
-        fNoiseTree->Branch("noise"      , &(fNoiseInfo.fNoise)    , "noise/F"     , 32000);
-        fNoiseTree->Branch("pedestal"   , &(fNoiseInfo.fPedestals) , "pedestal/F"  , 32000);
+        fNoiseTree->Branch("noise"      , &fNoiseInfo.fNoise[0]    , "noise[100000]/F"     , 32000);
+        fNoiseTree->Branch("pedestal"   , &fNoiseInfo.fPedestals[0] , "pedestal[100000]/F"  , 32000);
                 
         initHistograms();
         cout<<"-----------------------"<<endl;
@@ -108,15 +108,34 @@ Bool_t MAPS::initOldRootFile() {
         fHitTree->SetBranchAddress( Form("p%i",i+1)   , &fFrameInfo.p[i][0]);
     }
     // Noise TTree
-    fNoiseTree =  (TTree*) fOutputFile->Get("noise");
+    fNoiseTree =  (TTree*) fOutputFile->Get("noisefolder");
     if (!fNoiseTree) // got pointer
     {
         cout<< colorred << "Error finding noise TTree in old ROOT file!"<< endlr;
         return 1;
     }
     fNoiseTree->SetBranchAddress("frame"      , &fFrameInfo.frame);
-    fNoiseTree->SetBranchAddress("noise"      , &(fNoiseInfo.fNoise));
-    fNoiseTree->SetBranchAddress("pedestal"   , &(fNoiseInfo.fPedestals));
+    fNoiseTree->SetBranchAddress("noise"      , &fNoiseInfo.fNoise[0]);
+    fNoiseTree->SetBranchAddress("pedestal"   , &fNoiseInfo.fPedestals[0]);
+        
+    Int_t BytesRead=fNoiseTree->GetEntry(1);    
+    cout << colorred << "BytesRead: " << BytesRead << endlr;
+    
+    for (Int_t pixeli=0; pixeli<fPixelsData ; pixeli++) {
+        if (pixeli > 500 && pixeli < 550 ) {
+            cout << "pixeli: " << pixeli << endl;
+            cout << " " << fNoiseInfo.fNoise[pixeli];
+        }
+    }
+    
+    
+    fHitTree->GetEntry(1);    
+    for(Int_t hiti=0; (unsigned int)hiti<fFrameInfo.hits;hiti++)
+    {
+            cout << " " << fFrameInfo.pixel[hiti];
+    }
+    
+    
     
     initHistograms();  
     cout<<"-----------------------"<<endl;
@@ -394,9 +413,9 @@ bool MAPS::checkConf( Int_t &PixelData ) {
         fF0matrix   = new Int_t     [fPixelsData]();
         fF1matrix   = new Int_t     [fPixelsData]();
         fCdsmatrix  = new Float_t       [fPixelsData]();
-        fNoiseInfo.fNoise      = new Float_t   [fPixelsData]();
-        fNoiseInfo.fPedestals  = new Float_t   [fPixelsData]();
         fHittedPixel= new Int_t     [fPixelsData]();
+        cout << colorcyan << "INIT !!!!!!!!" << endl;
+        
         //-----------------------------------------------
         return true;
     }
@@ -429,8 +448,6 @@ bool MAPS::defaultConf(  ) {
     fF0matrix   = new Int_t     [fPixelsData]();
     fF1matrix   = new Int_t     [fPixelsData]();
     fCdsmatrix  = new Float_t       [fPixelsData]();
-    fNoiseInfo.fNoise      = new Float_t   [fPixelsData]();
-    fNoiseInfo.fPedestals  = new Float_t   [fPixelsData]();
     fHittedPixel= new Int_t     [fPixelsData]();
     //-----------------------------------------------
     return true;
@@ -962,7 +979,7 @@ bool MAPS::InitialDynNoise(Int_t startframe, Int_t frames) {
         
         if( fSave  )
         {
-            fNoiseTree->Fill();
+//             fNoiseTree->Fill();
             cout << colorcyan << fNoiseInfo.fNoise[100] << endlr;
         //             getNoise(startframe, frames);
         }
index cb0ff42aebeb09988566f7a980acd1e95e4b5013..c04eea27e8859042eaad7833125c45a782610fd3 100644 (file)
@@ -924,53 +924,44 @@ string Run::to_str_w_prec(const Float_t a_value, int precision = 3)
 
 Bool_t Run::binLeakageCurrent(HistogramType* oneHistogramClass)
 {
-/*    Float_t pedestial;
-    TBranch* noiseBranch;
-//     oneHistogramClass->LeakageCurrent->Reset();  
-    processed->fNoiseTree->SetBranchAddress("pedestal", &pedestial, &noiseBranch);    
-    cout << colorcyan << "processed->fNoiseTree->GetEntries(): " << processed->fNoiseTree->GetEntries() << endlr;
+    Double_t pedestals [cursensorinfo.columns*cursensorinfo.rows];
     for (Int_t framei=0; framei<processed->fNoiseTree->GetEntries(); framei++) { // loop over all frames
-//         
         processed->fNoiseTree->GetEntry(framei);
-//         cout << pedestial << endl;
-        oneHistogramClass->LeakageCurrent->Fill(1);
-    }  */  
+        for (Int_t pixeli=0; pixeli<cursensorinfo.columns*cursensorinfo.rows ; pixeli++) {
+            pedestals[pixeli] += processed->fNoiseInfo.fPedestals[pixeli];
+        }   
+    }
+    for (Int_t pixeli=0; pixeli<cursensorinfo.columns*cursensorinfo.rows ; pixeli++) {
+        pedestals[pixeli] /= cursensorinfo.columns*cursensorinfo.rows;
+    }
     return 0;
-    
-    
-//     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++)        {
-//             pixelnumber = processed->fFrameInfo.pixel[hiti];
-//             HistogramTypepointer->pixeltimefired->Fill(pixelnumber);
-//         }
-//     }
 }
 
 Bool_t Run::binNoise(HistogramType* oneHistogramClass)
 {
-    Double_t const probabilities[] = {0.3415/2, 0.5, 1-0.3415/2}; // sigma/2 from gaus to the left and to the right //{0.17, 0.5, 1-0.17};
-    oneHistogramClass->Noise->Reset();  
-    cout << colorcyan << "Entries in noise : " << processed->fNoiseTree->GetEntries() << endlr;
-    processed->fNoiseTree->GetEntry(0);
-    for (Int_t framei=0; framei<processed->fNoiseTree->GetEntries(); framei++) { // loop over all frames
-        processed->fNoiseTree->GetEntry(framei);
-        cout << processed->fNoiseInfo.fNoise[100] << " ";
-        cout << processed->fNoiseInfo.fNoise[110] << " ";
-    }
     
-//     for (Int_t cnt=0; cnt<processed->fNoiseTree->GetEntries(); cnt++) {
+       
+    Double_t const probabilities[] = {0.3415/2, 0.5, 1-0.3415/2}; // sigma/2 from gaus to the left and to the right //{0.17, 0.5, 1-0.17}; 
+    cout << "processed->fNoiseTree->GetEntries: " << processed->fNoiseTree->GetEntries() << endl;
+    
+    processed->fNoiseTree->GetEntry(0);        
     for (Int_t pixeli=0; pixeli<cursensorinfo.columns*cursensorinfo.rows ; pixeli++) {
-            oneHistogramClass->Noise->Fill(processed->fNoiseInfo.fNoise[pixeli]);
+//         if (pixeli > 500 && pixeli < 550 ) {
+//             cout << "pixeli: " << pixeli;
+//             cout << " " << processed->fNoiseInfo.fNoise[pixeli] << endl;
+//         }
+        oneHistogramClass->Noise->Fill(processed->fNoiseInfo.fNoise[pixeli]);
     }
-//     }    
     oneHistogramClass->Noise->GetQuantiles( 3, noisequantiles, probabilities);
     oneHistogramClass->avgNoise = noisequantiles[1];
     oneHistogramClass->avgNoisePlus = noisequantiles[2] - noisequantiles[1];
     oneHistogramClass->avgNoiseMinus = noisequantiles[1] - noisequantiles[0];
-    //     if (labbook.system == "PXI")
-    //         for (int j=0; j<3; j++)
-    //             noisequantiles[j] /= 16.0; // TODO analyze PXI scales
+    
+    cout << "HistogramEnd" << endl;
+    processed->fNoiseTree->GetEntry(processed->fNoiseTree->GetEntries()-1);    
+    for (Int_t pixeli=0; pixeli<cursensorinfo.columns*cursensorinfo.rows ; pixeli++) {
+        oneHistogramClass->NoiseEnd->Fill(processed->fNoiseInfo.fNoise[pixeli]);
+    }
     return 0;
 }
 
@@ -1520,7 +1511,8 @@ Bool_t Run::plotAllHistograms(HistogramType* HistogramTypepointer)
         owntitle3->AddText(trimRunnumberAtBegin(HistogramTypepointer->Veto->GetName()));
         owntitle3->Draw("SAME");
         canvas->cd(4);
-        HistogramTypepointer->Noise->Draw();
+        HistogramTypepointer->NoiseEnd->Draw("SAME");
+        HistogramTypepointer->Noise->Draw("SAME");
         TString  legendEntry = Form("Noise: %.2f + %.2f - %.2f",HistogramTypepointer->avgNoise, HistogramTypepointer->avgNoisePlus, HistogramTypepointer->avgNoiseMinus);
         TLegend* leg = new TLegend(0.5,0.8,0.89,0.89);//(0.6,0.7,0.89,0.89);
         leg->AddEntry(HistogramTypepointer->Veto, legendEntry, "l");
index 454f5175eb5cadd3ad1c3af2e14d59e2f06418d7..ed0d4c30885cc1a95280b5f7534fe1f5f797364f 100644 (file)
@@ -17,6 +17,7 @@
 #include <TLegend.h>
 
 #define MAXHITS                        1000000
+#define MAXPIXELS         100000
 //####################################################################
 /**
  * @file help.h
@@ -137,11 +138,11 @@ struct frameInfo{
  */
 struct noiseInfo{
 //     Int_t pixel;
-    Int_t frame;
+    UInt_t frame;
     /// Array with noise information of. given pixel, estimated in @c InitialDynNoise()
-    Float_t*    fNoise;/**< Some documentation for first. */
+    Float_t    fNoise [MAXPIXELS];
     /// Array with pedestial information of given pixel
-    Float_t*    fPedestals;
+    Float_t    fPedestals [MAXPIXELS];
 };