#ifndef __JAANET__JEVTWEIGHTDAQ__ #define __JAANET__JEVTWEIGHTDAQ__ #include "km3net-dataformat/definitions/weightlist.hh" #include "km3net-dataformat/offline/Head.hh" #include "km3net-dataformat/offline/Evt.hh" #include "JLang/JException.hh" #include "JLang/JClonable.hh" #include "JAAnet/JHead.hh" #include "JAAnet/JHeadToolkit.hh" #include "JAAnet/JEvtWeight.hh" /** * \author mdejong */ namespace JAANET {} namespace JPP { using namespace JAANET; } namespace JAANET { using JLANG::JClonable; /** * Implementation of event weighing for DAQ data. */ struct JEvtWeightDAQ: public JClonable { /** * Default constructor. */ JEvtWeightDAQ() {} /** * Constructor. * * \param header header */ JEvtWeightDAQ(const JHead& header) { configure(header); } /** * Get name. * * \return name */ virtual const char* const getName() const override { return "DAQ"; } /** * Configuration. * * \param header header */ void configure(const JHead& header) override { using namespace JPP; if (check(header)) { setNormalisation(1.0 / header.DAQ.livetime_s); } else { THROW(JValueOutOfRange, "JEvtWeightDAQ::configure(): Provided header is inconsistent with a DAQ-header."); } } /** * Check whether header is consistent with this event weighter. * * \param header header * \return true if consistent; else false */ bool check(const JHead& header) const override { return is_daq(header); } /** * Get weight of given event. * * \param evt event * \return weight [1/s] */ double getWeight(const Evt& evt) const override { if (evt.w.size() > WEIGHTLIST_RESCALED_EVENT_RATE) { return evt.w[WEIGHTLIST_RESCALED_EVENT_RATE]; } else { return getNormalisation(evt); } } }; } #endif