#ifndef __JAANET__JAANETDICTIONARY__ #define __JAANET__JAANETDICTIONARY__ #include "km3net-dataformat/offline/Head.hh" #include "JROOT/JRootDictionary.hh" #include "JROOT/JRootStreamer.hh" #include "JAAnet/JHead.hh" /** * \author mdejong */ namespace JAANET { using JROOT::JRootReader; using JROOT::JRootWriter; using JROOT::JRootDictionary; /** * Auxiliary class for reading multiple entries in Monte Carlo header with same tag into single std::vector. */ template struct JMultipleTagsStreamer { /** * Read object. * * \param reader ROOT reader * \param object object * \return ROOT reader */ static JRootReader& getObject(JRootReader& reader, std::vector& object) { JElement_t element; reader.getObject(element); object.push_back(element); return reader; } /** * Write object. * * \param writer ROOT writer * \param object object * \return ROOT writer */ static JRootWriter& putObject(JRootWriter& writer, const std::vector& object) { return writer.putObject(object); } /** * Write given key and value according equation format. * * \param writer ROOT writer * \param key key * \param value value * \return ROOT writer */ static JRootWriter& put(JRootWriter& writer, const std::string& key, const std::vector& value) { for (typename std::vector::const_iterator i = value.begin(); i != value.end(); ++i) { writer.put(key, *i); } return writer; } }; /** * Simple wrapper class around JROOT::JRootDictionary so that other classes are included by construction, */ class JAAnetDictionary : public JRootDictionary { private: /** * Default constructor. */ JAAnetDictionary() : JRootDictionary(JRootDictionary::getInstance()) { add(); add(); add(); add(); add(); add< std::vector >(); add< std::vector >(); add< std::vector >(); add< std::vector >(); } public: /** * Get reference to unique instance of this class object. * This JROOT::JRootDictionary object includes the various Monte Carlo data types. * * \return reference to this class object */ static JRootDictionary& getInstance() { static JAAnetDictionary dictionary; return dictionary; } }; } namespace JROOT { using JAANET::JMultipleTagsStreamer; /** * Specialisation of JROOT::JRootStreamer for JAANET::JHead::detector. */ template<> struct JRootStreamer< std::vector > : public JMultipleTagsStreamer {}; /** * Specialisation of JROOT::JRootStreamer for JAANET::JHead::physics. */ template<> struct JRootStreamer< std::vector > : public JMultipleTagsStreamer {}; /** * Specialisation of JROOT::JRootStreamer for JAANET::JHead::simul. */ template<> struct JRootStreamer< std::vector > : public JMultipleTagsStreamer {}; /** * Specialisation of JROOT::JRootStreamer for JAANET::JHead::flux. */ template<> struct JRootStreamer< std::vector > : public JMultipleTagsStreamer {}; } #endif