#ifndef __JAANET__JEVTWEIGHTFACTORGSEAGEN__ #define __JAANET__JEVTWEIGHTFACTORGSEAGEN__ #include "km3net-dataformat/definitions/w2list_gseagen.hh" #include "km3net-dataformat/offline/Evt.hh" #include "km3net-dataformat/offline/Trk.hh" #include "JLang/JClonable.hh" #include "JLang/JException.hh" #include "JAAnet/JEvtWeightFactorTFormula.hh" /** * \author bjung */ namespace JAANET {} namespace JPP { using namespace JAANET; } namespace JAANET { using JLANG::JClonable; /** * Implementation of reweighting factor for simulated neutrino interactions according to a specifiable ROOT TFormula. * * Note: The ROOT TFormula may assume any number of parameters, but should be restricted to\n * the physical variables listed among `JEvtWeightFactorGSeaGen::variables`.\n * These variables may be specified within the ROOT TFormula as 'x[\]',\n * where \ corresponds to the index of the desired physical variable within `JEvtWeightFactorGSeaGen::variables`. */ class JEvtWeightFactorGSeaGen final : public JClonable { public: /** * Indices of reweighting variables for GSeaGen. */ enum variables { COSTH, //!< Cosine zenith angle INITIAL_STATE_ENERGY, //!< Initial state energy NEUTRINO_ENERGY, //!< Initial state neutrino energy FINAL_STATE_ENERGY, //!< Final state energy LEADING_LEPTON_ENERGY, //!< Final state leading lepton energy BJORKEN_X, //!< Björken-x (= fractional momentum carried by the struck nucleon) INELASTICITY, //!< Inelasticity (= Björken-y) INTERACTION_TYPE, //!< Interaction channel type CURRENT_TYPE, //!< Weak current type (CC or NC) XSEC, //!< Exclusive total cross-section of the interaction XSEC_MEAN, //!< Average interaction cross-section per nucleon along neutrino path [m2] XSEC_DIFFERENTIAL, //!< Differential cross-section of the interaction XSEC_WATER, //!< Inclusive cross-section in water INT_LENGTH_WATER, //!< Interaction length in pure water COLUMN_DEPTH, //!< Column density [m.w.e] P_EARTH, //!< Earth transmission probability P_SCALE, //!< GENIE ineraction probability scale TARGET_A, //!< Number of nucleons in the target TARGET_Z, //!< Number of protons in the target NUMBER_OF_VARIABLES //!< Number of reweighting variables; \n //!< N.B.\ This enum value needs to be specified last! }; /** * Default constructor. */ JEvtWeightFactorGSeaGen() {} /** * Check whether this formula is valid. * * \return true if valid; else false */ bool is_valid() const override final { const int N = getFormula().GetNpar(); return N >= 0 && N <= (int) NUMBER_OF_VARIABLES; } /** * Get weighting factor for given event. * * \param evt event * \return weighting factor */ double getFactor(const Evt& evt) const override final { using namespace std; using namespace JPP; Double_t vars[NUMBER_OF_VARIABLES] = { 0.0 }; const Trk& neutrino = get_neutrino (evt); const Trk& leading_lepton = get_leading_lepton(evt); vars[COSTH] = neutrino.dir.z; vars[INITIAL_STATE_ENERGY] = getE0(evt); vars[NEUTRINO_ENERGY] = neutrino.E; vars[FINAL_STATE_ENERGY] = getE1(evt); vars[LEADING_LEPTON_ENERGY] = leading_lepton.E; vars[BJORKEN_X] = evt.w2list[W2LIST_GSEAGEN_BX]; vars[INELASTICITY] = evt.w2list[W2LIST_GSEAGEN_BY]; vars[INTERACTION_TYPE] = evt.w2list[W2LIST_GSEAGEN_ICHAN]; vars[CURRENT_TYPE] = evt.w2list[W2LIST_GSEAGEN_CC]; vars[XSEC] = evt.w2list[W2LIST_GSEAGEN_XSEC]; vars[XSEC_MEAN] = evt.w2list[W2LIST_GSEAGEN_XSEC_MEAN]; vars[XSEC_DIFFERENTIAL] = evt.w2list[W2LIST_GSEAGEN_DXSEC]; vars[XSEC_WATER] = evt.w2list[W2LIST_GSEAGEN_WATERXSEC]; vars[INT_LENGTH_WATER] = evt.w2list[W2LIST_GSEAGEN_WATER_INT_LEN]; vars[COLUMN_DEPTH] = evt.w2list[W2LIST_GSEAGEN_COLUMN_DEPTH]; vars[P_EARTH] = evt.w2list[W2LIST_GSEAGEN_P_EARTH]; vars[P_SCALE] = evt.w2list[W2LIST_GSEAGEN_P_SCALE]; vars[TARGET_A] = evt.w2list[W2LIST_GSEAGEN_TARGETA]; vars[TARGET_Z] = evt.w2list[W2LIST_GSEAGEN_TARGETZ]; return getFormula().EvalPar(&vars[0]); } }; } #endif