skzpReweight.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file skzpReweight.h
3 ///
4 /// \version $Id: skzpReweight.h,v 1.2 2011-01-29 19:44:13 p-nusoftart Exp $
5 /// \author ???
6 ////////////////////////////////////////////////////////////////////////
7 #ifndef NBW_SKZPREWEIGHT_H
8 #define NBW_SKZPREWEIGHT_H
9 
10 #include <string>
11 #include <map>
12 #include <vector>
14 #include "nutools/NuBeamWeights/Conventions.h"
15 
16 class TFile;
17 class TH2F;
18 class TH2D;
19 
20 ///reweighting utility for NuMI beam
21 namespace nbw{
22 
23  class skzpReweight{
24 
25  public:
26 
27  skzpReweight(std::string fpath="/nova/data/flux/SKZPdata/fluka05ptxf.root", std::string bpath="/nova/data/flux/SKZPdata/IPNDhists.root", int flag=2);
28  //Bpath="/nova/data/flux/SKZPdata/beamsys_Dogwood1_Daikon07_v2.root ", flag=1 is another working configuration.
29  ~skzpReweight();
30  void SetParams(std::vector<double> fpar, std::vector<double> bpar) {
31  fFPar=fpar; FlukConfig();
32  fBPar=bpar; BeamConfig();
33  return; };
34  void SetFlukParams(std::vector<double> fpar) {
35  fFPar=fpar; FlukConfig();
36  return; };
37  void SetBeamParams(std::vector<double> bpar) {
38  fBPar=bpar; BeamConfig();
39  return; };
40 
41  double GetWeight(const simb::MCFlux *mcf, double Enu, int det, int beam){
42  double pt = sqrt(mcf->ftpx*mcf->ftpx + mcf->ftpy*mcf->ftpy);
43  return GetFlukWeight(mcf->ftptype,pt,mcf->ftpz)*GetBeamWeight(mcf->fntype,Enu,beam,det); };
44 
45  double GetFlukWeight(const simb::MCFlux *mcf){
46  double pt = sqrt(mcf->ftpx*mcf->ftpx + mcf->ftpy*mcf->ftpy);
47  return GetFlukWeight(mcf->ftptype,pt,mcf->ftpz); };
48 
49  double GetFlukWeight(int ptype, double pT, double pz);
50 
51  double GetBeamWeight(int ntype, double Enu, int det=1, int beam=2);
52 
53  private:
54  //methods for Fluk
55  void FlukConfig();
58  //members for Fluk
59  std::vector<double> fFPar;
61  std::vector<Conventions::ParticleType_t> fPlist;
62  std::map<Conventions::ParticleType_t, TH2F* > fPTPZ;
63  std::map<Conventions::ParticleType_t, TH2F* > fWeightedPTPZ;
64  std::map<Conventions::ParticleType_t, TH2F* > fWeightHist;
65  std::map<Conventions::ParticleType_t, double > fMeanPT;
66  std::map<Conventions::ParticleType_t, double > fN;
67  std::map<Conventions::ParticleType_t, double > fNWeighted;
68  std::map<Conventions::ParticleType_t, double > fWeightedMeanPT;
69  std::map<Conventions::ParticleType_t, int > fNBinsY,fNBinsX;
70 
71  //methods for Beam
72  void BeamConfig();
73  //Each flag (path location) is a different formatting to histogram names
74  std::string GetHname(int inu, int eff, int beam, int det);
75  void FillVector(TH1D* hist, int ntype, int eff, int beam, int det);
76  void FillVector(TH1F* hist, int ntype, int eff, int beam, int det);
80  //mapkey structure for Beam
81  //Each combination that makes up a mapkey has a different weight histogram.
82  struct mapkey
83  {
84  int NuDex;
85  int DetDex;
86  int BeamDex;
87  int EffDex;
88  };
89 
90  struct LessThan
91  {
92  bool operator()(const mapkey lhs,const mapkey rhs) const
93  {
94  if (lhs.NuDex < rhs.NuDex)
95  return true;
96  else if (lhs.NuDex == rhs.NuDex)
97  {
98  if(lhs.DetDex < rhs.DetDex)
99  return true;
100  else if (lhs.DetDex == rhs.DetDex)
101  {
102  if(lhs.BeamDex < rhs.BeamDex)
103  return true;
104  else if (lhs.BeamDex == rhs.BeamDex)
105  {
106  if(lhs.EffDex < rhs.EffDex)
107  return true; //(else return false)
108  }
109  }
110  }
111  return false;
112  }
113  };
114  //members for Beam
115  std::vector<double> fBPar;
117  TFile* fBeamSysFile;
118  //key for WeightMap_t represents the upper edge of the energy of each bin, the mapped value is the corresponding weight.
119  typedef std::map<double, double> WeightMap_t;
120  //see struct mapkey above
121  std::map<mapkey, WeightMap_t, LessThan > fBeamSysMap;
122  //Each flag (path location) is a different formatting to histogram names
123  //flag = 1: formatting based on "beamsys_Dogwood1_Daikon07_v2.root"
124  //flag = 2: formatting based on "IPNDhists.root" - histograms from ipndfluxerr and histograms names from enum names located in Conventions.
125  //See GetHname and *ToString methods for details.
126  int fBflag;
127  };
128 }
129 #endif //NBW_SKZPREWEIGHT_H
std::map< Conventions::ParticleType_t, int > fNBinsY
Definition: skzpReweight.h:69
std::vector< double > fFPar
Definition: skzpReweight.h:59
std::map< Conventions::ParticleType_t, double > fN
Definition: skzpReweight.h:66
std::map< Conventions::ParticleType_t, int > fNBinsX
Definition: skzpReweight.h:69
double ftpx
Definition: MCFlux.h:79
enum nbw::Conventions::EDetType DetType_t
std::string string
Definition: nybbler.cc:12
int ftptype
Definition: MCFlux.h:82
std::vector< Conventions::ParticleType_t > fPlist
Definition: skzpReweight.h:61
std::map< Conventions::ParticleType_t, double > fNWeighted
Definition: skzpReweight.h:67
bool operator()(const mapkey lhs, const mapkey rhs) const
Definition: skzpReweight.h:92
enum nbw::Conventions::EParticleType ParticleType_t
std::string GetHname(int inu, int eff, int beam, int det)
void SetParams(std::vector< double > fpar, std::vector< double > bpar)
Definition: skzpReweight.h:30
object containing MC flux information
std::string BeamTypeToString(Conventions::BeamType_t btype)
double GetWeight(const simb::MCFlux *mcf, double Enu, int det, int beam)
Definition: skzpReweight.h:41
double GetBeamWeight(int ntype, double Enu, int det=1, int beam=2)
std::string fBpath
Definition: skzpReweight.h:116
std::map< mapkey, WeightMap_t, LessThan > fBeamSysMap
Definition: skzpReweight.h:121
enum nbw::Conventions::EBeamType BeamType_t
std::string fFpath
Definition: skzpReweight.h:60
std::map< Conventions::ParticleType_t, TH2F * > fWeightedPTPZ
Definition: skzpReweight.h:63
double ftpz
Definition: MCFlux.h:81
std::map< Conventions::ParticleType_t, TH2F * > fPTPZ
Definition: skzpReweight.h:62
std::map< Conventions::ParticleType_t, TH2F * > fWeightHist
Definition: skzpReweight.h:64
skzpReweight(std::string fpath="/nova/data/flux/SKZPdata/fluka05ptxf.root", std::string bpath="/nova/data/flux/SKZPdata/IPNDhists.root", int flag=2)
void FillVector(TH1D *hist, int ntype, int eff, int beam, int det)
enum nbw::Conventions::EBeamSys BeamSys_t
std::map< Conventions::ParticleType_t, double > fWeightedMeanPT
Definition: skzpReweight.h:68
std::map< double, double > WeightMap_t
Definition: skzpReweight.h:119
std::string PartEnumToString(Conventions::ParticleType_t ptype)
int fntype
Definition: MCFlux.h:51
double GetFlukWeight(const simb::MCFlux *mcf)
Definition: skzpReweight.h:45
std::string BeamSysToString(Conventions::BeamSys_t bstype)
reweighting utility for NuMI beam
Definition: Conventions.h:10
std::map< Conventions::ParticleType_t, double > fMeanPT
Definition: skzpReweight.h:65
std::string DetTypeToString(Conventions::DetType_t dtype)
std::vector< double > fBPar
Definition: skzpReweight.h:115
void SetBeamParams(std::vector< double > bpar)
Definition: skzpReweight.h:37
double ftpy
Definition: MCFlux.h:80
Conventions::ParticleType_t GeantToEnum(int ptype)
void SetFlukParams(std::vector< double > fpar)
Definition: skzpReweight.h:34