]> jspc29.x-matter.uni-frankfurt.de Git - radhard.git/commitdiff
Reorganized Noise storage in TTree to be more suited for various studies to come
authorBenjamin Linnik <blinnik@jspc61.x-matter.uni-frankfurt.de>
Thu, 11 Aug 2016 15:23:00 +0000 (17:23 +0200)
committerBenjamin Linnik <blinnik@jspc61.x-matter.uni-frankfurt.de>
Thu, 11 Aug 2016 15:23:00 +0000 (17:23 +0200)
MABS_run_analyzer/ChargeSpektrum.c
MABS_run_analyzer/HistogramType.c
MABS_run_analyzer/MAPS.c
MABS_run_analyzer/MAPS.h
MABS_run_analyzer/Run.c
MABS_run_analyzer/help.h

index e1a53516177dac147951385bc3c3933a9a23e3e2..a4983e5c2dca2dac1fc8acebeb832ca290ed1340 100644 (file)
@@ -147,4 +147,5 @@ CompareHistograms(&compareHistogramVector3);
 //    writeObservableToFile("seed threshold");
 //     writeObservableToFile("seed threshold");
 //     writeObservableToFile("sum threshold");
+    cout << "" << endl;
 }
index 4170c03a8dc5c8eccbe9099babbddbf53f315951..97af3b9376a5f2cf53f180724e1fdaa0302135aa 100644 (file)
@@ -48,7 +48,7 @@ void HistogramType::initHistograms(Int_t gotcolor, Int_t gotstyle) {
     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-1, cursensorinfo->columns*cursensorinfo->rows, "Pixel index", "Average CDS");
+    initHistogramCustom(LeakageCurrent, "Leakage current per pixel" + histogramdescription, 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);
index eb13dbddaf55ac5f77ed23a586caf3940e4f1585..7ae4452d3c898da288fcae180f7c838a127762bc 100644 (file)
@@ -65,8 +65,10 @@ Bool_t MAPS::initNewRootFile() {
         }
         // Noise TTree
         fNoiseTree      = new TTree("noise", "noise");
-        fDynNoiseTree   = fNoiseTree;
-        
+        fNoiseTree->Branch("frame"      , &fFrameInfo.frame    , "frame/i"     , 32000);
+        fNoiseTree->Branch("noise"      , &(fNoiseInfo.fNoise)    , "noise/F"     , 32000);
+        fNoiseTree->Branch("pedestal"   , &(fNoiseInfo.fPedestals) , "pedestal/F"  , 32000);
+                
         initHistograms();
         cout<<"-----------------------"<<endl;
         cout<<fRootFile<<" recreated!"<<endl;
@@ -105,13 +107,17 @@ Bool_t MAPS::initOldRootFile() {
     for(int i=0; i<25; i++) {
         fHitTree->SetBranchAddress( Form("p%i",i+1)   , &fFrameInfo.p[i][0]);
     }
+    // Noise TTree
     fNoiseTree =  (TTree*) fOutputFile->Get("noise");
     if (!fNoiseTree) // got pointer
     {
         cout<< colorred << "Error finding noise TTree in old ROOT file!"<< endlr;
         return 1;
     }
-    fDynNoiseTree   = fNoiseTree;
+    fNoiseTree->SetBranchAddress("frame"      , &fFrameInfo.frame);
+    fNoiseTree->SetBranchAddress("noise"      , &(fNoiseInfo.fNoise));
+    fNoiseTree->SetBranchAddress("pedestal"   , &(fNoiseInfo.fPedestals));
+    
     initHistograms();  
     cout<<"-----------------------"<<endl;
     cout<<fRootFile<<" opened!"<<endl;
@@ -127,7 +133,6 @@ MAPS::~MAPS(void) {
         
         fHitTree->Write("",TObject::kOverwrite);
         fNoiseTree->Write("",TObject::kOverwrite);
-        fDynNoiseTree->Write("",TObject::kOverwrite);
         
         hint1->Write("",TObject::kOverwrite);
         hint2->Write("",TObject::kOverwrite);
@@ -163,8 +168,6 @@ MAPS::~MAPS(void) {
     delete[] fF0matrix;
     delete[] fF1matrix;
     delete[] fCdsmatrix;
-    delete[] fNoise;
-    delete[] fPedestals;
     cout<< colorwhite <<"================================================================="<<endlr;
     
 };
@@ -188,7 +191,6 @@ void MAPS::save() {
         
         fHitTree->Write("",TObject::kOverwrite);
         fNoiseTree->Write("",TObject::kOverwrite);
-        fDynNoiseTree->Write("",TObject::kOverwrite);
         
         hint1->Write("",TObject::kOverwrite);
         hint2->Write("",TObject::kOverwrite);
@@ -392,8 +394,8 @@ bool MAPS::checkConf( Int_t &PixelData ) {
         fF0matrix   = new Int_t     [fPixelsData]();
         fF1matrix   = new Int_t     [fPixelsData]();
         fCdsmatrix  = new Float_t       [fPixelsData]();
-        fNoise      = new Float_t   [fPixelsData]();
-        fPedestals  = new Float_t   [fPixelsData]();
+        fNoiseInfo.fNoise      = new Float_t   [fPixelsData]();
+        fNoiseInfo.fPedestals  = new Float_t   [fPixelsData]();
         fHittedPixel= new Int_t     [fPixelsData]();
         //-----------------------------------------------
         return true;
@@ -427,8 +429,8 @@ bool MAPS::defaultConf(  ) {
     fF0matrix   = new Int_t     [fPixelsData]();
     fF1matrix   = new Int_t     [fPixelsData]();
     fCdsmatrix  = new Float_t       [fPixelsData]();
-    fNoise      = new Float_t   [fPixelsData]();
-    fPedestals  = new Float_t   [fPixelsData]();
+    fNoiseInfo.fNoise      = new Float_t   [fPixelsData]();
+    fNoiseInfo.fPedestals  = new Float_t   [fPixelsData]();
     fHittedPixel= new Int_t     [fPixelsData]();
     //-----------------------------------------------
     return true;
@@ -696,91 +698,81 @@ bool MAPS::getFrame(UInt_t FrameNumber) {
 //####################################################################
 
 bool MAPS::getNoise(UInt_t Start, UInt_t Frames) {
-//Noise + Pedestals
-if(fOk)
-{
-    cout<<"Run getNoise() ..."<<endl;
-    //Check amount of Frames
-    if(Frames<50)
-    {
-        cout<<"Too few Frames! Change Frames from "<<Frames<<" to ";
-        Frames = 50;
-        cout<<Frames<<" !"<<endl;
-    }
-    //Check availabilty of Frames
-    if( Frames          > fEventsSum )  {
-        Frames = fEventsSum;
-        printf("Changed 'Number Frames' to: %u\n", Frames );
-    }
-    if( Frames+Start    > fEventsSum )  {
-        Start = fEventsSum-Frames;
-        printf("Changed 'First Event'   to: %u\n", Start );
-    }
-    // Get fPixels and allocate array
-    Float_t *ARR = new Float_t[Frames*fPixels];
-    Float_t PEDESTAL;
-    Float_t NOISE;
-    Int_t PIXEL;
-    
-    for(UInt_t i=Start; i<Frames+Start; i++)
+    //Noise + Pedestals
+    if(fOk)
     {
-        getFrame(i);
-        
-        for(Int_t j=0; j<fPixels; j++)
+        cout<<"Run getNoise() ..."<<endl;
+        //Check amount of Frames
+        if(Frames<50)
         {
-            ARR[(i-Start)*fPixels+j] = fCdsmatrix[j];
+            cout<<"Too few Frames! Change Frames from "<<Frames<<" to ";
+            Frames = 50;
+            cout<<Frames<<" !"<<endl;
         }
-    }
-    
-    
-    if(fSave)
-    {
-        fNoiseTree->Reset();
-        fNoiseTree->Branch("pixel"      , &PIXEL    , "pixel/i"     , 32000);
-        fNoiseTree->Branch("noise"      , &NOISE    , "noise/F"     , 32000);
-        fNoiseTree->Branch("pedestal"   , &PEDESTAL , "pedestal/F"  , 32000);
-    }
-    
-    for(Int_t i=0; i<fPixels; i++)
-    {
-        PEDESTAL    = 0;
-        NOISE       = 0;
+        //Check availabilty of Frames
+        if( Frames          > fEventsSum )  {
+            Frames = fEventsSum;
+            printf("Changed 'Number Frames' to: %u\n", Frames );
+        }
+        if( Frames+Start    > fEventsSum )  {
+            Start = fEventsSum-Frames;
+            printf("Changed 'First Event'   to: %u\n", Start );
+        }
+        // Get fPixels and allocate array
+        Float_t *ARR = new Float_t[Frames*fPixels];
+        Float_t PEDESTAL;
+        Float_t NOISE;
+        Int_t PIXEL;
         
-        for(UInt_t j=0; j<Frames; j++)
+        for(UInt_t i=Start; i<Frames+Start; i++)
         {
-            PEDESTAL+=ARR[j*fPixels+i];
+            getFrame(i);        
+            for(Int_t j=0; j<fPixels; j++)
+            {
+                ARR[(i-Start)*fPixels+j] = fCdsmatrix[j];
+            }
         }
         
-        PEDESTAL = PEDESTAL/Frames;
-        cout << colorcyan << "Pedestal :" << PEDESTAL << endlr;
         
-        for(UInt_t j=0; j<Frames; j++)
+        for(Int_t i=0; i<fPixels; i++)
         {
-            NOISE+=TMath::Power(ARR[j*fPixels+i]-PEDESTAL,2);
+            PEDESTAL    = 0;
+            NOISE       = 0;
+            
+            for(UInt_t j=0; j<Frames; j++)
+            {
+                PEDESTAL+=ARR[j*fPixels+i];
+            }
+            
+            PEDESTAL = PEDESTAL/Frames;
+            cout << colorcyan << "Pedestal :" << PEDESTAL << endlr;
+            
+            for(UInt_t j=0; j<Frames; j++)
+            {
+                NOISE+=TMath::Power(ARR[j*fPixels+i]-PEDESTAL,2);
+            }
+            
+            NOISE = TMath::Sqrt(NOISE/(Frames-1));
+            cout << colorcyan << "NOISE :" << NOISE << endlr;
+            
+            fNoiseInfo.fNoise[i]       = NOISE;
+            fNoiseInfo.fPedestals[i]   = PEDESTAL;
+            
+    //         if(fSave)   {
+    //             fNoiseTree->Fill();
+    //         }
         }
         
-        NOISE = TMath::Sqrt(NOISE/(Frames-1));
-        cout << colorcyan << "NOISE :" << NOISE << endlr;
-        
-        fNoise[i]       = NOISE;
-        fPedestals[i]   = PEDESTAL;
-        PIXEL           = i;
+        cout<<"-----------------------"<<endl;
         
-        if(fSave)   {
-            fNoiseTree->Fill();
-        }
+        delete[] ARR;
+        fNoiseOk = true;
+        return true;
+    }
+    else
+    {
+        return false;
     }
-    
-    cout<<"-----------------------"<<endl;
-    
-    delete[] ARR;
-    fNoiseOk = true;
-    return true;
-}
-else
-{
-    return false;
-}
 };
 
 //####################################################################
@@ -802,9 +794,6 @@ bool MAPS::InitialDynNoise(Int_t startframe, Int_t frames) {
     Int_t* nframescutawaythirdnoiseestimate = new Int_t[fPixels]();   
     Int_t npixelscutawaythirdnoiseestimate=0; 
 
-
-
-
     //     fDynNoiseTree->Branch("frame"       , &fFrameNumber     , "frame/i"     , 32000);
     //     fDynNoiseTree->Branch("noise"       , &fNoiseMean       , "noise/F"     , 32000);
     //     fDynNoiseTree->Branch("pedestal"    , &fPedestalsMean   , "pedestal/F"  , 32000);
@@ -836,13 +825,13 @@ bool MAPS::InitialDynNoise(Int_t startframe, Int_t frames) {
             
             for(Int_t pixeli=0; pixeli<fPixels; pixeli++)
             {
-                fPedestals[pixeli] += fCdsmatrix[pixeli];
+                fNoiseInfo.fPedestals[pixeli] += fCdsmatrix[pixeli];
             }
         }
         // calculate average pedestal of each pixel
         for(Int_t pixeli=0; pixeli<fPixels; pixeli++)
         {
-            fPedestals[pixeli] /= frames;
+            fNoiseInfo.fPedestals[pixeli] /= frames;
         }
         
         // sum up over all frames every variance from the pedestial, pixelwise
@@ -851,12 +840,12 @@ bool MAPS::InitialDynNoise(Int_t startframe, Int_t frames) {
             getFrame(framei);
             for(Int_t pixeli=0; pixeli<fPixels; pixeli++)
             {
-                fNoise[pixeli] += TMath::Power(1.*fCdsmatrix[pixeli]-fPedestals[pixeli],2);
+                fNoiseInfo.fNoise[pixeli] += TMath::Power(1.*fCdsmatrix[pixeli]-fNoiseInfo.fPedestals[pixeli],2);
             }
         }
         for(Int_t pixeli=0; pixeli<fPixels; pixeli++)
         {
-            fNoise[pixeli] = TMath::Sqrt(fNoise[pixeli]/(frames-1)); // Standard deviation is defined with n-1 
+            fNoiseInfo.fNoise[pixeli] = TMath::Sqrt(fNoiseInfo.fNoise[pixeli]/(frames-1)); // Standard deviation is defined with n-1 
         }
         
         // second estimate
@@ -867,7 +856,7 @@ bool MAPS::InitialDynNoise(Int_t startframe, Int_t frames) {
             getFrame(framei);
             for(Int_t pixeli=0; pixeli<fPixels; pixeli++)
             {
-                if (abs(1.*(fCdsmatrix[pixeli]-fPedestals[pixeli])) <= 5.*fNoise[pixeli])
+                if (abs(1.*(fCdsmatrix[pixeli]-fNoiseInfo.fPedestals[pixeli])) <= 5.*fNoiseInfo.fNoise[pixeli])
                 {
                     pixelpedestal2[pixeli] += fCdsmatrix[pixeli];
                 }
@@ -891,7 +880,7 @@ bool MAPS::InitialDynNoise(Int_t startframe, Int_t frames) {
             getFrame(framei);
             for(Int_t pixeli=0; pixeli<fPixels; pixeli++)
             {
-                if (abs(1.*(fCdsmatrix[pixeli]-fPedestals[pixeli])) <= 5.*fNoise[pixeli])
+                if (abs(1.*(fCdsmatrix[pixeli]-fNoiseInfo.fPedestals[pixeli])) <= 5.*fNoiseInfo.fNoise[pixeli])
                 {
                     pixelnoise2[pixeli] += TMath::Power(1.*fCdsmatrix[pixeli]-pixelpedestal2[pixeli],2);
                 }
@@ -912,8 +901,8 @@ bool MAPS::InitialDynNoise(Int_t startframe, Int_t frames) {
         // reset noise and pedestal array
         for(Int_t pixeli=0; pixeli<fPixels; pixeli++)
         {
-            fPedestals[pixeli]=0;
-            fNoise[pixeli]=0;
+            fNoiseInfo.fPedestals[pixeli]=0;
+            fNoiseInfo.fNoise[pixeli]=0;
         }
         
         for(Int_t framei=startframe; framei<frames+startframe; framei++)
@@ -923,7 +912,7 @@ bool MAPS::InitialDynNoise(Int_t startframe, Int_t frames) {
             {
                 if (abs(1.*(fCdsmatrix[pixeli]-pixelpedestal2[pixeli])) <= 5.*pixelnoise2[pixeli])
                 {
-                    fPedestals[pixeli] += fCdsmatrix[pixeli];
+                    fNoiseInfo.fPedestals[pixeli] += fCdsmatrix[pixeli];
                     if (!useexponentialdecayingnoisewindow)
                         CDSlastframes[pixeli].push(fCdsmatrix[pixeli]);
                 }
@@ -936,7 +925,7 @@ bool MAPS::InitialDynNoise(Int_t startframe, Int_t frames) {
         }
         for(Int_t pixeli=0; pixeli<fPixels; pixeli++)
         {
-            fPedestals[pixeli] /= (frames-nframescutawaythirdnoiseestimate[pixeli]);
+            fNoiseInfo.fPedestals[pixeli] /= (frames-nframescutawaythirdnoiseestimate[pixeli]);
         }
         
         // sum up over all frames every variance from the pedestial, pixelwise
@@ -947,9 +936,9 @@ bool MAPS::InitialDynNoise(Int_t startframe, Int_t frames) {
             {
                 if (abs(1.*(fCdsmatrix[pixeli]-pixelpedestal2[pixeli])) <= 5.*pixelnoise2[pixeli])
                 {
-                    fNoise[pixeli] += TMath::Power(1.*fCdsmatrix[pixeli]-fPedestals[pixeli],2);
+                    fNoiseInfo.fNoise[pixeli] += TMath::Power(1.*fCdsmatrix[pixeli]-fNoiseInfo.fPedestals[pixeli],2);
                     if (!useexponentialdecayingnoisewindow)
-                        noiselastframes[pixeli].push(TMath::Power(1.*fCdsmatrix[pixeli]-fPedestals[pixeli],2));
+                        noiselastframes[pixeli].push(TMath::Power(1.*fCdsmatrix[pixeli]-fNoiseInfo.fPedestals[pixeli],2));
                 }
             }
         }
@@ -957,8 +946,8 @@ bool MAPS::InitialDynNoise(Int_t startframe, Int_t frames) {
         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 )
+            fNoiseInfo.fNoise[pixeli] = TMath::Sqrt(fNoiseInfo.fNoise[pixeli]/(frames-nframescutawaythirdnoiseestimate[pixeli]-1)); // don't forget the "-1" !!!
+            if ( fNoiseInfo.fNoise[pixeli] == 0 )
                 npixelwithnoisezero++;            
         }
         npixelscutawaythirdnoiseestimate = SumOverArray(nframescutawaythirdnoiseestimate, fPixels);
@@ -973,23 +962,8 @@ bool MAPS::InitialDynNoise(Int_t startframe, Int_t frames) {
         
         if( fSave  )
         {
-            Float_t PEDESTAL;
-            Float_t NOISE;
-            Int_t PIXEL;
-            
-            fNoiseTree->Branch("pixel"      , &PIXEL    , "pixel/i"     , 32000);
-            fNoiseTree->Branch("noise"      , &NOISE    , "noise/F"     , 32000);
-            fNoiseTree->Branch("pedestal"   , &PEDESTAL , "pedestal/F"  , 32000);
-        
-            for(Int_t pixeli=0; pixeli<fPixels; pixeli++)
-            {
-                PEDESTAL = fPedestals[pixeli];                
-                NOISE = fNoise[pixeli];
-                PIXEL = pixeli;
-                
-                if (NOISE > 0)
-                    fNoiseTree->Fill();
-            }
+            fNoiseTree->Fill();
+            cout << colorcyan << fNoiseInfo.fNoise[100] << endlr;
         //             getNoise(startframe, frames);
         }
         
@@ -1042,19 +1016,19 @@ bool MAPS::regetDynNoise(Int_t Frames) {
         {
             if (useexponentialdecayingnoisewindow)
             {
-                fNoise[pixeli]     = TMath::Sqrt(( (Frames-2)*TMath::Power(fNoise[pixeli],2) + TMath::Power(1.*fCdsmatrix[pixeli]-fPedestals[pixeli],2) )/(Frames-1));
-                fPedestals[pixeli] = ( (Frames-1)*fPedestals[pixeli] + fCdsmatrix[pixeli] )/Frames;
+                fNoiseInfo.fNoise[pixeli]     = TMath::Sqrt(( (Frames-2)*TMath::Power(fNoiseInfo.fNoise[pixeli],2) + TMath::Power(1.*fCdsmatrix[pixeli]-fNoiseInfo.fPedestals[pixeli],2) )/(Frames-1));
+                fNoiseInfo.fPedestals[pixeli] = ( (Frames-1)*fNoiseInfo.fPedestals[pixeli] + fCdsmatrix[pixeli] )/Frames;
             }
             else
             {
-                fNoise[pixeli]=TMath::Sqrt(TMath::Power(fNoise[pixeli],2)-(noiselastframes[pixeli].front()-TMath::Power(fCdsmatrix[pixeli]-fPedestals[pixeli],2))/(noiselastframes[pixeli].size()-1));
+                fNoiseInfo.fNoise[pixeli]=TMath::Sqrt(TMath::Power(fNoiseInfo.fNoise[pixeli],2)-(noiselastframes[pixeli].front()-TMath::Power(fCdsmatrix[pixeli]-fNoiseInfo.fPedestals[pixeli],2))/(noiselastframes[pixeli].size()-1));
                 noiselastframes[pixeli].pop();
-                noiselastframes[pixeli].push(TMath::Power(fCdsmatrix[pixeli]-fPedestals[pixeli],2));
-                fPedestals[pixeli] -= (CDSlastframes[pixeli].front()-fCdsmatrix[pixeli])/CDSlastframes[pixeli].size();
+                noiselastframes[pixeli].push(TMath::Power(fCdsmatrix[pixeli]-fNoiseInfo.fPedestals[pixeli],2));
+                fNoiseInfo.fPedestals[pixeli] -= (CDSlastframes[pixeli].front()-fCdsmatrix[pixeli])/CDSlastframes[pixeli].size();
                 CDSlastframes[pixeli].pop();
                 CDSlastframes[pixeli].push(fCdsmatrix[pixeli]);
             }
-            if (abs(fPedestals[pixeli])>20)
+            if (abs(fNoiseInfo.fPedestals[pixeli])>20)
             {
                 fPedestalhighPixel++;
                 if (!pedestalhighinthisframe) {
@@ -1070,7 +1044,7 @@ bool MAPS::regetDynNoise(Int_t Frames) {
                 //                                     debugStream<>(fHittedPixel, fPixels, fColumns, 1, 1);
                 //                                     exit(1);
             }
-            if (abs(fNoise[pixeli])>20)
+            if (abs(fNoiseInfo.fNoise[pixeli])>20)
             {
                 fNoiseHighPixel++;
                 if (!noisehighinthisframe) {
@@ -1103,26 +1077,9 @@ bool MAPS::regetDynNoise(Int_t Frames) {
     {
         if(fSave)
         {
-            Float_t PEDESTAL;
-            Float_t NOISE;
-            Int_t PIXEL;
-            
-            fNoiseTree      = new TTree("noise", "noise");
-            fNoiseTree->Reset();
-            fNoiseTree->Branch("pixel"      , &PIXEL    , "pixel/i"     , 32000);
-            fNoiseTree->Branch("noise"      , &NOISE    , "noise/F"     , 32000);
-            fNoiseTree->Branch("pedestal"   , &PEDESTAL , "pedestal/F"  , 32000);
-            
-            for(Int_t pixeli=0; pixeli<fPixels; pixeli++)
-            {
-                
-                PEDESTAL = fPedestals[pixeli];                
-                NOISE = fNoise[pixeli];
-                PIXEL = pixeli;
-                fNoiseTree->Fill();
-            }
-//             cout << colorcyan << "Refilling" << endlr;
-            
+            fNoiseTree->Fill();
+            cout << colorcyan << "Refilling" << endlr;   
+            cout << colorcyan << fNoiseInfo.fNoise[100] << endlr;         
             RefilledNoiseBranch = true;
             //             for(Int_t pixeli=0; pixeli<fPixels; pixeli++)
             //             {
@@ -1147,58 +1104,12 @@ bool MAPS::regetDynNoise(Int_t Frames) {
     return true;
 }
 
-//###################################################################
-bool MAPS::loadNoise() {
-    loadNoise(fRootFile);
-    return 0;
-}
-
-bool MAPS::loadNoise( TString filename) {
-    TFile *f = new TFile(filename,"READ");
-
-    if(f->IsZombie())
-    {
-        cerr<<"ERROR: loadNoise() failed!"<<endl;
-        cerr<<filename<<" not found!"<<endl;
-        cerr<<"-----------------------"<<endl;
-        return false;
-        exit(-1);
-    }
-    else
-    {
-        
-        TTree *noiseTree    = (TNtuple*) f->Get("noise");
-        
-        UInt_t  PIXEL;
-        Float_t NOISE, PEDESTAL;
-        
-        noiseTree->SetBranchAddress("pixel"     , &PIXEL    );
-        cout<<"Noise/Pedestals loaded from:"<< filename << "!"<<endl;
-        noiseTree->SetBranchAddress("noise"     , &NOISE    );
-        noiseTree->SetBranchAddress("pedestal"  , &PEDESTAL );
-        
-        Int_t entries       = noiseTree->GetEntries();
-        
-        for(Int_t i=0; i<entries; i++)
-        {
-            noiseTree->GetEntry(i);
-            
-            fNoise[i]       = NOISE;
-            fPedestals[i]   = PEDESTAL;
-        }
-        cout<<"-----------------------"<<endl;
-        fNoiseOk    = true;
-        fNoiseExt   = true;
-        return true;
-    }
-};
-
 //####################################################################
 
 bool MAPS::setNoise(Float_t Noise) {
     for(Int_t i=0; i<fPixels; i++)
     {
-        fNoise[i]       = Noise;
+        fNoiseInfo.fNoise[i]       = Noise;
     }
 
     fNoiseOk = true;
@@ -1210,7 +1121,7 @@ bool MAPS::setNoise(Float_t Noise) {
 bool MAPS::setPedestals(Float_t Pedestals) {
     for(Int_t i=0; i<fPixels; i++)
     {
-        fPedestals[i]   = Pedestals;
+        fNoiseInfo.fPedestals[i]   = Pedestals;
     }
 
     //  fNoiseOk = true;
@@ -1264,10 +1175,10 @@ void MAPS::hitana() {
 //           debugStream<>(fPedestals, fPixels, fColumns, 2, 20);        
         for(Int_t i=0; i<fPixels; i++)
         {
-            cdsmatrixCorrPed[i]=(float)(1.*fCdsmatrix[i]-fPedestals[i]);
+            cdsmatrixCorrPed[i]=(float)(1.*fCdsmatrix[i]-fNoiseInfo.fPedestals[i]);
             fHittedPixel[i] = 0;
             //    if( (float)(1.*fCdsmatrix[i]-fPedestals[i]) > (50.) )
-            if( (float)(1.*fCdsmatrix[i]-fPedestals[i]) > (5.*fNoise[i]) )
+            if( (float)(1.*fCdsmatrix[i]-fNoiseInfo.fPedestals[i]) > (5.*fNoiseInfo.fNoise[i]) )
             {
                 HITNR++;
                 HITS.Set(HITNR);
@@ -1277,7 +1188,7 @@ void MAPS::hitana() {
                 }
             }
             
-            if( (float)(1.*fCdsmatrix[i]-fPedestals[i]) < (-5.*fNoise[i]) )  // loop to find pixel with highly negative CDS
+            if( (float)(1.*fCdsmatrix[i]-fNoiseInfo.fPedestals[i]) < (-5.*fNoiseInfo.fNoise[i]) )  // loop to find pixel with highly negative CDS
             {
                 rechargePixellist.push_back(i);
             }
@@ -1355,7 +1266,7 @@ void MAPS::hitana() {
                             pixelchargeincluster[(row*5)+column]=DUMMY;
                         }
                         else                                            {
-                            pixelchargeincluster[(row*5)+column] = 1.*fCdsmatrix [rechargePixellist[rechargingpixeli]+(row-2)*fColumns+(column-2)] - fPedestals [rechargePixellist[rechargingpixeli]+(row-2)*fColumns+(column-2)];
+                            pixelchargeincluster[(row*5)+column] = 1.*fCdsmatrix [rechargePixellist[rechargingpixeli]+(row-2)*fColumns+(column-2)] - fNoiseInfo.fPedestals [rechargePixellist[rechargingpixeli]+(row-2)*fColumns+(column-2)];
                         }
                     }
                 }
@@ -1499,8 +1410,8 @@ void MAPS::hitana() {
                             noiseincluster[(row*5)+column]=DUMMY;
                         }
                         else                                            {
-                            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)];
+                            noiseincluster[(row*5)+column] = fNoiseInfo.fNoise[Hitlist[hit]+(row-2)*fColumns+(column-2)];
+                            pixelchargeincluster[(row*5)+column] = 1.*fCdsmatrix [Hitlist[hit]+(row-2)*fColumns+(column-2)] - fNoiseInfo.fPedestals [Hitlist[hit]+(row-2)*fColumns+(column-2)];
                             noisesumincluster+=TMath::Power(noiseincluster[(row*5)+column],2);
                             //noisesumincluster+=noiseincluster[(row*5)+column]; //Mathematicabug reconstructed
                             chargesumincluster+=pixelchargeincluster[(row*5)+column];
@@ -1748,7 +1659,7 @@ void MAPS::filterCommonMode() {
         
         for(int column=0; column<fColumns; column++ )
         {
-            Arr[column] = fCdsmatrix[ row*fColumns+column ] - fPedestals[ row*fColumns+column ];    // Bugfix: Considered pedestals in common mode calculation
+            Arr[column] = fCdsmatrix[ row*fColumns+column ] - fNoiseInfo.fPedestals[ row*fColumns+column ];    // Bugfix: Considered pedestals in common mode calculation
         }
         
         CommonModeInRow = TMath::Median(fColumns, Arr); // Don't use mean, consider hitted pixel !
@@ -1792,7 +1703,7 @@ void MAPS::plotFrame(Int_t FrameNumber) {
         Float_t cdsmatrixCorrPed[fPixels];
         for(Int_t i=0; i<fPixels; i++)
         {
-            cdsmatrixCorrPed[i]=(float)(1.*fCdsmatrix[i]-fPedestals[i]);
+            cdsmatrixCorrPed[i]=(float)(1.*fCdsmatrix[i]-fNoiseInfo.fPedestals[i]);
         }
         cout<<"CDS matrix minus pedestals:"<<endl;
         debugStream<>(cdsmatrixCorrPed, fPixels/fColumns, fColumns, 0, 10);
@@ -1913,8 +1824,8 @@ void MAPS::plotNoise() {
             
             column  = i%fColumns;
             row     = i/fColumns;
-            NOISE       = fNoise[i];
-            PEDESTAL    = fPedestals[i];
+            NOISE       = fNoiseInfo.fNoise[i];
+            PEDESTAL    = fNoiseInfo.fPedestals[i];
             
             h1->Fill(NOISE);
             h2->Fill(PEDESTAL);
@@ -1955,7 +1866,6 @@ void MAPS::plotNoise() {
 //####################################################################
 
 void MAPS::plotHitDis(UInt_t Start, UInt_t Frames) {
-
     if(fOk)
     {
         //Check availabilty of Frames
index 3067d7c98e9d1ec95e631c0e7e99cf433319a51b..53c8c83b2831d7c225b5e6bc2b9c32aecfa042a7 100644 (file)
@@ -118,10 +118,6 @@ private:
     Int_t*      fF1matrix;
     /// Array with CDS values of pixels in current frame
     Float_t*      fCdsmatrix;
-    /// Array with noise information of. given pixel, estimated in @c InitialDynNoise()
-    Float_t*    fNoise;/**< Some documentation for first. */
-    /// Array with pedestial information of given pixel
-    Float_t*    fPedestals;
     
     std::queue<Float_t>* noiselastframes;
     std::queue<Float_t>* CDSlastframes;
@@ -379,9 +375,6 @@ public:
      * @brief Old routine, shoould be deletable without side effects */
     bool getNoise       (UInt_t Start, UInt_t Frames);
     
-    /// Pointer to the ROOT TTree of the run containing the noise, only used if external noise used
-    TTree*  fNoiseTree;
-    
     
     /**
      *  @brief  Calculates a first estimate of the noise and pedestial of each pixel in #MAPS::frames
@@ -431,18 +424,7 @@ public:
      * @return true if no errors occured
      */
     bool regetDynNoise  (Int_t Frames = numberofframesfornoise);
-    
-    /**
-     * @brief Old routine, should load noise information from given runnumber root file
-     * 
-     * Was not maintained a while, one should check it before applying
-     * 
-     * @param InDir Directory in LINUX format where the *runnumber*_*matrix*.root file can be found
-     * @param RunNumber The runnumber is used to substitute the correct name of the .root file
-     * @param Matrix Used to substitute in filename
-     */
-    bool loadNoise      (TString filename);
-    bool loadNoise      ();
+
     /**
      * @brief Sets noise of each pixel to a given value
      * 
@@ -461,6 +443,10 @@ public:
     frameInfo fFrameInfo;
     // pointer to TTree with hit, frame and cluster information
     TTree*  fHitTree;
+    /// stores infomration about the current frame, and its noise
+    noiseInfo  fNoiseInfo;
+    // pointer to TTree with noise, pedestal and frame information
+    TTree*  fNoiseTree;
     
     Bool_t useexponentialdecayingnoisewindow = 0;
     
@@ -501,7 +487,7 @@ public:
     Float_t*        GetCDSFrame()                   { return fCdsmatrix;                    }
     Int_t*          GetF0Frame()                    { return fF0matrix;                     }
     Int_t*          GetF1Frame()                    { return fF1matrix;                     }
-    Float_t*        GetNoise()                      { return fNoise;                        }
+    Float_t*        GetNoise()                      { return fNoiseInfo.fNoise;             }
     
     // Output Directory, set and passed initMapsRun() to  in the constructor
     
index 0ca21b9723f4eac38f6aae7206e60add369fbeb6..cb0ff42aebeb09988566f7a980acd1e95e4b5013 100644 (file)
@@ -381,8 +381,8 @@ Bool_t Run::analyzeRun(Bool_t force)
             processed->InitialDynNoise();
             int start   = 0;
             int nframes = processed->GetNumberFrames();
-//             for(int i=0; i<10000;i++) // TODO remove 100000 run 342272
-            for(int i=0; i<nframes;i++) // TODO remove 100000 run 342272
+            for(int i=0; i<1000;i++) // TODO remove 100000 run 342272
+//             for(int i=0; i<nframes;i++) // TODO remove 100000 run 342272
             {
 //                 cout << "getframe " << i << endl;
                 processed->getFrame(i);
@@ -924,16 +924,17 @@ string Run::to_str_w_prec(const Float_t a_value, int precision = 3)
 
 Bool_t Run::binLeakageCurrent(HistogramType* oneHistogramClass)
 {
-    Float_t pedestial;
+/*    Float_t pedestial;
     TBranch* noiseBranch;
-    oneHistogramClass->LeakageCurrent->Reset();  
+//     oneHistogramClass->LeakageCurrent->Reset();  
     processed->fNoiseTree->SetBranchAddress("pedestal", &pedestial, &noiseBranch);    
-//     cout << colorcyan << "processed->fNoiseTree->GetEntries(): " << processed->fNoiseTree->GetEntries() << endlr;
+    cout << colorcyan << "processed->fNoiseTree->GetEntries(): " << processed->fNoiseTree->GetEntries() << endlr;
     for (Int_t framei=0; framei<processed->fNoiseTree->GetEntries(); framei++) { // loop over all frames
-        
+//         
         processed->fNoiseTree->GetEntry(framei);
-        oneHistogramClass->LeakageCurrent->Fill(pedestial);
-    }    
+//         cout << pedestial << endl;
+        oneHistogramClass->LeakageCurrent->Fill(1);
+    }  */  
     return 0;
     
     
@@ -948,15 +949,21 @@ Bool_t Run::binLeakageCurrent(HistogramType* oneHistogramClass)
 
 Bool_t Run::binNoise(HistogramType* oneHistogramClass)
 {
-    Float_t noise;
-    TBranch* noiseBranch;
     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();
-    processed->fNoiseTree->SetBranchAddress("noise", &noise, &noiseBranch);    
-    for (Int_t cnt=0; cnt<processed->fNoiseTree->GetEntries(); cnt++) {
-        processed->fNoiseTree->GetEntry(cnt);
-        oneHistogramClass->Noise->Fill(noise);
-    }    
+    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++) {
+    for (Int_t pixeli=0; pixeli<cursensorinfo.columns*cursensorinfo.rows ; pixeli++) {
+            oneHistogramClass->Noise->Fill(processed->fNoiseInfo.fNoise[pixeli]);
+    }
+//     }    
     oneHistogramClass->Noise->GetQuantiles( 3, noisequantiles, probabilities);
     oneHistogramClass->avgNoise = noisequantiles[1];
     oneHistogramClass->avgNoisePlus = noisequantiles[2] - noisequantiles[1];
index d6c49336d171aac5896713fe4f8f3b077c4c9749..454f5175eb5cadd3ad1c3af2e14d59e2f06418d7 100644 (file)
@@ -131,6 +131,20 @@ struct frameInfo{
        Float_t p               [25][MAXHITS];
 };
 
+
+/** @brief holds frame specific variables
+ * 
+ */
+struct noiseInfo{
+//     Int_t pixel;
+    Int_t frame;
+    /// Array with noise information of. given pixel, estimated in @c InitialDynNoise()
+    Float_t*    fNoise;/**< Some documentation for first. */
+    /// Array with pedestial information of given pixel
+    Float_t*    fPedestals;
+};
+
+
 /** @brief system specific constants
  * 
  * Set in #HistogramType::setSystemSpecificParameters()