forked from DeepLearnPhysics/Supera
-
Notifications
You must be signed in to change notification settings - Fork 1
/
SuperaBase.cxx
191 lines (144 loc) · 8.01 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#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_mcpart = cfg.get<std::string>("LArMCParticleProducer", "");
auto producer_mctrack = cfg.get<std::string>("LArMCTrackProducer", "");
auto producer_mcshower = cfg.get<std::string>("LArMCShowerProducer", "");
auto producer_simch = cfg.get<std::string>("LArSimChProducer", "");
auto producer_simedep = cfg.get<std::string>("LArSimEnergyDepositProducer", "");
auto producer_sps = cfg.get<std::string>("LArSpacePoint", "");
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_mcpart.empty() ) {
LARCV_INFO() << "Requesting MCParticle data product by " << producer_mcpart << std::endl;
Request(supera::LArDataType_t::kLArMCParticle_t, producer_mcpart );
}
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);
}
if(!producer_simedep.empty() ) {
LARCV_INFO() << "Requesting SimEnergyDeposit data product by " << producer_simedep << std::endl;
Request(supera::LArDataType_t::kLArSimEnergyDeposit_t, producer_simedep);
}
if(!producer_sps.empty() ) {
LARCV_INFO() << "Requesting SpacePoint data product by " << producer_sps << std::endl;
Request(supera::LArDataType_t::kLArSpacePoint_t, producer_sps);
}
}
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_mcp_v = nullptr;
_ptr_mct_v = nullptr;
_ptr_mcs_v = nullptr;
_ptr_simedep_v = nullptr;
// FIXME(kvtsang) Temporary solution to access associations
_event = nullptr;
}
// FIXME(kvtsang) Temporary solution to access associations
const art::Event* SuperaBase::GetEvent(){
if (!_event)
throw larbys("art::Event not set!");
return _event;
}
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::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::LArMCParticle_t>& SuperaBase::LArData<supera::LArMCParticle_t>() const
{ if(!_ptr_mcp_v) throw larbys("MCParticle data pointer not available"); return *_ptr_mcp_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 <> 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::LArSimEnergyDeposit_t>& SuperaBase::LArData<supera::LArSimEnergyDeposit_t>() const
{ if(!_ptr_simedep_v) throw larbys("SimEnergyDeposit data pointer not available"); return *_ptr_simedep_v; }
template <> const std::vector<supera::LArSpacePoint_t>& SuperaBase::LArData<supera::LArSpacePoint_t>() const
{ if(!_ptr_spacepoint_v) throw larbys("SpacePoint data pointer not available"); return *_ptr_spacepoint_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::LArMCParticle_t>& data_v)
{ _ptr_mcp_v = (std::vector<supera::LArMCParticle_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); }
template <> void SuperaBase::LArData(const std::vector<supera::LArSimEnergyDeposit_t>& data_v)
{ _ptr_simedep_v = (std::vector<supera::LArSimEnergyDeposit_t>*)(&data_v); }
template <> void SuperaBase::LArData(const std::vector<supera::LArSpacePoint_t>& data_v)
{ _ptr_spacepoint_v = (std::vector<supera::LArSpacePoint_t>*)(&data_v); }
}
#endif