From 2961f0b048ec1f4043807aa23a5a2f50d2d4b2de Mon Sep 17 00:00:00 2001 From: Samir Amar-Youcef Date: Thu, 14 Nov 2013 13:32:30 +0100 Subject: [PATCH] Added: dynamic noise calculation in MAPS --- newCOMBI/MAPS.C | 232 +++++++++++++++++++++++++++++++++++++++++++++++- newCOMBI/MAPS.h | 13 ++- newCOMBI/run.C | 7 +- 3 files changed, 246 insertions(+), 6 deletions(-) diff --git a/newCOMBI/MAPS.C b/newCOMBI/MAPS.C index c95280c..bc53b67 100755 --- a/newCOMBI/MAPS.C +++ b/newCOMBI/MAPS.C @@ -87,10 +87,12 @@ MAPS::~MAPS(void) { fHitTree->Write("",TObject::kOverwrite); fNoiseTree->Write("",TObject::kOverwrite); + fDynNoiseTree->Write("",TObject::kOverwrite); hint1->Write("",TObject::kOverwrite); hint2->Write("",TObject::kOverwrite); + fOutputFile->Save(); fOutputFile->Close(); @@ -122,6 +124,8 @@ MAPS::~MAPS(void) { delete[] fCdsmatrix; delete[] fNoise; delete[] fPedestals; + delete[] fDynFrameArr; + delete[] fDynCounter; cout<<"================================================================="<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"); + fDynNoiseTree = new TTree("dynnoise", "dynnoise"); //----------------------------------------------- hint1 = new TH2F("Hitmulit", "Hit multiplicity", fColumns, 0, fColumns, fRows, 0, fRows); hint2 = new TH2F("Pixmulit", "Pix multiplicity", fColumns, 0, fColumns, fRows, 0, fRows); @@ -554,7 +561,6 @@ bool MAPS::getNoise(Int_t Start, Int_t Frames) { for(Int_t j=0; j5*PEDESTAL) continue; //throw all frames with a signal >5pedestal away, because of postulated signal charge NOISE+=TMath::Power(ARR[j*fPixels+i]-PEDESTAL,2); } @@ -581,6 +587,193 @@ bool MAPS::getNoise(Int_t Start, Int_t Frames) { //#################################################################### +bool MAPS::getDynNoise(Int_t Frames) { +//Dynamic Noise + Pedestals calculation + + if( fNoiseDyn ) + { + delete[] fDynFrameArr; + delete[] fDynCounter; + + fDynFrameArr = new Float_t[Frames*fPixels]; + fDynCounter = new Int_t[fPixels]; + } + else + { + fDynNoiseTree->Branch("frame" , &fFrameNumber , "frame/i" , 32000); + fDynNoiseTree->Branch("noise" , &fNoiseMean , "noise/F" , 32000); + fDynNoiseTree->Branch("pedestal" , &fPedestalsMean , "pedestal/F" , 32000); + } + + if(fOk) + { +//Check amount of Frames + if(Frames<50) + { + cout<<"Too few Frames! Change Frames from "<= 1) { printf("%6.2f TB ", (Float_t)(End/(TMath::Power(2,40))) ); } + else if (End/(TMath::Power(2,30)) >= 1) { printf("%6.2f GB ", (Float_t)(End/(TMath::Power(2,30))) ); } + else if (End/(TMath::Power(2,20)) >= 1) { printf("%6.2f MB ", (Float_t)(End/(TMath::Power(2,20))) ); } + else if (End/(TMath::Power(2,10)) >= 1) { printf("%6.2f kB ", (Float_t)(End/(TMath::Power(2,10))) ); } + else { printf("%6.2f B ", (Float_t)(End)); } + cout<<"for dynamic noise calculation! "< fEventsSum ) { Frames = fEventsSum; printf("Changed 'Number Frames' to: %u\n", Frames ); } +// Get fPixels and allocate array + Float_t PEDESTAL; + Float_t NOISE; +// Int_t PIXEL=0; + + if(!fNoiseOk) {getNoise(0,Frames);} + + { + int i=0; + + while(!STOP) + { + getFrame(i); + hitana(); + + STOP = true; + + for(Int_t j=0; jFill(); + + fFrameNumber = 0; + fNoiseMean = TMath::Mean((const int)fPixels, fNoise); + fPedestalsMean = TMath::Mean((const int)fPixels, fPedestals); + + fDynNoiseTree->Fill(); + } + return true; + } + else + { + return false; + } +}; + +//#################################################################### + +bool MAPS::regetDynNoise() { + + if( fNoiseDyn ) + { + Float_t PEDESTAL; + Float_t NOISE; + Int_t Frames = fNoiseDyn; + + for(Int_t i=0; iFill(); + } + + return true; + } + else + { + return false; + } +} + +//#################################################################### + bool MAPS::loadNoise( TString InDir, Int_t RunNumber, Int_t Matrix) { TString FILENAME = InDir+Form("%i/%i_%i.root",RunNumber,RunNumber,Matrix); @@ -669,6 +862,8 @@ void MAPS::hitana() { for(Int_t i=0; i (5.*fNoise[i]) ) { HITNR++; @@ -742,6 +937,26 @@ void MAPS::hitana() { fHits++; if(fSave) { hint1->Fill( Hitlist[hit]%fColumns, (int)(Hitlist[hit]/fColumns) ); } + + for(Int_t row=0;row<5;row++) + { + for(Int_t column=0;column<5;column++) + { + if ( (row==0) && (A<2) ) { } + else if ( (row==1) && (A<1) ) { } + else if ( (row==3) && (A>= (fRows-1)) ) { } + else if ( (row==4) && (A>= (fRows-2)) ) { } + else + { + if ( (column==0) && (B<2) ) { } + else if ( (column==1) && (B==0) ) { } + else if ( (column==3) && (B==fColumns-1)) { } + else if ( (column==4) && (B>fColumns-3)) { } + else { fHittedPixel[Hitlist[hit]+(row-2)*fColumns+(column-2)] = 1; } + } + } + } + fHittedPixel[Hitlist[hit]] = 2; } } //End: loop evaluate true seeds: @@ -760,6 +975,21 @@ void MAPS::hitana() { } } + if( fNoiseDyn ) + { + for(Int_t j=0; jgetNoise (0,1000); +// a->getNoise (0,1000); + a->getDynNoise (1000); // Dynamic Noise Calculation } int start = 0; @@ -65,6 +66,7 @@ for(Int_t runLauf=0;runLauf<1;runLauf++) a->getFrame(i); a->filterCommonMode(); a->hitana(); + if(i%100==0) { a->regetDynNoise(); } // Dynamic Noise Calculation progress = (Int_t)(((i-start)*100)/(entries-1)*10); if(progress!=progress_tmp) { print_progress( (((i-start)*100.)/(entries-1)) ); progress_tmp=progress;} @@ -77,6 +79,5 @@ for(Int_t runLauf=0;runLauf<1;runLauf++) delete a; //------------------------------------------------------- - cout<