9 #include "art/Framework/Core/EDProducer.h"
10 #include "art/Framework/Core/ModuleMacros.h"
11 #include "art/Framework/Principal/Event.h"
12 #include "art/Framework/Principal/Handle.h"
13 #include "art/Framework/Principal/Run.h"
14 #include "art/Framework/Principal/SubRun.h"
15 #include "canvas/Utilities/InputTag.h"
16 #include "fhiclcpp/ParameterSet.h"
17 #include "messagefacility/MessageLogger/MessageLogger.h"
18 #include "art/Utilities/make_tool.h"
35 class SBNDFlashFinder;
50 void produce(art::Event &
e)
override;
79 _hit_producers =
p.get<std::vector<std::string>>(
"OpHitProducers");
81 auto const flash_algo =
p.get<std::string>(
"FlashFinderAlgo");
85 _mgr.SetFlashAlgo(algo_ptr);
87 _ophit_input_time =
p.get<std::string>(
"OpHitInputTime",
"PeakTime");
88 _use_t0tool =
p.get<
bool>(
"UseT0Tool",
false);
89 _correct_light_propagation =
p.get<
bool>(
"CorrectLightPropagation",
false);
92 _flashgeo = art::make_tool<lightana::FlashGeoBase>(flashgeo_pset);
96 _flasht0calculator = art::make_tool<lightana::FlashT0Base>(flasht0_pset);
99 if(_correct_light_propagation){
101 _driftestimator = art::make_tool<lightana::DriftEstimatorBase>(driftestimator_pset);
104 produces< std::vector<recob::OpFlash> >();
105 produces< art::Assns <recob::OpHit, recob::OpFlash> >();
112 std::unique_ptr< std::vector<recob::OpFlash> > opflashes(
new std::vector<recob::OpFlash>);
113 std::unique_ptr< art::Assns <recob::OpHit, recob::OpFlash> > flash2hit_assn_v
114 (
new art::Assns<recob::OpHit, recob::OpFlash>);
116 std::vector<art::Ptr<recob::OpHit>> ophit_v;
124 art::Handle<std::vector<recob::OpHit> > ophit_h;
125 e.getByLabel(producer, ophit_h);
128 if(!ophit_h.isValid()) {
129 std::cerr <<
"\033[93m[ERROR]\033[00m ... could not locate OpHit!" << std::endl;
130 throw std::exception();
133 std::vector<art::Ptr<recob::OpHit>> temp_v;
134 art::fill_ptr_vector(temp_v, ophit_h);
135 ophit_v.insert(ophit_v.end(), temp_v.begin(), temp_v.end());
138 for(
auto const oph : ophit_v) {
140 if(trigger_time > 1.e20) trigger_time = oph->PeakTimeAbs() - oph->PeakTime();
148 loph.
channel = oph->OpChannel();
149 ophits.emplace_back(std::move(loph));
154 for(
const auto& lflash : flash_v) {
157 double Ycenter, Zcenter, Ywidth, Zwidth;
158 _flashgeo->GetFlashLocation(lflash.channel_pe, Ycenter, Zcenter, Ywidth, Zwidth);
161 double flasht0 = lflash.time;
169 if(_correct_light_propagation){
171 double drift_distance =
_driftestimator->GetDriftPosition( lflash.channel_pe );
172 double propagation_time =
_driftestimator->GetPropagationTime( drift_distance );
173 flasht0 = flasht0-propagation_time * 1e-3;
175 drift_distance = (lflash.tpc==0 ? -drift_distance : drift_distance);
177 recob::OpFlash flash(flasht0, lflash.time_err, trigger_time + flasht0,
178 (trigger_time + flasht0) / 1600., lflash.channel_pe,
180 drift_distance, -1, Ycenter, Ywidth, Zcenter, Zwidth);
181 opflashes->emplace_back(std::move(flash));
184 recob::OpFlash flash(flasht0, lflash.time_err, trigger_time + flasht0,
185 (trigger_time + flasht0) / 1600., lflash.channel_pe,
187 100., -1., Ycenter, Ywidth, Zcenter, Zwidth);
188 opflashes->emplace_back(std::move(flash));
192 for(
auto const& hitidx : lflash.asshit_idx) {
193 const art::Ptr<recob::OpHit> hit_ptr(ophit_v.at(hitidx));
198 e.put(std::move(opflashes));
199 e.put(std::move(flash2hit_assn_v));
208 for(
auto const& hitidx : lite_flash.
asshit_idx) {
209 flash_hits_v.emplace_back(std::move(lite_hits_v.at(hitidx)));
std::unique_ptr< lightana::DriftEstimatorBase > _driftestimator
std::string _ophit_input_time
SBNDFlashFinder & operator=(SBNDFlashFinder const &)=delete
BEGIN_PROLOG could also be cerr
::lightana::PECalib _pecalib
bool _correct_light_propagation
void produce(art::Event &e) override
timescale_traits< TriggerTimeCategory >::time_point_t trigger_time
A point in time on the trigger time scale.
std::vector< lightana::LiteOpHit_t > LiteOpHitArray_t
double Calibrate(const size_t opdet, const double area) const
SBNDFlashFinder(fhicl::ParameterSet const &p)
std::unique_ptr< lightana::FlashGeoBase > _flashgeo
::lightana::FlashFinderManager _mgr
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
size_t OpDetFromOpChannel(size_t opch)
std::vector< std::string > _hit_producers
std::vector< unsigned int > asshit_idx
std::unique_ptr< lightana::FlashT0Base > _flasht0calculator
LiteOpFlashArray_t RecoFlash(const LiteOpHitArray_t &ophits) const
static FlashAlgoFactory & get()
Static sharable instance getter.
FlashAlgoBase * create(const std::string name, const std::string instance_name)
Factory creation method (should be called by clients, possibly you!)
virtual void Configure(const Config_t &p)=0
::lightana::LiteOpHitArray_t GetAssociatedLiteHits(::lightana::LiteOpFlash_t lite_flash,::lightana::LiteOpHitArray_t lite_hits_v)
fhicl::ParameterSet Config_t