From 3b1ee1fe8870e868e4a42ad461da1f26627ddc60 Mon Sep 17 00:00:00 2001 From: Benjamin Linnik Date: Thu, 14 May 2015 06:56:06 +0200 Subject: [PATCH] Run analyzer: Important bugfix - fixed memory leakage, cleaned up code, added error catching routines, overall stability fixes --- MABS_run_analyzer/ChargeSpektrum.c | 293 ++++++++++++++++++++--------- MABS_run_analyzer/MAPS.c | 132 ++++++++----- MABS_run_analyzer/MAPS.h | 26 ++- MABS_run_analyzer/Run.c | 102 ++++++---- MABS_run_analyzer/Run.h | 17 +- 5 files changed, 383 insertions(+), 187 deletions(-) diff --git a/MABS_run_analyzer/ChargeSpektrum.c b/MABS_run_analyzer/ChargeSpektrum.c index d861245..7031977 100644 --- a/MABS_run_analyzer/ChargeSpektrum.c +++ b/MABS_run_analyzer/ChargeSpektrum.c @@ -7,27 +7,16 @@ * */ -#include "Run.h" -#include "MAPS.h" - - -/** - * @file - * @brief Use brief, otherwise the index won't have a brief explanation. - * - * Detailed explanation. - * - * - */ - // bad c- style fix me -#include "Run.c" #include "MAPS.c" +#include "Run.c" #include "CSVRow.h" #include "CSVRow.C" #include +#include Int_t* ReadRunList(); +Int_t ReadRunList(std::vector*); void plotAllRuns(); void plotAllRuns(TString); @@ -35,87 +24,184 @@ Run** runs; Int_t numberRuns; Bool_t isBatch = kFALSE; -void ChargeSpektrum(Int_t runnumber = -1) +const TString colorwhite = "\033[1;29m"; +const TString colorred = "\033[1;31m"; +const TString coloryellow = "\033[1;33m"; +const TString colorreset = "\033[0m"; +const TString endlr = "\033[0m\n"; + +void ChargeSpektrum(Int_t runnumber) +{ + cout << endl << colorred << "Given parameters have wrong format, please enter integer run numbers devided by '" << colorreset << colorwhite << "," << colorreset << colorred << "' and surrounded by '" << colorreset << colorwhite << "\"" << colorreset << colorred << "'." << endlr; + cout << "For example run: root -l 'ChargeSpektrum.c+(\"342815,342816\")'" << endl; + exit(1); +} + +void ChargeSpektrum(Int_t runnumber, Int_t runnumber2) +{ + cout << endl << colorred << "Given parameters have wrong format, please enter integer run numbers devided by '" << colorreset << colorwhite << "," << colorreset << colorred << "' and surrounded by '" << colorreset << colorwhite << "\"" << colorreset << colorred << "'." << endlr; + cout << "For example run: " << colorwhite << "root -l 'ChargeSpektrum.c+(\"342815,342816\")'" << endl; + exit(1); +} + +void ChargeSpektrum(TString runnumber = "") { cout << endl << endl; if (gROOT->IsBatch()) isBatch = kTRUE; numberRuns=0; - Int_t* runList; - if (runnumber > 0) + std::vector runList; + if (runnumber.Length() > 0) { - numberRuns=1; - runList=new Int_t[numberRuns]; - runList[0]=runnumber; + if (runnumber.Contains("-")) + { + TObjArray* runarray = runnumber.Tokenize("-"); + if (runarray->GetEntries()==2) + { + TObjString* tempstrobj; + tempstrobj=static_cast(runarray->At(0)); + if (tempstrobj->GetString().Length()>0) + { + Int_t tempintstart = tempstrobj->GetString().Atoi(); + tempstrobj=static_cast(runarray->At(1)); + if (tempstrobj->GetString().Length()>0) + { + Int_t tempintend = tempstrobj->GetString().Atoi(); + if (tempintend-tempintstart > 0) + { + for (Int_t i=tempintstart; i <= tempintend; i++) + { + runList.push_back(i); + numberRuns++; + } + } + else + cout << coloryellow << "Invalid run number range "<< colorreset << colorwhite << tempintstart << " till " << tempintend << endlr; + } + else + cout << coloryellow << "Invalid run number "<< colorreset << colorwhite << tempstrobj->GetString() << endlr; + + } + else + cout << coloryellow << "Invalid run number "<< colorreset << colorwhite << tempstrobj->GetString() << endlr; + } + else + { + cout << endl << colorred << "Given parameters have wrong format, please enter integer run numbers devided by '" << colorreset << colorwhite << "," << colorreset << colorred << " or 2 runnumbers devided by " << colorreset << colorwhite << "-" << colorreset << colorred << "' and surrounded by '" << colorreset << colorwhite << "\"" << colorreset << colorred << "'." << endlr; + cout << "For example run: " << colorwhite << "root -l 'ChargeSpektrum.c+(\"342815,342816\")'" << endl; + exit(1); + } + + } + else + { + TObjArray* runarray = runnumber.Tokenize(","); + if (runarray->GetEntries()>0) + { + TObjString* tempstrobj; + for (Int_t i=0; i < runarray->GetEntries(); i++) + { + tempstrobj=static_cast(runarray->At(i)); + if (tempstrobj->GetString().Length()>0) + { + Int_t tempint = tempstrobj->GetString().Atoi(); + if (tempint > 0) + { + runList.push_back(tempint); + numberRuns++; + } + else + cout << coloryellow << "Invalid run number "<< colorreset << colorwhite << tempint << endlr; + } + else + cout << coloryellow << "Invalid run number "<< colorreset << colorwhite << tempstrobj->GetString() << endlr; + } + } + else + { + cout << endl << colorred << "Given parameters have wrong format, please enter integer run numbers devided by '" << colorreset << colorwhite << "," << colorreset << colorred << "' and surrounded by '" << colorreset << colorwhite << "\"" << colorreset << colorred << "'." << endlr; + cout << "For example run: " << colorwhite << "root -l 'ChargeSpektrum.c+(\"342815,342816\")'" << endl; + exit(1); + } + } } else { /// number of runs to be analyzed, number of lines read by @c ReadRunList() - numberRuns=0; - ReadRunList(); - /// array with run numbers - runList=new Int_t[numberRuns]; - runList=ReadRunList(); + ReadRunList(&runList); } runs = new Run*[numberRuns]; - cout << "Found " << numberRuns << " run(s) in 'runlist.txt'." << endl; + cout << "Found " << numberRuns << " run(s) in 'runlist.txt' or given as parameters." << endl; for(Int_t runi=0;runi0) { - // check if devided matrix is investigated - if (runList[runi-1] == runList[runi]) + runs[runi] = new Run(runList[runi], runi); + if (!runs[runi]->error) { - cout << "Using devided matrix upper" << endl; - runs[runi]->dividedmatrix = 1; - runs[runi]->upperpart = 1; + if (runi%2) + { + // check if devided matrix is investigated + if (runList[runi-1] == runList[runi]) + { + cout << "Using devided matrix upper" << endl; + runs[runi]->dividedmatrix = 1; + runs[runi]->upperpart = 1; + } + } + if (runi+1 < numberRuns) + { + if (runList[runi] == runList[runi+1] ) + { + cout << "Using devided matrix lower" << endl; + runs[runi]->dividedmatrix = 1; + runs[runi]->upperpart = 0; + } + } + runs[runi]->setResultsPath("./results/"); + runs[runi]->useDynamicalNoise(true); + // runs[runi]->analyzeFrame(542875); // creates or opens .root file, can analyze the RAW data + runs[runi]->error=runs[runi]->analyzeRun(false); // creates or opens .root file, can analyze the RAW data + if (!runs[runi]->error) + { + // gROOT->SetBatch(kTRUE); + // runs[runi]->plotSeed(); + runs[runi]->plotSeedThreshold(); + // runs[runi]->plotSeed(); + // runs[runi]->plotSum(); + // runs[runi]->plotVeto(); + // runs[runi]->plotNoise(); + if (!isBatch) + gROOT->SetBatch(kFALSE); + // runs[runi]->plotAllHistograms(); + runs[runi]->plotAllHistogramsThresholdCluster(); + // runs[runi]->plotAllHistogramsCalibrated(); + runs[runi]->writeAllHistogramsToFile(); + } } } - if (runi+1 < numberRuns) - { - if (runList[runi] == runList[runi+1] ) - { - cout << "Using devided matrix lower" << endl; - runs[runi]->dividedmatrix = 1; - runs[runi]->upperpart = 0; - } - } - runs[runi]->setResultsPath("./results/"); - runs[runi]->useDynamicalNoise(true); - runs[runi]->analyzeRun(false); // creates or opens .root file, can analyze the RAW data -// gROOT->SetBatch(kTRUE); - // runs[runi]->plotSeed(); -// runs[runi]->plotSeedThreshold(); -// runs[runi]->plotSum(); -// runs[runi]->plotVeto(); - // runs[runi]->plotNoise(); - if (!isBatch) - gROOT->SetBatch(kFALSE); -// runs[runi]->plotAllHistograms(); - runs[runi]->plotAllHistogramsThresholdCluster(); -// runs[runi]->plotAllHistogramsCalibrated(); - runs[runi]->writeAllHistogramsToFile(); } plotAllRuns(""); - plotAllRuns("threshold"); +// plotAllRuns("threshold"); } Int_t* ReadRunList() { Int_t* runList=new Int_t[1000]; - std::ifstream file("runlist.txt"); - CSVRow row; + Int_t row; Int_t runLauf=0; while (file >> row) - { + { try { - runList[runLauf]=atoi(row[0].c_str()); - runLauf++; + if (row > 0) + { + runList[runLauf]=row; + runLauf++; + } } catch(...) { @@ -127,6 +213,29 @@ Int_t* ReadRunList() } +Int_t ReadRunList(std::vector* runlist) +{ + std::ifstream file("runlist.txt"); + Int_t row; + while (file >> row) + { + try + { + if (row > 0) + { + runlist->push_back(row); + numberRuns++; + } + } + catch(...) + { + cout << "File ended"; + } + } + return numberRuns; +} + + // void plotNoiseComparison() // { // @@ -135,15 +244,15 @@ Int_t* ReadRunList() void plotAllRuns(TString histogramtype) { - if (histogramtype.Contains("threshold")) + if (histogramtype.Contains("threshold")){ for(Int_t runi=0;runihistogrampointer = &runs[runi]->histogramthreshold; } - else if (histogramtype.Contains("calibrated") || histogramtype.Contains("electron")) + runs[runi]->plothistogrampointer = &runs[runi]->histogramthreshold; } } + else if (histogramtype.Contains("calibrated") || histogramtype.Contains("electron")) { for(Int_t runi=0;runihistogrampointer = &runs[runi]->histogramCalibrated; } - else + runs[runi]->plothistogrampointer = &runs[runi]->histogramCalibrated; } } + else { for(Int_t runi=0;runihistogrampointer = &runs[runi]->histogram; } + runs[runi]->plothistogrampointer = &runs[runi]->histogram; } } plotAllRuns(); } @@ -170,26 +279,32 @@ void plotAllRuns() for(Int_t runi=0;runicd(1); - runs[runi]->histogrampointer->Seed->Draw("SAME"); - lastbin = runs[runi]->histogrampointer->Seed->GetBinCenter(runs[runi]->histogrampointer->Seed->FindLastBinAbove(2,1)); - runs[runi]->histogrampointer->Seed->SetAxisRange(0,lastbin*1.1,"X"); - gPad->SetLogy(1); - legendEntry = Form("%s", runs[runi]->histogrampointer->Seed->GetTitle()); - leg1->AddEntry(runs[runi]->histogrampointer->Veto, legendEntry, "l"); - leg1->Draw("SAME"); - canvas->cd(2); - runs[runi]->histogrampointer->Sum->Draw("SAME"); - lastbin = runs[runi]->histogrampointer->Sum->GetBinCenter(runs[runi]->histogrampointer->Sum->FindLastBinAbove(2,1)); - runs[runi]->histogrampointer->Sum->SetAxisRange(0,lastbin*1.1,"X"); - canvas->cd(3); - runs[runi]->histogrampointer->Veto->Draw("SAME"); - runs[runi]->histogrampointer->Veto->SetAxisRange(runs[runi]->histogrampointer->posVeto*0.7,runs[runi]->histogrampointer->posVeto*1.4,"X"); - canvas->cd(4); - runs[runi]->histogrampointer->Noise->Draw("SAME"); - legendEntry = Form("%s, Noise: %.2f", runs[runi]->labbook.matrix.Data(), runs[runi]->histogrampointer->avgNoise); - leg2->AddEntry(runs[runi]->histogrampointer->Veto, legendEntry, "l"); - leg2->Draw("SAME"); + if (runs[runi] != nullptr) + { + if (!runs[runi]->error) + { + canvas->cd(1); + runs[runi]->plothistogrampointer->Seed->Draw("SAME"); + lastbin = runs[runi]->plothistogrampointer->Seed->GetBinCenter(runs[runi]->plothistogrampointer->Seed->FindLastBinAbove(2,1)); + runs[runi]->plothistogrampointer->Seed->SetAxisRange(0,lastbin*1.1,"X"); + gPad->SetLogy(1); + legendEntry = Form("%s", runs[runi]->plothistogrampointer->Seed->GetTitle()); + leg1->AddEntry(runs[runi]->plothistogrampointer->Veto, legendEntry, "l"); + leg1->Draw("SAME"); + canvas->cd(2); + runs[runi]->plothistogrampointer->Sum->Draw("SAME"); + lastbin = runs[runi]->plothistogrampointer->Sum->GetBinCenter(runs[runi]->plothistogrampointer->Sum->FindLastBinAbove(2,1)); + runs[runi]->plothistogrampointer->Sum->SetAxisRange(0,lastbin*1.1,"X"); + canvas->cd(3); + runs[runi]->plothistogrampointer->Veto->Draw("SAME"); + runs[runi]->plothistogrampointer->Veto->SetAxisRange(runs[runi]->plothistogrampointer->posVeto*0.7,runs[runi]->plothistogrampointer->posVeto*1.4,"X"); + canvas->cd(4); + runs[runi]->plothistogrampointer->Noise->Draw("SAME"); + legendEntry = Form("%s, Noise: %.2f", runs[runi]->labbook.matrix.Data(), runs[runi]->plothistogrampointer->avgNoise); + leg2->AddEntry(runs[runi]->plothistogrampointer->Veto, legendEntry, "l"); + leg2->Draw("SAME"); + } + } } // canvas -> Print( runs[0]->savepathresults + "/" + canvastitle + ".eps"); diff --git a/MABS_run_analyzer/MAPS.c b/MABS_run_analyzer/MAPS.c index cf53a83..1e97fbb 100644 --- a/MABS_run_analyzer/MAPS.c +++ b/MABS_run_analyzer/MAPS.c @@ -6,7 +6,8 @@ * * */ - +#ifndef __MAPS__C +#define __MAPS__C #include"MAPS.h" #include "Run.h" @@ -18,22 +19,24 @@ MAPS::MAPS() { MAPS::MAPS(Run* runp) { run = runp; - initMapsRun(); - - // check if sepcified system is correct, if not, switch and reinitialize - if ( switchsystem() ) + error = initMapsRun(); + if (!error) { - if (run->labbook.system.EqualTo("USB")) + // check if sepcified system is correct, if not, switch and reinitialize + if ( switchsystem() ) { - run->labbook.system = Form("PXI"); - } - else - { - run->labbook.system = Form("USB"); + if (run->labbook.system.EqualTo("USB")) + { + run->labbook.system = Form("PXI"); + } + else + { + run->labbook.system = Form("USB"); + } + run->setSystemSpecificParameters(); + error = initMapsRun( ); } - run->setSystemSpecificParameters(); - initMapsRun( ); - } sleep(1); // TODO test if removable + } } @@ -46,8 +49,8 @@ Bool_t MAPS::initNewRootFile() { //Check and open Data Files int MaxFiles = TMath::Ceil((Float_t) FileTotalEvNbInConfig/FileEvNbInConfig); if( checkDataFiles(MaxFiles) ) - { fOutputFile = new TFile(fRootFile,"RECREATE"); + { // Hit TTree fHitTree = new TTree("hit", "hit"); fHitTree->Branch("frame" , &fFrameInfo.frame , "frame/i" , 32000); @@ -147,15 +150,13 @@ MAPS::~MAPS(void) { fInn[i].close(); } - cout << "Bevor delete MAPS Arrays! " << endl; delete[] fEvents; delete[] fF0matrix; delete[] fF1matrix; delete[] fCdsmatrix; delete[] fNoise; delete[] fPedestals; - cout << "Nach delete MAPS Arrays! " << endl; - cout<<"================================================================="<cd(); fHitTree->Write("",TObject::kOverwrite); @@ -181,7 +189,7 @@ void MAPS::save() { //#################################################################### -void MAPS::initMapsRun( ) { +Bool_t MAPS::initMapsRun( ) { // fInDir=run->storepathRAWLinux; fOutDir = run->storepathRAWLinux; // default ouput directory is input directory @@ -225,6 +233,19 @@ void MAPS::initMapsRun( ) { value1[vi][vj] = (vj*16 + (vi & 0xF0) / 16); } } + + ifstream inn(fConfigFile, ios::binary); + if( !inn.good() ) + { + cout<<"-----------------------"< ",fRunNumber,FileNr)<= 1) { - printf("%6.2f TB ", (Float_t)(End/(TMath::Power(2,40))) ); - } - else if (End/(TMath::Power(2,30)) >= 1) { - printf("%6.2f GB ", (Float_t)(End/(TMath::Power(2,30))) ); - } - else if (End/(TMath::Power(2,20)) >= 1) { - printf("%6.2f MB ", (Float_t)(End/(TMath::Power(2,20))) ); - } - else if (End/(TMath::Power(2,10)) >= 1) { - printf("%6.2f kB ", (Float_t)(End/(TMath::Power(2,10))) ); - } - else { - printf("%6.2f B ", (Float_t)(End)); - } - - cout< ",fRunNumber,FileNr)<= 1) { +// printf("%6.2f TB ", (Float_t)(End/(TMath::Power(2,40))) ); +// } +// else if (End/(TMath::Power(2,30)) >= 1) { +// printf("%6.2f GB ", (Float_t)(End/(TMath::Power(2,30))) ); +// } +// else if (End/(TMath::Power(2,20)) >= 1) { +// printf("%6.2f MB ", (Float_t)(End/(TMath::Power(2,20))) ); +// } +// else if (End/(TMath::Power(2,10)) >= 1) { +// printf("%6.2f kB ", (Float_t)(End/(TMath::Power(2,10))) ); +// } +// else { +// printf("%6.2f B ", (Float_t)(End)); +// } +// +// cout<= 20000) - cout << "\033[1;31mRun could be corrupted, number of events in file doesn't match configuration! ("<< Frames << " != " << FileEvNbInConfig << ") \033[0m\n"; + cout << colorred << "Run could be corrupted, number of events in file doesn't match configuration! ("<< Frames << " != " << FileEvNbInConfig << ")" << endlr; // cout<Branch("frame" , &fFrameNumber , "frame/i" , 32000); // fDynNoiseTree->Branch("noise" , &fNoiseMean , "noise/F" , 32000); // fDynNoiseTree->Branch("pedestal" , &fPedestalsMean , "pedestal/F" , 32000); @@ -953,7 +979,10 @@ void MAPS::debugStream(const arraytype* (a), Int_t n, Int_t columns, Int_t preci cout << endl; } + bool MAPS::regetDynNoise(Int_t Frames) { + Bool_t pedestalhighinthisframe = false; + Bool_t noisehighinthisframe = false; for(Int_t pixeli=0; pixeli20) { - cout<<"\rFrame: "< Pdestial suspiciously high!"< Pedestal suspiciously high!"<(fCdsmatrix , fPixels, fColumns, 1, 20); // cout<<" Pedestial of sensor: "; @@ -985,7 +1019,12 @@ bool MAPS::regetDynNoise(Int_t Frames) { } if (abs(fNoise[pixeli])>20) { - cout <<"\rFrame: "< Noise suspiciously high! "< Noise suspiciously high! "<(fCdsmatrix , fPixels, fColumns, 1, 20); // cout<<" Noise of sensor: "; @@ -1001,6 +1040,10 @@ bool MAPS::regetDynNoise(Int_t Frames) { // cout << "Skipped pixel " << pixeli << " for noise calc" << endl; } } + if (pedestalhighinthisframe) + cout<<"\rFrame: "< Pedestal suspiciously high!"< Noise suspiciously high!"<SetSeed(0); @@ -54,13 +57,22 @@ Run::Run(Int_t runnumber, Int_t loopi) // replace windows drive notation with linux style if (labbook.storepath.Length() > 0) { + storepathRAWLinux = labbook.storepath; // storepathRAWLinux = storepathRAWLinux.ReplaceAll("H:","/jspc53_H"); // storepathRAWLinux = storepathRAWLinux.ReplaceAll("h:","/jspc53_H"); - storepathRAWLinux = storepathRAWLinux.ReplaceAll("H:","/d/garlic"); - storepathRAWLinux = storepathRAWLinux.ReplaceAll("h:","/d/garlic"); - storepathRAWLinux = storepathRAWLinux.ReplaceAll("U:","/jspc53_U"); - storepathRAWLinux = storepathRAWLinux.ReplaceAll("u:","/jspc53_U"); + storepathRAWLinux = storepathRAWLinux.ReplaceAll("H:","/d/jspc53_H"); + storepathRAWLinux = storepathRAWLinux.ReplaceAll("h:","/d/jspc53_H"); + if (TString(hostname).EqualTo("jspc48")) + { + storepathRAWLinux = storepathRAWLinux.ReplaceAll("U:","/d/jspc28/jspc53_U"); + storepathRAWLinux = storepathRAWLinux.ReplaceAll("u:","/d/jspc28/jspc53_U"); + } + else + { + storepathRAWLinux = storepathRAWLinux.ReplaceAll("U:","/jspc53_U"); + storepathRAWLinux = storepathRAWLinux.ReplaceAll("u:","/jspc53_U"); + } storepathRAWLinux = storepathRAWLinux.ReplaceAll("F:","/jspc12_F"); storepathRAWLinux = storepathRAWLinux.ReplaceAll("f:","/jspc12_F"); storepathRAWLinux = storepathRAWLinux.ReplaceAll("O:","/d/garlic"); @@ -113,7 +125,7 @@ Run::Run(Int_t runnumber, Int_t loopi) initRootParameters(); cout << colorwhite << "initHistograms():" << endlr; initHistograms(&histogram); - histogrampointer = &histogram; + plothistogrampointer = &histogram; initHistograms(&histogramthreshold, " threshold"); runexistsinDB = 1; debugDBreadout(); @@ -121,11 +133,13 @@ Run::Run(Int_t runnumber, Int_t loopi) else { cout << "\033[1;31mNo database data for run " << numberToString<>(labbook.runnumber) << " found!\033[0m" << endl; + error = 1; } } catch(...) { cout << "\033[1;31mError while reading laboratory book (run number " << numberToString<>(labbook.runnumber) << ")!\033[0m\n"; + error = 1; } } @@ -188,43 +202,49 @@ Bool_t Run::analyzeRun(Bool_t force) { cout << colorwhite << "instatiate MAPS(this)" << endlr; processed = new MAPS(this); - if (!runAllreadyAnalyzed() || force) + error = processed->error; + if (!error) { - processed->initNewRootFile(); - /// progress meter, temporal variable - ULong_t progress_tmp=-1; - /// progress meter - Float_t progress; - processed->InitialDynNoise(); - int start = 0; - int nframes = processed->GetNumberFrames(); - for(int i=0; igetFrame(i); -// processed->filterCommonMode(); - processed->hitana(); - if (dynamicalNoise) - processed->regetDynNoise(); - progress = (Int_t)(((i-start)*100)/(nframes-1)*10); - if (progress!=progress_tmp) { print_progress( (((i-start)*100.)/(nframes-1)) ); progress_tmp=progress;} - } -// cout << processed->plus << " vs. " << processed->minus << " : " << (processed->plus*1.0)/processed->minus<< endl; + if (processed->initNewRootFile()) return 1; + /// progress meter, temporal variable + ULong_t progress_tmp=-1; + /// progress meter + Float_t progress; + processed->InitialDynNoise(); + int start = 0; + int nframes = processed->GetNumberFrames(); + for(int i=0; igetFrame(i); + // processed->filterCommonMode(); + // cout << "hitana " << endl; + processed->hitana(); + // cout << "regetDynNoise " << endl; + if (dynamicalNoise) + processed->regetDynNoise(); + progress = (Int_t)(((i-start)*100)/(nframes-1)*10); + if (progress!=progress_tmp) { print_progress( (((i-start)*100.)/(nframes-1)) ); progress_tmp=progress;} + } + // cout << processed->plus << " vs. " << processed->minus << " : " << (processed->plus*1.0)/processed->minus<< endl; - // print a dummy file to indicate, that a root file was created once - fstream* fout = new fstream(storepathRAWLinux + "/rootfilecreated",std::ios::out); - *fout << "" << endl; - fout->close(); - processed->save(); - } - else - { - cout << "Skipped analysis of run " << labbook.runnumber << ", I think the root file for this run allready exists." << endl; - cout << colorwhite << "initOldRootFile():" << endlr; + // print a dummy file to indicate, that a root file was created once + fstream* fout = new fstream(storepathRAWLinux + "/rootfilecreated",std::ios::out); + *fout << "" << endl; + fout->close(); + processed->save(); + } + else + { + cout << "Skipped analysis of run " << labbook.runnumber << ", I think the root file for this run allready exists." << endl; + cout << colorwhite << "initOldRootFile():" << endlr; + } } - if (!error) { - error = processed->initOldRootFile(); + if (processed->initOldRootFile()) return 1; cout << colorwhite << "binNoise():" << endlr; binNoise(); cout << colorwhite << "binSeedSumVeto():" << endlr; @@ -235,13 +255,13 @@ Bool_t Run::analyzeRun(Bool_t force) calculteCCE(); cout << colorwhite << "updateDatabase():" << endlr; updateDatabase(); - cout << colorwhite << "delete processed:" << endlr; + cout << colorwhite << "delete MAPS class:" << endlr; delete processed; - return true; + return 0; } delete processed; } - return false; + return 1; } Bool_t Run::calculteCCE() @@ -824,7 +844,7 @@ Float_t Run::FitPerform(TH1F* histogrampointer, TString fitFuncType, Bool_t verb Float_t posMax = 0; Float_t posMax2 = 0; Float_t posMaxValHist = histogrampointer->GetXaxis()->GetXmax(); - Float_t noiseborder = posMaxValHist/15; + Float_t noiseborder = posMaxValHist/10; // for USB system, the value is 90 if (doFits) { @@ -1194,7 +1214,6 @@ void Run::initHistogram(TH1F* &histogrampointer, TString prefix) TString humanreadablestr = Form("%s, %s spectrum, Mi%s, chip %s, %s, T=%.1f",prefix.Data(), labbook.source.Data(), labbook.chipGen.Data(), labbook.chip.Data(), labbook.matrix.Data(), labbook.temp); histogrampointer=new TH1F(prefix.Data(), humanreadablestr.Data(), systemparamcur.nbins, 0, systemparamcur.maxbin); histogrampointer->SetLineStyle(rootlinestyle[plotStyle]); - cout << "prefix: " << prefix << " rootcolor: " << rootcolors[plotStyle] << endl; histogrampointer->SetLineColor(rootcolors[plotStyle]); histogrampointer->SetStats(kTRUE); histogrampointer->SetStats(111111111); @@ -1211,3 +1230,4 @@ void Run::initRootParameters() rootlinestyle = new Int_t[13]{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; } +#endif diff --git a/MABS_run_analyzer/Run.h b/MABS_run_analyzer/Run.h index e16d164..cba162b 100644 --- a/MABS_run_analyzer/Run.h +++ b/MABS_run_analyzer/Run.h @@ -27,7 +27,7 @@ #define SERVERUSER "radhard" #define SERVERPWD "mimosa88" -#include "MAPS.h" +#include "MAPS.c" class MAPS; /** @@ -132,12 +132,12 @@ private: /// is set to true if the RAW Data is consistent Bool_t runRAWok = 0; - - /// is set to true if an error occured - Bool_t error = 0; - + TRandom* random1; + /// host name of the machine, used to find correct mount points + char hostname[1024]; + /** * @brief fills noise #histogram */ Bool_t binNoise(); @@ -209,7 +209,7 @@ private: }; systemparam systemparamUSB { 900, // maxbin; - 900/15,// nbins; + 900/5,// nbins; 25, //vetothreshold 10, 100 @@ -270,6 +270,9 @@ public: /** @brief Makes a gnuplot file to plot the histogram data created in @c writeAllHistogramsToFile() */ void MakeGnuplotFile(); + /// is set to true if an error occured + Bool_t error = 0; + /** * @brief analysis the RAW data * @@ -416,7 +419,7 @@ public: histogramstruct histogram; histogramstruct histogramCalibrated; histogramstruct histogramthreshold; - histogramstruct* histogrampointer; + histogramstruct* plothistogrampointer; /** @brief Plots all histograms from #histogram into one canvas */ Bool_t plotAllHistograms(histogramstruct*); -- 2.43.0