GReWeightNuXSecCOH.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  Authors: Costas Andreopoulos <costas.andreopoulos \at stfc.ac.uk>
8  University of Liverpool & STFC Rutherford Appleton Lab
9 
10  Jim Dobson <J.Dobson07 \at imperial.ac.uk>
11  Imperial College London
12 
13  For the class documentation see the corresponding header file.
14 
15  Important revisions after version 2.0.0 :
16  @ Aug 01, 2009 - CA
17  Was adapted from Jim's and Costas' T2K-specific GENIE reweighting code.
18  First included in v2.5.1.
19  @ May 17, 2010 - CA
20  Code extracted from GReWeightNuXSec and redeveloped in preparation for
21  the Summer 2010 T2K analyses.
22 
23 */
24 //____________________________________________________________________________
25 
26 #include <TMath.h>
27 
28 #include "Algorithm/AlgFactory.h"
30 #include "Base/XSecAlgorithmI.h"
31 #include "Conventions/Units.h"
32 #include "Conventions/Controls.h"
33 #include "EVGCore/EventRecord.h"
34 #include "GHEP/GHepParticle.h"
36 #include "Messenger/Messenger.h"
37 #include "PDG/PDGCodes.h"
39 #include "ReWeight/GSystSet.h"
41 #include "Registry/Registry.h"
42 
43 using namespace genie;
44 using namespace genie::rew;
45 
46 //_______________________________________________________________________________________
48 {
49  this->Init();
50 }
51 //_______________________________________________________________________________________
53 {
54 
55 }
56 //_______________________________________________________________________________________
58 {
59  bool handle;
60 
61  switch(syst) {
62  case ( kXSecTwkDial_MaCOHpi ) :
63  case ( kXSecTwkDial_R0COHpi ) :
64  handle = true;
65  break;
66  default:
67  handle = false;
68  break;
69  }
70  return handle;
71 }
72 //_______________________________________________________________________________________
73 void GReWeightNuXSecCOH::SetSystematic(GSyst_t syst, double twk_dial)
74 {
75  switch(syst) {
76  case ( kXSecTwkDial_MaCOHpi ) :
77  fMaTwkDial = twk_dial;
78  break;
79  case ( kXSecTwkDial_R0COHpi ) :
80  fR0TwkDial = twk_dial;
81  break;
82  default:
83  break;
84  }
85 }
86 //_______________________________________________________________________________________
88 {
89  fMaTwkDial = 0.;
90  fMaCurr = fMaDef;
91  fR0TwkDial = 0.;
92  fR0Curr = fR0Def;
93 
94  this->Reconfigure();
95 }
96 //_______________________________________________________________________________________
98 {
100 
101  double fracerr_ma = fracerr->OneSigmaErr(kXSecTwkDial_MaCOHpi);
102  double fracerr_r0 = fracerr->OneSigmaErr(kXSecTwkDial_R0COHpi);
103 
104  fMaCurr = fMaDef * (1. + fMaTwkDial * fracerr_ma);
105  fR0Curr = fR0Def * (1. + fR0TwkDial * fracerr_r0);
106 
107  fMaCurr = TMath::Max(0., fMaCurr );
108  fR0Curr = TMath::Max(0., fR0Curr );
109 
111 
112  r.Set(fMaPath, fMaCurr);
113  r.Set(fR0Path, fR0Curr);
114 
115  fXSecModel->Configure(r);
116 
117 //LOG("ReW", pDEBUG) << *fXSecModel;
118 }
119 //_______________________________________________________________________________________
121 {
122  Interaction * interaction = event.Summary();
123 
124  bool is_coh = interaction->ProcInfo().IsCoherent();
125  if(!is_coh) return 1.;
126 
127  bool tweaked =
128  (TMath::Abs(fMaTwkDial) > controls::kASmallNum) ||
129  (TMath::Abs(fR0TwkDial) > controls::kASmallNum);
130  if(!tweaked) return 1.0;
131 
132  bool is_cc = interaction->ProcInfo().IsWeakCC();
133  bool is_nc = interaction->ProcInfo().IsWeakNC();
134  if(is_cc && !fRewCC) return 1.;
135  if(is_nc && !fRewNC) return 1.;
136 
137  int nupdg = interaction->InitState().ProbePdg();
138  if(nupdg==kPdgNuMu && !fRewNumu ) return 1.;
139  if(nupdg==kPdgAntiNuMu && !fRewNumubar) return 1.;
140  if(nupdg==kPdgNuE && !fRewNue ) return 1.;
141  if(nupdg==kPdgAntiNuE && !fRewNuebar ) return 1.;
142 
143  interaction->KinePtr()->UseSelectedKinematics();
144 
145  double old_xsec = event.DiffXSec();
146  double old_weight = event.Weight();
147  double new_xsec = fXSecModel->XSec(interaction, kPSxyfE);
148  double new_weight = old_weight * (new_xsec/old_xsec);
149 
150  interaction->KinePtr()->ClearRunningValues();
151 
152  return new_weight;
153 }
154 //_______________________________________________________________________________________
156 {
157  AlgId id("genie::ReinSehgalCOHPiPXSec","Default");
158 
159  AlgFactory * algf = AlgFactory::Instance();
160  Algorithm * alg = algf->AdoptAlgorithm(id);
161 
162  fXSecModel = dynamic_cast<XSecAlgorithmI*>(alg);
164 
166 //LOG("ReW", pNOTICE) << *fXSecModelConfig;
167 
168  this->RewNue (true);
169  this->RewNuebar (true);
170  this->RewNumu (true);
171  this->RewNumubar(true);
172  this->RewCC (true);
173  this->RewNC (true);
174 
175  this->SetMaPath("Ma");
176  this->SetR0Path("Ro");
177 
178  fMaTwkDial = 0.;
180  fMaCurr = fMaDef;
181  fR0TwkDial = 0.;
183  fR0Curr = fR0Def;
184 }
185 //_______________________________________________________________________________________
186 
187 
bool fRewNuebar
reweight nu_e_bar?
virtual const Registry & GetConfig(void) const
Get configuration registry.
Definition: Algorithm.h:63
Cross Section Calculation Interface.
bool IsWeakCC(void) const
const int kPdgNuE
Definition: PDGCodes.h:25
#include "Numerical/GSFunc.h"
Definition: AlgCmp.h:26
double CalcWeight(const EventRecord &event)
calculate a weight for the input event using the current nuisance param values
Kinematics * KinePtr(void) const
Definition: Interaction.h:73
virtual double XSec(const Interaction *i, KinePhaseSpace_t k=kPSfE) const =0
Compute the cross section for the input interaction.
void SetSystematic(GSyst_t syst, double val)
update the value for the specified nuisance param
const int kPdgAntiNuE
Definition: PDGCodes.h:26
void Reset(void)
set all nuisance parameters to default values
const int kPdgNuMu
Definition: PDGCodes.h:27
Algorithm abstract base class.
Definition: Algorithm.h:48
RgDbl GetDouble(RgKey key) const
Definition: Registry.cxx:488
double OneSigmaErr(GSyst_t syst, int sign=0) const
Summary information for an interaction.
Definition: Interaction.h:53
void UseSelectedKinematics(void)
Definition: Kinematics.cxx:369
bool IsHandled(GSyst_t syst)
does the current weight calculator handle the input nuisance param?
bool IsWeakNC(void) const
virtual void Configure(const Registry &config)
Configure the algorithm.
Definition: Algorithm.cxx:70
int ProbePdg(void) const
Definition: InitialState.h:54
static const double kASmallNum
Definition: Controls.h:40
tweak R0 for COH pion production
Definition: GSyst.h:67
An enumeration of systematic parameters.
void AdoptSubstructure(void)
Definition: Algorithm.cxx:287
Algorithm * AdoptAlgorithm(const AlgId &algid) const
Definition: AlgFactory.cxx:127
const int kPdgAntiNuMu
Definition: PDGCodes.h:28
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
Definition: EventRecord.h:38
Algorithm ID (algorithm name + configuration set name)
Definition: AlgId.h:35
bool fRewNumubar
reweight nu_mu_bar?
static AlgFactory * Instance()
Definition: AlgFactory.cxx:75
string fMaPath
M_{A} path in config Registry.
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:66
const InitialState & InitState(void) const
Definition: Interaction.h:66
tweak Ma for COH pion production
Definition: GSyst.h:66
const ProcessInfo & ProcInfo(void) const
Definition: Interaction.h:67
static GSystUncertainty * Instance(void)
string fR0Path
R_{0} path in config Registry.
void ClearRunningValues(void)
Definition: Kinematics.cxx:357
void Reconfigure(void)
propagate updated nuisance parameter values to actual MC, etc
The GENIE Algorithm Factory.
Definition: AlgFactory.h:40
void Set(RgIMapPair entry)
Definition: Registry.cxx:281
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
Event finding and building.
bool IsCoherent(void) const