Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes | List of all members
ana::MINERvA_MEC_Wgt_Var Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-28/CAFAna/Vars/GenieWeights.h"

Inheritance diagram for ana::MINERvA_MEC_Wgt_Var:
ana::_Var< T >

Public Types

typedef double( VarFunc_t) (const T *sr)
 The type of the function part of a var. More...
 

Public Member Functions

 MINERvA_MEC_Wgt_Var (const std::string &whichWgt)
 
double operator() (const T *sr) const
 Allows a variable to be called with double value = myVar(sr) syntax. More...
 
int ID () const
 Vars with the same definition will have the same ID. More...
 
_Cut< Toperator< (double c) const
 
_Cut< Toperator< (const _Var< T > &v) const
 
_Cut< Toperator> (double c) const
 
_Cut< Toperator> (const _Var< T > &v) const
 
_Cut< Toperator>= (double c) const
 
_Cut< Toperator>= (const _Var< T > &v) const
 
_Cut< Toperator<= (double c) const
 
_Cut< Toperator<= (const _Var< T > &v) const
 
_Cut< Toperator== (double c) const
 
_Cut< Toperator== (const _Var< T > &v) const
 
_Cut< Toperator!= (double c) const
 
_Cut< Toperator!= (const _Var< T > &v) const
 
_Var< Toperator* (const _Var< T > &v) const
 
_Var< Toperator/ (const _Var< T > &v) const
 
_Var< Toperator+ (const _Var< T > &v) const
 
_Var< Toperator- (const _Var< T > &v) const
 

Static Public Member Functions

static int MaxID ()
 

Protected Attributes

std::function< VarFunc_tfFunc
 
int fID
 

Static Protected Attributes

static int fgNextID = 0
 The next ID that hasn't yet been assigned. More...
 

Private Member Functions

double GetWeight (const caf::SRNeutrinoProxy *sr) const
 Draws the weight from the histogram. More...
 

Private Attributes

const std::string histFile = FindCAFAnaDir() + "/data/xs/MINERvA_MEC_wgts.root"
 
const novarwgt::HistWrapper< TH2 > fHist_nu
 
const novarwgt::HistWrapper< TH2 > fHist_nubar
 
caf::mode_type_ fRxn
 
int fHitNuc
 

Detailed Description

Implementation of various reweight schemes from MINERvA which attempt to fit to the excess in their data under different MEC hypotheses. There are four choices, each of which much be applied under different circumstances:

These are as publicized by R. Gran at NuInt 2017, https://meetings.triumf.ca/indico/event/6/session/4/contribution/77 Citation forthcoming. (Weight functions from K. McFarland in private communication to J. Wolcott.) They live here, rather than in NOvARwgt, because we don't have permission to distribute them.

Definition at line 205 of file GenieWeights.h.

Member Typedef Documentation

template<class T>
typedef double( ana::_Var< T >::VarFunc_t) (const T *sr)
inherited

The type of the function part of a var.

Definition at line 18 of file Var.h.

Constructor & Destructor Documentation

ana::MINERvA_MEC_Wgt_Var::MINERvA_MEC_Wgt_Var ( const std::string whichWgt)

Definition at line 26 of file GenieWeights.cxx.

References ana::_Var< T >::fFunc, fHist_nu, fHist_nubar, fHitNuc, fRxn, GetWeight(), histFile, caf::kMEC, caf::kQE, and sr.

27  : NuTruthVar([](const caf::SRNeutrinoProxy * sr){ return -5; }), // will be overridden shortly, but "this" ptr doesn't exist yet
28  fHist_nu ( histFile, whichWgt ),
29  fHist_nubar( histFile, "anti" + whichWgt ),
30  fRxn( whichWgt == "QE" ? caf::kQE : caf::kMEC ),
31  fHitNuc( whichWgt == "MECNP" ? 2000000201 : (whichWgt == "MECPP" ? -2000000201 : 0))
32  {
33  fFunc = [this](const caf::SRNeutrinoProxy * sr)
34  {
35  return this->GetWeight(sr);
36  };
37  }
std::function< VarFunc_t > fFunc
Definition: Var.h:62
Proxy for caf::SRNeutrino.
Definition: SRProxy.h:510
const novarwgt::HistWrapper< TH2 > fHist_nubar
Definition: GenieWeights.h:216
caf::mode_type_ fRxn
Definition: GenieWeights.h:217
_Var< caf::SRNeutrinoProxy > NuTruthVar
Var designed to be used over the nuTree, ie all neutrinos, not just those that got slices...
Definition: Var.h:82
caf::StandardRecord * sr
double GetWeight(const caf::SRNeutrinoProxy *sr) const
Draws the weight from the histogram.
const novarwgt::HistWrapper< TH2 > fHist_nu
Definition: GenieWeights.h:215
const std::string histFile
Definition: GenieWeights.h:207

Member Function Documentation

double ana::MINERvA_MEC_Wgt_Var::GetWeight ( const caf::SRNeutrinoProxy sr) const
private

Draws the weight from the histogram.

Definition at line 41 of file GenieWeights.cxx.

References abs(), novarwgt::ConvertSRTruth(), caf::Proxy< caf::SRNeutrino >::E, fHist_nu, fHist_nubar, fHitNuc, fRxn, analysePickle::hist, caf::Proxy< caf::SRNeutrino >::hitnuc, caf::Proxy< caf::SRNeutrino >::iscc, ana::kMINERvA_Wgt_MEC_NT, ana::kMINERvA_Wgt_MECNP_NT, ana::kMINERvA_Wgt_MECPP_NT, ana::kMINERvA_Wgt_QE_NT, caf::kQE, caf::Proxy< caf::SRNeutrino >::mode, caf::Proxy< caf::SRNeutrino >::pdg, caf::Proxy< caf::SRNeutrino >::q2, util::sqr(), std::sqrt(), wgt, and caf::Proxy< caf::SRNeutrino >::y.

Referenced by MINERvA_MEC_Wgt_Var().

42  {
43  // MINERvA weights only tuned for CC
44  if (!sr->iscc)
45  return 1.;
46 
47  // one of the weights is for QE. Make sure we're doing it right
48  if (sr->mode != fRxn)
49  return 1.;
50 
51  // in the 'QE' weight, MEC has to be disabled
52  if (fRxn == caf::kQE && sr->mode == caf::kMEC)
53  return 0;
54 
55  // some variants adjust specific nucleon-nucleon pairs
56  if (fHitNuc > 0 && sr->hitnuc != fHitNuc)
57  return 1.;
58  else if (fHitNuc < 0 && sr->hitnuc == abs(fHitNuc))
59  return 1.;
60 
61  double wgt = 1;
62 
63  // we convert Dytman-MEC to Valencia-MEC to be compatible w/ MINERvA base model
64  if (sr->mode == caf::kMEC)
65  wgt *= novarwgt::GetWeighter<novarwgt::EmpiricalMEC_to_Valencia_Wgt>()->GetWeight(novarwgt::ConvertSRTruth(sr), {});
66 
67  double q0 = sr->E * sr->y;
68  double qmag = sqrt(sr->q2 + util::sqr(q0));
69  bool isAntiNu = sr->pdg < 0;
70 
71  if (qmag <= 0) // how??
72  return 1.;
73 
74  const novarwgt::HistWrapper<TH2> & hist = (isAntiNu) ? fHist_nubar : fHist_nu;
75  // the histograms contain the *correction*, not the weight.
76  // that is: 0 means "no change", not "no event".
77  // thus need to add 1 to get the weight.
78  // also, pin to bins 1-40 since 41 and above are empty
79  wgt *= 1 + hist.GetValueInRange(qmag, q0/qmag, {1, 40});
80 
81  return wgt;
82  }
T sqrt(T number)
Definition: d0nt_math.hpp:156
void abs(TH1 *hist)
caf::Proxy< int > mode
Definition: SRProxy.h:543
caf::Proxy< float > E
Definition: SRProxy.h:520
caf::Proxy< int > hitnuc
Definition: SRProxy.h:532
T sqr(T x)
More efficient square function than pow(x,2)
Definition: MathUtil.h:23
const novarwgt::HistWrapper< TH2 > fHist_nubar
Definition: GenieWeights.h:216
caf::mode_type_ fRxn
Definition: GenieWeights.h:217
caf::Proxy< bool > iscc
Definition: SRProxy.h:538
double GetWeight(const caf::SRNeutrinoProxy *sr) const
Draws the weight from the histogram.
const ana::Var wgt
caf::Proxy< float > y
Definition: SRProxy.h:577
const novarwgt::HistWrapper< TH2 > fHist_nu
Definition: GenieWeights.h:215
caf::Proxy< float > q2
Definition: SRProxy.h:557
caf::Proxy< short int > pdg
Definition: SRProxy.h:552
const novarwgt::EventRecord & ConvertSRTruth(const T *nu, bool forceNoCache)
Copy information out of an SRNeutrino.
template<class T>
int ana::_Var< T >::ID ( ) const
inlineinherited

Vars with the same definition will have the same ID.

Definition at line 36 of file Var.h.

Referenced by ana::SpectrumLoaderBase::GetSinkSCW(), ana::_Var< T >::operator*(), ana::_Var< T >::operator+(), ana::_Var< T >::operator-(), and ana::_Var< T >::operator/().

36 {return fID;}
int fID
Definition: Var.h:64
template<class T>
static int ana::_Var< T >::MaxID ( )
inlinestaticinherited

Definition at line 38 of file Var.h.

38 {return fgNextID-1;}
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: Var.h:66
template<class T>
_Cut<T> ana::_Var< T >::operator!= ( double  c) const
inherited
template<class T>
_Cut<T> ana::_Var< T >::operator!= ( const _Var< T > &  v) const
inherited
template<class T>
double ana::_Var< T >::operator() ( const T sr) const
inlineinherited

Allows a variable to be called with double value = myVar(sr) syntax.

Definition at line 30 of file Var.h.

Referenced by ana::Constant(), ana::_Var< T >::operator*(), ana::_Var< T >::operator+(), ana::_Var< T >::operator-(), ana::_Var< T >::operator/(), ana::Scaled(), and ana::Sqrt().

31  {
32  return fFunc(sr);
33  }
std::function< VarFunc_t > fFunc
Definition: Var.h:62
caf::StandardRecord * sr
template<class T>
_Var< T > ana::_Var< T >::operator* ( const _Var< T > &  v) const
inherited

Definition at line 339 of file Var.cxx.

References a, b, ana::_Var< T >::fgNextID, ana::_Var< T >::ID(), PandAna.Demos.tute_pid_validation::ids, findDuplicateFiles::key, ana::_Var< T >::operator()(), ana::_Var< T >::operator/(), sr, and T.

Referenced by ana::_Var< caf::SRProxy >::MaxID(), and ana::Sqrt().

340  {
341  static std::map<std::pair<int, int>, int> ids;
342  const std::pair<int, int> key(ID(), v.ID());
343 
344  struct Times
345  {
346  const _Var<T> a, b;
347  double operator()(const T* sr) const {return a(sr) * b(sr);}
348  };
349 
350  if(ids.count(key) == 0) ids[key] = fgNextID++;
351  return _Var<T>(Times{*this, v});
352  }
int ID() const
Vars with the same definition will have the same ID.
Definition: Var.h:36
const double a
double operator()(const T *sr) const
Allows a variable to be called with double value = myVar(sr) syntax.
Definition: Var.h:30
caf::StandardRecord * sr
const hit & b
Definition: hits.cxx:21
double T
Definition: Xdiff_gwt.C:5
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: Var.h:66
template<class T>
_Var< T > ana::_Var< T >::operator+ ( const _Var< T > &  v) const
inherited

Definition at line 380 of file Var.cxx.

References a, b, ana::_Var< T >::fgNextID, ana::_Var< T >::ID(), PandAna.Demos.tute_pid_validation::ids, findDuplicateFiles::key, ana::_Var< T >::operator()(), ana::_Var< T >::operator-(), sr, and T.

Referenced by ana::_Var< caf::SRProxy >::MaxID(), and ana::_Var< T >::operator/().

381  {
382  static std::map<std::pair<int, int>, int> ids;
383  const std::pair<int, int> key(ID(), v.ID());
384 
385  struct Plus
386  {
387  const _Var<T> a, b;
388  double operator()(const T* sr) const {return a(sr) + b(sr);}
389  };
390 
391  if(ids.count(key) == 0) ids[key] = fgNextID++;
392  return _Var<T>(Plus{*this, v}, ids[key]);
393  }
int ID() const
Vars with the same definition will have the same ID.
Definition: Var.h:36
const double a
double operator()(const T *sr) const
Allows a variable to be called with double value = myVar(sr) syntax.
Definition: Var.h:30
caf::StandardRecord * sr
const hit & b
Definition: hits.cxx:21
double T
Definition: Xdiff_gwt.C:5
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: Var.h:66
template<class T>
_Var< T > ana::_Var< T >::operator- ( const _Var< T > &  v) const
inherited

Definition at line 397 of file Var.cxx.

References a, b, ana::_Var< T >::fgNextID, ana::_Var< T >::ID(), PandAna.Demos.tute_pid_validation::ids, findDuplicateFiles::key, ana::_Var< T >::operator()(), sr, and T.

Referenced by ana::_Var< caf::SRProxy >::MaxID(), and ana::_Var< T >::operator+().

398  {
399  static std::map<std::pair<int, int>, int> ids;
400  const std::pair<int, int> key(ID(), v.ID());
401 
402  struct Minus
403  {
404  const _Var<T> a, b;
405  double operator()(const T* sr) const {return a(sr) - b(sr);}
406  };
407 
408  if(ids.count(key) == 0) ids[key] = fgNextID++;
409  return _Var<T>(Minus{*this, v}, ids[key]);
410  }
int ID() const
Vars with the same definition will have the same ID.
Definition: Var.h:36
const double a
double operator()(const T *sr) const
Allows a variable to be called with double value = myVar(sr) syntax.
Definition: Var.h:30
caf::StandardRecord * sr
const hit & b
Definition: hits.cxx:21
double T
Definition: Xdiff_gwt.C:5
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: Var.h:66
template<class T>
_Var< T > ana::_Var< T >::operator/ ( const _Var< T > &  v) const
inherited

Definition at line 356 of file Var.cxx.

References a, b, Divide(), ana::_Var< T >::fgNextID, ana::_Var< T >::ID(), PandAna.Demos.tute_pid_validation::ids, findDuplicateFiles::key, ana::_Var< T >::operator()(), ana::_Var< T >::operator+(), sr, and T.

Referenced by ana::_Var< caf::SRProxy >::MaxID(), and ana::_Var< T >::operator*().

357  {
358  static std::map<std::pair<int, int>, int> ids;
359  const std::pair<int, int> key(ID(), v.ID());
360 
361  struct Divide
362  {
363  const _Var<T> a, b;
364  double operator()(const T* sr) const
365  {
366  const double denom = b(sr);
367  if(denom != 0)
368  return a(sr) / denom;
369  else
370  return 0.0;
371  }
372  };
373 
374  if(ids.count(key) == 0) ids[key] = fgNextID++;
375  return _Var<T>(Divide{*this, v}, ids[key]);
376  }
ratio_hxv Divide(hxv, goal_hxv)
int ID() const
Vars with the same definition will have the same ID.
Definition: Var.h:36
const double a
double operator()(const T *sr) const
Allows a variable to be called with double value = myVar(sr) syntax.
Definition: Var.h:30
caf::StandardRecord * sr
const hit & b
Definition: hits.cxx:21
double T
Definition: Xdiff_gwt.C:5
static int fgNextID
The next ID that hasn&#39;t yet been assigned.
Definition: Var.h:66
template<class T>
_Cut<T> ana::_Var< T >::operator< ( double  c) const
inherited
template<class T>
_Cut<T> ana::_Var< T >::operator< ( const _Var< T > &  v) const
inherited
template<class T>
_Cut<T> ana::_Var< T >::operator<= ( double  c) const
inherited
template<class T>
_Cut<T> ana::_Var< T >::operator<= ( const _Var< T > &  v) const
inherited
template<class T>
_Cut<T> ana::_Var< T >::operator== ( double  c) const
inherited
template<class T>
_Cut<T> ana::_Var< T >::operator== ( const _Var< T > &  v) const
inherited
template<class T>
_Cut<T> ana::_Var< T >::operator> ( double  c) const
inherited
template<class T>
_Cut<T> ana::_Var< T >::operator> ( const _Var< T > &  v) const
inherited
template<class T>
_Cut<T> ana::_Var< T >::operator>= ( double  c) const
inherited
template<class T>
_Cut<T> ana::_Var< T >::operator>= ( const _Var< T > &  v) const
inherited

Member Data Documentation

template<class T>
std::function<VarFunc_t> ana::_Var< T >::fFunc
protectedinherited
template<class T>
int ana::_Var< T >::fgNextID = 0
staticprotectedinherited

The next ID that hasn't yet been assigned.

Definition at line 66 of file Var.h.

Referenced by ana::_Var< caf::SRProxy >::MaxID(), ana::_Var< T >::operator*(), ana::_Var< T >::operator+(), ana::_Var< T >::operator-(), and ana::_Var< T >::operator/().

const novarwgt::HistWrapper<TH2> ana::MINERvA_MEC_Wgt_Var::fHist_nu
private

Definition at line 215 of file GenieWeights.h.

Referenced by GetWeight(), and MINERvA_MEC_Wgt_Var().

const novarwgt::HistWrapper<TH2> ana::MINERvA_MEC_Wgt_Var::fHist_nubar
private

Definition at line 216 of file GenieWeights.h.

Referenced by GetWeight(), and MINERvA_MEC_Wgt_Var().

int ana::MINERvA_MEC_Wgt_Var::fHitNuc
private

which nucleon pair to adjust. >0 means 'adjust pair with this pdg code'; <0 means 'adjust anything but pairs with this pdg code; 0 means 'do nothing'

Definition at line 223 of file GenieWeights.h.

Referenced by GetWeight(), and MINERvA_MEC_Wgt_Var().

template<class T>
int ana::_Var< T >::fID
protectedinherited
caf::mode_type_ ana::MINERvA_MEC_Wgt_Var::fRxn
private

Definition at line 217 of file GenieWeights.h.

Referenced by GetWeight(), and MINERvA_MEC_Wgt_Var().

const std::string ana::MINERvA_MEC_Wgt_Var::histFile = FindCAFAnaDir() + "/data/xs/MINERvA_MEC_wgts.root"
private

Definition at line 207 of file GenieWeights.h.

Referenced by MINERvA_MEC_Wgt_Var().


The documentation for this class was generated from the following files: