CbmRoot
Loading...
Searching...
No Matches
CbmAnaJpsiSuperEventReport.cxx
Go to the documentation of this file.
1/* Copyright (C) 2015-2021 UGiessen, JINR-LIT
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Adrian Amatus Weber, Semen Lebedev [committer] */
4
6
7#include "CbmAnaJpsiCuts.h"
8#include "CbmAnaJpsiHist.h"
9#include "CbmDrawHist.h"
10#include "CbmHistManager.h"
11#include "CbmReportElement.h"
12#include "CbmUtils.h"
13
14#include "TCanvas.h"
15#include "TDirectory.h"
16#include "TF1.h"
17#include "TFile.h"
18#include "TH1.h"
19#include "TLatex.h"
20#include "TLine.h"
21#include "TMarker.h"
22#include "TPad.h"
23#include "TStyle.h"
24
25#include <boost/assign/list_of.hpp>
26
27#include <iostream>
28#include <map>
29
30using boost::assign::list_of;
32using Cbm::Split;
33using std::cout;
34using std::endl;
35using std::map;
36using std::string;
37
39{
40 SetReportName("jpsi_superevent_qa");
41}
42
44
45void CbmAnaJpsiSuperEventReport::Create(const string& fileEventByEvent, const string& fileSuperEvent,
46 const string& outputDir)
47{
49 TFile* oldFile = gFile;
50 TDirectory* oldDir = gDirectory;
51
53 TFile* fileSE = new TFile(fileSuperEvent.c_str());
55
57 TFile* fileEbE = new TFile(fileEventByEvent.c_str());
59
60 SetOutputDir(outputDir);
62
64 gFile = oldFile;
65 gDirectory = oldDir;
66}
68{
69 //Out().precision(3);
70 Out() << R()->DocumentBegin();
71 Out() << R()->Title(0, GetTitle());
72
74
75 Out() << R()->DocumentEnd();
76}
77
79{
81
82 long nofSEEvents = fHMSuperEvent->H1("fh_se_event_number")->GetEntries();
83 long nofSEEventsSquared = nofSEEvents * nofSEEvents;
84 cout << "Number of SE events = " << nofSEEventsSquared << endl;
85 fHMSuperEvent->ScaleByPattern(".*", 1. / (nofSEEventsSquared));
86
87 int nofEEEvents = fHMEventByEvent->H1("fh_event_number")->GetEntries();
88 cout << "Number of EE events = " << nofEEEvents << endl;
89 fHMEventByEvent->ScaleByPattern(".*", 1. / nofEEEvents);
90
91
92 Int_t nRebins = 20;
93 fHMEventByEvent->RebinByPattern("fh_signal_minv.+", nRebins);
94 fHMEventByEvent->RebinByPattern("fh_bg_minv.+", nRebins);
95 fHMEventByEvent->RebinByPattern("fh_ee_signal_minv_diff_ptcuts.+", nRebins);
96 fHMSuperEvent->RebinByPattern("fh_se_bg_participants_minv.+", nRebins);
97 fHMSuperEvent->RebinByPattern("fh_se_bg_truematch.+", nRebins);
98 fHMSuperEvent->RebinByPattern("fh_se_bg_mismatch.+", nRebins);
99
100
101 fHMEventByEvent->ScaleByPattern("fh_signal_minv.+", nRebins);
102 fHMEventByEvent->ScaleByPattern("fh_bg_minv.+", nRebins);
103 fHMEventByEvent->ScaleByPattern("fh_ee_signal_minv_diff_ptcuts.+", nRebins);
104 fHMSuperEvent->ScaleByPattern("fh_se_bg_participants_minv.+", nRebins);
105 fHMSuperEvent->ScaleByPattern("fh_se_bg_truematch.+", nRebins);
106 fHMSuperEvent->ScaleByPattern("fh_se_bg_mismatch.+", nRebins);
107
109
111
113
115
116 {
117 CreateCanvas("jpsi_fh_SE_PdgCode_of Others_BG", "jpsi_fh_SE_PdgCode_of Others_BG", 1000, 1000);
118 DrawH1(fHMSuperEvent->H1("fh_SE_PdgCode_of Others_BG"));
120 }
121
123
125}
126
128{
129 CreateCanvas("jpsi_se_fh_se_ee_bg_minv_reco", "jpsi_fh_se_ee_bg_minv_reco", 900, 900);
130 DrawH1(list_of((TH1*) fHMEventByEvent->H1("fh_bg_minv_reco")->Clone())(
131 (TH1*) fHMSuperEvent->H1("fh_se_bg_minv_" + CbmAnaJpsiHist::fAnaSteps[kJpsiReco])->Clone()),
132 list_of("Event-by-Event")("SuperEvent"), kLinear, kLinear, true, 0.7, 0.9, 0.99, 0.95);
134
135
136 CreateCanvas("jpsi_se_fh_se_ee_bg_minv_chi2prim", "jpsi_fh_se_ee_bg_minv_chi2prim", 900, 900);
137 DrawH1(list_of((TH1*) fHMEventByEvent->H1("fh_bg_minv_chi2prim")->Clone())(
138 (TH1*) fHMSuperEvent->H1("fh_se_bg_minv_" + CbmAnaJpsiHist::fAnaSteps[kJpsiChi2Prim])->Clone()),
139 list_of("Event-by-Event")("SuperEvent"), kLinear, kLinear, true, 0.7, 0.9, 0.99, 0.95);
141
142
143 CreateCanvas("jpsi_se_fh_se_ee_bg_minv_elid", "jpsi_fh_se_ee_bg_minv_elid", 900, 900);
144 DrawH1(list_of((TH1*) fHMEventByEvent->H1("fh_bg_minv_elid")->Clone())(
145 (TH1*) fHMSuperEvent->H1("fh_se_bg_minv_" + CbmAnaJpsiHist::fAnaSteps[kJpsiElId])->Clone()),
146 list_of("Event-by-Event")("SuperEvent"), kLinear, kLinear, true, 0.7, 0.9, 0.99, 0.95);
148
149
150 CreateCanvas("jpsi_se_fh_se_ee_bg_minv_ptcut", "jpsi_fh_se_ee_bg_minv_ptcut", 900, 900);
151 DrawH1(list_of((TH1*) fHMEventByEvent->H1("fh_bg_minv_ptcut")->Clone())(
152 (TH1*) fHMSuperEvent->H1("fh_se_bg_minv_" + CbmAnaJpsiHist::fAnaSteps[kJpsiPtCut])->Clone()),
153 list_of("Event-by-Event")("SuperEvent"), kLinear, kLinear, true, 0.7, 0.9, 0.99, 0.95);
155}
156
158{
159 CreateCanvas("jpsi_se_minv_reco", "jpsi_se_minv_reco", 900, 900);
160 fHMSuperEvent->H1("fh_se_bg_minv_" + CbmAnaJpsiHist::fAnaSteps[kJpsiReco])->SetMinimum(1e-9);
161 DrawH1(list_of((TH1*) fHMSuperEvent->H1("fh_se_bg_minv_" + CbmAnaJpsiHist::fAnaSteps[kJpsiReco])->Clone())(
162 (TH1*) fHMEventByEvent->H1("fh_signal_minv_" + CbmAnaJpsiHist::fAnaSteps[kJpsiReco])->Clone()),
163 list_of("Background SuperEvent")("Signal Event-By-Event"), kLinear, kLog, true, 0.7, 0.9, 0.99, 0.95);
165
166 CreateCanvas("jpsi_se_minv_chi2prim", "jpsi_se_minv_chi2prim", 900, 900);
167 fHMSuperEvent->H1("fh_se_bg_minv_" + CbmAnaJpsiHist::fAnaSteps[kJpsiChi2Prim])->SetMinimum(1e-9);
168 DrawH1(list_of((TH1*) fHMSuperEvent->H1("fh_se_bg_minv_" + CbmAnaJpsiHist::fAnaSteps[kJpsiChi2Prim])->Clone())(
169 (TH1*) fHMEventByEvent->H1("fh_signal_minv_" + CbmAnaJpsiHist::fAnaSteps[kJpsiChi2Prim])->Clone()),
170 list_of("Background SuperEvent")("Signal Event-By-Event"), kLinear, kLog, true, 0.7, 0.9, 0.99, 0.95);
172
173 CreateCanvas("jpsi_se_minv_elid", "jpsi_se_minv_elid", 900, 900);
174 fHMSuperEvent->H1("fh_se_bg_minv_" + CbmAnaJpsiHist::fAnaSteps[kJpsiElId])->SetMinimum(1e-9);
175 DrawH1(list_of((TH1*) fHMSuperEvent->H1("fh_se_bg_minv_" + CbmAnaJpsiHist::fAnaSteps[kJpsiElId])->Clone())(
176 (TH1*) fHMEventByEvent->H1("fh_signal_minv_" + CbmAnaJpsiHist::fAnaSteps[kJpsiElId])->Clone()),
177 list_of("Background SuperEvent")("Signal Event-By-Event"), kLinear, kLog, true, 0.7, 0.9, 0.99, 0.95);
179
180 CreateCanvas("jpsi_se_minv_ptcut", "jpsi_se_minv_ptcut", 900, 900);
181 fHMSuperEvent->H1("fh_se_bg_minv_" + CbmAnaJpsiHist::fAnaSteps[kJpsiPtCut])->SetMinimum(1e-9);
182 DrawH1(list_of((TH1*) fHMSuperEvent->H1("fh_se_bg_minv_" + CbmAnaJpsiHist::fAnaSteps[kJpsiPtCut])->Clone())(
183 (TH1*) fHMEventByEvent->H1("fh_signal_minv_" + CbmAnaJpsiHist::fAnaSteps[kJpsiPtCut])->Clone()),
184 list_of("Background SuperEvent")("Signal Event-By-Event"), kLinear, kLog, true, 0.7, 0.9, 0.99, 0.95);
186
187 CreateCanvas("jpsi_se_ee_minv_ptcut", "jpsi_se_ee_minv_ptcut", 900, 900);
188 TH1D* fhBg = (TH1D*) fHMSuperEvent->H1("fh_se_bg_minv_" + CbmAnaJpsiHist::fAnaSteps[kJpsiPtCut])->Clone();
189 TH1D* fhSignal = (TH1D*) fHMEventByEvent->H1("fh_signal_minv_" + CbmAnaJpsiHist::fAnaSteps[kJpsiPtCut])->Clone();
190 TH1D* fhBgSignal = (TH1D*) fhBg->Clone();
191 fhBgSignal->Add(fhSignal);
192 fhBgSignal->SetMinimum(1e-9);
193 DrawH1(list_of(fhBg)(fhSignal)(fhBgSignal),
194 list_of("Background SuperEvent")("Signal Event-By-Event")("Signal and Background"), kLinear, kLog, true, 0.7,
195 0.9, 0.99, 0.95);
197}
198
200{
201 TH1D* signal_ee = (TH1D*) fHMEventByEvent->H1("fh_signal_minv_" + CbmAnaJpsiHist::fAnaSteps[step]);
202 TH1D* bg_se = (TH1D*) fHMSuperEvent->H1("fh_se_bg_minv_" + CbmAnaJpsiHist::fAnaSteps[step]);
203
204 //Create Histogram for the Gaus-Fit
205 TH1D* signalFit_ee = (TH1D*) signal_ee->Clone();
206 signalFit_ee->Fit("gaus", "", "", 2.9, 3.3);
207
208 //Calculate sigma and Mean
209 Double_t sigmaSignal = signalFit_ee->GetFunction("gaus")->GetParameter("Sigma");
210 Double_t meanSignal = signalFit_ee->GetFunction("gaus")->GetParameter("Mean");
211
212 //Get the number of the Bins of Min and Max
213 int signalMin = signal_ee->FindBin(meanSignal - 2. * sigmaSignal);
214 int signalMax = signal_ee->FindBin(meanSignal + 2. * sigmaSignal);
215
216 double NOfSignalEntries = 0.;
217 double NOfBgEntries = 0.;
218
219 //sum up all the bins
220 for (int i = signalMin; i <= signalMax; i++) {
221 NOfSignalEntries += signal_ee->GetBinContent(i);
222 NOfBgEntries += bg_se->GetBinContent(i);
223 }
224
225 //Calculate Signal/Background
226 if (NOfBgEntries <= 0.) { return 0.; }
227 else {
228 double sOverBg = NOfSignalEntries / NOfBgEntries;
229 return sOverBg;
230 }
231}
232
234{
235 CreateCanvas("jpsi_fh_se_SignalOverBg_allAnaSteps", "jpsi_fh_se_SignalOverBg_allAnaSteps", 600, 600);
236 fHMSuperEvent->Create1<TH1D>("fh_se_SignalOverBg_allAnaSteps", "fh_se_SignalOverBg_allAnaSteps;AnaSteps;S/Bg", 4, 0,
237 4);
238
239
240 for (int i = 0; i < CbmAnaJpsiHist::fNofAnaSteps - 2; i++) {
241 double nstep = i + 0.5;
242 double SOverBg = SignalOverBg(i + 2);
243 fHMSuperEvent->H1("fh_se_SignalOverBg_allAnaSteps")->Fill(nstep, SOverBg);
244 gPad->SetLogy();
245 }
246
247 fHMSuperEvent->H1("fh_se_SignalOverBg_allAnaSteps")->GetXaxis()->SetLabelSize(0.06);
248 int x = 1;
249 for (Int_t step = 2; step < CbmAnaJpsiHist::fNofAnaSteps; step++) {
250 fHMSuperEvent->H1("fh_se_SignalOverBg_allAnaSteps")
251 ->GetXaxis()
252 ->SetBinLabel(x, CbmAnaJpsiHist::fAnaStepsLatex[step].c_str());
253 x++;
254 }
255
256 DrawH1(fHMSuperEvent->H1("fh_se_SignalOverBg_allAnaSteps"), kLinear, kLinear, "Text COLZ");
257}
258
260{
261 CreateCanvas("jpsi_fh_bg_pair_source", "jpsi_fh_bg_pair_source", 800, 800);
262
263 DrawH1(list_of((TH1*) fHMSuperEvent->H1("fh_se_bg_minv_" + CbmAnaJpsiHist::fAnaSteps[kJpsiPtCut])->Clone())(
264 fHMSuperEvent->H1("fh_se_bg_participants_minv_gg"))(fHMSuperEvent->H1("fh_se_bg_participants_minv_gp"))(
265 fHMSuperEvent->H1("fh_se_bg_participants_minv_go"))(fHMSuperEvent->H1("fh_se_bg_participants_minv_pp"))(
266 fHMSuperEvent->H1("fh_se_bg_participants_minv_po"))(fHMSuperEvent->H1("fh_se_bg_participants_minv_oo")),
267 list_of("whole BG")("#gamma + #gamma")("#gamma + #pi^{0}")("#gamma + others")("#pi^{0} + #pi^{0}")(
268 "#pi^{0} + others")("others + others"),
269 kLinear, kLog, true, 0.85, 0.6, 0.99, 0.99);
270
272}
273
275{
276 CreateCanvas("jpsi_fh_se_bg_Minv_Mismatch_pt", "jpsi_fh_se_bg_Minv_Mismatch_pt", 800, 800);
277
278 double trueMatch = fHMSuperEvent->H1("fh_se_bg_truematch_minv_ptCut")->GetEntries();
279 double trueMatchEl = fHMSuperEvent->H1("fh_se_bg_truematch_el_minv_ptCut")->GetEntries();
280 double trueMatchNotEl = fHMSuperEvent->H1("fh_se_bg_truematch_notel_minv_ptCut")->GetEntries();
281 double misMatch = fHMSuperEvent->H1("fh_se_bg_mismatch_minv_ptCut")->GetEntries();
282 double nofBg = fHMSuperEvent->H1("fh_se_bg_minv_ptcut")->GetEntries();
283
284 DrawH1(
285 list_of(fHMSuperEvent->H1("fh_se_bg_truematch_minv_ptCut"))(fHMSuperEvent->H1("fh_se_bg_truematch_el_minv_ptCut"))(
286 fHMSuperEvent->H1("fh_se_bg_truematch_notel_minv_ptCut"))(fHMSuperEvent->H1("fh_se_bg_mismatch_minv_ptCut")),
287 list_of("true match (" + Cbm::NumberToString(100. * trueMatch / nofBg, 1)
288 + "%)")("true match (e^{#pm}) (" + Cbm::NumberToString(100. * trueMatchEl / nofBg, 1)
289 + "%)")("true match (not e^{#pm}) (" + Cbm::NumberToString(100. * trueMatchNotEl / nofBg, 1)
290 + "%)")("mismatch (" + Cbm::NumberToString(100. * misMatch / nofBg) + "%)"),
291 kLinear, kLog, true, 0.65, 0.8, 0.99, 0.99);
292
294}
295
297{
298 TCanvas* c6 = CreateCanvas("jpsi_se_ee_minv_diff_ptCuts", "jpsi_se_ee_minv_diff_ptCuts", 1600, 800);
299 c6->Divide(4, 2);
300 for (int i = 0; i < 8; i++) {
301 c6->cd(i + 1);
302 TH1D* fhBgDiffPtCuts = (TH1D*) fHMSuperEvent->H1("fh_se_bg_minv_diff_ptcuts_" + Cbm::NumberToString(i))->Clone();
303 TH1D* fhSignalDiffPtCuts =
304 (TH1D*) fHMEventByEvent->H1("fh_ee_signal_minv_diff_ptcuts_" + Cbm::NumberToString(i))->Clone();
305 TH1D* fhBgSignalDiffPtCuts = (TH1D*) fhBgDiffPtCuts->Clone();
306 fhBgSignalDiffPtCuts->Add(fhSignalDiffPtCuts);
307 fhBgSignalDiffPtCuts->SetMinimum(1e-9);
308
309 double lowerCut = 0;
310 double upperCut = 0;
311 if (i < 6) {
312 upperCut = (0.4 * (i + 1));
313 lowerCut = (upperCut - 0.4);
314 }
315 else if (i == 6) {
316 upperCut = 3.0;
317 lowerCut = 2.4;
318 }
319 else if (i == 7) {
320 upperCut = 6.0;
321 lowerCut = 3.0;
322 }
323 string text = Cbm::NumberToString(lowerCut, 2) + "<P_t<" + Cbm::NumberToString(upperCut, 2);
324
325 //SignalOverBackground
326 //Create Histogram for the Gaus-Fit
327 TH1D* signalFit_DiffPt_ee = (TH1D*) fhSignalDiffPtCuts->Clone();
328 signalFit_DiffPt_ee->Fit("gaus", "", "", 2.9, 3.3);
329
330 //Calculate sigma and Mean
331 Double_t sigmaSignal = signalFit_DiffPt_ee->GetFunction("gaus")->GetParameter("Sigma");
332 Double_t meanSignal = signalFit_DiffPt_ee->GetFunction("gaus")->GetParameter("Mean");
333
334 //Get the number of the Bins of Min and Max
335 int signalMin = signalFit_DiffPt_ee->FindBin(meanSignal - 2. * sigmaSignal);
336 int signalMax = signalFit_DiffPt_ee->FindBin(meanSignal + 2. * sigmaSignal);
337
338 double NOfSignalEntries = 0.;
339 double NOfBgEntries = 0.;
340
341 //sum up all the bins
342 for (int j = signalMin; j <= signalMax; j++) {
343 NOfSignalEntries += signalFit_DiffPt_ee->GetBinContent(j);
344 NOfBgEntries += fhBgDiffPtCuts->GetBinContent(j);
345 }
346
347 //Calculate Signal/Background
348 double SOverBg = 0.;
349 if (NOfBgEntries <= 0.) { SOverBg = 0; }
350 else {
351 SOverBg = NOfSignalEntries / NOfBgEntries;
352 }
353 string textSOverBg = "S/Bg = " + Cbm::NumberToString(SOverBg, 3) + " " + text;
354
355 DrawH1(list_of(fhBgDiffPtCuts)(fhSignalDiffPtCuts)(fhBgSignalDiffPtCuts),
356 list_of("Background")("Signal")("Signal and Background"), kLinear, kLog, true, 0.65, 0.8, 0.99, 0.95);
357 DrawTextOnPad(textSOverBg, 0.07, 0.88, 0.65, 0.95);
358 }
359}
360
@ kJpsiReco
@ kJpsiPtCut
@ kJpsiElId
@ kJpsiChi2Prim
ClassImp(CbmConverterManager)
void DrawTextOnPad(const string &text, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
void SetDefaultDrawStyle()
void DrawH1(TH1 *hist, HistScale logx, HistScale logy, const string &drawOpt, Int_t color, Int_t lineWidth, Int_t lineStyle, Int_t markerSize, Int_t markerStyle)
Helper functions for drawing 1D and 2D histograms and graphs.
@ kLinear
Definition CbmDrawHist.h:69
@ kLog
Definition CbmDrawHist.h:68
Histogram manager.
Abstract class for basic report elements (headers, tables, images etc.).
static const std::vector< std::string > fAnaStepsLatex
static const int fNofAnaSteps
static const std::vector< std::string > fAnaSteps
virtual void Create()
Inherited from CbmSimulationReport.
virtual ~CbmAnaJpsiSuperEventReport()
Destructor.
virtual void Draw()
Inherited from CbmSimulationReport.
Histogram manager.
void ReadFromFile(TFile *file)
Read histograms from file.
void ScaleByPattern(const std::string &pattern, Double_t scale)
Scale histograms which name matches specified pattern.
void RebinByPattern(const std::string &pattern, Int_t ngroup)
Rebin histograms which name matches specified pattern.
void Create1(const std::string &name, const std::string &title, Int_t nofBins, Double_t minBin, Double_t maxBin)
Helper function for creation of 1-dimensional histograms and profiles. Template argument is a real ob...
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
virtual std::string Title(int size, const std::string &title) const =0
Return string with title.
virtual std::string DocumentBegin() const =0
Return string with open tags for document.
virtual std::string DocumentEnd() const =0
Return string with close tags of the document.
std::ostream & Out() const
All text output goes to this stream.
Definition CbmReport.h:66
void SetOutputDir(const std::string &outputDir)
Definition CbmReport.h:71
void SetReportName(const std::string &name)
Definition CbmReport.h:69
void PrintCanvases() const
Print images created from canvases in the report.
const CbmReportElement * R() const
Accessor to CbmReportElement object. User has to write the report using available tags from CbmReport...
Definition CbmReport.h:61
void CreateReports()
Create all available report types.
Definition CbmReport.cxx:71
TCanvas * CreateCanvas(const char *name, const char *title, Int_t ww, Int_t wh)
Create canvas and put it to vector of TCanvases. Canvases created with this function will be automati...
Definition CbmReport.cxx:94
Base class for simulation reports.
vector< string > Split(const string &name, char delimiter)
Definition CbmUtils.cxx:67
std::string NumberToString(const T &value, int precision=1)
Definition CbmUtils.h:34