From ce1fff36c86af272fa9533b290df590cf9ab47fa Mon Sep 17 00:00:00 2001 From: Vratislav Chudoba Date: Thu, 20 Jul 2017 16:56:37 +0300 Subject: [PATCH] BeAnalysis::EpsilonT() implemented --- Be/BeAnalysis.cpp | 126 +++++++++++++++++++++++++++++++++- Be/BeAnalysis.h | 3 + macros/BeCorrPRC/lib_test.cxx | 1 + 3 files changed, 129 insertions(+), 1 deletion(-) diff --git a/Be/BeAnalysis.cpp b/Be/BeAnalysis.cpp index 9fc7353..9fac8b2 100644 --- a/Be/BeAnalysis.cpp +++ b/Be/BeAnalysis.cpp @@ -9,6 +9,7 @@ #include "BeWork.h" #include "TCanvas.h" +#include "TGaxis.h" BeAnalysis::BeAnalysis() : che(0), spectra(1) { // TODO Auto-generated constructor stub @@ -279,7 +280,7 @@ void BeAnalysis::Spectra() { if (!che) return; TCanvas *cSpectra = new TCanvas(); - TString canvasTitle; +// TString canvasTitle; TH1F *hsSpectra[6]; TH1F *heSpectra[6]; @@ -367,3 +368,126 @@ void BeAnalysis::Spectra() { Info("sfAngInt_spectra.cxx", "Finished."); } + +void BeAnalysis::EpsilonT() { + + const Int_t nointervals = 5; + const Bool_t epsilonT[nointervals] = {1,0,0,0,0}; + const Bool_t kVerbose = 1; + const Float_t kRangeProportionIn = 2.0; + + Long64_t eEventsECuts[5][6] = {3950000, 3950000, 3800000, 3850000, 3950000, 3900000, + eMaxEvents, eMaxEvents, 4100000, eMaxEvents, eMaxEvents, eMaxEvents, + 3050000, 3150000, 3200000, 3200000, 3250000, 3350000, + 3850000, 3950000, 3900000, 3900000, 4000000, 4000000, + 4100000, 4100000, 4000000, 4100000, eMaxEvents, eMaxEvents}; + + Long64_t sEventsECuts[5][6] = {sMaxEvents, sMaxEvents, sMaxEvents, sMaxEvents, sMaxEvents, sMaxEvents, + sMaxEvents, 2630000, sMaxEvents, sMaxEvents, 2660000, 2660000, + sMaxEvents, sMaxEvents, sMaxEvents, sMaxEvents, sMaxEvents, sMaxEvents, + sMaxEvents, sMaxEvents, sMaxEvents, sMaxEvents, sMaxEvents, sMaxEvents, + sMaxEvents, sMaxEvents, sMaxEvents, sMaxEvents, sMaxEvents, sMaxEvents}; + + const Double_t eTRange[5][6] = {300, 300, 300, 300, 300, 300, + 380, 380, 380, 380, 380, 380, + 300, 300, 300, 300, 300, 300, + 500, 500, 500, 500, 500, 500, + 500, 500, 500, 500, 500, 500}; + + TCanvas *canEpsilonT[nointervals]; + for (Int_t i = 0; iSetTitle(canvasTitle.Data()); + canEpsilonT[i]->Divide(2, 3); + + che->SetLineColor(kBlack); + for (Int_t j = 0; j < 6; j++) { //different files + if (!kChains[j]) continue; + canEpsilonT[i]->cd(j+1); + chs[j]->SetLineColor(kGray+1); + chs[j]->SetFillColor(kGray+1); + hsName.Form("hseT%d_%d", i, j); + // drawCommand.Form("fTpp/f6BeIM>>%s(50,0,1)", hsName.Data()); + drawCommand.Form("fTpp/f6BeIM>>%s(30,0,1)", hsName.Data()); + // chs[j]->Draw(drawCommand.Data(), cQ && crBeE[i] && crAngles && sRatio[j], "", sEventsECuts[i][j]); + chs[j]->Draw(drawCommand.Data(), cProtons && cQ && crBeE[i] && crAngles && sRatio[j], "", sEventsECuts[i][j]); + hseT[i][j] = (TH1F*)gPad->FindObject(hsName.Data()); + heName.Form("heeT%d_%d", i, j); + // drawCommand.Form("fTpp/fBeIM>>%s(50,0,1)", heName.Data()); + drawCommand.Form("fTpp/fBeIM>>%s", heName.Data()); + // che->Draw(drawCommand.Data(), cQ && cBeE[i] && cAngles, "E same", eEventsECuts[i][j]); + che->Draw(drawCommand.Data(), cProtons && cQ && cBeE[i] && cAngles, "E same", eEventsECuts[i][j]); + heeT[i][j] = (TH1F*)gPad->FindObject(heName.Data()); + + hseT[i][j]->Draw(); + hseT[i][j]->SetTitle(""); + hseT[i][j]->SetXTitle("\\varepsilon"); + hseT[i][j]->GetXaxis()->SetTitleOffset(0.95); + hseT[i][j]->GetXaxis()->CenterTitle(); + hseT[i][j]->SetYTitle("counts"); + // hseT[i][j]->GetYaxis()->SetTitleOffset(1.09); + hseT[i][j]->GetYaxis()->SetTitleOffset(0.7); + hseT[i][j]->GetYaxis()->CenterTitle(); + heeT[i][j]->Draw("E same"); + if (kAutoRange) { + Float_t leftMaxMC = kRangeProportion*hseT[i][j]->GetMaximum(); + Float_t leftMaxE = kRangeProportion*heeT[i][j]->GetMaximum(); + hseT[i][j]->GetYaxis()->SetRangeUser(0, leftMaxE); + leftMaxMC > leftMaxE ? hseT[i][j]->GetYaxis()->SetRangeUser(0, leftMaxMC) : hseT[i][j]->GetYaxis()->SetRangeUser(0, leftMaxE); + } + else { + hseT[i][j]->GetYaxis()->SetRangeUser(0, eTRange[i][j]); + } + canEpsilonT[i]->Update(); + + + hiName.Form("hieT%d_%d", i, j); + // drawCommand.Form("sTpp/E_IM>>%s(50,0,1)", hiName.Data()); + drawCommand.Form("sTpp/E_IM>>%s", hiName.Data()); + ti[j]->Draw(drawCommand.Data(), ciBeE[i] && sRatio[j], "same"); + hieT[i][j] = (TH1F*)gPad->FindObject(hiName.Data()); + Float_t rightmax = kRangeProportionIn*hieT[i][j]->GetMaximum(); + Float_t scale = canEpsilonT[i]->GetPad(j+1)->GetUymax()/rightmax; + hieT[i][j]->SetLineColor(kRed); + hieT[i][j]->Scale(scale); + + //draw an axis on the right side + TGaxis *axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(), + gPad->GetUxmax(), gPad->GetUymax(),0,rightmax,510,"+L"); + axis->SetLineColor(kRed); + axis->SetLabelColor(kRed); + axis->Draw(); + + canEpsilonT[i]->Update(); + + if (kVerbose) { + Info("sfAngInt_epsilonT.cxx", "cut%d; case%d: %3.1f (exp)/ %3.1f (sim) = %3.3f", + i, j, heeT[i][j]->Integral(0,heeT[i][j]->GetNbinsX()), + hseT[i][j]->Integral(0,hseT[i][j]->GetNbinsX()), + heeT[i][j]->Integral(0,heeT[i][j]->GetNbinsX())/hseT[i][j]->Integral(0,hseT[i][j]->GetNbinsX()) ); + } + + }//for j + if (kVerbose) cout << endl; + + /*if (savePictures) { + canvasName.Form("%sfig%depsilonT:%s%s", ppath.Data(), i, configuration.Data(), pictFormat.Data()); + cout << canvasName.Data() << endl; + canEpsilonT[i]->SaveAs(canvasName.Data()); + canEpsilonT[i]->cd(); + canEpsilonT[i]->Close(); + }//if save pictures*/ +// }//if + }//for i + +} diff --git a/Be/BeAnalysis.h b/Be/BeAnalysis.h index 4421ef8..a4f1a59 100644 --- a/Be/BeAnalysis.h +++ b/Be/BeAnalysis.h @@ -42,6 +42,7 @@ public: void SetRatiosGStoEX(); void Spectra(); + void EpsilonT(); // private: TChain *che; //chain with experimental trees @@ -150,6 +151,8 @@ private: TString drawCommand; TString hsName; TString heName; + TString hiName; + TString canvasTitle; }; diff --git a/macros/BeCorrPRC/lib_test.cxx b/macros/BeCorrPRC/lib_test.cxx index 0d7b2a5..9cbb04a 100755 --- a/macros/BeCorrPRC/lib_test.cxx +++ b/macros/BeCorrPRC/lib_test.cxx @@ -12,4 +12,5 @@ void lib_test() { ana.SetRatiosGStoEX(); ana.Spectra(); + ana.EpsilonT(); } -- 2.18.1