#include "CSVRow.h"
#include "CSVRow.C"
#include <TTimeStamp.h>
+#include <fstream>
Int_t* ReadRunList();
+Int_t ReadRunList(std::vector<int>*);
void plotAllRuns();
void plotAllRuns(TString);
-
+ void writeObservableToFile(TString);
Run** runs;
Int_t numberRuns;
Bool_t isBatch = kFALSE;
}
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;runi<numberRuns;runi++) // loop over runs read from file
{
- runs[runi] = new Run(runList[runi], runi);
- 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]>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<int>* 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(...)
{
// {
//
// }
-
+ void writeObservableToFile(TString observable)
+ {
+ TString runnumberListe="Seed_";
+ for(Int_t runi=0;runi<numberRuns;runi++) // loop over runs read from file
+ {
+ TString runnumber=Form("%d",runs[runi]->labbook.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;runi<numberRuns;runi++) // loop over runs read from file
+ {
+ TString runnumber=Form("%d",runs[runi]->labbook.runnumber);
+ header+="Bins\t"+runnumber+"\t";
+ }
+
+ *fout << header << endl;
+ TString headerInfo;
+ for(Int_t runi=0;runi<numberRuns;runi++) // loop over runs read from file
+ {
+ headerInfo+="\t"+runs[runi]->runcode+"\t";
+ }
+
+ *fout << headerInfo << endl;
+
+ runs[0]->histogrampointer = &runs[0]->histogramthreshold;
+
+ for(Int_t bin=0;bin<runs[0]->histogrampointer->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;runi<numberRuns;runi++) // loop over runs read from file
+ {
+ runs[runi]->histogrampointer = &runs[runi]->histogramthreshold;
+ TString outline;
+ outline=Form("%.1f\t%.1f",runs[runi]->histogrampointer->Seed->GetBinCenter(bin),runs[runi]->histogrampointer->Seed->GetBinContent(bin));
+ *fout<<outline<<"\t";
+ }
+ *fout<<endl;
+ }
+ fout->close();
+
+ return;
-
-
-
+ }
void plotAllRuns(TString histogramtype)
{
- if (histogramtype.Contains("threshold")){
- if (histogramtype.Contains("threshold"))
-- for(Int_t runi=0;runi<numberRuns;runi++) { /* loop over runs read from file */
- runs[runi]->histogrampointer = &runs[runi]->histogramthreshold;
- }
- else if (histogramtype.Contains("calibrated") || histogramtype.Contains("electron"))
++ if (histogramtype.Contains("threshold")) {
++ for(Int_t runi=0;runi<numberRuns;runi++)/* loop over runs read from file */ {
+ runs[runi]->plothistogrampointer = &runs[runi]->histogramthreshold; } }
+ else if (histogramtype.Contains("calibrated") || histogramtype.Contains("electron")) {
for(Int_t runi=0;runi<numberRuns;runi++) /* loop over runs read from file */ {
- runs[runi]->histogrampointer = &runs[runi]->histogramCalibrated; }
- else
+ runs[runi]->plothistogrampointer = &runs[runi]->histogramCalibrated; } }
+ else {
for(Int_t runi=0;runi<numberRuns;runi++) /* loop over runs read from file */ {
- runs[runi]->histogrampointer = &runs[runi]->histogram; }
+ runs[runi]->plothistogrampointer = &runs[runi]->histogram; } }
plotAllRuns();
}