22 #include "art/Framework/Core/ModuleMacros.h"
23 #include "art/Framework/Core/EDProducer.h"
24 #include "art/Framework/Principal/Event.h"
25 #include "art/Framework/Services/Registry/ServiceHandle.h"
26 #include "canvas/Utilities/InputTag.h"
27 #include "messagefacility/MessageLogger/MessageLogger.h"
29 #include "art/Persistency/Common/PtrMaker.h"
45 explicit HitMerger(fhicl::ParameterSet
const & pset);
49 virtual void reconfigure(fhicl::ParameterSet
const & pset);
50 virtual void produce(art::Event &
e);
87 produces< std::vector<recob::Hit>>();
88 produces< art::Assns<recob::Wire, recob::Hit>>();
89 produces< art::Assns<raw::RawDigit, recob::Hit>>();
92 mf::LogInfo(
"HitMerger") <<
"HitMerger configured\n";
134 std::unique_ptr<std::vector<recob::Hit>> outputHitPtrVec(
new std::vector<recob::Hit>);
137 std::unique_ptr<art::Assns<recob::Wire, recob::Hit>> wireAssns(
new art::Assns<recob::Wire, recob::Hit>);
140 std::unique_ptr<art::Assns<raw::RawDigit, recob::Hit>> rawDigitAssns(
new art::Assns<raw::RawDigit, recob::Hit>);
145 art::PtrMaker<recob::Hit> ptrMaker(evt);
151 art::Handle< std::vector<recob::Hit> > hitHandle;
152 evt.getByLabel(inputTag, hitHandle);
154 for(
size_t hitIdx = 0; hitIdx < hitHandle->size(); hitIdx++)
156 art::Ptr<recob::Hit> hitPtr(hitHandle,hitIdx);
164 recob::Hit* newHit = &outputHitPtrVec->back();
167 recobHitToPtrMap[newHit] = ptrMaker(outputHitPtrVec->size()-1);
177 evt.put(std::move(outputHitPtrVec));
178 evt.put(std::move(wireAssns));
179 evt.put(std::move(rawDigitAssns));
187 wireAssns = art::Assns<recob::Wire, recob::Hit>();
191 std::unordered_map<raw::ChannelID_t, art::Ptr<recob::Wire>> channelToWireMap;
196 art::ValidHandle<std::vector<recob::Hit>> hitHandle = evt.getValidHandle<std::vector<recob::Hit>>(inputTag);
198 art::FindOneP<recob::Wire> hitToWireAssns(hitHandle, evt, inputTag);
200 if (hitToWireAssns.isValid())
202 for(
size_t wireIdx = 0; wireIdx < hitToWireAssns.size(); wireIdx++)
204 art::Ptr<recob::Wire> wire = hitToWireAssns.at(wireIdx);
206 channelToWireMap[wire->Channel()] = wire;
212 for(
const auto& hitPtrPair : recobHitPtrMap)
216 std::unordered_map<raw::ChannelID_t, art::Ptr<recob::Wire>>::iterator chanWireItr = channelToWireMap.find(channel);
218 if (!(chanWireItr != channelToWireMap.end()))
continue;
220 wireAssns.addSingle(chanWireItr->second, hitPtrPair.second);
229 rawDigitAssns = art::Assns<raw::RawDigit, recob::Hit>();
233 std::unordered_map<raw::ChannelID_t, art::Ptr<raw::RawDigit>> channelToRawDigitMap;
238 art::ValidHandle<std::vector<recob::Hit>> hitHandle = evt.getValidHandle<std::vector<recob::Hit>>(inputTag);
240 art::FindOneP<raw::RawDigit> hitToRawDigitAssns(hitHandle, evt, inputTag);
242 if (hitToRawDigitAssns.isValid())
244 for(
size_t rawDigitIdx = 0; rawDigitIdx < hitToRawDigitAssns.size(); rawDigitIdx++)
246 art::Ptr<raw::RawDigit> rawDigit = hitToRawDigitAssns.at(rawDigitIdx);
248 channelToRawDigitMap[rawDigit->Channel()] = rawDigit;
254 for(
const auto& hitPtrPair : recobHitPtrMap)
258 std::unordered_map<raw::ChannelID_t, art::Ptr<raw::RawDigit>>::iterator chanRawDigitItr = channelToRawDigitMap.find(channel);
260 if (!(chanRawDigitItr != channelToRawDigitMap.end()))
continue;
262 rawDigitAssns.addSingle(chanRawDigitItr->second, hitPtrPair.second);
virtual void endJob()
End job method.
Utilities related to art service access.
void makeWireAssns(const art::Event &, art::Assns< recob::Wire, recob::Hit > &, RecobHitToPtrMap &) const
Create recob::Wire to recob::Hit associations.
std::vector< art::InputTag > HitMergerfHitProducerLabelVec
The full collection of hits.
geo::WireID WireID() const
Declaration of signal hit object.
virtual ~HitMerger()
Destructor.
HitMerger(fhicl::ParameterSet const &pset)
virtual void beginJob()
Begin job method.
std::unordered_map< const recob::Hit *, art::Ptr< recob::Hit >> RecobHitToPtrMap
Class managing the creation of a new recob::Hit object.
Helper functions to create a hit.
virtual void produce(art::Event &e)
std::vector< art::Ptr< recob::Hit >> HitPtrVector
void makeRawDigitAssns(const art::Event &, art::Assns< raw::RawDigit, recob::Hit > &, RecobHitToPtrMap &) const
Create raw::RawDigit to recob::Hit associations.
2D representation of charge deposited in the TDC/wire plane
virtual void reconfigure(fhicl::ParameterSet const &pset)
unsigned int ChannelID_t
Type representing the ID of a readout channel.
art framework interface to geometry description