forked from kvtsang/Supera
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSuperaMetaMaker.cxx
97 lines (84 loc) · 3.63 KB
/
SuperaMetaMaker.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
#ifndef __SUPERAMETAMAKER_CXX__
#define __SUPERAMETAMAKER_CXX__
#include "SuperaMetaMaker.h"
#include "SuperaCSVReader.h"
#include "LAr2Image.h"
#include "ImageMetaMakerFactory.h"
#include "ImageMetaMaker.h"
#include "PulledPork3DSlicer.h"
#include "Voxel3DSlicer.h"
#include "larcv/core/DataFormat/EventImage2D.h"
namespace larcv {
static SuperaMetaMakerProcessFactory __global_SuperaMetaMakerProcessFactory__;
SuperaMetaMaker::SuperaMetaMaker(const std::string name)
: SuperaBase(name)
, _meta_maker(nullptr)
{}
bool SuperaMetaMaker::is(const std::string question) const
{
if(question == "Supera") return true;
if(question == "SuperaMetaMaker") return true;
return false;
}
void SuperaMetaMaker::configure(const PSet& cfg)
{
SuperaBase::configure(cfg);
if(_meta_maker) delete _meta_maker;
_meta_maker = supera::CreateImageMetaMaker(cfg);
supera::ImageMetaMaker::SetSharedMetaMaker(_meta_maker);
}
void SuperaMetaMaker::initialize()
{ SuperaBase::initialize(); }
bool SuperaMetaMaker::process(IOManager& mgr)
{
SuperaBase::process(mgr);
if(supera::PulledPork3DSlicer::Is(_meta_maker)) {
((supera::PulledPork3DSlicer*)(_meta_maker))->ClearEventData();
if(!LArDataLabel(supera::LArDataType_t::kLArMCTruth_t).empty())
((supera::PulledPork3DSlicer*)(_meta_maker))->AddConstraint(LArData<supera::LArMCTruth_t>());
if(!CSV().empty() && _constraint_m.empty()) {
_constraint_m.clear();
supera::csvreader::read_constraint_file(CSV(),_constraint_m);
LARCV_NORMAL() << "Loaded constraint points for " << _constraint_m.size() << " events..." << std::endl;
}
if(_constraint_m.size()) {
auto const& larcv_event_id = mgr.event_id();
//supera::RSEID supera_event_id(larcv_event_id.run(),larcv_event_id.subrun(),larcv_event_id.event());
supera::RSEID supera_event_id(larcv_event_id.run(),larcv_event_id.event());
auto iter = _constraint_m.find(supera_event_id);
if(iter!=_constraint_m.end())
((supera::PulledPork3DSlicer*)(_meta_maker))->AddConstraint((*iter).second[0],(*iter).second[1],(*iter).second[2]);
}
if(!LArDataLabel(supera::LArDataType_t::kLArSimCh_t).empty())
((supera::PulledPork3DSlicer*)(_meta_maker))->GenerateMeta(LArData<supera::LArSimCh_t>(),TimeOffset());
else
((supera::PulledPork3DSlicer*)(_meta_maker))->GenerateMeta(TimeOffset());
}
else if(supera::Voxel3DSlicer::Is(_meta_maker)) {
((supera::Voxel3DSlicer*)(_meta_maker))->ClearEventData();
if(!LArDataLabel(supera::LArDataType_t::kLArMCTruth_t).empty())
((supera::Voxel3DSlicer*)(_meta_maker))->AddConstraint(LArData<supera::LArMCTruth_t>());
if(!CSV().empty() && _constraint_m.empty()) {
_constraint_m.clear();
supera::csvreader::read_constraint_file(CSV(),_constraint_m);
LARCV_NORMAL() << "Loaded constraint points for " << _constraint_m.size() << " events..." << std::endl;
}
if(_constraint_m.size()) {
auto const& larcv_event_id = mgr.event_id();
//supera::RSEID supera_event_id(larcv_event_id.run(),larcv_event_id.subrun(),larcv_event_id.event());
supera::RSEID supera_event_id(larcv_event_id.run(),larcv_event_id.event());
auto iter = _constraint_m.find(supera_event_id);
if(iter!=_constraint_m.end())
((supera::Voxel3DSlicer*)(_meta_maker))->AddConstraint((*iter).second[0],(*iter).second[1],(*iter).second[2]);
}
if(!LArDataLabel(supera::LArDataType_t::kLArSimCh_t).empty())
((supera::Voxel3DSlicer*)(_meta_maker))->GenerateMeta(LArData<supera::LArSimCh_t>(),TimeOffset());
else
((supera::Voxel3DSlicer*)(_meta_maker))->GenerateMeta(TimeOffset());
}
return true;
}
void SuperaMetaMaker::finalize()
{}
}
#endif