From: Benjamin Linnik Date: Fri, 16 Dec 2016 13:32:43 +0000 (+0100) Subject: Analyzer: Better plot names X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=5a81cdb5a974d7975ea89aae3a1388f5b0f29429;p=radhard.git Analyzer: Better plot names --- diff --git a/MABS_run_analyzer/ChargeSpektrum.c b/MABS_run_analyzer/ChargeSpektrum.c index d880678..f85588d 100644 --- a/MABS_run_analyzer/ChargeSpektrum.c +++ b/MABS_run_analyzer/ChargeSpektrum.c @@ -14,13 +14,10 @@ Bool_t isBatch = kFALSE; #include "MAPS.c" #include "Run.c" -#include #include "help.h" Run** runs; Int_t numberRuns; -TTimeStamp timestamp = TTimeStamp(); -TString savepathresults = Form("./results/%d%06d/", (int)timestamp.GetDate(kFALSE), (int)timestamp.GetTime(kFALSE)); #include "ChargeSpektrumFunctions.c" @@ -38,8 +35,11 @@ void ChargeSpektrum(TString runnumber = "") #include "SetStyle.c" InterpreteUserInput(runnumber, &runList, &runListForceAnalysis, &runListCustomTitle, &sumuprunList); - runs = new Run*[numberRuns]; + + // 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; runiSetBatch(kFALSE); // Uncomment below to do classical analysis withour RTS - compareHistogramClassVector2.push_back(runs[runi]->histogram->normalized->calibrated); - compareHistogramClassVector.push_back(runs[runi]->histogram->normalized); +// compareHistogramClassVector.push_back(runs[runi]->histogramwoRTS->normalized); +// compareHistogramClassVector2.push_back(runs[runi]->histogramwoRTS); + compareHistogramClassVector.push_back(runs[runi]->histogram->normalized); + //compareHistogramClassVector.push_back(runs[runi]->histogramwoRTS); // compareHistogramClassVector2.push_back(runs[runi]->histogramthreshold); - compareHistogramVector.push_back(runs[runi]->histogram->normalized->calibrated->Seed); - compareHistogramVector2.push_back(runs[runi]->histogram->normalized->Seed); + //compareHistogramVector.push_back(runs[runi]->histogram->normalized->calibrated->Seed); + //compareHistogramVector2.push_back(runs[runi]->histogram->normalized->Seed); //runs[runi]->plot1DHistogram(runs[runi]->histogram->normalized->calibrated, runs[runi]->histogram->normalized->calibrated->Seed, "landau", 1); // runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS->normalized->calibrated, runs[runi]->histogramwoRTS->normalized->calibrated->Seed, "landau", true); // runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS->normalized->calibrated, runs[runi]->histogramwoRTS->normalized->calibrated->Sum, "gaus", true); @@ -174,25 +176,28 @@ void ChargeSpektrum(TString runnumber = "") // compareHistogramVector.push_back(runs[runi]->histogramwoRTS->normalized->Seed); // runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS, runs[runi]->histogramwoRTS->pixeltimefired, "", 0); // runs[runi]->plot1DHistogram(runs[runi]->histogram, runs[runi]->histogram->Seed, "landau", 1); -// runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS, runs[runi]->histogramwoRTS->pixeltimefiredsorted, "", 0, true, true); -// runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS, runs[runi]->histogramwoRTS->pixeltimefired, "", 0, true, true); +// runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS, runs[runi]->histogramwoRTS->pixeltimefiredsorted, "", 0, true, true); +// runs[runi]->plot1DHistogram(runs[runi]->histogram, runs[runi]->histogram->pixeltimefired, "", 0, true, true); +// runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS, runs[runi]->histogramwoRTS->pixeltimefired, "", 0, true, true); +// runs[runi]->plot1DHistogram(runs[runi]->histogram, runs[runi]->histogram->pixeltimefired, "", 0, true, true); // runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS, runs[runi]->histogramwoRTS->LeakageCurrentInPixel, "", 0); // runs[runi]->plot1DHistogram(runs[runi]->histogram, runs[runi]->histogram->LeakageCurrentInPixel, "", 0); -// runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS, runs[runi]->histogramwoRTS->LeakageCurrentInPixelSorted, "", 0); -// runs[runi]->plot1DHistogram(runs[runi]->histogram, runs[runi]->histogram->LeakageCurrentInPixelSorted, "", 0); +// runs[runi]->plot1DHistogram(runs[runi]->histogramwoRTS, runs[runi]->histogramwoRTS->LeakageCurrentInPixelSorted, "", 0); +// runs[runi]->plot1DHistogram(runs[runi]->histogram, runs[runi]->histogram->LeakageCurrentInPixelSorted, "", 0); // runs[runi]->plot1DHistogram(runs[runi]->histogram, runs[runi]->histogram->pixeltimefired, "gaus", 1); // compareHistogramVector2.push_back(runs[runi]->histogramthreshold->normalized->Seed); //compareHistogramClassVector.push_back(runs[runi]->histogram); // runs[runi]->plot1DHistogram(runs[runi]->histogramthreshold, runs[runi]->histogramthreshold->Veto, "gaus"); // runs[runi]->plot1DHistogram(runs[runi]->histogram, runs[runi]->histogram->Sum, "gaus", 1); - runs[runi]->plot1DHistogram(runs[runi]->histogram, runs[runi]->histogram->Seed, "GaussTail", 1); +// runs[runi]->plot1DHistogram(runs[runi]->histogram, runs[runi]->histogram->normalized->Seed, "landau", 1); + //runs[runi]->plot1DHistogram(runs[runi]->histogram, runs[runi]->histogram->normalized->Seed, "GaussTail", 1, 0,0,70); // compareHistogramVector.push_back(runs[runi]->histogramthreshold->calibrated->normalized->Veto); // runs[runi]->plot1DHistogram(runs[runi]->histogram, runs[runi]->histogram->Seed, "landau", 1); runs[runi]->writeAllHistogramsToFile(); // CompareHistograms(&compareHistogramVector); // compareHistogramVector.clear(); -// plotAllRuns(&compareHistogramClassVector); + //plotAllRuns(&compareHistogramClassVector); // compareHistogramClassVector.clear(); } //cout << runs[runi]->histogram diff --git a/MABS_run_analyzer/ChargeSpektrumFunctions.c b/MABS_run_analyzer/ChargeSpektrumFunctions.c index 2f90da6..cac72bc 100644 --- a/MABS_run_analyzer/ChargeSpektrumFunctions.c +++ b/MABS_run_analyzer/ChargeSpektrumFunctions.c @@ -14,6 +14,9 @@ #include #include #include +#include +#include "HistogramType.h" +#include "Run.h" #include "help.h" using namespace std; @@ -23,6 +26,24 @@ Int_t ReadRunList(std::vector*); void InterpreteUserInput(TString, std::vector*, std::vector*, std::vector*, std::vector*); Bool_t plotAllRuns(); Bool_t plotAllRuns(vector*); +// vector wich is used to save a good title by the function FindGoodTitle() +vector headerStringsVector; +// vector wich is used to save good legend entries by the function FindGoodTitle() +vector legendStringsVector; +TString folderadd; +/** + * @brief This functions analyzis the runs given for camparison and finds simmilarities and differences + * + * @input ptCompareHistogramClassVector a Vector of type HistogramType + * + * After finding the simmilarities and differences a suggestion for the overall title is given. + * If findind a common nominator fails it return a false value + * + */ +Bool_t FindGoodTitle(vector* ptCompareHistogramClassVector); +Bool_t FindGoodTitle(); + + /** @brief A function to plot TH1F histograms of different runs into one file * * You push in #ChargeSpectrum.c a pointer of the type TH1F into the vector #compareHistogramVector and then @@ -43,6 +64,12 @@ Bool_t CompareHistograms(vector* ptCompareHistogramVector, TString titles Bool_t writeOneHistogramTypeToFile(vector*); + +/** @brief A function to setup file path and other variables + * + */ +void Init(); + Bool_t writeObservableToFile(); /** @brief A vector able to hold pointer of type #Run::histogramstruct * @@ -61,6 +88,7 @@ string to_str_w_prec(const Float_t a_value, int precision = 1); vector compareHistogramClassVector, compareHistogramClassVector2, compareHistogramClassVector3, compareHistogramClassVector4, compareHistogramClassVector5, compareHistogramClassVector6, compareHistogramClassVector7, compareHistogramClassVector8, compareHistogramClassVectorMABSBot; vector compareHistogramVector, compareHistogramVector2, compareHistogramVector3, compareHistogramVector4, compareHistogramVector5, compareHistogramVector6, compareHistogramVector7, compareHistogramVector8; TString ownpath = ""; +TString savepathresults; void setCustomPath(TString setOwnpath) { @@ -81,6 +109,15 @@ void ChargeSpektrum(Int_t runnumber, Int_t runnumber2) exit(1); } +void Init() +{ + //FindGoodTitle(); + TTimeStamp timestamp = TTimeStamp(); + savepathresults = Form("./results/%d%06d/", (int)timestamp.GetDate(kFALSE), (int)timestamp.GetTime(kFALSE)); +} + +// in the command line one can add labels, by printing a equal sign '=' and a string escaped by the question sign '§', for example: +// root -l -b -q 'ChargeSpektrum.c+("40100=§5 V§,40097=§10 V§,40091=§20 V§,40103=§30 V§,40106=§40 V§")' void InterpreteUserInput(TString runnumber, std::vector *runList, std::vector *runListForceAnalysis, std::vector *runListCustomTitle, std::vector *sumuprunList) { if (runnumber.Length() > 0) @@ -155,8 +192,8 @@ void InterpreteUserInput(TString runnumber, std::vector *runList, std::vect else runListForceAnalysis->push_back(kFALSE); if (currunnumberstr.Contains("=")) { - cout << colorcyan << currunnumberstr << endlr; - runListCustomTitle->push_back(currunnumberstr(currunnumberstr.Index('=')+1,currunnumberstr.Length()-currunnumberstr.Index('=')-1)); + cout << colorcyan << currunnumberstr << " ---> " << " Index: " << currunnumberstr.Index("§") << " ---> " << currunnumberstr(currunnumberstr.Index("§")+2,currunnumberstr.Length()-currunnumberstr.Index("§")-4) << endlr; + runListCustomTitle->push_back(currunnumberstr(currunnumberstr.Index("§")+2,currunnumberstr.Length()-currunnumberstr.Index("§")-4)); } else { runListCustomTitle->push_back(""); } @@ -216,7 +253,7 @@ Bool_t writeOneHistogramTypeToFile(vector* ptCompareHistogramCla { system("mkdir "+ runs[0]->savepathresults + " -p"); - TString filename = Form("%s/Spectrum_%s", runs[0]->savepathresults.Data(), ptCompareHistogramClassVector->at(0)->histogramdescription.Data()); + TString filename = Form("%s/Spectrum_%d_%s", runs[0]->savepathresults.Data(), ptCompareHistogramClassVector->at(0)->labbook->runnumber, ptCompareHistogramClassVector->at(0)->histogramdescription.Data()); TString header = ""; for(UInt_t runi=0;runisize();runi++) // loop over runs read from file @@ -276,7 +313,7 @@ Bool_t writeObservableToFile() if (!runs[runi]->error) { filename+= Form("_%d",runs[runi]->labbook.runnumber); - header += Form("#%s, %lu frames\n", runs[runi]->runcode.Data(), runs[runi]->frames_found); + header += Form("#%s, %lu frames\n", runs[runi]->humanreadablestr.Data(), runs[runi]->frames_found); } } } @@ -330,8 +367,9 @@ Bool_t CompareHistograms(vector* ptCompareHistogramVector, TString titles Float_t lastbin1=0; Float_t heighestval1=0; TString canvastitle = Form("Compare_%s", trimRunnumberAtBegin(ptCompareHistogramVector->at(0)->GetName()).Data()); - TTimeStamp* time = new TTimeStamp(); - TString canvasname = Form("%d",time->GetNanoSec()); + TTimeStamp* time = new TTimeStamp(); + TString canvasname = Form("%s_%d",ptCompareHistogramVector->at(0)->GetName(),(int)time->GetNanoSec()/100000); + //TString canvasname = Form("%d",time->GetNanoSec()); for (UInt_t histogrami=0; histogrami < ptCompareHistogramVector->size(); histogrami++) { TH1F* curhistogramclone = (TH1F*) ptCompareHistogramVector->at(histogrami)->Clone(); @@ -416,7 +454,7 @@ Bool_t CompareLeageCurrent(vector* ptCompareHistogramClassVector canvastitle+= Form("_%d",curhistogramclassp->labbook->runnumber); } TTimeStamp* time = new TTimeStamp(); - TString canvasname = Form("%d",time->GetNanoSec()); + TString canvasname = Form("%d",(int)time->GetNanoSec()/100000); TCanvas* canvas = new TCanvas(canvasname, canvastitle, 1200, 800); int numberofhistogramclasses = ptCompareHistogramClassVector->size(); @@ -502,7 +540,7 @@ Bool_t CompareLeageCurrent(vector* ptCompareHistogramClassVector // leg1->Draw("SAME"); canvas->Update(); - MSaveBigPNG(canvas,savepathresults + "/" + canvastitle + ".png"); + MSaveBigPNG(canvas,savepathresults + "/" + canvastitle + ".png",1); TImageDump *img = new TImageDump(savepathresults + "/" + canvastitle + ".png"); canvas->Paint(); @@ -560,14 +598,16 @@ Bool_t testifMixingCalibration(vector* ptCompareHistogramClassVe */ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) { - if (numberRuns>0) - { + if (ptCompareHistogramClassVector->size()>0) + { + FindGoodTitle(ptCompareHistogramClassVector); + gROOT->SetStyle("RadHard_NoTitle"); if (testifMixingCalibration(ptCompareHistogramClassVector)) return 1; // legend entries Float_t height = ptCompareHistogramClassVector->size() * 0.055; - TLegend* leg1 = new TLegend(0.4,0.89-height,0.95,0.89);//(0.6,0.7,0.89,0.89); + TLegend* leg1 = new TLegend(0.6,0.89-height,0.95,0.89);//(0.6,0.7,0.89,0.89); leg1->SetTextSize(0.035); leg1->SetFillStyle(0); leg1->SetTextFont(132); @@ -575,13 +615,15 @@ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) TLegend* leg2 = (TLegend*) leg1->Clone(); TLegend* leg3 = (TLegend*) leg1->Clone(); TLegend* leg4 = (TLegend*) leg1->Clone(); + leg4->SetX1(0.4); TString legendEntry; TPaveText *owntitle = new TPaveText(0.15,0.9,0.930401,0.995,"nbNDC"); owntitle->SetFillStyle(0); owntitle->SetBorderSize(0); owntitle->SetTextAlign(22); - owntitle->SetTextSize(0.05); + owntitle->SetTextSize(0.04); + owntitle->SetMargin(0.07); owntitle->SetTextFont(42); TPaveText *owntitle2 = (TPaveText*)owntitle->Clone(); TPaveText *owntitle3 = (TPaveText*)owntitle->Clone(); @@ -602,7 +644,9 @@ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) canvastitle+= Form("_%d",curhistogramclassp->labbook->runnumber); } TTimeStamp* time = new TTimeStamp(); - TString canvasname = Form("%d",time->GetNanoSec()); + + TString canvasname = Form("Summary_%s_%d",ptCompareHistogramClassVector->at(0)->run->runcode.Data(),(int)time->GetNanoSec()/100000); + //TString canvasname = Form("%d",time->GetNanoSec()); TCanvas* canvas = new TCanvas(canvasname, canvastitle, 1200, 800); canvas->Divide(2,2); THStack *hs = new THStack("hs","Sum spectra"); @@ -649,6 +693,7 @@ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) curhistogramclone->Draw("SAME"); // legendEntry = Form("%d %s", curhistogramclassp->labbook->runnumber, curhistogramclone->GetTitle()); legendEntry = Form("%s", curhistogramclone->GetTitle()); + legendEntry = Form("%s", legendStringsVector.at(histogrami).Data()); leg1->AddEntry(curhistogramclone, legendEntry, "l"); leg1->Draw("SAME"); curhistogramclone->SetAxisRange(0,lastbin1*1.1,"X"); @@ -658,7 +703,10 @@ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) gPad->SetGrid(1); gPad->SetGridy(1); owntitle->Clear(); - owntitle->AddText(trimRunnumberAtBegin(curhistogramclone->GetName())); + if (headerStringsVector.size() > 0) { + owntitle->AddText(Form("%s, %s",trimRunnumberAtBegin(curhistogramclone->GetName()).Data(), headerStringsVector.at(1).Data())); + owntitle->AddText(headerStringsVector.at(2)); + } owntitle->Draw("SAME"); canvas->cd(2); @@ -667,6 +715,8 @@ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) curhistogramclone->Draw("SAME"); hs->Add(curhistogramclone); legendEntry = Form("%s", curhistogramclone->GetTitle()); + if (legendStringsVector.size() > 0) + legendEntry = Form("%s", legendStringsVector.at(histogrami).Data()); leg2->AddEntry(curhistogramclone, legendEntry, "l"); leg2->Draw("SAME"); // hs->Add(leg1); @@ -678,10 +728,12 @@ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) // gPad->SetLogy(1); gPad->SetGrid(1); gPad->SetGridy(1); - + owntitle2->Clear(); - owntitle2->AddText(trimRunnumberAtBegin(curhistogramclone->GetName())); - // hs->Add(owntitle2); + if (headerStringsVector.size() > 0) { + owntitle2->AddText(Form("%s, %s",trimRunnumberAtBegin(curhistogramclone->GetName()).Data(), headerStringsVector.at(1).Data())); + owntitle2->AddText(headerStringsVector.at(2)); + } owntitle2->Draw("SAME"); canvas->cd(3); @@ -689,6 +741,8 @@ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) curhistogramclone->SetLineColor(rootcolors[histogrami%13]); curhistogramclone->Draw("SAME"); legendEntry = Form("%s", curhistogramclone->GetTitle()); + if (legendStringsVector.size() > 0) + legendEntry = Form("%s", legendStringsVector.at(histogrami).Data()); leg3->AddEntry(curhistogramclone, legendEntry, "l"); leg3->Draw("SAME"); curhistogramclone->SetAxisRange(1,lastbin3*1.1,"X"); @@ -698,8 +752,12 @@ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) curhistogramclone->Draw("SAME"); gPad->SetGrid(1); gPad->SetGridy(1); + owntitle3->Clear(); - owntitle3->AddText(trimRunnumberAtBegin(curhistogramclone->GetName())); + if (headerStringsVector.size() > 0) { + owntitle3->AddText(Form("%s, %s",trimRunnumberAtBegin(curhistogramclone->GetName()).Data(), headerStringsVector.at(1).Data())); + owntitle3->AddText(headerStringsVector.at(2)); + } owntitle3->Draw("SAME"); canvas->cd(4); @@ -710,8 +768,12 @@ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) leg4->AddEntry(curhistogramclone, legendEntry, "l"); leg4->Draw(); curhistogramclone->GetYaxis()->SetRangeUser(0,heighestval4*1.2); + owntitle4->Clear(); - owntitle4->AddText(trimRunnumberAtBegin(curhistogramclone->GetName())); + if (headerStringsVector.size() > 0) { + owntitle4->AddText(Form("%s, %s",trimRunnumberAtBegin(curhistogramclone->GetName()).Data(), headerStringsVector.at(1).Data())); + owntitle4->AddText(headerStringsVector.at(2)); + } owntitle4->Draw("SAME"); } canvas->cd(0); @@ -719,7 +781,7 @@ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) // canvas->cd(2); hs->Draw("nostack same");// T.DrawTextNDC(.5,.95,"Option \"nostack\""); // canvas->BuildLegend(); canvas->Update(); - MSaveBigPNG(canvas,savepathresults + "/" + canvastitle + ".png"); + MSaveBigPNG(canvas,savepathresults + "/Big_" + canvastitle + ".png",2); TImageDump *img = new TImageDump(savepathresults + "/" + canvastitle + ".png"); canvas->Paint(); @@ -739,6 +801,183 @@ Bool_t plotAllRuns(vector* ptCompareHistogramClassVector) return 1; } +Bool_t FindGoodTitle() { + vector compareHistogramClassVector; + for(Int_t runi=0;runierror) + { + compareHistogramClassVector.push_back(runs[runi]->histogram); + } + } + } + return FindGoodTitle(&compareHistogramClassVector); +} + + +Bool_t FindGoodTitle(vector* ptCompareHistogramClassVector) { + + // Title with everything included: + // + // Spectrum type, Source, Chip generation, Pixel number, Pixel Pitch, Pixel comment + // Temperature, Ionizing radiation, Non-ionizing radiation, Readout Speed, Depletion voltage + // Annealing, System + + Bool_t same_Source = kTRUE; + Bool_t same_NonIonRad = kTRUE; + Bool_t same_IonRad = kTRUE; + Bool_t same_ChipNum = kTRUE; + Bool_t same_ChipGen = kTRUE; + //Bool_t same_Spectra = kTRUE; + Bool_t same_Matrix= kTRUE; + Bool_t same_Temp = kTRUE; + Bool_t same_Clock = kTRUE; + Bool_t same_Depletion = kTRUE; + //Bool_t same_Annealing = kTRUE; + //Bool_t same_System = kTRUE; + + headerStringsVector.clear(); + legendStringsVector.clear(); + + if (ptCompareHistogramClassVector->size() == 1) { + HistogramType* curhistogramclassp = ptCompareHistogramClassVector->at(0); + labbooksctruct curlabbook = curhistogramclassp->run->labbook; + pixelinfo curpixelinfo = curhistogramclassp->run->curpixelinfo; + + TString title1 = Form("%s, %s, %s, %.0fx%.0f #mum^{2} pitch, %s\nT=%.0f {}^{o}C, %.1f MRad, %.1f*10^{13} n_{eq}/cm^{2}, %.2f Mhz, U_{dep}=%.1f V", curlabbook.source.Data(), + curlabbook.chipGen.Data(), curlabbook.matrix.Data(), curpixelinfo.pitchX, curpixelinfo.pitchY, curpixelinfo.comment.Data(), + curlabbook.tempSens, curlabbook.radDoseIon, curlabbook.radDoseNonIon, curlabbook.clock, curlabbook.depletionV); + + TString title2 = Form("%s", curlabbook.comment.Data()); + + headerStringsVector.push_back(title1); + TObjArray *humanreadablestrings = trimRunnumberAtBegin(title1).Tokenize("\n"); + headerStringsVector.push_back(((TObjString *)(humanreadablestrings->At(0)))->String()); + headerStringsVector.push_back(((TObjString *)(humanreadablestrings->At(1)))->String()); + headerStringsVector.push_back(title2); + return false; + } + + HistogramType* firsthistogramclassp = ptCompareHistogramClassVector->at(0); + labbooksctruct firstlabbook = firsthistogramclassp->run->labbook; + pixelinfo firstpixelinfo = firsthistogramclassp->run->curpixelinfo; + + for (UInt_t histogrami=1; histogrami < ptCompareHistogramClassVector->size(); histogrami++) { + HistogramType* curhistogramclassp = ptCompareHistogramClassVector->at(histogrami); + labbooksctruct curlabbook = curhistogramclassp->run->labbook; + pixelinfo curpixelinfo = curhistogramclassp->run->curpixelinfo; + + if (!curlabbook.source.EqualTo(firstlabbook.source)) + same_Source = kFALSE; + if (!curlabbook.chipGen.EqualTo(firstlabbook.chipGen)) + same_ChipGen = kFALSE; + if (!curlabbook.matrix.EqualTo(firstlabbook.matrix)) { + same_Matrix = kFALSE; + cout << colorred << "Not same matrix: " << curlabbook.matrix << " != " << firstlabbook.matrix << endlr; + } + if (firstlabbook.tempSens > 0) { // allow 10 % difference + if (curlabbook.tempSens > firstlabbook.tempSens*1.1 || curlabbook.tempSens < firstlabbook.tempSens*0.9) + same_Temp = kFALSE; + } else { + if (curlabbook.tempSens < firstlabbook.tempSens*1.1 || curlabbook.tempSens > firstlabbook.tempSens*0.9) + same_Temp = kFALSE; + } + if (curlabbook.radDoseIon != firstlabbook.radDoseIon) + same_IonRad = kFALSE; + if (curlabbook.radDoseNonIon != firstlabbook.radDoseNonIon) + same_NonIonRad = kFALSE; + if (!curlabbook.chip.EqualTo(firstlabbook.chip)) + same_ChipNum = kFALSE; + if (curlabbook.clock != firstlabbook.clock) + same_Clock = kFALSE; + if (curlabbook.depletionV != firstlabbook.depletionV) + same_Depletion= kFALSE; +// if (curlabbook.system != firstlabbook.system) +// same_System = kFALSE; + } + + // construct header stringö + TString title1 = ""; + if (same_Source) + title1.Append(Form(", %s", firstlabbook.source.Data())); + if (same_ChipGen) + title1.Append(Form(", %s", firstlabbook.chipGen.Data())); + if (same_Matrix) + title1.Append(Form(", %s, %.0fx%.0f #mum^{2} pitch, %s", firstlabbook.matrix.Data(), firstpixelinfo.pitchX, firstpixelinfo.pitchY, firstpixelinfo.comment.Data())); + title1.Append(Form("\n")); + if (same_Temp) + title1.Append(Form("T=%.0f {}^{o}C", firstlabbook.tempSens)); + if (same_IonRad && firstlabbook.radDoseIon != 0) + title1.Append(Form(", %.1f MRad", firstlabbook.radDoseIon)); + if (same_NonIonRad && firstlabbook.radDoseNonIon != 0) + title1.Append(Form(", %.1f*10^{13} n_{eq}/cm^{2}", firstlabbook.radDoseNonIon)); + if (same_Clock) + title1.Append(Form(", %.2f Mhz", firstlabbook.clock)); + if (same_Depletion && firstlabbook.depletionV > 0) + title1.Append(Form(", U_{dep}=%.1f V", firstlabbook.depletionV)); + + headerStringsVector.push_back(title1); + TObjArray *humanreadablestrings = trimRunnumberAtBegin(title1).Tokenize("\n"); + headerStringsVector.push_back(((TObjString *)(humanreadablestrings->At(0)))->String()); + headerStringsVector.push_back(((TObjString *)(humanreadablestrings->At(1)))->String()); + + // legend creation + for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++) { + TString legendstr = ""; + HistogramType* curhistogramclassp = ptCompareHistogramClassVector->at(histogrami); + labbooksctruct curlabbook = curhistogramclassp->run->labbook; + pixelinfo curpixelinfo = curhistogramclassp->run->curpixelinfo; + if (!same_Source) { if (legendstr.Length()) legendstr.Append(", "); + legendstr.Append(Form("%s", curlabbook.source.Data())); } + if (!same_ChipGen) { if (legendstr.Length()) legendstr.Append(", "); + legendstr.Append(Form("%s", curlabbook.chipGen.Data())); } + if (!same_ChipNum) { if (legendstr.Length()) legendstr.Append(", "); + legendstr.Append(Form("Chip# %s", curlabbook.chip.Data())); } + if (!same_Matrix) { if (legendstr.Length()) legendstr.Append(", "); + legendstr.Append(Form("%s, %.0fx%.0f #mum^{2} pitch, %s", curlabbook.matrix.Data(), curpixelinfo.pitchX, curpixelinfo.pitchY, curpixelinfo.comment.Data())); } + if (!same_Temp) { if (legendstr.Length()) legendstr.Append(", "); + legendstr.Append(Form("T=%.0f {}^{o}C", curlabbook.tempSens)); } + if (!same_IonRad && curlabbook.radDoseIon != 0) { if (legendstr.Length()) legendstr.Append(", "); + legendstr.Append(Form("%.1f MRad", firstlabbook.radDoseIon)); } + if (!same_NonIonRad && curlabbook.radDoseNonIon != 0) { if (legendstr.Length()) legendstr.Append(", "); + legendstr.Append(Form("%.1f*10^{13} n_{eq}/cm^{2}", curlabbook.radDoseNonIon)); } + if (!same_Clock) { if (legendstr.Length()) legendstr.Append(", "); + legendstr.Append(Form("%.2f Mhz", curlabbook.clock)); } + if (!same_Depletion && curlabbook.depletionV > 0) { if (legendstr.Length()) legendstr.Append(", "); + legendstr.Append(Form("U_{dep}=%.1f V", curlabbook.depletionV)); } + legendStringsVector.push_back(legendstr); + } + + // Folder name suffix + TString folderadd = ""; + HistogramType* curhistogramclassp = ptCompareHistogramClassVector->at(0); + labbooksctruct curlabbook = curhistogramclassp->run->labbook; + pixelinfo curpixelinfo = curhistogramclassp->run->curpixelinfo; + if (same_Source) + folderadd.Append(Form(" %s", curlabbook.source.Data())); + if (same_ChipGen) + folderadd.Append(Form(" %s", curlabbook.chipGen.Data())); + if (!same_Matrix) + for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++) + folderadd.Append(Form(" %s", ptCompareHistogramClassVector->at(histogrami)->labbook->matrix.Data())); + if (same_Temp) + folderadd.Append(Form(" %.0fC", curlabbook.tempSens)); + if (same_IonRad && curlabbook.radDoseIon != 0) + folderadd.Append(Form(" %.1f MRad", firstlabbook.radDoseIon)); + if (same_NonIonRad && curlabbook.radDoseNonIon != 0) + folderadd.Append(Form(" %.1fe13 neq", curlabbook.radDoseNonIon)); + if (!same_Clock) + for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++) + folderadd.Append(Form(" %.2f Mhz", ptCompareHistogramClassVector->at(histogrami)->labbook->clock)); + if (!same_Depletion && curlabbook.depletionV > 0) + for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++) + folderadd.Append(Form(" %.1fV", ptCompareHistogramClassVector->at(histogrami)->labbook->depletionV)); + + return false; +} + /** * @brief This functions prints a summary table of runs pushed into the ptCompareHistogramClassVector @@ -810,14 +1049,15 @@ Bool_t printSummaryTable(vector* ptCompareHistogramClassVector) //cout << left << setw(width) << setfill(' ') << "Veto Peak"; filecontent += Form("Veto Peak\t"); // cout << left << setw(width+2) << setfill(' ') << "Veto Integral"; filecontent += Form("Veto Integral\t"); // cout << left << setw(width+2) << setfill(' ') << "Sum Integral"; filecontent += Form("Veto Integral\t"); - Float_t printRTSpixel = 0; + Float_t printRTSpixel = 1; if (printRTSpixel > 0) { cout << left << setw(width-2) << setfill(' ') << "RTS pixel"; filecontent += Form("RTS pixel\t"); } Float_t printSeedIntegral = 1; if (printSeedIntegral > 0) { cout << left << setw(width) << setfill(' ') << "Seed integral"; filecontent += Form("Seed integral\t"); } - Float_t printLeakage = 0; + Float_t printLeakage = 1; if (printLeakage > 0) { cout << left << setw(width+2) << setfill(' ') << "Leakage"; filecontent += Form("Leakage cur.\t"); } cout << left << setw(width-2) << setfill(' ') << "Noise"; filecontent += Form("Noise\t"); - cout << left << setw(width) << setfill(' ') << "Noise threshold"; filecontent += Form("Noise threshold\t"); + Float_t printnsethr = 0; + if (printnsethr > 0) {cout << left << setw(width) << setfill(' ') << "Noise threshold"; filecontent += Form("Noise threshold\t"); } cout << endl; filecontent += Form("\n"); for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++) { @@ -844,7 +1084,7 @@ Bool_t printSummaryTable(vector* ptCompareHistogramClassVector) if (printSeedIntegral > 0) { cout << left << setw(width) << setfill(' ') << printTableElement(curhistogramclassp->integralSeed,ptCompareHistogramClassVector->at(0)->integralSeed); filecontent += Form("%s\t", printTableElement(curhistogramclassp->integralSeed,ptCompareHistogramClassVector->at(0)->integralSeed).c_str()); } if (printLeakage > 0.0) { cout << left << setw(width+2) << setfill(' ') << printTableElement((float)curhistogramclassp->medianLeakageCurrent,(float)ptCompareHistogramClassVector->at(0)->medianLeakageCurrent,1); filecontent += Form("%s\t", printTableElement((float)curhistogramclassp->medianLeakageCurrent,(float)ptCompareHistogramClassVector->at(0)->medianLeakageCurrent,1).c_str()); } cout << left << setw(width-2) << setfill(' ') << printTableElement(curhistogramclassp->avgNoise,ptCompareHistogramClassVector->at(0)->avgNoise); filecontent += Form("%s\t", printTableElement(curhistogramclassp->avgNoise,ptCompareHistogramClassVector->at(0)->avgNoise).c_str()); - cout << left << setw(width) << setfill(' ') << printTableElement(curhistogramclassp->noisethresholdborder,ptCompareHistogramClassVector->at(0)->noisethresholdborder); filecontent += Form("%s\t", printTableElement(curhistogramclassp->noisethresholdborder,ptCompareHistogramClassVector->at(0)->noisethresholdborder).c_str()); + if (printnsethr > 0) { cout << left << setw(width) << setfill(' ') << printTableElement(curhistogramclassp->noisethresholdborder,ptCompareHistogramClassVector->at(0)->noisethresholdborder); filecontent += Form("%s\t", printTableElement(curhistogramclassp->noisethresholdborder,ptCompareHistogramClassVector->at(0)->noisethresholdborder).c_str()); } cout << "" << endl; filecontent += Form("\n"); } cout << right << setw(width*11) << setfill('=') << " " << endl; diff --git a/MABS_run_analyzer/HistogramType.c b/MABS_run_analyzer/HistogramType.c index 198a3cf..db2eb9d 100644 --- a/MABS_run_analyzer/HistogramType.c +++ b/MABS_run_analyzer/HistogramType.c @@ -20,11 +20,12 @@ HistogramType::~HistogramType( void) { } -HistogramType::HistogramType(TString suffix, systemparam* gotsystempar, sensorinfostruct* gotsensorinfo, TString gothumanreadablestr, labbooksctruct* plabbook, Int_t gotcolor, Int_t gotstyle ) { +HistogramType::HistogramType(TString suffix, systemparam* gotsystempar, sensorinfostruct* gotsensorinfo, TString gothumanreadablestr, labbooksctruct* plabbook, Run* runpointer, Int_t gotcolor, Int_t gotstyle ) { histogramdescription = suffix; humanreadablestr = gothumanreadablestr; cursystempar = gotsystempar; labbook = plabbook; + run = runpointer; cursensorinfo = gotsensorinfo; initHistograms(gotcolor, gotstyle); }; @@ -67,8 +68,9 @@ void HistogramType::initHistogram(TH1F* &histogrampointer, TString prefix, Int_t histogrampointer->SetStats(kTRUE); histogrampointer->SetStats(111111111); histogrampointer->SetLineWidth(2); // TODO: set to 3 again - histogrampointer->GetXaxis()->SetTitle("Q_coll [ADU]"); - histogrampointer->GetYaxis()->SetTitle(Form("Entries [1/%.1f ADU]",histogrampointer->GetBinWidth(1))); + histogrampointer->GetXaxis()->SetTitle("Collected charge [ADU]"); + //histogrampointer->GetYaxis()->SetTitle(Form("Entries [1/%.1f ADU]",histogrampointer->GetBinWidth(1))); + histogrampointer->GetYaxis()->SetTitle(Form("Yield [1/%.1f ADU]",histogrampointer->GetBinWidth(1))); histogrampointer->GetXaxis()->CenterTitle(); histogrampointer->GetYaxis()->CenterTitle(); } @@ -108,7 +110,7 @@ Bool_t HistogramType::calibrateHistograms( Float_t gotgain ) { return 1; } gain = gotgain; - calibrated = new HistogramType(histogramdescription+" calibrated", cursystempar, cursensorinfo, humanreadablestr, labbook, color, style); + calibrated = new HistogramType(histogramdescription+" calibrated", cursystempar, cursensorinfo, humanreadablestr, labbook, run, color, style); if (Seed != 0) calibrateHistogram(calibrated->Seed, Seed); if (Sum != 0) calibrateHistogram(calibrated->Sum, Sum); if (Veto != 0) calibrateHistogram(calibrated->Veto, Veto); @@ -154,7 +156,7 @@ void HistogramType::calibrateHistogram(TH1F* &histogrampointernew, TH1F* &histog histogrampointernew = (TH1F*)histogrampointerold->Clone(); histogrampointernew->SetName(Form("%s Calibr.", histogrampointerold->GetName())); histogrampointernew->SetTitle(Form("%s Calibr.", histogrampointerold->GetTitle())); - histogrampointernew->GetXaxis()->SetTitle("Q_coll [e]"); + histogrampointernew->GetXaxis()->SetTitle("Collected charge [e]"); int nbins = histogrampointernew->GetXaxis()->GetNbins(); double new_bins[nbins+1]; for(int i=0; i <= nbins; i++){ @@ -170,7 +172,7 @@ void HistogramType::calibrateHistogramYAxis(TH1F* &histogrampointernew, TH1F* &h histogrampointernew = (TH1F*)histogrampointerold->Clone(); histogrampointernew->SetName(Form("%s Calibr.", histogrampointerold->GetName())); histogrampointernew->SetTitle(Form("%s Calibr.", histogrampointerold->GetTitle())); - histogrampointernew->GetYaxis()->SetTitle("Q_coll [e]"); + histogrampointernew->GetYaxis()->SetTitle("Collected charge [e]"); int nbins = histogrampointernew->GetXaxis()->GetNbins(); for(int x=0; x <= nbins; x++){ histogrampointernew->SetBinContent(x,histogrampointerold->GetBinContent(x)*gain); @@ -182,7 +184,7 @@ void HistogramType::calibrate2DHistogramCounts(TH2F* &histogrampointernew, TH2F* histogrampointernew = (TH2F*)histogrampointerold->Clone(); histogrampointernew->SetName(Form("%s Calibr.", histogrampointerold->GetName())); histogrampointernew->SetTitle(Form("%s Calibr.", histogrampointerold->GetTitle())); - histogrampointernew->GetZaxis()->SetTitle("Q_coll [e]"); + histogrampointernew->GetZaxis()->SetTitle("Collected charge [e]"); int nbinsx = histogrampointernew->GetXaxis()->GetNbins(); int nbinsy = histogrampointernew->GetYaxis()->GetNbins(); @@ -207,7 +209,7 @@ Bool_t HistogramType::normalizeHistograms( Int_t got_frames_found ) { else frames_found = got_frames_found; - normalized = new HistogramType(histogramdescription+" normalized", cursystempar, cursensorinfo, humanreadablestr, labbook, color, style); + normalized = new HistogramType(histogramdescription+" normalized", cursystempar, cursensorinfo, humanreadablestr, labbook, run, color, style); if (Seed != 0) normalizeHistogram(normalized->Seed, Seed); if (Sum != 0) normalizeHistogram(normalized->Sum, Sum); if (Veto != 0) normalizeHistogram(normalized->Veto, Veto); @@ -259,7 +261,7 @@ void HistogramType::normalizeHistogram(TH1F* &histogrampointernew, TH1F* &histog for(int x=0; x <= nbins; x++){ histogrampointernew->SetBinContent(x,histogrampointerold->GetBinContent(x)/frames_found*1000000.0); } - histogrampointernew->GetYaxis()->SetTitle(Form("%s\b/(%d/1000000)]",histogrampointernew->GetYaxis()->GetTitle(), frames_found)); + //histogrampointernew->GetYaxis()->SetTitle(Form("%s\b/(%d/1000000)]",histogrampointernew->GetYaxis()->GetTitle(), frames_found)); } void HistogramType::normalizeHistogramXAxis(TH1F* &histogrampointernew, TH1F* &histogrampointerold) { @@ -272,7 +274,7 @@ void HistogramType::normalizeHistogramXAxis(TH1F* &histogrampointernew, TH1F* &h new_bins[i] = histogrampointernew->GetBinLowEdge(i)/frames_found*1000000; } histogrampointernew->SetBins(nbins, new_bins); - histogrampointernew->GetYaxis()->SetTitle(Form("%s\b/(%d/1000000)]",histogrampointernew->GetYaxis()->GetTitle(), frames_found)); +// histogrampointernew->GetYaxis()->SetTitle(Form("%s\b/(%d/1000000)]",histogrampointernew->GetYaxis()->GetTitle(), frames_found)); } @@ -530,7 +532,7 @@ Double_t* HistogramType::FitPerform(TH1F* histogrampointer, TString fitFuncType, // histogrampointer->GetXaxis()->SetRangeUser(noiseborder,posMaxValHist); TF1* fitFunc = new TF1("fitFunc",GaussTail,noiseborder,posMaxValHist,6); - parameters = (Double_t *)calloc(8, sizeof(Double_t)); + parameters = (Double_t *)calloc(9, sizeof(Double_t)); const Double_t def_amplitude=459.951; const Double_t def_peakcenter=histogrampointer->GetBinCenter(histogrampointer->GetMaximumBin()); // cout << colorcyan << "def_peakcenter: " << def_peakcenter << endlr; @@ -557,12 +559,12 @@ Double_t* HistogramType::FitPerform(TH1F* histogrampointer, TString fitFuncType, fitFunc->SetParLimits(3,0,def_distgauss*2); fitFunc->SetParName(4,"background slope"); fitFunc->SetParameter(4,def_bgslope); - fitFunc->SetParLimits(4,def_bgslope-0.1,def_bgslope+0.1); +// fitFunc->SetParLimits(4,def_bgslope-0.1,def_bgslope+0.1); fitFunc->SetParName(5,"background offset"); fitFunc->SetParameter(5,def_bgoffs); -// fitFunc->SetParLimits(5,def_bgoffs*0.8,def_bgoffs*1.2); + fitFunc->SetParLimits(5,0,def_bgoffs*4); - parameters = (Double_t *)calloc(8, sizeof(Double_t)); + parameters = (Double_t *)calloc(9, sizeof(Double_t)); int fittries = 0; Bool_t failed = false; do { @@ -626,16 +628,17 @@ Double_t* HistogramType::FitPerform(TH1F* histogrampointer, TString fitFuncType, //parameters[7] = FindBorderToPeak(histogrampointer, noiseborder,def_peakcenter, verbose); // starting 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 parameters[6] = histogrampointer->Integral(histogrampointer->GetXaxis()->FindBin( parameters[1] - 2*parameters[2] ), histogrampointer->GetXaxis()->FindBin( parameters[1] + 2*parameters[2])); // integral value of histogram (NOT fit) TF1 *bgfct = new TF1("f1","[0] +[1]*x",0,posMaxValHist); bgfct->SetParameters(parameters[5],parameters[4]); - double integralbg = bgfct->Integral(parameters[1] - 2*parameters[2] ,parameters[1] + 2*parameters[2]); // integral value of histogram (NOT fit) + double integralbg = bgfct->Integral(parameters[7] ,parameters[8]); // integral value of histogram (NOT fit) parameters[6] -= integralbg; if (verbose) { - cout << colorcyan << "Integral from bin : " << histogrampointer->FindBin(parameters[7]) << " to " << histogrampointer->GetXaxis()->FindBin(parameters[1] + 2*parameters[2]) << endlr; - cout << colorcyan << "Integral from val : " << parameters[7] << " to " << parameters[1] + 2*parameters[2] << endlr; + cout << colorcyan << "Integral from bin : " << histogrampointer->FindBin(parameters[7]) << " to " << histogrampointer->GetXaxis()->FindBin(parameters[8]) << endlr; + cout << colorcyan << "Integral from val : " << parameters[7] << " to " << parameters[8] << endlr; cout << colorcyan << "Integral value: " << parameters[6] << endlr; cout << colorcyan << "Integral bg: " << integralbg << endlr; } diff --git a/MABS_run_analyzer/HistogramType.h b/MABS_run_analyzer/HistogramType.h index 8b7e9ee..ba758fb 100644 --- a/MABS_run_analyzer/HistogramType.h +++ b/MABS_run_analyzer/HistogramType.h @@ -110,8 +110,12 @@ public: ~HistogramType(void); /** @brief constructor */ - HistogramType(TString suffix, systemparam* gotsystempar, sensorinfostruct* gotsensorinfo, TString gothumanreadablestr="", labbooksctruct* plabbook=0, Int_t gotcolor=0, Int_t gotstyle=0); + HistogramType(TString suffix, systemparam* gotsystempar, sensorinfostruct* gotsensorinfo, TString gothumanreadablestr="", labbooksctruct* plabbook=0, Run* runpointer=0, Int_t gotcolor=0, Int_t gotstyle=0); + /// Pointer to the run class wich initialized this histogram type + Run* run = 0; + + //***************** // TH HISTOGRAMS //***************** @@ -215,7 +219,7 @@ public: /// A string representing the current run database information in a human readable format TString humanreadablestr=""; /// type in here what the histogram is intended for or how it is calculated, will be added to filenames - TString histogramdescription = ""; + TString histogramdescription = ""; /// The gain used to rescale the histograms Float_t gain = 0; /// set to true, if bins are in electrons, otherwise in ADU diff --git a/MABS_run_analyzer/MAPS.c b/MABS_run_analyzer/MAPS.c index 77b13c8..abe296d 100644 --- a/MABS_run_analyzer/MAPS.c +++ b/MABS_run_analyzer/MAPS.c @@ -132,6 +132,7 @@ Bool_t MAPS::initOldRootFile() { MAPS::~MAPS(void) { if(fSave && fOk) { + system("mkdir "+ fOutDir + " -p"); fOutputFile->cd(); fHitTree->Write("",TObject::kOverwrite); diff --git a/MABS_run_analyzer/Run.c b/MABS_run_analyzer/Run.c index e617e15..497cc3b 100644 --- a/MABS_run_analyzer/Run.c +++ b/MABS_run_analyzer/Run.c @@ -42,7 +42,7 @@ Run::Run(Int_t runnumber, Int_t loopi, TString customtitle) //db = TSQLServer::Connect("mysql://jspc29.x-matter.uni-frankfurt.de","radhard","mimosa88"); try { - string selectquery = prepareSQLStatement("select `System`, `TempCooling`, COALESCE(`TempChipStart`,-10000) as `TempChipStart`, COALESCE(`TempChipEnd`,-10000) as `TempChipEnd`, `ChipNum`, `RadiationSource`, `Matrix`, `Clock`, `StorePath`, `ChipGen`,COALESCE(`VetoPeak`,-1) as `VetoPeak`,COALESCE(`SeedPeak`,-1) as `SeedPeak`,COALESCE(`SumPeak`,-1) as `SumPeak`,COALESCE(`Gain`,-1) as `Gain`,COALESCE(`Avg.Noise`,-1) as `Avg.Noise`,COALESCE(`Avg.Noise+`,-1) as `Avg.Noise+`,COALESCE(`Avg.Noise-`,-1) as `Avg.Noise-`,COALESCE(`CCE_1`,-1) as `CCE_1`,COALESCE(`CCE_25`,-1) as `CCE_25`,COALESCE(`Frames_found`,-1) as `Frames_found`,COALESCE(`Sr90IntegralVal`,-1) as `Sr90IntegralVal`,COALESCE(`StoN`,-1) as `StoN`, `Comment` from `radhard`.`labbook` WHERE `runnumber`=" + numberToString<>(labbook.runnumber)); + string selectquery = prepareSQLStatement("select `System`, `TempCooling`, COALESCE(`TempChipStart`,-10000) as `TempChipStart`, COALESCE(`TempChipEnd`,-10000) as `TempChipEnd`, `ChipNum`, `RadiationSource`, `Matrix`, `Clock`, `StorePath`, `ChipGen`,COALESCE(`VetoPeak`,-1) as `VetoPeak`,COALESCE(`SeedPeak`,-1) as `SeedPeak`,COALESCE(`SumPeak`,-1) as `SumPeak`,COALESCE(`Gain`,-1) as `Gain`,COALESCE(`Avg.Noise`,-1) as `Avg.Noise`,COALESCE(`Avg.Noise+`,-1) as `Avg.Noise+`,COALESCE(`Avg.Noise-`,-1) as `Avg.Noise-`,COALESCE(`CCE_1`,-1) as `CCE_1`,COALESCE(`CCE_25`,-1) as `CCE_25`,COALESCE(`Frames_found`,-1) as `Frames_found`,COALESCE(`Sr90IntegralVal`,-1) as `Sr90IntegralVal`,COALESCE(`StoN`,-1) as `StoN`, `Comment`, `DepletionVoltage` from `radhard`.`labbook` WHERE `runnumber`=" + numberToString<>(labbook.runnumber)); res = db->Query(selectquery.c_str()); nrows = res->GetRowCount(); if (nrows > 0) @@ -56,7 +56,7 @@ Run::Run(Int_t runnumber, Int_t loopi, TString customtitle) labbook.chip = customtitle; labbook.source = (rowsql->GetField(5) != NULL)?std::string(rowsql->GetField(5)):""; labbook.matrix = (rowsql->GetField(6) != NULL)?std::string(rowsql->GetField(6)):""; - labbook.clock = (rowsql->GetField(7) != NULL)?atoi(rowsql->GetField(7)):100; + labbook.clock = (rowsql->GetField(7) != NULL)?atof(rowsql->GetField(7)):100; labbook.chipGen = (rowsql->GetField(9) != NULL)?std::string(rowsql->GetField(9)):""; labbook.storepath = (rowsql->GetField(8) != NULL)?std::string(rowsql->GetField(8)):""; // replace windows drive notation with linux style @@ -105,6 +105,7 @@ Run::Run(Int_t runnumber, Int_t loopi, TString customtitle) labbook.Sr90IntegralVal = (rowsql->GetField(20) != NULL)?atof(rowsql->GetField(20)):-1; labbook.StoN = (rowsql->GetField(21) != NULL)?atof(rowsql->GetField(21)):-1; labbook.comment = (rowsql->GetField(22) != NULL)?std::string(rowsql->GetField(22)):""; + labbook.depletionV = (rowsql->GetField(23) != NULL)?atof(rowsql->GetField(23)):-1; // labbook.frames_Analyzed = (rowsql->GetField(20) != NULL)?atoi(rowsql->GetField(20)):-1; delete res; if (labbook.chipGen.Length() > 0) @@ -126,7 +127,7 @@ Run::Run(Int_t runnumber, Int_t loopi, TString customtitle) } if (labbook.matrix.Length() > 0) // versuche infos zum Pixel aus der ChipDatenbank zu bekommen { - selectquery=prepareSQLStatement("select `pitchX`, `pitchY`, `num_diod`, `staggered` from `radhard`.`pixelinfo` WHERE `matrix`='" + labbook.matrix + "' AND `ChipGen`='" + labbook.chipGen + "'"); + selectquery=prepareSQLStatement("select `pitchX`, `pitchY`, `num_diod`, `staggered`, `comment` from `radhard`.`pixelinfo` WHERE `matrix`='" + labbook.matrix + "' AND `ChipGen`='" + labbook.chipGen + "'"); res = db->Query(selectquery.c_str()); nrows = res->GetRowCount(); if (nrows > 0) @@ -135,7 +136,8 @@ Run::Run(Int_t runnumber, Int_t loopi, TString customtitle) curpixelinfo.pitchX = (rowsql->GetField(0) != NULL)?atof(rowsql->GetField(0)):-1; curpixelinfo.pitchY = (rowsql->GetField(1) != NULL)?atof(rowsql->GetField(1)):-1; curpixelinfo.ndiods = (rowsql->GetField(2) != NULL)?atoi(rowsql->GetField(2)):-1; - curpixelinfo.staggered = (rowsql->GetField(3) != NULL)?atoi(rowsql->GetField(3)):0; + curpixelinfo.staggered = (rowsql->GetField(3) != NULL)?atoi(rowsql->GetField(3)):0; + curpixelinfo.comment = (rowsql->GetField(4) != NULL)?std::string(rowsql->GetField(4)):""; delete res; } } @@ -157,35 +159,35 @@ Run::Run(Int_t runnumber, Int_t loopi, TString customtitle) cout << colorwhite << "init Histogram classes:" << endlr; // default histogram class, no special cuts applied - histogram = new HistogramType("", &cursystemparam, &cursensorinfo, humanreadablestr, &labbook, rootcolors[plotStyle], rootlinestyle[plotStyle] ); + histogram = new HistogramType("", &cursystemparam, &cursensorinfo, humanreadablestr, &labbook, this, rootcolors[plotStyle], rootlinestyle[plotStyle]); HistogramClassVector.push_back(histogram); // dynamical cluster threshold cut - histogramthreshold = new HistogramType(" Threshold", &cursystemparam, &cursensorinfo, humanreadablestr, &labbook, rootcolors[plotStyle], rootlinestyle[plotStyle] ); + histogramthreshold = new HistogramType(" Threshold", &cursystemparam, &cursensorinfo, humanreadablestr, &labbook, this, rootcolors[plotStyle], rootlinestyle[plotStyle] ); HistogramClassVector.push_back(histogramthreshold); // fixed threshold cut -// histogramfixedthreshold = new HistogramType(" fixed Threshold", &cursystemparam, &cursensorinfo, humanreadablestr, &labbook, rootcolors[plotStyle], rootlinestyle[plotStyle] ); + // histogramfixedthreshold = new HistogramType(" fixed Threshold", &cursystemparam, &cursensorinfo, humanreadablestr, &labbook, rootcolors[plotStyle], rootlinestyle[plotStyle] ); // HistogramClassVector.push_back(histogramfixedthreshold); // RTS pixel removed histograms - histogramwoRTS = new HistogramType(" RTS cleaned", &cursystemparam, &cursensorinfo, humanreadablestr, &labbook, rootcolors[plotStyle], rootlinestyle[plotStyle] ); + histogramwoRTS = new HistogramType(" RTS cleaned", &cursystemparam, &cursensorinfo, humanreadablestr, &labbook, this, rootcolors[plotStyle], rootlinestyle[plotStyle] ); histogramwoRTS->maskRTSpixel = true; HistogramClassVector.push_back(histogramwoRTS); - histogramwoRTSthreshold = new HistogramType(" Threshold, RTS cleaned", &cursystemparam, &cursensorinfo, humanreadablestr, &labbook, rootcolors[plotStyle], rootlinestyle[plotStyle] ); + histogramwoRTSthreshold = new HistogramType(" Threshold, RTS cleaned", &cursystemparam, &cursensorinfo, humanreadablestr, &labbook, this, rootcolors[plotStyle], rootlinestyle[plotStyle] ); histogramwoRTSthreshold->maskRTSpixel = true; HistogramClassVector.push_back(histogramwoRTSthreshold); -// histogramwoRTSAggresive = new HistogramType(" more RTS cleaned", &cursystemparam, &cursensorinfo, humanreadablestr, &labbook, rootcolors[plotStyle], rootlinestyle[plotStyle] ); + // histogramwoRTSAggresive = new HistogramType(" more RTS cleaned", &cursystemparam, &cursensorinfo, humanreadablestr, &labbook, this, rootcolors[plotStyle], rootlinestyle[plotStyle]); // histogramwoRTSAggresive->maskRTSpixel = true; // histogramwoRTSAggresive->RTSthreshold = 1.5; // HistogramClassVector.push_back(histogramwoRTSAggresive); -// histogramwoRTSAggresivethreshold = new HistogramType(" Threshold, more RTS cleaned", &cursystemparam, &cursensorinfo, humanreadablestr, &labbook, rootcolors[plotStyle], rootlinestyle[plotStyle] ); + // histogramwoRTSAggresivethreshold = new HistogramType(" Threshold, more RTS cleaned", &cursystemparam, &cursensorinfo, humanreadablestr, &labbook, this, rootcolors[plotStyle], rootlinestyle[plotStyle] ); // histogramwoRTSAggresivethreshold->maskRTSpixel = true; // histogramwoRTSAggresivethreshold->RTSthreshold = 1.0; // HistogramClassVector.push_back(histogramwoRTSAggresivethreshold); // histogram with pixel, which have a good veto spectrum -// histogramGoodVeto = new HistogramType(" good Veto", &cursystemparam, &cursensorinfo, humanreadablestr, &labbook, rootcolors[plotStyle], rootlinestyle[plotStyle] ); + // histogramGoodVeto = new HistogramType(" good Veto", &cursystemparam, &cursensorinfo, humanreadablestr, &labbook, this, rootcolors[plotStyle], rootlinestyle[plotStyle] ); // HistogramClassVector.push_back(histogramGoodVeto); debugDBreadout(); @@ -224,6 +226,7 @@ Bool_t Run::debugDBreadout() cout << "| resistivity: " << std::right << colorwhite << labbook.resistivity << endlr; cout << "| epi_thickness: " << std::right << colorwhite << labbook.epi_thickness << endlr; cout << "| clock: " << std::right << colorwhite << labbook.clock << endlr; + cout << "| depletion vol. " << std::right << colorwhite << labbook.depletionV << endlr; cout << "| storepath: " << std::right << colorwhite << labbook.storepath << endlr; cout << "| posSeedDB: " << std::right << colorwhite << labbook.posSeedDB << endlr; cout << "| posSumDB: " << std::right << colorwhite << labbook.posSumDB << endlr; @@ -246,7 +249,7 @@ Bool_t Run::debugDBreadout() void Run::setSystemSpecificParameters() { // systemparam systemparamUSB (2800/*maxbin*/,2800/4/*nbins*/, 25/*vetothreshold*/, 10/*maxbinnoise*/, 100/*nbinsnoise*/); // TODO: uncomment and add again old binning - systemparam systemparamUSB (2800/*maxbin*/,2800/6/*nbins*/, 25/*vetothreshold*/, 10/*maxbinnoise*/, 100/*nbinsnoise*/); + systemparam systemparamUSB (1400/*maxbin*/,1400/2/*nbins*/, 25/*vetothreshold*/, 10/*maxbinnoise*/, 100/*nbinsnoise*/); systemparam systemparamPegasus (2800,2800/2,20,10,100); systemparam systemparamPXI (800*16,800,75,150,150); systemparam systemparamFSBB (2800,2800/4,25,10,100); @@ -260,9 +263,9 @@ void Run::setSystemSpecificParameters() cursystemparam = systemparamPXI; else if (labbook.system.EqualTo("Pegasus")) // && labbook.chipGen.EqualTo("34") ) cursystemparam = systemparamPegasus; - if (labbook.system.EqualTo("USB") && labbook.chipGen.EqualTo("Mi19") ) + else if (labbook.system.EqualTo("USB") && labbook.chipGen.EqualTo("Mi19") ) cursystemparam = systemparamUSBMi19; - if (labbook.system.EqualTo("USB") && labbook.chipGen.EqualTo("Pipper2") ) + else if (labbook.system.EqualTo("USB") && labbook.chipGen.EqualTo("Pipper2") ) cursystemparam = systemparamPipper2; else if (labbook.system.EqualTo("USB")) // && labbook.chipGen.EqualTo("34") ) cursystemparam = systemparamUSB; @@ -443,8 +446,10 @@ Bool_t Run::analyzeRun(Bool_t force) for (vector::iterator curHistogramClass = HistogramClassVector.begin(); curHistogramClass != HistogramClassVector.end(); curHistogramClass++) { cout << "Processing histograms in class: <" << colorwhite << (*curHistogramClass)->histogramdescription << colorreset << " >" << endlr; if ((*curHistogramClass)->maskRTSpixel) { - cout << colorwhite << " FindRTSPixelToMask():" << endlr; -// FindRTSPixelToMask(*curHistogramClass); + if (labbook.chipGen=="Mi19") { + cout << colorwhite << " FindRTSPixelToMask():" << endlr; + FindRTSPixelToMask(*curHistogramClass); + } } } cout << "--------------------------------------------" << endl; @@ -773,7 +778,11 @@ Bool_t Run::setLabel(TString newlabel) Bool_t Run::generateReadableRunCode() { - humanreadablestr = Form("%s, %s, chip %s, %s, %sT=%.1f", labbook.source.Data(), labbook.chipGen.Data(), labbook.chip.Data(), labbook.matrix.Data(), humanreadablesuffix.Data(), labbook.temp); + humanreadablestr = Form("%s, %s, %s, %.0fx%.0f #mum^{2} pitch, %s, T=%.0f {}^{o}C, %.1f MRad, %.1f*10^{13} n_{eq}/cm^{2}, %.2f Mhz, U_{dep}=%.1f V", labbook.source.Data(), + labbook.chipGen.Data(), labbook.matrix.Data(), curpixelinfo.pitchX, curpixelinfo.pitchY, curpixelinfo.comment.Data(), + labbook.tempSens, labbook.radDoseIon, labbook.radDoseNonIon, labbook.clock, labbook.depletionV); + + //humanreadablestr = Form("%s, %s, chip %s, %s, %sT=%.1f", labbook.source.Data(), labbook.chipGen.Data(), labbook.chip.Data(), labbook.matrix.Data(), humanreadablesuffix.Data(), labbook.temp); cout << colorwhite << " " << colorgreen << humanreadablestr << colorwhite <<" " << endlr; for (vector::iterator curHistogramClass = HistogramClassVector.begin(); curHistogramClass != HistogramClassVector.end(); curHistogramClass++) (*curHistogramClass)->humanreadablestr = humanreadablestr; @@ -802,7 +811,7 @@ Bool_t Run::generateReadableRunCode() runcode+= tempstring; runcode+= Form("%+.0f", labbook.temp*10); runcode+= Form("%+.0f", labbook.tempSens*10); - runcode+= Form("%03i", labbook.clock); + runcode+= Form("%.0f", labbook.clock); runcode+= Form("%c", labbook.system[0]); if (dividedmatrix) { @@ -1361,7 +1370,7 @@ Bool_t Run::binSeedSumVeto() } // end loop over all frames // gROOT->SetBatch(kTRUE); for (vector::iterator curHistogramClass = HistogramClassVector.begin(); curHistogramClass != HistogramClassVector.end(); curHistogramClass++) { - Double_t* parameters = (Double_t *)calloc(8, sizeof(Double_t)); + Double_t* parameters = (Double_t *)calloc(10, sizeof(Double_t)); // allocate 10 parameters for safety, maximum 9 used at the moment (*curHistogramClass)->FindNoisethresholdborder((*curHistogramClass)->Seed, false, false); if (labbook.runnumber == 343056) (*curHistogramClass)->noisethresholdborder = 34; @@ -2102,7 +2111,7 @@ TCanvas* Run::plot1DHistogram(HistogramType* HistogramTypepointer, TH1F* onehist onehistogram=ShowOverflow(onehistogram); onehistogram->Draw(); - Double_t* parameters = (Double_t *)calloc(9, sizeof(Double_t)); // allocate 9 parameters for safety, maximum 8 used at the moment + Double_t* parameters = (Double_t *)calloc(10, sizeof(Double_t)); // allocate 10 parameters for safety, maximum 9 used at the moment Float_t maxValue = 0; if (fitFuncType!="") { @@ -2134,11 +2143,13 @@ TCanvas* Run::plot1DHistogram(HistogramType* HistogramTypepointer, TH1F* onehist if (fitFuncType=="GaussTail") { Float_t integralstart = parameters[7]; + Float_t integralend = parameters[8]; Float_t integralval = parameters[6]; TString integrallbl = Form("Integral: %.0f", integralval); // cout << colorcyan << " " << HistogramTypepointer->histogramdescription << endlr; // cout << colorcyan << ": " << parameters[7] << endlr; plotVerticalLineHeigher(onehistogram, integralstart); + plotVerticalLineHeigher(onehistogram, integralend, "Integral to:"); plotTextAtVal(onehistogram, maxValue, integrallbl); if (verbose) { cout << "fit parameters " << endl; @@ -2232,7 +2243,7 @@ Bool_t Run::writeAllHistogramsToFile() TString filename= savepathresults + "/" + runcode + " histograms.dat"; fstream* fout = new fstream(filename,ios::out); - TString header = Form("#%s %lu frames\n", runcode.Data(), frames_found); + TString header = Form("#%s, %s, %lu frames\n", runcode.Data(), humanreadablestr.Data(), frames_found); header += Form("#posVeto, run: %.1f, DB: %.1f, Fe55 DB (%d, %.1f): %.1f\n", histogram->posVeto, labbook.posVetoDB, Fe55run.posVetorunnumber, Fe55run.temperature, Fe55run.posVeto); header += Form("#\t\t"); diff --git a/MABS_run_analyzer/Run.h b/MABS_run_analyzer/Run.h index d4345ee..f127117 100644 --- a/MABS_run_analyzer/Run.h +++ b/MABS_run_analyzer/Run.h @@ -36,9 +36,10 @@ #define SERVERUSER "radhard" #define SERVERPWD "mimosa88" +class MAPS; +class Run; #include "MAPS.c" #include "HistogramType.c" -class MAPS; /** * @file Run.h * @brief Has all the raw and processed information from MAPS about a specific run @@ -169,29 +170,12 @@ private: Double_t noisequantiles[3]; /// noise quantiles: mean value, sigma in postive direction and sigma in negative direction Double_t leakagequantiles[3]; - - /// A string representing the current run database information in a human readable format - TString humanreadablestr=""; /** * @brief Checks if a file exists */ Bool_t checkFileExists(TString); - - - /** @brief information about the submatrices of the sensor - */ - struct pixelinfo - { - Int_t ndiods = -1; - Float_t diodesize = -1; - Float_t pitchX = -1; - Float_t pitchY = -1; - Bool_t staggered = 0; - /// TODO: add more - }; - pixelinfo curpixelinfo; - + Int_t* rootlinestyle; /** @brief calls #initCluster for each structure of type @c Run::histogram @@ -351,6 +335,8 @@ public: /// stores information from the SQL database of a given run labbooksctruct labbook; + pixelinfo curpixelinfo; + /// path to the RAW files on LINUX systems TString storepathRAWLinux = ""; /// path to the ROOT files on LINUX systems @@ -360,6 +346,9 @@ public: /// number of frames found in given folder ULong_t frames_found = 0; + /// A string representing the current run database information in a human readable format + TString humanreadablestr=""; + TFile* rootfile; /** @brief sets #sensorinfocurrent after run data got from db, USB or PXI */ diff --git a/MABS_run_analyzer/help.h b/MABS_run_analyzer/help.h index cebec7f..12a44e8 100644 --- a/MABS_run_analyzer/help.h +++ b/MABS_run_analyzer/help.h @@ -252,7 +252,7 @@ struct labbooksctruct /// Thickness of epitexial layer in micro meters Int_t epi_thickness = -1; /// clock rate at wich the chip was measured in MHz - Int_t clock = 100; + Float_t clock = 100; /// path to the RAW files as seen from system which took the run TString storepath = ""; /// number of frames analyzed for this run @@ -268,6 +268,21 @@ struct labbooksctruct /// average F0 in current run Float_t averageF0 = -1; Float_t sigmaF0 = -1; + /// depletion voltage + Float_t depletionV = -1; +}; + +/** @brief information about the submatrices of the sensor + */ +struct pixelinfo +{ + Int_t ndiods = -1; + Float_t diodesize = -1; + Float_t pitchX = -1; + Float_t pitchY = -1; + Bool_t staggered = 0; + TString comment = ""; + /// TODO: add more }; void preparecanvas() { @@ -406,9 +421,12 @@ void plotVerticalLine(TH1F* histogrampointer, Float_t xVal) { * @param histogrampointer histogram pointer to calculate vertical line end * @param xVal position of the vertical line at x-axis */ -void plotVerticalLineHeigher(TH1F* histogrampointer, Float_t xVal) { +void plotVerticalLineHeigher(TH1F* histogrampointer, Float_t xVal, TString texttoprint = "") { if (xVal > 0) - { + { + if (texttoprint.Length() < 1) + texttoprint = "integral from:"; + Double_t gPadX2 = histogrampointer->GetBinCenter(histogrampointer->GetXaxis()->GetLast()); Double_t gPadY2 = histogrampointer->GetMaximum(); // cout << gPadX2 << endl; @@ -424,10 +442,10 @@ void plotVerticalLineHeigher(TH1F* histogrampointer, Float_t xVal) { l->Draw("same"); TString legendEntry; - if (abs(xVal) < 1) - legendEntry = TString(Form("integral from: %.2f",xVal )); + if (abs(xVal) < 1) // TODO make dunction generic + legendEntry = TString(Form("%s %.2f",texttoprint.Data(),xVal )); else - legendEntry = TString(Form("integral from: %.1f",xVal )); + legendEntry = TString(Form("%s %.1f",texttoprint.Data(),xVal )); // TLegend* leg = new TLegend(xVal*0.9/gPadX2,posMaxValue*1.05/gPadY2,xVal*1.2/gPadX2,posMaxValue*1.1/gPadY2, "", "");//(0.6,0.7,0.89,0.89); TLegend* leg = new TLegend(xVal/gPadX2-0.25,posMaxValue/gPadY2+0.15,xVal/gPadX2+0.1,posMaxValue/gPadY2+0.25);//(0.6,0.7,0.89,0.89); leg->SetFillColor(0);