File indexing completed on 2024-11-19 23:20:31
0001 #include "eventindexmap.h"
0002
0003 using namespace RooUtil;
0004
0005 RooUtil::EventIndexMap::EventIndexMap() {}
0006 RooUtil::EventIndexMap::~EventIndexMap() {}
0007
0008
0009 void RooUtil::EventIndexMap::load(TString filename) {
0010 eventlistmap_.clear();
0011
0012 std::ifstream ifile;
0013 ifile.open(filename.Data());
0014 std::string line;
0015
0016 while (std::getline(ifile, line)) {
0017 std::string cms4path;
0018 int number_of_events;
0019 TEventList* event_indexs = new TEventList(cms4path.c_str());
0020 unsigned int event_index;
0021
0022 std::stringstream ss(line);
0023
0024 ss >> cms4path >> number_of_events;
0025
0026 for (int ii = 0; ii < number_of_events; ++ii) {
0027 ss >> event_index;
0028 event_indexs->Enter(event_index);
0029 }
0030
0031 eventlistmap_[cms4path] = event_indexs;
0032 }
0033 }
0034
0035
0036 bool RooUtil::EventIndexMap::hasEventList(TString cms4file) {
0037 return eventlistmap_.find(cms4file) != eventlistmap_.end();
0038 }
0039
0040
0041 TEventList* RooUtil::EventIndexMap::getEventList(TString cms4file) {
0042 if (not hasEventList(cms4file))
0043 error(TString::Format("Does not have the event list for the input %s but asked for it!", cms4file.Data()),
0044 __FUNCTION__);
0045
0046 return eventlistmap_[cms4file];
0047 }