From ae4512922c0131416198b5491d4cf429f6696d36 Mon Sep 17 00:00:00 2001 From: Benjamin Linnik Date: Mon, 13 Nov 2017 15:11:49 +0100 Subject: [PATCH] Analyzer: Reorganized code, better result paths --- MABS_run_analyzer/ChargeSpektrum.c | 36 ++++++++++----------- MABS_run_analyzer/ChargeSpektrumFunctions.c | 15 +++++---- MABS_run_analyzer/Run.c | 10 +++--- MABS_run_analyzer/help.h | 11 +++++++ 4 files changed, 43 insertions(+), 29 deletions(-) diff --git a/MABS_run_analyzer/ChargeSpektrum.c b/MABS_run_analyzer/ChargeSpektrum.c index 71f7107..0dd2d86 100644 --- a/MABS_run_analyzer/ChargeSpektrum.c +++ b/MABS_run_analyzer/ChargeSpektrum.c @@ -29,13 +29,12 @@ void ChargeSpektrum(TString runnumber = "") numberRuns=0; std::vector runList; - TString analysisis; // what kind of analyse to make, can be more than one std::vector runListForceAnalysis; std::vector runListCustomTitle; std::vector sumuprunList; // not used yet, add runs to each other, combine statistics #include "SetStyle.c" - InterpreteUserInput(runnumber, &runList, &runListForceAnalysis, &runListCustomTitle, &sumuprunList, &analysisis); + InterpreteUserInput(runnumber, &runList, &runListForceAnalysis, &runListCustomTitle, &sumuprunList, &analysisType); runs = new Run*[numberRuns]; // set file path and other variables to be set @@ -88,7 +87,10 @@ void ChargeSpektrum(TString runnumber = "") runs[runi] = new Run(runList[runi], runi); if (!runs[runi]->error) { - runs[runi]->setResultsPath(savepathresults); + vector CompareHistogramVector; + CompareHistogramVector.push_back(runs[runi]->histogram->Seed); + FindGoodTitle(&CompareHistogramVector); + runs[runi]->setResultsPath(savepathresults + folderadd); runs[runi]->error=runs[runi]->initRun(); runs[runi]->setDynamicalNoiseMode("simple"); runs[runi]->useDynamicalNoise(true); @@ -107,7 +109,7 @@ void ChargeSpektrum(TString runnumber = "") //runs[runi]->setNoisethresholdborderE(220); // runs[runi]->analyzeFrame(680); // continue; - runs[runi]->setFixedThresholdValueADU(30); +// runs[runi]->setFixedThresholdValueADU(30); // creates or opens .root file, can analyze the RAW data @@ -141,13 +143,13 @@ void ChargeSpektrum(TString runnumber = "") // use only lower case when matching anaylsis types - if (analysisis.Contains("clas")) { // classic analysis + if (analysisType.Contains("clas")) { // classic analysis compareHistogramClassVectorClassic.push_back(runs[runi]->histogram->normalized); if (runi+1 == runnumber) compareHistogramClassVectorVector.push_back(compareHistogramClassVectorClassic); } - if (analysisis.Contains("dynthresh") || analysisis.Contains("dynamicalthresh")) { // fixed threshold analysis + if (analysisType.Contains("dynthresh") || analysisType.Contains("dynamicalthresh")) { // fixed threshold analysis vector compareHistogramClassVectorDynamicalThreshold; compareHistogramClassVectorDynamicalThreshold.push_back(runs[runi]->histogram); compareHistogramClassVectorDynamicalThreshold.push_back(runs[runi]->histogramdynamicalthreshold); @@ -155,17 +157,17 @@ void ChargeSpektrum(TString runnumber = "") compareHistogramClassVectorDynamicalThreshold.clear(); } - if (analysisis.Contains("cali")) { // calibrated analysis + if (analysisType.Contains("cali")) { // calibrated analysis compareHistogramClassVectorCalibrated.push_back(runs[runi]->histogram->calibrated->normalized); if (runi+1 == runnumber) compareHistogramClassVectorVector.push_back(compareHistogramClassVectorCalibrated); } - if (analysisis.Contains("signal")) { // F0 analysis for some frames, quantitatively + if (analysisType.Contains("signal")) { // F0 analysis for some frames, quantitatively runs[runi]->processed->plotSignal(100,1000); } - if (analysisis.Contains("depl")) { // depletion analysis + if (analysisType.Contains("depl")) { // depletion analysis compareHistogramVectorDepletion.push_back(runs[runi]->histogramdynamicalthreshold->normalized->SeedPerc); datainputPosVeto->itsHistogramType = runs[runi]->histogramdynamicalthreshold; @@ -176,18 +178,16 @@ void ChargeSpektrum(TString runnumber = "") ntupleVectorDepltetion1.push_back(datainputPosVeto); ntupleVectorVector.push_back(ntupleVectorDepltetion1); } - + prop2ndpixelfire->itsHistogramType = runs[runi]->histogramdynamicalthreshold; prop2ndpixelfire->xaxisTitle = "Voltage"; prop2ndpixelfire->yaxisTitle = "Propability for second pixel to fire"; prop2ndpixelfire->Fill(runs[runi]->labbook.depletionV,runs[runi]->histogramdynamicalthreshold->clustermultiplicity->GetBinContent(2),0,0); - cout << colorcyan << " Cluster Mult.:" << runs[runi]->histogramdynamicalthreshold->clustermultiplicity << endlr; if (runi+1 == runnumber) { ntupleVectorDepltetion2.push_back(prop2ndpixelfire); ntupleVectorVector.push_back(ntupleVectorDepltetion2); } - Double_t AverageCharge[9]; Double_t TotalHits[9]; for (UInt_t sumi = 0; sumi < 9; sumi++) { @@ -218,7 +218,7 @@ void ChargeSpektrum(TString runnumber = "") } } - if (analysisis.Contains("rts")) { // rts studies + if (analysisType.Contains("rts")) { // rts studies vector compareHistogramClassVectorRTS; compareHistogramClassVectorRTS.push_back(runs[runi]->histogramwoRTS); compareHistogramClassVectorRTS.push_back(runs[runi]->histogram); @@ -238,7 +238,7 @@ void ChargeSpektrum(TString runnumber = "") } } - if (analysisis.Contains("seedf")) { // seedfit: seed integral anaylsis + if (analysisType.Contains("seedf")) { // seedfit: seed integral anaylsis runs[runi]->plot1DHistogram( runs[runi]->histogram->normalized->Seed, "gaus", true, false, false, runs[runi]->histogram->fixedThresholdValue); runs[runi]->plot1DHistogram( runs[runi]->histogramdynamicalthreshold->normalized->Seed, "gaus", true, false, false, runs[runi]->histogram->fixedThresholdValue); @@ -258,7 +258,7 @@ void ChargeSpektrum(TString runnumber = "") } } - if (analysisis.Contains("sumf")) { // seedfit: seed integral anaylsis + if (analysisType.Contains("sumf")) { // seedfit: seed integral anaylsis runs[runi]->plot1DHistogram(*(runs[runi]->histogram->normalized->Sum), "gaus", true, false, false, runs[runi]->histogram->fixedThresholdValue); runs[runi]->plot1DHistogram(*(runs[runi]->histogramdynamicalthreshold->normalized->Sum), "gaus", true, false, false, runs[runi]->histogram->fixedThresholdValue); @@ -278,7 +278,7 @@ void ChargeSpektrum(TString runnumber = "") } } - if (analysisis.Contains("cluster")) { // analyze cluster formation + if (analysisType.Contains("cluster")) { // analyze cluster formation // show cluster multiplicity compareHistogramVectorClusterMultiplicity.push_back(runs[runi]->histogram->normalized->clustermultiplicity); // runs[runi]->plot1DHistogram( runs[runi]->histogram->clustermultiplicity); @@ -352,7 +352,7 @@ void ChargeSpektrum(TString runnumber = "") } - if (analysisis.Contains("temp")) { // analyze temperatur dependance + if (analysisType.Contains("temp")) { // analyze temperatur dependance compareHistogramClassVectorTemp.push_back(runs[runi]->histogramfixedthreshold->normalized); Double_t AverageChargeTempSeed = 0; @@ -388,7 +388,7 @@ void ChargeSpektrum(TString runnumber = "") } - if (analysisis.Contains("f0")) { // analyze cluster formation + if (analysisType.Contains("f0")) { // analyze cluster formation // Plot F0 signal vector compareHistogramVectorF0; compareHistogramVectorF0.push_back(runs[runi]->averageF0DistrEnd); diff --git a/MABS_run_analyzer/ChargeSpektrumFunctions.c b/MABS_run_analyzer/ChargeSpektrumFunctions.c index db281ea..4a18cb3 100644 --- a/MABS_run_analyzer/ChargeSpektrumFunctions.c +++ b/MABS_run_analyzer/ChargeSpektrumFunctions.c @@ -70,7 +70,7 @@ Bool_t writeOneHistogramTypeToFile(vector*); /** @brief A function to setup file path and other variables * */ -void Init(); +void Init(TString); /** @brief A function to plot ntuplöe data into a canvas @@ -106,6 +106,7 @@ vector< vector > compareHistogramVectorVector; vector< vector > ntupleVectorVector; TString ownpath = ""; TString savepathresults; +TString analysisType = ""; void setCustomPath(TString setOwnpath) { @@ -128,9 +129,9 @@ void ChargeSpektrum(Int_t runnumber, Int_t runnumber2) void Init() { - //FindGoodTitle(); +// FindGoodTitle(); TTimeStamp timestamp = TTimeStamp(); - savepathresults = Form("./results/%d%06d", (int)timestamp.GetDate(kFALSE), (int)timestamp.GetTime(kFALSE)); + savepathresults = Form("./results/%d%06d %s", (int)timestamp.GetDate(kFALSE), (int)timestamp.GetTime(kFALSE), analysisType.Data()); } @@ -387,7 +388,7 @@ Bool_t writeNTupleVectorToFile(std::vector* ntuplepvectorpointer) { if (ntuplepvectorpointer->size() > 0) { TNtupleO* ntuplepointer = ntuplepvectorpointer->at(0); - system("mkdir "+ savepathresults + folderadd + "/" + " -p"); + system("mkdir \""+ savepathresults + folderadd + "/\"" + " -p"); TString filename = savepathresults + folderadd + "/" + Form("Observable_%s.dat", ntuplepointer->GetName()); TString header = ""; @@ -430,7 +431,7 @@ Bool_t writeOneHistogramTypeToFile(vector* ptCompareHistogramCla { if (ptCompareHistogramClassVector->size() > 0) { - system("mkdir "+ savepathresults + folderadd + "/" + " -p"); + system("mkdir \""+ savepathresults + folderadd + "/\"" + " -p"); TString filename = Form("%s%s/Spectrum_%d_%s", savepathresults.Data(), folderadd.Data(), ptCompareHistogramClassVector->at(0)->labbook->runnumber, ptCompareHistogramClassVector->at(0)->histogramdescription.Data()); @@ -481,7 +482,7 @@ Bool_t writeObservableToFile(vector* ptCompareHistogramVector) { if (numberRuns>0) { - system("mkdir "+ savepathresults + folderadd + "/" + " -p"); + system("mkdir \""+ savepathresults + folderadd + "/\"" + " -p"); TString filename = savepathresults + folderadd + "/Spectra"; TString header = ""; @@ -1272,6 +1273,8 @@ Bool_t FindGoodTitle(vector* ptCompareHistogramClassVector, vect for (UInt_t histogrami=0; histogrami < ptCompareHistogramClassVector->size(); histogrami++) folderadd.Append(Form(" %.2fMhz", ptCompareHistogramClassVector->at(histogrami)->labbook->clock)); + removeForbiddenChar(&folderadd); + system("mkdir \""+ savepathresults + folderadd + "/\"" + " -p"); // cout << colorred << savepathresults << folderadd << endlr; diff --git a/MABS_run_analyzer/Run.c b/MABS_run_analyzer/Run.c index bc0b94c..c92aaec 100644 --- a/MABS_run_analyzer/Run.c +++ b/MABS_run_analyzer/Run.c @@ -369,7 +369,7 @@ Bool_t Run::setFixedThresholdValueADU(HistogramType* HistogramTypepointer, Float Bool_t Run::setResultsPath(TString path) { cout << "Changing save directory to '" << path << "'" << endl; - if (system("mkdir '"+ path + "' -p")) + if (system("mkdir \""+ path + "\" -p")) { cout << "\033[1;31mError changing directory, save path is: '\033[1;37m" << savepathresults << "\033[1;31m'\033[0m" << endl; return 1; @@ -2447,7 +2447,7 @@ TCanvas* Run::plot1DHistogram(HistogramType* HistogramTypepointer, TH1FO* onehis Bool_t Run::writeHistogramToFile(TH1F* onehistogram) { - system("mkdir "+ savepathresults + " -p"); + system("mkdir \""+ savepathresults + "\" -p"); TString filename= savepathresults + "/" + runcode + " " + onehistogram->GetName() + " hist.dat"; fstream* fout = new fstream(filename,ios::out); @@ -2466,7 +2466,7 @@ Bool_t Run::writeHistogramToFile(TH1F* onehistogram) Bool_t Run::write2DHistogramToFile(TH2F* onehistogram) { - system("mkdir "+ savepathresults + " -p"); + system("mkdir \""+ savepathresults + "\" -p"); TString filename= savepathresults + "/" + runcode + " " + onehistogram->GetName() + " hist.dat"; fstream* fout = new fstream(filename,ios::out); @@ -2487,7 +2487,7 @@ Bool_t Run::write2DHistogramToFile(TH2F* onehistogram) Bool_t Run::writeAllHistogramsToFile() { - system("mkdir "+ savepathresults + " -p"); + system("mkdir \""+ savepathresults + "\" -p"); TString filename= savepathresults + "/" + runcode + " histograms.dat"; fstream* fout = new fstream(filename,ios::out); @@ -2543,7 +2543,7 @@ Bool_t Run::writeAllHistogramsToFile() void Run::MakeGnuplotFile() { - system("mkdir "+ savepathresults + " -p"); + system("mkdir \""+ savepathresults + "\" -p"); TString filename= savepathresults + "/" + runcode+"_gnuplot.plt"; fstream* fout = new fstream(filename,ios::out); diff --git a/MABS_run_analyzer/help.h b/MABS_run_analyzer/help.h index 4fc72e7..910038d 100644 --- a/MABS_run_analyzer/help.h +++ b/MABS_run_analyzer/help.h @@ -557,6 +557,17 @@ TH1F * ShowOverflow(TH1F *h) bool compareFloatvalues (Float_t i,Float_t j) { return (i|"; + for (string::iterator it = illegalChars.begin() ; it < illegalChars.end() ; ++it){ + s->ReplaceAll(*it, ' '); + } +} + void *sortThread(void *ptr) { // TStopwatch timer; -- 2.43.0