CbmRoot
Loading...
Searching...
No Matches
CbmKresGammaCorrection.cxx
Go to the documentation of this file.
1/* Copyright (C) 2017-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Ievgenii Kres, Florian Uhlig [committer] */
4
20
22
23#include <Logger.h>
24
25#include "TFile.h"
26#include "TH2D.h"
27#include "TMath.h"
28#include "TSystem.h"
29
30#include <iostream>
31
32
33using namespace std;
34
42
44
45void CbmKresGammaCorrection::Init(std::vector<std::vector<double>>& vect_all,
46 std::vector<std::vector<double>>& vect_two,
47 std::vector<std::vector<double>>& vect_onetwo, double OA, double IM)
48{
50
51 string Correction_path = string(gSystem->Getenv("VMCWORKDIR"))
52 + Form("/analysis/conversion2/Correction_pi0_g_OA%i_IM%i_num2.root", (int) OA,
53 (int) IM);
54 cout << "file is " << Correction_path << endl;
55
57 TFile* oldFile = gFile;
58 TDirectory* oldDir = gDirectory;
59
60 TFile* fcorrection = new TFile(
61 Correction_path.c_str()); // file with almost ?? Mio photons, homogeneously distributed over interested region
62 // rapidity graphs
63 LOG_IF(fatal, !fcorrection) << "Could not open file " << Correction_path.c_str();
64 TH2D* mc = fcorrection->Get<TH2D>("conversionKres/General/MC_info/MC_Direct_photons_Pt_vs_rap_est");
65 LOG_IF(fatal, !mc) << "Could not read histogram MC_Direct_photons_Pt_vs_rap_est from file "
66 << Correction_path.c_str();
67
68 TH2D* all = fcorrection->Get<TH2D>("conversionKres/direct photons/Both/all/Ph_pt_vs_rap_est_all_Both");
69 LOG_IF(fatal, !all) << "Could not read histogram Ph_pt_vs_rap_est_all_Both from file " << Correction_path.c_str();
70
71 TH2D* two = fcorrection->Get<TH2D>("conversionKres/direct photons/Both/two/Ph_pt_vs_rap_est_two_Both");
72 LOG_IF(fatal, !two) << "Could not read histogram Ph_pt_vs_rap_est_two_Both from file " << Correction_path.c_str();
73
74 TH2D* onetwo = fcorrection->Get<TH2D>("conversionKres/direct photons/Both/onetwo/Ph_pt_vs_rap_est_onetwo_Both");
75 LOG_IF(fatal, !onetwo) << "Could not read histogram Ph_pt_vs_rap_est_onetwo_Both from file "
76 << Correction_path.c_str();
77
78 std::vector<double> rapidity_column;
79
80 for (int ix = 1; ix <= 10; ix++) {
81 rapidity_column.clear();
82 for (int iy = 1; iy <= 30; iy++) {
83 double cont_reco = all->GetBinContent(ix, iy);
84 double mc_cont = mc->GetBinContent(ix, iy);
85 if (mc_cont == 0) mc_cont = 1;
86 double eff = cont_reco / mc_cont;
87 rapidity_column.push_back(eff);
88 double content = 0;
89 if (eff != 0) content = 1 / eff;
90 Correction_factros_all->SetBinContent(ix, iy, content);
91 // cout << "ix = " << ix << "; iy = " << iy << "; content = " << eff << endl;
92 // cout << "all: rap_bin = " << ix-1 << "; pt_bin = " << iy-1 << "; cont_reco = " << cont_reco << "; mc_cont = " << mc_cont << "; eff = " << eff << endl;
93 }
94 vect_all.push_back(rapidity_column);
95 }
96
97 for (int ix = 1; ix <= 10; ix++) {
98 rapidity_column.clear();
99 for (int iy = 1; iy <= 30; iy++) {
100 double cont_reco = two->GetBinContent(ix, iy);
101 double mc_cont = mc->GetBinContent(ix, iy);
102 if (mc_cont == 0) mc_cont = 1;
103 double eff = cont_reco / mc_cont;
104 rapidity_column.push_back(eff);
105 double content = 0;
106 if (eff != 0) content = 1 / eff;
107 Correction_factros_two->SetBinContent(ix, iy, content);
108 // cout << "two: rap_bin = " << ix-1 << "; pt_bin = " << iy-1 << "; cont_reco = " << cont_reco << "; mc_cont = " << mc_cont << "; eff = " << eff << endl;
109 }
110 vect_two.push_back(rapidity_column);
111 }
112
113 for (int ix = 1; ix <= 10; ix++) {
114 rapidity_column.clear();
115 for (int iy = 1; iy <= 30; iy++) {
116 double cont_reco = onetwo->GetBinContent(ix, iy);
117 double mc_cont = mc->GetBinContent(ix, iy);
118 if (mc_cont == 0) mc_cont = 1;
119 double eff = cont_reco / mc_cont;
120 rapidity_column.push_back(eff);
121 double content = 0;
122 if (eff != 0) content = 1 / eff;
123 Correction_factros_onetwo->SetBinContent(ix, iy, content);
124 // cout << "onetwo: rap_bin = " << ix-1 << "; pt_bin = " << iy-1 << "; cont_reco = " << cont_reco << "; mc_cont = " << mc_cont << "; eff = " << eff << endl;
125 }
126 vect_onetwo.push_back(rapidity_column);
127 }
128
130 gFile = oldFile;
131 gDirectory = oldDir;
132}
133
135{
136 gDirectory->mkdir("Correction factors");
137 gDirectory->cd("Correction factors");
138 for (UInt_t i = 0; i < fHistoList_factors.size(); i++) {
139 fHistoList_factors[i]->Write();
140 }
141 gDirectory->cd("..");
142}
143
145{
147 new TH2D("Correction_factros_all", "Correction_factros_all; rapidity y; p_{t} in GeV/c ", 10, 0., 4., 40, 0., 4.);
150 new TH2D("Correction_factros_two", "Correction_factros_two; rapidity y; p_{t} in GeV/c ", 10, 0., 4., 40, 0., 4.);
152 Correction_factros_onetwo = new TH2D(
153 "Correction_factros_onetwo", "Correction_factros_onetwo; rapidity y; p_{t} in GeV/c ", 10, 0., 4., 40, 0., 4.);
155}
void Init(std::vector< std::vector< double > > &vect_all, std::vector< std::vector< double > > &vect_two, std::vector< std::vector< double > > &vect_onetwo, double OA, double IM)
Hash for CbmL1LinkKey.