From cc87a0d79c93bd80d62f267ce76ab6b554463c8d Mon Sep 17 00:00:00 2001 From: Vratislav Chudoba Date: Mon, 31 Jul 2017 19:11:45 +0300 Subject: [PATCH] SaveEpsilonTHist() implemented. --- Be/BeAnalysis.cpp | 97 ++++++++++++++++++++++++++++++++++++++--------- Be/BeAnalysis.h | 56 +++++++++++++++------------ 2 files changed, 111 insertions(+), 42 deletions(-) diff --git a/Be/BeAnalysis.cpp b/Be/BeAnalysis.cpp index 7d100c7..f555a8c 100644 --- a/Be/BeAnalysis.cpp +++ b/Be/BeAnalysis.cpp @@ -23,6 +23,9 @@ BeAnalysis::BeAnalysis() : che(0), lowExpFile(0), upExpFile(0), spectra(0) { SetChainsToDraw(); SetNoBinsSpectra(); + SetNoBinsCorrelations(); + + InitHistos(); noIntervals = 5; @@ -138,7 +141,7 @@ void BeAnalysis::SetCuts() { ciEpsilon = "sTpp/E_IM<0.2"; //ciEpsilon = "sTpp/E_IM<1."; //ciEpsilonY = "sTap/E_IM<0.5"; - ciEpsilonY = "sTap/E_IM>0.7"; +// ciEpsilonY = "sTap/E_IM>0.7"; cQ = "TMath::Abs(fQLiP)<10"; cProtons = "fP1Lab.fE-938.272<50 && fP2Lab.fE-938.272<50"; @@ -222,6 +225,53 @@ void BeAnalysis::SetRatiosGStoEX(TString sRatioAl0, TString sRatioNoAl0, } +void BeAnalysis::InitHistos() { + + for (Int_t i = 0; i < 6; i++) { + hsSpectra[i] = 0; + heSpectra[i] = 0; + hSdiff[i] = 0; + } + + for (Int_t i = 0; i < 5; i++) { + for (Int_t j = 0; j < 6; j++) { + hseT[i][j] = 0; + heeT[i][j] = 0; + hieT[i][j] = 0; + } + } + + +} + +void BeAnalysis::SaveSpectrumHist(Int_t i) { + + TFile fw("figures/spectra.root", "UPDATE"); + if (heSpectra[i] != 0) heSpectra[i]->Write(); + if (hsSpectra[i] != 0) hsSpectra[i]->Write(); + fw.Close(); + +} + +void BeAnalysis::SaveEpsilonTHist(Int_t interval, Int_t chain) { + + TFile fw("figures/epsilonT.root", "UPDATE"); + if (heeT[interval][chain] != 0) { + heeT[interval][chain]->Write(); + Info("BeAnalysis::SaveEpsilonTHist", "Histogram saved."); + } + if (hseT[interval][chain] != 0) { + Info("BeAnalysis::SaveEpsilonTHist", "Histogram saved."); + hseT[interval][chain]->Write(); + } + if (hieT[interval][chain] != 0) { + Info("BeAnalysis::SaveEpsilonTHist", "Histogram saved."); + hieT[interval][chain]->Write(); + } + fw.Close(); + +} + void BeAnalysis::SetCMAngularCuts() { TString sAngles, srAngles; @@ -236,6 +286,7 @@ void BeAnalysis::SetCMAngularCuts() { void BeAnalysis::Spectra() { if (!spectra) { + Error("BeAnalysis::Spectra", "kSpectra was to zero."); return; } @@ -253,9 +304,9 @@ void BeAnalysis::Spectra() { TCanvas *cSpectra = new TCanvas(); - TH1F *hsSpectra[6]; - TH1F *heSpectra[6]; - TH1F *hSdiff[6]; +// TH1F *hsSpectra[6]; +// TH1F *heSpectra[6]; +// TH1F *hSdiff[6]; canvasTitle.Form("energy spectra fitting;\t(%d,%d) degrees", kMinAngle, kMaxAngle); cSpectra->SetTitle(canvasTitle.Data()); @@ -271,19 +322,22 @@ void BeAnalysis::Spectra() { chs[j]->SetLineColor(kBlue); chs[j]->SetFillColor(kWhite); hsName.Form("hsSpectra%d", j); - hsSpectra[j] = new TH1F(hsName.Data(), "title", noBinsSpectra, 0, 10); + hsSpectra[j] = new TH1F(hsName.Data(), cAngles.GetTitle(), noBinsSpectra, 0, 10); // drawCommand.Form("f6BeIM>>%s(200,0,10)", hsName.Data()); drawCommand.Form("f6BeIM>>%s", hsName.Data()); // chs[j]->Draw(drawCommand.Data(), cQ && crBeWork && crAngles && sRatio[j], "", sEvents[j]); chs[j]->Draw(drawCommand.Data(), cProtons && cQ && crBeWork && crAngles && sRatio[j], "", sEvents[j]); // hsSpectra[j] = (TH1F*)gPad->FindObject(hsName.Data()); heName.Form("heSpectra%d", j); - heSpectra[j] = new TH1F(heName.Data(), "title", noBinsSpectra, 0, 10); + heSpectra[j] = new TH1F(heName.Data(), cAngles.GetTitle(), noBinsSpectra, 0, 10); // drawCommand.Form("fBeIM>>%s(200,0,10)", heName.Data()); drawCommand.Form("fBeIM>>%s", heName.Data()); // che->Draw(drawCommand.Data(), cQ && cBeWork && cAngles, "same", eEvents[j]); che->Draw(drawCommand.Data(), cProtons && cQ && cBeWork && cAngles, "", eEvents[j]); +// TString histTitle; +// histTitle.Form("%s", cAngles.GetTitle()); +// heSpectra[j]->SetTitle(cAngles.GetTitle()); //// cout << drawCommand << "\t" << eEvents[j] << endl; //// che->Draw(drawCommand.Data(), cProtons && cQ && cBeWork && cAngles, "", eEvents[j]); @@ -294,16 +348,18 @@ void BeAnalysis::Spectra() { // heSpectra[j]->Draw(""); heSpectra[j]->Draw("E"); heSpectra[j]->SetLineColor(1); - heSpectra[j]->SetTitle(""); +// heSpectra[j]->SetTitle(""); heSpectra[j]->SetXTitle("E_{T} (MeV)"); // heSpectra[j]->GetXaxis()->SetTitleOffset(0.95); heSpectra[j]->GetXaxis()->CenterTitle(); heSpectra[j]->SetYTitle("counts"); // heSpectra[j]->GetYaxis()->SetTitleOffset(0.7); heSpectra[j]->GetYaxis()->CenterTitle(); + hsSpectra[j]->SetLineColor(kGray+1); hsSpectra[j]->SetFillColor(kGray+1); hsSpectra[j]->Draw("same"); + heSpectra[j]->Draw("same E"); if (kAutoRange) { @@ -353,9 +409,9 @@ void BeAnalysis::EpsilonT() { TCanvas *canEpsilonT[noIntervals]; for (Int_t i = 0; icd(j+1); - chs[j]->SetLineColor(kGray+1); - chs[j]->SetFillColor(kGray+1); +// chs[j]->SetLineColor(kGray+1); +// chs[j]->SetFillColor(kGray+1); hsName.Form("hseT%d_%d", i, j); - drawCommand.Form("fTpp/f6BeIM>>%s(30,0,1)", hsName.Data()); +// hsSpectra[j] = new TH1F(hsName.Data(), cAngles.GetTitle(), noBinsSpectra, 0, 10); + hseT[i][j] = new TH1F(hsName.Data(), cAngles.GetTitle(), noBinsCorr, 0, 1.); + hseT[i][j]->SetLineColor(kGray+1); + hseT[i][j]->SetFillColor(kGray+1); +// drawCommand.Form("fTpp/f6BeIM>>%s(30,0,1)", hsName.Data()); + drawCommand.Form("fTpp/f6BeIM>>%s", hsName.Data()); chs[j]->Draw(drawCommand.Data(), cProtons && cQ && crBeE[i] && crAngles && sRatio[j], "", sEventsECuts[i][j]); - hseT[i][j] = (TH1F*)gPad->FindObject(hsName.Data()); +// hseT[i][j] = (TH1F*)gPad->FindObject(hsName.Data()); heName.Form("heeT%d_%d", i, j); + heeT[i][j] = new TH1F(heName.Data(), cAngles.GetTitle(), noBinsCorr, 0, 1.); drawCommand.Form("fTpp/fBeIM>>%s", heName.Data()); che->Draw(drawCommand.Data(), cProtons && cQ && cBeE[i] && cAngles, "E same", eEventsECuts[i][j]); - heeT[i][j] = (TH1F*)gPad->FindObject(heName.Data()); +// heeT[i][j] = (TH1F*)gPad->FindObject(heName.Data()); // continue; hseT[i][j]->Draw(); - hseT[i][j]->SetTitle(""); +// hseT[i][j]->SetTitle(""); hseT[i][j]->SetXTitle("\\varepsilon"); // hseT[i][j]->GetXaxis()->SetTitleOffset(0.95); // hseT[i][j]->GetXaxis()->SetTitleSize(0.11); @@ -418,8 +480,9 @@ void BeAnalysis::EpsilonT() { hiName.Form("hieT%d_%d", i, j); drawCommand.Form("sTpp/E_IM>>%s", hiName.Data()); + hieT[i][j] = new TH1F(hiName.Data(), cAngles.GetTitle(), noBinsCorr, 0, 1.); ti[j]->Draw(drawCommand.Data(), ciBeE[i] && sRatio[j], "same"); - hieT[i][j] = (TH1F*)gPad->FindObject(hiName.Data()); +// 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); diff --git a/Be/BeAnalysis.h b/Be/BeAnalysis.h index f76429a..7a3e3f6 100644 --- a/Be/BeAnalysis.h +++ b/Be/BeAnalysis.h @@ -15,6 +15,8 @@ #include "TCut.h" #include "TCanvas.h" +#define NOINTERVALS 5; + using std::cout; using std::endl; @@ -37,20 +39,16 @@ public: void OpenExpChain(); void SetNoBinsSpectra(Int_t noBins = 100) {noBinsSpectra = noBins;}; + void SetNoBinsCorrelations(Int_t noBins = 30) {noBinsCorr = noBins;}; TChain* GetExpChain() {return che;}; TChain* GetSimChain(Int_t i) {return chs[i];}; void SetChainsToDraw(Bool_t ch0 = 1, Bool_t ch1 = 1, Bool_t ch2 = 1, Bool_t ch3 = 1, Bool_t ch4 = 1, Bool_t ch5 = 1); -private: - void SetCuts(); -public: void SetSimCuts(TString sEt[5]/*, TString sET0 = "", TString sET1 = "", TString sET2 = "", TString sET3 = "", TString sET4 = ""*/); void SetCMAngularRange(Int_t minAngle, Int_t maxAngle); -private: - void SetCMAngularCuts(); -public: + void SetRangeProportion(Float_t rangeProportion = 1.1, Bool_t autoRange = 1); void SetNoExpEvents(Long64_t *noExpEvents = 0); @@ -58,9 +56,7 @@ public: void SetRatiosGStoEX(TString sRatioAl0, TString sRatioNoAl0, TString sRatioAl180, TString sRatioNoAl180, TString sRatioAl90, TString sRatioNoAl90); -// void ExpEventsECuts(Long64_t **noExpEvents = 0); -// void ExpEventsECuts(Int_t (&noExpEvents)[5][6]); -// void ExpEventsECuts(Int_t (*noExpEvents)[5][6]); + void ExpEventsECuts(Long64_t noExpEvents[5][6] = 0); void SimEventsECuts(Long64_t noSimEvents[5][6] = 0); void EpsilonTRange(); @@ -81,9 +77,12 @@ public: void SetFigures(TString figPath = "figures/", TString figFormat = ".eps", Bool_t kSave = 1); + void SaveSpectrumHist(Int_t i); + void SaveEpsilonTHist(Int_t interval, Int_t chain); + // -//private: +private: TChain *che; //chain with experimental trees TChain *chs[6]; //array of chains with simulation trees TTree *ti[6]; //array of chains with simulation input @@ -98,10 +97,25 @@ private: Int_t upSimFile[6]; Int_t noBinsSpectra; + Int_t noBinsCorr; Int_t kMinAngle; Int_t kMaxAngle; +//histograms + TH1F *hsSpectra[6]; + TH1F *heSpectra[6]; + TH1F *hSdiff[6]; + + TH1F *hseT[5][6]; + TH1F *heeT[5][6]; + TH1F *hieT[5][6]; + +// TH1F *hscoskT[noIntervals][6]; +// TH1F *hecoskT[noIntervals][6]; +// TH1F *hicoskT[noIntervals][6]; + +//cuts TCut cAngles; TCut crAngles; @@ -132,14 +146,7 @@ private: Double_t eTRange[5][6]; //! //cuts -// TCut cBe20; -// TCut cBe3; TCut cBeWork; -// TCut cBe0_14; -// TCut cBe14_19; -// TCut cBe19_25; -// TCut cBe25_31; -// TCut cBe31_37; TCut cBeE[5]; TCut cEpsilonT; @@ -147,14 +154,7 @@ private: //raw files //energy cuts -// TCut crBe20; -// TCut crBe3; TCut crBeWork; -// TCut crBe0_14; -// TCut crBe14_19; -// TCut crBe19_25; -// TCut crBe25_31; -// TCut crBe31_37; TCut crBeE[5]; //angular cuts @@ -165,7 +165,7 @@ private: TCut ciBeE[5]; TCut ciEpsilon; - TCut ciEpsilonY; +// TCut ciEpsilonY; TCut cQ; TCut cProtons; @@ -186,9 +186,15 @@ private: TString figureFormat; private: + + void InitHistos(); + void SaveFigures(TCanvas *canvas, TString variable, Int_t interval); void CanvasDivision(TCanvas *c); + void SetCuts(); + void SetCMAngularCuts(); + }; #endif /* BE_BEANALYSIS_H_ */ -- 2.18.1