--- /dev/null
+#include "CSVRow.h"
+
+#include <iostream>
+#include <sstream>
+#include <vector>
+#include <string>
+
+
+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;
+}
+
--- /dev/null
+#ifndef CSVROW_H
+#define CSVROW_H
+
+
+#include <vector>
+#include <string>
+
+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<std::string> m_data;
+};
+
+//std::istream& operator>>(std::istream& str,CSVRow& data);
+
+#endif
--- /dev/null
+#include <iostream>
+#include <fstream>
+#include <vector>
+#include <string>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <stdlib.h>
+
+#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<TH1F*> histNtuple;
+ std::vector<TH1F*> histNtupleSum;
+ std::vector<TH1F*> histNtupleVeto;
+ Int_t nHistNtuple = 0;
+ std::vector<std::string> runDetails;
+ std::vector<Float_t> fitMaxPosX;
+ std::vector<Float_t> fitMaxPosXSum;
+ std::vector<Float_t> 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; cnt<NUMPIXELS; cnt++) {
+ hitNtuple->SetBranchAddress(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; cnt<nentries; cnt++) {
+ hitNtuple->GetEntry(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; i<NUMPIXELS; i++){
+ pixelSum += pixel[i];
+ }
+ histNtupleSum[nHistNtuple]->Fill(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<NUMPIXELS; i++)
+ notSeedSum += pixel[i];
+ if (abs(notSeedSum) > VETO_THRESHOLD)
+ continue;
+// meanNotSeedSum+=notSeedSum;
+// nhits++;
+ histNtupleVeto[nHistNtuple]->Fill(pixel[12]); // histogram with the single pixel
+
+ }
+// cout<<"Mittelwert"<<meanNotSeedSum/nhits<<endl;
+
+
+ histNtuple[nHistNtuple]->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<TH1F*>::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<TH1F*>::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<TH1F*>::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<TH1F*>::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<TH1F*>::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<TH1F*>::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; i<runDetails.size(); ++i){
+// cout << runDetails[i] << Form("\t%.2f", fitMaxPosX[i]) << Form("\t%.2f", fitMaxPosXSum[i]) << endl;
+ cout << runDetails[i] << (DRAW_SINGLE_HISTOGRAMS ? Form("\t%.2f", fitMaxPosX[i]):"") << (DRAW_SUMMED_HISTOGRAMS ? Form("\t%.2f", fitMaxPosXSum[i]):"") << (DRAW_VETO_HISTOGRAMS ? Form("\t%.2f", fitMaxPosXVeto[i]):"") << endl;
+ }
+
+
+ gettimeofday(&end, 0);
+ diff = (int) (end.tv_sec-start.tv_sec);
+ if (PRINT_HEADER)
+ printf("\nElasped Time: %02i:%02i:%02i\n",(int)((diff%86400)/3600),(int)((diff%3600)/60),(int)(diff%60) );
+
+}
+
+
+
+
+// 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");
+
+// 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; i<nentries) {
+// hist->Fill()
+// }
+// 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");
+
--- /dev/null
+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
--- /dev/null
+#include "CSVRow.h"
+
+#include <iostream>
+#include <sstream>
+#include <vector>
+#include <string>
+
+
+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;
+}
+
--- /dev/null
+#ifndef CSVROW_H
+#define CSVROW_H
+
+
+#include <vector>
+#include <string>
+
+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<std::string> m_data;
+};
+
+std::istream& operator>>(std::istream& str,CSVRow& data);
+
+#endif
\ No newline at end of file
--- /dev/null
+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
--- /dev/null
+#include <stdlib.h>
+#include <TClass.h>
+#include <fstream>
+#include <iostream>
+#include "Riostream.h"
+#include <string>
+#include "TString.h"
+#include "TMath.h"
+#include <TFile.h>
+#include <TNtuple.h>
+#include <TH1F.h>
+#include <TH2F.h>
+#include "TH1.h"
+#include "TF1.h"
+#include "TROOT.h"
+#include <TApplication.h>
+#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 <TQObject.h>
+#include <TMultiGraph.h>
+#include <iostream>
+#include <fstream>
+
+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<<"-----------------------"<<endl;
+ cout<<"Initiate MAPS() ..."<<endl;
+ cout<<"--------------"<<endl;
+ cout<<"Input Directory : "<<fInDir<<endl;
+ cout<<"Output Directory : "<<fOutDir<<endl;
+ cout<<"Runnumber : "<<fRunNumber<<endl;
+ cout<<"Pixels : "<<fRows<<" x "<<fColumns<<endl;
+ cout<<"Matrices : "<<fMatrices<<endl;
+ cout<<"Matrix to scan : "<<fMatrix<<endl;
+ cout<<"Sub-Matrix to scan : "<<fSubMatrix<<endl;
+ cout<<"Ordering according to : "<<fOrderCode<<endl;
+ cout<<"Save/Overwrite data : "<<fSave<<endl;
+ if(fMatrix>=fMatrices) {cout<<"ERROR: Matrix can only possible if between 0 and "<<fMatrices-1<<"!"<<endl;}
+ cout<<"-----------------------"<<endl;
+//-----------------------------------------------
+//Count Files
+ fFile = -1;
+ ifstream inn;
+
+ do
+ {
+ fFile++;
+ FILENAME=fInDir+Form("%i/RUN_%i_%i.rz",fRunNumber,fRunNumber,fFile);
+ inn.open(FILENAME, ios::binary);
+ inn.close();
+ }while(inn.good());
+//-----------------------------------------------
+//Check and open Data Files
+ fEvents = new Int_t [fFile];
+ fInn = new ifstream [fFile];
+ fEventsSum = 0;
+
+ for(Int_t j=0;j<fFile;j++)
+ {
+ FILENAME=fInDir+Form("%i/RUN_%i_%i.rz",fRunNumber,fRunNumber,j);
+ fInn[j].open(FILENAME, ios::binary);
+ fInn[j].seekg(0, ios::beg);
+ fInn[j].seekg(0, ios::end);
+ LENGTH = fInn[j].tellg();
+ fEvents[j] = (Int_t)(LENGTH/fBuffer/fMatrices);
+ fEventsSum += fEvents[j];
+ fInn[j].seekg(0, ios::beg);
+
+ Float_t TMP = (Float_t)(LENGTH)*10./fBuffer/fMatrices;
+ if(((Int_t)(TMP))%10!=0){cout<<"Irregularities have occurred! Check specifications: Matrices .. Matrix! Errors may occur..."<<endl;}
+
+// cout<<Form("RUN_%i_%i.rz",fRunNumber,j)<<" found!\t"<<(Float_t)(LENGTH/1048576.)<<" MBytes"<<"\t"<<LENGTH<<" Bytes"<< "\t--> "<<fEvents[j]<<" Frames"<<endl;
+
+ fOk = true;
+ }
+ cout<<"-----------------------"<<endl;
+//-----------------------------------------------
+//Open Output File:
+ if(fSave && fOk)
+ {
+ FILENAME = fOutDir+Form("%i/%i_%i_%i.root",fRunNumber,fRunNumber,fMatrix,fSubMatrix);
+ cout<<"File '"<<FILENAME<<"' recreated!"<<endl;
+ fOutputFile = new TFile(FILENAME,"RECREATE");
+// fHitNtup = new TNtuple("hit", "hit", "frame:pixel:p1:p2:p3:p4:p5:p6:p7:p8:p9:p10:p11:p12:p13:p14:p15:p16:p17:p18:p19:p20:p21:p22:p23:p24:p25:xpos:ypos");
+ fHitNtup = new TNtuple("hit", "hit", "frame:pixel:p1:p2:p3:p4:p5:p6:p7:p8:p9:p10:p11:p12:p13:p14:p15:p16:p17:p18:p19:p20:p21:p22:p23:p24:p25");
+ fHitsNtup = new TNtuple("hits", "hits", "frame:counts");
+ fNoiseNtup = new TNtuple("noise", "noise", "pixel:noise:pedestal");
+// fMeanNoiseNtup = new TNtuple("meannoise", "meannoise", "frame:noise:pedestal");
+ cout<<"-----------------------"<<endl;
+ }
+
+ if(!fOk){cout<<"No files found!"<<endl;}
+
+//-----------------------------------------------
+ plotHint = false;
+ hint1 = new TH2F("Hitmulit", "Hit multiplicity", fColumns, 0, fColumns, fRows, 0, fRows);
+ hint2 = new TH2F("Pixmulit", "Pix multiplicity", fColumns, 0, fColumns, fRows, 0, fRows);
+//-----------------------------------------------
+}
+
+//####################################################################
+
+MAPS::~MAPS(void) {
+
+ if(plotHint)
+ {
+ TCanvas* cm3;
+ cm3 = new TCanvas("cc23","Matrix",50,100,1200,800);
+ cm3->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<<"-----------------------"<<endl;
+ cout<<"Ntuples written!"<<endl;
+ cout<<"File '"<<fOutDir+Form("%i/%i_%i_%i.root",fRunNumber,fRunNumber,fMatrix,fSubMatrix)<<"' saved!"<<endl;
+ //fOutputFile->Close();
+// cout<<"...finished!"<<endl;
+ cout<<"-----------------------"<<endl;
+
+// TString FILENAME = fOutDir+Form("%i/%i_%i_%i.root",fRunNumber,fRunNumber,fMatrix,fSubMatrix);
+// TFile::Open(FILENAME);
+// gROOT->ProcessLine("new TBrowser;");
+
+// delete[] fOutputFile;
+// delete[] fHitNtup;
+// delete[] fNoiseNtup;
+// delete[] fMeanNoiseNtup;
+ }
+
+ for(Int_t i=0;i<fFile;i++)
+ {
+ fInn[i].close();
+ }
+
+ delete[] fEvents;
+ delete[] fF0matrix;
+ delete[] fF1matrix;
+ delete[] fCdsmatrix;
+ delete[] fNoise;
+ delete[] fPedestals;
+
+};
+
+//####################################################################
+
+bool MAPS::getFrame(Int_t FrameNumber) {
+
+ fFrameNumber = FrameNumber;
+
+ if(fFrameNumber<fEventsSum)
+ {
+ Int_t EVENTSUM = 0;
+ Int_t FFILE=0;
+
+ for(Int_t i=0; i<fFile;i++)
+ {
+ EVENTSUM+=fEvents[i];
+
+ if(fFrameNumber<EVENTSUM) {FFILE=i; EVENTSUM-=fEvents[i]; break;}
+ }
+
+ Int_t POSFILE = fBuffer*fMatrices*fFrameNumber + fBuffer*fMatrix - fBuffer*fMatrices*EVENTSUM;
+ Int_t HDRLENGTH = 4*28;
+ Int_t BYTELENGTH = 4*fPixels;
+
+ char* HDRDATA; //delete[] HDRDATA;
+ char* RAWDATA; //delete[] RAWDATA;
+ HDRDATA = new char[HDRLENGTH];
+ RAWDATA = new char[BYTELENGTH];
+
+ fInn[FFILE].seekg(POSFILE, ios::beg);
+ fInn[FFILE].read(HDRDATA,HDRLENGTH);
+ fInn[FFILE].read(RAWDATA,BYTELENGTH);
+
+ Int_t COUNT=0;
+ for(Int_t i=0;i<BYTELENGTH;i+=4)
+ {
+ fF0matrix[COUNT] = value1 [(UChar_t)RAWDATA[i+1]] [(UChar_t)RAWDATA[i+2]];
+ fF1matrix[COUNT] = value2 [(UChar_t)RAWDATA[i]] [(UChar_t)RAWDATA[i+1]];
+
+ fCdsmatrix[COUNT] = fF0matrix[COUNT]- fF1matrix[COUNT];
+ COUNT++;
+ }
+
+ if (fOrderCode == "") { fPixelsSub=fPixels; fRowsSub=fRows, fColumnsSub=fColumns; }
+ else if (fOrderCode == "Mi26") { reorderMi26(); }
+ else if (fOrderCode == "Mi29a") { reorderMi29a(); }
+ else if (fOrderCode == "Mi29b") { reorderMi29b(); }
+
+ delete[] HDRDATA;
+ delete[] RAWDATA;
+
+ fFrameOk = true;
+ return true;
+ }
+ else
+ {
+ cout<<"Event number: "<<fFrameNumber<<" is too big! Max: "<<fEventsSum<<endl;
+ fFrameOk = false;
+ return false;
+ }
+};
+
+//####################################################################
+
+void MAPS::filterCommonMode() {
+
+ Float_t CommonModeInRow = 0;
+ // Int_t Count = 0;
+ bool warning = false;
+
+ Float_t* Arr = new Float_t[fColumns];
+
+ for(int row=0; row<fRows; row++ )
+ {
+ CommonModeInRow = 0;
+ // Count = 0;
+
+ for(int column=0; column<fColumns; column++ )
+ {
+ // CommonModeInRow += fCdsmatrix[ row*fColumns+column ];
+ Arr[column] = fCdsmatrix[ row*fColumns+column ];
+ }
+
+ // CommonModeInRow = CommonModeInRow/fColumns;
+ CommonModeInRow = TMath::Median(fColumns, Arr);
+ // cout<<CommonModeInRow<<endl;
+ // CommonModeInRow = 0;
+ if(TMath::Abs(CommonModeInRow)>100)
+ {
+ warning = true;
+ }
+
+ for(int column=0; column<fColumns; column++ )
+ {
+ // cout<<CommonModeInRow<<"\t"<<fCdsmatrix[ row*fColumns+column ]<<"\t";
+ fCdsmatrix[ row*fColumns+column ] = fCdsmatrix[ row*fColumns+column ] - CommonModeInRow;
+ // cout<<fCdsmatrix[ row*fColumns+column ]<<endl;
+ }
+ }
+
+ if(warning) { cout<<"\rFrame: "<<fFrameNumber<<" --> Common Mode suspiciously high! "<<endl; }
+}
+
+//####################################################################
+
+bool MAPS::getNoise(Int_t Frames, Int_t Offset, bool Mode) {
+//Noise + Pedestals
+// if(fNoiseOk){cout<<"Noise has been already set!"<<endl;}
+ if(fNoiseOk){cout<<"Noise already calculated!"<<endl; return true;}
+ if(!Mode)
+ {
+ cout<<"Run getNoise() ..."<<endl;
+//Check amount of Frames
+ if(Frames<50)
+ {
+ cout<<"Too few Frames! Change Frames from "<<Frames<<" to ";
+ Frames = 50;
+ cout<<Frames<<" !"<<endl;
+ }
+//Check availabilty of Frames
+ if(Frames+Offset>fEventsSum)
+ {
+ cout<<"Change Offset from "<<Offset<<" to ";
+ Offset = fEventsSum-Frames;
+ cout<<Offset<<" !"<<endl;
+ }
+// Get fPixelsSub and allocate array
+ getFrame(0);
+
+ Int_t *ARR = new Int_t[Frames*fPixelsSub];
+ Float_t PEDESTAL;
+ Float_t NOISE;
+
+ for(Int_t i=Offset; i<Frames+Offset;i++)
+ {
+ getFrame(i);
+
+ for(Int_t j=0; j<fPixelsSub;j++)
+ {
+ ARR[(i-Offset)*fPixelsSub+j] = fCdsmatrix[j];
+ }
+ }
+
+ for(Int_t i=0; i<fPixelsSub;i++)
+ {
+ PEDESTAL = 0;
+ NOISE = 0;
+
+ for(Int_t j=0; j<Frames;j++)
+ {
+ PEDESTAL+=ARR[j*fPixelsSub+i];
+ }
+
+ PEDESTAL = PEDESTAL/Frames;
+
+ for(Int_t j=0; j<Frames;j++)
+ {
+ NOISE+=TMath::Power(ARR[j*fPixelsSub+i]-PEDESTAL,2);
+ }
+
+ NOISE = TMath::Sqrt(NOISE/(Frames-1));
+
+ fNoise[i] = NOISE;
+ fPedestals[i] = PEDESTAL;
+
+ if(fSave) { fNoiseNtup->Fill(i, NOISE, PEDESTAL); }
+ }
+
+ cout<<"-----------------------"<<endl;
+
+ delete[] ARR;
+ fNoiseOk = true;
+ return true;
+ }
+ else
+ {
+ fNoiseOk = false;
+ return false;
+ }
+};
+
+//####################################################################
+
+bool MAPS::loadNoise( TString InDir, Int_t RunNumber, Int_t SubMatrix, Int_t Matrix) {
+
+ TString FILENAME = InDir+Form("%i/%i_%i_%i.root",RunNumber,RunNumber,Matrix,SubMatrix);
+ TFile *f = new TFile(FILENAME,"READ");
+
+ if(f->IsZombie())
+ {
+ cerr<<"ERROR: loadNoise() failed!"<<endl;
+ cerr<<FILENAME<<" not found!"<<endl;
+ cerr<<"-----------------------"<<endl;
+ return false;
+ exit(-1);
+ }
+ else
+ {
+ cout<<"Noise/Pedestals loaded from:"<< FILENAME << "!"<<endl;
+
+ TNtuple *noiseNtup = (TNtuple*) f->Get("noise");
+ Int_t entries = noiseNtup->GetEntries();
+ Float_t *noiseData;
+
+ for(Int_t i=0; i<entries; i++)
+ {
+ noiseNtup->GetEntry(i);
+ noiseData = noiseNtup->GetArgs();
+
+ fNoise[i] = noiseData[1];
+ fPedestals[i] = noiseData[2];
+ }
+ cout<<"-----------------------"<<endl;
+ fNoiseOk = true;
+ return true;
+ }
+};
+
+//####################################################################
+
+Float_t MAPS::GetMeanNoise() {
+ Float_t noiseMean=0;
+ for(Int_t pix=0;pix<fPixelsSub;pix++)
+ {
+ noiseMean+=fNoise[pix];
+
+ }
+ noiseMean=noiseMean/fPixelsSub;
+ return noiseMean;
+ };
+
+//####################################################################
+
+bool MAPS::setNoise(Float_t Noise) {
+
+ for(Int_t i=0; i<fPixelsSub; i++)
+ {
+ fNoise[i] = Noise;
+ }
+
+ fNoiseOk = true;
+ return true;
+};
+
+//####################################################################
+
+bool MAPS::setPedestals(Float_t Pedestals) {
+
+ for(Int_t i=0; i<fPixelsSub; i++)
+ {
+ fPedestals[i] = Pedestals;
+ }
+
+// fNoiseOk = true;
+ return true;
+};
+
+//####################################################################
+
+void MAPS::plotFrame() {
+
+ if(!fFrameOk) {cout<<"No frame loaded!"<<endl;}
+ else {
+
+ TCanvas* cm1;
+ cm1 = new TCanvas("cc2","Matrix",50,100,1200,800);
+ cm1->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; i<fPixelsSub;i++)
+ {
+ row = i/fColumnsSub;
+ column = i%fColumnsSub;
+
+ CDS = fCdsmatrix[i];
+ F0 = fF0matrix[i];
+ F1 = fF1matrix[i];
+
+ h1->Fill(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! "<<endl;
+ cout<<"-------------------"<<endl;
+ }
+}
+
+//####################################################################
+
+void MAPS::plotNoise() {
+
+ if(!fNoiseOk) {cout<<"Noise/Pedestals not calculated/set!"<<endl;}
+ else {
+
+ getFrame(0);
+ TCanvas* cm2;
+ cm2 = new TCanvas("cc3","Noise",50,100,1200,800);
+ cm2->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; i<fPixelsSub;i++)
+ {
+
+ column = i%fColumnsSub;
+ row = i/fColumnsSub;
+ NOISE = fNoise[i];
+ PEDESTAL = fPedestals[i];
+
+ h1->Fill(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!"<<endl;
+ cout<<"-------------------"<<endl;
+ }
+}
+
+//####################################################################
+
+void MAPS::hitana() {
+
+ if(!fFrameOk) {cout<<"No frame loaded!"<<endl;}
+ else if(!fNoiseOk) {cout<<"Noise/Pedestals not set!"<<endl;}
+ else {
+
+//Local variables
+ TArrayI HITS;
+ Int_t HITNR = 0;
+ Int_t *Hitlist;
+ Int_t A;
+ Int_t B;
+ Int_t DUMMY=0;
+ Float_t CLUSTER[25];
+// Float_t CLUSTER9[9];
+// Int_t POSC9;
+ Int_t CHANCE;
+// Float_t XCOM;
+// Float_t YCOM;
+// Int_t XV;
+// Int_t YV;
+// Float_t MALL;
+// Float_t REST;
+
+ for(Int_t i=0; i<fPixelsSub; i++)
+ {
+ if( (float)(fCdsmatrix[i]-fPedestals[i]) >= 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<HITNR;i++)
+ {
+ Hitlist[i]=HITS.At(i);
+ }
+
+//Begin: loop over all potential seed pixels:
+//Determine 'hit-vicinity':
+ Int_t HIT_count=0;
+
+ for(Int_t hit=0; hit<HITNR;hit++)
+ {
+ A = (Hitlist[hit])/fColumnsSub; // A: row of seed
+ B = (Hitlist[hit])%fColumnsSub; // B: column of seed
+
+
+
+
+ // Consider boundaries => 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;j<i;++j)
+ {
+ if(array[j]>array[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; i<fPixels; i++)
+ {
+ matrixF0_tmp[i] = fF0matrix[i];
+ matrixF1_tmp[i] = fF1matrix[i];
+ matrixCD_tmp[i] = fCdsmatrix[i];
+ }
+
+ for(Int_t i=0; i<fPixels; i++)
+ {
+ pos = row*1152 + column + block*8;
+
+ fF0matrix[pos] = matrixF0_tmp[i];
+ fF1matrix[pos] = matrixF1_tmp[i];
+ fCdsmatrix[pos] = matrixCD_tmp[i];
+
+ row++;
+ if(row==576) { row=0; block++; }
+ if(block==144) { block=0; column++; }
+ }
+
+ fPixelsSub = fPixels;
+ fColumnsSub = fColumns;
+ fRowsSub = fRows;
+}
+
+//####################################################################
+
+void MAPS::reorderMi29a() {
+
+ if( fSubMatrix>5 )
+ {
+ cerr<<"ERROR: "<<fSubMatrix<<". Sub-Matrix not found! Choose: 0 to 5 !"<<endl;
+ cerr<<"-----------------------"<<endl;
+ fRowsSub = 0;
+ fColumnsSub = 0;
+ fPixelsSub = 0;
+ }
+ else
+ {
+ Int_t ROWSSUB[6] = {48,48,32,32,32,32};
+ Int_t OFFSET = 0;
+
+ for(Int_t i=0;i<fSubMatrix;i++)
+ {
+ OFFSET+=ROWSSUB[i];
+ }
+ OFFSET = OFFSET*48;
+
+ fRowsSub = ROWSSUB[fSubMatrix];
+ fColumnsSub = 48;
+ fPixelsSub = fRowsSub*fColumnsSub;
+
+ Int_t CDSMATRIX [fPixelsSub];
+ Int_t F0MATRIX [fPixelsSub];
+ Int_t F1MATRIX [fPixelsSub];
+
+ for(Int_t i=0;i<fPixelsSub;i++)
+ {
+ CDSMATRIX [i] = fCdsmatrix[OFFSET+i];
+ F0MATRIX [i] = fF0matrix [OFFSET+i];
+ F1MATRIX [i] = fF1matrix [OFFSET+i];
+ }
+
+ for(Int_t i=0;i<fPixelsSub;i++)
+ {
+ fCdsmatrix [i] = CDSMATRIX [i];
+ fF0matrix [i] = F0MATRIX [i];
+ fF1matrix [i] = F1MATRIX [i];
+ }
+ }
+}
+
+//####################################################################
+
+void MAPS::reorderMi29b() {
+
+ if( fSubMatrix>5 )
+ {
+ cerr<<"ERROR: "<<fSubMatrix<<". Sub-Matrix not found! Choose: 0 to 5 !"<<endl;
+ cerr<<"-----------------------"<<endl;
+ fRowsSub = 0;
+ fColumnsSub = 0;
+ fPixelsSub = 0;
+ }
+ else
+ {
+ Int_t ROWSSUB[6] = {64,64,32,32,32,32};
+ Int_t OFFSET = 0;
+
+ for(Int_t i=0;i<fSubMatrix;i++)
+ {
+ OFFSET+=ROWSSUB[i];
+ }
+ OFFSET = OFFSET*51;
+
+ fRowsSub = ROWSSUB[fSubMatrix];
+ fColumnsSub = 51;
+ fPixelsSub = fRowsSub*fColumnsSub;
+
+ Int_t CDSMATRIX [fPixelsSub];
+ Int_t F0MATRIX [fPixelsSub];
+ Int_t F1MATRIX [fPixelsSub];
+
+ for(Int_t i=0;i<fPixelsSub;i++)
+ {
+ CDSMATRIX [i] = fCdsmatrix[OFFSET+i];
+ F0MATRIX [i] = fF0matrix [OFFSET+i];
+ F1MATRIX [i] = fF1matrix [OFFSET+i];
+ }
+
+ for(Int_t i=0;i<fPixelsSub;i++)
+ {
+ fCdsmatrix [i] = CDSMATRIX [i];
+ fF0matrix [i] = F0MATRIX [i];
+ fF1matrix [i] = F1MATRIX [i];
+ }
+ }
+}
+
+//####################################################################
+//####################################################################
\ No newline at end of file
--- /dev/null
+#ifndef MAPS_H
+#define MAPS_H
+
+#include <TFile.h>
+#include <TNtuple.h>
+#include <TH2F.h>
+
+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<Int_t>* 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<Int_t>* GetPixels() { return ListOfPixels; }
+// Int_t GetPixelAt(Int_t index) { return ListOfPixels->at(index); }
+// vector<Int_t>* GetPixelEntries() { return ListOfPixelEntries; }
+// Int_t GetPixelEntryAt(Int_t index) { return ListOfPixelEntries->at(index); }
+
+};
+
+
+#endif
\ No newline at end of file
--- /dev/null
+#include <iostream>
+#include <fstream>
+#include <vector>
+#include <string>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sstream>
+
+
+#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<noiseRun> 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<noiseRun>::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
--- /dev/null
+#include "analyzeRun.h"
+
+#include <cstring>
+#include <string>
+#include <iostream>
+//#include <boost/filesystem/operations.hpp>
+#include <ctime>
+#include <iostream>
+#include <sstream>
+#include <fstream>
+
+
+
+
+
+
+
+#include <unistd.h>
+
+
+
+
+
+
+
+
+
+
+#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; i<events; i++) {
+ mapsi->getFrame(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<<endl;
+
+ delete mapsi;
+ logfile << runNo << "\t" << matrixAB << "\t" << submatrix << "\tprocessed with noise\t" << noiseRunNo << endl;
+ }
+ logfile.close();
+ }
+
+
+}
+
+
+
+
+
+ // // file exists already?
+ // string pathString = string(outputDataPath) + std::to_string(runNo) + "/" + std::to_string(runNo) + "_" + matrixAorB + "_" + std::to_string(submatrix) + ".root";
+ // if (boost::filesystem::exists(boost::filesystem::path(pathString)) ) {
+ // cout << "Das hier steckt in path: " << pathString;
+ // cout << "joa ES EXISTIERT UND IST EINDEUTIG :D!\n\n\n\n";
+ // return;
+ // }
+ // else{
+ // cout << "Das hier steckt in path: " << pathString;
+ // cout << "joa ex net... NIIICHT!!\n\n\n\n";
+ // }
+
+
+
+ // std::time_t t = boost::filesystem::last_write_time( p ) ;
+ // std::cout << "On " << std::ctime( &t ) << " the file " << argv[ 1 ]
+ // << " was modified the last time!\n" ;
+ // std::cout << "Setting the modification time to now:\n" ;
+ // std::time_t n = std::time( 0 ) ;
+ // boost::filesystem::last_write_time( p , n ) ;
+ // t = boost::filesystem::last_write_time( p ) ;
+ // std::cout << "Now the modification time is " << std::ctime( &t ) << std::endl ;
+ // return 0 ;
+ // } else {
+ // std::cout << "Could not find file " << argv[ 1 ] << '\n' ;
+ // return 2 ;
+ // }
+
\ No newline at end of file
--- /dev/null
+#ifndef ANALYZERUN_H
+#define ANALYZERUN_H
+
+#include <TNtuple.h>
+
+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