GReWeightNonResonanceBkg.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 #include <TMath.h>
26 
27 #include "Algorithm/AlgFactory.h"
29 #include "Conventions/Controls.h"
30 #include "Conventions/Units.h"
31 #include "EVGCore/EventRecord.h"
32 #include "GHEP/GHepParticle.h"
34 #include "Messenger/Messenger.h"
35 #include "PDG/PDGCodes.h"
37 #include "ReWeight/GSystSet.h"
39 
40 using namespace genie;
41 using namespace genie::rew;
42 
43 //_______________________________________________________________________________________
45 {
46  this->Init();
47 }
48 //_______________________________________________________________________________________
50 {
51 
52 }
53 //_______________________________________________________________________________________
55 {
56  bool handle;
57 
58  switch(syst) {
59  case ( kXSecTwkDial_RvpCC1pi ) :
60  case ( kXSecTwkDial_RvpCC2pi ) :
61  case ( kXSecTwkDial_RvpNC1pi ) :
62  case ( kXSecTwkDial_RvpNC2pi ) :
63  case ( kXSecTwkDial_RvnCC1pi ) :
64  case ( kXSecTwkDial_RvnCC2pi ) :
65  case ( kXSecTwkDial_RvnNC1pi ) :
66  case ( kXSecTwkDial_RvnNC2pi ) :
67  case ( kXSecTwkDial_RvbarpCC1pi ) :
68  case ( kXSecTwkDial_RvbarpCC2pi ) :
69  case ( kXSecTwkDial_RvbarpNC1pi ) :
70  case ( kXSecTwkDial_RvbarpNC2pi ) :
71  case ( kXSecTwkDial_RvbarnCC1pi ) :
72  case ( kXSecTwkDial_RvbarnCC2pi ) :
73  case ( kXSecTwkDial_RvbarnNC1pi ) :
74  case ( kXSecTwkDial_RvbarnNC2pi ) :
75 
76  handle = true;
77  break;
78 
79  default:
80  handle = false;
81  break;
82  }
83 
84  return handle;
85 }
86 //_______________________________________________________________________________________
88 {
89  switch(syst) {
90  case ( kXSecTwkDial_RvpCC1pi ) :
91  case ( kXSecTwkDial_RvpCC2pi ) :
92  case ( kXSecTwkDial_RvpNC1pi ) :
93  case ( kXSecTwkDial_RvpNC2pi ) :
94  case ( kXSecTwkDial_RvnCC1pi ) :
95  case ( kXSecTwkDial_RvnCC2pi ) :
96  case ( kXSecTwkDial_RvnNC1pi ) :
97  case ( kXSecTwkDial_RvnNC2pi ) :
98  case ( kXSecTwkDial_RvbarpCC1pi ) :
99  case ( kXSecTwkDial_RvbarpCC2pi ) :
100  case ( kXSecTwkDial_RvbarpNC1pi ) :
101  case ( kXSecTwkDial_RvbarpNC2pi ) :
102  case ( kXSecTwkDial_RvbarnCC1pi ) :
103  case ( kXSecTwkDial_RvbarnCC2pi ) :
104  case ( kXSecTwkDial_RvbarnNC1pi ) :
105  case ( kXSecTwkDial_RvbarnNC2pi ) :
106 
107  fRTwkDial[syst] = twk_dial;
108  break;
109 
110  default:
111  break;
112  }
113 }
114 //_______________________________________________________________________________________
116 {
118  for( ; it != fRTwkDial.end(); ++it) {
119  it->second = 0.;
120  }
121 
122  this->Reconfigure();
123 }
124 //_______________________________________________________________________________________
126 {
128 
130  for( ; it != fRTwkDial.end(); ++it) {
131  GSyst_t syst = it->first;
132  double twk_dial = it->second;
133  double curr = fRDef[syst] * (1 + twk_dial * fracerr->OneSigmaErr(syst));
134  fRCurr[syst] = TMath::Max(0.,curr);
135  }
136 }
137 //_______________________________________________________________________________________
139 {
140  Interaction * interaction = event.Summary();
141 
142  bool is_dis = interaction->ProcInfo().IsDeepInelastic();
143  if(!is_dis) return 1.;
144 
145  bool selected = true;
146  double W = interaction->Kine().W(selected);
147  bool in_transition = (W<fWmin);
148  if(!in_transition) return 1.;
149 
150  int probe = interaction->InitState().ProbePdg();
151  int hitnuc = interaction->InitState().Tgt().HitNucPdg();
152  InteractionType_t itype = interaction->ProcInfo().InteractionTypeId();
153 
154  int nhadmult = 0;
155  int nnuc = 0;
156  int npi = 0;
157 
158  GHepParticle * p = 0;
159  TIter event_iter(&event);
160  while ( (p = dynamic_cast<GHepParticle *>(event_iter.Next())) ) {
161 
162  int pdgc = p->Pdg();
163  int imom = p->FirstMother();
164  if(imom == -1) continue;
165 
166  GHepParticle * mom = event.Particle(imom);
167  if(!mom) continue;
168 
169  if(mom->Pdg() == kPdgHadronicSyst)
170  {
171  nhadmult++;
172  if ( pdg::IsNucleon(pdgc) ) { nnuc++; }
173  if ( pdg::IsPion (pdgc) ) { npi++; }
174  }
175  }//p
176 
177  if(nhadmult < 2 || nhadmult > 3) return 1.;
178  if(nnuc != 1) return 1.;
179 
180  GSyst_t syst = GSyst::RBkg(itype, probe, hitnuc, npi);
181  if(syst == kNullSystematic) return 1.;
182 
183  double curr = fRCurr[syst];
184  double def = fRDef[syst];
185 
186  if(def>0. && curr>=0.) {
187  double wght = curr / def;
188  return wght;
189  }
190 
191  return 1.;
192 }
193 //_______________________________________________________________________________________
195 {
196  this->SetWminCut(2.0*units::GeV);
197 
198  // Get the default parameters
199  AlgConfigPool * conf_pool = AlgConfigPool::Instance();
200  Registry * user_config = conf_pool->GlobalParameterList();
201 
202  fRDef.insert(map<GSyst_t,double>::value_type(
203  kXSecTwkDial_RvpCC1pi, user_config->GetDouble("DIS-HMultWgt-vp-CC-m2" )));
204  fRDef.insert(map<GSyst_t,double>::value_type(
205  kXSecTwkDial_RvpCC2pi, user_config->GetDouble("DIS-HMultWgt-vp-CC-m3" )));
206  fRDef.insert(map<GSyst_t,double>::value_type(
207  kXSecTwkDial_RvpNC1pi, user_config->GetDouble("DIS-HMultWgt-vp-NC-m2" )));
208  fRDef.insert(map<GSyst_t,double>::value_type(
209  kXSecTwkDial_RvpNC2pi, user_config->GetDouble("DIS-HMultWgt-vp-NC-m3" )));
210  fRDef.insert(map<GSyst_t,double>::value_type(
211  kXSecTwkDial_RvnCC1pi, user_config->GetDouble("DIS-HMultWgt-vn-CC-m2" )));
212  fRDef.insert(map<GSyst_t,double>::value_type(
213  kXSecTwkDial_RvnCC2pi, user_config->GetDouble("DIS-HMultWgt-vn-CC-m3" )));
214  fRDef.insert(map<GSyst_t,double>::value_type(
215  kXSecTwkDial_RvnNC1pi, user_config->GetDouble("DIS-HMultWgt-vn-NC-m2" )));
216  fRDef.insert(map<GSyst_t,double>::value_type(
217  kXSecTwkDial_RvnNC2pi, user_config->GetDouble("DIS-HMultWgt-vn-NC-m3" )));
218  fRDef.insert(map<GSyst_t,double>::value_type(
219  kXSecTwkDial_RvbarpCC1pi, user_config->GetDouble("DIS-HMultWgt-vbp-CC-m2")));
220  fRDef.insert(map<GSyst_t,double>::value_type(
221  kXSecTwkDial_RvbarpCC2pi, user_config->GetDouble("DIS-HMultWgt-vbp-CC-m3")));
222  fRDef.insert(map<GSyst_t,double>::value_type(
223  kXSecTwkDial_RvbarpNC1pi, user_config->GetDouble("DIS-HMultWgt-vbp-NC-m2")));
224  fRDef.insert(map<GSyst_t,double>::value_type(
225  kXSecTwkDial_RvbarpNC2pi, user_config->GetDouble("DIS-HMultWgt-vbp-NC-m3")));
226  fRDef.insert(map<GSyst_t,double>::value_type(
227  kXSecTwkDial_RvbarnCC1pi, user_config->GetDouble("DIS-HMultWgt-vbn-CC-m2")));
228  fRDef.insert(map<GSyst_t,double>::value_type(
229  kXSecTwkDial_RvbarnCC2pi, user_config->GetDouble("DIS-HMultWgt-vbn-CC-m3")));
230  fRDef.insert(map<GSyst_t,double>::value_type(
231  kXSecTwkDial_RvbarnNC1pi, user_config->GetDouble("DIS-HMultWgt-vbn-NC-m2")));
232  fRDef.insert(map<GSyst_t,double>::value_type(
233  kXSecTwkDial_RvbarnNC2pi, user_config->GetDouble("DIS-HMultWgt-vbn-NC-m3")));
234 
236  for( ; it != fRDef.end(); ++it) {
237  fRCurr.insert(map<GSyst_t,double>::value_type(it->first, it->second));
238  }
239 }
240 //_______________________________________________________________________________________
double CalcWeight(const EventRecord &event)
calculate a weight for the input event using the current nuisance param values
tweak the 1pi non-RES bkg in the RES region, for v+p CC
Definition: GSyst.h:69
void Reset(void)
set all nuisance parameters to default values
double W(bool selected=false) const
Definition: Kinematics.cxx:167
bool IsPion(int pdgc)
Definition: PDGUtils.cxx:296
tweak the 1pi non-RES bkg in the RES region, for v+p NC
Definition: GSyst.h:71
static GSyst_t RBkg(InteractionType_t itype, int probe, int hitnuc, int npi)
Definition: GSyst.h:499
InteractionType_t InteractionTypeId(void) const
#include "Numerical/GSFunc.h"
Definition: AlgCmp.h:26
void Reconfigure(void)
propagate updated nuisance parameter values to actual MC, etc
int HitNucPdg(void) const
Definition: Target.cxx:311
intermediate_table::iterator iterator
bool IsNucleon(int pdgc)
Definition: PDGUtils.cxx:316
A singleton class holding all configuration registries built while parsing all loaded XML configurati...
Definition: AlgConfigPool.h:41
tweak the 1pi non-RES bkg in the RES region, for vbar+n CC
Definition: GSyst.h:81
RgDbl GetDouble(RgKey key) const
Definition: Registry.cxx:488
double OneSigmaErr(GSyst_t syst, int sign=0) const
int Pdg(void) const
Definition: GHepParticle.h:64
int FirstMother(void) const
Definition: GHepParticle.h:67
Summary information for an interaction.
Definition: Interaction.h:53
tweak the 2pi non-RES bkg in the RES region, for vbar+p NC
Definition: GSyst.h:80
intermediate_table::const_iterator const_iterator
tweak the 2pi non-RES bkg in the RES region, for vbar+n NC
Definition: GSyst.h:84
tweak the 1pi non-RES bkg in the RES region, for v+n CC
Definition: GSyst.h:73
const Kinematics & Kine(void) const
Definition: Interaction.h:68
int ProbePdg(void) const
Definition: InitialState.h:54
tweak the 2pi non-RES bkg in the RES region, for v+n CC
Definition: GSyst.h:74
tweak the 2pi non-RES bkg in the RES region, for vbar+n CC
Definition: GSyst.h:82
An enumeration of systematic parameters.
tweak the 1pi non-RES bkg in the RES region, for vbar+p CC
Definition: GSyst.h:77
tweak the 2pi non-RES bkg in the RES region, for v+p NC
Definition: GSyst.h:72
Registry * GlobalParameterList(void) const
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
p
Definition: test.py:228
tweak the 2pi non-RES bkg in the RES region, for v+n NC
Definition: GSyst.h:76
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:66
tweak the 1pi non-RES bkg in the RES region, for v+n NC
Definition: GSyst.h:75
tweak the 2pi non-RES bkg in the RES region, for vbar+p CC
Definition: GSyst.h:78
double fWmin
W_{min} cut. Reweight only events with W < W_{min}.
const InitialState & InitState(void) const
Definition: Interaction.h:66
const ProcessInfo & ProcInfo(void) const
Definition: Interaction.h:67
bool IsHandled(GSyst_t syst)
does the current weight calculator handle the input nuisance param?
static GSystUncertainty * Instance(void)
const Target & Tgt(void) const
Definition: InitialState.h:56
tweak the 1pi non-RES bkg in the RES region, for vbar+p NC
Definition: GSyst.h:79
static const double GeV
Definition: Units.h:29
const int kPdgHadronicSyst
Definition: PDGCodes.h:181
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
enum genie::EInteractionType InteractionType_t
STDHEP-like event record entry that can fit a particle or a nucleus.
Definition: GHepParticle.h:40
tweak the 2pi non-RES bkg in the RES region, for v+p CC
Definition: GSyst.h:70
tweak the 1pi non-RES bkg in the RES region, for vbar+n NC
Definition: GSyst.h:83
Event finding and building.
static AlgConfigPool * Instance()
void SetSystematic(GSyst_t syst, double val)
update the value for the specified nuisance param