From: Stefan Strohauer Date: Tue, 20 Aug 2013 14:01:36 +0000 (+0200) Subject: Inital commit of ROOT analysis code X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=41f9b403f065d3238d69b315d63c102824d906b4;p=radhard.git Inital commit of ROOT analysis code --- diff --git a/PlotGraph/CSVRow.C b/PlotGraph/CSVRow.C new file mode 100644 index 0000000..9bf3cc1 --- /dev/null +++ b/PlotGraph/CSVRow.C @@ -0,0 +1,34 @@ +#include "CSVRow.h" + +#include +#include +#include +#include + + +std::string const& CSVRow::operator[](std::size_t index) const { + return m_data[index]; +} + +std::size_t CSVRow::size() const { + return m_data.size(); +} + +void CSVRow::readNextRow(std::istream& str) { + std::string line; + std::getline(str,line); + + std::stringstream lineStream(line); + std::string cell; + + m_data.clear(); + while(std::getline(lineStream,cell,'\t')) { + m_data.push_back(cell); + } +} + +std::istream& operator>>(std::istream& str,CSVRow& data) { + data.readNextRow(str); + return str; +} + diff --git a/PlotGraph/CSVRow.h b/PlotGraph/CSVRow.h new file mode 100644 index 0000000..c11e33c --- /dev/null +++ b/PlotGraph/CSVRow.h @@ -0,0 +1,22 @@ +#ifndef CSVROW_H +#define CSVROW_H + + +#include +#include + +class CSVRow { +public: + std::string const& operator[](std::size_t index) const; + std::size_t size() const; + void readNextRow(std::istream& str); + + friend std::istream& operator>>(std::istream& str,CSVRow& data); + +private: + std::vector m_data; +}; + +//std::istream& operator>>(std::istream& str,CSVRow& data); + +#endif diff --git a/PlotGraph/PlotGraph.C b/PlotGraph/PlotGraph.C new file mode 100644 index 0000000..3cc39d1 --- /dev/null +++ b/PlotGraph/PlotGraph.C @@ -0,0 +1,468 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "CSVRow.h" +//#ifdef __CINT__ +#include "CSVRow.C" // bad C-style... but root wants it this way... no correct separation of declaration and implementation possible. +//#endif + +#include "TFile.h" +#include "TTree.h" +#include "TNtuple.h" +#include "TBranch.h" +#include "TString.h" +#include "TCanvas.h" +#include "TH1F.h" +#include "TLegend.h" +#include "TF1.h" + +#define COLRUNNO 0 +#define COLTEMP 2 +#define COLTEMPSENS 3 +#define COLCHIP 5 +#define COLSOURCE 6 +#define COLMATRIX 7 +#define COLRADDOSE 8 +#define COLDONE 10 + +#define NUMPIXELS 25 +#define RIGHT_BOUNDARY 400 + +#define VETO_THRESHOLD 20 + +#define LABORBUCH "RelevantRuns.csv" +#define DATAPATH "/local/sstrohauer/data/data_8.8.2013_19:21/" +#define DRAW_SINGLE_HISTOGRAMS true +#define DRAW_SUMMED_HISTOGRAMS true +#define DRAW_VETO_HISTOGRAMS true +#define DRAW_FITS true +#define PRINT_HEADER false + +void PlotGraph(Float_t selTemp, Int_t selChip, std::string selSource, Int_t selMatrix6480, Int_t selSubmatrix, Float_t selRadDose) +{ + Int_t runNo; // run number + Float_t temperature; // desired temperature + Float_t tempSens; // actual temperature + Int_t chip; // chip number (eg. 1-6) + std::string source; + Int_t matrix6480; // which matrix? + Float_t radDose; + Bool_t runFinished; // measurement already done? + std::string matrixAB; + Int_t submatrix; + Int_t numSubmatrices; + + timeval start, end; + int diff; + gettimeofday(&start, 0); + + std::ifstream file(LABORBUCH); + CSVRow row; + file >> row; // read first row (header) of the laboratory book + + + std::vector histNtuple; + std::vector histNtupleSum; + std::vector histNtupleVeto; + Int_t nHistNtuple = 0; + std::vector runDetails; + std::vector fitMaxPosX; + std::vector fitMaxPosXSum; + std::vector fitMaxPosXVeto; + + TLegend* leg = new TLegend(0.5,0.5,0.89,0.89);//(0.6,0.7,0.89,0.89); +// leg->SetHeader();//"Legend Title"); + leg->SetFillStyle(0); + +// cout << "runNo\tTemp\tChip\tSource\tMatrix\tRadDose\tSubmtrx\n"; + while (file >> row) { + + try { + if (row[COLRUNNO] == "") + continue; // no relevant data in this row + runNo = atoi(row[COLRUNNO].c_str()); // run number (conversion works like runNo = stoi(std::string ("300");) + temperature = atof(row[COLTEMP].c_str()); // temperature + tempSens = atof(row[COLTEMPSENS].c_str()); // temperature + chip = atoi(row[COLCHIP].c_str()); + source = row[COLSOURCE]; + matrix6480 = atoi(row[COLMATRIX].c_str()); // which matrix? + radDose = atof(row[COLRADDOSE].c_str()); + runFinished = row[COLDONE] == "y"; // measurement already done? + + if (!runFinished) + continue; + + if (selMatrix6480 == 64) + numSubmatrices = 6; // could change for different Mimosa chips + else if (selMatrix6480 == 80) + numSubmatrices = 6; + else if (selMatrix6480 == -1) + numSubmatrices = 6; + else + cout << "Unknown matrix: " << selMatrix6480 << endl; + + for (submatrix=0; submatrix < numSubmatrices; submatrix++){ + if ( (temperature == selTemp || selTemp == -1) + && (chip == selChip || selChip == -1) + && (source == selSource || selSource == "-1") + && (matrix6480 == selMatrix6480 || selMatrix6480 == -1) + && (radDose == selRadDose || selRadDose == -1) + && (submatrix == selSubmatrix || selSubmatrix == -1)) + { +// cout << "runNo " << runNo << "\tTemperature " << temperature << "\tChip " << chip << "\tSource " << source << "\tMatrix " << matrix6480 << "\tRad.dose " << radDose << "\tSubmatrix " << submatrix << endl; + if (PRINT_HEADER) + cout << runNo << "\t" << temperature << "\t" << chip << "\t" << source << "\t" << matrix6480 << "\t" << radDose << "\t" << submatrix << endl; + + 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)); + + + // open the file + TString path = TString(DATAPATH) + Form("%i/%i_0_%i.root", runNo, runNo, submatrix); + TFile* f = TFile::Open(path); + if (f->IsZombie()) { + // if we cannot open the file, print an error messageForm("hist%i",nHistNtuple) and return immediatly + printf("Error: cannot open %s\n", path.Data()); + return; + } + + // get a pointer to the tree + TNtuple* hitNtuple = (TNtuple*) f->Get("hit"); + TNtuple* hitsNtuple = (TNtuple*) f->Get("hits"); + + // one array element and one branch for each pixel + Float_t pixel[NUMPIXELS]; + TBranch* pixelBranch[NUMPIXELS]; + for (Int_t cnt=0; cntSetBranchAddress(Form("p%i",cnt+1), &pixel[cnt], &pixelBranch[cnt]); + } + Float_t frame; + TBranch* frameBranch; + hitNtuple->SetBranchAddress("frame", &frame, &frameBranch); + + Float_t frameCounts; + TBranch* frameCountsBranch; + hitsNtuple->SetBranchAddress("counts", &frameCounts, &frameCountsBranch); + + // create histogram + 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)); + + // loop over all hits to fill histogram + Int_t nentries = hitNtuple->GetEntries(); +// Double_t meanNotSeedSum=0; +// Int_t nhits=0; + + for (Int_t cnt=0; cntGetEntry(cnt); + + // take only frames with a maximum of one hit +// hitsNtuple->GetEntry((Int_t) frame); +// if (frameCounts > 1) +// continue; + + + // histogram with the single pixel + histNtuple[nHistNtuple]->Fill(pixel[12]); + + // histogram with the summed pixels + Double_t pixelSum = 0; + for (Int_t i=0; iFill(pixelSum); + + // histogram with the single pixel and with "veto trigger" + // for the "histNtupleVeto" take only hits where only the seed pixel contains charge + Double_t notSeedSum = 0; + for (Int_t i=0; i<12; i++) + notSeedSum += pixel[i]; + for (Int_t i=13; i VETO_THRESHOLD) + continue; +// meanNotSeedSum+=notSeedSum; +// nhits++; + histNtupleVeto[nHistNtuple]->Fill(pixel[12]); // histogram with the single pixel + + } +// cout<<"Mittelwert"<SetLineColor(nHistNtuple+1); + histNtuple[nHistNtuple]->SetStats(kFALSE); + histNtupleSum[nHistNtuple]->SetLineColor(nHistNtuple+1); + histNtupleSum[nHistNtuple]->SetStats(kFALSE); + histNtupleSum[nHistNtuple]->SetLineStyle(2); // make summed graphs dashed + histNtupleVeto[nHistNtuple]->SetLineColor(nHistNtuple+1); + histNtupleVeto[nHistNtuple]->SetStats(kFALSE); + histNtupleVeto[nHistNtuple]->SetLineStyle(3); // make summed graphs dotted +// TString legendEntry = Form("#splitline{Run %i: T_{set}=%.1f, T_{sens}=%.1f, Chip=%i, }{Source=%s, Matrix=%i, Submatrix=%i, RadDose=%.2E}", runNo, temperature, tempSens, chip, TString(source).Data(), matrix6480, submatrix, radDose); + TString legendEntry = TString(Form("Run %i: ",runNo)) + (selTemp==-1 ? Form(" T_{set}=%.1f",temperature):"") + Form(" T_{sens}=%.1f",tempSens) + (selChip==-1 ? Form(" Chip=%i",chip):"") + (selSource=="-1" ? Form(" Source=%s",source.c_str()):"") + (selMatrix6480==-1 ? Form(" Matrix=%i",matrix6480):"") + (selSubmatrix==-1 ? Form(" Submatrix=%i",submatrix):"") + (selRadDose==-1 ? Form(" RadDose=%.2E",radDose):""); +// TString legendEntry = TString(Form("test") + (selTemp==-1 ? Form(", T_{set}=%.1f",temperature):"");// + Form(", T_{sens}=%.1f",tempSens) + (selChip==-1 ? Form(", Chip=%i",chip):"") + (selSource=="-1" ? Form(", Source=%s",source):"") + (selMatrix6480==-1 ? Form(", Matrix=%i",matrix6480):"") + (selSubmatrix==-1 ? Form(", Submatrix=%i",submatrix):"") + (selRadDose==-1 ? Form(", RadDose=%.2E",radDose):""); + leg->AddEntry(histNtuple[nHistNtuple], legendEntry); +// leg->AddEntry((TObject*)0, "", ""); + +// histNtuple[nHistNtuple]->SetLineColor(nHistNtuple); +// histNtuple[nHistNtuple]->Draw(); + + cout << "Hits per Frame: " << nentries/frame << endl; + + nHistNtuple++; // increase + } + } + + + } + catch(...){ + cout << "Error while reading laboratory book (run number " << runNo << ")!\n"; + } + } + + + // determine maximum y-value + Float_t maxY = 0; + for (std::vector::iterator it = histNtuple.begin(); it != histNtuple.end(); ++it){ + Int_t thismax = (*it)->GetMaximum(); + if (thismax > maxY){ + maxY = thismax; +// maxHistNum = std::distance(histNtuple.begin(), it); + } + } + for (std::vector::iterator it = histNtupleSum.begin(); it != histNtupleSum.end(); ++it){ + Int_t thismax = (*it)->GetMaximum(); + if (thismax > maxY){ + maxY = thismax; +// maxHistNum = std::distance(histNtuple.begin(), it); + } + } + for (std::vector::iterator it = histNtupleVeto.begin(); it != histNtupleVeto.end(); ++it){ + Int_t thismax = (*it)->GetMaximum(); + if (thismax > maxY){ + maxY = thismax; +// maxHistNum = std::distance(histNtuple.begin(), it); + } + } + + + TCanvas* c1 = new TCanvas(); + c1->SetTitle("Testtitel"); + TF1* fitFunc = new TF1("fitFunc","gaus",0,RIGHT_BOUNDARY); + // plot every single pixel histogram in one canvas + if (DRAW_SINGLE_HISTOGRAMS){ + for (std::vector::iterator it = histNtuple.begin(); it != histNtuple.end(); ++it){ + Int_t cnt = std::distance(histNtuple.begin(), it) ; + // (*it)->SetLineColor(cnt); + (*it)->SetMaximum(1.05*maxY); + (*it)->Draw((cnt==0)?"":"same"); + + (*it)->GetXaxis()->SetRange((*it)->GetXaxis()->FindBin(20),(*it)->GetXaxis()->FindBin(RIGHT_BOUNDARY)); // look only for maxima with x greater than 20 + Int_t xValMax = (*it)->GetBinCenter((*it)->GetMaximumBin()); + (*it)->Fit(fitFunc, "N,Q,W", "", xValMax-10, xValMax+10); + (*it)->GetXaxis()->UnZoom(); + if (DRAW_FITS) + fitFunc->DrawCopy("same"); +// cout << "Maximum bin: " << (*it)->GetBinCenter((*it)->GetMaximumBin()) << endl; +// cout << "Maximum of gaussian fit: " << fitFunc->GetParameter(1) << "\n\n"; + fitMaxPosX.push_back(fitFunc->GetParameter(1)); +// runDetails[cnt] = runDetails[cnt] + Form("%.2f", fitMaxPosX); + } + } + // plot all summed histograms into the same histogram + if (DRAW_SUMMED_HISTOGRAMS){ + for (std::vector::iterator it = histNtupleSum.begin(); it != histNtupleSum.end(); ++it){ + Int_t cnt = std::distance(histNtupleSum.begin(), it) ; + (*it)->SetMaximum(1.05*maxY); + if (!DRAW_SINGLE_HISTOGRAMS) + (*it)->Draw((cnt==0)?"":"same"); + else + (*it)->Draw("same"); + +// (*it)->GetXaxis()->SetRange((*it)->GetXaxis()->FindBin(fitMaxPosX[cnt] + 25),(*it)->GetXaxis()->FindBin(RIGHT_BOUNDARY)); // look only for maxima with x greater than 25 more right than the peak of the seed pixel + (*it)->GetXaxis()->SetRange((*it)->GetXaxis()->FindBin(fitMaxPosX[cnt]),(*it)->GetXaxis()->FindBin(RIGHT_BOUNDARY)); // look only for maxima with x greater than 20 + Int_t xValMax = (*it)->GetBinCenter((*it)->GetMaximumBin()); + (*it)->Fit(fitFunc, "N,Q,W", "", xValMax-15, xValMax+15); + (*it)->GetXaxis()->UnZoom(); + if (DRAW_FITS) + fitFunc->DrawCopy("same"); +// cout << "Maximum bin: " << (*it)->GetBinCenter((*it)->GetMaximumBin()) << endl; +// cout << "Maximum of gaussian fit: " << fitFunc->GetParameter(1) << "\n\n"; + fitMaxPosXSum.push_back(fitFunc->GetParameter(1)); + } + } + // plot single pixel histograms with veto trigger in the same histogram + if (DRAW_VETO_HISTOGRAMS){ + for (std::vector::iterator it = histNtupleVeto.begin(); it != histNtupleVeto.end(); ++it){ + Int_t cnt = std::distance(histNtupleVeto.begin(), it) ; + (*it)->SetMaximum(1.05*maxY); + if (!DRAW_SINGLE_HISTOGRAMS && !DRAW_SUMMED_HISTOGRAMS) + (*it)->Draw((cnt==0)?"":"same"); + else + (*it)->Draw("same"); + +// (*it)->GetXaxis()->SetRange((*it)->GetXaxis()->FindBin(fitMaxPosX[cnt] + 25),(*it)->GetXaxis()->FindBin(RIGHT_BOUNDARY)); // look only for maxima with x greater than 25 more right than the peak of the seed pixel + (*it)->GetXaxis()->SetRange((*it)->GetXaxis()->FindBin(fitMaxPosX[cnt]),(*it)->GetXaxis()->FindBin(RIGHT_BOUNDARY)); // look only for maxima with x greater than 20 + Int_t xValMax = (*it)->GetBinCenter((*it)->GetMaximumBin()); + (*it)->Fit(fitFunc, "N,Q,W", "", xValMax-15, xValMax+15); + (*it)->GetXaxis()->UnZoom(); + if (DRAW_FITS) + fitFunc->DrawCopy("same"); +// cout << "Maximum bin: " << (*it)->GetBinCenter((*it)->GetMaximumBin()) << endl; +// cout << "Maximum of gaussian fit: " << fitFunc->GetParameter(1) << "\n\n"; + fitMaxPosXVeto.push_back(fitFunc->GetParameter(1)); + } + } + + + + // add legend + TString legendEntry = TString("Same Parameters: ") + (selTemp!=-1 ? Form(" T_{set}=%.1f",selTemp):"") + (selChip!=-1 ? Form(" Chip=%i",selChip):"") + (selSource!="-1" ? Form(" Source=%s",selSource.c_str()):"") + (selMatrix6480!=-1 ? Form(" Matrix=%i",selMatrix6480):"") + (selSubmatrix!=-1 ? Form(" Submatrix=%i",selSubmatrix):"") + (selRadDose!=-1 ? Form(" RadDose=%.2E",selRadDose):""); + leg->AddEntry((TObject*) 0, legendEntry, ""); + leg->SetTextSize(0.02); + leg->Draw(); + + // print all information + TString runDetailsHeader = TString("runNo\tT\tTSens\tChip\tSource\tMatrix\tRadDose\tSubmtrx") + (DRAW_SINGLE_HISTOGRAMS ? "\tColPeak":"") + (DRAW_SUMMED_HISTOGRAMS ? "\tSumColPeak":"") + (DRAW_VETO_HISTOGRAMS ? "\tCalibPeak":"") + "\n"; + if (PRINT_HEADER) + cout << endl << runDetailsHeader; + for (UInt_t i=0; iGet("hit"); +// +// hitNtuple->Draw("p13"); +// // hitNtuple->Draw("p10","","same"); +// +// delete f; +// +// Int_t runNo = 29016; +// Int_t submatrix = 0; +// TString path = TString(OUTPUTDATAPATH) + Form("%i/%i_0_%i.root", runNo, runNo, submatrix); +// TFile *f = TFile::Open(path); +// if (f == 0) { +// // if we cannot open the file, print an error message and return immediatly +// printf("Error: cannot open %s\n", path); +// return; +// } +// hitNtuple = (TNtuple*) f->Get("hit"); +// hitNtuple->Draw("p13","","same"); + +// TH1F *hist = new TH1F("hHitNtuple", "p13!! ist das :)"); // dynamic allocation (delete at the end) +// Long64_t nentries = hitNtuple->GetEntries(); +// for (Long64_t i; i=0; iFill() +// } +// delete hist; + + + + + + + + +// { +// TFile f1("essai1.root"); +// TH1F *h1=f1.Get("2"); +// TFile f2("essai2.root"); +// TH1F *h2=f2.Get("2"); +// TFile f3("essai3.root"); +// TH1F *h3=f3.Get("2"); +// +// h2->SetLineColor(kRed); +// h3->SetLineColor(kGreen); +// +// h1->Draw("l"); +// h2->Draw("same"); +// h3->Draw("same"); +// } + + + + + + + + +// Int_t runNo = 29012; +// Int_t submatrix = 0; +// +// +// +// +// // Variables used to store the data +// Int_t totalSize = 0; // Sum of data size (in bytes) of all events +// Int_t eventSize = 0; // Size of the current event +// TBranch *eventSizeBranch = 0; // Pointer to the event.fEventsize branch +// +// // open the file +// TString path = TString(OUTPUTDATAPATH) + Form("%i/%i_0_%i.root", runNo, runNo, submatrix); +// TFile *f = TFile::Open(path); +// +// if (f == 0) { +// // if we cannot open the file, print an error message and return immediatly +// printf("Error: cannot open %s\n", path); +// return; +// } +// +// // get a pointer to the tree +// TNtuple* hitNtuple = (TNtuple*) f->Get("hit"); +// +// hitNtuple->Draw("p13"); +// // hitNtuple->Draw("p10","","same"); +// +// delete f; +// +// Int_t runNo = 29016; +// Int_t submatrix = 0; +// TString path = TString(OUTPUTDATAPATH) + Form("%i/%i_0_%i.root", runNo, runNo, submatrix); +// TFile *f = TFile::Open(path); +// if (f == 0) { +// // if we cannot open the file, print an error message and return immediatly +// printf("Error: cannot open %s\n", path); +// return; +// } +// hitNtuple = (TNtuple*) f->Get("hit"); +// hitNtuple->Draw("p13","","same"); + diff --git a/PlotGraph/RelevantRuns.csv b/PlotGraph/RelevantRuns.csv new file mode 100644 index 0000000..0a85b9a --- /dev/null +++ b/PlotGraph/RelevantRuns.csv @@ -0,0 +1,114 @@ +Runnr. Date Temperature T-sensor Events Chip Source 64/80 Radiation dose Vbo Done? Allowed T-range Comment +29012 5/17/2013 20 21.5 50000 1 Fe55 64 0.00E+00 3.20 y 19 … 21 All the yellow marked measurements were made with a baseline in the range between 500 and 3500 for -20°C and were not modified for the other highlighted measurements. +29013 5/17/2013 20 21.5 50000 1 Fe55 80 0.00E+00 3.12 y +29014 5/17/2013 -20 -15.5 50000 1 Fe55 64 0.00E+00 3.19 y -12 … -19 +29015 5/17/2013 -20 -16.0 50000 1 Fe55 80 0.00E+00 3.12 y +29016 5/18/2013 -70 -58.0 50000 1 Fe55 64 0.00E+00 3.18 y -30 … -60 +29017 5/18/2013 -70 -58.0 50000 1 Fe55 80 0.00E+00 3.10 y + +29018 5/16/2013 20 20.0 50000 1 none 64 0.00E+00 3.20 y +29019 5/16/2013 20 20.5 50000 1 none 80 0.00E+00 3.12 y +29020 5/16/2013 -20 -16.5 50000 1 none 64 0.00E+00 3.19 y +29021 5/16/2013 -20 -17.0 50000 1 none 80 0.00E+00 3.12 y +29022 5/16/2013 -70 -57.5 50000 1 none 64 0.00E+00 3.18 y +29023 5/16/2013 -70 -59.5 50000 1 none 80 0.00E+00 3.10 y + +29024 5/21/2013 20 21.5 50000 1 Sr90 64 0.00E+00 3.20 y +29025 5/21/2013 20 21.5 50000 1 Sr90 80 0.00E+00 3.12 y +29026 5/21/2013 -20 -14.0 50000 1 Sr90 64 0.00E+00 3.19 y +29027 5/21/2013 -20 -14.5 50000 1 Sr90 80 0.00E+00 3.12 y +29028 5/21/2013 -70 -53.5 50000 1 Sr90 64 0.00E+00 3.18 y +29029 5/21/2013 -70 -54.5 50000 1 Sr90 80 0.00E+00 3.10 y + +29030 5/27/2013 20 21.0 50000 1 Fe55,dimmed 64 0.00E+00 3.20 y same as run 29012, but dimmed +29031 5/27/2013 20 21.0 50000 1 Fe55,dimmed 80 0.00E+00 3.12 y same as run 29013, but dimmed +29032 5/28/2013 -20 -16.5 50000 1 Fe55,dimmed 64 0.00E+00 3.19 y same as run 29014, but dimmed +29033 5/28/2013 -20 -16.5 50000 1 Fe55,dimmed 80 0.00E+00 3.12 y same as run 29015, but dimmed + + +29034 5/29/2013 20 21.5 50000 2 Fe55,dimmed 64 1.50E+05 3.15 y 19 … 21 +29035 5/29/2013 20 21.0 50000 2 Fe55,dimmed 80 1.50E+05 3.15 y +29036 5/29/2013 -20 -16.0 50000 2 Fe55,dimmed 64 1.50E+05 3.15 y -12 … -19 +29037 5/30/2013 -20 -16.0 50000 2 Fe55,dimmed 80 1.50E+05 3.15 y +29038 5/30/2013 -70 -57.0 50000 2 Fe55,dimmed 64 1.50E+05 3.15 y -30 … -60 +29039 5/30/2013 -70 -56.5 50000 2 Fe55,dimmed 80 1.50E+05 3.15 y + +29040 5/28/2013 20 21.0 50000 2 none 64 1.50E+05 3.08 y +29041 5/28/2013 20 21.0 50000 2 none 80 1.50E+05 3.08 y +29042 5/28/2013 -20 -13.5 50000 2 none 64 1.50E+05 3.08 y +29043 5/28/2013 -20 -14.5 50000 2 none 80 1.50E+05 3.08 y +29044 5/29/2013 -70 -52.5 50000 2 none 64 1.50E+05 3.08 y +29045 5/29/2013 -70 -53.5 50000 2 none 80 1.50E+05 3.08 y + +29046 5/31/2013 20 21.6 50000 2 Sr90 64 1.50E+05 3.15 y +29047 5/31/2013 20 21.0 50000 2 Sr90 80 1.50E+05 3.15 y +29048 5/31/2013 -20 -15.5 50000 2 Sr90 64 1.50E+05 3.15 y +29049 6/2/2013 -20 -16.0 50000 2 Sr90 80 1.50E+05 3.15 y +29050 6/2/2013 -70 -54.5 50000 2 Sr90 64 1.50E+05 3.15 y +29051 6/2/2013 -70 -54.5 50000 2 Sr90 80 1.50E+05 3.15 y + + +29052 6/7/2013 20 21.0 50000 4 Fe55,dimmed 64 1.00E+12 1.52 y 19 … 21 +29053 6/7/2013 20 21.0 50000 4 Fe55,dimmed 80 1.00E+12 1.52 y +29054 6/7/2013 -20 -15.5 50000 4 Fe55,dimmed 64 1.00E+12 1.52 y -12 … -19 +29055 6/7/2013 -20 -16.5 50000 4 Fe55,dimmed 80 1.00E+12 1.52 y +29056 6/7/2013 -70 -58.0 50000 4 Fe55,dimmed 64 1.00E+12 1.52 y -30 … -60 +29057 6/7/2013 -70 -58.0 50000 4 Fe55,dimmed 80 1.00E+12 1.52 y + +29058 6/6/2013 20 21.5 50000 4 none 64 1.00E+12 1.52 y +29059 6/6/2013 20 21.0 50000 4 none 80 1.00E+12 1.52 y +29060 6/6/2013 -20 -15.5 50000 4 none 64 1.00E+12 1.52 y +29061 6/6/2013 -20 -15.5 50000 4 none 80 1.00E+12 1.52 y +29062 6/6/2013 -70 -54.5 50000 4 none 64 1.00E+12 1.52 y +29063 6/6/2013 -70 -56.0 50000 4 none 80 1.00E+12 1.52 y + +29064 6/10/2013 20 22.0 50000 4 Sr90 64 1.00E+12 1.52 y +29065 6/10/2013 20 21.5 50000 4 Sr90 80 1.00E+12 1.52 y +29066 6/10/2013 -20 -13.5 50000 4 Sr90 64 1.00E+12 1.52 y +29067 6/10/2013 -20 -14.0 50000 4 Sr90 80 1.00E+12 1.52 y +29068 6/10/2013 -70 -53.0 50000 4 Sr90 64 1.00E+12 1.52 y +29069 6/10/2013 -70 -54.0 50000 4 Sr90 80 1.00E+12 1.52 y + + +29070 6/14/2013 20 21.5 50000 5 Fe55,dimmed 64 3.00E+12 1.57 y 19 … 21 +29071 6/14/2013 20 21.0 50000 5 Fe55,dimmed 80 3.00E+12 1.55 y +29072 6/14/2013 -20 -16.0 50000 5 Fe55,dimmed 64 3.00E+12 1.57 y -12 … -19 +29073 6/14/2013 -20 -16.5 50000 5 Fe55,dimmed 80 3.00E+12 1.55 y +29074 6/14/2013 -70 -58.5 50000 5 Fe55,dimmed 64 3.00E+12 1.57 y -30 … -60 +29075 6/14/2013 -70 -58.5 50000 5 Fe55,dimmed 80 3.00E+12 1.55 y + +29076 6/13/2013 20 20.5 50000 5 none 64 3.00E+12 1.57 y +29077 6/13/2013 20 20.5 50000 5 none 80 3.00E+12 1.55 y +29078 6/13/2013 -20 -16.5 50000 5 none 64 3.00E+12 1.57 y +29079 6/13/2013 -20 -17.0 50000 5 none 80 3.00E+12 1.55 y +29080 6/13/2013 -70 -57.0 50000 5 none 64 3.00E+12 1.57 y +29081 6/13/2013 -70 -59.5 50000 5 none 80 3.00E+12 1.55 y + +29082 6/17/2013 20 21.5 50000 5 Sr90 64 3.00E+12 1.57 y +29083 6/17/2013 20 21.0 50000 5 Sr90 80 3.00E+12 1.55 y +29084 6/17/2013 -20 -14.0 50000 5 Sr90 64 3.00E+12 1.57 y +29085 6/17/2013 -20 -15.0 50000 5 Sr90 80 3.00E+12 1.55 y +29086 6/17/2013 -70 -54.0 50000 5 Sr90 64 3.00E+12 1.57 y +29087 6/17/2013 -70 -54.5 50000 5 Sr90 80 3.00E+12 1.55 y + + +29088 6/20/2013 20 21.0 50000 6 Fe55,dimmed 64 1.00E+13 1.54 y 19 … 21 +29089 6/20/2013 20 21.0 50000 6 Fe55,dimmed 80 1.00E+13 1.53 y +29090 6/20/2013 -20 -16.5 50000 6 Fe55,dimmed 64 1.00E+13 1.54 y -12 … -19 +29091 6/20/2013 -20 -16.5 50000 6 Fe55,dimmed 80 1.00E+13 1.53 y +29092 6/20/2013 -70 -58.5 50000 6 Fe55,dimmed 64 1.00E+13 1.54 y -30 … -60 +29093 6/20/2013 -70 -59.5 50000 6 Fe55,dimmed 80 1.00E+13 1.53 y + +29094 6/18/2013 20 20.5 50000 6 none 64 1.00E+13 1.54 y +29095 6/18/2013 20 20.5 50000 6 none 80 1.00E+13 1.53 y +29096 6/18/2013 -20 -15.5 50000 6 none 64 1.00E+13 1.54 y +29097 6/18/2013 -20 -15.5 50000 6 none 80 1.00E+13 1.53 y +29098 6/19/2013 -70 -60.0 50000 6 none 64 1.00E+13 1.54 y +29099 6/19/2013 -70 -60.0 50000 6 none 80 1.00E+13 1.53 y + +29100 6/24/2013 20 21.0 50000 6 Sr90 64 1.00E+13 1.54 y +29101 6/24/2013 20 21.0 50000 6 Sr90 80 1.00E+13 1.53 y +29102 6/24/2013 -20 -15.0 50000 6 Sr90 64 1.00E+13 1.54 y +29103 6/24/2013 -20 -16.0 50000 6 Sr90 80 1.00E+13 1.53 y +29104 6/24/2013 -70 -54.5 50000 6 Sr90 64 1.00E+13 1.54 y +29105 6/24/2013 -70 -55.5 50000 6 Sr90 80 1.00E+13 1.53 y diff --git a/ProcessMeasurements/CSVRow.C b/ProcessMeasurements/CSVRow.C new file mode 100644 index 0000000..9bf3cc1 --- /dev/null +++ b/ProcessMeasurements/CSVRow.C @@ -0,0 +1,34 @@ +#include "CSVRow.h" + +#include +#include +#include +#include + + +std::string const& CSVRow::operator[](std::size_t index) const { + return m_data[index]; +} + +std::size_t CSVRow::size() const { + return m_data.size(); +} + +void CSVRow::readNextRow(std::istream& str) { + std::string line; + std::getline(str,line); + + std::stringstream lineStream(line); + std::string cell; + + m_data.clear(); + while(std::getline(lineStream,cell,'\t')) { + m_data.push_back(cell); + } +} + +std::istream& operator>>(std::istream& str,CSVRow& data) { + data.readNextRow(str); + return str; +} + diff --git a/ProcessMeasurements/CSVRow.h b/ProcessMeasurements/CSVRow.h new file mode 100644 index 0000000..71c7183 --- /dev/null +++ b/ProcessMeasurements/CSVRow.h @@ -0,0 +1,19 @@ +#ifndef CSVROW_H +#define CSVROW_H + + +#include +#include + +class CSVRow { +public: + std::string const& operator[](std::size_t index) const; + std::size_t size() const; + void readNextRow(std::istream& str); +private: + std::vector m_data; +}; + +std::istream& operator>>(std::istream& str,CSVRow& data); + +#endif \ No newline at end of file diff --git a/ProcessMeasurements/LaborbuchMi29.csv b/ProcessMeasurements/LaborbuchMi29.csv new file mode 100644 index 0000000..72da025 --- /dev/null +++ b/ProcessMeasurements/LaborbuchMi29.csv @@ -0,0 +1,120 @@ +Runnr. Date Temperature T-sensor Events Chip Source 64/80 Radiation dose Vbo Done? Allowed T-range Comment +29008 4/23/2013 -20 -15.0 5000 1 Fe55 64 0.00E+00 y +29009 4/23/2013 -20 -15.0 5000 1 none 64 0.00E+00 y +29010 4/23/2013 -20 -15.0 5000 1 Fe55 80 0.00E+00 y +29011 4/23/2013 -20 -15.0 5000 1 none 80 0.00E+00 + + +29012 5/17/2013 20 21.5 50000 1 Fe55 64 0.00E+00 3.20 y 19 … 21 All the yellow marked measurements were made with a baseline in the range between 500 and 3500 for -20°C and were not modified for the other highlighted measurements. +29013 5/17/2013 20 21.5 50000 1 Fe55 80 0.00E+00 3.12 y +29014 5/17/2013 -20 -15.5 50000 1 Fe55 64 0.00E+00 3.19 y -12 … -19 +29015 5/17/2013 -20 -16.0 50000 1 Fe55 80 0.00E+00 3.12 y +29016 5/18/2013 -70 -58.0 50000 1 Fe55 64 0.00E+00 3.18 y -30 … -60 +29017 5/18/2013 -70 -58.0 50000 1 Fe55 80 0.00E+00 3.10 y + +29018 5/16/2013 20 20.0 50000 1 none 64 0.00E+00 3.20 y +29019 5/16/2013 20 20.5 50000 1 none 80 0.00E+00 3.12 y +29020 5/16/2013 -20 -16.5 50000 1 none 64 0.00E+00 3.19 y +29021 5/16/2013 -20 -17.0 50000 1 none 80 0.00E+00 3.12 y +29022 5/16/2013 -70 -57.5 50000 1 none 64 0.00E+00 3.18 y +29023 5/16/2013 -70 -59.5 50000 1 none 80 0.00E+00 3.10 y + +29024 5/21/2013 20 21.5 50000 1 Sr-90 64 0.00E+00 3.20 y +29025 5/21/2013 20 21.5 50000 1 Sr-90 80 0.00E+00 3.12 y +29026 5/21/2013 -20 -14.0 50000 1 Sr-90 64 0.00E+00 3.19 y +29027 5/21/2013 -20 -14.5 50000 1 Sr-90 80 0.00E+00 3.12 y +29028 5/21/2013 -70 -53.5 50000 1 Sr-90 64 0.00E+00 3.18 y +29029 5/21/2013 -70 -54.5 50000 1 Sr-90 80 0.00E+00 3.10 y + +29030 5/27/2013 20 21.0 50000 1 Fe55, dimmed 64 0.00E+00 3.20 y same as run 29012, but dimmed +29031 5/27/2013 20 21.0 50000 1 Fe55, dimmed 80 0.00E+00 3.12 y same as run 29013, but dimmed +29032 5/28/2013 -20 -16.5 50000 1 Fe55, dimmed 64 0.00E+00 3.19 y same as run 29014, but dimmed +29033 5/28/2013 -20 -16.5 50000 1 Fe55, dimmed 80 0.00E+00 3.12 y same as run 29015, but dimmed + + +29034 5/29/2013 20 21.5 50000 2 Fe55, dimmed 64 1.50E+05 3.15 y 19 … 21 +29035 5/29/2013 20 21.0 50000 2 Fe55, dimmed 80 1.50E+05 3.15 y +29036 5/29/2013 -20 -16.0 50000 2 Fe55, dimmed 64 1.50E+05 3.15 y -12 … -19 +29037 5/30/2013 -20 -16.0 50000 2 Fe55, dimmed 80 1.50E+05 3.15 y +29038 5/30/2013 -70 -57.0 50000 2 Fe55, dimmed 64 1.50E+05 3.15 y -30 … -60 +29039 5/30/2013 -70 -56.5 50000 2 Fe55, dimmed 80 1.50E+05 3.15 y + +29040 5/28/2013 20 21.0 50000 2 none 64 1.50E+05 3.08 y +29041 5/28/2013 20 21.0 50000 2 none 80 1.50E+05 3.08 y +29042 5/28/2013 -20 -13.5 50000 2 none 64 1.50E+05 3.08 y +29043 5/28/2013 -20 -14.5 50000 2 none 80 1.50E+05 3.08 y +29044 5/29/2013 -70 -52.5 50000 2 none 64 1.50E+05 3.08 y +29045 5/29/2013 -70 -53.5 50000 2 none 80 1.50E+05 3.08 y + +29046 5/31/2013 20 21.6 50000 2 Sr-90 64 1.50E+05 3.15 y +29047 5/31/2013 20 21.0 50000 2 Sr-90 80 1.50E+05 3.15 y +29048 5/31/2013 -20 -15.5 50000 2 Sr-90 64 1.50E+05 3.15 y +29049 6/2/2013 -20 -16.0 50000 2 Sr-90 80 1.50E+05 3.15 y +29050 6/2/2013 -70 -54.5 50000 2 Sr-90 64 1.50E+05 3.15 y +29051 6/2/2013 -70 -54.5 50000 2 Sr-90 80 1.50E+05 3.15 y + + +29052 6/7/2013 20 21.0 50000 4 Fe55, dimmed 64 1.00E+12 1.52 y 19 … 21 +29053 6/7/2013 20 21.0 50000 4 Fe55, dimmed 80 1.00E+12 1.52 y +29054 6/7/2013 -20 -15.5 50000 4 Fe55, dimmed 64 1.00E+12 1.52 y -12 … -19 +29055 6/7/2013 -20 -16.5 50000 4 Fe55, dimmed 80 1.00E+12 1.52 y +29056 6/7/2013 -70 -58.0 50000 4 Fe55, dimmed 64 1.00E+12 1.52 y -30 … -60 +29057 6/7/2013 -70 -58.0 50000 4 Fe55, dimmed 80 1.00E+12 1.52 y + +29058 6/6/2013 20 21.5 50000 4 none 64 1.00E+12 1.52 y +29059 6/6/2013 20 21.0 50000 4 none 80 1.00E+12 1.52 y +29060 6/6/2013 -20 -15.5 50000 4 none 64 1.00E+12 1.52 y +29061 6/6/2013 -20 -15.5 50000 4 none 80 1.00E+12 1.52 y +29062 6/6/2013 -70 -54.5 50000 4 none 64 1.00E+12 1.52 y +29063 6/6/2013 -70 -56.0 50000 4 none 80 1.00E+12 1.52 y + +29064 6/10/2013 20 22.0 50000 4 Sr-90 64 1.00E+12 1.52 y +29065 6/10/2013 20 21.5 50000 4 Sr-90 80 1.00E+12 1.52 y +29066 6/10/2013 -20 -13.5 50000 4 Sr-90 64 1.00E+12 1.52 y +29067 6/10/2013 -20 -14.0 50000 4 Sr-90 80 1.00E+12 1.52 y +29068 6/10/2013 -70 -53.0 50000 4 Sr-90 64 1.00E+12 1.52 y +29069 6/10/2013 -70 -54.0 50000 4 Sr-90 80 1.00E+12 1.52 y + + +29070 6/14/2013 20 21.5 50000 5 Fe55, dimmed 64 3.00E+12 1.57 y 19 … 21 +29071 6/14/2013 20 21.0 50000 5 Fe55, dimmed 80 3.00E+12 1.55 y +29072 6/14/2013 -20 -16.0 50000 5 Fe55, dimmed 64 3.00E+12 1.57 y -12 … -19 +29073 6/14/2013 -20 -16.5 50000 5 Fe55, dimmed 80 3.00E+12 1.55 y +29074 6/14/2013 -70 -58.5 50000 5 Fe55, dimmed 64 3.00E+12 1.57 y -30 … -60 +29075 6/14/2013 -70 -58.5 50000 5 Fe55, dimmed 80 3.00E+12 1.55 y + +29076 6/13/2013 20 20.5 50000 5 none 64 3.00E+12 1.57 y +29077 6/13/2013 20 20.5 50000 5 none 80 3.00E+12 1.55 y +29078 6/13/2013 -20 -16.5 50000 5 none 64 3.00E+12 1.57 y +29079 6/13/2013 -20 -17.0 50000 5 none 80 3.00E+12 1.55 y +29080 6/13/2013 -70 -57.0 50000 5 none 64 3.00E+12 1.57 y +29081 6/13/2013 -70 -59.5 50000 5 none 80 3.00E+12 1.55 y + +29082 6/17/2013 20 21.5 50000 5 Sr-90 64 3.00E+12 1.57 y +29083 6/17/2013 20 21.0 50000 5 Sr-90 80 3.00E+12 1.55 y +29084 6/17/2013 -20 -14.0 50000 5 Sr-90 64 3.00E+12 1.57 y +29085 6/17/2013 -20 -15.0 50000 5 Sr-90 80 3.00E+12 1.55 y +29086 6/17/2013 -70 -54.0 50000 5 Sr-90 64 3.00E+12 1.57 y +29087 6/17/2013 -70 -54.5 50000 5 Sr-90 80 3.00E+12 1.55 y + + +29088 6/20/2013 20 21.0 50000 6 Fe55, dimmed 64 1.00E+13 1.54 y 19 … 21 +29089 6/20/2013 20 21.0 50000 6 Fe55, dimmed 80 1.00E+13 1.53 y +29090 6/20/2013 -20 -16.5 50000 6 Fe55, dimmed 64 1.00E+13 1.54 y -12 … -19 +29091 6/20/2013 -20 -16.5 50000 6 Fe55, dimmed 80 1.00E+13 1.53 y +29092 6/20/2013 -70 -58.5 50000 6 Fe55, dimmed 64 1.00E+13 1.54 y -30 … -60 +29093 6/20/2013 -70 -59.5 50000 6 Fe55, dimmed 80 1.00E+13 1.53 y + +29094 6/18/2013 20 20.5 50000 6 none 64 1.00E+13 1.54 y +29095 6/18/2013 20 20.5 50000 6 none 80 1.00E+13 1.53 y +29096 6/18/2013 -20 -15.5 50000 6 none 64 1.00E+13 1.54 y +29097 6/18/2013 -20 -15.5 50000 6 none 80 1.00E+13 1.53 y +29098 6/19/2013 -70 -60.0 50000 6 none 64 1.00E+13 1.54 y +29099 6/19/2013 -70 -60.0 50000 6 none 80 1.00E+13 1.53 y + +29100 6/24/2013 20 21.0 50000 6 Sr-90 64 1.00E+13 1.54 y +29101 6/24/2013 20 21.0 50000 6 Sr-90 80 1.00E+13 1.53 y +29102 6/24/2013 -20 -15.0 50000 6 Sr-90 64 1.00E+13 1.54 y +29103 6/24/2013 -20 -16.0 50000 6 Sr-90 80 1.00E+13 1.53 y +29104 6/24/2013 -70 -54.5 50000 6 Sr-90 64 1.00E+13 1.54 y +29105 6/24/2013 -70 -55.5 50000 6 Sr-90 80 1.00E+13 1.53 y diff --git a/ProcessMeasurements/LaborbuchMi29.xls b/ProcessMeasurements/LaborbuchMi29.xls new file mode 100755 index 0000000..15ead53 Binary files /dev/null and b/ProcessMeasurements/LaborbuchMi29.xls differ diff --git a/ProcessMeasurements/MAPS.C b/ProcessMeasurements/MAPS.C new file mode 100644 index 0000000..5fc55d2 --- /dev/null +++ b/ProcessMeasurements/MAPS.C @@ -0,0 +1,1046 @@ +#include +#include +#include +#include +#include "Riostream.h" +#include +#include "TString.h" +#include "TMath.h" +#include +#include +#include +#include +#include "TH1.h" +#include "TF1.h" +#include "TROOT.h" +#include +#include "TCanvas.h" +#include "TObject.h" +#include "TStyle.h" +#include "TEnv.h" +#include "TGraph.h" +#include "TGaxis.h" +#include "TStyle.h" +#include "TFrame.h" +#include "TVector.h" +#include "TVectorD.h" +#include "Foption.h" +#include "TRandom.h" +#include "TSpline.h" +#include "TPaveStats.h" +#include "TVirtualFitter.h" +#include "TVirtualPad.h" +#include "TVirtualGraphPainter.h" +#include "TBrowser.h" +#include "TSystem.h" +#include "TPluginManager.h" +#include "TPad.h" +#include +#include +#include +#include + +using namespace std; + +#include"MAPS.h" +//#################################################################### + +MAPS::MAPS() { + +}; + +//#################################################################### + +MAPS::MAPS( TString InDir, TString OutDir, Int_t RunNumber, Int_t Rows, Int_t Columns, TString OrderCode, Int_t SubMatrix, bool Save , Int_t Matrices, Int_t Matrix) { +//----------------------------------------------- + unsigned short int vi,vj; + for (vi = 0; vi <= 0xFF; vi++) { + for (vj = 0; vj <= 0xFF; vj++) { + value2[vi][vj] = (vi + (vj & 0x0F) * 256); + value1[vi][vj] = (vj*16 + (vi & 0xF0) / 16); } } +//----------------------------------------------- +//Set: + fInDir = InDir; + fOutDir = OutDir; + fRunNumber = RunNumber; + fRows = Rows; + fColumns = Columns; + fPixels = fRows * fColumns; + fMatrices = Matrices; + fMatrix = Matrix; + fSubMatrix = SubMatrix; + fBuffer = 4*(fPixels+29); + fSave = Save; + fOk = false; + fOrderCode = OrderCode; +//----------------------------------------------- +//PARAMETER: + TString FILENAME; + Long64_t LENGTH; + + fF0matrix = new Int_t [fPixels]; + fF1matrix = new Int_t [fPixels]; + fCdsmatrix = new Float_t [fPixels]; + fNoise = new Float_t [fPixels]; + fPedestals = new Float_t [fPixels]; + + fNoiseOk = false; +//----------------------------------------------- +//Tell-me + cout<<"-----------------------"<=fMatrices) {cout<<"ERROR: Matrix can only possible if between 0 and "< "<Divide(2,1); + gStyle->SetOptFit(1011); + gStyle->SetPalette(1); + gStyle->SetCanvasColor(0); + gStyle->SetFrameFillColor(10); + gStyle->SetOptStat(0); + + cm3->cd(1); + hint1->Draw("colz"); + hint1->GetXaxis()->SetRangeUser(0, fColumnsSub); + hint1->GetYaxis()->SetRangeUser(0, fRowsSub); + hint1->GetXaxis()->SetTitle("column"); + hint1->GetYaxis()->SetTitle("row"); + hint1->GetZaxis()->SetTitle("Signal [ADC]"); + + cm3->cd(2); + hint2->Draw("col2z"); + hint2->GetXaxis()->SetRangeUser(0, fColumnsSub); + hint2->GetYaxis()->SetRangeUser(0, fRowsSub); + hint2->GetXaxis()->SetTitle("column"); + hint2->GetYaxis()->SetTitle("row"); + hint2->GetZaxis()->SetTitle("Signal [ADC]"); + + cm3->DrawClone(); + cm3->Close(); + cm3->Update(); + } + if(fSave && fOk) + { + fOutputFile->cd(); + + fHitNtup->Write("",TObject::kOverwrite); + fHitsNtup->Write("",TObject::kOverwrite); + fNoiseNtup->Write("",TObject::kOverwrite); +// fMeanNoiseNtup->Write("",TObject::kOverwrite); + fOutputFile->Save(); + fOutputFile->Close(); + + cout<<"-----------------------"<Close(); +// cout<<"...finished!"<ProcessLine("new TBrowser;"); + +// delete[] fOutputFile; +// delete[] fHitNtup; +// delete[] fNoiseNtup; +// delete[] fMeanNoiseNtup; + } + + for(Int_t i=0;i100) + { + warning = true; + } + + for(int column=0; column Common Mode suspiciously high! "<fEventsSum) + { + cout<<"Change Offset from "<Fill(i, NOISE, PEDESTAL); } + } + + cout<<"-----------------------"<IsZombie()) + { + cerr<<"ERROR: loadNoise() failed!"<Get("noise"); + Int_t entries = noiseNtup->GetEntries(); + Float_t *noiseData; + + for(Int_t i=0; iGetEntry(i); + noiseData = noiseNtup->GetArgs(); + + fNoise[i] = noiseData[1]; + fPedestals[i] = noiseData[2]; + } + cout<<"-----------------------"<Divide(2,3); + gStyle->SetOptFit(1011); + gStyle->SetPalette(1); + gStyle->SetCanvasColor(0); + gStyle->SetFrameFillColor(10); + gStyle->SetOptStat(0); + + TH2F *h1 = new TH2F("CDS matrix", "CDS matrix", fColumnsSub, 0, fColumnsSub, fRowsSub, 0, fRowsSub); + TH2F *h2 = new TH2F("Frame 0 matrix", "Frame 0 matrix", fColumnsSub, 0, fColumnsSub, fRowsSub, 0, fRowsSub); + TH2F *h3 = new TH2F("Frame 1 matrix", "Frame 1 matrix", fColumnsSub, 0, fColumnsSub, fRowsSub, 0, fRowsSub); + TH1F *h4 = new TH1F("Frame 0 histo", "Frame 0 histo", 4096, 0, 4096); + TH1F *h5 = new TH1F("Frame 1 histo", "Frame 1 histo", 4096, 0, 4096); + + Int_t column; + Int_t row; + Float_t F0,F1,CDS; + + for(Int_t i=0; iFill(column,row,CDS); + h2->Fill(column,row,F0); + h3->Fill(column,row,F1); + h4->Fill(F0); + h5->Fill(F1); + + } + + cm1->cd(1); + h1->Draw("colz"); + h1->GetXaxis()->SetTitle("column"); + h1->GetYaxis()->SetTitle("row"); + h1->GetZaxis()->SetTitle("Signal [ADC]"); + + cm1->cd(2); + h1->Draw("surf2z"); + h1->GetXaxis()->SetTitle("column"); + h1->GetYaxis()->SetTitle("row"); + h1->GetZaxis()->SetTitle("Signal [ADC]"); + + cm1->cd(3); + h2->Draw("surf2z"); + h2->GetXaxis()->SetTitle("column"); + h2->GetYaxis()->SetTitle("row"); + h2->GetZaxis()->SetTitle("Signal [ADC]"); + + cm1->cd(4); + h3->Draw("surf2z"); + h3->GetXaxis()->SetTitle("column"); + h3->GetYaxis()->SetTitle("row"); + h3->GetZaxis()->SetTitle("Signal [ADC]"); + + cm1->cd(5); + h4->Draw(); + h4->GetXaxis()->SetTitle("Signal [ADC]"); + h4->GetYaxis()->SetTitle("Counts"); + + cm1->cd(6); + h5->Draw(); + h5->GetXaxis()->SetTitle("Signal [ADC]"); + h5->GetYaxis()->SetTitle("Counts"); + + cm1->DrawClone(); + cm1->Close(); + cm1->Update(); + cout<<"\rPIXELMATRIX plotted! "<Divide(2,2); + gStyle->SetOptFit(1011); + gStyle->SetPalette(1); + gStyle->SetCanvasColor(0); + gStyle->SetFrameFillColor(10); + gStyle->SetOptStat(1); + + TH1F *h1 = new TH1F("noisee", "noise", 10000, 0, 100); + TH1F *h2 = new TH1F("pedestal", "pedestal", 10000, -20, 20); + TH2F *h3 = new TH2F("noise matrix", "noise matrix", fColumnsSub, 0, fColumnsSub, fRowsSub, 0, fRowsSub); + TH2F *h4 = new TH2F("pedestal matrix", "pedestal matrix", fColumnsSub, 0, fColumnsSub, fRowsSub, 0, fRowsSub); + + Int_t column; + Int_t row; + Float_t NOISE,PEDESTAL; + + for(Int_t i=0; iFill(NOISE); + h2->Fill(PEDESTAL); + h3->Fill(column,row,NOISE); + h4->Fill(column,row,PEDESTAL); + } + + cm2->cd(1); + h3->Draw("colz"); + h3->GetXaxis()->SetTitle("column"); + h3->GetYaxis()->SetTitle("row"); + h3->GetZaxis()->SetTitle("Noise [ADC]"); + + cm2->cd(2); + h4->Draw("colz"); + h4->GetXaxis()->SetTitle("column"); + h4->GetYaxis()->SetTitle("row"); + h4->GetZaxis()->SetTitle("Pedstals [ADC]"); + + cm2->cd(3); + h1->Draw(); + h1->GetXaxis()->SetTitle("Noise [ADC]"); + h1->GetYaxis()->SetTitle("Counts"); + + cm2->cd(4); + h2->Draw(); + h2->GetXaxis()->SetTitle("Pedestal [ADC]"); + h2->GetYaxis()->SetTitle("Counts"); + + cm2->Update(); + cout<<"NOISE plotted!"<= 0 && (float)(fCdsmatrix[i]-fPedestals[i]) > (5.*fNoise[i]) ) + { + HITNR++; + HITS.Set(HITNR); + HITS.AddAt(i,(HITNR-1)); + + if(plotHint) {hint2->Fill(i%fColumnsSub, (int)(i/fColumnsSub));} + } + } + +//Rewrite HITS to fHitlist array + Hitlist= new Int_t[HITNR]; + + for(Int_t i=0;i Remove hits where the seed pixel is within 2 pixels beside the edge + if (Hitlist[hit]/fColumnsSub < 2 || Hitlist[hit]/fColumnsSub > fRowsSub-3 || Hitlist[hit]%fColumnsSub < 2 || Hitlist[hit]%fColumnsSub > fRowsSub-3) + continue; + + + + + + + + + + + + + + + + + + + + + + + +//Provide 5x5 clusters with CDS - content: + for(Int_t row=0;row<5;row++) + { + for(Int_t column=0;column<5;column++) + { + if ( (row==0) && (A<2) ) {CLUSTER[(row*5)+column]=DUMMY; } + else if ( (row==1) && (A<1) ) {CLUSTER[(row*5)+column]=DUMMY; } + else if ( (row==3) && (A>= (fRowsSub-1)) ) {CLUSTER[(row*5)+column]=DUMMY; } + else if ( (row==4) && (A>= (fRowsSub-2)) ) {CLUSTER[(row*5)+column]=DUMMY; } + else + { + if ( (column==0) && (B<2) ) {CLUSTER[(row*5)+column]=DUMMY; } + else if ( (column==1) && (B==0) ) {CLUSTER[(row*5)+column]=DUMMY; } + else if ( (column==3) && (B==fColumnsSub-1)) {CLUSTER[(row*5)+column]=DUMMY; } + else if ( (column==4) && (B>fColumnsSub-3)) {CLUSTER[(row*5)+column]=DUMMY; } +// else {CLUSTER[(row*5)+column] = fCdsmatrix[Hitlist[hit]+(row-2)*fColumnsSub+(column-2)];} + else {CLUSTER[(row*5)+column] = 1.*fCdsmatrix[Hitlist[hit]+(row-2)*fColumnsSub+(column-2)] - fPedestals[Hitlist[hit]+(row-2)*fColumnsSub+(column-2)] ;} + } + } + } + + + + + + + + + + + + + + + + + + + + + + // Check wether the summed charge of the whole cluster is > 3*noise + Double_t clusterSum=0; + for(Int_t i=0;i<25;i++) + { + clusterSum+=CLUSTER[i];// Charge of whole cluster + + } + if(clusterSum<3.*GetMeanNoise()){continue;} //Cut on whole cluster 3 times Mean(noise) + + + + + + + + + + +//Check seeds (whether highest entry in cluster): +// POSC9=0; + for(Int_t i=6;i<19;i++) + { +// CLUSTER9[POSC9]=CLUSTER[i]; +// POSC9++; + if ( (i!=12) && (CLUSTER[i] > CLUSTER[12]) ) {CHANCE=0; break;} + else if ( (i!=12) && (CLUSTER[i] == CLUSTER[12]) && i>12 ) {CHANCE=0; break;} //NOTE: potential error source + else {CHANCE=100; if(i%5==3) {i+=2;}; } + } + +//Begin: loop evaluate true seeds: + if(CHANCE==100) + { + +//Sort hit-clusters: +// sort(CLUSTER9,9); + +//Hit: centre of mass + hit details +// XCOM=0; +// YCOM=0; +// XV=0; +// YV=-3; +// MALL=0; +// // REST=0; +// for(Int_t i=0; i<25;i++) +// { +// XV=((i%5)-2); +// if(i%5==0){YV++;} +// +// XCOM += CLUSTER[i]*XV; +// YCOM += CLUSTER[i]*YV; +// MALL += CLUSTER[i]; +// +// } +// +// if(MALL!=0) +// { +// XCOM = XCOM/MALL; +// YCOM = YCOM/MALL; +// } +// else +// { +// XCOM = 0; +// YCOM = 0; +// } +//Fill hit ntupel: + HIT_tmp[ 0] = fFrameNumber; + HIT_tmp[ 1] = Hitlist[hit]; + HIT_tmp[ 2] = CLUSTER[0]; + HIT_tmp[ 3] = CLUSTER[1]; + HIT_tmp[ 4] = CLUSTER[2]; + HIT_tmp[ 5] = CLUSTER[3]; + HIT_tmp[ 6] = CLUSTER[4]; + HIT_tmp[ 7] = CLUSTER[5]; + HIT_tmp[ 8] = CLUSTER[6]; + HIT_tmp[ 9] = CLUSTER[7]; + HIT_tmp[10] = CLUSTER[8]; + HIT_tmp[11] = CLUSTER[9]; + HIT_tmp[12] = CLUSTER[10]; + HIT_tmp[13] = CLUSTER[11]; + HIT_tmp[14] = CLUSTER[12]; + HIT_tmp[15] = CLUSTER[13]; + HIT_tmp[16] = CLUSTER[14]; + HIT_tmp[17] = CLUSTER[15]; + HIT_tmp[18] = CLUSTER[16]; + HIT_tmp[19] = CLUSTER[17]; + HIT_tmp[20] = CLUSTER[18]; + HIT_tmp[21] = CLUSTER[19]; + HIT_tmp[22] = CLUSTER[20]; + HIT_tmp[23] = CLUSTER[21]; + HIT_tmp[24] = CLUSTER[22]; + HIT_tmp[25] = CLUSTER[23]; + HIT_tmp[26] = CLUSTER[24]; +// HIT_tmp[27] = XCOM; +// HIT_tmp[28] = YCOM; + + if(fSave) { fHitNtup->Fill(HIT_tmp); } + if(plotHint) {hint1->Fill(Hitlist[hit]%fColumnsSub, (int)(Hitlist[hit]/fColumnsSub));} + HIT_count++; + } + } +//End: loop evaluate true seeds: +//End: loop over all potential seed pixels: + + HITS_tmp[0] = fFrameNumber; + HITS_tmp[1] = HIT_count; + if(fSave) { fHitsNtup ->Fill(HITS_tmp); } + delete[] Hitlist; +}} + +//#################################################################### + +void MAPS::sort(Float_t *array,Int_t size) { + Int_t i = size-1; + Int_t LASTAKTION; + while(i>0) + { + LASTAKTION = 0; + + for(Int_t j=0;jarray[j+1]) + { + swap(&array[j],&array[j+1]); + LASTAKTION = j; + } + } + i = LASTAKTION; + } +} + +//#################################################################### + +void MAPS::swap(Float_t *a,Float_t *b) { + Float_t tmp = *a; + *a = *b; + *b = tmp; +} + +//#################################################################### + +void MAPS::reorderMi26() { + + Int_t matrixF0_tmp[576*1152]; + Int_t matrixF1_tmp[576*1152]; + Int_t matrixCD_tmp[576*1152]; + + Int_t row = 0; + Int_t column = 0; + Int_t block = 0; + Int_t pos; + + for(Int_t i=0; i5 ) + { + cerr<<"ERROR: "<5 ) + { + cerr<<"ERROR: "< +#include +#include + +class MAPS { + +private: + + TString fInDir; + TString fOutDir; + TString fOrderCode; + Int_t fRunNumber; + Int_t fPixels; + Int_t fPixelsSub; + Int_t fRows; + Int_t fRowsSub; + Int_t fColumns; + Int_t fColumnsSub; + Int_t fMatrices; + Int_t fMatrix; + Int_t fSubMatrix; + Int_t fBuffer; + Int_t fEventsSum; + Int_t fFile; + bool fOk; + bool fSave; + ifstream* fInn; + + Int_t *fEvents; + Int_t *fF0matrix; + Int_t *fF1matrix; + Float_t *fCdsmatrix; + Float_t *fNoise; + Float_t *fPedestals; + + TFile *fOutputFile; + TNtuple *fHitNtup; + TNtuple *fHitsNtup; + TNtuple *fNoiseNtup; +// TNtuple *fMeanNoiseNtup; + + TH2F *hint1,*hint2; + bool plotHint; + + Int_t fFrameNumber; + bool fFrameOk; + bool fNoiseOk; + + unsigned short int value1[0x100][0x100]; + unsigned short int value2[0x100][0x100]; + + Float_t HIT_tmp[29]; + Float_t HITS_tmp[2]; + + void sort(Float_t *array,Int_t size); + void swap(Float_t *a,Float_t *b); + void reorderMi26(); + void reorderMi29a(); + void reorderMi29b(); + +public: + + MAPS(); + MAPS( TString InDir, TString OutDir, Int_t RunNumber, Int_t Rows, Int_t Columns, TString OrderCode="", Int_t SubMatrix=0, bool Save=1, Int_t Matrices=1, Int_t Matrix=0); + ~MAPS(void); + bool getFrame(Int_t FrameNumber); + bool getNoise(Int_t Frames, Int_t Offset=0, bool Mode=0); + bool setNoise(Float_t Noise); + bool loadNoise(TString InDir, Int_t RunNumber, Int_t SubMatrix, Int_t Matrix=0); + bool setPedestals(Float_t Pedestals); + void hitana(); + void filterCommonMode(); + void plotFrame(void); + void plotNoise(void); + Float_t GetMeanNoise(); + + Int_t GetNumberRun() { return fRunNumber; } + Int_t GetNumberEvents() { return fEventsSum; } + Int_t GetNumberPixels() { return fPixels; } + Int_t GetNumberRows() { return fRows; } + Int_t GetNumberColumn() { return fColumns; } + Float_t* GetCDSFrame() { return fCdsmatrix; } + Int_t* GetF0Frame() { return fF0matrix; } + Int_t* GetF1Frame() { return fF1matrix; } + Float_t* GetNoise() { return fNoise; } +// +// Int_t GetEventNumber() { return EventNumber; } +// Int_t GetBoardNumber() { return BoardNumber; } +// Int_t GetNumberOfTriggers() { return ListOfTriggers->size(); } +// vector* GetTriggers() { return ListOfTriggers; } +// Int_t GetTriggerAt(Int_t index) { return ListOfTriggers->at(index); } +// Int_t GetNumberOfFrames() { return ListOfFrames->size(); } +// Int_t GetFrameAt(Int_t index) { return ListOfFrames->at(index); } +// Int_t GetNumberOfPixels() { return ListOfPixels->size(); } +// vector* GetPixels() { return ListOfPixels; } +// Int_t GetPixelAt(Int_t index) { return ListOfPixels->at(index); } +// vector* GetPixelEntries() { return ListOfPixelEntries; } +// Int_t GetPixelEntryAt(Int_t index) { return ListOfPixelEntries->at(index); } + +}; + + +#endif \ No newline at end of file diff --git a/ProcessMeasurements/ProcessMeasurements.C b/ProcessMeasurements/ProcessMeasurements.C new file mode 100644 index 0000000..4fdb718 --- /dev/null +++ b/ProcessMeasurements/ProcessMeasurements.C @@ -0,0 +1,214 @@ +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "TRandom1.h" +#include "CSVRow.h" +#include "analyzeRun.h" + +#define COLRUNNO 0 +#define COLTEMP 2 +#define COLTEMPSENS 3 +#define COLCHIP 5 +#define COLSOURCE 6 +#define COLMATRIX 7 +#define COLDONE 10 + +#define LABORBUCH "LaborbuchMi29.csv" +#define INPUTDATAPATH "/jspc12_F/Mi29/" +#define OUTPUTDATAPATH_MAINFOLDER "/local/sstrohauer/data/" + +using std::cout; +using std::endl; + +struct noiseRun {Int_t runNo; Float_t temperature; Int_t chip; Int_t matrix6480;}; + +void ProcessMeasurements(Bool_t overwrite = false, Bool_t useSeperateNoiseRun = true, Int_t processRunNo = -1, std::string matrixAB = "Mi29a", Int_t seperateNoiseRunNo = -1) { + + Bool_t runIsNoise; // is current run a noise run or with source? + Int_t runNo; // run number + Float_t temperature; // desired temperature + Float_t tempSens; // actual temperature + Int_t chip; // chip number (eg. 1-6) + Int_t matrix6480; // which matrix? + Bool_t runFinished; // measurement already done? + std::string source; + std::vector noiseRunList; // here we store all run numbers which are a noise run + std::ofstream logfile; + + timeval start, end; + int diff; + gettimeofday(&start, 0); + + // ---------------- + // create logfile + time_t timestamp; + tm *now; + timestamp = time(0); + now = localtime(×tamp); + std::stringstream timeSS; + timeSS << now->tm_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"; + 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"; + logfile.close(); + // ---------------- + + + std::string outputDataPath = std::string(OUTPUTDATAPATH_MAINFOLDER) + "data_" + timeSS.str() + "/"; + mkdir(outputDataPath.c_str(), 0755); // create directory for this evaluation if not existent + + // 1. case: Process one single run, chosen by the user while calling main() + if (processRunNo != -1){ + if (useSeperateNoiseRun){ + mkdir((outputDataPath + std::to_string(seperateNoiseRunNo) +"/").c_str(), 0755); // create directory if not existent + mkdir((outputDataPath + std::to_string(processRunNo) +"/").c_str(), 0755); // create directory if not existent + // use seperate files for noise and run + analyzeRun(INPUTDATAPATH, outputDataPath.c_str(), seperateNoiseRunNo, matrixAB, true, true, -1, overwrite, logfileName); // noise + analyzeRun(INPUTDATAPATH, outputDataPath.c_str(), processRunNo, matrixAB, true, false, seperateNoiseRunNo, overwrite, logfileName); // run + } + else { + mkdir((outputDataPath + std::to_string(processRunNo) +"/").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(processRunNo) + "/").c_str(), 0755); // create directory if not existent + // use same run for calculating noise + analyzeRun(INPUTDATAPATH, outputDataPath.c_str(), processRunNo, matrixAB, false, false, -1, overwrite, logfileName); // noise & run + } + return; // that's all if processing a single run + } + + // 2. case: Go through lab journal. In a first iteration analyze all noise data, in the second iteration analyze all runs + for (Int_t firstNoiseSecondRun = 0; firstNoiseSecondRun < 2; firstNoiseSecondRun++){ + std::ifstream file(LABORBUCH); + CSVRow row; + + file >> row; // read first row (header) of the laboratory book + + if (firstNoiseSecondRun == 0){ + cout << "=====================================================================\n"; + cout << "=====================================================================\n"; + cout << "First: Analyzing only runs WITH NO source (for noise)...\n"; + } + else{ + cout << "=====================================================================\n"; + cout << "=====================================================================\n"; + cout << "Second: Analyzing only runs WITH source...\n"; + } + while(file >> row) { // for each row + + try { + if (row[COLRUNNO] == "") + continue; // no relevant data in this row + runNo = stoi(row[COLRUNNO]); // run number (conversion works like runNo = stoi(std::string ("300");) + temperature = stod(row[COLTEMP]); // temperature + tempSens = stod(row[COLTEMPSENS]); // temperature + chip = stoi(row[COLCHIP]); + source = row[COLSOURCE]; + matrix6480 = stoi(row[COLMATRIX]); // which matrix? + runFinished = row[COLDONE] == "y"; // measurement already done? + + // print info about current run to process + cout << "\n\n=========================\n"; + cout << "runNo\t" << "tempSens\t" << "matrix6480\t" << "runFinished\t\n"; + if (runFinished) + cout << runNo << "\t" << tempSens << "\t\t" << matrix6480 << "\t\t" << runFinished << endl; + else { + cout << runNo << "\t" << tempSens << "\t\t" << matrix6480 << "\t\t" << runFinished << " ======> skipped because measurement not done yet" << endl; + continue; + } + + if (matrix6480 == 64) + matrixAB = "Mi29a"; + else if (matrix6480 == 80) + matrixAB = "Mi29b"; + else + cout << "Unknown matrix! 64 and 80 are allowed values.\n"; + + + if (source == "none" && firstNoiseSecondRun == 0 && useSeperateNoiseRun){ + mkdir((outputDataPath + row[COLRUNNO] +"/").c_str(), 0755); // create directory if not existent + // analyze noise in the first for loop + noiseRun tmpnoiseRun = {runNo, temperature, chip, matrix6480}; + noiseRunList.push_back(tmpnoiseRun); // store noiseRun in list + analyzeRun(INPUTDATAPATH, outputDataPath.c_str(), runNo, matrixAB.c_str(), true, true, -1, overwrite, logfileName); + } + else if (source != "none" && firstNoiseSecondRun == 1){ + mkdir((outputDataPath + row[COLRUNNO] +"/").c_str(), 0755); // create directory if not existent + // analyze run in second for loop + Int_t noiseRunNo; + for(std::vector::iterator it = noiseRunList.begin(); it != noiseRunList.end(); ++it){ + if ((it->temperature == temperature) && (it->chip == chip) && (it->matrix6480 == matrix6480)) + noiseRunNo = it->runNo; // get correct noiseRun number for this run + } + if (!noiseRunNo){ + cout << "Corresponding noise run to run number " << runNo << " not found! ===> skipped\n"; + continue; + } + analyzeRun(INPUTDATAPATH, outputDataPath.c_str(), runNo, matrixAB, true, false, noiseRunNo, overwrite, logfileName); + } + else { + cout << "==> skipped in " << firstNoiseSecondRun+1 << ". step (currently processing " << ((firstNoiseSecondRun == 0) ? "noise)":"runs)") << endl; + } + } + catch(...){ + cout << "Error while reading laboratory book (run number " << runNo << ")!\n"; + } + + } + + } + + // copy file to output folder + std::ifstream src(logfileName, std::ios::binary); + std::ofstream dst(outputDataPath + logfileName, std::ios::binary); + dst << src.rdbuf(); + + gettimeofday(&end, 0); + diff = (int) (end.tv_sec-start.tv_sec); + printf("\nElasped Time: %02i:%02i:%02i\n",(int)((diff%86400)/3600),(int)((diff%3600)/60),(int)(diff%60) ); + +} + + +# ifndef __CINT__ +int main(int argc, char* argv[]) +{ + Bool_t overwrite = false; + Bool_t useSeperateNoiseRun = true; + Int_t processRunNo = -1; + std::string matrixAB = "Mi29a"; + Int_t seperateNoiseRunNo = -1; + + switch(argc){ + case 6: seperateNoiseRunNo = std::stoi(argv[5]); + case 5: matrixAB = argv[4]; + case 4: processRunNo = std::stoi(argv[3]); + case 3: useSeperateNoiseRun = !strcmp(argv[2], "1"); + case 2: overwrite = !strcmp(argv[1], "1"); + } + + cout << "---------------------- Parameters --------------------------\n"; + cout << "Usage:\nmain [BOOL overwrite?] [BOOL use seperate noise run?] [INT run number to process] [STRING matrixAB] [INT run number for seperate noise file]\n\n"; + cout << "Values chosen:\n"; + cout << "Overwrite: " << overwrite << (overwrite ? " (yes)\n":" (no)\n"); + cout << "Use seperate noise run: " << useSeperateNoiseRun << (useSeperateNoiseRun ? " (yes)\n":" (no)\n"); + cout << "Run number to process (default (-1): using the lab journal): " << processRunNo << endl; + cout << "Noise run number to use (default (-1): using the lab journal): " << seperateNoiseRunNo << endl; + cout << "Input directory: " << INPUTDATAPATH << endl; + cout << "Output directory: " << OUTPUTDATAPATH_MAINFOLDER << endl; + cout << "------------------------------------------------------------\n\n"; + + + ProcessMeasurements(overwrite, useSeperateNoiseRun, processRunNo, matrixAB, seperateNoiseRunNo); + return 0; +} +# endif \ No newline at end of file diff --git a/ProcessMeasurements/analyzeRun.C b/ProcessMeasurements/analyzeRun.C new file mode 100644 index 0000000..acfafd0 --- /dev/null +++ b/ProcessMeasurements/analyzeRun.C @@ -0,0 +1,157 @@ +#include "analyzeRun.h" + +#include +#include +#include +//#include +#include +#include +#include +#include + + + + + + + +#include + + + + + + + + + + +#include "TString.h" + +#include "MAPS.h" + +#define NUMEVENTSFORNOISE 1000 + +void analyzeRun(const char *const inputDataPath, const char *const outputDataPath, Int_t runNo, std::string matrixAB, Bool_t useSeperateNoiseRun, Bool_t runIsNoise, Int_t noiseRunNo, Bool_t overwrite, std::string logfileName) +{ + using namespace std; + + Int_t matrixNoRows; + Int_t matrixNoCoulmns; + Int_t numSubmatrices; + std::ofstream logfile; + Int_t b=0; + Int_t b_tmp=0; + + if (matrixAB == "Mi29a"){ + matrixNoRows = 272; + matrixNoCoulmns = 48; + numSubmatrices = 6; + } + else if (matrixAB == "Mi29b"){ + matrixNoRows = 256; + matrixNoCoulmns = 51; + numSubmatrices = 6; + } + else { + cout << "This matrix (" << matrixAB << ") does not exist! Please choose either Mi29a or Mi29b.\n"; + return; + } + + + for (Int_t submatrix = 0; submatrix < numSubmatrices; submatrix++){ + logfile.open(logfileName, std::ios::out | std::ios::app); + + // file exists already? + TString pathString = TString(outputDataPath) + Form("%i/%i_0_%i.root", runNo, runNo, submatrix); //std::to_string(runNo) + "/" + std::to_string(runNo) + "_" + matrixAorB + "_" + std::to_string(submatrix) + ".root"; + TFile f(pathString); + if (!f.IsZombie() && !overwrite) { + // file exists, so skip it! + cout << pathString << " does already exist! ==> skipped\n\n"; + logfile << runNo << "\t" << matrixAB << "\t" << submatrix << "\talready exists ==> skipped\n"; + logfile.close(); + continue; // skip this submatrix if file already exists + } + else { + cout << "\n" << pathString << " ==> processing now...\n\n"; + } + + + if (runIsNoise) { + MAPS *mapsi = new MAPS(inputDataPath,outputDataPath,runNo,matrixNoRows,matrixNoCoulmns,matrixAB.c_str(),submatrix); + mapsi->getNoise(NUMEVENTSFORNOISE,0,0); + delete mapsi; + logfile << runNo << "\t" << matrixAB << "\t" << submatrix << "\tprocessed as NOISE\n"; + } + else { + std::string noiseOutputDataPath = std::string(outputDataPath); + if (!useSeperateNoiseRun){ + MAPS *mapsiNoise = new MAPS(inputDataPath,std::string(outputDataPath)+"noise/",runNo,matrixNoRows,matrixNoCoulmns,matrixAB.c_str(),submatrix); + mapsiNoise->getNoise(NUMEVENTSFORNOISE,0,0); + delete mapsiNoise; + logfile << runNo << "\t" << matrixAB << "\t" << submatrix << "\tprocessed as NOISE\n"; + noiseRunNo = runNo; + noiseOutputDataPath = std::string(outputDataPath)+"noise/"; +// int pipi; +// cin >> pipi; +// cout << "hi2"; + } + + MAPS *mapsi = new MAPS(inputDataPath,outputDataPath,runNo,matrixNoRows,matrixNoCoulmns,matrixAB.c_str(),submatrix); + Int_t events = mapsi->GetNumberEvents(); + mapsi->loadNoise(noiseOutputDataPath, noiseRunNo, submatrix); + for(Int_t i=0; igetFrame(i); + mapsi->filterCommonMode(); + mapsi->hitana(); + + if(i==103) + mapsi->plotFrame(); + + b = (Int_t)(((i+1)*100)/(events)*10); + if(b!=b_tmp) + printf("\r---> %4i%% %10i Frames processed!", (100*i/(events-1)), i+1 ); fflush(stdout); b_tmp=b; // In 10% steps + } + cout< + +void analyzeRun(const char *const inputDataPath, const char *const outputDataPath, Int_t runNo, std::string matrixAB, Bool_t useSeperateNoiseRun, Bool_t runIsNoise, Int_t noiseRunNo, Bool_t overwrite, std::string logfileName); + +#endif \ No newline at end of file