forked from kvtsang/Supera
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LArCVSuperaDriver.cxx
98 lines (77 loc) · 2.85 KB
/
LArCVSuperaDriver.cxx
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#ifndef LARCVSUPERADRIVER_CXX
#define LARCVSUPERADRIVER_CXX
#include "LArCVSuperaDriver.h"
namespace larcv {
LArCVSuperaDriver::LArCVSuperaDriver()
: _driver("ProcessDriver")
, _supera_chstatus_ptr(nullptr)
{}
void LArCVSuperaDriver::SetCSV(std::string proc_name, std::string fname)
{
auto const pid = _driver.process_id(proc_name);
if(pid >= _driver.process_names().size()) {
LARCV_CRITICAL() << "Invalid process name (" << proc_name << ") to set CSV file for..." << std::endl;
throw larbys();
}
((SuperaBase*)(_driver.process_ptr(pid)))->SetCSV(fname);
}
void LArCVSuperaDriver::configure(const std::string cfg_file)
{
_driver.configure(cfg_file);
}
void LArCVSuperaDriver::configure(const larcv::PSet& cfg)
{
_driver.configure(cfg);
}
void LArCVSuperaDriver::override_input_file(const std::vector<std::string>& flist)
{
_driver.override_input_file(flist);
}
void LArCVSuperaDriver::override_output_file(const std::string fname)
{
_driver.override_output_file(fname);
}
SuperaChStatus* LArCVSuperaDriver::SuperaChStatusPointer()
{ return _supera_chstatus_ptr; }
const std::set<std::string>& LArCVSuperaDriver::DataLabels(supera::LArDataType_t type) const
{
static std::set<std::string> empty_string;
auto iter = _data_request_m.find(type);
if(iter == _data_request_m.end()) return empty_string;
return (*iter).second;
}
void LArCVSuperaDriver::initialize() {
_driver.initialize();
_supera_idx_v.clear();
for(size_t idx=0; idx<_driver.process_names().size(); ++idx) {
auto proc_ptr = _driver.process_ptr(idx);
if(proc_ptr->is("SuperaMetaMaker") && idx) {
LARCV_CRITICAL() << "SuperaMetaMaker must be the first module!" << std::endl;
throw larbys();
}
if(proc_ptr->is("Supera") || proc_ptr->is("SuperaMetaMaker")) {
_supera_idx_v.push_back(idx);
for(size_t data_type=0; data_type<(size_t)(supera::LArDataType_t::kLArDataTypeMax); ++data_type) {
auto const& label = ((SuperaBase*)proc_ptr)->LArDataLabel((supera::LArDataType_t)data_type);
if(label.empty()) continue;
_data_request_m[(supera::LArDataType_t)(data_type)].insert(label);
}
}
if(_driver.process_ptr(idx)->is("SuperaChStatus")) {
_supera_chstatus_ptr = (SuperaChStatus*)(_driver.process_ptr(idx));
for(size_t data_type=0; data_type<(size_t)(supera::LArDataType_t::kLArDataTypeMax); ++data_type) {
auto const& label = _supera_chstatus_ptr->LArDataLabel((supera::LArDataType_t)data_type);
if(label.empty()) continue;
_data_request_m[(supera::LArDataType_t)(data_type)].insert(label);
}
}
}
}
bool LArCVSuperaDriver::process(size_t run, size_t subrun, size_t event)
{
_driver.set_id(run,subrun,event);
return _driver.process_entry();
}
void LArCVSuperaDriver::finalize() { _driver.finalize(); }
}
#endif