]> jspc29.x-matter.uni-frankfurt.de Git - radhard.git/commitdiff
writeObservableToFile added
authorDennis Doering <doering@physik.uni-frankfurt.de>
Wed, 13 May 2015 11:18:42 +0000 (13:18 +0200)
committerDennis Doering <doering@physik.uni-frankfurt.de>
Wed, 13 May 2015 11:18:42 +0000 (13:18 +0200)
MABS_run_analyzer/ChargeSpektrum.c

index ab1eb6865f6153d950974e27ed319ca88a3e4d0e..f7aafd88c1bb30cc6333d35794ba373c79936cb1 100644 (file)
@@ -30,7 +30,7 @@
 Int_t* ReadRunList();
 void plotAllRuns();
 void plotAllRuns(TString);
-
+void writeObservableToFile(TString);
 Run** runs;
 Int_t numberRuns;
 Bool_t isBatch = kFALSE;
@@ -85,8 +85,8 @@ void ChargeSpektrum(Int_t runnumber = -1)
         }
         runs[runi]->setResultsPath("./results/");
         runs[runi]->useDynamicalNoise(true);
-       // runs[runi]->analyzeRun(true); // creates or opens .root file, can analyze the RAW data
-               runs[runi]->analyzeFrame(353);
+        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();
@@ -102,6 +102,7 @@ void ChargeSpektrum(Int_t runnumber = -1)
     }
     plotAllRuns("");
     plotAllRuns("threshold");
+       writeObservableToFile("Seed");
 }
 
 Int_t* ReadRunList()
@@ -132,13 +133,61 @@ Int_t* ReadRunList()
 // {
 //     
 // }
-
+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"))
         for(Int_t runi=0;runi<numberRuns;runi++) { /* loop over runs read from file */
-            runs[runi]->histogrampointer = &runs[runi]->histogramthreshold; }
+            runs[runi]->histogrampointer = &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; }