#ifndef filemanager_H #define filemanager_H #include #include #include #include #include "TChain.h" typedef long int runnumber_id; typedef std::string period_id; struct DatasetInformation { std::string name; std::string regex; std::string path; }; class FileManager { public: typedef std::multimap database_type; typedef std::pair bi_iterator; /** * the constructor take an identifier of the data, actually it can be: * * - DATA * - DATAEGAMMA * - DATAL1CALO * - MCJF17 * - MCGAMGAM15 * - MCGAMGAM7 **/ explicit FileManager(const std::string dataset_name = "DATA"); explicit FileManager(const DatasetInformation & dataset_information); /** * all these functions (probably you don't need them) return a couple of * iterators: * std::pair * the first value is the begin(), the second the end() of the space you * want to iterate. Example: * * FileManager::bi_iterator startend = file_manager.get_iterator_from(0); * FileManager::database_type::const_iterator begin = startend.first; * FileManager::database_type::const_iterator end = startend.second; * FileManager::database_type::const_iterator it = begin; * for (; it != end; ++it) * std::cout << "run: " << it->first << " file: " << it->second << std::endl; * **/ bi_iterator get_iterator(runnumber_id runnumber) const; bi_iterator get_iterator_all() const; bi_iterator get_iterator_from(runnumber_id from) const; bi_iterator get_iterator_to(runnumber_id to) const; bi_iterator get_iterator_fromto(runnumber_id from, runnumber_id to) const; bi_iterator get_iterator_period(period_id period) const; /** * all these functions return a std::vector of filenames **/ std::vector get_filename(runnumber_id runnumber) const; std::vector get_filename_all() const; std::vector get_filename_from(runnumber_id from) const; std::vector get_filename_to(runnumber_id to) const; std::vector get_filename_fromto(runnumber_id from, runnumber_id to) const; std::vector get_filename_period(period_id period) const; /** * probably this is what you want. These functions return a TChain* * ready to be used. **/ TChain* get_chain(runnumber_id runnumber) const; TChain* get_chain_all() const; TChain* get_chain_from(runnumber_id from) const; TChain* get_chain_to(runnumber_id to) const; TChain* get_chain_fromto(runnumber_id from, runnumber_id to) const; TChain* get_chain_period(period_id period) const; private: database_type database; std::map datasets_info; DatasetInformation dataset_info; runnumber_id get_runnumber_from_filename(const std::string); void find_files(); void InitDatasetInformation(); void AddDatasetInformation(const DatasetInformation & dataset_information); }; #endif