From 6fe9e934233a1f32613fb4e48ba82df81719d0f8 Mon Sep 17 00:00:00 2001 From: Stefan Strohauer Date: Mon, 28 Oct 2013 13:11:24 +0100 Subject: [PATCH] Fixed bugs: Correction of common mode calculation in MAPS.C. Added some minor changes in PlotGraph.C and ProcessMeasurements.C --- PlotGraph/PlotGraph.C | 122 ++++++++++++++--- PlotGraph/RelevantRuns.csv | 7 + ProcessMeasurements/LaborbuchMi29.csv | 158 +++++++++++++--------- ProcessMeasurements/LaborbuchMi29.xls | Bin 24064 -> 28160 bytes ProcessMeasurements/MAPS.C | 6 +- ProcessMeasurements/ProcessMeasurements.C | 33 ++++- newCOMBI/MAPS.C | 2 +- 7 files changed, 242 insertions(+), 86 deletions(-) diff --git a/PlotGraph/PlotGraph.C b/PlotGraph/PlotGraph.C index 1f1c75a..91869d5 100644 --- a/PlotGraph/PlotGraph.C +++ b/PlotGraph/PlotGraph.C @@ -38,16 +38,19 @@ #define VETO_THRESHOLD 20 #define LABORBUCH "RelevantRuns.csv" -#define DATAPATH "/local/sstrohauer/data/data_8.8.2013_19:21/" +// #define DATAPATH "/local/sstrohauer/data/data_15.10.2013_11:36/" +// #define DATAPATH "/local/sstrohauer/data/data_18.10.2013_16:8/" +// #define DATAPATH "/local/sstrohauer/data/data_22.10.2013_14:9/" +#define DATAPATH "/local/sstrohauer/data/data_22.10.2013_18:22/" #define USE_SEPARATE_NOISE_RUN true #define DRAW_SINGLE_HISTOGRAMS true -#define DRAW_SUMMED_HISTOGRAMS false -#define DRAW_VETO_HISTOGRAMS false +#define DRAW_SUMMED_HISTOGRAMS true +#define DRAW_VETO_HISTOGRAMS true #define DRAW_PIXEL_DISTRIBUTION_HISTOGRAMS true // examples for fit functions: gaus, landau -#define FIT_FUNC "landau" -#define DRAW_FITS true -#define DRAW_NOISE_HISTOGRAM true +#define FIT_FUNC "gaus" +#define DRAW_FITS false +#define DRAW_NOISE_HISTOGRAM false #define PRINT_HEADER false void PlotGraph(Float_t selTemp, Int_t selChip, std::string selSource, Int_t selMatrix6480, Int_t selSubmatrix, Float_t selRadDose) @@ -76,6 +79,7 @@ void PlotGraph(Float_t selTemp, Int_t selChip, std::string selSource, Int_t selM std::vector histNtuple; std::vector histNtupleSum; std::vector histNtupleVeto; + std::vector histPixelNumIsSeed; std::vector histPixelDistribution1; std::vector histPixelDistribution2; std::vector histNoise; @@ -135,6 +139,19 @@ void PlotGraph(Float_t selTemp, Int_t selChip, std::string selSource, Int_t selM runDetails.push_back(Form("%i\t%.1f\t%.1f\t%i\t%s\t%i\t%.2E\t%i", runNo, temperature, tempSens, chip, source.c_str(), matrix6480, radDose, submatrix)); + Int_t totalPixelNum; + if (matrix6480 == 64) { + if (submatrix < 2) + totalPixelNum = 48*48; + else + totalPixelNum = 48*32; + } + else if (matrix6480 == 80) { + if (submatrix < 2) + totalPixelNum = 51*64; + else + totalPixelNum = 51*32; + } // open the file TString path = TString(DATAPATH) + Form("%i/%i_0_%i.root", runNo, runNo, submatrix); @@ -170,14 +187,44 @@ void PlotGraph(Float_t selTemp, Int_t selChip, std::string selSource, Int_t selM histNtuple.push_back(new TH1F(Form("hist%i",nHistNtuple), "Histogram title", 200, 0, RIGHT_BOUNDARY)); histNtupleSum.push_back(new TH1F(Form("histSum%i",nHistNtuple), "Histogram title", 200, 0, RIGHT_BOUNDARY)); histNtupleVeto.push_back(new TH1F(Form("histVeto%i",nHistNtuple), "Histogram title", 200, 0, RIGHT_BOUNDARY)); - histPixelDistribution1.push_back(new TH1F(Form("histPixelDistribution1_%i",nHistNtuple), "Histogram title", 50000, 0, 50000)); - histPixelDistribution2.push_back(new TH1F(Form("histPixelDistribution2_%i",nHistNtuple), "Histogram title", 50000, 0, 50000)); + histPixelNumIsSeed.push_back(new TH1F(Form("histPixelNumIsSeed_%i",nHistNtuple), "Histogram title", totalPixelNum, 0, totalPixelNum)); + histPixelDistribution1.push_back(new TH1F(Form("histPixelDistribution1_%i",nHistNtuple), "Histogram title", totalPixelNum, 0, totalPixelNum)); + histPixelDistribution2.push_back(new TH1F(Form("histPixelDistribution2_%i",nHistNtuple), "Histogram title", totalPixelNum, 0, totalPixelNum)); // loop over all hits to fill histogram Int_t nentries = hitNtuple->GetEntries(); // Double_t meanNotSeedSum=0; // Int_t nhits=0; + + + + cout << "Mittelwert Hits pro frame: " << nentries/50000.0 << endl; + + + + + + for (Int_t cnt=0; cntGetEntry(cnt); + histPixelNumIsSeed[nHistNtuple]->Fill(seedPixel); + } + Float_t averageBinContent = nentries/totalPixelNum; + + + + + + + + + + + + + + + for (Int_t cnt=0; cntGetEntry(cnt); @@ -187,9 +234,31 @@ void PlotGraph(Float_t selTemp, Int_t selChip, std::string selSource, Int_t selM // continue; + + + + // histogram with the single pixel +// if (pixel[12] > 20) +// continue; + + if (histPixelNumIsSeed[nHistNtuple]->GetBinContent(histPixelNumIsSeed[nHistNtuple]->GetXaxis()->FindBin(seedPixel)) > 3*averageBinContent) { +// cout << "seed: " << seedPixel << endl; + continue; + } histNtuple[nHistNtuple]->Fill(pixel[12]); +// cout << histPixelNumIsSeed[nHistNtuple]->GetBinContent(seedPixel) << endl; + + + + + + + + + + // histogram with the summed pixels Double_t pixelSum = 0; for (Int_t i=0; iFill(pixelSum); // search for systematics in pixel distribution - if (pixelSum > 100 && pixelSum < 150) { - histPixelDistribution1[nHistNtuple]->Fill(frame); + if (true) { + histPixelDistribution1[nHistNtuple]->Fill(seedPixel); } - else if (pixelSum > 180 && pixelSum < 300) { - histPixelDistribution2[nHistNtuple]->Fill(frame); + if (135 < pixelSum and pixelSum < 150) { + histPixelDistribution2[nHistNtuple]->Fill(seedPixel); } @@ -362,7 +431,6 @@ void PlotGraph(Float_t selTemp, Int_t selChip, std::string selSource, Int_t selM } } - // determine maximum y-value Float_t maxY = 0; if (DRAW_SINGLE_HISTOGRAMS){ @@ -422,19 +490,27 @@ void PlotGraph(Float_t selTemp, Int_t selChip, std::string selSource, Int_t selM Float_t maxFitMax = 1000; (*it)->Fit(fitFunc, "N,Q,W", "", 20, RIGHT_BOUNDARY); - fitMax1 = fitFunc->GetParameter(1); + fitMax1 = fitFunc->GetMaximumX(0,RIGHT_BOUNDARY); fitFunc->DrawCopy("same"); - (*it)->Fit(fitFunc, "N,Q,W", "", 20, fitMax1); - fitMax2 = fitFunc->GetParameter(1); + (*it)->Fit(fitFunc, "N,Q,W", "", 20, fitMax1+10); + fitMax2 = fitFunc->GetMaximumX(0,RIGHT_BOUNDARY); fitFunc->SetLineColor(kBlue); fitFunc->SetLineStyle(2); // dashed fitFunc->DrawCopy("same"); (*it)->Fit(fitFunc, "N,Q,W", "", fitMax1, RIGHT_BOUNDARY); - fitMax3 = fitFunc->GetParameter(1); + fitMax3 = fitFunc->GetMaximumX(0,RIGHT_BOUNDARY); fitFunc->SetLineColor(kGreen); fitFunc->DrawCopy("same"); fitFunc->SetLineStyle(1); // normal for the following fits + + + +// cout << fitMax1 << "\t" << fitMax2 << "\t" << fitMax3 << "\t" << fitFunc->GetMaximumX(0,RIGHT_BOUNDARY) << endl; + + + + // Sort the three fits and save error estimation minFitMax = TMath::Min(TMath::Min(fitMax1,fitMax2),fitMax3); maxFitMax = TMath::Max(TMath::Max(fitMax1,fitMax2),fitMax3); @@ -522,7 +598,17 @@ void PlotGraph(Float_t selTemp, Int_t selChip, std::string selSource, Int_t selM cout << endl << runDetailsHeader; for (UInt_t i=0; i^ zUAtfG$6famO+-VK2NSx94@O8d$^%g!H1R==F&a(eK@&`P&}cm~ckb+-z2ha*?ETN( z^E+qnf6ffyk38Y;J=uZIjUcaXfDPBT9yivmM&V%`YjCW^u@1+290NE8ar`?wJL`;1 z_3OrZ&rF+tfi>UPxnd_y^Q$d$-;b~eKU@V5tN?gcs6w{}I~Mmj)9>PRKfwN`X@AG! zBhK_Sd;0Olv>jD`ttl$ewa>4jS@^ry>i0T%;CZm$e5PYe$Sj?RJ)mco_=^$R^i9^-tkb-Op@xm+F% z1SxoVx?rBs4Hv{sAJHzN=4*LwOrr%g+PFpw+1mXCV#){WpYC|aXWoQmz|-3WLpXNh z*adrV?1g>!`VPPX_y;6EmVgv0~|W(Jo6uO_H4K`kaoFhN%_vl8P2{(2Z(l9X|W zVhYT-!i;M%;{-GQzt#AFzi|e6i3thJ9bDABn2@4`6vb?QHz9%vxvKeFRl_~RpeQjW z!I%nTDoiuQY^IoCJD~a9d?zq`jf4^70lG#eP-|TylNv3e(WYFQ*$q*b*bOm__8Mxf z$xLgWi)*xmMoV(dY+3Co&4X!;b_uoCWHOrPvKlSdq?t}T$~TFQW@)s7MtdE#)?|vB z=SptPgtA+Nibktyv|5YCT^>fQOY{%!6b4mk(g|Twr%g>rldkN6i6)o&@GEwonrL<@ zOjvtXJ}|_4AGaEVH)YUC5_D2Ie^MKBlEj>}K3-+V_aB*bQzLDh7_BTDTFWl@pV*~G9yxWRhp7_|HcU_OTbwL z&bq03T$b?76Dt0 zf=vWlF0e%^<{L7DA0)Uyzy$>^Xu$;nE|6DTK<*IlcnxzERK?uieAl=A&G&i+Kgkq| zA_d3aMU_Gk*VJ22_6CXsT5ME{#TI3;+kUw`a77rpD3~uxU-1(JgI^`7L`Wq?DoIj_ zkV>Syl8aOlq~nsrk0lK5NK#pl90!*bsVqrlLMoG*$}Uow)Wi=v41SlS3L#Y#sUk@g zLaLCODlSrm)WnZa4DL!&RgfHyRu!o#NmW9slA5Y6QkB%i4`vMRNm7lFYKl~|Nte;C%?e340?abkkPCYD6*$(90ET61_n z>Nyxf5|dJMa#9Uj83Y(uyivrAKw@n^ljjOdVwYfg0+f^5Y$hno#POeji$RJZk!y3C zus4a;X+F$+hCtO0KnwwsqcY{#820O^nM|2nm-&rRdva-3GZTm3 J=3iNC%m8&DOltrD diff --git a/ProcessMeasurements/MAPS.C b/ProcessMeasurements/MAPS.C index f485ce5..a47bb35 100644 --- a/ProcessMeasurements/MAPS.C +++ b/ProcessMeasurements/MAPS.C @@ -237,6 +237,9 @@ MAPS::~MAPS(void) { delete[] fNoise; delete[] fPedestals; +// delete[] hint1; +// delete[] hint2; + }; //#################################################################### @@ -317,7 +320,8 @@ void MAPS::filterCommonMode() { for(int column=0; columntm_mday << '.' << now->tm_mon+1 << '.' << now->tm_year+1900 << "_" << now->tm_hour << ':' << now->tm_min; - cout << timeSS.str() << endl; std::string logfileName = "logfile_" + timeSS.str() + ".txt"; + cout << "logfile-name: " << logfileName << endl; logfile.open(logfileName, std::ios::trunc); logfile << "This is a log file which lists all processed entries in the lab book.\n\n"; logfile << "runNo\tmatrix\tsubmtrx\tcomment\n"; @@ -65,7 +65,12 @@ void ProcessMeasurements(Bool_t overwrite = false, Bool_t useSeperateNoiseRun = std::string outputDataPath = std::string(OUTPUTDATAPATH_MAINFOLDER) + "data_" + timeSS.str() + "/"; - mkdir(outputDataPath.c_str(), 0755); // create directory for this evaluation if not existent + cout << "Working directory: " << outputDataPath << endl; + Int_t mkdirReturnValue = mkdir(outputDataPath.c_str(), 0755); + if (mkdirReturnValue != 0) { + cout << "Can not create directory (mkdir returns " << mkdirReturnValue << ")! Possible error source: No disk space available or directory already existent.\n"; // create directory for this evaluation if not existent and raise error if directory is full + return; + } // 1. case: Process one single run, chosen by the user while calling main() if (processRunNo != -1){ @@ -93,16 +98,27 @@ void ProcessMeasurements(Bool_t overwrite = false, Bool_t useSeperateNoiseRun = file >> row; // read first row (header) of the laboratory book - if (firstNoiseSecondRun == 0){ + if (firstNoiseSecondRun == 0 && useSeperateNoiseRun){ cout << "=====================================================================\n"; cout << "=====================================================================\n"; cout << "First: Analyzing only runs WITH NO source (for noise)...\n"; } - else{ + else if (useSeperateNoiseRun) { cout << "=====================================================================\n"; cout << "=====================================================================\n"; cout << "Second: Analyzing only runs WITH source...\n"; } + else if (firstNoiseSecondRun == 0 && !useSeperateNoiseRun){ + cout << "=====================================================================\n"; + cout << "=====================================================================\n"; + cout << "Analyzing run with previous noise calculation of the same file...\n"; + } + else { + cout << "=====================================================================\n"; + cout << "=====================================================================\n"; + cout << "Finished after first loop.\n"; + break; + } while(file >> row) { // for each row try { @@ -155,6 +171,13 @@ void ProcessMeasurements(Bool_t overwrite = false, Bool_t useSeperateNoiseRun = } analyzeRun(INPUTDATAPATH, outputDataPath.c_str(), runNo, matrixAB, true, false, noiseRunNo, overwrite, logfileName); } + else if (!useSeperateNoiseRun && firstNoiseSecondRun == 0) { + mkdir((outputDataPath + std::to_string(runNo) +"/").c_str(), 0755); // create directory if not existent + mkdir((outputDataPath + std::string("noise/")).c_str(), 0755); // create directory if not existent + mkdir((outputDataPath + std::string("noise/") + std::to_string(runNo) + "/").c_str(), 0755); // create directory if not existent + // use same run for calculating noise + analyzeRun(INPUTDATAPATH, outputDataPath.c_str(), runNo, matrixAB, false, false, -1, overwrite, logfileName); // noise & run + } else { cout << "==> skipped in " << firstNoiseSecondRun+1 << ". step (currently processing " << ((firstNoiseSecondRun == 0) ? "noise)":"runs)") << endl; } diff --git a/newCOMBI/MAPS.C b/newCOMBI/MAPS.C index 396d296..c95280c 100755 --- a/newCOMBI/MAPS.C +++ b/newCOMBI/MAPS.C @@ -781,7 +781,7 @@ void MAPS::filterCommonMode() { for(int column=0; column