#ifndef __JSUPPORT_JHEADSET__ #define __JSUPPORT_JHEADSET__ #include #include #include #include "km3net-dataformat/offline/Head.hh" #include "JLang/JException.hh" #include "JAAnet/JHead.hh" #include "JAAnet/JHeadToolkit.hh" #include "JSupport/JMonteCarloFileSupportkit.hh" namespace JSUPPORT {} namespace JPP { using namespace JSUPPORT; } namespace JSUPPORT { using JLANG::JValueOutOfRange; /** * Auxiliary class for organising Monte Carlo run headers. */ template > struct JHeadSet : std::vector { /** * Default constructor. */ JHeadSet() {} /** * Constructor. * * \param input file list */ JHeadSet(JMultipleFileScanner_t& input) { put(input); } /** * Put headers from given list of files. * * \param input file list */ void put(JMultipleFileScanner_t& input) { for (JMultipleFileScanner_t::const_iterator i = input.begin(); i != input.end(); ++i) { this->put(*i); } } /** * Put header from given file. * * \param input file name */ void put(const std::string& input) { using namespace std; using namespace JPP; const JHead head = getHeader(input); iterator p = lower_bound(this->begin(), this->end(), head, compare); if (p != this->end() && *p == head) p->add(head); else this->insert(p, head); } /** * Get header for given file. * * \param input file name */ const JHead& get(const std::string& input) const { const JHead head = getHeader(input); const_iterator p = lower_bound(this->begin(), this->end(), head, compare); if (p != this->end()) return *p; else THROW(JValueOutOfRange, "No corresponding header for file " << input); } /** * Function object for comparison of headers. */ JComparator_t compare; }; } #endif