CbmRoot
CbmKresGammaCorrection.cxx
Go to the documentation of this file.
1 
17 #include "CbmKresGammaCorrection.h"
18 #include "TFile.h"
19 #include "TH2D.h"
20 #include "TMath.h"
21 #include "TSystem.h"
22 
23 #include <iostream>
24 
25 
26 using namespace std;
27 
29  : fHistoList_factors()
30  , Correction_factros_all(nullptr)
31  , Correction_factros_two(nullptr)
32  , Correction_factros_onetwo(nullptr) {}
33 
35 
36 void CbmKresGammaCorrection::Init(std::vector<std::vector<double>>& vect_all,
37  std::vector<std::vector<double>>& vect_two,
38  std::vector<std::vector<double>>& vect_onetwo,
39  double OA,
40  double IM) {
42 
43  string Correction_path =
44  string(gSystem->Getenv("VMCWORKDIR"))
45  + Form("/analysis/conversion2/Correction_pi0_g_OA%i_IM%i_num2.root",
46  (int) OA,
47  (int) IM);
48  cout << "file is " << Correction_path << endl;
49  TFile* fcorrection = new TFile(
50  Correction_path
51  .c_str()); // file with almost ?? Mio photons, homogeneously distributed over interested region
52  // rapidity graphs
53  TH2D* mc = (TH2D*) fcorrection->Get(
54  "conversionKres/General/MC_info/MC_Direct_photons_Pt_vs_rap_est");
55  TH2D* all = (TH2D*) fcorrection->Get(
56  "conversionKres/direct photons/Both/all/Ph_pt_vs_rap_est_all_Both");
57  TH2D* two = (TH2D*) fcorrection->Get(
58  "conversionKres/direct photons/Both/two/Ph_pt_vs_rap_est_two_Both");
59  TH2D* onetwo = (TH2D*) fcorrection->Get(
60  "conversionKres/direct photons/Both/onetwo/Ph_pt_vs_rap_est_onetwo_Both");
61 
62  std::vector<double> rapidity_column;
63 
64  for (int ix = 1; ix <= 10; ix++) {
65  rapidity_column.clear();
66  for (int iy = 1; iy <= 30; iy++) {
67  double cont_reco = all->GetBinContent(ix, iy);
68  double mc_cont = mc->GetBinContent(ix, iy);
69  if (mc_cont == 0) mc_cont = 1;
70  double eff = cont_reco / mc_cont;
71  rapidity_column.push_back(eff);
72  double content = 0;
73  if (eff != 0) content = 1 / eff;
74  Correction_factros_all->SetBinContent(ix, iy, content);
75  // cout << "ix = " << ix << "; iy = " << iy << "; content = " << eff << endl;
76  // cout << "all: rap_bin = " << ix-1 << "; pt_bin = " << iy-1 << "; cont_reco = " << cont_reco << "; mc_cont = " << mc_cont << "; eff = " << eff << endl;
77  }
78  vect_all.push_back(rapidity_column);
79  }
80 
81  for (int ix = 1; ix <= 10; ix++) {
82  rapidity_column.clear();
83  for (int iy = 1; iy <= 30; iy++) {
84  double cont_reco = two->GetBinContent(ix, iy);
85  double mc_cont = mc->GetBinContent(ix, iy);
86  if (mc_cont == 0) mc_cont = 1;
87  double eff = cont_reco / mc_cont;
88  rapidity_column.push_back(eff);
89  double content = 0;
90  if (eff != 0) content = 1 / eff;
91  Correction_factros_two->SetBinContent(ix, iy, content);
92  // cout << "two: rap_bin = " << ix-1 << "; pt_bin = " << iy-1 << "; cont_reco = " << cont_reco << "; mc_cont = " << mc_cont << "; eff = " << eff << endl;
93  }
94  vect_two.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 = onetwo->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_onetwo->SetBinContent(ix, iy, content);
108  // cout << "onetwo: rap_bin = " << ix-1 << "; pt_bin = " << iy-1 << "; cont_reco = " << cont_reco << "; mc_cont = " << mc_cont << "; eff = " << eff << endl;
109  }
110  vect_onetwo.push_back(rapidity_column);
111  }
112 }
113 
115  gDirectory->mkdir("Correction factors");
116  gDirectory->cd("Correction factors");
117  for (UInt_t i = 0; i < fHistoList_factors.size(); i++) {
118  fHistoList_factors[i]->Write();
119  }
120  gDirectory->cd("..");
121 }
122 
125  new TH2D("Correction_factros_all",
126  "Correction_factros_all; rapidity y; p_{t} in GeV/c ",
127  10,
128  0.,
129  4.,
130  40,
131  0.,
132  4.);
135  new TH2D("Correction_factros_two",
136  "Correction_factros_two; rapidity y; p_{t} in GeV/c ",
137  10,
138  0.,
139  4.,
140  40,
141  0.,
142  4.);
145  new TH2D("Correction_factros_onetwo",
146  "Correction_factros_onetwo; rapidity y; p_{t} in GeV/c ",
147  10,
148  0.,
149  4.,
150  40,
151  0.,
152  4.);
154 }
CbmKresGammaCorrection::~CbmKresGammaCorrection
virtual ~CbmKresGammaCorrection()
Definition: CbmKresGammaCorrection.cxx:34
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmKresGammaCorrection::Correction_factros_onetwo
TH2D * Correction_factros_onetwo
Definition: CbmKresGammaCorrection.h:31
CbmKresGammaCorrection::fHistoList_factors
vector< TH1 * > fHistoList_factors
Definition: CbmKresGammaCorrection.h:28
CbmKresGammaCorrection::Correction_factros_all
TH2D * Correction_factros_all
Definition: CbmKresGammaCorrection.h:29
CbmKresGammaCorrection::InitHistograms
void InitHistograms()
Definition: CbmKresGammaCorrection.cxx:123
CbmKresGammaCorrection::Init
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)
Definition: CbmKresGammaCorrection.cxx:36
CbmKresGammaCorrection.h
CbmKresGammaCorrection::Finish
void Finish()
Definition: CbmKresGammaCorrection.cxx:114
CbmKresGammaCorrection::CbmKresGammaCorrection
CbmKresGammaCorrection()
Definition: CbmKresGammaCorrection.cxx:28
CbmKresGammaCorrection::Correction_factros_two
TH2D * Correction_factros_two
Definition: CbmKresGammaCorrection.h:30