GenieWeights.cxx
Go to the documentation of this file.
2 
4 
5 #include "Utilities/func/MathUtil.h"
6 
7 
8 namespace ana
9 {
11  ([](const caf::SRNeutrinoProxy *nu)
12  {
13  const std::vector<unsigned int> okVersion({2,11,0});
14  return
15  nu->generator == caf::kUnknownGenerator ||
16  (nu->generator == caf::kGENIE && nu->genVersion < okVersion);
17  });
18 
19  //----------------------------------------------------------------------------
20 
21  const EmpiricalMECWgt2020 * kEmpiricalMECWgt2020_Provisional = novarwgt::GetWeighter<EmpiricalMECWgt2020>();
22  const ValenciaMECWgt2020_Provisional * kValenciaMECWgt2020_Provisional = novarwgt::GetWeighter<ValenciaMECWgt2020_Provisional>();
23 
24  //----------------------------------------------------------------------------
25 
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  }
38 
39  //----------------------------------------------------------------------------
40 
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  }
83 
84  //----------------------------------------------------------------------------
89 
90 
91 }
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
T sqrt(T number)
Definition: d0nt_math.hpp:156
const MINERvA_MEC_Wgt_Var kMINERvA_Wgt_MECNP_NT("MECNP")
"2p2h-np" fit (only &#39;np&#39; component of MEC was fit; &#39;nn&#39; or &#39;pp&#39; (depending on nu vs antinu) left alon...
Definition: GenieWeights.h:235
void abs(TH1 *hist)
const EmpiricalMECWgt2020 * kEmpiricalMECWgt2020_Provisional
GenericCut< caf::SRNeutrinoProxy > NuTruthCut
Cut designed to be used over the nuTree, ie all neutrinos, not just those that got slices...
Definition: Cut.h:104
T sqr(T x)
More efficient square function than pow(x,2)
Definition: MathUtil.h:23
const ValenciaMECWgt2020_Provisional * kValenciaMECWgt2020_Provisional
const novarwgt::HistWrapper< TH2 > fHist_nubar
Definition: GenieWeights.h:216
const MINERvA_MEC_Wgt_Var kMINERvA_Wgt_QE_NT("QE")
"1p1h" fit (QE was fit, MEC disabled)
Definition: GenieWeights.h:227
caf::mode_type_ fRxn
Definition: GenieWeights.h:217
caf::Proxy< SRNeutrino > SRNeutrinoProxy
Definition: FwdDeclare.h:116
std::function< VarFunc_t > fFunc
Definition: Var.h:64
double GetWeight(const caf::SRNeutrinoProxy *sr) const
Draws the weight from the histogram.
const ana::Var wgt
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
const MINERvA_MEC_Wgt_Var kMINERvA_Wgt_MEC_NT("MEC")
"2p2h" fit (all MEC was fit)
Definition: GenieWeights.h:231
const NuTruthCut kIsOldGENIEMEC([](const caf::SRNeutrinoProxy *nu){const std::vector< unsigned int > okVersion({2, 11, 0});return nu->generator==caf::kUnknownGenerator||(nu->generator==caf::kGENIE &&nu->genVersion< okVersion);})
Definition: GenieWeights.h:132
const novarwgt::HistWrapper< TH2 > fHist_nu
Definition: GenieWeights.h:215
const MINERvA_MEC_Wgt_Var kMINERvA_Wgt_MECPP_NT("MECPP")
"2p2h-pp" fit (either &#39;pp&#39; or &#39;nn&#39; component of MEC (depending on nu vs antinu) was fit; &#39;np&#39; left al...
Definition: GenieWeights.h:239
const novarwgt::EventRecord & ConvertSRTruth(const T *nu, bool forceNoCache)
Copy information out of an SRNeutrino.
This module creates Common Analysis Files.
Definition: FileReducer.h:10
const std::string histFile
Definition: GenieWeights.h:207
static constexpr Double_t sr
Definition: Munits.h:164
Template for Var and SpillVar.
Definition: Var.h:16
MINERvA_MEC_Wgt_Var(const std::string &whichWgt)