GReWeightUtils.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2017, GENIE Neutrino MC Generator Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5  or see $GENIE/LICENSE
6 
7  Author: Jim Dobson <J.Dobson07 \at imperial.ac.uk>
8  Imperial College London
9 
10  Costas Andreopoulos <costas.andreopoulos \at stfc.ac.uk>
11  University of Liverpool & STFC Rutherford Appleton Lab
12 
13  For documentation see the corresponding header file.
14 
15  Important revisions after version 2.0.0 :
16  @ Sep 11, 2009 - CA
17  Was first added in v2.5.1. Adapted from the T2K-specific version of the
18  GENIE reweighting tool.
19  @ Dec 17, 2010 - JD
20  Added method to calculate weight for a modified formation zone.
21  @ Jul 29, 2011 - SD,AM
22  Update INUKE fates. Mean free path is now function of Z too.
23  @ Feb 08, 2013 - CA
24  Adjust formation zone reweighting. Mean free path is function of Z too.
25 */
26 //____________________________________________________________________________
27 
28 #include <cassert>
29 
30 #include <TMath.h>
31 
32 #include "Conventions/Units.h"
33 #include "Conventions/Controls.h"
34 #include "GHEP/GHepParticle.h"
38 #include "Messenger/Messenger.h"
39 #include "Numerical/Spline.h"
40 #include "PDG/PDGUtils.h"
41 #include "PDG/PDGCodes.h"
43 
44 using namespace genie;
45 using namespace genie::rew;
46 using namespace genie::controls;
47 
48 //____________________________________________________________________________
50  int pdgc, const TLorentzVector & x4, const TLorentzVector & p4,
51  double A, double Z,
52  double mfp_scale_factor, bool interacted,
53  double nRpi, double nRnuc, double NR, double R0)
54 {
55  LOG("ReW", pINFO)
56  << "Calculating mean free path weight: "
57  << "A = " << A << ", Z = " << Z << ", mfp_scale = " << mfp_scale_factor
58  << ", interacted = " << interacted;
59  LOG("ReW", pDEBUG)
60  << "nR_pion = " << nRpi << ", nR_nucleon = " << nRnuc
61  << ", NR = " << NR << ", R0 = " << R0;
62 
63  // Get the nominal survival probability
64  double pdef = utils::intranuke::ProbSurvival(
65  pdgc,x4,p4,A,Z,1.,nRpi,nRnuc,NR,R0);
66  LOG("ReW", pINFO) << "Probability(default mfp) = " << pdef;
67  if(pdef<=0) return 1.;
68 
69  // Get the survival probability for the tweaked mean free path
70  double ptwk = utils::intranuke::ProbSurvival(
71  pdgc,x4,p4,A,Z,mfp_scale_factor,nRpi,nRnuc,NR,R0);
72  LOG("ReW", pINFO) << "Probability(tweaked mfp) = " << ptwk;
73  if(ptwk<=0) return 1.;
74 
75  // Calculate weight
76  double w_mfp = utils::rew::MeanFreePathWeight(pdef, ptwk, interacted);
77  LOG("ReW", pINFO) << "Mean free path weight = " << w_mfp;
78  return w_mfp;
79 }
80 //____________________________________________________________________________
82  int pdgc, const TLorentzVector & vtx, const TLorentzVector & x4,
83  const TLorentzVector & p4, double A, double Z,
84  double fz_scale_factor, bool interacted,
85  double nRpi, double nRnuc, double NR, double R0)
86 {
87  // Calculate hadron start assuming tweaked formation zone
88  TLorentzVector fz = x4 - vtx;
89  TLorentzVector fztwk = fz_scale_factor*fz;
90  TLorentzVector x4twk = x4 + fztwk - fz;
91 
92  LOG("ReW", pDEBUG) << "Formation zone = "<< fz.Vect().Mag() << " fm";
93 
94  // Get nominal survival probability.
95  double pdef = utils::intranuke::ProbSurvival(
96  pdgc,x4,p4,A,Z,1.,nRpi,nRnuc,NR,R0);
97  LOG("ReW", pDEBUG) << "Survival probability (nominal) = "<< pdef;
98  if(pdef<=0) return 1.;
99  if(pdef>=1.){
100  LOG("ReW", pERROR)
101  << "Default formation zone takes hadron outside "
102  << "nucleus so cannot reweight!" ;
103  return 1.;
104  }
105 
106  // Get tweaked survival probability.
107  double ptwk = utils::intranuke::ProbSurvival(
108  pdgc,x4twk,p4,A,Z,1.,nRpi,nRnuc,NR,R0);
109  if(ptwk<=0) return 1.;
110  LOG("ReW", pDEBUG) << "Survival probability (tweaked) = "<< ptwk;
111 
112  // Calculate weight
113  double w_fz = utils::rew::MeanFreePathWeight(pdef, ptwk, interacted);
114  LOG("ReW", pDEBUG)
115  << "Particle weight for formation zone tweak = "<< ptwk;
116  return w_fz;
117 }
118 //____________________________________________________________________________
120  double pdef, double ptwk, bool interacted)
121 {
122 // Returns a weight to account for a change in hadron mean free path inside
123 // insidea nuclear medium.
124 //
125 // Inputs:
126 // pdef : nominal survival probability
127 // ptwk : survival probability for the tweaked mean free path
128 // interacted : flag indicating whether the hadron interacted or escaped
129 //
130 // See utils::intranuke::ProbSurvival() for the calculation of probabilities.
131 //
132  double w_mfp = 1.;
133 
134  if(interacted) {
135  w_mfp = (1-pdef>0) ? (1-ptwk) / (1-pdef) : 1;
136  } else {
137  w_mfp = (pdef>0) ? ptwk / pdef : 1;
138  }
139  w_mfp = TMath::Max(0.,w_mfp);
140 
141  return w_mfp;
142 }
143 //____________________________________________________________________________
145  genie::rew::GSyst_t syst, double kinE, double frac_scale_factor)
146 {
147  double fate_frac = 0.0;
148 
150 
151  // convert to MeV and
152  double ke = kinE / units::MeV;
153  ke = TMath::Max(INukeHadroData::fMinKinEnergy, ke);
154  ke = TMath::Min(INukeHadroData::fMaxKinEnergyHA, ke);
155 
156  switch (syst) {
157 
158  //
159  // pions
160  //
161 
163  {
164  fate_frac = hd->Frac(kPdgPiP, kIHAFtCEx, ke);
165  }
166  break;
167 
169  {
170  fate_frac = hd->Frac(kPdgPiP, kIHAFtElas, ke);
171  }
172  break;
173 
175  {
176  fate_frac = hd->Frac(kPdgPiP, kIHAFtInelas, ke);
177  }
178  break;
179 
181  {
182  fate_frac = hd->Frac(kPdgPiP, kIHAFtAbs, ke);
183  }
184  break;
185 
187  {
188  fate_frac = hd->Frac(kPdgPiP, kIHAFtPiProd, ke);
189  }
190  break;
191 
192  //
193  // nucleons
194  //
195 
197  {
198  fate_frac = hd->Frac(kPdgProton, kIHAFtCEx, ke);
199  }
200  break;
201 
203  {
204  fate_frac = hd->Frac(kPdgProton, kIHAFtElas, ke);
205  }
206  break;
207 
209  {
210  fate_frac = hd->Frac(kPdgProton, kIHAFtInelas, ke);
211  }
212  break;
213 
215  {
216  fate_frac = hd->Frac(kPdgProton, kIHAFtAbs, ke);
217  }
218  break;
219 
221  {
222  fate_frac = hd->Frac(kPdgProton, kIHAFtPiProd, ke);
223  }
224  break;
225 
226  default:
227  {
228  LOG("ReW", pDEBUG)
229  << "Have reached default case and assigning fraction{fate} = 0";
230  fate_frac = 0;
231  }
232  break;
233 
234  } // hadron_fate?
235 
236  fate_frac *= frac_scale_factor;
237 
238  return fate_frac;
239 }
240 //____________________________________________________________________________
242  genie::rew::GSyst_t syst, double kinE, double fate_frac)
243 {
244  double fate_frac_nominal = FateFraction(syst,kinE,1.);
245 
246  if(TMath::Abs(fate_frac-fate_frac_nominal) < kASmallNum) return 0;
247 
248  if(fate_frac_nominal <= 0) { return -99999; }
249 
250  double scale = TMath::Max(0.,fate_frac)/fate_frac_nominal;
251  return scale;
252 }
253 //____________________________________________________________________________
255 {
256  Interaction * interaction = event.Summary();
257  assert(interaction);
258 
259  bool is_dis = interaction->ProcInfo().IsDeepInelastic();
260  bool charm = interaction->ExclTag().IsCharmEvent();
261  bool by_agky = is_dis && !charm;
262 
263  return by_agky;
264 }
265 //____________________________________________________________________________
267 {
268 // Check whether the event was hadronized by AGKY/KNO or AGKY/PYTHIA
269 
271  bool found_string = (event.FindParticle(kPdgString, prefragm, 0) != 0);
272  bool found_cluster = (event.FindParticle(kPdgCluster, prefragm, 0) != 0);
273  bool handled_by_pythia = found_string || found_cluster;
274 
275  return handled_by_pythia;
276 }
277 //____________________________________________________________________________
279 {
280  GHepParticle * nu = event.Probe(); // incoming v
281  GHepParticle * N = event.HitNucleon(); // struck nucleon
282  GHepParticle * l = event.FinalStatePrimaryLepton(); // f/s primary lepton
283 
284  assert(nu);
285  assert(N);
286  assert(l);
287 
288  // Compute the Final State Hadronic System 4p (PX = Pv + PN - Pl)
289 
290  const TLorentzVector & p4nu = *(nu->P4());
291  const TLorentzVector & p4N = *(N ->P4());
292  const TLorentzVector & p4l = *(l ->P4());
293 
294  TLorentzVector pX4 = p4nu + p4N - p4l;
295 
296  return pX4;
297 }
298 //____________________________________________________________________________
299 double genie::utils::rew::AGKYWeight(int /*pdgc*/, double /*xF*/, double /*pT2*/)
300 {
301  return 1.0;
302 }
303 //____________________________________________________________________________
304 int genie::utils::rew::Sign(double twkdial)
305 {
306  if(twkdial < 0.) return -1;
307  if(twkdial > 0.) return +1;
308  return 0;
309 }
310 //____________________________________________________________________________
311 
double FZoneWeight(int pdgc, const TLorentzVector &vtx, const TLorentzVector &x4, const TLorentzVector &p4, double A, double Z, double fz_scale_factor, bool interacted, double nRpi=0.5, double nRnuc=1.0, double NR=3, double R0=1.4)
double WhichFateFractionScaleFactor(genie::rew::GSyst_t syst, double kinE, double fate_frac)
tweak inelastic probability for pions, for given total rescattering probability
Definition: GSyst.h:128
#include "Numerical/GSFunc.h"
Definition: AlgCmp.h:26
#define pERROR
Definition: Messenger.h:50
tweak elastic probability for pions, for given total rescattering probability
Definition: GSyst.h:127
enum genie::EGHepStatus GHepStatus_t
static const double MeV
Definition: Units.h:130
TLorentzVector Hadronic4pLAB(const EventRecord &event)
tweak charge exchange probability for nucleons, for given total rescattering probability ...
Definition: GSyst.h:131
double AGKYWeight(int pdgc, double xF, double pT2)
tweak pion production probability for pions, for given total rescattering probability ...
Definition: GSyst.h:130
double Frac(int hpdgc, INukeFateHA_t fate, double ke) const
bool IsCharmEvent(void) const
Definition: XclsTag.h:48
Summary information for an interaction.
Definition: Interaction.h:53
tweak inelastic probability for nucleons, for given total rescattering probability ...
Definition: GSyst.h:133
tweak absorption probability for nucleons, for given total rescattering probability ...
Definition: GSyst.h:134
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:87
bool HadronizedByAGKY(const EventRecord &event)
static double fMinKinEnergy
tweak absorption probability for pions, for given total rescattering probability
Definition: GSyst.h:129
static INukeHadroData * Instance(void)
double ProbSurvival(int pdgc, const TLorentzVector &x4, const TLorentzVector &p4, double A, double Z, double mfp_scale_factor=1.0, double nRpi=0.5, double nRnuc=1.0, double NR=3, double R0=1.4)
Hadron survival probability.
Definition: INukeUtils.cxx:218
const int kPdgPiP
Definition: PDGCodes.h:132
const int kPdgString
Definition: PDGCodes.h:192
static const double kASmallNum
Definition: Controls.h:40
An enumeration of systematic parameters.
#define pINFO
Definition: Messenger.h:53
tweak elastic probability for nucleons, for given total rescattering probability
Definition: GSyst.h:132
Misc GENIE control constants.
double MeanFreePathWeight(int pdgc, const TLorentzVector &x4, const TLorentzVector &p4, double A, double Z, double mfp_scale_factor, bool interacted, double nRpi=0.5, double nRnuc=1.0, double NR=3, double R0=1.4)
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
Definition: EventRecord.h:38
bool IsDeepInelastic(void) const
Definition: ProcessInfo.cxx:98
static const double A
Definition: Units.h:82
bool HadronizedByAGKYPythia(const EventRecord &event)
const XclsTag & ExclTag(void) const
Definition: Interaction.h:69
tweak pion production probability for nucleons, for given total rescattering probability ...
Definition: GSyst.h:135
const ProcessInfo & ProcInfo(void) const
Definition: Interaction.h:67
double FateFraction(genie::rew::GSyst_t syst, double kinE, double frac_scale_factor=1.)
const int kPdgProton
Definition: PDGCodes.h:62
const int kPdgCluster
Definition: PDGCodes.h:191
Singleton class to load & serve hadron x-section splines used by GENIE&#39;s version of the INTRANUKE cascade...
static double fMaxKinEnergyHA
TLorentzVector * P4(void) const
Definition: GHepParticle.h:79
tweak charge exchange probability for pions, for given total rescattering probability ...
Definition: GSyst.h:126
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
STDHEP-like event record entry that can fit a particle or a nucleus.
Definition: GHepParticle.h:40
Event finding and building.
#define pDEBUG
Definition: Messenger.h:54
int Sign(double twkdial)