10 #include "art/Framework/Core/EDProducer.h"
11 #include "art/Framework/Core/ModuleMacros.h"
12 #include "art/Framework/Principal/Event.h"
13 #include "art/Framework/Principal/Handle.h"
14 #include "art/Framework/Principal/Run.h"
15 #include "art/Framework/Principal/SubRun.h"
16 #include "canvas/Utilities/InputTag.h"
17 #include "fhiclcpp/ParameterSet.h"
18 #include "messagefacility/MessageLogger/MessageLogger.h"
45 void produce(art::Event &
e)
override;
55 void GetFlashLocation(std::vector<double>,
double&,
double&,
double&,
double&);
64 _hit_producer =
p.get<std::string>(
"OpHitProducer");
66 auto const flash_algo =
p.get<std::string>(
"FlashFinderAlgo");
70 _mgr.SetFlashAlgo(algo_ptr);
74 produces< std::vector<recob::OpFlash> >();
75 produces< art::Assns <recob::OpHit, recob::OpFlash> >();
82 std::unique_ptr< std::vector<recob::OpFlash> > opflashes(
new std::vector<recob::OpFlash>);
83 std::unique_ptr< art::Assns <recob::OpHit, recob::OpFlash> > flash2hit_assn_v (
new art::Assns<recob::OpHit, recob::OpFlash> );
85 art::Handle<std::vector<recob::OpHit> > ophit_h;
89 if(!ophit_h.isValid()) {
90 std::cerr<<
"\033[93m[ERROR]\033[00m ... could not locate OpHit!"<<std::endl;
91 throw std::exception();
96 for(
auto const& oph : *ophit_h) {
98 if(trigger_time > 1.e20) trigger_time = oph.PeakTimeAbs() - oph.PeakTime();
103 loph.
channel = oph.OpChannel();
104 ophits.emplace_back(std::move(loph));
109 for(
const auto& lflash : flash_v) {
111 double Ycenter, Zcenter, Ywidth, Zwidth;
115 trigger_time + lflash.time,
116 (trigger_time + lflash.time) / 1600.,
119 Ycenter, Ywidth, Zcenter, Zwidth);
120 opflashes->emplace_back(std::move(flash));
122 for(
auto const& hitidx : lflash.asshit_idx) {
123 const art::Ptr<recob::OpHit> hit_ptr(ophit_h, hitidx);
128 e.put(std::move(opflashes));
129 e.put(std::move(flash2hit_assn_v));
140 Ycenter = Zcenter = 0.;
141 Ywidth = Zwidth = -999.;
143 double sumy = 0., sumz = 0., sumy2 = 0., sumz2 = 0.;
145 for (
unsigned int opch = 0; opch < pePerOpChannel.size(); opch++) {
157 sumy += pePerOpChannel[opch]*PMTxyz[1];
158 sumy2 += pePerOpChannel[opch]*PMTxyz[1]*PMTxyz[1];
159 sumz += pePerOpChannel[opch]*PMTxyz[2];
160 sumz2 += pePerOpChannel[opch]*PMTxyz[2]*PMTxyz[2];
162 totalPE += pePerOpChannel[opch];
165 Ycenter = sumy/totalPE;
166 Zcenter = sumz/totalPE;
169 if ( (sumy2*totalPE - sumy*sumy) > 0. )
170 Ywidth = std::sqrt(sumy2*totalPE - sumy*sumy)/totalPE;
172 if ( (sumz2*totalPE - sumz*sumz) > 0. )
173 Zwidth = std::sqrt(sumz2*totalPE - sumz*sumz)/totalPE;
std::vector< pmtana::LiteOpHit_t > LiteOpHitArray_t
FlashAlgoBase * create(const std::string name, const std::string instance_name)
Factory creation method (should be called by clients, possibly you!)
BEGIN_PROLOG could also be cerr
::pmtana::PECalib _pecalib
std::string _hit_producer
timescale_traits< TriggerTimeCategory >::time_point_t trigger_time
A point in time on the trigger time scale.
double Calibrate(const size_t opdet, const double area) const
fhicl::ParameterSet Config_t
ICARUSFlashFinder(fhicl::ParameterSet const &p)
void produce(art::Event &e) override
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)
virtual void Configure(const Config_t &p)=0
static FlashAlgoFactory & get()
Static sharable instance getter.
ICARUSFlashFinder & operator=(ICARUSFlashFinder const &)=delete
void OpDetCenterFromOpChannel(size_t opch, double *xyz)
::pmtana::FlashFinderManager _mgr
void GetFlashLocation(std::vector< double >, double &, double &, double &, double &)
LiteOpFlashArray_t RecoFlash(const LiteOpHitArray_t &ophits) const