#ifndef __JAANET__JEVTWEIGHTDAQ__ #define __JAANET__JEVTWEIGHTDAQ__ #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 { using JLANG::JClonable; using JLANG::JValueOutOfRange; /** * Implementation of event weighing for DAQ data. */ struct JEvtWeightDAQ: public JClonable { /** * Default constructor. */ JEvtWeightDAQ() {} /** * Constructor. * * \param header header */ JEvtWeightDAQ(const JHead& header) { configure(header); } /** * Configuration. * * \param header header * \return true if okay; else false */ void configure(const JHead& header) override { if (check(header) && header.DAQ.livetime_s > 0.0) { norm = 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 { return norm; } }; } #endif