34 template <
typename Left,
typename Right,
typename Metadata>
55 float sigma_peak_time,
57 float sigma_peak_amplitude,
59 float hit_sigma_integral,
61 short int multiplicity,
62 short int local_index,
63 float goodness_of_fit,
65 :
hit(digits.Channel(),
80 art::ServiceHandle<
geo::Geometry const>()->View(digits.Channel()),
81 art::ServiceHandle<
geo::Geometry const>()->SignalType(digits.Channel()),
92 float sigma_peak_time,
94 float sigma_peak_amplitude,
96 float hit_sigma_integral,
98 short int multiplicity,
99 short int local_index,
100 float goodness_of_fit,
102 :
hit(wire.Channel(),
109 sigma_peak_amplitude,
118 art::ServiceHandle<
geo::Geometry const>()->SignalType(wire.Channel()),
129 float sigma_peak_time,
130 float peak_amplitude,
131 float sigma_peak_amplitude,
133 float hit_sigma_integral,
134 short int multiplicity,
135 short int local_index,
136 float goodness_of_fit,
146 sigma_peak_amplitude,
149 std::accumulate(wire.SignalROI().
begin() + start_tick,
150 wire.SignalROI().
begin() + end_tick,
163 float sigma_peak_time,
164 float peak_amplitude,
165 float sigma_peak_amplitude,
167 float hit_sigma_integral,
169 short int multiplicity,
170 short int local_index,
171 float goodness_of_fit,
176 signal.begin_index(),
182 sigma_peak_amplitude,
197 float sigma_peak_time,
198 float peak_amplitude,
199 float sigma_peak_amplitude,
201 float hit_sigma_integral,
203 short int multiplicity,
204 short int local_index,
205 float goodness_of_fit,
214 sigma_peak_amplitude,
222 wire.SignalROI().range(iSignalRoI))
229 hit.fWireID = wireID;
236 std::string instance_name,
238 bool doRawDigitAssns)
239 : prod_instance(instance_name)
242 , RawDigitAssns(doRawDigitAssns ? new
art::Assns<
raw::RawDigit,
recob::
Hit> : nullptr)
244 , hitPtrMaker(*(this->event), prod_instance)
249 std::string instance_name ,
254 collector.
produces<std::vector<recob::Hit>>(instance_name);
258 if (doRawDigitAssns) {
276 std::string instance_name ,
282 hits.reset(
new std::vector<recob::Hit>);
292 hits->emplace_back(std::move(
hit));
304 hits->push_back(hit);
314 <<
"HitCollectionCreator is trying to put into the event" 315 " a hit collection that was never created!\n";
344 std::string instance_name,
349 WireModuleLabel !=
"",
350 RawDigitModuleLabel !=
"")
351 , wires_label(WireModuleLabel)
352 , digits_label(RawDigitModuleLabel)
354 hits.reset(
new std::vector<recob::Hit>);
359 std::string instance_name,
369 <<
"HitCollectionAssociator can't create hit <--> raw digit" 370 " associations through wires, without wires!\n";
372 hits.reset(
new std::vector<recob::Hit>);
378 hits = std::move(srchits);
407 event->getValidHandle<std::vector<recob::Wire>>(
wires_label);
417 std::unique_ptr<art::FindOneP<raw::RawDigit>> WireToDigit;
418 if (bUseWiresForDigits) {
423 for (
size_t iHit = 0; iHit < srchits.size(); ++iHit) {
426 size_t iChannel = size_t(srchits[iHit].Channel());
429 size_t iWire = std::numeric_limits<size_t>::max();
430 if (iChannel < WireMap.size()) iWire = WireMap[iChannel];
431 if (iWire == std::numeric_limits<size_t>::max()) {
433 <<
"No wire associated to channel #" << iChannel <<
" whence hit #" << iHit
443 if (bUseWiresForDigits) {
448 <<
"No raw digit associated to channel #" << iChannel <<
" whence hit #" << iHit
462 event->getValidHandle<std::vector<raw::RawDigit>>(
digits_label);
465 std::vector<size_t> DigitMap =
469 for (
size_t iHit = 0; iHit < srchits.size(); ++iHit) {
472 size_t iChannel = size_t(srchits[iHit].Channel());
475 size_t iDigit = std::numeric_limits<size_t>::max();
476 if (iChannel < DigitMap.size()) iDigit = DigitMap[iChannel];
477 if (iDigit == std::numeric_limits<size_t>::max()) {
479 <<
"No raw digit associated to channel #" << iChannel <<
" whence hit #" << iHit
497 std::string instance_name ,
502 , hits_label(HitModuleLabel)
504 hits.reset(
new std::vector<recob::Hit>);
510 hits = std::move(srchits);
532 event->getValidHandle<std::vector<recob::Hit>>(
hits_label);
541 if (!HitToWire.isValid()) {
543 <<
"Can't find the associations between hits and wires produced by '" <<
hits_label 548 std::vector<art::Ptr<recob::Wire>> WireMap;
549 for (
size_t iAssn = 0; iAssn < HitToWire.size(); ++iAssn) {
551 if (wire.
isNull())
continue;
552 size_t channelID = (size_t)wire->
Channel();
553 if (WireMap.size() <= channelID)
554 WireMap.resize(std::max(channelID + 1, 2 * WireMap.size()), {});
555 WireMap[channelID] = std::move(wire);
559 for (
size_t iHit = 0; iHit < srchits.size(); ++iHit) {
561 size_t channelID = (size_t)hit.
Channel();
564 if ((channelID >= WireMap.size()) || !WireMap[channelID])
continue;
578 if (!HitToDigits.isValid()) {
580 <<
"Can't find the associations between hits and raw digits" 585 std::vector<art::Ptr<raw::RawDigit>> DigitMap;
586 for (
size_t iAssn = 0; iAssn < HitToDigits.size(); ++iAssn) {
588 if (digits.
isNull())
continue;
589 size_t channelID = (size_t)digits->
Channel();
590 if (DigitMap.size() <= channelID)
591 DigitMap.resize(std::max(channelID + 1, 2 * DigitMap.size()), {});
592 DigitMap[channelID] = std::move(digits);
596 for (
size_t iHit = 0; iHit < srchits.size(); ++iHit) {
598 size_t channelID = (size_t)hit.
Channel();
601 if ((channelID >= DigitMap.size()) || !DigitMap[channelID])
continue;
HitPtr_t CreatePtrToLastHit() const
Creates an art pointer to the hit with the last index.
Collection of charge vs time digitized from a single readout channel.
Reconstruction base classes.
void prepare_associations()
Finds out the associations for the current hits.
HitAndAssociationsWriterBase(art::Event &event, std::string instance_name, bool doWireAssns, bool doRawDigitAssns)
Constructor: sets instance name and whether to build associations.
std::string prod_instance
Tame of the instance for data products.
art::InputTag wires_label
Label of the collection of wires to associate.
Declaration of signal hit object.
Procedures to create maps of object locations.
ChannelID_t Channel() const
DAQ channel this raw data was read from.
std::unique_ptr< art::Assns< recob::Wire, recob::Hit > > WireAssns
Associations with wires.
void use_hits(std::unique_ptr< std::vector< recob::Hit >> &&srchits)
Uses the specified collection as data product.
std::vector< size_t > MakeIndex(Coll const &data, KeyOf key_of=KeyOf())
Creates a map of indices from an existing collection.
void swap(art::Assns< L, R, D > &other)
static void declare_products(art::ProducesCollector &collector, std::string instance_name="", bool doWireAssns=true, bool doRawDigitAssns=true)
Declares the hit products we are going to fill.
int TDCtick_t
Type representing a TDC tick.
Class managing the creation of a new recob::Hit object.
Helper functions to create a hit.
void produces(std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
void use_hits(std::unique_ptr< std::vector< recob::Hit >> &&srchits)
Uses the specified collection as data product.
void prepare_associations()
Finds out the associations for the current hits.
void put_into()
Moves the data into the event.
raw::ChannelID_t Channel() const
Returns the ID of the channel (or InvalidChannelID)
void put_into()
Moves the data into the event.
HitPtr_t CreatePtr(size_t index) const
Creates an art pointer to the hit with the specified index.
details::FindAllP< recob::Hit, recob::Wire > HitToWire
Query object connecting a hit to a wire.
void CreateAssociationsToLastHit(art::Ptr< recob::Wire > const &wire, art::Ptr< raw::RawDigit > const &digits)
Creates associations between the last hit and the specified pointers.
bool isNull() const noexcept
void emplace_back(recob::Hit &&hit, art::Ptr< recob::Wire > const &wire=art::Ptr< recob::Wire >(), art::Ptr< raw::RawDigit > const &digits=art::Ptr< raw::RawDigit >())
Adds the specified hit to the data collection.
Detector simulation of raw signals on wires.
HitRefinerAssociator(art::Event &event, art::InputTag const &HitModuleLabel, std::string instance_name="", bool doWireAssns=true, bool doRawDigitAssns=true)
Constructor: sets instance name and whether to build associations.
art::InputTag hits_label
Label of the collection of hits.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
HitCollectionAssociator(art::Event &event, std::string instance_name, art::InputTag const &WireModuleLabel, art::InputTag const &RawDigitModuleLabel)
Constructor: sets instance name and whether to build associations.
bool isNonnull() const noexcept
void put_into()
Moves the data into the event.
HitCollectionCreator(art::Event &event, std::string instance_name="", bool doWireAssns=true, bool doRawDigitAssns=true)
Constructor: sets instance name and whether to build associations.
Class holding the regions of interest of signal from a channel.
HitCreator(raw::RawDigit const &digits, geo::WireID const &wireID, raw::TDCtick_t start_tick, raw::TDCtick_t end_tick, float rms, float peak_time, float sigma_peak_time, float peak_amplitude, float sigma_peak_amplitude, float hit_integral, float hit_sigma_integral, float summedADC, short int multiplicity, short int local_index, float goodness_of_fit, int dof)
Constructor: extracts some information from raw digit.
art::InputTag digits_label
Label of raw digits collection to associate.
Declaration of basic channel signal object.
std::unique_ptr< art::Assns< raw::RawDigit, recob::Hit > > RawDigitAssns
Associations with raw digits.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
void put_into()
Moves the data into the event.
2D representation of charge deposited in the TDC/wire plane
recob::Wire::RegionsOfInterest_t::datarange_t RegionOfInterest_t
Type of one region of interest.
std::unique_ptr< std::vector< recob::Hit > > hits
Collection of hits.
Namespace collecting geometry-related classes utilities.
raw::ChannelID_t Channel() const
ID of the readout channel the hit was extracted from.
Base class handling a collection of hits and its associations.
art framework interface to geometry description
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Event finding and building.