-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathEventAuxReader.h
More file actions
56 lines (45 loc) · 1.28 KB
/
EventAuxReader.h
File metadata and controls
56 lines (45 loc) · 1.28 KB
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
52
53
54
55
56
#if !defined(EventAuxReader_h)
#define EventAuxReader_h
#include <cassert>
#include "EventIdentifier.h"
#include "art/EventAuxiliary.h"
#include "cms/EventAuxiliary.h"
#include "TBranch.h"
#include "TFile.h"
namespace cce::tf {
inline EventIdentifier cmsEventID(void** address) {
assert(address);
auto aux = *reinterpret_cast<edm::EventAuxiliary**>(address);
return EventIdentifier{aux->run(), aux->luminosityBlock(), aux->event()};
}
inline EventIdentifier artEventID(void** address) {
assert(address);
auto aux = *reinterpret_cast<art::EventAuxiliary**>(address);
return EventIdentifier{aux->run(), aux->subRun(), aux->event()};
}
inline std::function<EventIdentifier(void**)> select_reader(TFile& file)
{
if (file.GetKey("RootFileDB")) {
return artEventID;
}
return cmsEventID;
}
class EventAuxReader {
public:
explicit EventAuxReader(TFile& file)
: func_{select_reader(file)}
{}
EventIdentifier doWork(TBranch* eventAuxBranch)
{
assert(eventAuxBranch);
return doWork(reinterpret_cast<void**>(eventAuxBranch->GetAddress()));
}
EventIdentifier doWork(void** eventAuxBranch)
{
return func_(eventAuxBranch);
}
private:
std::function<EventIdentifier(void**)> func_{};
};
}
#endif