AttenuationMC.cpp
Go to the documentation of this file.
1 #include <cstdlib>
2 
3 #include "AttenuationMC.h"
4 
5 namespace NeutrinoFluxReweight{
6 
7  AttenuationMC* AttenuationMC::instance = 0;
8 
10  const char* ppfxDir = getenv("PPFX_DIR");
11  char dirData[400];
12  sprintf(dirData,"%s/data",ppfxDir);
13 
14  AttenuationMC::fInelXS_MC = new TFile(Form("%s/MC/InelXS_geant4.root",dirData),"read");
15 
16  AttenuationMC::fzpos_tgt_MC_le = new TFile(Form("%s/MIPP/tarpos_yield_le.root",dirData),"read");
17  AttenuationMC::fzpos_tgt_MC_me = new TFile(Form("%s/MIPP/tarpos_yield_me.root",dirData),"read");
18 
19  //Loading the geant4 inelastic cross section for pion on Aluminum
20  AttenuationMC::hXS_piAl = (TH1D*)AttenuationMC::fInelXS_MC->Get("pip/hpip_Al");
21  AttenuationMC::hXS_prtC = (TH1D*)AttenuationMC::fInelXS_MC->Get("prt/hprt_C");
22  AttenuationMC::hXS_piC = (TH1D*)AttenuationMC::fInelXS_MC->Get("pip/hpip_C");
23  AttenuationMC::hXS_kapC = (TH1D*)AttenuationMC::fInelXS_MC->Get("kap/hkap_C");
24  AttenuationMC::hXS_kamC = (TH1D*)AttenuationMC::fInelXS_MC->Get("kam/hkam_C");
25 
26  //Loading z postition histograms from MC g4NuMI:
27  //These are yields per z position per MIPP particle per MIPP bin.
28  //per 2.5E8 POT
29  //For pip: 124 bins, for pim: 119
30  char namehist[100];
31  for(int ibin=0;ibin<124;ibin++){
32  sprintf(namehist,"pip/htar_ydz_pip_bin%d",ibin);
33  AttenuationMC::hzpostgt_pip_le.push_back((TH1D*)AttenuationMC::fzpos_tgt_MC_le->Get(namehist));
34  AttenuationMC::hzpostgt_pip_me.push_back((TH1D*)AttenuationMC::fzpos_tgt_MC_me->Get(namehist));
35  }
36  for(int ibin=0;ibin<119;ibin++){
37  sprintf(namehist,"pim/htar_ydz_pim_bin%d",ibin);
38  AttenuationMC::hzpostgt_pim_le.push_back((TH1D*)AttenuationMC::fzpos_tgt_MC_le->Get(namehist));
39  AttenuationMC::hzpostgt_pim_me.push_back((TH1D*)AttenuationMC::fzpos_tgt_MC_me->Get(namehist));
40  }
41  //for kap and kam, we are going to get just thoese what we need (p_{Z} > 20 GeV/c)
42  //that means, for kap and kam do not consider the first 78 hist and for kam
43  for(int ibin=78;ibin<124;ibin++){
44  sprintf(namehist,"kap/htar_ydz_kap_bin%d",ibin);
45  AttenuationMC::hzpostgt_kap_le.push_back((TH1D*)AttenuationMC::fzpos_tgt_MC_le->Get(namehist));
46  AttenuationMC::hzpostgt_kap_me.push_back((TH1D*)AttenuationMC::fzpos_tgt_MC_me->Get(namehist));
47  sprintf(namehist,"kam/htar_ydz_kam_bin%d",ibin);
48  AttenuationMC::hzpostgt_kam_le.push_back((TH1D*)AttenuationMC::fzpos_tgt_MC_le->Get(namehist));
49  AttenuationMC::hzpostgt_kam_me.push_back((TH1D*)AttenuationMC::fzpos_tgt_MC_me->Get(namehist));
50  }
51 
52  }
53 
55  }
56 
58  if (instance == 0) instance = new AttenuationMC;
59  return instance;
60  }
61 
62 }
std::vector< TH1D * > hzpostgt_kam_le
Definition: AttenuationMC.h:29
std::vector< TH1D * > hzpostgt_pip_le
Definition: AttenuationMC.h:26
static AttenuationMC * instance
Definition: AttenuationMC.h:32
std::vector< TH1D * > hzpostgt_kam_me
Definition: AttenuationMC.h:29
std::vector< TH1D * > hzpostgt_pim_me
Definition: AttenuationMC.h:27
std::vector< TH1D * > hzpostgt_pip_me
Definition: AttenuationMC.h:26
std::vector< TH1D * > hzpostgt_kap_me
Definition: AttenuationMC.h:28
std::string getenv(std::string const &name)
Definition: getenv.cc:15
std::vector< TH1D * > hzpostgt_kap_le
Definition: AttenuationMC.h:28
static AttenuationMC * getInstance()
std::vector< TH1D * > hzpostgt_pim_le
Definition: AttenuationMC.h:27