// set file path and other variables to be set
Init();
-
-
cout << "Found " << numberRuns << " run(s) in 'runlist.txt' or given as parameters." << endl;
for(Int_t runi=0; runi<numberRuns; runi++) // loop over runs read from file or given as aparameters
{
gROOT->SetBatch(kFALSE);
// Uncomment below to do classical analysis withour RTS
- compareHistogramClassVector.push_back(runs[runi]->histogramwoRTS);
- compareHistogramClassVector.push_back(runs[runi]->histogramfixedthreshold);
+ compareHistogramClassVector.push_back(runs[runi]->histogram->normalized);
+ compareHistogramClassVector.push_back(runs[runi]->histogramfixedthreshold->normalized);
+
+
+ compareHistogramClassVector2.push_back(runs[runi]->histogram->normalized);
+
+ compareHistogramVector.push_back(runs[runi]->histogram->normalized->Seed);
+ compareHistogramVector.push_back(runs[runi]->histogram->normalized->Sum);
// compareHistogramClassVector2.push_back(runs[runi]->histogramwoRTS);
- compareHistogramClassVector2.push_back(runs[runi]->histogram->normalized);
- compareHistogramClassVector2.push_back(runs[runi]->histogramwoRTS->normalized);
- compareHistogramClassVector2.push_back(runs[runi]->histogramwoRTSAggresive->normalized);
+// compareHistogramClassVector2.push_back(runs[runi]->histogram->normalized);
+// compareHistogramClassVector2.push_back(runs[runi]->histogramwoRTS->normalized);
+// compareHistogramClassVector2.push_back(runs[runi]->histogramwoRTSAggresive->normalized);
// compareHistogramClassVector2.push_back(runs[runi]->histogramwoRTS->normalized);
// compareHistogramClassVector.push_back(runs[runi]->histogramwoRTS->normalized);
// compareHistogramClassVector.push_back(runs[runi]->histogramfixedthreshold->normalized);
// runs[runi]->plot1DHistogram(runs[runi]->histogram->Seed);
// runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS->Seed);
+
+ ntuple->Fill(runs[runi]->labbook.depletionV,runs[runi]->histogramfixedthreshold->posSeed,0,0);
+// ntuple->Fill(2,2,1,1);
+// ntuple->Fill(3,3,1,1);
+// ntuple->Fill(4,4,1,1);
+// ntuple->Fill(5,5,1,1);
+//
+//
+
// compareHistogramVector.push_back(runs[runi]->histogram->Seed);
// compareHistogramVector.push_back(runs[runi]->histogramwoRTS->Seed);
// compareHistogramVector.push_back(runs[runi]->histogramwoRTSAggresive->Seed);
// runs[runi]->plot1DHistogram( runs[runi]->histogramfixedthreshold->normalized->Seed, "gaus", true, false, false, 500);
//runs[runi]->plot1DHistogram( runs[runi]->histogramwoRTS->normalized->Seed, "GaussTail");
//runs[runi]->plot1DHistogram( runs[runi]->histogramwoRTS->a_Sum[0]);
- compareHistogramVector.push_back(runs[runi]->histogramwoRTS->a_Sum[0]); // Seed
- compareHistogramVector.push_back(runs[runi]->histogramwoRTS->a_Sum[1]); // Seed + next bigger charge pixel
- compareHistogramVector.push_back(runs[runi]->histogramwoRTS->a_Sum[2]); // Seed + 2
- compareHistogramVector.push_back(runs[runi]->histogramwoRTS->a_Sum[8]); // Sum over 9 pixel in cluster
- compareHistogramVector.push_back(runs[runi]->histogramwoRTS->a_Sum[24]); // Sum over 25 pixel in cluster
+// compareHistogramVector.push_back(runs[runi]->histogramwoRTS->a_Sum[0]); // Seed
+// compareHistogramVector.push_back(runs[runi]->histogramwoRTS->a_Sum[1]); // Seed + next bigger charge pixel
+// compareHistogramVector.push_back(runs[runi]->histogramwoRTS->a_Sum[2]); // Seed + 2
+// compareHistogramVector.push_back(runs[runi]->histogramwoRTS->a_Sum[8]); // Sum over 9 pixel in cluster
+// compareHistogramVector.push_back(runs[runi]->histogramwoRTS->a_Sum[24]); // Sum over 25 pixel in cluster
-// runs[runi]->plot1DHistogram( runs[runi]->histogramfixedthreshold->normalized->Seed, "gaus", true, false, false, runs[runi]->histogramfixedthreshold->normalized->fixedThresholdValue);
-// runs[runi]->plot1DHistogram( runs[runi]->histogramfixedthreshold->normalized->Sum, "gaus", true, false, false, 500);
+// runs[runi]->plot1DHistogram( runs[runi]->histogram->normalized->Seed, "gaus", true, false, false, runs[runi]->histogramfixedthreshold->normalized->fixedThresholdValue);
+// runs[runi]->plot1DHistogram( runs[runi]->histogram->normalized->Sum, "gaus", true, false, false, runs[runi]->histogramfixedthreshold->normalized->fixedThresholdValue);
+
+
+// runs[runi]->plot1DHistogram( runs[runi]->histogramfixedthreshold->normalized->Seed, "GaussTail", true, false, false, runs[runi]->histogramfixedthreshold->normalized->fixedThresholdValue);
+// runs[runi]->plot1DHistogram( runs[runi]->histogramfixedthreshold->normalized->Sum, "GaussTail", true, false, false, runs[runi]->histogramfixedthreshold->normalized->fixedThresholdValue);
// plot RTS pixel histogram
- runs[runi]->plot1DHistogram( runs[runi]->histogramwoRTS->pixeltimefiredDistrib, "", 0);
+ //runs[runi]->plot1DHistogram( runs[runi]->histogramwoRTS->pixeltimefiredDistrib, "", 0);
-
+
+// runs[runi]->plot1DHistogram( runs[runi]->histogram->normalized->Seed);
+// runs[runi]->plot1DHistogram( runs[runi]->histogram->normalized->Sum);
- runs[runi]->writeAllHistogramsToFile();
+ runs[runi]->writeAllHistogramsToFile();
+
+ // plot and clear compareHistogramClassVector vector, delete these two lines if you want to compare among different runs
+ plotAllRuns(&compareHistogramClassVector);
+ compareHistogramClassVector.clear();
}
//cout << runs[runi]->histogram
}
plotAllRuns(&compareHistogramClassVector3);
plotAllRuns(&compareHistogramClassVector4);
plotAllRuns(&compareHistogramClassVector5);
+plot1DData(ntuple);
CompareLeageCurrent(&compareHistogramClassVector4);
CompareLeageCurrent(&compareHistogramClassVector5);
writeObservableToFile();
#include <TCanvas.h>
#include <TH2C.h>
#include <TTimeStamp.h>
+#include <TGraphErrors.h>
#include "HistogramType.h"
#include "Run.h"
Bool_t FindGoodTitle(vector<TH1FO*>* ptCompareHistogramVector);
Bool_t FindGoodTitle();
+/** @brief A function to write data from TNtuple to a file. File is save with the prefix "Oberservable_" in the result folder
+ * */
+Bool_t writeNTupleToFile(TNtuple* ntuplepointer);
+
/** @brief A function to plot TH1F histograms of different runs into one file
*
*/
void Init();
+
+/** @brief A function to plot ntuplöe data into a canvas
+ *
+ */
+TCanvas* plot1DData(TNtuple* ntuplepointer, Bool_t verbose=0, Bool_t logscale=0, TString titlestr="", TString legendstr="" );
+
Bool_t writeObservableToFile();
/** @brief A vector able to hold pointer of type #Run::histogramstruct
*
string to_str_w_prec(const Float_t a_value, int precision = 1);
vector<HistogramType*> compareHistogramClassVector, compareHistogramClassVector2, compareHistogramClassVector3, compareHistogramClassVector4, compareHistogramClassVector5, compareHistogramClassVector6, compareHistogramClassVector7, compareHistogramClassVector8, compareHistogramClassVectorMABSBot;
vector<TH1FO*> compareHistogramVector, compareHistogramVector2, compareHistogramVector3, compareHistogramVector4, compareHistogramVector5, compareHistogramVector6, compareHistogramVector7, compareHistogramVector8;
+TNtuple *ntuple, *ntuple2, *ntuple3, *ntuple4;
TString ownpath = "";
TString savepathresults;
//FindGoodTitle();
TTimeStamp timestamp = TTimeStamp();
savepathresults = Form("./results/%d%06d/", (int)timestamp.GetDate(kFALSE), (int)timestamp.GetTime(kFALSE));
+ ntuple = new TNtuple("ntuple", "data", "x:y:xerr:yerr");
+ ntuple2 = new TNtuple("ntuple2","data2","x:y:xerr:yerr");
+ ntuple3 = new TNtuple("ntuple3","data3","x:y:xerr:yerr");
+ ntuple4 = new TNtuple("ntuple4","data4","x:y:xerr:yerr");
+
}
// in the command line one can add labels, by printing a equal sign '=' and a string escaped by the question sign '§', for example:
return numberRuns;
}
+
+
+TCanvas* plot1DData(TNtuple* ntuplepointer, Bool_t verbose, Bool_t logscale, TString titlestr, TString legendstr )
+{
+ if (ntuplepointer != nullptr)
+ {
+ if (ntuplepointer->GetEntries() > 0) {
+ TString canvastitle = Form("%s", ntuplepointer->GetName());
+ TString canvasname = Form("%s", ntuplepointer->GetName());
+ TCanvas* canvas = new TCanvas(canvasname, canvastitle, 900, 700);
+ canvas->SetGrid();
+
+ if (titlestr.Length()>0)
+ ntuplepointer->SetTitle(titlestr);
+ if (logscale) {
+ gPad->SetLogy(1);
+ }
+
+ ntuplepointer->Draw("x:y:xerr:yerr","","goff");
+
+ TGraphErrors *gr = new TGraphErrors(ntuplepointer->GetEntries(),ntuplepointer->GetV1(),ntuplepointer->GetV2(),ntuplepointer->GetV3(),ntuplepointer->GetV4());
+ gr->SetTitle("TGraphErrors Example");
+ gr->SetMarkerColor(4);
+ gr->SetMarkerStyle(21);
+ gr->Draw("ALP");
+
+ canvas->Update();
+ // canvas -> SaveAs( savepathresults + "/" + runcode + " " + onehistogram->GetName() + ".eps");
+
+ TImageDump *img = new TImageDump(savepathresults + ntuplepointer->GetName() + ".png");
+ canvas->Paint();
+ img->Close();
+
+ writeNTupleToFile(ntuplepointer);
+ return canvas;
+ }
+ }
+ return nullptr;
+}
+
+
+Bool_t writeNTupleToFile(TNtuple* ntuplepointer)
+{
+ if (ntuplepointer != nullptr)
+ {
+ system("mkdir "+ savepathresults + " -p");
+
+ TString filename = savepathresults + Form("Observable_%s.dat", ntuplepointer->GetName());
+
+ TString header = "x\ty\txerr\tyerr";
+ fstream* fout = new fstream(filename,ios::out);
+
+ *fout << header << endl;
+ TString outline;
+ for(int i=0;i<ntuplepointer->GetEntries();i++) {
+ ntuplepointer->GetEntry(i);
+ Float_t *p = ntuplepointer->GetArgs();
+ outline ="";
+ outline+=Form("%.2f\t%.2f\t%.2f\t%.2f", p[0], p[1], p[2], p[3]);
+ *fout<<outline<<endl;
+ }
+ fout->close();
+ return 0;
+ }
+ return 1;
+}
+
+
Bool_t writeOneHistogramTypeToFile(vector<HistogramType*>* ptCompareHistogramClassVector)
{
if (ptCompareHistogramClassVector->size() > 0)
return 1;
}
+
Bool_t CompareLeageCurrent(vector<HistogramType*>* ptCompareHistogramClassVector)
{
if (ptCompareHistogramClassVector->size() > 0)
{
HistogramType* curhistogramclassp = ptCompareHistogramClassVector->at(histogrami);
TH1F* curhistogramclone = (TH1F*) curhistogramclassp->Seed->Clone();
+ Float_t posMaxValHist = curhistogramclone->GetXaxis()->GetXmax();
curhistogramclone->GetXaxis()->UnZoom();
+ curhistogramclone->GetXaxis()->SetRange(curhistogramclone->GetXaxis()->FindBin(curhistogramclassp->noisethresholdborder),curhistogramclone->GetXaxis()->FindBin(posMaxValHist)); // look only for maxima with x greater than noiseborder, cut away noise
heighestval1 = (curhistogramclone->GetMaximum()>heighestval1?curhistogramclone->GetMaximum():heighestval1);
lastbin1 = (curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(2,1))>lastbin1)?curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(2,1)):lastbin1;
// cout << "Last bin: " << colorcyan << lastbin1 << endlr;
// cout << "curhistogramclone->GetMaximum(): " << colorcyan << curhistogramclone->GetMaximum() << endlr;
curhistogramclone = (TH1F*) curhistogramclassp->Sum->Clone();
+ posMaxValHist = curhistogramclone->GetXaxis()->GetXmax();
curhistogramclone->GetXaxis()->UnZoom();
+ curhistogramclone->GetXaxis()->SetRange(curhistogramclone->GetXaxis()->FindBin(curhistogramclassp->noisethresholdborder),curhistogramclone->GetXaxis()->FindBin(posMaxValHist)); // look only for maxima with x greater than noiseborder, cut away noise
+
+
heighestval2 = (curhistogramclone->GetMaximum()>heighestval2?curhistogramclone->GetMaximum():heighestval2);
lastbin2 = (curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(2,1))>lastbin2)?curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(2,1)):lastbin2;
curhistogramclone = (TH1F*) curhistogramclassp->Veto->Clone();
+ posMaxValHist = curhistogramclone->GetXaxis()->GetXmax();
curhistogramclone->GetXaxis()->UnZoom();
+ curhistogramclone->GetXaxis()->SetRange(curhistogramclone->GetXaxis()->FindBin(curhistogramclassp->noisethresholdborder),curhistogramclone->GetXaxis()->FindBin(posMaxValHist)); // look only for maxima with x greater than noiseborder, cut away noise
heighestval3 = (curhistogramclone->GetMaximum()>heighestval3?curhistogramclone->GetMaximum():heighestval3);
lastbin3 = (curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(2,1))>lastbin3)?curhistogramclone->GetBinCenter(curhistogramclone->FindLastBinAbove(2,1)):lastbin3;
// cout << "heighestval3: " << colorcyan << heighestval3 << endlr;
curhistogramclone->SetAxisRange(0,lastbin1*1.1,"X");
curhistogramclone->SetAxisRange(0,heighestval1*1.1,"Y");
curhistogramclone->GetYaxis()->SetRangeUser(1,heighestval1*1.0);
- gPad->SetLogy(1);
+// gPad->SetLogy(1);
gPad->SetGrid(1);
gPad->SetGridy(1);
owntitle->Clear();
// heighestval2 = (curhistogramclone->GetMaximum()>heighestval2?curhistogramclone->GetMaximum():heighestval2);
curhistogramclone->GetYaxis()->SetRangeUser(1,heighestval2*1.2);
curhistogramclone->Draw("SAME");
- gPad->SetLogy(1);
+// gPad->SetLogy(1);
gPad->SetGrid(1);
gPad->SetGridy(1);
normalized->posSum = posSum;
normalized->posVeto = posVeto;
normalized->integralSeed = integralSeed/frames_found*pow10(6);
- normalized->integralSeedErr = integralSeedErr/frames_found*pow10(6);
+ normalized->integralSeedErr = integralSeedErr * sqrt(pow10(6)/frames_found);
normalized->integralVeto= integralVeto/frames_found*pow10(6);
normalized->integralVeto= integralVeto/frames_found*pow10(6);
normalized->integralSum = integralSum/frames_found*pow10(6);
- normalized->integralSumErr = integralSumErr/frames_found*pow10(6);
+ normalized->integralSumErr = integralSumErr * sqrt(pow10(6)/frames_found);
normalized->posSeedPerc = posSeedPerc;
normalized->sigmaSeedPerc = sigmaSeedPerc;
normalized->noisethresholdborder = noisethresholdborder;
const Double_t def_peakcenter=histogrampointer->GetBinCenter(histogrampointer->GetMaximumBin());
// cout << colorcyan << "def_amplitude: " << def_amplitude << endlr;
// cout << colorcyan << "def_peakcenter: " << def_peakcenter << endlr;
- const Double_t def_gausssig=12;
+ const Double_t def_gausssig=10;
// set start values for some parameters
fitFunc->SetParName(0,"amplitude of peak");
fitFunc->SetParameter(0,def_amplitude);
// make an error estimate, in case of rare events one can use the poisson distribution
// error bars become +- sqrt(n) for each bin, where n is the bin content.
- parameters[7] = parameters[1] - 3*parameters[2] ; // starting point of histogram integration
- parameters[8] = parameters[1] + 3*parameters[2] ; // end point of histogram integration
+ parameters[7] = parameters[1] - 2*parameters[2] ; // starting point of histogram integration
+ parameters[8] = parameters[1] + 2*parameters[2] ; // end point of histogram integration
integralPeak = histogrampointer->IntegralAndError(histogrampointer->GetXaxis()->FindBin( parameters[7] ), histogrampointer->GetXaxis()->FindBin( parameters[8]), integralPeakError, "width"); // integral value of histogram (NOT fit), normaliezed with bin size!
posMax = fitFunc->GetMaximumX(); // Methode 2
fitFunc->SetLineStyle(1); // normal for the following fits
// TODO: This fix disables the background
fitFunc->FixParameter(4,0);
- // fitFunc->FixParameter(5,0);
+ fitFunc->FixParameter(5,0);
int fittries = 0;
Bool_t failed = false;
systemparam systemparamPXI (800*16,800,75,150,150);
systemparam systemparamFSBB (2800,2800/4,25,10,100);
systemparam systemparamUSBMi19 (400/*maxbin*/,400/1/*nbins*/, 25/*vetothreshold*/, 10/*maxbinnoise*/, 100/*nbinsnoise*/);
- systemparam systemparamPipper2 (1000,200,25,10,100);
+ systemparam systemparamPipper2 (1000,500,25,10,100); // change bin size to 200 if Cd109
+ systemparam systemparamPipper2_Cd (1000,200,25,10,100); // change bin size to 200 if Cd109
if (labbook.system.EqualTo("USB") && labbook.chipGen.EqualTo("Mi34") )
cursystemparam = systemparamUSB;
else if (labbook.system.EqualTo("USB") && labbook.chipGen.EqualTo("FSBB") )
cursystemparam = systemparamPegasus;
else if (labbook.system.EqualTo("USB") && labbook.chipGen.EqualTo("Mi19") )
cursystemparam = systemparamUSBMi19;
- else if (labbook.system.EqualTo("USB") && labbook.chipGen.EqualTo("Pipper2") )
- cursystemparam = systemparamPipper2;
+ else if (labbook.system.EqualTo("USB") && labbook.chipGen.EqualTo("Pipper2") ) {
+ if (labbook.source.Contains("Cd"))
+ cursystemparam = systemparamPipper2_Cd;
+ else
+ cursystemparam = systemparamPipper2;
+ }
else if (labbook.system.EqualTo("USB")) // && labbook.chipGen.EqualTo("34") )
cursystemparam = systemparamUSB;
cout << coloryellow << "Cannot rescale run from [ADU] to [e] units, no calibration peak found." << endlr;
return 0;
}
- Float_t gain = 1640.0/vetopeakposition;
+ Float_t gain = 1;
+ if (labbook.source.Contains("Fe"))
+ gain = 1640.0/vetopeakposition;
+ else if (labbook.source.Contains("Cd"))
+ gain = 6140.0/vetopeakposition;
for (vector<HistogramType*>::iterator curHistogramClass = HistogramClassVector.begin(); curHistogramClass != HistogramClassVector.end(); curHistogramClass++) {
(*curHistogramClass)->calibrateHistograms(gain);
(*curHistogramClass)->normalized->calibrateHistograms(gain);
// Add code to set the pointer histogramclassToUseForDB to class to use for database values
// histogramclassToUseForDB = histogramthreshold;
if (labbook.chipGen.EqualTo("Pipper2")) {
- histogramclassToUseForDB = histogramwoRTS;
+ histogramclassToUseForDB = histogramfixedthreshold;
} else {
histogramclassToUseForDB = histogramwoRTSthreshold;
}
if (histogramfixedthreshold != 0 && histogram != 0) {
if (histogramfixedthreshold->fixedThresholdValue <= 0) {
float_t cutval = histogram->Sum->GetBinCenter(histogram->Sum->FindLastBinAbove(3,1));
- setFixedThresholdValueADU(cutval*0.8);
+ setFixedThresholdValueADU(cutval*0.5); // change back to *0.8
}
if (pixelSum > histogramfixedthreshold->fixedThresholdValue) // charge is more then histogramfixedthreshold->fixedThresholdValue in whole cluster
{
cout << colorcyan << "numberofgoodvetopixels: " << numberofgoodvetopixels << endlr;
cout << colorcyan << "numberofactivepixel: " << numberofactivepixel << endlr;
percentageofGoodVetoPixel = (numberofgoodvetopixels*100.0)/numberofactivepixel;
- cout << colorcyan << "percentageodGoodVetoPixel: " << percentageofGoodVetoPixel << endlr;
+ cout << colorcyan << "percentageofGoodVetoPixel: " << percentageofGoodVetoPixel << endlr;
}
if (histogramGoodVeto->pixelHadGoodVeto->GetBinContent(pixelno+1) > 1) {
(*curHistogramClass)->integralVeto = parameters[6];
}
if (labbook.chipGen.EqualTo("Pipper2"))
- parameters = (*curHistogramClass)->FitPerform((*curHistogramClass)->Seed, "GaussTail", 0, false, (*curHistogramClass)->fixedThresholdValue);
+ parameters = (*curHistogramClass)->FitPerform((*curHistogramClass)->Seed, "gaus", 0, false, (*curHistogramClass)->fixedThresholdValue);
else
parameters = (*curHistogramClass)->FitPerform((*curHistogramClass)->Seed, "landau");
(*curHistogramClass)->integralSeed = parameters[6];
(*curHistogramClass)->posSeed = parameters[1];
(*curHistogramClass)->integralSeedErr = parameters[9];
- parameters = (*curHistogramClass)->FitPerform((*curHistogramClass)->Sum, "GaussTail", 0, false, (*curHistogramClass)->fixedThresholdValue); //TODO change back to gauss
+ parameters = (*curHistogramClass)->FitPerform((*curHistogramClass)->Sum, "gaus", 0, false, (*curHistogramClass)->fixedThresholdValue); //TODO change back to gauss
(*curHistogramClass)->posSum = parameters[1];
(*curHistogramClass)->integralSum = parameters[6];
(*curHistogramClass)->integralSumErr = parameters[9];