From da841dae851653a0a7c29e5da8d5aca506ab5744 Mon Sep 17 00:00:00 2001 From: Dennis Doering Date: Thu, 24 Sep 2015 12:09:31 +0200 Subject: [PATCH] FSBB reOrder Sicherung --- MABS_run_analyzer/ChargeSpektrumFunctions.c | 8 +- MABS_run_analyzer/HistogramType.h | 1 + MABS_run_analyzer/MAPS.c | 418 +++++++++++++++----- MABS_run_analyzer/MAPS.h | 9 +- MABS_run_analyzer/Run.c | 129 +++++- MABS_run_analyzer/Run.h | 9 +- MABS_run_analyzer/help.h | 2 + 7 files changed, 457 insertions(+), 119 deletions(-) diff --git a/MABS_run_analyzer/ChargeSpektrumFunctions.c b/MABS_run_analyzer/ChargeSpektrumFunctions.c index 1b36ac7..1bfef59 100644 --- a/MABS_run_analyzer/ChargeSpektrumFunctions.c +++ b/MABS_run_analyzer/ChargeSpektrumFunctions.c @@ -78,9 +78,9 @@ Bool_t writeObservableToFile() { if (numberRuns>0) { - system("mkdir "+ runs[0]->savepathresults + " -p"); + system("mkdir "+ runs[0]->savepathresults + ownpath+ " -p"); - TString filename = runs[0]->savepathresults + "/Spectra"; + TString filename = runs[0]->savepathresults + ownpath + "/Spectra"; TString header = ""; for(Int_t runi=0;runiruncode+"\t\t\t"; } - TH1F* plothistogrampointer = runs[0]->plothistogrampointer; + // TH1F* plothistogrampointer = runs[0]->plothistogrampointer; TString runnumberListe=""; TString header=""; cout<<"komme ich hierher3"<Seed->Clone(); - runnumberListe+=Form("%d_",curhistogramclassp->labbook.runnumber); + // runnumberListe+=Form("%d_",curhistogramclassp->labbook.runnumber); // header+=Form("%d\t%s\t\t\t", runs[runi]->labbook.runnumber, curhistogramclone->GetTitle()); } diff --git a/MABS_run_analyzer/HistogramType.h b/MABS_run_analyzer/HistogramType.h index ac60cc0..bf2d7a7 100644 --- a/MABS_run_analyzer/HistogramType.h +++ b/MABS_run_analyzer/HistogramType.h @@ -186,6 +186,7 @@ public: Float_t FitPerform(TH1F* histogrampointer, TString fitFuncType, Bool_t verbose = 0, Double_t* parameters = 0); /** @brief calculates Charge Collection Efficiency if Fe55 run */ Bool_t calculteCCE(); + /** * @brief find the border between the noise and the signal in Sr90 runs * diff --git a/MABS_run_analyzer/MAPS.c b/MABS_run_analyzer/MAPS.c index f9c1582..2465a3d 100644 --- a/MABS_run_analyzer/MAPS.c +++ b/MABS_run_analyzer/MAPS.c @@ -33,7 +33,9 @@ MAPS::MAPS(Run* runp) { { run->labbook.system = Form("USB"); } + cout<<"COLUMNS2"<setSystemSpecificParameters(); + cout<<"COLUMNS3"<Branch("pixelfixedthreshold", &fFrameInfo.pixelfixedthreshold[0],"pixelfixedthreshold[hits]/i", 32000); for(int i=0; i<25; i++) { fHitTree->Branch( Form("p%i",i+1) , &fFrameInfo.p[i][0] , Form("p%i [hits]/F",i+1) , 32000); + fHitTree->Branch( Form("n%i",i+1) , &fFrameInfo.n[i][0] , Form("n%i [hits]/F",i+1) , 32000); } // Noise TTree fNoiseTree = new TTree("noise", "noise"); @@ -78,11 +81,12 @@ Bool_t MAPS::initNewRootFile() { Bool_t MAPS::initOldRootFile() { fSave = false; - if ( !checkConf(fPixelsData) ) { // TODO FileEvNbInConfig - defaultConf(); - } - int MaxFiles = TMath::Ceil((Float_t) FileTotalEvNbInConfig/FileEvNbInConfig); - checkDataFiles(MaxFiles); + // if ( !checkConf(fPixelsData) ) { // TODO FileEvNbInConfig + // defaultConf(); + // } + // int MaxFiles = TMath::Ceil((Float_t) FileTotalEvNbInConfig/FileEvNbInConfig); + // checkDataFiles(MaxFiles); + cout<<"COLUMNS"<IsZombie()) { @@ -103,6 +107,7 @@ Bool_t MAPS::initOldRootFile() { for(int i=0; i<25; i++) { fHitTree->SetBranchAddress( Form("p%i",i+1) , &fFrameInfo.p[i][0]); + fHitTree->SetBranchAddress( Form("n%i",i+1) , &fFrameInfo.n[i][0]); } fNoiseTree = (TTree*) fOutputFile->Get("noise"); if (!fNoiseTree) // got pointer @@ -117,6 +122,15 @@ Bool_t MAPS::initOldRootFile() { cout<<"-----------------------"< pixelchargeincluster[12]) ) { - CHANCE=0; - // cout << "kill cluster: " << Hitlist[hit] << " with ADC: " << pixelchargeincluster[12] << endl; - break; - } - // maybe this is unnecessary, if upper if clause is a >= comparison - else if ( (i!=12) && (pixelchargeincluster[i] == pixelchargeincluster[12]) && i>12 ) { - cout << "WARNING: next pixel value identical to precessor, frame : " << fFrameInfo.frame << ", values: " << pixelchargeincluster[i] << " == " << pixelchargeincluster[12] << endl; - CHANCE=0; //NOTE: potential error source - break; - } - else { - CHANCE=100; - if(i%5==3) { - i+=2; - }; - } + if(fOrderCode=="FSBB") + { + for(Int_t i=0; i<25; i++) // why not over full cluster? (I=0 i<25 TODO + { + if ( (i!=12) && (pixelchargeincluster[i] > pixelchargeincluster[12]) ) { + CHANCE=0; + // cout << "kill cluster: " << Hitlist[hit] << " with ADC: " << pixelchargeincluster[12] << endl; + break; + } + // maybe this is unnecessary, if upper if clause is a >= comparison + else if ( (i!=12) && (pixelchargeincluster[i] == pixelchargeincluster[12]) && i>12 ) { + cout << "WARNING: next pixel value identical to precessor, frame : " << fFrameInfo.frame << ", values: " << pixelchargeincluster[i] << " == " << pixelchargeincluster[12] << endl; + CHANCE=0; //NOTE: potential error source + break; + } + else { + CHANCE=100; + } + } + } + else + { + for(Int_t i=6; i<19; i++) // why not over full cluster? (I=0 i<25 TODO + { + if ( (i!=12) && (pixelchargeincluster[i] > pixelchargeincluster[12]) ) { + CHANCE=0; + // cout << "kill cluster: " << Hitlist[hit] << " with ADC: " << pixelchargeincluster[12] << endl; + break; + } + // maybe this is unnecessary, if upper if clause is a >= comparison + else if ( (i!=12) && (pixelchargeincluster[i] == pixelchargeincluster[12]) && i>12 ) { + cout << "WARNING: next pixel value identical to precessor, frame : " << fFrameInfo.frame << ", values: " << pixelchargeincluster[i] << " == " << pixelchargeincluster[12] << endl; + CHANCE=0; //NOTE: potential error source + break; + } + else { + CHANCE=100; + if(i%5==3) { + i+=2; + }; + } + } } - //Begin: loop evaluate true seeds: if(CHANCE==100) { if(fOrderCode=="FSBB") { - if (B < 2 || B > fColumns-3 || A < 1 || A > fRows-2) - bordercluster = true; + if (B < 1 || B > fColumns-2 || A < 1 || A > fRows-2) + bordercluster = false; else bordercluster = false; } @@ -1630,6 +1666,7 @@ void MAPS::hitana() { for(int clupos=0; clupos<25; clupos++) { fFrameInfo.p [clupos][fHits] = pixelchargeincluster[clupos]; + fFrameInfo.n [clupos][fHits] = noiseincluster[clupos]; } // for(Int_t row=0; row<5; row++) // { @@ -1645,7 +1682,7 @@ void MAPS::hitana() { // if cluster charge > clusternoise * const if(fOrderCode=="FSBB") { - if (1.0*chargesumincluster4 > noisesumincluster4*6.0) + if (1.0*chargesumincluster4 > noisesumincluster4*5.0) fFrameInfo.pixelthreshold[fHits] = Hitlist[hit]; else fFrameInfo.pixelthreshold[fHits] = 0; @@ -1775,18 +1812,64 @@ void MAPS::plotFrame(Int_t FrameNumber) { else { cout <(fCdsmatrix, fPixels, fColumns, 0, 39); + debugStream<>(fCdsmatrix, fPixels, fRows, 0, 39); Float_t cdsmatrixCorrPed[fPixels]; for(Int_t i=0; i(cdsmatrixCorrPed, fPixels, fColumns, 0, 10); + // debugStream<>(cdsmatrixCorrPed, fPixels, fRows, 0, 10); // cout<(fHittedPixel, fPixels, fColumns, 1, 1); - + // cout<<"Hitted pixel discriminator matrix:"<(fHittedPixel, fPixels, fRows, 1, 1); + Double_t cdsmatrixSum; + for(Int_t i=0; iDivide(2,3); gStyle->SetOptFit(1011); @@ -2443,67 +2526,216 @@ void MAPS::reorderMi29a() { } } } - //#################################################################### void MAPS::reorderFSBB() { - - Float_t CDSMATRIX [fPixels]; - Int_t F0MATRIX [fPixels]; - Int_t F1MATRIX [fPixels]; - for(Int_t i=0; i(fCdsmatrix, fPixels, 4*416, 0, 39); + //Divide CDSMATRIX in the channels. First pixel is from A0-0, then A0-1, then A0-2, then A0-3, then A1-0, then A1-1, then A1-2, then A1-3, then second pixel is from A0-0, then... + // for(Int_t iPixelInZeile=0; iPixelInZeile(fCdsmatrix, fPixels, fColumns, 0, 20); + + Float_t tMatrix [fPixels]; + for(Int_t iPixel=0; iPixel(tMatrix, fPixels, fColumns, 0, 20); + // exit(0); +} + +//#################################################################### +void MAPS::reorderFSBBSicherung() { + + Float_t CDSMATRIX [fPixels]; + Int_t F0MATRIX [fPixels]; + Int_t F1MATRIX [fPixels]; + for(Int_t i=0; i(fCdsmatrix, fPixels, 4*416, 0, 39); + //Divide CDSMATRIX in the channels. First pixel is from A0-0, then A0-1, then A0-2, then A0-3, then A1-0, then A1-1, then A1-2, then A1-3, then second pixel is from A0-0, then... + // for(Int_t iPixelInZeile=0; iPixelInZeile(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 f792b86..fe15134 100644 --- a/MABS_run_analyzer/MAPS.h +++ b/MABS_run_analyzer/MAPS.h @@ -279,6 +279,7 @@ private: * Pixels are counted different here - account for this Two lines are merged together CURRENTLY A TODO */ void reorderFSBB(); + void reorderFSBBSicherung(); /** * @brief Sums over a given array * @@ -339,7 +340,13 @@ public: * */ Bool_t initOldRootFile(); - + /** + * @brief Reopens an allready existing ROOT file for plotFrame + * + * Loads a ROOT file + * + */ + Bool_t initOldRootFileFrame(); /** @brief Refill the noise branch every #MAPS::numberofframesfornoise frames or just use the initial initialization * diff --git a/MABS_run_analyzer/Run.c b/MABS_run_analyzer/Run.c index b9beb7a..859c8eb 100644 --- a/MABS_run_analyzer/Run.c +++ b/MABS_run_analyzer/Run.c @@ -157,10 +157,11 @@ Run::Run(Int_t runnumber, Int_t loopi) // fixed threshold cut histogramfixedthreshold = new HistogramType(" fixed Threshold", &cursystemparam, &cursensorinfo, humanreadablestr, labbook.runnumber, rootcolors[plotStyle], rootlinestyle[plotStyle] ); HistogramClassVector.push_back(histogramfixedthreshold); - // dennis megacut - dennismegacut = new HistogramType(" Dennis Mega Cut", &cursystemparam, &cursensorinfo, humanreadablestr, labbook.runnumber, rootcolors[plotStyle], rootlinestyle[plotStyle] ); - HistogramClassVector.push_back(dennismegacut); - + // FSBB + histogramFSBB = new HistogramType(" FSBB", &cursystemparam, &cursensorinfo, humanreadablestr, labbook.runnumber, rootcolors[plotStyle+plotStyle*1], rootlinestyle[plotStyle] ); + HistogramClassVector.push_back(histogramFSBB); + histogramFSBB2 = new HistogramType(" FSBB2", &cursystemparam, &cursensorinfo, humanreadablestr, labbook.runnumber, rootcolors[plotStyle+plotStyle*2], rootlinestyle[plotStyle] ); + HistogramClassVector.push_back(histogramFSBB2); debugDBreadout(); } else @@ -236,7 +237,7 @@ void Run::setSensorInSystemParam() sensorinfostruct sensorinfoMi34USB( 8, 64 ); sensorinfostruct sensorinfoMi34PXI( 16, /* rows */ 64 /* columns */ ); sensorinfostruct sensorinfoPegasus( 8, 56 ); - sensorinfostruct sensorinfoFSBB( 4, 416 ); + sensorinfostruct sensorinfoFSBB( 416, 4 ); if (labbook.system.EqualTo("USB") && labbook.chipGen.EqualTo("Mi34") ) cursensorinfo=sensorinfoMi34USB; @@ -350,7 +351,7 @@ Bool_t Run::analyzeRun(Bool_t force) processed->InitialDynNoise(); int start = 0; int nframes = processed->GetNumberFrames(); - // for(int i=0; i<1000;i++) // TODO remove 100000 run 342272 + // for(int i=0; i<1000000;i++) // TODO remove 100000 run 342272 for(int i=0; iinitOldRootFile()) return 1; + cout<<"BLABLABLA2"<GetNumberFrames(); // cout << colorwhite << "plotPixSignal():"<< flush << endlr; // processed->plotPixSignal(0,10000000,351); @@ -403,7 +406,7 @@ Bool_t Run::analyzeRun(Bool_t force) histogramfixedthreshold->integrateSr90Spectra(histogramfixedthreshold->Seed, frames_found, 0); rescaleHistogramClasses(); cout << colorwhite << "updateDatabase():" << endlr; - updateDatabase(); + // updateDatabase(); cout << colorwhite << "delete MAPS class:" << endlr; delete processed; return 0; @@ -449,7 +452,7 @@ Bool_t Run::analyzeFrame(Int_t frame) if (!error) { processed = new MAPS(this); - processed->initNewRootFile(); + processed->initOldRootFileFrame(); int entries = processed->GetNumberFrames(); if (frame < entries) { @@ -713,13 +716,16 @@ string Run::to_str_w_prec(const Float_t a_value, int precision = 3) } Bool_t Run::binNoise(HistogramType* oneHistogramClass) -{ +{ + for (Int_t lauf=0; lauf<8; lauf++) { 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++) { + // for (Int_t cnt=0; cntfNoiseTree->GetEntries(); cnt++) { + + for (Int_t cnt=208*lauf; cnt<208*(lauf+1); cnt++) { processed->fNoiseTree->GetEntry(cnt); oneHistogramClass->Noise->Fill(noise); } @@ -727,6 +733,8 @@ Bool_t Run::binNoise(HistogramType* oneHistogramClass) oneHistogramClass->avgNoise = noisequantiles[1]; oneHistogramClass->avgNoisePlus = noisequantiles[2] - noisequantiles[1]; oneHistogramClass->avgNoiseMinus = noisequantiles[1] - noisequantiles[0]; + cout<<"Channel: "<avgNoise<fHitTree->GetEntries(); framei++) // loop over all frames { processed->fHitTree->GetEntry(framei); // account only frames with less then 10 hits - if (processed->fFrameInfo.hits<(unsigned int)10) + // if (processed->fFrameInfo.hits>=(unsigned int)3) + // cout<<"Warning, frame "<fFrameInfo.hits<<" hits"<fFrameInfo.hits==(unsigned int)1) { for(Int_t hiti=0; (unsigned int)hitifFrameInfo.hits;hiti++) { @@ -815,16 +829,45 @@ Bool_t Run::binSeedSumVeto() if (TMath::Abs(notSeedSum) < cursystemparam.vetothreshold && (labbook.source.Contains("Fe")||labbook.source.Contains("Cd"))) histogramfixedthreshold->Veto->Fill(processed->fFrameInfo.p[12][hiti]); // histogram with the single pixel } - - if (processed->fFrameInfo.pixel[hiti]>800) + // FSBB CODE START + int index[25]; + Double_t pixelchargeincluster[25]={ 0 }; + Double_t pixelnoiseincluster[25]={ 0 }; + Double_t pixelchargesum=0; + Double_t pixelnoisesum=0; + for(int clus=0;clus<25;clus++) + { + pixelchargeincluster[clus]=processed->fFrameInfo.p[clus][hiti]; + pixelnoiseincluster[clus]=processed->fFrameInfo.n[clus][hiti]; + } + TMath::Sort(25,pixelchargeincluster,index,1); + for(int clus=0;clus<20;clus++) + { + pixelchargesum+=pixelchargeincluster[index[clus]]; + pixelnoisesum+=TMath::Power(pixelnoiseincluster[index[clus]],2); + } + pixelnoisesum=TMath::Sqrt(pixelnoisesum); + + if (pixelchargesum>5.0*pixelnoisesum&& fPixelFakeHits[processed->fFrameInfo.pixel[hiti]+1]>0) { - dennismegacut->numberofhits++; - - dennismegacut->Seed->Fill(processed->fFrameInfo.p[12][hiti]); - dennismegacut->Sum->Fill(pixelSum); + histogramFSBB->numberofhits++; + // cout<fFrameInfo.n[12][hiti]<Seed->Fill(processed->fFrameInfo.p[12][hiti]); + histogramFSBB->Sum->Fill(pixelSum); + if (TMath::Abs(notSeedSum) < cursystemparam.vetothreshold && (labbook.source.Contains("Fe")||labbook.source.Contains("Cd"))) + histogramFSBB->Veto->Fill(processed->fFrameInfo.p[12][hiti]); // histogram with the single pixel + } + if (pixelchargesum>5.0*pixelnoisesum) + { + histogramFSBB2->numberofhits++; + // cout<fFrameInfo.n[12][hiti]<Seed->Fill(processed->fFrameInfo.p[12][hiti]); + histogramFSBB2->Sum->Fill(pixelSum); if (TMath::Abs(notSeedSum) < cursystemparam.vetothreshold && (labbook.source.Contains("Fe")||labbook.source.Contains("Cd"))) - dennismegacut->Veto->Fill(processed->fFrameInfo.p[12][hiti]); // histogram with the single pixel + histogramFSBB->Veto->Fill(processed->fFrameInfo.p[12][hiti]); // histogram with the single pixel } + + //FSBB CODE END } } } @@ -1642,5 +1685,51 @@ void Run::initRootParameters() rootcolors = new Int_t[13]{1, 2, 4, 6, 8, 13, 46, 28, 32, 33, 12, 20, 40}; rootlinestyle = new Int_t[13]{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; } - +void Run::getPixelWithFakehits() +{ + Int_t pixels=cursensorinfo.columns*cursensorinfo.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; + Float_t fakehitrate=0.0001; + Float_t sourceIntensity=1;//Adjust it depending on the intensity of the used source + if(labbook.source.Contains("Fe")) + { + sourceIntensity=30; + } + else if(labbook.source.Contains("Sr")) + { + sourceIntensity=2; + } + else if(labbook.source.Contains("Cd")) + { + sourceIntensity=2; + } + for(int ipixel=0;ipixelGetBinContent(ipixel)>fakehitrate*sourceIntensity*labbook.frames_foundDB)//show only pixels with a fake hit rate above 1e-5 + { + fcountPixelFakeHits++; + fPixelFakeHits[ipixel]=0;//pixel is a fake hit pixel + + cout<GetBinContent(ipixel)<GetBinContent(ipixel)<<"\t"; + fPixelFakeHits[ipixel]=1;//pixel is NOT a fake hit pixel + } + + } + cout<<"Number of masked pixel due to a fake hit rate above "<