GReWeightNuXSecCCQEvec.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  @ May 24, 2010 - CA
17  First included in v2.7.1.
18 
19 */
20 //____________________________________________________________________________
21 
22 #include <cassert>
23 
24 #include <TMath.h>
25 #include <TFile.h>
26 #include <TNtupleD.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 
42 using namespace genie;
43 using namespace genie::rew;
44 
45 //_______________________________________________________________________________________
47 {
48  this->Init();
49 }
50 //_______________________________________________________________________________________
52 {
53 #ifdef _G_REWEIGHT_CCQE_VEC_DEBUG_
54  fTestFile->cd();
55  fTestNtp ->Write();
56  fTestFile->Close();
57  delete fTestFile;
58 #endif
59 }
60 //_______________________________________________________________________________________
62 {
63  switch(syst) {
64  case ( kXSecTwkDial_VecFFCCQEshape ) :
65  return true;
66  break;
67  default:
68  return false;
69  break;
70  }
71  return false;
72 }
73 //_______________________________________________________________________________________
75 {
76  if(!this->IsHandled(syst)) return;
77 
78  switch(syst) {
79  case ( kXSecTwkDial_VecFFCCQEshape ) :
80  fFFTwkDial = twk_dial;
81  break;
82  default:
83  return;
84  }
85 }
86 //_______________________________________________________________________________________
88 {
89  fFFTwkDial = 0.;
90 }
91 //_______________________________________________________________________________________
93 {
94 
95 }
96 //_______________________________________________________________________________________
98 {
99  bool tweaked = (TMath::Abs(fFFTwkDial) > controls::kASmallNum);
100  if(!tweaked) return 1.;
101 
102  Interaction * interaction = event.Summary();
103 
104  bool is_qe = interaction->ProcInfo().IsQuasiElastic();
105  bool is_cc = interaction->ProcInfo().IsWeakCC();
106  if(!is_qe || !is_cc) return 1.;
107 
108  bool charm = interaction->ExclTag().IsCharmEvent(); // skip CCQE charm
109  if(charm) return 1.;
110 
111  int nupdg = event.Probe()->Pdg();
112  if(nupdg==kPdgNuMu && !fRewNumu ) return 1.;
113  if(nupdg==kPdgAntiNuMu && !fRewNumubar) return 1.;
114  if(nupdg==kPdgNuE && !fRewNue ) return 1.;
115  if(nupdg==kPdgAntiNuE && !fRewNuebar ) return 1.;
116 
117  //
118  // Calculate weight
119  // Input tweaking dial changes elastic nucleon form factors
120  // (twk dial: 0 -> default/BBA, twk dial: 1 -> dipole).
121  // Calculated weight includes `shape only effect in dsigma/dQ2
122  // (normalized to constant integrated cross section)
123  //
124 
125  interaction->KinePtr()->UseSelectedKinematics();
126  interaction->SetBit(kIAssumeFreeNucleon);
127 
128  double dial = fFFTwkDial;
129  double old_weight = event.Weight();
130  double def_xsec = event.DiffXSec();
131  double dpl_xsec = fXSecModel_dpl->XSec(interaction, kPSQ2fE);
132  double def_integrated_xsec = fXSecModel_bba->Integral(interaction);
133  double dpl_integrated_xsec = fXSecModel_dpl->Integral(interaction);
134 
135  assert(def_integrated_xsec > 0.);
136  assert(dpl_integrated_xsec > 0.);
137 // if(def_integrated_xsec <= 0 || dpl_integrated_xsec <= 0) return 1.;
138 
139  double def_ratio = def_xsec / def_integrated_xsec;
140  double dpl_ratio = dpl_xsec / dpl_integrated_xsec;
141 
142  assert(def_ratio > 0.);
143 // if(def_ratio <= 0) return 1.;
144 
145  double weight = old_weight * (dial * dpl_ratio + (1-dial)*def_ratio) / def_ratio;
146 
147 #ifdef _G_REWEIGHT_CCQE_VEC_DEBUG_
148  double E = interaction->InitState().ProbeE(kRfHitNucRest);
149  double Q2 = interaction->Kine().Q2(true);
150  fTestNtp->Fill(
151  E,Q2,weight,def_integrated_xsec,dpl_integrated_xsec,def_xsec,dpl_xsec);
152 #endif
153 
154 
155  return weight;
156 }
157 //_______________________________________________________________________________________
159 {
160  AlgFactory * algf = AlgFactory::Instance();
161 
162  AlgId id0("genie::LwlynSmithQELCCPXSec","Default");
163  Algorithm * alg0 = algf->AdoptAlgorithm(id0);
164  fXSecModel_bba = dynamic_cast<XSecAlgorithmI*>(alg0);
166 
167  AlgId id1("genie::LwlynSmithQELCCPXSec","DipoleELFF");
168  Algorithm * alg1 = algf->AdoptAlgorithm(id1);
169  fXSecModel_dpl = dynamic_cast<XSecAlgorithmI*>(alg1);
171 
172  this->RewNue (true);
173  this->RewNuebar (true);
174  this->RewNumu (true);
175  this->RewNumubar(true);
176 
177  fFFTwkDial = 0.;
178 
179 #ifdef _G_REWEIGHT_CCQE_VEC_DEBUG_
180  fTestFile = new TFile("./ccqevec_reweight_test.root","recreate");
181  fTestNtp = new TNtupleD("testntp","","E:Q2:wght:sig0:sig:dsig0:dsig");
182 #endif
183 
184 }
185 //_______________________________________________________________________________________
186 
Cross Section Calculation Interface.
void SetSystematic(GSyst_t syst, double val)
update the value for the specified nuisance param
bool IsWeakCC(void) const
const int kPdgNuE
Definition: PDGCodes.h:25
#include "Numerical/GSFunc.h"
Definition: AlgCmp.h:26
XSecAlgorithmI * fXSecModel_dpl
CCQE model with dipole f/f ("maximally" tweaked)
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
bool IsCharmEvent(void) const
Definition: XclsTag.h:48
Summary information for an interaction.
Definition: Interaction.h:53
void UseSelectedKinematics(void)
Definition: Kinematics.cxx:369
double fFFTwkDial
tweaking dial (0: bba/default, +1: dipole)
virtual double Integral(const Interaction *i) const =0
const Kinematics & Kine(void) const
Definition: Interaction.h:68
double CalcWeight(const EventRecord &event)
calculate a weight for the input event using the current nuisance param values
XSecAlgorithmI * fXSecModel_bba
CCQE model with BBA05 f/f (default)
void Reconfigure(void)
propagate updated nuisance parameter values to actual MC, etc
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
const int kPdgAntiNuMu
Definition: PDGCodes.h:28
tweak elastic nucleon form factors (BBA/default -> dipole) - shape only effect of dsigma(CCQE)/dQ2 ...
Definition: GSyst.h:53
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
void Reset(void)
set all nuisance parameters to default values
const UInt_t kIAssumeFreeNucleon
Definition: Interaction.h:46
const XclsTag & ExclTag(void) const
Definition: Interaction.h:69
bool IsHandled(GSyst_t syst)
does the current weight calculator handle the input nuisance param?
bool fRewNuebar
reweight nu_e_bar CC?
bool fRewNumubar
reweight nu_mu_bar CC?
const InitialState & InitState(void) const
Definition: Interaction.h:66
const ProcessInfo & ProcInfo(void) const
Definition: Interaction.h:67
weight
Definition: test.py:293
double Q2(bool selected=false) const
Definition: Kinematics.cxx:135
The GENIE Algorithm Factory.
Definition: AlgFactory.h:40
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.