From: Benjamin Linnik Date: Thu, 14 May 2015 05:04:14 +0000 (+0200) Subject: Run analyzer: merge, writeObservableToFile not working yet X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=6d4ced83a0adac7ae2f690c8964c686909fa8480;p=radhard.git Run analyzer: merge, writeObservableToFile not working yet --- 6d4ced83a0adac7ae2f690c8964c686909fa8480 diff --cc MABS_run_analyzer/ChargeSpektrum.c index 7031977,f7aafd8..6be47b3 --- a/MABS_run_analyzer/ChargeSpektrum.c +++ b/MABS_run_analyzer/ChargeSpektrum.c @@@ -13,13 -26,11 +13,13 @@@ #include "CSVRow.h" #include "CSVRow.C" #include +#include Int_t* ReadRunList(); +Int_t ReadRunList(std::vector*); void plotAllRuns(); void plotAllRuns(TString); - + void writeObservableToFile(TString); Run** runs; Int_t numberRuns; Bool_t isBatch = kFALSE; @@@ -133,99 -60,64 +133,74 @@@ void ChargeSpektrum(TString runnumber } 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;runidividedmatrix = 1; - runs[runi]->upperpart = 1; - } - } - if (runi+1 < numberRuns) + if (runList[runi]>0) { - if (runList[runi] == runList[runi+1] ) + runs[runi] = new Run(runList[runi], runi); + if (!runs[runi]->error) { - cout << "Using devided matrix lower" << endl; - runs[runi]->dividedmatrix = 1; - runs[runi]->upperpart = 0; + 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(); + } } } - runs[runi]->setResultsPath("./results/"); - runs[runi]->useDynamicalNoise(true); - runs[runi]->analyzeRun(false); // creates or opens .root file, can analyze the RAW data - // runs[runi]->analyzeFrame(353); -// 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"); - } - - Int_t* ReadRunList() - { - Int_t* runList=new Int_t[1000]; - std::ifstream file("runlist.txt"); - Int_t row; - Int_t runLauf=0; - while (file >> row) - { - try - { - if (row > 0) - { - runList[runLauf]=row; - runLauf++; - } - } - catch(...) - { - cout << "File ended"; - } - } - numberRuns=runLauf; - return runList; ++// plotAllRuns(""); + plotAllRuns("threshold"); - writeObservableToFile("Seed"); ++ writeObservableToFile("Seed"); } - -Int_t* ReadRunList() +Int_t ReadRunList(std::vector* runlist) { - Int_t* runList=new Int_t[1000]; - - std::ifstream file("runlist.txt"); - CSVRow row; - Int_t runLauf=0; + std::ifstream file("runlist.txt"); + Int_t row; while (file >> row) - { + { try { - runList[runLauf]=atoi(row[0].c_str()); - runLauf++; + if (row > 0) + { + runlist->push_back(row); + numberRuns++; + } } catch(...) { @@@ -240,19 -133,67 +215,63 @@@ // { // // } - + void writeObservableToFile(TString observable) + { + TString runnumberListe="Seed_"; + for(Int_t runi=0;runilabbook.runnumber); + + runnumberListe+=runnumber+"_"; + } + system("mkdir "+ runs[0]->savepathresults + " -p"); + TString filename= runs[0]->savepathresults + "/" + runnumberListe + "_histograms.dat"; + fstream* fout = new fstream(filename,ios::out); + TString header; + for(Int_t runi=0;runilabbook.runnumber); + header+="Bins\t"+runnumber+"\t"; + } + + *fout << header << endl; + TString headerInfo; + for(Int_t runi=0;runiruncode+"\t"; + } + + *fout << headerInfo << endl; + + runs[0]->histogrampointer = &runs[0]->histogramthreshold; + + for(Int_t bin=0;binhistogrampointer->Seed->GetNbinsX();bin++)//Achtung möglicher Bug, da hier nur die Bins vom ersten Run genommen werden, haben die anderen runs mehr/weniger Bins, kann es crashen, sollte aber normalerweise kein Problem sein, da alle Histogramme mit der gleichen Binzahl erstellt werden + { + for(Int_t runi=0;runihistogrampointer = &runs[runi]->histogramthreshold; + TString outline; + outline=Form("%.1f\t%.1f",runs[runi]->histogrampointer->Seed->GetBinCenter(bin),runs[runi]->histogrampointer->Seed->GetBinContent(bin)); + *fout<close(); + + return; - - - + } 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")) ++ if (histogramtype.Contains("threshold")) { ++ for(Int_t runi=0;runiplothistogrampointer = &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(); }