All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
HitMerger Class Reference
Inheritance diagram for HitMerger:

Public Member Functions

 HitMerger (fhicl::ParameterSet const &pset)
 
virtual ~HitMerger ()
 Destructor. More...
 
virtual void reconfigure (fhicl::ParameterSet const &pset)
 
virtual void produce (art::Event &e)
 
virtual void beginJob ()
 Begin job method. More...
 
virtual void endJob ()
 End job method. More...
 

Private Types

using RecobHitToPtrMap = std::unordered_map< const recob::Hit *, art::Ptr< recob::Hit >>
 
using HitPtrVector = std::vector< art::Ptr< recob::Hit >>
 

Private Member Functions

void makeWireAssns (const art::Event &, art::Assns< recob::Wire, recob::Hit > &, RecobHitToPtrMap &) const
 Create recob::Wire to recob::Hit associations. More...
 
void makeRawDigitAssns (const art::Event &, art::Assns< raw::RawDigit, recob::Hit > &, RecobHitToPtrMap &) const
 Create raw::RawDigit to recob::Hit associations. More...
 

Private Attributes

std::vector< art::InputTag > HitMergerfHitProducerLabelVec
 The full collection of hits. More...
 

Detailed Description

Definition at line 40 of file HitMerger_module.cc.

Member Typedef Documentation

using HitMerger::HitPtrVector = std::vector<art::Ptr<recob::Hit>>
private

Definition at line 68 of file HitMerger_module.cc.

using HitMerger::RecobHitToPtrMap = std::unordered_map<const recob::Hit*, art::Ptr<recob::Hit>>
private

Definition at line 55 of file HitMerger_module.cc.

Constructor & Destructor Documentation

HitMerger::HitMerger ( fhicl::ParameterSet const &  pset)
explicit

Constructor.

Arguments:

pset - Fcl parameters.

Definition at line 83 of file HitMerger_module.cc.

83  : EDProducer{pset}
84 {
85  reconfigure(pset);
86 
87  produces< std::vector<recob::Hit>>();
88  produces< art::Assns<recob::Wire, recob::Hit>>();
89  produces< art::Assns<raw::RawDigit, recob::Hit>>();
90 
91  // Report.
92  mf::LogInfo("HitMerger") << "HitMerger configured\n";
93 }
virtual void reconfigure(fhicl::ParameterSet const &pset)
HitMerger::~HitMerger ( )
virtual

Destructor.

Definition at line 97 of file HitMerger_module.cc.

98 {}

Member Function Documentation

void HitMerger::beginJob ( )
virtual

Begin job method.

Definition at line 114 of file HitMerger_module.cc.

115 {
116 // auto const* detp = lar::providerFrom<detinfo::DetectorPropertiesService>();
117 // auto const* geo = lar::providerFrom<geo::Geometry>();
118 // auto const* ts = lar::providerFrom<detinfo::DetectorClocksService>();
119 }
void HitMerger::endJob ( )
virtual

End job method.

Definition at line 270 of file HitMerger_module.cc.

271 {
272  return;
273 }
void HitMerger::makeRawDigitAssns ( const art::Event &  evt,
art::Assns< raw::RawDigit, recob::Hit > &  rawDigitAssns,
RecobHitToPtrMap recobHitPtrMap 
) const
private

Create raw::RawDigit to recob::Hit associations.

Definition at line 226 of file HitMerger_module.cc.

227 {
228  // Let's make sure the input associations container is empty
229  rawDigitAssns = art::Assns<raw::RawDigit, recob::Hit>();
230 
231  // First task is to recover all of the previous wire <--> hit associations and map them by channel number
232  // Create the temporary container
233  std::unordered_map<raw::ChannelID_t, art::Ptr<raw::RawDigit>> channelToRawDigitMap;
234 
235  // Go through the list of input sources and fill out the map
236  for(const auto& inputTag : HitMergerfHitProducerLabelVec)
237  {
238  art::ValidHandle<std::vector<recob::Hit>> hitHandle = evt.getValidHandle<std::vector<recob::Hit>>(inputTag);
239 
240  art::FindOneP<raw::RawDigit> hitToRawDigitAssns(hitHandle, evt, inputTag);
241 
242  if (hitToRawDigitAssns.isValid())
243  {
244  for(size_t rawDigitIdx = 0; rawDigitIdx < hitToRawDigitAssns.size(); rawDigitIdx++)
245  {
246  art::Ptr<raw::RawDigit> rawDigit = hitToRawDigitAssns.at(rawDigitIdx);
247 
248  channelToRawDigitMap[rawDigit->Channel()] = rawDigit;
249  }
250  }
251  }
252 
253  // Now fill the container
254  for(const auto& hitPtrPair : recobHitPtrMap)
255  {
256  raw::ChannelID_t channel = hitPtrPair.first->Channel();
257 
258  std::unordered_map<raw::ChannelID_t, art::Ptr<raw::RawDigit>>::iterator chanRawDigitItr = channelToRawDigitMap.find(channel);
259 
260  if (!(chanRawDigitItr != channelToRawDigitMap.end())) continue;
261 
262  rawDigitAssns.addSingle(chanRawDigitItr->second, hitPtrPair.second);
263  }
264 
265  return;
266 }
std::vector< art::InputTag > HitMergerfHitProducerLabelVec
The full collection of hits.
TCEvent evt
Definition: DataStructs.cxx:8
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
void HitMerger::makeWireAssns ( const art::Event &  evt,
art::Assns< recob::Wire, recob::Hit > &  wireAssns,
RecobHitToPtrMap recobHitPtrMap 
) const
private

Create recob::Wire to recob::Hit associations.

Definition at line 184 of file HitMerger_module.cc.

185 {
186  // Let's make sure the input associations container is empty
187  wireAssns = art::Assns<recob::Wire, recob::Hit>();
188 
189  // First task is to recover all of the previous wire <--> hit associations and map them by channel number
190  // Create the temporary container
191  std::unordered_map<raw::ChannelID_t, art::Ptr<recob::Wire>> channelToWireMap;
192 
193  // Go through the list of input sources and fill out the map
194  for(const auto& inputTag : HitMergerfHitProducerLabelVec)
195  {
196  art::ValidHandle<std::vector<recob::Hit>> hitHandle = evt.getValidHandle<std::vector<recob::Hit>>(inputTag);
197 
198  art::FindOneP<recob::Wire> hitToWireAssns(hitHandle, evt, inputTag);
199 
200  if (hitToWireAssns.isValid())
201  {
202  for(size_t wireIdx = 0; wireIdx < hitToWireAssns.size(); wireIdx++)
203  {
204  art::Ptr<recob::Wire> wire = hitToWireAssns.at(wireIdx);
205 
206  channelToWireMap[wire->Channel()] = wire;
207  }
208  }
209  }
210 
211  // Now fill the container
212  for(const auto& hitPtrPair : recobHitPtrMap)
213  {
214  raw::ChannelID_t channel = hitPtrPair.first->Channel();
215 
216  std::unordered_map<raw::ChannelID_t, art::Ptr<recob::Wire>>::iterator chanWireItr = channelToWireMap.find(channel);
217 
218  if (!(chanWireItr != channelToWireMap.end())) continue;
219 
220  wireAssns.addSingle(chanWireItr->second, hitPtrPair.second);
221  }
222 
223  return;
224 }
std::vector< art::InputTag > HitMergerfHitProducerLabelVec
The full collection of hits.
TCEvent evt
Definition: DataStructs.cxx:8
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
void HitMerger::produce ( art::Event &  evt)
virtual

Produce method.

Arguments:

evt - Art event.

This is the primary method. The goal is to merge input hit collections and output a single hit collection on the backside.

Associations with wires.

Associations with raw digits.

Definition at line 131 of file HitMerger_module.cc.

132 {
133  // container for our new hit collection
134  std::unique_ptr<std::vector<recob::Hit>> outputHitPtrVec(new std::vector<recob::Hit>);
135 
136  /// Associations with wires.
137  std::unique_ptr<art::Assns<recob::Wire, recob::Hit>> wireAssns(new art::Assns<recob::Wire, recob::Hit>);
138 
139  /// Associations with raw digits.
140  std::unique_ptr<art::Assns<raw::RawDigit, recob::Hit>> rawDigitAssns(new art::Assns<raw::RawDigit, recob::Hit>);
141 
142  RecobHitToPtrMap recobHitToPtrMap;
143 
144  // Use this handy art utility to make art::Ptr objects to the new recob::Hits for use in the output phase
145  art::PtrMaker<recob::Hit> ptrMaker(evt);
146 
147  // Outside loop over the input hit producers
148  for(const auto& inputTag : HitMergerfHitProducerLabelVec)
149  {
150  // Start by looking up the original hits
151  art::Handle< std::vector<recob::Hit> > hitHandle;
152  evt.getByLabel(inputTag, hitHandle);
153 
154  for(size_t hitIdx = 0; hitIdx < hitHandle->size(); hitIdx++)
155  {
156  art::Ptr<recob::Hit> hitPtr(hitHandle,hitIdx);
157 
158  const recob::Hit* hit2D = hitPtr.get();
159 
160  // Create and save the new recob::Hit with the correct WireID
161  outputHitPtrVec->emplace_back(recob::HitCreator(*hit2D, hit2D->WireID()).copy());
162 
163  // Recover a pointer to it...
164  recob::Hit* newHit = &outputHitPtrVec->back();
165 
166  // Create a mapping from this hit to an art Ptr representing it
167  recobHitToPtrMap[newHit] = ptrMaker(outputHitPtrVec->size()-1);
168  }
169  }
170 
171  // Set up to make the associations (if desired)
172  makeWireAssns(evt, *wireAssns, recobHitToPtrMap);
173 
174  makeRawDigitAssns(evt, *rawDigitAssns, recobHitToPtrMap);
175 
176  // Move everything into the event
177  evt.put(std::move(outputHitPtrVec));
178  evt.put(std::move(wireAssns));
179  evt.put(std::move(rawDigitAssns));
180 
181  return;
182 }
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
Definition: Hit.h:233
std::unordered_map< const recob::Hit *, art::Ptr< recob::Hit >> RecobHitToPtrMap
Class managing the creation of a new recob::Hit object.
Definition: HitCreator.h:83
void makeRawDigitAssns(const art::Event &, art::Assns< raw::RawDigit, recob::Hit > &, RecobHitToPtrMap &) const
Create raw::RawDigit to recob::Hit associations.
T copy(T const &v)
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
TCEvent evt
Definition: DataStructs.cxx:8
void HitMerger::reconfigure ( fhicl::ParameterSet const &  pset)
virtual

Reconfigure method.

Arguments:

pset - Fcl parameter set.

Definition at line 107 of file HitMerger_module.cc.

108 {
109  HitMergerfHitProducerLabelVec = pset.get<std::vector<art::InputTag>>("HitProducerLabelVec");
110 }
std::vector< art::InputTag > HitMergerfHitProducerLabelVec
The full collection of hits.

Member Data Documentation

std::vector<art::InputTag> HitMerger::HitMergerfHitProducerLabelVec
private

The full collection of hits.

Definition at line 71 of file HitMerger_module.cc.


The documentation for this class was generated from the following file: