diff --git a/src/Reweight/ModeNormEngine.h b/src/Reweight/ModeNormEngine.h index 4915298..6b5da6f 100644 --- a/src/Reweight/ModeNormEngine.h +++ b/src/Reweight/ModeNormEngine.h @@ -1,82 +1,87 @@ #ifndef ModeNormEngine_H #define ModeNormEngine_H #include "FitLogger.h" #include "GeneratorUtils.h" #include "WeightEngineBase.h" class ModeNormEngine : public WeightEngineBase { public: ModeNormEngine(std::string name = "ModeNormEngine") : fName(name){}; ~ModeNormEngine(){}; void IncludeDial(std::string name, double startval) { int rwenum = Reweight::ConvDial(name, kMODENORM); int mode = Reweight::RemoveDialType(rwenum); if (fDialEnumIndex.count(mode)) { THROW("Mode dial: " << mode << " already included. Cannot include twice."); } fDialEnumIndex[mode] = fDialValues.size(); fDialValues.push_back(startval); QLOG(FIT, "Added mode dial for mode: " << mode); } void SetDialValue(int rwenum, double val) { int mode = Reweight::RemoveDialType(rwenum); if (!fDialEnumIndex.count(mode)) { THROW("Mode dial: " << mode << " has not been included. Cannot set value."); } + QLOG(DEB, "[INFO]: ModeNormEngine ObsMode: " << mode << " weight " << val + << ", rwenum = " << rwenum); fDialValues[fDialEnumIndex[mode]] = val; } void SetDialValue(std::string name, double val) { SetDialValue(Reweight::ConvDial(name, kMODENORM), val); } void Reconfigure(bool silent = false) { (void)silent; } static int ModeToDial(int mode) { return 60 + mode; } double CalcWeight(BaseFitEvt* evt) { int mode = ModeToDial(abs(evt->Mode)); if (!fDialEnumIndex.count(mode)) { return 1; } + QLOG(DEB, "[INFO]: Ev mode " + << evt->Mode << ", ObsMode: " << mode + << ", weight = " << fDialValues[fDialEnumIndex[mode]]); return fDialValues[fDialEnumIndex[mode]]; }; bool NeedsEventReWeight() { return false; }; double GetDialValue(std::string name) { int rwenum = Reweight::ConvDial(name, kMODENORM); int mode = Reweight::RemoveDialType(rwenum); if (fDialEnumIndex.count(mode)) { return fDialValues[fDialEnumIndex[mode]]; } else { return 0xdeadbeef; } } static int SystEnumFromString(std::string const& name) { std::vector splits = GeneralUtils::ParseToStr(name, "_"); if (splits.size() != 2) { ERR(FTL) << "Attempting to parse dial name: \"" << name << "\" as a mode norm dial but failed. Expect e.g. \"mode_2\"." << std::endl; } int mode_num = GeneralUtils::StrToInt(splits[1]); if (!mode_num) { ERR(FTL) << "Attempting to parse dial name: \"" << name << "\" as a mode norm dial but failed." << std::endl; throw; } return ModeToDial(mode_num); } std::map fDialEnumIndex; std::vector fDialValues; std::string fName; }; #endif