11 #include <unordered_map> 12 #include <unordered_set> 14 #include "nugen/NuReweight/ReweightLabels.h" 20 #include "NOvARwgt/rwgt/EventRecord.h" 29 const std::unordered_map<rwgt::EReweightLabel, novarwgt::ReweightKnob> RW_KNOB_NAME_MAP
31 {rwgt::fReweightMaCCQE, novarwgt::kKnob_MaCCQE},
32 {rwgt::fReweightMaCCRES, novarwgt::kKnob_MaCCRES},
36 const std::unordered_map<caf::mode_type_, novarwgt::ReactionType>
REACTION_ENUM_MAP 60 const std::unordered_map<caf::generator_, novarwgt::Generator>
GENERATOR_ID_MAP 66 class UnmatchedKnobWarn
69 UnmatchedKnobWarn() =
default;
76 std::cerr <<
"WARNING: no corresponding NOvARwgt knob found for the following rwgt::ReweightLabel indices (found in events):" <<
std::endl;
83 void AddKnob(std::size_t newKnob)
98 "novarwgt::ConvertSRTruth() can only be used with SRNeutrino or SRNeutrinoProxy");
103 static novarwgt::EventRecord sCachedEvt;
106 &&
std::abs(nu->y - sCachedEvt.y) < 0.0001 && (nu->iscc == sCachedEvt.isCC);
108 if (matches && !forceNoCache)
114 for (
const auto &
v : nu->genVersion)
115 sCachedEvt.generatorVersion.push_back(
v);
116 sCachedEvt.generatorConfigStr = nu->genConfigString;
118 sCachedEvt.nupdg = nu->pdg;
119 sCachedEvt.isCC = nu->iscc;
121 sCachedEvt.struckNucl = nu->hitnuc;
123 sCachedEvt.Enu = nu->E;
124 sCachedEvt.q = TLorentzVector(1, 0, 0, nu->y * nu->E);
125 sCachedEvt.q.SetRho(
sqrt(nu->q2 + sCachedEvt.q.E()*sCachedEvt.q.E()));
126 sCachedEvt.y = nu->y;
127 sCachedEvt.W =
sqrt(nu->W2);
129 sCachedEvt.A = nu->tgtA;
131 sCachedEvt.npiplus = nu->npiplus;
132 sCachedEvt.npizero = nu->npizero;
133 sCachedEvt.npiminus = nu->npiminus;
135 for (
const auto &
part : nu->prim)
137 sCachedEvt.fsPartMult[
part.pdg]++;
138 sCachedEvt.fsPartKE[
part.pdg] += (1 - 1./
part.p.Gamma()) *
part.p.E;
149 static UnmatchedKnobWarn
warn;
152 sCachedEvt.genieWeights.resize(novarwgt::kLastKnob);
153 for (std::size_t
idx = 0;
idx < nu->rwgt.genie.size();
idx++)
156 const auto & stdRecWgts = nu->rwgt.genie[
idx];
157 auto rwgtIdx =
static_cast<rwgt::ReweightLabel_t
>(
idx);
161 sCachedEvt.genieWeights[novaRwIdx]
162 = {stdRecWgts.minus2sigma, stdRecWgts.minus1sigma, stdRecWgts.plus1sigma, stdRecWgts.plus2sigma};
164 catch(std::out_of_range &
e)
166 warn.AddKnob(rwgtIdx);
171 sCachedEvt.expectNoWeights =
true;
176 sCachedEvt.expectNoWeights =
true;
192 bool fixZexpKnobs =
false;
193 if (nu->iscc && nu->mode ==
caf::kQE && !sCachedEvt.genieWeights.IsSet(novarwgt::kKnob_ZNormCCQE))
199 for (
const auto &
part : nu->prefsi)
212 const std::vector <novarwgt::ReweightKnob> knobs_to_fix = {
213 novarwgt::kKnob_ZNormCCQE,
214 novarwgt::kKnob_ZExpA1CCQE,
215 novarwgt::kKnob_ZExpA2CCQE,
216 novarwgt::kKnob_ZExpA3CCQE,
217 novarwgt::kKnob_ZExpA4CCQE,
218 novarwgt::kKnob_AxFFCCQEshape
221 for (
const auto &knob : knobs_to_fix)
222 sCachedEvt.genieWeights[knob] = {1.0, 1.0, 1.0, 1.0};
232 template <
typename T>
236 "novarwgt::ConvertSRTruth() can only be used with SRNeutrino or SRNeutrinoProxy");
238 static novarwgt::EventRecord emptyRecord;
mode_type_
Neutrino interaction categories.
Proxy for caf::SRNeutrino.
Proxy for caf::StandardRecord.
const novarwgt::EventRecord & ConvertSREvent(const T *sr, bool forceNoCache)
Copy information out of a StandardRecord.
const std::unordered_map< rwgt::ReweightLabel_t, novarwgt::ReweightKnob > kNugenKnobTranslationTable
The SRNeutrino is a representation of neutrino interaction information.
std::unordered_set< std::size_t > fUnmatchedKnobs
const XML_Char int const XML_Char * value
const std::unordered_map< novarwgt::ReactionType, caf::mode_type_ > REACTION_ENUM_MAP
The StandardRecord is the primary top-level object in the Common Analysis File trees.
const std::unordered_map< novarwgt::Generator, caf::generator_ > GENERATOR_ID_MAP
const novarwgt::EventRecord & ConvertSRTruth(const T *nu, bool forceNoCache)
Copy information out of an SRNeutrino.