LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
GENIEReweight.cxx
Go to the documentation of this file.
1 
8 // C/C++ includes
9 #include <math.h>
10 #include <map>
11 #include <fstream>
12 
13 //ROOT includes
14 #include "TVector3.h"
15 #include "TLorentzVector.h"
16 #include "TSystem.h"
17 
18 //GENIE includes
19 #include "Conventions/Units.h"
20 #include "EVGCore/EventRecord.h"
21 #include "GHEP/GHepUtils.h"
22 #include "Messenger/Messenger.h"
23 // Necessary because the GENIE LOG_* macros don't fully qualify Messenger
24 using genie::Messenger;
25 
26 #include "ReWeight/GReWeightI.h"
27 #include "ReWeight/GSystSet.h"
28 #include "ReWeight/GSyst.h"
29 #include "ReWeight/GReWeight.h"
30 #include "ReWeight/GReWeightNuXSecNCEL.h"
31 #include "ReWeight/GReWeightNuXSecCCQE.h"
32 #include "ReWeight/GReWeightNuXSecCCRES.h"
33 #include "ReWeight/GReWeightNuXSecCOH.h"
34 #include "ReWeight/GReWeightNonResonanceBkg.h"
35 #include "ReWeight/GReWeightFGM.h"
36 #include "ReWeight/GReWeightDISNuclMod.h"
37 #include "ReWeight/GReWeightResonanceDecay.h"
38 #include "ReWeight/GReWeightFZone.h"
39 #include "ReWeight/GReWeightINuke.h"
40 #include "ReWeight/GReWeightAGKY.h"
41 #include "ReWeight/GReWeightNuXSecCCQEvec.h"
42 #include "ReWeight/GReWeightNuXSecNCRES.h"
43 #include "ReWeight/GReWeightNuXSecDIS.h"
44 #include "ReWeight/GReWeightNuXSecNC.h"
45 #include "ReWeight/GSystUncertainty.h"
46 #include "ReWeight/GReWeightUtils.h"
47 
48 #include "Geo/ROOTGeomAnalyzer.h"
49 #include "Geo/GeomVolSelectorFiducial.h"
50 #include "Geo/GeomVolSelectorRockBox.h"
51 #include "Utils/StringUtils.h"
52 #include "Utils/XmlParserUtils.h"
53 #include "Interaction/InitialState.h"
54 #include "Interaction/Interaction.h"
55 #include "Interaction/Kinematics.h"
56 #include "Interaction/KPhaseSpace.h"
57 #include "Interaction/ProcessInfo.h"
58 #include "Interaction/XclsTag.h"
59 #include "GHEP/GHepParticle.h"
60 #include "PDG/PDGCodeList.h"
61 #include "Conventions/Constants.h" //for calculating event kinematics
62 
63 //NuTools includes
69 
70 // Framework includes
71 //#include "messagefacility/MessageLogger/MessageLogger.h"
72 
73 
74 
75 namespace rwgt {
78  fReweightNCEL(false),
79  fReweightQEMA(false),
80  fReweightQEVec(false),
81  fReweightCCRes(false),
82  fReweightNCRes(false),
83  fReweightResBkg(false),
84  fReweightResDecay(false),
85  fReweightNC(false),
86  fReweightDIS(false),
87  fReweightCoh(false),
88  fReweightAGKY(false),
89  fReweightDISNucMod(false),
90  fReweightFGM(false),
91  fReweightFZone(false),
92  fReweightINuke(false),
93  fReweightZexp(false),
94  fReweightMEC(false),
95  fMaQEshape(false),
96  fMaCCResShape(false),
97  fMaNCResShape(false),
98  fDISshape(false),
99  fUseSigmaDef(true) {
100 
101  LOG_INFO("GENIEReweight") << "Create GENIEReweight object";
102 
103  fWcalc = new genie::rew::GReWeight();
104  this->SetNominalValues();
105  }
106 
109  delete fWcalc;
110  }
111 
114  //CCQE Nominal Values
116 
118 
119  //CCQE Nominal Values
121 
123 
125 
128 
129  //Resonance Nominal Values
135 
141 
142  //Coherent pion nominal values
145 
146 
147  // Non-resonance background tweaking parameters:
164 
165 
166  // DIS tweaking parameters - applied for DIS events with [Q2>Q2o, W>Wo], typically Q2okReweight =1GeV^2, WokReweight =1.7-2.0GeV
171 
176 
178 
179 
180  fNominalParameters[(int)rwgt::fReweightRnubarnuCC] = 0.0;//v to vbar ratio reweighting is not working in GENIE at the moment
181  fNominalParameters[(int)rwgt::fReweightDISNuclMod] = 0.0;//The DIS nuclear model switch is not working in GENIE at the moment
182  //
183 
185 
186  //
187  // Hadronization [free nucleon target]
188  //
191 
192  //
193  // Medium-effects to hadronization
194  //
196 
197  //
198  // Intranuclear rescattering systematics.
211 
212 
213  //
214  //RFG Nuclear model
215  //
218  //Continous "switch" at 0.0 full FG model. At 1.0 full spectral function model.
219  //From genie code it looks like weird stuff may happen for <0 and >1.
220  //This parameter does not have an "uncertainty" value associated with it.
221  //The tweaked dial value gets passed all the way through unchanged to the weight calculator
222 
223  //
224  // Resonance decays
225  //
229  //Continous "switch" at 0.0 full isotropic pion angular distribution. At 1.0 full R/S pion angular distribtuion.
230  //This parameter does not have an "uncertainty" value associated with it.
231  //The tweaked dial value gets passed all the way through unchanged to the weight calculator
232  }
233 
236  double nominal_value;
237  nominal_value = fNominalParameters[rLabel];
238  return nominal_value;
239  }
240 
243  int label = (int)rLabel;
244  bool in_loop = false;
245  bool found_par = false;
246  double parameter = -10000;
247  for(unsigned int i = 0; i < fReWgtParameterName.size(); i++) {
248  in_loop = true;
249  if(label == fReWgtParameterName[i]) {
250  parameter = fReWgtParameterValue[i];
251  found_par = true;
252  }
253  }
254  if(in_loop) {
255  if(found_par) return parameter;
256  else {
257  LOG_WARN("GENIEReweight") << "Parameter " << label << " not set yet or does not exist";
258  return parameter;
259  }
260  }
261  else {
262  LOG_WARN("GENIEReweight") << "Vector of parameters has not been initialized yet (Size is 0).";
263  return parameter;
264  }
265  }
266 
269  int label = (int)rLabel;
270  LOG_INFO("GENIEReweight") << "Adding parameter: " << genie::rew::GSyst::AsString(genie::rew::EGSyst(label)) << ". With value: " << value;
271  fReWgtParameterName.push_back(label);
272  fReWgtParameterValue.push_back(value);
273 
274  }
275 
278  int label = (int)rLabel;
279  bool found = false;
280  for(unsigned int i = 0; i < fReWgtParameterName.size(); i++) {
281  if(fReWgtParameterName[i] == label) {
283  found = true;
284  }
285  }
286  if(!found) {
287  this->AddReweightValue(rLabel, value);
288  }
289  }
290 
293  LOG_INFO("GENIEReweight") << "Configure weight calculator";
294 
295  for(unsigned int i = 0; i < fReWgtParameterName.size(); i++) {
296 
297  switch (fReWgtParameterName[i])
298  {
299  //NC Elastic parameters
302  fReweightNCEL = true;
303  break;
304 
305  //CC QE Axial parameters
310  fReweightQEMA = true;
311  break;
312 
313  //CC QE Vector parameters
315  fReweightQEVec = true;
316  break;
317 
318  //CC Resonance parameters
324  fReweightCCRes = true;
325  break;
326 
327  //NC Resonance parameters
333  fReweightNCRes = true;
334  break;
335 
336  //Coherent parameters
339  fReweightCoh = true;
340  break;
341 
342  //Non-resonance background KNO parameters
359  fReweightResBkg = true;
360  break;
361 
362  //DIS parameters
373  fReweightDIS = true;
374  break;
375 
376  //DIS nuclear model parameters
378  fReweightDISNucMod = true;
379  break;
380 
381  //NC cross section
382  case rwgt::fReweightNC:
383  fReweightNC = true;
384  break;
385 
386  //Hadronization parameters
389  fReweightAGKY = true;
390  break;
391 
392  //Elastic (and QE) nuclear model parameters
395  fReweightFGM = true;
396  break;
397 
398  //Formation Zone
400  fReweightFZone = true;
401  break;
402 
403  //Intranuke Parameters
416  fReweightINuke = true;
417  break;
418 
419  //Resonance Decay parameters
423  fReweightResDecay = true;
424  break;
425 
426  //Z-expansion parameters
433  fReweightZexp = true;
434  break;
435 
436  } // switch(fReWgtParameterName[i])
437 
438  } //end for loop
439 
440  //configure the individual weight calculators
441  if(fReweightNCEL) this->ConfigureNCEL();
443  if(fReweightQEVec) this->ConfigureQEVec();
444  if(fReweightCCRes) this->ConfigureCCRes();
445  if(fReweightNCRes) this->ConfigureNCRes();
446  if(fReweightResBkg) this->ConfigureResBkg();
448  if(fReweightNC) this->ConfigureNC();
449  if(fReweightDIS) this->ConfigureDIS();
450  if(fReweightCoh) this->ConfigureCoh();
451  if(fReweightAGKY) this->ConfigureAGKY();
453  if(fReweightFGM) this->ConfigureFGM();
454  if(fReweightFZone) this->ConfigureFZone();
455  if(fReweightINuke) this->ConfigureINuke();
456  this->ConfigureParameters();
457 
458  }
459 
462  delete fWcalc;
463  fWcalc = new genie::rew::GReWeight();
464  this->Configure();
465  }
466 
470  void GENIEReweight::ReweightNCEL(double ma, double eta) {
471  LOG_INFO("GENIEReweight") << "Configuring GENIEReweight for NC Elastic Reweighting";
472  if(ma!=0.0) {
474  }
475  if(eta!=0.0) {
477  }
478  this->Configure();
479  }
482  void GENIEReweight::ReweightQEMA(double ma) {
483  LOG_INFO("GENIEReweight") << "Configuring GENIEReweight for QE Axial Mass Reweighting";
484  fMaQEshape=false;
486  this->Configure();
487  }
490  void GENIEReweight::ReweightQEVec(double mv) {
491  LOG_INFO("GENIEReweight") << "Configuring GENIEReweight for QE Vector Mass Reweighting";
493  this->Configure();
494  }
495 
496  void GENIEReweight::ReweightQEZExp(double norm, double a1, double a2, double a3, double a4)
497  {
498  LOG_INFO("GENIEReweight") << "Configuring GENIEReweight for Z-expansion QE Reweighting";
504  this->Configure();
505  }
508  void GENIEReweight::ReweightCCRes(double ma, double mv) {
509  LOG_INFO("GENIEReweight") << "Configuring GENIEReweight for CC Resonance Reweighting";
510  fMaCCResShape=false;
512  if(mv!=0.0) {
514  }
515  this->Configure();
516  }
519  void GENIEReweight::ReweightNCRes(double ma, double mv) {
520  LOG_INFO("GENIEReweight") << "Configuring GENIEReweight for NC Resonance Reweighting";
521  fMaNCResShape=false;
523  if(mv!=0.0) {
525  }
526  this->Configure();
527  }
530  void GENIEReweight::ReweightResGanged(double ma, double mv) {
531  LOG_INFO("GENIEReweight") << "Configuring GENIEReweight for CC and NC Resonance Reweighting";
532  fMaCCResShape=false;
533  fMaNCResShape=false;
536  if(mv!=0.0) {
539  }
540  this->Configure();
541  }
544  void GENIEReweight::ReweightCoh(double ma, double r0) {
545  LOG_INFO("GENIEReweight") << "Configuring GENIEReweight for Coherant Reweighting";
548  this->Configure();
549  }
550 
552  //Here it is being configured for v+p and vbar + n (1 pi) type interactions
553  void GENIEReweight::ReweightNonResRvp1pi(double sigma) {
554  LOG_INFO("GENIEReweight") << "Configuring GENIEReweight for Non-Resonance Background Reweighting (Neutrino Single Pion)";
559  this->Configure();
560  }
561 
563  //Here it is being configured for v+n and vbar + p (1 pi) type interactions
564  void GENIEReweight::ReweightNonResRvbarp1pi(double sigma) {
565  LOG_INFO("GENIEReweight") << "Configuring GENIEReweight for Non-Resonance Background Reweighting (Anti-Neutrino Single Pion)";
570  this->Configure();
571  }
574  void GENIEReweight::ReweightNonResRvp2pi(double sigma) {
575  LOG_INFO("GENIEReweight") << "Configuring GENIEReweight for Non-Resonance Background Reweighting (Neutrino Two Pion)";
580  this->Configure();
581  }
582 
584  // Here it is being configured for v+n and vbar + p (2 pi) type interactions
585  void GENIEReweight::ReweightNonResRvbarp2pi(double sigma) {
586  LOG_INFO("GENIEReweight") << "Configuring GENIEReweight for Non-Resonance Background Reweighting (Anti-Neutrino Two Pion)";
591  this->Configure();
592  }
595  void GENIEReweight::ReweightResDecay(double gamma, double eta, double theta) {
596  LOG_INFO("GENIEReweight") << "Configuring GENIEReweight for Resoncance Decay Parameters";
597  if(gamma!=0.0) {
599  }
600  if(eta!=0.0) {
602  }
603  if(theta!=0.0) {
605  }
606  this->Configure();
607  }
610  void GENIEReweight::ReweightNC(double norm) {
611  LOG_INFO("GENIEReweight") << "Configuring GENIEReweight for NC Cross Section Scale";
612  this->AddReweightValue(rwgt::fReweightNC, norm);
613  this->Configure();
614  }
617  void GENIEReweight::ReweightDIS(double aht, double bht, double cv1u, double cv2u) {
618  LOG_INFO("GENIEReweight") << "Configuring GENIEReweight for DIS Form Factor Model Reweighting";
619  fDISshape = false;
620  if(aht != 0.0) {
622  }
623  if(bht != 0.0) {
625  }
626  if(cv1u != 0.0) {
628  }
629  if(cv2u != 0.0) {
631  }
632  this->Configure();
633  }
636  void GENIEReweight::ReweightDISnucl(bool mode) {
637  LOG_INFO("GENIEReweight") << "Configuring GENIEReweight for DIS Nuclear Model";
639  this->Configure();
640  }
643  void GENIEReweight::ReweightAGKY(double xF, double pT) {
644  LOG_INFO("GENIEReweight") << "Configuring GENIEReweight for DIS AGKY Hadronization Model Reweighting";
645  if(xF==0.0) {
647  }
648  if(pT==0.0) {
650  }
651  this->Configure();
652  }
655  void GENIEReweight::ReweightIntraNuke(ReweightLabel_t name, double sigma) {
656  LOG_INFO("GENIEReweight") << "Configuring GENIEReweight for Intranuke Model Reweighting";
657  if ( (name==rwgt::fReweightMFP_pi) ||
658  (name==rwgt::fReweightMFP_N) ||
659  (name==rwgt::fReweightFrCEx_pi) ||
660  (name==rwgt::fReweightFrElas_pi) ||
661  (name==rwgt::fReweightFrInel_pi) ||
662  (name==rwgt::fReweightFrAbs_pi) ||
663  (name==rwgt::fReweightFrPiProd_pi) ||
664  (name==rwgt::fReweightFrCEx_N) ||
665  (name==rwgt::fReweightFrElas_N) ||
666  (name==rwgt::fReweightFrInel_N ) ||
667  (name==rwgt::fReweightFrAbs_N ) ||
668  (name==rwgt::fReweightFrPiProd_N) ) {
669  this->AddReweightValue(name, sigma);
670  }
671  else {
672  LOG_WARN("GENIEReweight") << "That is not a valid Intranuke parameter Intranuke not configured";
673  }
674  this->Configure();
675  }
678  void GENIEReweight::ReweightFormZone(double sigma) {
679  LOG_INFO("GENIEReweight") << "Configuring GENIEReweight for Formation Zone Reweighting";
681  this->Configure();
682  }
685  void GENIEReweight::ReweightFGM(double kF, double sf) {
686  LOG_INFO("GENIEReweight") << "Configuring GENIEReweight for Fermi Gas Model Reweighting";
689  this->Configure();
690  }
691 
693 
697  LOG_INFO("GENIEReweight") << "Adding NC elastic weight calculator";
698  fWcalc->AdoptWghtCalc( "xsec_ncel", new GReWeightNuXSecNCEL );
699  }
700 
703  LOG_INFO("GENIEReweight") << "Adding CCQE axial FF weight calculator ";
704  fWcalc->AdoptWghtCalc( "xsec_ccqe", new GReWeightNuXSecCCQE );
705  GReWeightNuXSecCCQE *rwccqe = dynamic_cast <GReWeightNuXSecCCQE*> (fWcalc->WghtCalc("xsec_ccqe"));
706  if (fReweightZexp)
707  {
708  LOG_INFO("GENIEReweight") << "in z-expansion mode";
709  rwccqe->SetMode(GReWeightNuXSecCCQE::kModeZExp);
710  }
711  else if(!fMaQEshape) {
712  LOG_INFO("GENIEReweight") << "in axial mass (QE) rate+shape mode";
713  rwccqe->SetMode(GReWeightNuXSecCCQE::kModeMa);
714  }
715  else {
716  LOG_INFO("GENIEReweight") << "in axial mass (QE) shape only mode";
717  }
718  }
719 
722  LOG_INFO("GENIEReweight") << "Adding CCQE vector FF weight calculator";
723  fWcalc->AdoptWghtCalc( "xsec_ccqe_vec", new GReWeightNuXSecCCQEvec );
724  }
725 
728  LOG_INFO("GENIEReweight") << "Adding CC resonance weight calculator";
729  fWcalc->AdoptWghtCalc( "xsec_ccres", new GReWeightNuXSecCCRES );
730  if(!fMaCCResShape) {
731  LOG_INFO("GENIEReweight") << "in axial mass (Res) rate+shape mode";
732  GReWeightNuXSecCCRES * rwccres = dynamic_cast<GReWeightNuXSecCCRES *> (fWcalc->WghtCalc("xsec_ccres"));
733  rwccres->SetMode(GReWeightNuXSecCCRES::kModeMaMv);
734  }
735  else {
736  LOG_INFO("GENIEReweight") << "in axial mass (Res) shape only mode";
737  }
738  }
739 
742  LOG_INFO("GENIEReweight") << "Adding NC resonance weight calculator";
743  fWcalc->AdoptWghtCalc( "xsec_ncres", new GReWeightNuXSecNCRES );
744  if(!fMaNCResShape) {
745  LOG_INFO("GENIEReweight") << "in axial mass (Res) rate+shape mode";
746  GReWeightNuXSecNCRES * rwncres = dynamic_cast<GReWeightNuXSecNCRES *> (fWcalc->WghtCalc("xsec_ncres"));
747  rwncres->SetMode(GReWeightNuXSecNCRES::kModeMaMv);
748  }
749  else {
750  LOG_INFO("GENIEReweight") << "in axial mass (Res) shape only mode";
751  }
752  }
753 
756  LOG_INFO("GENIEReweight") << "Adding low Q^2 DIS (KNO) weight calculator";
757  fWcalc->AdoptWghtCalc( "xsec_nonresbkg", new GReWeightNonResonanceBkg );
758  }
759 
762  LOG_INFO("GENIEReweight") << "Adding resonance decay weight calculator";
763  fWcalc->AdoptWghtCalc( "hadro_res_decay", new GReWeightResonanceDecay );
764  }
765 
768  LOG_INFO("GENIEReweight") << "Adding NC total cross section weight calculator";
769  fWcalc->AdoptWghtCalc( "xsec_nc", new GReWeightNuXSecNC );
770  }
771 
774  LOG_INFO("GENIEReweight") << "Adding DIS (Bodek-Yang) weight calculator";
775  fWcalc->AdoptWghtCalc( "xsec_dis", new GReWeightNuXSecDIS );
776  if(!fDISshape) {
777  LOG_INFO("GENIEReweight") << "in shape+rate mode";
778  GReWeightNuXSecDIS * rwdis = dynamic_cast<GReWeightNuXSecDIS *> (fWcalc->WghtCalc("xsec_dis"));
779  rwdis->SetMode(GReWeightNuXSecDIS::kModeABCV12u);
780  }
781  else {
782  LOG_INFO("GENIEReweight") << "in shape only mode";
783  }
784  }
785 
788  LOG_INFO("GENIEReweight") << "Adding coherant interaction model weight calculator";
789  fWcalc->AdoptWghtCalc( "xsec_coh", new GReWeightNuXSecCOH );
790  }
791 
794  LOG_INFO("GENIEReweight") << "Adding hadronization (AGKY) model weight calculator";
795  fWcalc->AdoptWghtCalc( "hadro_agky", new GReWeightAGKY );
796  }
797 
800  LOG_INFO("GENIEReweight") << "Adding DIS nuclear model weight calculator";
801  fWcalc->AdoptWghtCalc( "nuclear_dis", new GReWeightDISNuclMod );
802  }
803 
806  LOG_INFO("GENIEReweight") << "Adding Fermi Gas Model (FGM) weight calculator";
807  fWcalc->AdoptWghtCalc( "nuclear_qe", new GReWeightFGM );
808  }
809 
812  LOG_INFO("GENIEReweight") << "Adding Formation Zone weight calculator";
813  fWcalc->AdoptWghtCalc( "hadro_fzone", new GReWeightFZone );
814  }
815 
818  LOG_INFO("GENIEReweight") << "Adding the Intra-Nuke weight calculator";
819  fWcalc->AdoptWghtCalc( "hadro_intranuke", new GReWeightINuke );
820  }
821 
824  GSystSet & syst = fWcalc->Systematics();
825  for(unsigned int i = 0; i < fReWgtParameterName.size(); i++) {
826  LOG_INFO("GENIEReweight") << "Configuring GENIEReweight parameter: " << genie::rew::GSyst::AsString(genie::rew::EGSyst(fReWgtParameterName[i])) << " with value: " << fReWgtParameterValue[i];
827  if(fUseSigmaDef) {
828  syst.Set( (GSyst_t)fReWgtParameterName[i], fReWgtParameterValue[i]);
829  }
830  else {
832  syst.Set( (GSyst_t)fReWgtParameterName[i], parameter);
833  }
834  }
835  fWcalc->Reconfigure();
836  }
837 
841  //double GENIEReweight::CalculateSigma(int label, double value) {
842  int iLabel = (int) label;
843  double nominal_def;
844  double frac_err;
845  double sigma;
846  int sign;
847  GSystUncertainty * gsysterr = GSystUncertainty::Instance();
850  label==rwgt::fReweightDISNuclMod) {
851  //These parameters don't use the sigma definition just pass them through the function unchanged
852  sigma = value;
853  }
854  else {
855  nominal_def = this->NominalParameterValue(label);
856  sign = genie::utils::rew::Sign(value-nominal_def);
857  frac_err = gsysterr->OneSigmaErr( (GSyst_t)iLabel, sign);
858  sigma = (value - nominal_def)/(frac_err*nominal_def);
859  }
860  return sigma;
861  }
862 
864  //double GENIEReweight::CalcWeight(simb::MCTruth truth, simb::GTruth gtruth) {
865  double GENIEReweight::CalculateWeight(const genie::EventRecord& evr) const {
866  //genie::EventRecord evr = this->RetrieveGHEP(truth, gtruth);
867  double wgt = fWcalc->CalcWeight(evr);
868  //mf::LogVerbatim("GENIEReweight") << "New Event Weight is: " << wgt;
869  return wgt;
870  }
871 
872  /*
874  genie::EventRecord GENIEReweight::RetrieveGHEP(simb::MCTruth truth, simb::GTruth gtruth) {
875 
876  genie::EventRecord newEvent;
877  newEvent.SetWeight(gtruth.fweight);
878  newEvent.SetProbability(gtruth.fprobability);
879  newEvent.SetXSec(gtruth.fXsec);
880  newEvent.SetDiffXSec(gtruth.fDiffXsec);
881  TLorentzVector vtx = gtruth.fVertex;
882  newEvent.SetVertex(vtx);
883 
884  for(int i = 0; i < truth.NParticles(); i++) {
885  simb::MCParticle mcpart = truth.GetParticle(i);
886 
887  int gmid = mcpart.PdgCode();
888  genie::GHepStatus_t gmst = (genie::GHepStatus_t)mcpart.StatusCode();
889  int gmmo = mcpart.Mother();
890  int ndaughters = mcpart.NumberDaughters();
891  //find the track ID of the first and last daughter particles
892  int fdtrkid = 0;
893  int ldtrkid = 0;
894  if(ndaughters !=0) {
895  fdtrkid = mcpart.Daughter(0);
896  if(ndaughters == 1) {
897  ldtrkid = 1;
898  }
899  else if(ndaughters >1) {
900  fdtrkid = mcpart.Daughter(ndaughters-1);
901  }
902  }
903  int gmfd = -1;
904  int gmld = -1;
905  //Genie uses the index in the particle array to reference the daughter particles.
906  //MCTruth keeps the particles in the same order so use the track ID to find the proper index.
907  for(int j = 0; j < truth.NParticles(); j++) {
908  simb::MCParticle temp = truth.GetParticle(i);
909  if(temp.TrackId() == fdtrkid) {
910  gmfd = j;
911  }
912  if(temp.TrackId() == ldtrkid) {
913  gmld = j;
914  }
915  }
916 
917  double gmpx = mcpart.Px(0);
918  double gmpy = mcpart.Py(0);
919  double gmpz = mcpart.Pz(0);
920  double gme = mcpart.E(0);
921  double gmvx = mcpart.Gvx();
922  double gmvy = mcpart.Gvy();
923  double gmvz = mcpart.Gvz();
924  double gmvt = mcpart.Gvt();
925  int gmri = mcpart.Rescatter();
926 
927  genie::GHepParticle gpart(gmid, gmst, gmmo, -1, gmfd, gmld, gmpx, gmpy, gmpz, gme, gmvx, gmvy, gmvz, gmvt);
928  gpart.SetRescatterCode(gmri);
929  TVector3 polz = mcpart.Polarization();
930  if(polz.x() !=0 || polz.y() !=0 || polz.z() !=0) {
931  gpart.SetPolarization(polz);
932  }
933  newEvent.AddParticle(gpart);
934 
935  }
936 
937  genie::ProcessInfo proc_info;
938  genie::ScatteringType_t gscty = (genie::ScatteringType_t)gtruth.fGscatter;
939  genie::InteractionType_t ginty = (genie::InteractionType_t)gtruth.fGint;
940 
941  proc_info.Set(gscty,ginty);
942 
943  genie::XclsTag gxt;
944 
945  //Set Exclusive Final State particle numbers
946  genie::Resonance_t gres = (genie::Resonance_t)gtruth.fResNum;
947  gxt.SetResonance(gres);
948  gxt.SetNPions(gtruth.fNumPiPlus, gtruth.fNumPi0, gtruth.fNumPiMinus);
949  gxt.SetNNucleons(gtruth.fNumProton, gtruth.fNumNeutron);
950 
951  if(gtruth.fIsCharm) {
952  gxt.SetCharm(0);
953  }
954  else {
955  gxt.UnsetCharm();
956  }
957 
958  //Set the GENIE kinematic info
959  genie::Kinematics gkin;
960  gkin.Setx(gtruth.fgX, true);
961  gkin.Sety(gtruth.fgY, true);
962  gkin.Sett(gtruth.fgT, true);
963  gkin.SetW(gtruth.fgW, true);
964  gkin.SetQ2(gtruth.fgQ2, true);
965  gkin.Setq2(gtruth.fgq2, true);
966  simb::MCNeutrino nu = truth.GetNeutrino();
967  simb::MCParticle lep = nu.Lepton();
968  gkin.SetFSLeptonP4(lep.Px(), lep.Py(), lep.Pz(), lep.E());
969  gkin.SetHadSystP4(gtruth.fFShadSystP4.Px(), gtruth.fFShadSystP4.Py(), gtruth.fFShadSystP4.Pz(), gtruth.fFShadSystP4.E());
970 
971  //Set the GENIE final state interaction info
972  genie::Interaction * p_gint = new genie::Interaction;
973  genie::InitialState * p_ginstate = p_gint->InitStatePtr();
974  //int Z = gtruth.ftgtZ;
975  //int A = gtruth.ftgtA;
976  int targetNucleon = nu.HitNuc();
977  int struckQuark = nu.HitQuark();
978  int incoming = gtruth.fProbePDG;
979  p_ginstate->SetProbePdg(incoming);
980 
981  genie::Target* target123 = p_ginstate->TgtPtr();
982 
983  target123->SetId(gtruth.ftgtPDG);
984  //target123->SetId(Z,A);
985 
986  //int pdg_code = pdg::IonPdgCode(A, Z);
987  //TParticlePDG * p = PDGLibrary::Instance()->Find(pdg_code);
988 
989  //mf::LogWarning("GENIEReweight") << "Setting Target Z and A";
990  //mf::LogWarning("GENIEReweight") << "Saved PDG: " << gtruth.ftgtPDG;
991  //mf::LogWarning("GENIEReweight") << "Target PDG: " << target123->Pdg();
992  target123->SetHitNucPdg(targetNucleon);
993  target123->SetHitQrkPdg(struckQuark);
994  target123->SetHitSeaQrk(gtruth.fIsSeaQuark);
995 
996  if(newEvent.HitNucleonPosition()> 0) {
997  genie::GHepParticle * hitnucleon = newEvent.HitNucleon();
998  std::auto_ptr<TLorentzVector> p4hitnucleon(hitnucleon->GetP4());
999  target123->SetHitNucP4(*p4hitnucleon);
1000  }
1001  else {
1002  TLorentzVector dummy(0.,0.,0.,0.);
1003  target123->SetHitNucP4(dummy);
1004  }
1005 
1006  genie::GHepParticle * probe = newEvent.Probe();
1007  std::auto_ptr<TLorentzVector> p4probe(probe->GetP4());
1008  p_ginstate->SetProbeP4(*p4probe);
1009  if(newEvent.TargetNucleusPosition()> 0) {
1010  genie::GHepParticle * target = newEvent.TargetNucleus();
1011  std::auto_ptr<TLorentzVector> p4target(target->GetP4());
1012  p_ginstate->SetTgtP4(*p4target);
1013  } else {
1014  TLorentzVector dummy(0.,0.,0.,0.);
1015  p_ginstate->SetTgtP4(dummy);
1016  }
1017  p_gint->SetProcInfo(proc_info);
1018  p_gint->SetKine(gkin);
1019  p_gint->SetExclTag(gxt);
1020  newEvent.AttachSummary(p_gint);
1021 
1022 
1023  //For temporary debugging purposes
1024  //genie::Interaction *inter = newEvent.Summary();
1025  //const genie::InitialState &initState = inter->InitState();
1026  //const genie::Target &tgt = initState.Tgt();
1027  //std::cout << "TargetPDG as Recorded: " << gtruth.ftgtPDG << std::endl;
1028  //std::cout << "TargetZ as Recorded: " << gtruth.ftgtZ << std::endl;
1029  //std::cout << "TargetA as Recorded: " << gtruth.ftgtA << std::endl;
1030  //std::cout << "TargetPDG as Recreated: " << tgt.Pdg() << std::endl;
1031  //std::cout << "TargetZ as Recreated: " << tgt.Z() << std::endl;
1032  //std::cout << "TargetA as Recreated: " << tgt.A() << std::endl;
1033 
1034  return newEvent;
1035 
1036  }
1037  */
1038 
1039 
1040 }
void AddReweightValue(ReweightLabel_t rLabel, double value)
Change a reweight parameter. If it hasn&#39;t been added yet add it.
tweak inelastic probability for pions, for given total rescattering probability
void ReweightIntraNuke(ReweightLabel_t name, double sigma)
Simple Configuration of the Formation Zone reweight calculator.
tweak absorption probability for nucleons, for given total rescattering probability ...
void ReweightQEVec(double mv)
enum rwgt::EReweightLabel ReweightLabel_t
void ConfigureINuke()
configure the weight parameters being used
tweak the 2pi non-RES bkg in the RES region, for v+n CC
tweak the 1pi non-RES bkg in the RES region, for vbar+p NC
tweak Mv CCRES, affects d2sigma(CCRES)/dWdQ2 both in shape and normalization
tweak the Bodek-Yang model parameter B_{ht} - incl. both shape and normalization effect ...
#define LOG_INFO(category)
tweak axial nucleon form factors (dipole -> z-expansion) - shape only effect of dsigma(CCQE)/dQ2 ...
void ConfigureCCRes()
Configure the NCRES calculator.
void ConfigureResBkg()
Configure the ResDecay weight calculator.
void ConfigureDIS()
Configure the Coherant model weight calculator.
void Configure()
Reconfigure the weight calculators.
tweak the Bodek-Yang model parameter CV2u - incl. both shape and normalization effect ...
const std::string label
tweak Ma CCRES, affects d2sigma(CCRES)/dWdQ2 in shape only (normalized to constant integral) ...
void ConfigureQEVec()
Configure the CCRES calculator.
void ReweightAGKY(double xF, double pT)
Simple Configuration of the Intranuke Nuclear model.
tweak the 2pi non-RES bkg in the RES region, for v+p CC
void ReweightResDecay(double gamma, double eta, double theta)
Simple Configuration of the Total NC cross section.
tweak inelastic probability for nucleons, for given total rescattering probability ...
void ReweightCCRes(double ma, double mv=0.0)
Simple Configurtion of the NC Resonance weight calculator.
void ReweightDIS(double aht, double bht, double cv1u, double cv2u)
Simple Configuration of the DIS nuclear model.
std::map< int, double > fNominalParameters
tweak Z-expansion CCQE normalization (energy independent)
void ConfigureNC()
Configure the DIS (Bodek-Yang) weight calculator.
void ReweightFGM(double kF, double sf)
End of Simple Reweight Configurations.
void ConfigureFGM()
Configure the Formation Zone weight calculator.
double CalculateWeight(const genie::EventRecord &evr) const
tweak Resonance -> X + gamma branching ratio, eg Delta+(1232) -> p gamma
void ReweightQEMA(double ma)
Simple Configuration of the CCQE vector weight calculator.
tweak the 1pi non-RES bkg in the RES region, for vbar+p CC
tweak pion production probability for nucleons, for given total rescattering probability ...
tweak xF distribution for low multiplicity (N + pi) DIS f/s produced by AGKY
std::vector< int > fReWgtParameterName
void ConfigureFZone()
Configure the intranuke weight calculator.
tweak the 2pi non-RES bkg in the RES region, for v+p NC
tweak CCQE normalization (maintains dependence on neutrino energy)
void ReweightQEZExp(double norm, double a1, double a2, double a3, double a4)
Simple Configuration of the CC Resonance weight calculator.
Particle class.
tweak the 2pi non-RES bkg in the RES region, for vbar+n CC
tweak CCQE normalization (energy independent)
tweak the 2pi non-RES bkg in the RES region, for vbar+n NC
tweak the 2pi non-RES bkg in the RES region, for vbar+p NC
void ReweightNonResRvbarp1pi(double sigma)
Simple Configuration of the Non-Resonance Background weight calculator. Here it is being configured f...
void ConfigureQEMA()
Configure the QE vector FF weight calculator.
void ReweightCoh(double ma, double r0)
Simple Configuration of the Non-Resonance Background weight calculator.
tweak formation zone
void ConfgureResDecay()
Configure the NC weight calculator.
#define a2
tweak pT distribution for low multiplicity (N + pi) DIS f/s produced by AGKY
#define a3
tweak the 2pi non-RES bkg in the RES region, for v+n NC
tweak elastic probability for nucleons, for given total rescattering probability
void SetNominalValues()
Return the nominal value for the given parameter.
tweak Ma NCRES, affects d2sigma(NCRES)/dWdQ2 both in shape and normalization
tweak Z-expansion coefficient 1, affects dsigma(CCQE)/dQ2 both in shape and normalization ...
GENIEReweight()
<constructor
tweak Mv NCRES, affects d2sigma(NCRES)/dWdQ2 both in shape and normalization
tweak the 1pi non-RES bkg in the RES region, for v+n CC
genie::rew::GReWeight * fWcalc
void ReweightResGanged(double ma, double mv=0.0)
Simple Configuration of the Coherant weight calculator.
void ConfigureNCRes()
Configure the ResBkg (kno) weight calculator.
tweak absorption probability for pions, for given total rescattering probability
tweak NCRES normalization
tweak Z-expansion coefficient 2, affects dsigma(CCQE)/dQ2 both in shape and normalization ...
void Reconfigure()
Simple Configuration functions for configuring a single weight calculator.
Wrapper for reweight neutrino interactions with GENIE base class.
void ChangeParameterValue(ReweightLabel_t rLabel, double value)
Configure the weight calculators.
void ReweightNonResRvbarp2pi(double sigma)
Simple Configuration of the Resonance decay model weight calculator.
tweak the Bodek-Yang model parameter CV1u - incl. both shape and normalization effect ...
tweak the 1pi non-RES bkg in the RES region, for vbar+n NC
void ReweightNCRes(double ma, double mv=0.0)
Simple Configuration of the NC and CC Resonance weight calculator with the axial mass parameter for N...
tweak the 1pi non-RES bkg in the RES region, for vbar+n CC
tweak mean free path for pions
tweak the 1pi non-RES bkg in the RES region, for v+p NC
tweak the Bodek-Yang model parameter A_{ht} - shape only effect to d2sigma(DIS)/dxdy ...
void ConfigureAGKY()
Configure the DIS nuclear model weight calculator.
void ConfigureNCEL()
Configure the MaQE weight calculator.
distort pi angular distribution in Delta -> N + pi
double NominalParameterValue(ReweightLabel_t rLabel)
Return the configured value of the given parameter.
tweak DIS nuclear modification (shadowing, anti-shadowing, EMC). Does not appear to be working in GEN...
~GENIEReweight()
Set the nominal values for the reweight parameters.
tweak the inclusive DIS CC normalization (not currently working in genie)
tweak the Bodek-Yang model parameter CV2u - shape only effect to d2sigma(DIS)/dxdy ...
tweak Z-expansion coefficient 3, affects dsigma(CCQE)/dQ2 both in shape and normalization ...
int sign(double val)
Definition: UtilFunc.cxx:106
tweak Mv CCRES, affects d2sigma(CCRES)/dWdQ2 in shape only (normalized to constant integral) ...
tweak Resonance -> X + eta branching ratio, eg N+(1440) -> p eta
std::string value(boost::any const &)
std::vector< double > fReWgtParameterValue
double ReweightParameterValue(ReweightLabel_t rLabel)
Add reweight parameters to the list.
tweak the Bodek-Yang model parameter B_{ht} - shape only effect to d2sigma(DIS)/dxdy ...
Float_t norm
tweak Ma NCEL, affects dsigma(NCEL)/dQ2 both in shape and normalization
void ReweightNCEL(double ma, double eta)
Simple Configurtion of the CCQE axial weight calculator.
void ReweightNonResRvp1pi(double sigma)
Simple Configuration of the Non-Resonance Background weight calculator.
tweak charge exchange probability for nucleons, for given total rescattering probability ...
tweak the Bodek-Yang model parameter A_{ht} - incl. both shape and normalization effect ...
double CalculateSigma(ReweightLabel_t label, double value)
Calculate the weights.
tweak Z-expansion coefficient 4, affects dsigma(CCQE)/dQ2 both in shape and normalization ...
tweak Ma NCRES, affects d2sigma(NCRES)/dWdQ2 in shape only (normalized to constant integral) ...
tweak Ma CCRES, affects d2sigma(CCRES)/dWdQ2 both in shape and normalization
tweak NCEL strange axial form factor eta, affects dsigma(NCEL)/dQ2 both in shape and normalization ...
#define a4
tweak the 2pi non-RES bkg in the RES region, for vbar+p CC
tweak Ma CCQE, affects dsigma(CCQE)/dQ2 in shape only (normalized to constant integral) ...
tweak pion production probability for pions, for given total rescattering probability ...
tweak Ma CCQE, affects dsigma(CCQE)/dQ2 both in shape and normalization
tweak Mv NCRES, affects d2sigma(NCRES)/dWdQ2 in shape only (normalized to constant integral) ...
tweak charge exchange probability for pions, for given total rescattering probability ...
tweak the Bodek-Yang model parameter CV1u - shape only effect to d2sigma(DIS)/dxdy ...
tweak elastic nucleon form factors (BBA/default -> dipole) - shape only effect of dsigma(CCQE)/dQ2 ...
tweak mean free path for nucleons
void ReweightNC(double norm)
Simple Configuration of the DIS FF model weight calculator.
void ReweightNonResRvp2pi(double sigma)
Simple Configuration of the Non-Resonance Background weight calculator.
tweak the 1pi non-RES bkg in the RES region, for v+p CC
void ReweightFormZone(double sigma)
Simple Configuration of the Fermigas model reweight calculator.
tweak Ma for COH pion production
tweak elastic probability for pions, for given total rescattering probability
void ConfigureDISNucMod()
Configure the FG model weight calculator.
tweak CCRES normalization
tweak the 1pi non-RES bkg in the RES region, for v+n NC
tweak the ratio of ( CC) / ( CC) (not currently working in genie)
void ReweightDISnucl(bool mode)
Simple Configuration of the DIS AGKY hadronization model.
tweak R0 for COH pion production
#define a1
void ConfigureCoh()
Configure the hadronization (AGKY) weight calculator.