forked from kvtsang/Supera
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SuperaOpDigit.cxx
75 lines (60 loc) · 2.08 KB
/
SuperaOpDigit.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
#ifndef __SUPERAOPDIGIT_CXX__
#define __SUPERAOPDIGIT_CXX__
#include "SuperaOpDigit.h"
#include "LAr2Image.h"
#include "ImageMetaMakerFactory.h"
#include "PulledPork3DSlicer.h"
#include "larcv/core/DataFormat/EventImage2D.h"
namespace larcv {
static SuperaOpDigitProcessFactory __global_SuperaOpDigitProcessFactory__;
SuperaOpDigit::SuperaOpDigit(const std::string name)
: SuperaBase(name)
{}
void SuperaOpDigit::configure(const PSet& cfg)
{
SuperaBase::configure(cfg);
supera::ParamsImage2D::configure(cfg);
supera::ImageMetaMaker::configure(cfg);
if(supera::PulledPork3DSlicer::Is(supera::ImageMetaMaker::MetaMakerPtr())) {
LARCV_CRITICAL() << "PulledPork3DSlicer should not be used for Optical image maker!" << std::endl;
throw larbys();
}
}
void SuperaOpDigit::initialize()
{ SuperaBase::initialize(); }
bool SuperaOpDigit::process(IOManager& mgr)
{
SuperaBase::process(mgr);
auto const& meta_v = Meta();
if(meta_v.empty()) {
LARCV_CRITICAL() << "Meta not created!" << std::endl;
throw larbys();
}
if(meta_v.size()!=1) {
LARCV_CRITICAL() << "Meta > 1, not expected for OpDigit" << std::endl;
throw larbys();
}
auto ev_image = (EventImage2D*)(mgr.get_data("image2d",OutImageLabel()));
if(!ev_image) {
LARCV_CRITICAL() << "Output image could not be created!" << std::endl;
throw larbys();
}
if(!(ev_image->image2d_array().empty())) {
LARCV_CRITICAL() << "Output image array not empty!" << std::endl;
throw larbys();
}
std::vector<larcv::Image2D> image_v;
image_v.emplace_back(supera::OpDigit2Image2D(meta_v.front(), LArData<supera::LArOpDigit_t>(), TimeOffset()));
for(size_t plane=0; plane<image_v.size(); ++plane) {
auto& image = image_v[plane];
image.compress(image.meta().rows() / RowCompressionFactor().at(plane),
image.meta().cols() / ColCompressionFactor().at(plane),
larcv::Image2D::kSum);
}
ev_image->emplace(std::move(image_v));
return true;
}
void SuperaOpDigit::finalize()
{}
}
#endif