]> jspc29.x-matter.uni-frankfurt.de Git - radhard.git/commitdiff
Anylyzer: Fixed graph colors
authorBenjamin Linnik <blinnik@jspc28.x-matter.uni-frankfurt.de>
Mon, 11 May 2015 12:16:19 +0000 (14:16 +0200)
committerBenjamin Linnik <blinnik@jspc28.x-matter.uni-frankfurt.de>
Mon, 11 May 2015 12:16:19 +0000 (14:16 +0200)
MABS_run_analyzer/ChargeSpektrum.c
MABS_run_analyzer/Run.c
MABS_run_analyzer/Run.h

index 0b5d8a18cbe7673bc1a7d3000c8385f86072b761..0ad1ba16310628a46083d8598b68cdee06b3c3b2 100644 (file)
@@ -29,6 +29,7 @@
 
 Int_t* ReadRunList();
 void plotAllRuns();
+void plotAllRunsThreshold();
 
 Run** runs;
 Int_t numberRuns;
@@ -62,7 +63,7 @@ void ChargeSpektrum(Int_t runnumber = -1)
     cout << "Found " << numberRuns << " run(s) in 'runlist.txt'." << endl;
     for(Int_t runi=0;runi<numberRuns;runi++) // loop over runs read from file
     {
-        runs[runi] = new Run(runList[runi]);
+        runs[runi] = new Run(runList[runi], runi);
         if (runi%2)
         {
             // check if devided matrix is investigated
@@ -83,22 +84,23 @@ void ChargeSpektrum(Int_t runnumber = -1)
             }
         }
         runs[runi]->setResultsPath("./results/");
-        runs[runi]->setPlotStyle(runi);
         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]->plotSeed();
+        runs[runi]->plotSeedThreshold();
 //         runs[runi]->plotSum();
 //         runs[runi]->plotVeto();
         //         runs[runi]->plotNoise();
         if (!isBatch)
             gROOT->SetBatch(kFALSE);
-        runs[runi]->plotAllHistograms();
+//         runs[runi]->plotAllHistograms();
         runs[runi]->plotAllHistogramsThresholdCluster();
-         runs[runi]->plotAllHistogramsCalibrated(); 
+//          runs[runi]->plotAllHistogramsCalibrated(); 
         runs[runi]->writeAllHistogramsToFile(); 
     }
     plotAllRuns();  
+    plotAllRunsThreshold();
 }
 
 Int_t* ReadRunList()
@@ -188,3 +190,60 @@ void plotAllRuns()
     }
 }
 
+void plotAllRunsThreshold()
+{
+    if (numberRuns > 1)
+    {
+        Float_t lastbin;
+        TTimeStamp* time = new TTimeStamp();
+        
+        TCanvas* canvas = new TCanvas(Form("%d",time->GetNanoSec()), "Summary", 1600, 1000);
+        if (isBatch)
+            canvas->SetCanvasSize(3200,2000);
+        
+        canvas->Divide(2,2);
+        Float_t height = numberRuns * 0.04;
+        TLegend* leg1 = new TLegend(0.3,0.89-height,0.89,0.89);//(0.6,0.7,0.89,0.89);
+        TLegend* leg2 = new TLegend(0.6,0.89-height,0.89,0.89);//(0.6,0.7,0.89,0.89);
+        leg1->SetTextSize(0.02);
+        leg2->SetTextSize(0.02);
+        leg1->SetFillColor(0); leg1->SetBorderSize(0);
+        leg2->SetFillColor(0); leg2->SetBorderSize(0);
+        TString  legendEntry;
+        
+        for(Int_t runi=0;runi<numberRuns;runi++) // loop over runs read from file
+        {
+            canvas->cd(1);
+            runs[runi]->histogramthreshold.Seed->Draw("SAME");
+            lastbin = runs[runi]->histogramthreshold.Seed->GetBinCenter(runs[runi]->histogramthreshold.Seed->FindLastBinAbove(2,1));
+            runs[runi]->histogramthreshold.Seed->SetAxisRange(0,lastbin*1.1,"X");
+            gPad->SetLogy(1);
+            legendEntry = Form("%s", runs[runi]->histogramthreshold.Seed->GetTitle());
+            leg1->AddEntry(runs[runi]->histogramthreshold.Veto, legendEntry, "l");
+            leg1->Draw("SAME");
+            canvas->cd(2);
+            runs[runi]->histogramthreshold.Sum->Draw("SAME");
+            lastbin = runs[runi]->histogramthreshold.Sum->GetBinCenter(runs[runi]->histogramthreshold.Sum->FindLastBinAbove(2,1));
+            runs[runi]->histogramthreshold.Sum->SetAxisRange(0,lastbin*1.1,"X");
+            canvas->cd(3);
+            runs[runi]->histogramthreshold.Veto->Draw("SAME");
+            runs[runi]->histogramthreshold.Veto->SetAxisRange(runs[runi]->histogramthreshold.posVeto*0.7,runs[runi]->histogramthreshold.posVeto*1.4,"X");
+            canvas->cd(4);
+            runs[runi]->histogramthreshold.Noise->Draw("SAME");
+            legendEntry = Form("%s, Noise: %.2f", runs[runi]->labbook.matrix.Data(), runs[runi]->histogramthreshold.avgNoise);
+            leg2->AddEntry(runs[runi]->histogramthreshold.Veto, legendEntry, "l");
+            leg2->Draw("SAME");
+        }
+        
+        //         canvas -> Print( runs[0]->savepathresults + "/" + canvastitle + ".eps");
+        TImageDump *img = new TImageDump(runs[0]->savepathresults + "/" + Form("%s - %s",runs[0]->runcode.Data(), runs[numberRuns-1]->runcode.Data()) + ".png");
+        canvas->Paint();
+        img->Close();
+        
+        TFile *f = new TFile(runs[0]->savepathresults + "/" + Form("%s - %s",runs[0]->runcode.Data(),runs[numberRuns-1]->runcode.Data()) + ".root","RECREATE");
+        f->cd();
+        f->Append(canvas);
+        f->Append(img);
+        f->Write();
+    }
+}
index dec78f3de90f247a719aa10058277014f90663c3..4985c5f0753eb09f52d81d3f91151ffcade6c604 100644 (file)
 #include "Run.h"
 using namespace std;
 
+Run::~Run( void)
+{
+    db->Close();
+    cout << "gelöscht Run" << endl;
+}
+
 Run::Run( void )
 {
     cout << "\033[1;31mError while initializing Run class, please provide a runnumber to the class!\033[0m\n";
     exit(EXIT_FAILURE);
 }
 
-Run::~Run( void)
+Run::Run(Int_t runnumber)
 {
-    db->Close();
-    cout << "gelöscht Run" << endl;
+    Run(runnumber, 0);
 }
 
-Run::Run(Int_t runnumber)
+Run::Run(Int_t runnumber, Int_t loopi)
 {
+    plotStyle = loopi%13;
     labbook.runnumber = runnumber;
     random1 = new TRandom;  
     random1->SetSeed(0);
@@ -649,6 +655,16 @@ void Run::setPlotStyle(Int_t x){
     histogram.Sum->SetLineColor(rootcolors[plotStyle]);
     histogram.Veto->SetLineColor(rootcolors[plotStyle]);
     histogram.Noise->SetLineColor(rootcolors[plotStyle]);
+    
+    histogramCalibrated.Seed->SetLineColor(rootcolors[plotStyle]);
+    histogramCalibrated.Sum->SetLineColor(rootcolors[plotStyle]);
+    histogramCalibrated.Veto->SetLineColor(rootcolors[plotStyle]);
+    histogramCalibrated.Noise->SetLineColor(rootcolors[plotStyle]);
+    
+    histogramthreshold.Seed->SetLineColor(rootcolors[plotStyle]);
+    histogramthreshold.Sum->SetLineColor(rootcolors[plotStyle]);
+    histogramthreshold.Veto->SetLineColor(rootcolors[plotStyle]);
+    histogramthreshold.Noise->SetLineColor(rootcolors[plotStyle]);
 }
 
 Bool_t Run::plotNoise()
@@ -673,6 +689,17 @@ Bool_t Run::plotSeed()
 }
 
 
+Bool_t Run::plotSeedThreshold()
+{
+    if (!error)
+    {
+        plot1DHistogram(histogramthreshold.Seed, "landau");
+        return 0;
+    }
+    return 1;
+}
+
+
 Bool_t Run::plotSum()
 {
     if (!error)
@@ -1163,6 +1190,7 @@ 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);
index 9c42288b94ce1128689cca5cfeba5d65c4a0683c..141793c8dfeded77dad540b531968af876311439 100644 (file)
@@ -208,8 +208,8 @@ private:
         Int_t nbinsnoise;
     };
     systemparam systemparamUSB {
-        800, // maxbin;
-        800/4,// nbins;
+        900, // maxbin;
+        900/15,// nbins;
         25, //vetothreshold
         10,
         100
@@ -243,6 +243,8 @@ public:
     Run    (void);
     /** @brief default constructor */
     Run    ( Int_t );
+    /** @brief default constructor */
+    Run    ( Int_t, Int_t );
     /** @brief writes values back to the database, destroys the #MAPS object */
     ~Run   (void);
 
@@ -291,6 +293,7 @@ public:
     
     Bool_t plotNoise();
     Bool_t plotSeed();
+    Bool_t plotSeedThreshold();
     Bool_t plotSum();
     Bool_t plotVeto();