forked from kvtsang/Supera
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SuperaBase.cxx
143 lines (107 loc) · 5.63 KB
/
SuperaBase.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#ifndef __SUPERABASE_CXX__
#define __SUPERABASE_CXX__
#include "SuperaBase.h"
namespace larcv {
static SuperaBaseProcessFactory __global_SuperaBaseProcessFactory__;
SuperaBase::SuperaBase(const std::string name)
: ProcessBase(name)
, _empty_string()
{ ClearEventData(); }
void SuperaBase::Request(supera::LArDataType_t type, std::string name)
{ _data_request_m[type]=name; }
const std::string& SuperaBase::LArDataLabel(supera::LArDataType_t type) const
{
auto iter = _data_request_m.find(type);
if(iter == _data_request_m.end()) return _empty_string;
return (*iter).second;
}
void SuperaBase::configure(const PSet& cfg)
{
_time_offset = cfg.get<int>("TimeOffset",2400);
auto producer_wire = cfg.get<std::string>("LArWireProducer", "");
auto producer_hit = cfg.get<std::string>("LArHitProducer", "");
auto producer_opdigit = cfg.get<std::string>("LArOpDigitProducer", "");
auto producer_mctruth = cfg.get<std::string>("LArMCTruthProducer", "");
auto producer_mctrack = cfg.get<std::string>("LArMCTrackProducer", "");
auto producer_mcshower = cfg.get<std::string>("LArMCShowerProducer","");
auto producer_simch = cfg.get<std::string>("LArSimChProducer", "");
if(!producer_wire.empty() ) {
LARCV_INFO() << "Requesting Wire data product by " << producer_wire << std::endl;
Request(supera::LArDataType_t::kLArWire_t, producer_wire);
}
if(!producer_hit.empty() ) {
LARCV_INFO() << "Requesting Hit data product by " << producer_hit << std::endl;
Request(supera::LArDataType_t::kLArHit_t, producer_hit);
}
if(!producer_opdigit.empty() ) {
LARCV_INFO() << "Requesting OpDigit data product by " << producer_opdigit << std::endl;
Request(supera::LArDataType_t::kLArOpDigit_t, producer_opdigit );
}
if(!producer_mctruth.empty() ) {
LARCV_INFO() << "Requesting MCTruth data product by " << producer_mctruth << std::endl;
Request(supera::LArDataType_t::kLArMCTruth_t, producer_mctruth );
}
if(!producer_mctrack.empty() ) {
LARCV_INFO() << "Requesting MCTrack data product by " << producer_mctrack << std::endl;
Request(supera::LArDataType_t::kLArMCTrack_t, producer_mctrack );
}
if(!producer_mcshower.empty()) {
LARCV_INFO() << "Requesting MCShower data product by " << producer_mcshower << std::endl;
Request(supera::LArDataType_t::kLArMCShower_t, producer_mcshower);
}
if(!producer_simch.empty() ) {
LARCV_INFO() << "Requesting SimCh data product by " << producer_simch << std::endl;
Request(supera::LArDataType_t::kLArSimCh_t, producer_simch);
}
}
void SuperaBase::initialize()
{ClearEventData();}
bool SuperaBase::process(IOManager& mgr)
{ return true; }
void SuperaBase::finalize()
{ClearEventData();}
bool SuperaBase::is(const std::string question) const
{
if(question == "Supera") return true;
return false;
}
void SuperaBase::ClearEventData()
{
_ptr_wire_v = nullptr;
_ptr_hit_v = nullptr;
_ptr_opdigit_v = nullptr;
_ptr_sch_v = nullptr;
_ptr_mctruth_v = nullptr;
_ptr_mct_v = nullptr;
_ptr_mcs_v = nullptr;
}
template <> const std::vector<supera::LArWire_t>& SuperaBase::LArData<supera::LArWire_t>() const
{ if(!_ptr_wire_v) throw larbys("Wire data pointer not available"); return *_ptr_wire_v; }
template <> const std::vector<supera::LArHit_t>& SuperaBase::LArData<supera::LArHit_t>() const
{ if(!_ptr_hit_v) throw larbys("Hit data pointer not available"); return *_ptr_hit_v; }
template <> const std::vector<supera::LArOpDigit_t>& SuperaBase::LArData<supera::LArOpDigit_t>() const
{ if(!_ptr_opdigit_v) throw larbys("OpDigit data pointer not available"); return *_ptr_opdigit_v; }
template <> const std::vector<supera::LArSimCh_t>& SuperaBase::LArData<supera::LArSimCh_t>() const
{ if(!_ptr_sch_v) throw larbys("SimCh data pointer not available"); return *_ptr_sch_v; }
template <> const std::vector<supera::LArMCTruth_t>& SuperaBase::LArData<supera::LArMCTruth_t>() const
{ if(!_ptr_mctruth_v) throw larbys("MCTruth data pointer not available"); return *_ptr_mctruth_v; }
template <> const std::vector<supera::LArMCTrack_t>& SuperaBase::LArData<supera::LArMCTrack_t>() const
{ if(!_ptr_mct_v) throw larbys("MCTrack data pointer not available"); return *_ptr_mct_v; }
template <> const std::vector<supera::LArMCShower_t>& SuperaBase::LArData<supera::LArMCShower_t>() const
{ if(!_ptr_mcs_v) throw larbys("MCShower data pointer not available"); return *_ptr_mcs_v; }
template <> void SuperaBase::LArData(const std::vector<supera::LArWire_t>& data_v)
{ _ptr_wire_v = (std::vector<supera::LArWire_t>*)(&data_v); }
template <> void SuperaBase::LArData(const std::vector<supera::LArHit_t>& data_v)
{ _ptr_hit_v = (std::vector<supera::LArHit_t>*)(&data_v); }
template <> void SuperaBase::LArData(const std::vector<supera::LArOpDigit_t>& data_v)
{ _ptr_opdigit_v = (std::vector<supera::LArOpDigit_t>*)(&data_v); }
template <> void SuperaBase::LArData(const std::vector<supera::LArMCTruth_t>& data_v)
{ _ptr_mctruth_v = (std::vector<supera::LArMCTruth_t>*)(&data_v); }
template <> void SuperaBase::LArData(const std::vector<supera::LArMCTrack_t>& data_v)
{ _ptr_mct_v = (std::vector<supera::LArMCTrack_t>*)(&data_v); }
template <> void SuperaBase::LArData(const std::vector<supera::LArMCShower_t>& data_v)
{ _ptr_mcs_v = (std::vector<supera::LArMCShower_t>*)(&data_v); }
template <> void SuperaBase::LArData(const std::vector<supera::LArSimCh_t>& data_v)
{ _ptr_sch_v = (std::vector<supera::LArSimCh_t>*)(&data_v); }
}
#endif