GReWeightNuXSecNCEL.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  For the class documentation see the corresponding header file.
11 
12  Important revisions after version 2.0.0 :
13  @ Nov 25, 2010 - CA
14  First included in v2.7.1. Added option to reweight NCEL axial mass M_{A}
15  and the strange axial form factor eta.
16 */
17 //____________________________________________________________________________
18 
19 #include <TMath.h>
20 #include <TFile.h>
21 #include <TNtupleD.h>
22 
23 #include "Algorithm/AlgFactory.h"
25 #include "Base/XSecAlgorithmI.h"
26 #include "Conventions/Units.h"
27 #include "Conventions/Controls.h"
28 #include "EVGCore/EventRecord.h"
29 #include "GHEP/GHepParticle.h"
31 #include "Messenger/Messenger.h"
32 #include "PDG/PDGCodes.h"
34 #include "ReWeight/GSystSet.h"
37 #include "Registry/Registry.h"
38 
39 using namespace genie;
40 using namespace genie::rew;
41 
42 //_______________________________________________________________________________________
44 {
45  this->Init();
46 }
47 //_______________________________________________________________________________________
49 {
50 #ifdef _G_REWEIGHT_NCEL_DEBUG_
51  fTestFile->cd();
52  fTestNtp ->Write();
53  fTestFile->Close();
54  delete fTestFile;
55 #endif
56 }
57 //_______________________________________________________________________________________
59 {
60  bool handle;
61  switch(syst) {
62  case ( kXSecTwkDial_MaNCEL ) : handle = true; break;
63  case ( kXSecTwkDial_EtaNCEL ) : handle = true; break;
64  default:
65  handle = false;
66  break;
67  }
68  return handle;
69 }
70 //_______________________________________________________________________________________
71 void GReWeightNuXSecNCEL::SetSystematic(GSyst_t syst, double twk_dial)
72 {
73  if(!this->IsHandled(syst)) return;
74 
75  switch(syst) {
76  case ( kXSecTwkDial_MaNCEL ) :
77  fMaTwkDial = twk_dial;
78  break;
79  case ( kXSecTwkDial_EtaNCEL ) :
80  fEtaTwkDial = twk_dial;
81  break;
82  default:
83  break;
84  }
85 }
86 //_______________________________________________________________________________________
88 {
89  fMaTwkDial = 0.;
90  fMaCurr = fMaDef;
91  fEtaTwkDial = 0.;
92  fEtaCurr = fEtaDef;
93 
94  this->Reconfigure();
95 }
96 //_______________________________________________________________________________________
98 {
100 
101  int sign_matwk = utils::rew::Sign(fMaTwkDial );
102  int sign_etatwk = utils::rew::Sign(fEtaTwkDial);
103 
104  double fracerr_ma = fracerr->OneSigmaErr(kXSecTwkDial_MaNCEL, sign_matwk );
105  double fracerr_eta = fracerr->OneSigmaErr(kXSecTwkDial_EtaNCEL, sign_etatwk);
106 
107  fMaCurr = fMaDef * (1. + fMaTwkDial * fracerr_ma);
108  fEtaCurr = fEtaDef * (1. + fEtaTwkDial * fracerr_eta);
109 
110  fMaCurr = TMath::Max(0., fMaCurr );
111  fEtaCurr = TMath::Max(0., fEtaCurr );
112 
114 
115  r.Set(fMaPath, fMaCurr );
116  r.Set(fEtaPath, fEtaCurr);
117  fXSecModel->Configure(r);
118 
119 //LOG("ReW, pDEBUG) << *fXSecModel;
120 }
121 //_______________________________________________________________________________________
123 {
124  Interaction * interaction = event.Summary();
125 
126  bool is_qe = interaction->ProcInfo().IsQuasiElastic();
127  bool is_nc = interaction->ProcInfo().IsWeakNC();
128  if(!is_qe || !is_nc) return 1.;
129 
130  int nupdg = event.Probe()->Pdg();
131  if(nupdg==kPdgNuMu && !fRewNumu ) return 1.;
132  if(nupdg==kPdgAntiNuMu && !fRewNumubar) return 1.;
133  if(nupdg==kPdgNuE && !fRewNue ) return 1.;
134  if(nupdg==kPdgAntiNuE && !fRewNuebar ) return 1.;
135 
136  bool tweaked_ma = (TMath::Abs(fMaTwkDial ) > controls::kASmallNum);
137  bool tweaked_eta = (TMath::Abs(fEtaTwkDial) > controls::kASmallNum);
138  bool tweaked = tweaked_ma || tweaked_eta;
139  if(!tweaked) return 1.0;
140 
141  interaction->KinePtr()->UseSelectedKinematics();
142  interaction->SetBit(kIAssumeFreeNucleon);
143 
144  double old_xsec = event.DiffXSec();
145  double old_weight = event.Weight();
146  double new_xsec = fXSecModel->XSec(interaction, kPSQ2fE);
147  double new_weight = old_weight * (new_xsec/old_xsec);
148 
149 //LOG("ReW", pDEBUG) << "differential cross section (old) = " << old_xsec;
150 //LOG("ReW", pDEBUG) << "differential cross section (new) = " << new_xsec;
151 //LOG("ReW", pDEBUG) << "event generation weight = " << old_weight;
152 //LOG("ReW", pDEBUG) << "new weight = " << new_weight;
153 
154 #ifdef _G_REWEIGHT_NCEL_DEBUG_
155  double E = interaction->InitState().ProbeE(kRfHitNucRest);
156  double Q2 = interaction->Kine().Q2(true);
157  fTestNtp->Fill(E,Q2,new_weight);
158 #endif
159 
160  interaction->KinePtr()->ClearRunningValues();
161  interaction->ResetBit(kIAssumeFreeNucleon);
162 
163  return new_weight;
164 }
165 //_______________________________________________________________________________________
167 {
168  AlgId id("genie::AhrensNCELPXSec","Default");
169 
170  AlgFactory * algf = AlgFactory::Instance();
171 
172  Algorithm * algdef = algf->AdoptAlgorithm(id);
173  fXSecModelDef = dynamic_cast<XSecAlgorithmI*>(algdef);
175 
176  Algorithm * alg = algf->AdoptAlgorithm(id);
177  fXSecModel = dynamic_cast<XSecAlgorithmI*>(alg);
179 
181 //LOG("ReW", pDEBUG) << *fXSecModelConfig;
182 
183  this->RewNue (true);
184  this->RewNuebar (true);
185  this->RewNumu (true);
186  this->RewNumubar(true);
187 
188  this->SetMaPath ("Ma");
189  this->SetEtaPath("Eta");
190 
191  fMaTwkDial = 0.;
193  fMaCurr = fMaDef;
194  fEtaTwkDial = 0.;
196  fEtaCurr = fEtaDef;
197 
198 #ifdef _G_REWEIGHT_NCEL_DEBUG_
199  fTestFile = new TFile("./ncel_reweight_test.root","recreate");
200  fTestNtp = new TNtupleD("testntp","","E:Q2:wght");
201 #endif
202 }
203 //_______________________________________________________________________________________
virtual const Registry & GetConfig(void) const
Get configuration registry.
Definition: Algorithm.h:63
Cross Section Calculation Interface.
bool fRewNumu
reweight nu_mu CC?
tweak NCEL strange axial form factor eta, affects dsigma(NCEL)/dQ2 both in shape and normalization ...
Definition: GSyst.h:47
void Reconfigure(void)
propagate updated nuisance parameter values to actual MC, etc
const int kPdgNuE
Definition: PDGCodes.h:25
#include "Numerical/GSFunc.h"
Definition: AlgCmp.h:26
void SetSystematic(GSyst_t syst, double val)
update the value for the specified nuisance param
bool IsHandled(GSyst_t syst)
does the current weight calculator handle the input nuisance param?
double Q2(const Interaction *const i)
Definition: KineUtils.cxx:642
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.
bool IsQuasiElastic(void) const
Definition: ProcessInfo.cxx:88
const int kPdgAntiNuE
Definition: PDGCodes.h:26
const int kPdgNuMu
Definition: PDGCodes.h:27
Algorithm abstract base class.
Definition: Algorithm.h:48
void Reset(void)
set all nuisance parameters to default values
tweak Ma NCEL, affects dsigma(NCEL)/dQ2 both in shape and normalization
Definition: GSyst.h:46
RgDbl GetDouble(RgKey key) const
Definition: Registry.cxx:488
Registry * fXSecModelConfig
config in tweaked model
XSecAlgorithmI * fXSecModel
tweaked model
bool fRewNuebar
reweight nu_e_bar CC?
double OneSigmaErr(GSyst_t syst, int sign=0) const
XSecAlgorithmI * fXSecModelDef
default model
Summary information for an interaction.
Definition: Interaction.h:53
void UseSelectedKinematics(void)
Definition: Kinematics.cxx:369
bool IsWeakNC(void) const
double CalcWeight(const EventRecord &event)
calculate a weight for the input event using the current nuisance param values
const Kinematics & Kine(void) const
Definition: Interaction.h:68
virtual void Configure(const Registry &config)
Configure the algorithm.
Definition: Algorithm.cxx:70
string fEtaPath
eta path in config Registry
static const double kASmallNum
Definition: Controls.h:40
An enumeration of systematic parameters.
void AdoptSubstructure(void)
Definition: Algorithm.cxx:287
Algorithm * AdoptAlgorithm(const AlgId &algid) const
Definition: AlgFactory.cxx:127
string fMaPath
M_{A} path in config Registry.
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
static AlgFactory * Instance()
Definition: AlgFactory.cxx:75
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:66
const UInt_t kIAssumeFreeNucleon
Definition: Interaction.h:46
const InitialState & InitState(void) const
Definition: Interaction.h:66
const ProcessInfo & ProcInfo(void) const
Definition: Interaction.h:67
static GSystUncertainty * Instance(void)
double Q2(bool selected=false) const
Definition: Kinematics.cxx:135
void ClearRunningValues(void)
Definition: Kinematics.cxx:357
The GENIE Algorithm Factory.
Definition: AlgFactory.h:40
void Set(RgIMapPair entry)
Definition: Registry.cxx:281
double ProbeE(RefFrame_t rf) const
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
Event finding and building.
bool fRewNumubar
reweight nu_mu_bar CC?
int Sign(double twkdial)