GReWeightNuXSecCCQEaxial.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  STFC, Rutherford Appleton Laboratory
9 
10  Jim Dobson <J.Dobson07 \at imperial.ac.uk>
11  Imperial College London
12 
13  Aaron Meyer <asmeyer \at uchicago.edu>
14  University of Chicago/Fermilab
15 
16  For the class documentation see the corresponding header file.
17 
18  Important revisions after version 2.0.0 :
19  @ Dec 14, 2015 - AM
20  First version, based on GReWeightNuXSecCCQEvec.cxx
21 
22 */
23 //____________________________________________________________________________
24 
25 #include <cassert>
26 
27 #include <TMath.h>
28 #include <TFile.h>
29 #include <TNtupleD.h>
30 
31 #include "Algorithm/AlgFactory.h"
33 #include "Base/XSecAlgorithmI.h"
34 #include "Conventions/Units.h"
35 #include "Conventions/Controls.h"
36 #include "EVGCore/EventRecord.h"
37 #include "GHEP/GHepParticle.h"
39 #include "Messenger/Messenger.h"
40 #include "PDG/PDGCodes.h"
42 #include "ReWeight/GSystSet.h"
44 
45 //#define _G_REWEIGHT_CCQE_AXFF_DEBUG_
46 
47 using namespace genie;
48 using namespace genie::rew;
49 
50 //_______________________________________________________________________________________
52 {
53  this->Init();
54 }
55 //_______________________________________________________________________________________
57 {
58 #ifdef _G_REWEIGHT_CCQE_AXFF_DEBUG_
59  fTestFile->cd();
60  fTestNtp ->Write();
61  fTestFile->Close();
62  delete fTestFile;
63 #endif
64 }
65 //_______________________________________________________________________________________
67 {
68  switch(syst) {
69  case ( kXSecTwkDial_AxFFCCQEshape ) :
70  return true;
71  break;
72  default:
73  return false;
74  break;
75  }
76  return false;
77 }
78 //_______________________________________________________________________________________
80 {
81  if(!this->IsHandled(syst)) return;
82 
83  switch(syst) {
84  case ( kXSecTwkDial_AxFFCCQEshape ) :
85  fFFTwkDial = twk_dial;
86  break;
87  default:
88  return;
89  }
90 }
91 //_______________________________________________________________________________________
93 {
94  fFFTwkDial = 0.;
95 }
96 //_______________________________________________________________________________________
98 {
99 
100 }
101 //_______________________________________________________________________________________
103 {
104  bool tweaked = (TMath::Abs(fFFTwkDial) > controls::kASmallNum);
105  if(!tweaked) return 1.;
106 
107  Interaction * interaction = event.Summary();
108 
109  bool is_qe = interaction->ProcInfo().IsQuasiElastic();
110  bool is_cc = interaction->ProcInfo().IsWeakCC();
111  if(!is_qe || !is_cc) return 1.;
112 
113  bool charm = interaction->ExclTag().IsCharmEvent(); // skip CCQE charm
114  if(charm) return 1.;
115 
116  int nupdg = event.Probe()->Pdg();
117  if(nupdg==kPdgNuMu && !fRewNumu ) return 1.;
118  if(nupdg==kPdgAntiNuMu && !fRewNumubar) return 1.;
119  if(nupdg==kPdgNuE && !fRewNue ) return 1.;
120  if(nupdg==kPdgAntiNuE && !fRewNuebar ) return 1.;
121 
122  //
123  // Calculate weight
124  // Input tweaking dial changes elastic nucleon form factors
125  // (twk dial: 0 -> default/dipole, twk dial: 1 -> zexp).
126  // Calculated weight includes `shape only effect in dsigma/dQ2
127  // (normalized to constant integrated cross section)
128  //
129 
130  interaction->KinePtr()->UseSelectedKinematics();
131  interaction->SetBit(kIAssumeFreeNucleon);
132 
133  double dial = fFFTwkDial;
134  double old_weight = event.Weight();
135  double def_xsec = event.DiffXSec();
136  double zexp_xsec = fXSecModel_zexp->XSec(interaction, kPSQ2fE);
137  //double def_integrated_xsec = fXSecModel_dpl->Integral(interaction);
138  //double zexp_integrated_xsec = fXSecModel_zexp->Integral(interaction);
139 
140  //assert(def_integrated_xsec > 0.);
141  //assert(zexp_integrated_xsec > 0.);
142 // if(def_integrated_xsec <= 0 || zexp_integrated_xsec <= 0) return 1.;
143 
144  //double def_ratio = def_xsec / def_integrated_xsec;
145  //double zexp_ratio = zexp_xsec / zexp_integrated_xsec;
146  double def_ratio = def_xsec ;
147  double zexp_ratio = zexp_xsec;
148 
149  assert(def_ratio > 0.);
150 // if(def_ratio <= 0) return 1.;
151 
152  double weight = old_weight * (dial * zexp_ratio + (1-dial)*def_ratio) / def_ratio;
153 
154 #ifdef _G_REWEIGHT_CCQE_AXFF_DEBUG_
155  double E = interaction->InitState().ProbeE(kRfHitNucRest);
156  double Q2 = interaction->Kine().Q2(true);
157  fTestNtp->Fill(
158  E,Q2,weight,def_integrated_xsec,zexp_integrated_xsec,def_xsec,zexp_xsec);
159 #endif
160 
161 
162  return weight;
163 }
164 //_______________________________________________________________________________________
166 {
167  double chisq = TMath::Power(fFFTwkDial, 2.);
168  return chisq;
169 }
170 //_______________________________________________________________________________________
172 {
173  AlgFactory * algf = AlgFactory::Instance();
174 
175  AlgId id0("genie::LwlynSmithQELCCPXSec","Default");
176  Algorithm * alg0 = algf->AdoptAlgorithm(id0);
177  fXSecModel_dpl = dynamic_cast<XSecAlgorithmI*>(alg0);
179 
180  AlgId id1("genie::LwlynSmithQELCCPXSec","ZExp");
181  Algorithm * alg1 = algf->AdoptAlgorithm(id1);
182  fXSecModel_zexp = dynamic_cast<XSecAlgorithmI*>(alg1);
184 
185  this->RewNue (true);
186  this->RewNuebar (true);
187  this->RewNumu (true);
188  this->RewNumubar(true);
189 
190  fFFTwkDial = 0.;
191 
192 #ifdef _G_REWEIGHT_CCQE_AXFF_DEBUG_
193  fTestFile = new TFile("./ccqeaxil_reweight_test.root","recreate");
194  fTestNtp = new TNtupleD("testntp","","E:Q2:wght:sig0:sig:dsig0:dsig");
195 #endif
196 
197 }
198 //_______________________________________________________________________________________
199 
Cross Section Calculation Interface.
bool IsWeakCC(void) const
const int kPdgNuE
Definition: PDGCodes.h:25
double CalcWeight(const EventRecord &event)
calculate a weight for the input event using the current nuisance param values
#include "Numerical/GSFunc.h"
Definition: AlgCmp.h:26
double Q2(const Interaction *const i)
Definition: KineUtils.cxx:642
Kinematics * KinePtr(void) const
Definition: Interaction.h:73
double fFFTwkDial
tweaking dial (0: bba/default, +1: dipole)
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
bool IsQuasiElastic(void) const
Definition: ProcessInfo.cxx:88
const int kPdgAntiNuE
Definition: PDGCodes.h:26
const int kPdgNuMu
Definition: PDGCodes.h:27
XSecAlgorithmI * fXSecModel_dpl
CCQE model with dipole f/f (default)
tweak axial nucleon form factors (dipole -> z-expansion) - shape only effect of dsigma(CCQE)/dQ2 ...
Definition: GSyst.h:161
Algorithm abstract base class.
Definition: Algorithm.h:48
void Reset(void)
set all nuisance parameters to default values
bool IsCharmEvent(void) const
Definition: XclsTag.h:48
Summary information for an interaction.
Definition: Interaction.h:53
void UseSelectedKinematics(void)
Definition: Kinematics.cxx:369
const Kinematics & Kine(void) const
Definition: Interaction.h:68
XSecAlgorithmI * fXSecModel_zexp
CCQE model with z-expansion f/f ("maximally" tweaked)
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
void Reconfigure(void)
propagate updated nuisance parameter values to actual MC, etc
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
const UInt_t kIAssumeFreeNucleon
Definition: Interaction.h:46
const XclsTag & ExclTag(void) const
Definition: Interaction.h:69
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
bool IsHandled(GSyst_t syst)
does the current weight calculator handle the input nuisance param?
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.