ReweightDriver.cpp
Go to the documentation of this file.
1 #include "ReweightDriver.h"
2 #include <iostream>
3 
4 #include <boost/property_tree/ptree.hpp>
5 #include <boost/property_tree/xml_parser.hpp>
6 
7 namespace NeutrinoFluxReweight{
8 
9  ReweightDriver::ReweightDriver(int iuniv, const ParameterTable& cv_pars, const ParameterTable& univ_pars, std::string fileIn)
10  : iUniv(iuniv), cvPars(cv_pars), univPars(univ_pars), fileOptions(fileIn)
11  {
12  ParseOptions();
13  Configure();
14 
15  }
16 
18 
19  //Creating the vector of reweighters:
20 
21  if(doMIPPNumi){
24  }
25 
32 
40 
41  }
42 
44  //Parsing the file input:
45  using boost::property_tree::ptree;
46  ptree top;
47  std::string val = "";
48  read_xml(fileOptions.c_str(),top,2); // option 2 removes comment strings
49  ptree& options = top.get_child("inputs.Settings");
50 
51  val = options.get<std::string>("Reweighters");
52  if(val=="MIPPNuMIOn")doMIPPNumi = true;
53  else doMIPPNumi = false;
54 
55  }
57 
58  double tot_wgt = 1.0;
59 
60  //Boolean flags:
61  const int nnodes=icd.interaction_chain.size();
62  std::vector<bool> interaction_nodes(nnodes,false);
63  std::vector<bool> attenuation_nodes(nnodes,false);
64  std::vector<bool> absorption_nodes(nnodes,false);
65 
66  /// ----- PROCESS INTERACTION NODES ----- ///
67 
68  //MIPP NuMI Pions:
69  bool has_mipp = false;
70  mipp_pion_wgt = 1.0;
71  if(doMIPPNumi){
72  interaction_nodes = MIPP_NUMI_PION_Universe->canReweight(icd);
73  for(size_t ii=0;ii<interaction_nodes.size();ii++){
74  if(interaction_nodes[ii]==true){
75  has_mipp = true;
77  break;
78  }
79  }
80  tot_wgt *= mipp_pion_wgt;
81  }
82 
83  //MIPP NuMI Kaons:
84  mipp_kaon_wgt = 1.0;
85  if(!has_mipp && doMIPPNumi){
86  interaction_nodes = MIPP_NUMI_KAON_Universe->canReweight(icd);
87 
88  for(size_t ii=0;ii<interaction_nodes.size();ii++){
89  if(interaction_nodes[ii]==true){
90  has_mipp = true;
92  break;
93  }
94  }
95  tot_wgt *= mipp_kaon_wgt;
96  }
97 
98  //Thin Target pC->piX:
99  pC_pi_wgt = 1.0;
100  for(int ii=(interaction_nodes.size()-1);ii>=0;ii--){
101  if(interaction_nodes[ii]==false){
103  if(is_rew){
105  pC_pi_wgt *= rewval;
106  interaction_nodes[ii]=true;
107  }
108  }
109  }
110  tot_wgt *= pC_pi_wgt;
111 
112  //Thin Target pC->KX:
113  pC_k_wgt = 1.0;
114  for(int ii=(interaction_nodes.size()-1);ii>=0;ii--){
115  if(interaction_nodes[ii]==false){
117  if(is_rew){
119  pC_k_wgt *= rewval;
120  interaction_nodes[ii]=true;
121  }
122  }
123  }
124  tot_wgt *= pC_k_wgt;
125 
126  //Thin Target nC->piX:
127  nC_pi_wgt = 1.0;
128  for(int ii=(interaction_nodes.size()-1);ii>=0;ii--){
129  if(interaction_nodes[ii]==false){
131  if(is_rew){
133  nC_pi_wgt *= rewval;
134  interaction_nodes[ii]=true;
135  }
136  }
137  }
138  tot_wgt *= nC_pi_wgt;
139 
140  //Thin Target pC->nucleonX:
141  pC_nu_wgt = 1.0;
142  for(int ii=(interaction_nodes.size()-1);ii>=0;ii--){
143  if(interaction_nodes[ii]==false){
145  if(is_rew){
147  pC_nu_wgt *= rewval;
148  interaction_nodes[ii]=true;
149  }
150  }
151  }
152  tot_wgt *= pC_nu_wgt;
153 
154  //Thin Target Meson Incident:
155  meson_inc_wgt = 1.0;
156  for(int ii=(interaction_nodes.size()-1);ii>=0;ii--){
157  if(interaction_nodes[ii]==false){
159  if(is_rew){
161  meson_inc_wgt *= rewval;
162  interaction_nodes[ii]=true;
163  }
164  }
165  }
166  tot_wgt *= meson_inc_wgt;
167 
168  //Thin Target Nucleon Incident not hanldle NA49 or Barton:
169  nuA_wgt = 1.0;
170  for(int ii=(interaction_nodes.size()-1);ii>=0;ii--){
171  if(interaction_nodes[ii]==false){
173  if(is_rew){
175  nuA_wgt *= rewval;
176  interaction_nodes[ii]=true;
177  }
178  }
179  }
180  tot_wgt *= nuA_wgt;
181 
182  //Any other interaction not handled yet:
183  other_wgt = 1.0;
184  for(int ii=(interaction_nodes.size()-1);ii>=0;ii--){
185  if(interaction_nodes[ii]==false){
186  bool is_rew = OTHER_Universe->canReweight((icd.interaction_chain)[ii]);
187  if(is_rew){
188  double rewval = OTHER_Universe->calculateWeight((icd.interaction_chain)[ii]);
189  other_wgt *= rewval;
190  interaction_nodes[ii]=true;
191  }
192  }
193  }
194  tot_wgt *= other_wgt;
195 
196  //Target attenuation correction:
197  att_wgt = 1.0;
198  attenuation_nodes = TARG_ATT_Universe->canReweight(icd);
199  //we just see for the first position (prmary proton)
200  if(attenuation_nodes.size()>0 && attenuation_nodes[0]==true){
202  }
203  tot_wgt *= att_wgt;
204 
205  //Absorption correction:
206  tot_abs_wgt = 1.0;
207 
208  // Correction of the pi & K absorption in volumes (Al)
209  abs_ic_wgt = 1.0;
210  absorption_nodes = VOL_ABS_IC_Universe->canReweight(icd);
211  //std::cout<<"size of absorption_nodes is "<<absorption_nodes.size()<<std::endl;
212 
213  if(absorption_nodes.size()>0 && absorption_nodes[0]==true){
215  }
216  tot_wgt *= abs_ic_wgt;
218 
219  //Correction of the pi & K absorption in volumes (Fe)
220  abs_dpip_wgt = 1.0;
221  absorption_nodes = VOL_ABS_DPIP_Universe->canReweight(icd);
222  if(absorption_nodes.size()>0 && absorption_nodes[0]==true){
224  }
225  tot_wgt *= abs_dpip_wgt;
227 
228 
229  //Correction of the pi & K absorption in volumes (He)
230  abs_dvol_wgt = 1.0;
231  absorption_nodes = VOL_ABS_DVOL_Universe->canReweight(icd);
232  if(absorption_nodes.size()>0 && absorption_nodes[0]==true){
234  }
235  tot_wgt *= abs_dvol_wgt;
237 
238  //Correction of nucleons on Al, Fe and He.
239  abs_nucleon_wgt = 1.0;
240  absorption_nodes = VOL_ABS_NUCLEON_Universe->canReweight(icd);
241  if(absorption_nodes.size()>0 && absorption_nodes[0]==true){
243  }
244  tot_wgt *= abs_nucleon_wgt;
246 
247  //Correction of any other particle on Al, Fe and He.
248  abs_other_wgt = 1.0;
249  absorption_nodes = VOL_ABS_OTHER_Universe->canReweight(icd);
250  if(absorption_nodes.size()>0 && absorption_nodes[0]==true){
252  }
253  tot_wgt *= abs_other_wgt;
255 
256  if(tot_wgt!=tot_wgt){
257  std::cout<<"Alert nan total wgt... check!!!"<<std::endl;
258  return 1.0;
259  }
260  return tot_wgt;
261  }
262 
264 
265  if(doMIPPNumi){
268  }
269  delete TARG_ATT_Universe;
270  delete VOL_ABS_IC_Universe;
271  delete VOL_ABS_DPIP_Universe;
272  delete VOL_ABS_DVOL_Universe;
274  delete VOL_ABS_OTHER_Universe;
281  delete OTHER_Universe;
282  }
283 
284 }
virtual double calculateWeight(const InteractionChainData &aa)
calculate a weight for this interaction chain given the central value parameters and the parameters f...
A list/table of parameter names and values.
virtual double calculateWeight(const InteractionData &aa)
calculate a weight for this interaction given the central value parameters and the parameters for thi...
Reweighter of thin target nucleonA interactions.
virtual double calculateWeight(const InteractionData &aa)
calculate a weight for this interaction given the central value parameters and the parameters for thi...
virtual double calculateWeight(const InteractionData &inter_data)
calculate a weight for this interaction given the central value parameters and the parameters for thi...
Reweight to account for attenuation of the beam in the target.
virtual std::vector< bool > canReweight(const InteractionChainData &aa)
Look through the InteractionChainData input and identify those Interactions that can be reweighted as...
ThinTargetMesonIncidentReweighter * THINTARGET_MESON_INCIDENT_Universe
virtual double calculateWeight(const InteractionChainData &aa)
calculate a weight for this interaction chain given the central value parameters and the parameters f...
std::string string
Definition: nybbler.cc:12
Reweighter of thin target nC interactions.
virtual std::vector< bool > canReweight(const InteractionChainData &aa)
Look through the InteractionChainData input and identify those Interactions that can be reweighted as...
ThinTargetpCNucleonReweighter * THINTARGET_PC_NUCLEON_Universe
Information about the chain of interactions leading to a neutrino.
virtual double calculateWeight(const InteractionData &aa)
calculate a weight for this interaction given the central value parameters and the parameters for thi...
Reweighter of thin target pion production.
Reweighter of no thin target and no MIPP interactions.
virtual bool canReweight(const InteractionData &aa)
can the particular instance of this class reweight this interaction?
virtual double calculateWeight(const InteractionChainData &aa)
calculate a weight for this interaction chain given the central value parameters and the parameters f...
std::vector< InteractionData > interaction_chain
vector of neutrino ancestors
virtual bool canReweight(const InteractionData &aa)
can the particular instance of this class reweight this interaction?
ThinTargetpCPionReweighter * THINTARGET_PC_PION_Universe
virtual double calculateWeight(const InteractionData &aa)
calculate a weight for this interaction given the central value parameters and the parameters for thi...
double calculateWeight(const InteractionChainData &icd)
TargetAttenuationReweighter * TARG_ATT_Universe
AbsorptionICReweighter * VOL_ABS_IC_Universe
virtual double calculateWeight(const InteractionChainData &aa)
calculate a weight for this interaction chain given the central value parameters and the parameters f...
virtual double calculateWeight(const InteractionData &aa)
calculate a weight for this interaction given the central value parameters and the parameters for thi...
MIPPNumiPionYieldsReweighter * MIPP_NUMI_PION_Universe
virtual double calculateWeight(const InteractionData &inter_data)
calculate a weight for this interaction given the central value parameters and the parameters for thi...
AbsorptionDPIPReweighter * VOL_ABS_DPIP_Universe
virtual std::vector< bool > canReweight(const InteractionChainData &aa)
Look through the InteractionChainData input and identify those Interactions that can be reweighted as...
OtherAbsorptionOutOfTargetReweighter * VOL_ABS_OTHER_Universe
virtual bool canReweight(const InteractionData &aa)
can the particular instance of this class reweight this interaction?
Reweight a chain of interactions that are covered by the NuMI target pi+ and pi- yields measured by M...
virtual bool canReweight(const InteractionData &aa)
can the particular instance of this class reweight this interaction?
ThinTargetnucleonAReweighter * THINTARGET_NUCLEON_A_Universe
NucleonAbsorptionOutOfTargetReweighter * VOL_ABS_NUCLEON_Universe
virtual bool canReweight(const InteractionData &aa)
can the particular instance of this class reweight this interaction?
virtual std::vector< bool > canReweight(const InteractionChainData &aa)
Look through the InteractionChainData input and identify those Interactions that can be reweighted as...
ReweightDriver(int iuniv, const ParameterTable &cv_pars, const ParameterTable &univ_pars, std::string fileIn)
virtual double calculateWeight(const InteractionChainData &aa)
calculate a weight for this interaction chain given the central value parameters and the parameters f...
virtual std::vector< bool > canReweight(const InteractionChainData &aa)
Look through the InteractionChainData input and identify those Interactions that can be reweighted as...
virtual std::vector< bool > canReweight(const InteractionChainData &aa)
Look through the InteractionChainData input and identify those Interactions that can be reweighted as...
Reweight a MC survival probabiity when the particles through volumes.
MIPPNumiKaonYieldsReweighter * MIPP_NUMI_KAON_Universe
virtual double calculateWeight(const InteractionChainData &aa)
calculate a weight for this interaction chain given the central value parameters and the parameters f...
ThinTargetnCPionReweighter * THINTARGET_NC_PION_Universe
virtual bool canReweight(const InteractionData &aa)
can the particular instance of this class reweight this interaction?
Reweight a chain of interactions that are covered by the NuMI target K/pi ratios measured by MIPP...
AbsorptionDVOLReweighter * VOL_ABS_DVOL_Universe
Reweight a MC survival probabiity when the particles through volumes.
virtual double calculateWeight(const InteractionChainData &aa)
calculate a weight for this interaction chain given the central value parameters and the parameters f...
ThinTargetpCKaonReweighter * THINTARGET_PC_KAON_Universe
virtual std::vector< bool > canReweight(const InteractionChainData &aa)
Look through the InteractionChainData input and identify those Interactions that can be reweighted as...
virtual std::vector< bool > canReweight(const InteractionChainData &aa)
Look through the InteractionChainData input and identify those Interactions that can be reweighted as...
virtual double calculateWeight(const InteractionChainData &aa)
calculate a weight for this interaction chain given the central value parameters and the parameters f...
QTextStream & endl(QTextStream &s)
virtual bool canReweight(const InteractionData &aa)
can the particular instance of this class reweight this interaction?