From: Dennis Doering Date: Thu, 17 Sep 2015 09:57:22 +0000 (+0200) Subject: getPixelWithFakehits X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=735e7fd941a2861612cb3e128bc18e8b03083b63;p=radhard.git getPixelWithFakehits --- diff --git a/MABS_run_analyzer/MAPS.c b/MABS_run_analyzer/MAPS.c index 3490fde..8d3e6d6 100644 --- a/MABS_run_analyzer/MAPS.c +++ b/MABS_run_analyzer/MAPS.c @@ -77,36 +77,45 @@ Bool_t MAPS::initNewRootFile() { Bool_t MAPS::initOldRootFile() { fSave = false; - fOutputFile = new TFile(fRootFile,"READ"); - if (fOutputFile->IsZombie()) - { - cout << colorred << "Error opening old ROOT file! -> Zombie"<< endlr; - return 1; - } - fHitTree = (TTree*) fOutputFile->Get("hit"); - if (!fHitTree) // got pointer - { - cout<< colorred << "Error finding hit TTree in old ROOT file!"<< endlr; - return 1; - } - fHitTree->SetBranchAddress("frame" , &fFrameInfo.frame ); - fHitTree->SetBranchAddress("hits" , &fFrameInfo.hits ); - fHitTree->SetBranchAddress ("pixel", &fFrameInfo.pixel[0]); - fHitTree->SetBranchAddress ("pixelthreshold", &fFrameInfo.pixelthreshold[0]); - for(int i=0; i<25; i++) { - fHitTree->SetBranchAddress( Form("p%i",i+1) , &fFrameInfo.p[i][0]); + if ( !checkConf(fPixelsData) ) { // TODO FileEvNbInConfig + defaultConf(); } - fNoiseTree = (TTree*) fOutputFile->Get("noise"); - if (!fNoiseTree) // got pointer + //----------------------------------------------- + //Check and open Data Files + int MaxFiles = TMath::Ceil((Float_t) FileTotalEvNbInConfig/FileEvNbInConfig); + if( checkDataFiles(MaxFiles) ) { - cout<< colorred << "Error finding noise TTree in old ROOT file!"<< endlr; - return 1; - } - fDynNoiseTree = fNoiseTree; - initHistograms(); - cout<<"-----------------------"<IsZombie()) + { + cout << colorred << "Error opening old ROOT file! -> Zombie"<< endlr; + return 1; + } + fHitTree = (TTree*) fOutputFile->Get("hit"); + if (!fHitTree) // got pointer + { + cout<< colorred << "Error finding hit TTree in old ROOT file!"<< endlr; + return 1; + } + fHitTree->SetBranchAddress("frame" , &fFrameInfo.frame ); + fHitTree->SetBranchAddress("hits" , &fFrameInfo.hits ); + fHitTree->SetBranchAddress ("pixel", &fFrameInfo.pixel[0]); + fHitTree->SetBranchAddress ("pixelthreshold", &fFrameInfo.pixelthreshold[0]); + for(int i=0; i<25; i++) { + fHitTree->SetBranchAddress( Form("p%i",i+1) , &fFrameInfo.p[i][0]); + } + fNoiseTree = (TTree*) fOutputFile->Get("noise"); + if (!fNoiseTree) // got pointer + { + cout<< colorred << "Error finding noise TTree in old ROOT file!"<< endlr; + return 1; + } + fDynNoiseTree = fNoiseTree; + initHistograms(); + cout<<"-----------------------"<(fPedestals , fPixels, 1664, 1, 14); + // cout<<"MedianAll"< 5 * sigma // sum up over all frames every CDS value, pixelwise @@ -964,7 +1008,7 @@ bool MAPS::InitialDynNoise(Int_t startframe, Int_t frames) { 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); @@ -1256,7 +1300,19 @@ void MAPS::hitana() { cdsmatrixCorrPed[i]=(float)(1.*fCdsmatrix[i]-fPedestals[i]); fHittedPixel[i] = 0; // if( (float)(1.*fCdsmatrix[i]-fPedestals[i]) > (50.) ) - if( (float)(1.*fCdsmatrix[i]-fPedestals[i]) > (5.*fNoise[i]) ) + if(fOrderCode=="FSBB") + { + if( (float)(1.*fCdsmatrix[i]-fPedestals[i]) > (5.*fNoise[i]) ) + { + HITNR++; + HITS.Set(HITNR); + HITS.AddAt(i,(HITNR-1)); + if(fSave) { + hint2->Fill(i%fColumns+0.1, (int)(i/fColumns)+0.1); // counts up in 2dimensional pixel matrix + } + } + } + else if( (float)(1.*fCdsmatrix[i]-fPedestals[i]) > (5.*fNoise[i]) ) { HITNR++; HITS.Set(HITNR); @@ -1600,7 +1656,8 @@ void MAPS::hitana() { //Begin: loop evaluate true seeds: if(CHANCE==100) { - //cout<<"CLUSTER ACCEPTED"<(fCdsmatrix, fPixels, fColumns, 1, 100); + // cout<<"CLUSTER ACCEPTED"< fColumns-3 || A < 1 || A > fRows-2) @@ -1642,7 +1699,8 @@ void MAPS::hitana() { else { fHittedPixel[Hitlist[hit]] = 2; - + // if(Hitlist[hit]<415&&Hitlist[hit]>830) + // cout<(fCdsmatrix, fPixels, fColumns, 0, 39); + debugStream<>(fCdsmatrix, fPixels, fColumns, 0, 39); + Float_t cdsmatrixCorrPed[fPixels]; for(Int_t i=0; i(cdsmatrixCorrPed, fPixels, fColumns, 0, 10); + debugStream<>(cdsmatrixCorrPed, fPixels, fColumns, 0, 10); // cout<(fHittedPixel, fPixels, fColumns, 1, 1); + // debugStream<>(fHittedPixel, fPixels, fColumns, 1, 1); cout << colorred <<"Accepted hit cluster:"<0) // TODO better warning criteria + if(TMath::Abs(CommonModeInRow)>10000) // TODO better warning criteria { warning = true; } @@ -2785,6 +2844,27 @@ void MAPS::reorderFSBB() { { a0[iOutChannel][column ] -= CommonModeInRow; } + CommonModeInRow = 0; + warning=false; + CommonModeInRow = TMath::Median(subColumns, a1[iOutChannel]); // Don't use mean, consider hitted pixel ! + if (CommonModeInRow < 0) + plus++; + else + minus++; + + if(TMath::Abs(CommonModeInRow)>10000) // TODO better warning criteria + { + warning = true; + } + if(warning) { cout<<"\rFrame: "< Common Mode suspiciously high! "<(fCdsmatrix, fPixels, fColumns, 0, 20); + debugStream<>(a1[iOutChannel], subColumns, subColumns, 1, 20); + } + + for(int column=0; column(fCdsmatrix, fPixels, fColumns, 0, 20); + // debugStream<>(fCdsmatrix, fPixels, fColumns, 0, 20); + Float_t tMatrix [fPixels]; for(Int_t iPixel=0; iPixel(tMatrix, fPixels, fColumns, 0, 20); //exit(0); } //#################################################################### //#################################################################### -void MAPS::reorderFSBB_B() { - // War: A0-0, A1-0, A0-1, A1-1 - //0,1,...,415 - //416,..., - //Ist Blödsinn, deshalb wird zuerst A0 ausgelesen, und dann A1 +void MAPS::reorderFSBB() { + Float_t CDSMATRIX [fPixels]; Int_t F0MATRIX [fPixels]; Int_t F1MATRIX [fPixels]; for(Int_t i=0; i0) // TODO better warning criteria + if(TMath::Abs(CommonModeInRow)>10000) // TODO better warning criteria { warning = true; } @@ -2911,10 +2991,31 @@ void MAPS::reorderFSBB_B() { { a0[iOutChannel][column ] -= CommonModeInRow; } + CommonModeInRow = 0; + warning=false; + CommonModeInRow = TMath::Median(subColumns, a1[iOutChannel]); // Don't use mean, consider hitted pixel ! + if (CommonModeInRow < 0) + plus++; + else + minus++; + + if(TMath::Abs(CommonModeInRow)>10000) // TODO better warning criteria + { + warning = true; + } + if(warning) { cout<<"\rFrame: "< Common Mode suspiciously high! "<(fCdsmatrix, fPixels, fColumns, 0, 20); + debugStream<>(a1[iOutChannel], subColumns, subColumns, 1, 20); + } + + for(int column=0; column(fCdsmatrix, fPixels, fColumns, 0, 20); + // debugStream<>(fCdsmatrix, fPixels, fColumns, 0, 20); + Float_t tMatrix [fPixels]; for(Int_t iPixel=0; iPixel(tMatrix, fPixels, fColumns, 0, 20); //exit(0); } diff --git a/MABS_run_analyzer/MAPS.h b/MABS_run_analyzer/MAPS.h index 05032f4..ecdc529 100644 --- a/MABS_run_analyzer/MAPS.h +++ b/MABS_run_analyzer/MAPS.h @@ -83,9 +83,7 @@ private: UInt_t fFrameNumber; /**< enum value 1 */ /// true if all data files OK bool fOk; - /// if set to true, a root file for the analyzed run will be created, set and passed initMapsRun() to in the constructor - bool fSave = true; - /// if set to true, the frame retrieved with @c getframe() is OK + /// if set to true, the frame retrieved with @c getframe() is OK bool fFrameOk; /// if set to true, the file from where the noise is extracted is OK bool fNoiseOk; @@ -322,7 +320,8 @@ public: /// is set to true if somewhere a critical error occurs Bool_t error = false; - + /// if set to true, a root file for the analyzed run will be created, set and passed initMapsRun() to in the constructor + bool fSave = true; /// is set to true if somewhere a critical error occurs Bool_t used_default_config = false; diff --git a/MABS_run_analyzer/Run.c b/MABS_run_analyzer/Run.c index 9bd22c8..3c1b8f1 100644 --- a/MABS_run_analyzer/Run.c +++ b/MABS_run_analyzer/Run.c @@ -269,8 +269,8 @@ Bool_t Run::analyzeRun(Bool_t force) processed->InitialDynNoise(); int start = 0; int nframes = processed->GetNumberFrames(); - for(int i=0; i<1000000;i++) // TODO remove 100000 run 342272 - // for(int i=0; igetFrame(i); @@ -443,25 +443,28 @@ Bool_t Run::analyzeFrame(Int_t frame) if (!error) { processed = new MAPS(this); - processed->initNewRootFile(); - int entries = processed->GetNumberFrames(); - if (frame < entries) - { + + processed->initOldRootFile(); + //processed->plotPixSignal (0, 100000, 350); + + int entries = processed->GetNumberFrames(); + // if (frame < entries) + // { if (dynamicalNoise) processed->InitialDynNoise(100); processed->getFrame(frame); // processed->filterCommonMode(); processed->hitana(); processed->plotFrame(frame); - delete processed; - return 0; - } - else - { - cout << "\033[1;33mFrame number too big, max frame: " << entries << "\033[0m" << endl; - } + // delete processed; + // return 0; + // } + // else + // { + // cout << "\033[1;33mFrame number too big, max frame: " << entries << "\033[0m" << endl; + // } } - delete processed; + // delete processed; return 1; } @@ -755,11 +758,21 @@ Bool_t Run::binNoise() 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}; histogram.Noise->Reset(); - processed->fNoiseTree->SetBranchAddress("noise", &noise, &noiseBranch); - for (Int_t cnt=0; cntfNoiseTree->GetEntries(); cnt++) { - processed->fNoiseTree->GetEntry(cnt); - histogram.Noise->Fill(noise); - } + processed->fNoiseTree->SetBranchAddress("noise", &noise, &noiseBranch); + for (Int_t cnt=0; cntfNoiseTree->GetEntries(); cnt++) { + uint pixel_column_x = cnt%sensorinfocur.columns; // column of seed + uint pixel_row_y = cnt/sensorinfocur.columns; // row of seed + if (false) { + cout << "submatrix_x_start: " << submatrix_x_start << ", submatrix_x_end: " << submatrix_x_end << endl; + cout << "submatrix_y_start: " << submatrix_y_start << ", submatrix_y_end: " << submatrix_y_end << endl; + cout << "pixel_column_x: " << pixel_column_x << ", pixel_row_y: " << pixel_row_y << endl; + } + if (pixel_column_x >= submatrix_x_start && pixel_column_x < submatrix_x_end && pixel_row_y >= submatrix_y_start && pixel_row_y < submatrix_y_end) // Diode sitzt oben im SeedPixel, da nach PitchY angeordnet + { + processed->fNoiseTree->GetEntry(cnt); + histogram.Noise->Fill(noise); + } + } histogram.Noise->GetQuantiles( 3, noisequantiles, probabilities); histogram.avgNoise = noisequantiles[1]; histogram.avgNoisePlus = noisequantiles[2] - noisequantiles[1]; @@ -783,6 +796,8 @@ Bool_t Run::binSeedSumVeto() /// collected charge in cluster Float_t pixelSum = 0; Float_t notSeedSum = 0; + getPixelWithFakehits(); + // for (Int_t framei=0; framei<10000; framei++) // loop over all frames for (Int_t framei=0; frameifHitTree->GetEntries(); framei++) // loop over all frames { @@ -820,7 +835,7 @@ Bool_t Run::binSeedSumVeto() notSeedSum += processed->fFrameInfo.p[clusteri][hiti]; } TMath::Sort(processed->clustersize*processed->clustersize,clusterArray,index,1); - for (Int_t clusteri=0; clusteri<4; clusteri++) + for (Int_t clusteri=0; clusteri<21; clusteri++) { pixelSum += clusterArray[index[clusteri]]; @@ -843,6 +858,22 @@ Bool_t Run::binSeedSumVeto() if (processed->fFrameInfo.pixelthreshold[hiti]>0) { + Bool_t pixelfound=false; + for(int col=0;colfFrameInfo.pixel[hiti]) + { + pixelfound=true; + } + } + if(pixelfound==true) + { + continue;//If pixel is a fake hit pixel with a rate >1e-5, do not count it + } + // if(pixelfound==false) + // { + // cout<<"Pixel"<fFrameInfo.pixel[hiti]<<" NOT found in array"<Fill(processed->fFrameInfo.p[12][hiti]); @@ -868,20 +899,20 @@ Bool_t Run::binSeedSumVeto() if (TMath::Abs(notSeedSum) < systemparamcur.vetothreshold && (labbook.source.Contains("Fe")||labbook.source.Contains("Cd"))) histogramthreshold.Veto->Fill(processed->fFrameInfo.p[12][hiti]); // histogram with the single pixel - if (TMath::Abs(pixelSum) > 200 && (labbook.source.Contains("Fe"))) - { - histogramthreshold.VetoSum->Fill(processed->fFrameInfo.p[12][hiti]); // histogram with the single pixel + //if (TMath::Abs(pixelSum) > 200 && (labbook.source.Contains("Fe"))) + //{ + // histoPixel->Fill(processed->fFrameInfo.pixel[hiti]); // histogram with the single pixel + //histogramthreshold.VetoSum->Fill(pixelSum); // cout<<"Hitnummer"<fFrameInfo.p[col][hiti]<<","; - // cout<SetBatch(kTRUE); if (labbook.source.Contains("Fe")||labbook.source.Contains("Cd")) histogram.posVeto=FitPerform(histogram.Veto, "gaus", true); @@ -2004,5 +2035,43 @@ void Run::initRootParameters() rootlinestyle = new Int_t[13]{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; } - +void Run::getPixelWithFakehits() +{ + Int_t pixels=sensorinfocur.columns*sensorinfocur.rows; + histoPixel = new TH1F("pixel histo","pixel histo",pixels,0,pixels); + for (Int_t framei=0; frameifHitTree->GetEntries(); framei++) // loop over all frames + { + processed->fHitTree->GetEntry(framei); + for(Int_t hiti=0; (unsigned int)hitifFrameInfo.hits;hiti++) + { + histoPixel->Fill(processed->fFrameInfo.pixel[hiti]); + } + } + fPixelFakeHits = new Float_t [pixels](); + fcountPixelFakeHits=0; + for(int col=0;colGetBinContent(col)>fakehitrate*sourceIntensity*labbook.frames_foundDB)//show only pixels with a fake hit rate above 1e-5 + { + fPixelFakeHits[fcountPixelFakeHits]=col; + fcountPixelFakeHits++; + cout<GetBinContent(col)<