-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy patheventindexmap.cc
51 lines (38 loc) · 1.41 KB
/
eventindexmap.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "eventindexmap.h"
RooUtil::EventIndexMap::EventIndexMap() {}
RooUtil::EventIndexMap::~EventIndexMap() {}
//_____________________________________________________________________________________
void RooUtil::EventIndexMap::load(TString filename)
{
eventlistmap_.clear();
std::ifstream ifile;
ifile.open(filename.Data());
std::string line;
while (std::getline(ifile, line))
{
std::string cms4path;
int number_of_events;
TEventList* event_indexs = new TEventList(cms4path.c_str());
unsigned int event_index;
std::stringstream ss(line);
ss >> cms4path >> number_of_events;
for (int ii = 0; ii < number_of_events; ++ii)
{
ss >> event_index;
event_indexs->Enter(event_index);
}
eventlistmap_[cms4path] = event_indexs;
}
}
//_____________________________________________________________________________________
bool RooUtil::EventIndexMap::hasEventList(TString cms4file)
{
return eventlistmap_.find(cms4file) != eventlistmap_.end();
}
//_____________________________________________________________________________________
TEventList* RooUtil::EventIndexMap::getEventList(TString cms4file)
{
if (not hasEventList(cms4file))
error(TString::Format("Does not have the event list for the input %s but asked for it!", cms4file.Data()), __FUNCTION__);
return eventlistmap_[cms4file];
}