From 819864b3480c4420ca7b6ddac9cd79810d60699e Mon Sep 17 00:00:00 2001 From: Benjamin Linnik Date: Fri, 12 Aug 2016 19:16:57 +0200 Subject: [PATCH] had a bug, now working, but I can do better --- MABS_run_analyzer/ChargeSpektrum.c | 1 + MABS_run_analyzer/HistogramType.c | 8 ++-- MABS_run_analyzer/HistogramType.h | 2 + MABS_run_analyzer/MAPS.c | 39 +++++++++++++------ MABS_run_analyzer/Run.c | 60 +++++++++++++----------------- MABS_run_analyzer/help.h | 7 ++-- 6 files changed, 66 insertions(+), 51 deletions(-) diff --git a/MABS_run_analyzer/ChargeSpektrum.c b/MABS_run_analyzer/ChargeSpektrum.c index a4983e5..103f58e 100644 --- a/MABS_run_analyzer/ChargeSpektrum.c +++ b/MABS_run_analyzer/ChargeSpektrum.c @@ -103,6 +103,7 @@ void ChargeSpektrum(TString runnumber = "") // compareHistogramVector.push_back(runs[runi]->histogramwoRTS->normalized->Seed); runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS, runs[runi]->histogramwoRTS->pixeltimefired, "", 0); runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS, runs[runi]->histogramwoRTS->pixeltimefiredsorted, "", 0, true, true); + runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS, runs[runi]->histogramwoRTS->LeakageCurrent, "", 0); // runs[runi]->plot1DHistogram(runs[runi]->histogram, runs[runi]->histogram->pixeltimefired, "gaus", 1); // compareHistogramVector2.push_back(runs[runi]->histogramthreshold->normalized->Seed); //compareHistogramClassVector.push_back(runs[runi]->histogram); diff --git a/MABS_run_analyzer/HistogramType.c b/MABS_run_analyzer/HistogramType.c index 97af3b9..9c3d5bd 100644 --- a/MABS_run_analyzer/HistogramType.c +++ b/MABS_run_analyzer/HistogramType.c @@ -45,13 +45,15 @@ void HistogramType::initHistograms(Int_t gotcolor, Int_t gotstyle) { initHistogram(Sum, "Sum" + histogramdescription, color, style); initHistogram(Veto, "Veto" + histogramdescription, color, style); initHistogram(Noise, "Noise" + histogramdescription, color, style); + initHistogram(NoiseEnd, "Noise at end" + histogramdescription, 16, style); 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, cursensorinfo->columns*cursensorinfo->rows, "Pixel index", "Average CDS"); + initHistogramCustom(pixeltimefired, "Pixel fired", color, style, 0, cursensorinfo->columns*cursensorinfo->rows-1, cursensorinfo->columns*cursensorinfo->rows, "Pixel index", "Counts"); + initHistogramCustom(pixeltimefiredsorted, "Fire counter", color, style, 0, labbook->frames_foundDB/250-1, labbook->frames_foundDB/250, "times fired", "Counts"); + initHistogramCustom(LeakageCurrent, "Leakage current per pixel", 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); + NoiseEnd->SetBins(cursystempar->nbinsnoise, 0, cursystempar->maxbinnoise); } void HistogramType::initHistogram(TH1F* &histogrampointer, TString prefix, Int_t color, Int_t style) { diff --git a/MABS_run_analyzer/HistogramType.h b/MABS_run_analyzer/HistogramType.h index 5fe99f7..47cf7b7 100644 --- a/MABS_run_analyzer/HistogramType.h +++ b/MABS_run_analyzer/HistogramType.h @@ -116,6 +116,8 @@ public: TH1F* Veto = 0; /// Noise histogram TH1F* Noise = 0; + /// Noise histogram at the end of a run + TH1F* NoiseEnd = 0; /// histogram with cluster data, rotated if staggered TH2F* histAvgCluster = 0; /// Percentage of charge gathered by seed pixel (Seed to Sum ratio) diff --git a/MABS_run_analyzer/MAPS.c b/MABS_run_analyzer/MAPS.c index 7ae4452..bad44f6 100644 --- a/MABS_run_analyzer/MAPS.c +++ b/MABS_run_analyzer/MAPS.c @@ -64,10 +64,10 @@ Bool_t MAPS::initNewRootFile() { fHitTree->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"); + fNoiseTree = new TTree("noisefolder", "noisefolder"); fNoiseTree->Branch("frame" , &fFrameInfo.frame , "frame/i" , 32000); - fNoiseTree->Branch("noise" , &(fNoiseInfo.fNoise) , "noise/F" , 32000); - fNoiseTree->Branch("pedestal" , &(fNoiseInfo.fPedestals) , "pedestal/F" , 32000); + fNoiseTree->Branch("noise" , &fNoiseInfo.fNoise[0] , "noise[100000]/F" , 32000); + fNoiseTree->Branch("pedestal" , &fNoiseInfo.fPedestals[0] , "pedestal[100000]/F" , 32000); initHistograms(); cout<<"-----------------------"<SetBranchAddress( Form("p%i",i+1) , &fFrameInfo.p[i][0]); } // Noise TTree - fNoiseTree = (TTree*) fOutputFile->Get("noise"); + fNoiseTree = (TTree*) fOutputFile->Get("noisefolder"); if (!fNoiseTree) // got pointer { cout<< colorred << "Error finding noise TTree in old ROOT file!"<< endlr; return 1; } fNoiseTree->SetBranchAddress("frame" , &fFrameInfo.frame); - fNoiseTree->SetBranchAddress("noise" , &(fNoiseInfo.fNoise)); - fNoiseTree->SetBranchAddress("pedestal" , &(fNoiseInfo.fPedestals)); + fNoiseTree->SetBranchAddress("noise" , &fNoiseInfo.fNoise[0]); + fNoiseTree->SetBranchAddress("pedestal" , &fNoiseInfo.fPedestals[0]); + + Int_t BytesRead=fNoiseTree->GetEntry(1); + cout << colorred << "BytesRead: " << BytesRead << endlr; + + for (Int_t pixeli=0; pixeli 500 && pixeli < 550 ) { + cout << "pixeli: " << pixeli << endl; + cout << " " << fNoiseInfo.fNoise[pixeli]; + } + } + + + fHitTree->GetEntry(1); + for(Int_t hiti=0; (unsigned int)hitiFill(); +// fNoiseTree->Fill(); cout << colorcyan << fNoiseInfo.fNoise[100] << endlr; // getNoise(startframe, frames); } diff --git a/MABS_run_analyzer/Run.c b/MABS_run_analyzer/Run.c index cb0ff42..c04eea2 100644 --- a/MABS_run_analyzer/Run.c +++ b/MABS_run_analyzer/Run.c @@ -924,53 +924,44 @@ string Run::to_str_w_prec(const Float_t a_value, int precision = 3) Bool_t Run::binLeakageCurrent(HistogramType* oneHistogramClass) { -/* Float_t pedestial; - TBranch* noiseBranch; -// oneHistogramClass->LeakageCurrent->Reset(); - processed->fNoiseTree->SetBranchAddress("pedestal", &pedestial, &noiseBranch); - cout << colorcyan << "processed->fNoiseTree->GetEntries(): " << processed->fNoiseTree->GetEntries() << endlr; + Double_t pedestals [cursensorinfo.columns*cursensorinfo.rows]; for (Int_t framei=0; frameifNoiseTree->GetEntries(); framei++) { // loop over all frames -// processed->fNoiseTree->GetEntry(framei); -// cout << pedestial << endl; - oneHistogramClass->LeakageCurrent->Fill(1); - } */ + for (Int_t pixeli=0; pixelifNoiseInfo.fPedestals[pixeli]; + } + } + for (Int_t pixeli=0; pixelifHitTree->GetEntries(); framei++) { // loop over all frames -// processed->fHitTree->GetEntry(framei); -// for(Int_t hiti=0; (unsigned int)hitifFrameInfo.hits;hiti++) { -// pixelnumber = processed->fFrameInfo.pixel[hiti]; -// HistogramTypepointer->pixeltimefired->Fill(pixelnumber); -// } -// } } Bool_t Run::binNoise(HistogramType* oneHistogramClass) { - 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(); - 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++) { + + 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}; + cout << "processed->fNoiseTree->GetEntries: " << processed->fNoiseTree->GetEntries() << endl; + + processed->fNoiseTree->GetEntry(0); for (Int_t pixeli=0; pixeliNoise->Fill(processed->fNoiseInfo.fNoise[pixeli]); +// if (pixeli > 500 && pixeli < 550 ) { +// cout << "pixeli: " << pixeli; +// cout << " " << processed->fNoiseInfo.fNoise[pixeli] << endl; +// } + oneHistogramClass->Noise->Fill(processed->fNoiseInfo.fNoise[pixeli]); } -// } oneHistogramClass->Noise->GetQuantiles( 3, noisequantiles, probabilities); oneHistogramClass->avgNoise = noisequantiles[1]; oneHistogramClass->avgNoisePlus = noisequantiles[2] - noisequantiles[1]; oneHistogramClass->avgNoiseMinus = noisequantiles[1] - noisequantiles[0]; - // if (labbook.system == "PXI") - // for (int j=0; j<3; j++) - // noisequantiles[j] /= 16.0; // TODO analyze PXI scales + + cout << "HistogramEnd" << endl; + processed->fNoiseTree->GetEntry(processed->fNoiseTree->GetEntries()-1); + for (Int_t pixeli=0; pixeliNoiseEnd->Fill(processed->fNoiseInfo.fNoise[pixeli]); + } return 0; } @@ -1520,7 +1511,8 @@ Bool_t Run::plotAllHistograms(HistogramType* HistogramTypepointer) owntitle3->AddText(trimRunnumberAtBegin(HistogramTypepointer->Veto->GetName())); owntitle3->Draw("SAME"); canvas->cd(4); - HistogramTypepointer->Noise->Draw(); + HistogramTypepointer->NoiseEnd->Draw("SAME"); + HistogramTypepointer->Noise->Draw("SAME"); TString legendEntry = Form("Noise: %.2f + %.2f - %.2f",HistogramTypepointer->avgNoise, HistogramTypepointer->avgNoisePlus, HistogramTypepointer->avgNoiseMinus); TLegend* leg = new TLegend(0.5,0.8,0.89,0.89);//(0.6,0.7,0.89,0.89); leg->AddEntry(HistogramTypepointer->Veto, legendEntry, "l"); diff --git a/MABS_run_analyzer/help.h b/MABS_run_analyzer/help.h index 454f517..ed0d4c3 100644 --- a/MABS_run_analyzer/help.h +++ b/MABS_run_analyzer/help.h @@ -17,6 +17,7 @@ #include #define MAXHITS 1000000 +#define MAXPIXELS 100000 //#################################################################### /** * @file help.h @@ -137,11 +138,11 @@ struct frameInfo{ */ struct noiseInfo{ // Int_t pixel; - Int_t frame; + UInt_t frame; /// Array with noise information of. given pixel, estimated in @c InitialDynNoise() - Float_t* fNoise;/**< Some documentation for first. */ + Float_t fNoise [MAXPIXELS]; /// Array with pedestial information of given pixel - Float_t* fPedestals; + Float_t fPedestals [MAXPIXELS]; }; -- 2.43.0