Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
NeutrinoFluxReweight::MakeReweight Class Reference

A class to make the reweight event by event. More...

#include <MakeReweight.h>

Public Member Functions

void SetOptions (std::string fileIn)
 
void calculateWeights (nu_g4numi *nu, const char *tgtcfg, const char *horncfg)
 
void calculateWeights (bsim::Dk2Nu *nu, bsim::DkMeta *meta)
 create an interaction chain from the new dk2nu(dkmeta) format More...
 
std::vector< double > GetTotalWeights ()
 total weights More...
 
int GetNumberOfUniversesUsed ()
 number of universes used in this run More...
 
std::vector< double > GetWeights (std::string nameReweighter)
 get the vector of the weights for a given reweighter More...
 
double GetCVWeight ()
 get the cv weights More...
 

Static Public Member Functions

static MakeReweightgetInstance ()
 
static void resetInstance ()
 

Public Attributes

std::vector< ReweightDriver * > vec_rws
 vector of Reweighter Drivers, one per universe More...
 
ReweightDrivercv_rw
 Reweighter Drivers for the central value. More...
 

Private Member Functions

 MakeReweight ()
 
 ~MakeReweight ()
 
void Initialize ()
 
void ParseOptions ()
 
void doTheJob (InteractionChainData *icd)
 

Private Attributes

std::vector< ParameterTablecvPars
 
std::vector< ParameterTableunivPars
 
int Nuniverses
 
std::string mippCorrOption
 
std::string fileOptions
 
std::vector< double > vec_wgts
 
std::map< std::string, std::vector< double > > map_rew_wgts
 
double cv_wgt
 

Static Private Attributes

static MakeReweightinstance = 0
 

Detailed Description

A class to make the reweight event by event.

Definition at line 32 of file MakeReweight.h.

Constructor & Destructor Documentation

NeutrinoFluxReweight::MakeReweight::MakeReweight ( )
private

Definition at line 9 of file MakeReweight.cpp.

9  {
10  }
NeutrinoFluxReweight::MakeReweight::~MakeReweight ( )
private

Definition at line 160 of file MakeReweight.cpp.

160  {
161 
162  }

Member Function Documentation

void NeutrinoFluxReweight::MakeReweight::calculateWeights ( nu_g4numi nu,
const char *  tgtcfg,
const char *  horncfg 
)

calculate the weights for this event using the old flux ntuple format (filled in nu_g4numi object), the tgtcfg (the target configuration, example: le010z) and the horncfg (horn configuration, example: 185i)

Definition at line 99 of file MakeReweight.cpp.

99  {
100  InteractionChainData inter_chain(nu,tgtcfg,horncfg);
101  doTheJob(&inter_chain);
102  }
void doTheJob(InteractionChainData *icd)
void NeutrinoFluxReweight::MakeReweight::calculateWeights ( bsim::Dk2Nu *  nu,
bsim::DkMeta *  meta 
)

create an interaction chain from the new dk2nu(dkmeta) format

Definition at line 104 of file MakeReweight.cpp.

104  {
105  InteractionChainData inter_chain(nu,meta);
106  doTheJob(&inter_chain);
107  }
void doTheJob(InteractionChainData *icd)
void NeutrinoFluxReweight::MakeReweight::doTheJob ( InteractionChainData icd)
private

Parse seeting options

Definition at line 109 of file MakeReweight.cpp.

109  {
110 
111  //universe calculation:
112  map_rew_wgts.clear();
113  for(int ii=0;ii<Nuniverses;ii++){
114  vec_wgts[ii] = vec_rws[ii]->calculateWeight(*icd);
115 
116  map_rew_wgts["MIPPNumiPionYields"].push_back(vec_rws[ii]->mipp_pion_wgt);
117  map_rew_wgts["MIPPNumiKaonYields"].push_back(vec_rws[ii]->mipp_kaon_wgt);
118 
119  map_rew_wgts["TargetAttenuation"].push_back(vec_rws[ii]->att_wgt);
120  map_rew_wgts["AbsorptionIC"].push_back(vec_rws[ii]->abs_ic_wgt);
121  map_rew_wgts["AbsorptionDPIP"].push_back(vec_rws[ii]->abs_dpip_wgt);
122  map_rew_wgts["AbsorptionDVOL"].push_back(vec_rws[ii]->abs_dvol_wgt);
123  map_rew_wgts["AbsorptionNucleon"].push_back(vec_rws[ii]->abs_nucleon_wgt);
124  map_rew_wgts["AbsorptionOther"].push_back(vec_rws[ii]->abs_other_wgt);
125  map_rew_wgts["TotalAbsorption"].push_back(vec_rws[ii]->tot_abs_wgt);
126 
127  map_rew_wgts["ThinTargetpCPion"].push_back(vec_rws[ii]->pC_pi_wgt);
128  map_rew_wgts["ThinTargetpCKaon"].push_back(vec_rws[ii]->pC_k_wgt);
129  map_rew_wgts["ThinTargetnCPion"].push_back(vec_rws[ii]->nC_pi_wgt);
130  map_rew_wgts["ThinTargetpCNucleon"].push_back(vec_rws[ii]->pC_nu_wgt);
131  map_rew_wgts["ThinTargetMesonIncident"].push_back(vec_rws[ii]->meson_inc_wgt);
132  map_rew_wgts["ThinTargetnucleonA"].push_back(vec_rws[ii]->nuA_wgt);
133  map_rew_wgts["Other"].push_back(vec_rws[ii]->other_wgt);
134 
135  }
136 
137  //cv calculation:
138  cv_wgt = cv_rw->calculateWeight(*icd);
139 
140  }
double calculateWeight(const InteractionChainData &icd)
std::vector< ReweightDriver * > vec_rws
vector of Reweighter Drivers, one per universe
Definition: MakeReweight.h:65
std::map< std::string, std::vector< double > > map_rew_wgts
Definition: MakeReweight.h:85
ReweightDriver * cv_rw
Reweighter Drivers for the central value.
Definition: MakeReweight.h:68
std::vector< double > vec_wgts
Definition: MakeReweight.h:84
double NeutrinoFluxReweight::MakeReweight::GetCVWeight ( )

get the cv weights

Definition at line 153 of file MakeReweight.cpp.

153  {
154  return cv_wgt;
155  }
MakeReweight * NeutrinoFluxReweight::MakeReweight::getInstance ( )
static

Definition at line 164 of file MakeReweight.cpp.

164  {
165  if (instance == 0) instance = new MakeReweight;
166  return instance;
167  }
static MakeReweight * instance
Definition: MakeReweight.h:88
int NeutrinoFluxReweight::MakeReweight::GetNumberOfUniversesUsed ( )

number of universes used in this run

Definition at line 157 of file MakeReweight.cpp.

157  {
158  return Nuniverses;
159  }
std::vector< double > NeutrinoFluxReweight::MakeReweight::GetTotalWeights ( )

total weights

Definition at line 95 of file MakeReweight.cpp.

95  {
96  return vec_wgts;
97  }
std::vector< double > vec_wgts
Definition: MakeReweight.h:84
std::vector< double > NeutrinoFluxReweight::MakeReweight::GetWeights ( std::string  nameReweighter)

get the vector of the weights for a given reweighter

Definition at line 142 of file MakeReweight.cpp.

142  {
143 
144  std::vector<double> tmp_vec;
145  std::map<std::string,std::vector<double> >::iterator it = map_rew_wgts.begin();
146  it = map_rew_wgts.find(nameReweighter);
147  if(it!=map_rew_wgts.end())tmp_vec = it->second;
148 
149  return tmp_vec;
150 
151  }
std::map< std::string, std::vector< double > > map_rew_wgts
Definition: MakeReweight.h:85
void NeutrinoFluxReweight::MakeReweight::Initialize ( void  )
private

Inititalize the job and configurethe ReweighterDrivier

Definition at line 28 of file MakeReweight.cpp.

28  {
29 
30  //Getting MIPP binning and the correlation parameters:
31  CentralValuesAndUncertainties* cvu = CentralValuesAndUncertainties::getInstance();;
32  MIPPNumiYieldsBins* myb = MIPPNumiYieldsBins::getInstance();
33  ThinTargetBins* thinbin = ThinTargetBins::getInstance();
34  MIPPNumiMC* mymc = MIPPNumiMC::getInstance();
35  const char* ppfxDir = getenv("PPFX_DIR");
36 
37  std::cout<<"Initializing correlation parameters"<<std::endl;
38  cvu->readFromXML(Form("%s/uncertainties/Parameters_%s.xml",ppfxDir,mippCorrOption.c_str()));
39 
40  std::cout<<"Initializing bin data conventions"<<std::endl;
41  myb->pip_data_from_xml(Form("%s/data/BINS/MIPPNumiData_PIP_Bins.xml",ppfxDir));
42  myb->pim_data_from_xml(Form("%s/data/BINS/MIPPNumiData_PIM_Bins.xml",ppfxDir));
43  myb->k_pi_data_from_xml(Form("%s/data/BINS/MIPPNumiData_K_PI_Bins.xml",ppfxDir));
44  thinbin->pC_pi_from_xml(Form("%s/data/BINS/ThinTarget_pC_pi_Bins.xml",ppfxDir));
45  thinbin->barton_pC_pi_from_xml(Form("%s/data/BINS/ThinTargetBarton_pC_pi_Bins.xml",ppfxDir));
46  thinbin->pC_k_from_xml(Form("%s/data/BINS/ThinTargetLowxF_pC_k_Bins.xml",ppfxDir));
47  thinbin->mipp_pC_k_pi_from_xml(Form("%s/data/BINS/ThinTarget_K_PI_Bins.xml",ppfxDir));
48  thinbin->meson_incident_from_xml(Form("%s/data/BINS/ThinTarget_MesonIncident.xml",ppfxDir));
49  thinbin->pC_p_from_xml(Form("%s/data/BINS/ThinTarget_pC_p_Bins.xml",ppfxDir));
50  thinbin->pC_n_from_xml(Form("%s/data/BINS/ThinTarget_pC_n_Bins.xml",ppfxDir));
51  thinbin->material_scaling_from_xml(Form("%s/data/BINS/ThinTarget_material_scaling_Bins.xml",ppfxDir));
52 
53  std::cout<<"Initializing MC values"<<std::endl;
54  mymc->pip_mc_from_xml(Form("%s/data/MIPP/MIPPNuMI_MC_PIP.xml",ppfxDir));
55  mymc->pim_mc_from_xml(Form("%s/data/MIPP/MIPPNuMI_MC_PIM.xml",ppfxDir));
56  mymc->kap_mc_from_xml(Form("%s/data/MIPP/MIPPNuMI_MC_KAP.xml",ppfxDir));
57  mymc->kam_mc_from_xml(Form("%s/data/MIPP/MIPPNuMI_MC_KAM.xml",ppfxDir));
58  mymc->k0l_mc_from_xml(Form("%s/data/MIPP/MIPPNuMI_MC_K0L.xml",ppfxDir));
59  mymc->k0s_mc_from_xml(Form("%s/data/MIPP/MIPPNuMI_MC_K0S.xml",ppfxDir));
60 
61  //Reweighter drivers:
62  vec_rws.reserve(Nuniverses);
63  std::cout<<"Initializing reweight drivers for "<<Nuniverses<<" universes"<<std::endl;
64 
65  const int base_universe=1000000;
66  // cvPars.reserve(Nuniverses+1);
67  univPars.reserve(Nuniverses+1);
68 
69  ParameterTable cvPars=cvu->getCVPars();
70 
71  std::cout<<"Loading parameters for universe: ";
72  for(int ii=0;ii<Nuniverses;ii++){
73  std::cout << ii << " " << std::flush;
74  // cvPars.push_back(cvu->getCVPars());
75  univPars.push_back(cvu->calculateParsForUniverse(ii+base_universe));
76  vec_rws.push_back(new ReweightDriver(ii,cvPars,univPars[ii],fileOptions));
77  vec_wgts.push_back(1.0);
78  }
79  std::cout << std::endl;
80 
81  //Central Value driver:
82  //by convention, we use universe -1 to hold the cv. It is in agreement with CentralValueAndUncertainties
83  const int cv_id = -1;
84  std::cout<<"Loading parameters for cv"<<std::endl;
85  // cvPars.push_back(cvu->getCVPars());
86  univPars.push_back(cvu->calculateParsForUniverse(cv_id));
87  cv_rw = new ReweightDriver(cv_id,cvPars,univPars[Nuniverses],fileOptions);
88 
89  cv_wgt = 1.0;
90 
91  std::cout<<"Done configuring universes"<<std::endl;
92 
93  }
static MIPPNumiMC * getInstance()
Definition: MIPPNumiMC.cpp:295
std::vector< ParameterTable > cvPars
Definition: MakeReweight.h:80
std::string getenv(std::string const &name)
Definition: getenv.cc:15
QTextStream & flush(QTextStream &s)
static ThinTargetBins * getInstance()
static MIPPNumiYieldsBins * getInstance()
std::vector< ReweightDriver * > vec_rws
vector of Reweighter Drivers, one per universe
Definition: MakeReweight.h:65
std::vector< ParameterTable > univPars
Definition: MakeReweight.h:80
ReweightDriver * cv_rw
Reweighter Drivers for the central value.
Definition: MakeReweight.h:68
std::vector< double > vec_wgts
Definition: MakeReweight.h:84
QTextStream & endl(QTextStream &s)
void NeutrinoFluxReweight::MakeReweight::ParseOptions ( )
private

Parse seeting options

Definition at line 17 of file MakeReweight.cpp.

17  {
18  //Parsing the file input:
19  using boost::property_tree::ptree;
20  ptree top;
21  read_xml(fileOptions.c_str(),top,2); // option 2 removes comment strings
22  ptree& options = top.get_child("inputs.Settings");
23 
24  mippCorrOption = options.get<std::string>("MIPPCorrOption");
25  Nuniverses = options.get<int>("NumberOfUniverses");
26 
27  }
std::string string
Definition: nybbler.cc:12
void NeutrinoFluxReweight::MakeReweight::resetInstance ( )
static

Definition at line 169 of file MakeReweight.cpp.

170  {
171  delete instance;
172  instance = 0;
173  }
static MakeReweight * instance
Definition: MakeReweight.h:88
void NeutrinoFluxReweight::MakeReweight::SetOptions ( std::string  fileIn)

Definition at line 11 of file MakeReweight.cpp.

Member Data Documentation

ReweightDriver* NeutrinoFluxReweight::MakeReweight::cv_rw

Reweighter Drivers for the central value.

Definition at line 68 of file MakeReweight.h.

double NeutrinoFluxReweight::MakeReweight::cv_wgt
private

Definition at line 86 of file MakeReweight.h.

std::vector<ParameterTable> NeutrinoFluxReweight::MakeReweight::cvPars
private

Definition at line 80 of file MakeReweight.h.

std::string NeutrinoFluxReweight::MakeReweight::fileOptions
private

Definition at line 83 of file MakeReweight.h.

MakeReweight * NeutrinoFluxReweight::MakeReweight::instance = 0
staticprivate

Definition at line 88 of file MakeReweight.h.

std::map<std::string,std::vector<double> > NeutrinoFluxReweight::MakeReweight::map_rew_wgts
private

Definition at line 85 of file MakeReweight.h.

std::string NeutrinoFluxReweight::MakeReweight::mippCorrOption
private

Definition at line 82 of file MakeReweight.h.

int NeutrinoFluxReweight::MakeReweight::Nuniverses
private

Definition at line 81 of file MakeReweight.h.

std::vector<ParameterTable> NeutrinoFluxReweight::MakeReweight::univPars
private

Definition at line 80 of file MakeReweight.h.

std::vector<ReweightDriver*> NeutrinoFluxReweight::MakeReweight::vec_rws

vector of Reweighter Drivers, one per universe

Definition at line 65 of file MakeReweight.h.

std::vector<double> NeutrinoFluxReweight::MakeReweight::vec_wgts
private

Definition at line 84 of file MakeReweight.h.


The documentation for this class was generated from the following files: