From 06719912c39919b6cf3c9db63c3b0cd0b0dcd34f Mon Sep 17 00:00:00 2001 From: Benjamin Linnik Date: Mon, 11 May 2015 14:16:19 +0200 Subject: [PATCH] Anylyzer: Fixed graph colors --- MABS_run_analyzer/ChargeSpektrum.c | 69 +++++++++++++++++++++++++++--- MABS_run_analyzer/Run.c | 36 ++++++++++++++-- MABS_run_analyzer/Run.h | 7 ++- 3 files changed, 101 insertions(+), 11 deletions(-) diff --git a/MABS_run_analyzer/ChargeSpektrum.c b/MABS_run_analyzer/ChargeSpektrum.c index 0b5d8a1..0ad1ba1 100644 --- a/MABS_run_analyzer/ChargeSpektrum.c +++ b/MABS_run_analyzer/ChargeSpektrum.c @@ -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;runisetResultsPath("./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;runicd(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(); + } +} diff --git a/MABS_run_analyzer/Run.c b/MABS_run_analyzer/Run.c index dec78f3..4985c5f 100644 --- a/MABS_run_analyzer/Run.c +++ b/MABS_run_analyzer/Run.c @@ -10,20 +10,26 @@ #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); diff --git a/MABS_run_analyzer/Run.h b/MABS_run_analyzer/Run.h index 9c42288..141793c 100644 --- a/MABS_run_analyzer/Run.h +++ b/MABS_run_analyzer/Run.h @@ -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(); -- 2.43.0