21 #include "canvas/Persistency/Common/FindOneP.h" 35 template <
typename Left,
typename Right,
typename Metadata>
57 float sigma_peak_time,
59 float sigma_peak_amplitude,
61 float hit_sigma_integral,
63 short int multiplicity,
64 short int local_index,
65 float goodness_of_fit,
85 art::ServiceHandle<
geo::Geometry
const>()->SignalType(digits.Channel()),
99 float sigma_peak_time,
100 float peak_amplitude,
101 float sigma_peak_amplitude,
103 float hit_sigma_integral,
105 short int multiplicity,
106 short int local_index,
107 float goodness_of_fit,
118 sigma_peak_amplitude,
127 art::ServiceHandle<
geo::Geometry
const>()->SignalType(wire.Channel()),
141 float sigma_peak_time,
142 float peak_amplitude,
143 float sigma_peak_amplitude,
145 float hit_sigma_integral,
146 short int multiplicity,
147 short int local_index,
148 float goodness_of_fit,
152 wire, wireID, start_tick, end_tick,
153 rms, peak_time, sigma_peak_time, peak_amplitude, sigma_peak_amplitude,
154 hit_integral, hit_sigma_integral,
156 wire.SignalROI().
begin() + start_tick,
157 wire.SignalROI().
begin() + end_tick,
160 multiplicity, local_index,
172 float sigma_peak_time,
173 float peak_amplitude,
174 float sigma_peak_amplitude,
176 float hit_sigma_integral,
178 short int multiplicity,
179 short int local_index,
180 float goodness_of_fit,
185 wire, wireID, signal.begin_index(), signal.end_index(),
186 rms, peak_time, sigma_peak_time, peak_amplitude, sigma_peak_amplitude,
187 hit_integral, hit_sigma_integral, summedADC, multiplicity, local_index,
199 float sigma_peak_time,
200 float peak_amplitude,
201 float sigma_peak_amplitude,
203 float hit_sigma_integral,
205 short int multiplicity,
206 short int local_index,
207 float goodness_of_fit,
212 wire, wireID, rms, peak_time, sigma_peak_time, peak_amplitude, sigma_peak_amplitude,
213 hit_integral, hit_sigma_integral, summedADC, multiplicity, local_index,
214 goodness_of_fit, dof, wire.SignalROI().range(iSignalRoI)
225 hit.fWireID = wireID;
235 std::string instance_name,
bool doWireAssns,
bool doRawDigitAssns
237 : prod_instance(instance_name)
242 (doRawDigitAssns? new
art::Assns<
raw::RawDigit,
recob::
Hit>: nullptr)
244 , hitPtrMaker(*(this->event), prod_instance)
251 bool doWireAssns ,
bool doRawDigitAssns
253 collector.
produces<std::vector<recob::Hit>>(instance_name);
260 if (doRawDigitAssns) {
281 bool doWireAssns ,
bool doRawDigitAssns
284 (event, instance_name, doWireAssns, doRawDigitAssns)
286 hits.reset(
new std::vector<recob::Hit>);
309 hits->push_back(hit);
319 <<
"HitCollectionCreator is trying to put into the event" 320 " a hit collection that was never created!\n";
357 event, instance_name,
358 WireModuleLabel !=
"", RawDigitModuleLabel !=
"" 360 , wires_label(WireModuleLabel)
361 , digits_label(RawDigitModuleLabel)
363 hits.reset(
new std::vector<recob::Hit>);
374 event, instance_name,
375 WireModuleLabel !=
"", doRawDigitAssns
382 <<
"HitCollectionAssociator can't create hit <--> raw digit" 383 " associations through wires, without wires!\n";
385 hits.reset(
new std::vector<recob::Hit>);
390 (std::unique_ptr<std::vector<recob::Hit>>&& srchits)
405 (std::vector<recob::Hit>
const& srchits)
423 =
event->getValidHandle<std::vector<recob::Wire>>(
wires_label);
426 std::vector<size_t> WireMap
434 std::unique_ptr<art::FindOneP<raw::RawDigit>> WireToDigit;
435 if (bUseWiresForDigits) {
441 for (
size_t iHit = 0; iHit < srchits.size(); ++iHit) {
444 size_t iChannel = size_t(srchits[iHit].Channel());
448 if (iChannel < WireMap.size()) iWire = WireMap[iChannel];
451 <<
"No wire associated to channel #" << iChannel <<
" whence hit #" 452 << iHit <<
" comes!\n";
461 if (bUseWiresForDigits) {
466 <<
"No raw digit associated to channel #" << iChannel
467 <<
" whence hit #" << iHit <<
" comes!\n";
480 =
event->getValidHandle<std::vector<raw::RawDigit>>(
digits_label);
483 std::vector<size_t> DigitMap
487 for (
size_t iHit = 0; iHit < srchits.size(); ++iHit) {
490 size_t iChannel = size_t(srchits[iHit].Channel());
494 if (iChannel < DigitMap.size()) iDigit = DigitMap[iChannel];
497 <<
"No raw digit associated to channel #" << iChannel
498 <<
" whence hit #" << iHit <<
" comes!\n";
517 bool doWireAssns ,
bool doRawDigitAssns
520 (event, instance_name, doWireAssns, doRawDigitAssns)
521 , hits_label(HitModuleLabel)
523 hits.reset(
new std::vector<recob::Hit>);
528 (std::unique_ptr<std::vector<recob::Hit>>&& srchits)
543 (std::vector<recob::Hit>
const& srchits)
554 =
event->getValidHandle<std::vector<recob::Hit>>(
hits_label);
563 if (!HitToWire.isValid()) {
565 <<
"Can't find the associations between hits and wires produced by '" 570 std::vector<art::Ptr<recob::Wire>> WireMap;
571 for (
size_t iAssn = 0; iAssn < HitToWire.size(); ++iAssn) {
573 if (wire.
isNull())
continue;
574 size_t channelID = (size_t) wire->
Channel();
575 if (WireMap.size() <= channelID)
576 WireMap.resize(
std::max(channelID + 1, 2 * WireMap.size()), {});
581 for (
size_t iHit = 0; iHit < srchits.size(); ++iHit) {
583 size_t channelID = (size_t) hit.
Channel();
586 if ((channelID >= WireMap.size()) || !WireMap[channelID])
continue;
600 if (!HitToDigits.isValid()) {
602 <<
"Can't find the associations between hits and raw digits" 607 std::vector<art::Ptr<raw::RawDigit>> DigitMap;
608 for (
size_t iAssn = 0; iAssn < HitToDigits.size(); ++iAssn) {
610 if (digits.
isNull())
continue;
611 size_t channelID = (size_t) digits->
Channel();
612 if (DigitMap.size() <= channelID)
613 DigitMap.resize(
std::max(channelID + 1, 2 * DigitMap.size()), {});
618 for (
size_t iHit = 0; iHit < srchits.size(); ++iHit) {
620 size_t channelID = (size_t) hit.
Channel();
623 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.
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
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.
AdcChannelData::View View
std::string prod_instance
Tame of the instance for data products.
art::InputTag wires_label
Label of the collection of wires to associate.
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.
art framework interface to geometry description
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.
static int max(int a, int b)
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
Declaration of signal hit object.
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.
LArSoft geometry interface.
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.
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Event finding and building.