From: Benjamin Linnik Date: Thu, 11 Aug 2016 15:23:00 +0000 (+0200) Subject: Reorganized Noise storage in TTree to be more suited for various studies to come X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=290f5261d031d20ce0868b5fb48d1c362d17469d;p=radhard.git Reorganized Noise storage in TTree to be more suited for various studies to come --- diff --git a/MABS_run_analyzer/ChargeSpektrum.c b/MABS_run_analyzer/ChargeSpektrum.c index e1a5351..a4983e5 100644 --- a/MABS_run_analyzer/ChargeSpektrum.c +++ b/MABS_run_analyzer/ChargeSpektrum.c @@ -147,4 +147,5 @@ CompareHistograms(&compareHistogramVector3); // writeObservableToFile("seed threshold"); // writeObservableToFile("seed threshold"); // writeObservableToFile("sum threshold"); + cout << "" << endl; } diff --git a/MABS_run_analyzer/HistogramType.c b/MABS_run_analyzer/HistogramType.c index 4170c03..97af3b9 100644 --- a/MABS_run_analyzer/HistogramType.c +++ b/MABS_run_analyzer/HistogramType.c @@ -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); diff --git a/MABS_run_analyzer/MAPS.c b/MABS_run_analyzer/MAPS.c index eb13dbd..7ae4452 100644 --- a/MABS_run_analyzer/MAPS.c +++ b/MABS_run_analyzer/MAPS.c @@ -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<<"-----------------------"<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<<"-----------------------"<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 <<"================================================================="<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() ..."< 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; iReset(); - 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 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; jFill(); + // } } - NOISE = TMath::Sqrt(NOISE/(Frames-1)); - cout << colorcyan << "NOISE :" << NOISE << endlr; - - fNoise[i] = NOISE; - fPedestals[i] = PEDESTAL; - PIXEL = i; + cout<<"-----------------------"<Fill(); - } + delete[] ARR; + fNoiseOk = true; + return true; + } + else + { + return false; } - - cout<<"-----------------------"<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; pixeliBranch("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 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; pixeliFill(); - } -// cout << colorcyan << "Refilling" << endlr; - + fNoiseTree->Fill(); + cout << colorcyan << "Refilling" << endlr; + cout << colorcyan << fNoiseInfo.fNoise[100] << endlr; RefilledNoiseBranch = true; // for(Int_t pixeli=0; pixeliIsZombie()) - { - cerr<<"ERROR: loadNoise() failed!"<Get("noise"); - - UInt_t PIXEL; - Float_t NOISE, PEDESTAL; - - noiseTree->SetBranchAddress("pixel" , &PIXEL ); - cout<<"Noise/Pedestals loaded from:"<< filename << "!"<SetBranchAddress("noise" , &NOISE ); - noiseTree->SetBranchAddress("pedestal" , &PEDESTAL ); - - Int_t entries = noiseTree->GetEntries(); - - for(Int_t i=0; iGetEntry(i); - - fNoise[i] = NOISE; - fPedestals[i] = PEDESTAL; - } - cout<<"-----------------------"<(fPedestals, fPixels, fColumns, 2, 20); for(Int_t i=0; 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(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 diff --git a/MABS_run_analyzer/MAPS.h b/MABS_run_analyzer/MAPS.h index 3067d7c..53c8c83 100644 --- a/MABS_run_analyzer/MAPS.h +++ b/MABS_run_analyzer/MAPS.h @@ -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* noiselastframes; std::queue* 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 diff --git a/MABS_run_analyzer/Run.c b/MABS_run_analyzer/Run.c index 0ca21b9..cb0ff42 100644 --- a/MABS_run_analyzer/Run.c +++ b/MABS_run_analyzer/Run.c @@ -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; igetFrame(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; frameifNoiseTree->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; cntfNoiseTree->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; frameifNoiseTree->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; cntfNoiseTree->GetEntries(); cnt++) { + for (Int_t pixeli=0; pixeliNoise->Fill(processed->fNoiseInfo.fNoise[pixeli]); + } +// } oneHistogramClass->Noise->GetQuantiles( 3, noisequantiles, probabilities); oneHistogramClass->avgNoise = noisequantiles[1]; oneHistogramClass->avgNoisePlus = noisequantiles[2] - noisequantiles[1]; diff --git a/MABS_run_analyzer/help.h b/MABS_run_analyzer/help.h index d6c4933..454f517 100644 --- a/MABS_run_analyzer/help.h +++ b/MABS_run_analyzer/help.h @@ -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()