All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
lar::example::TotallyCheatTracker Class Reference

Module: creates tracks from simulated particles. More...

Inheritance diagram for lar::example::TotallyCheatTracker:

Classes

struct  Config
 Module configuration data. More...
 

Public Types

using Parameters = art::EDProducer::Table< Config >
 Standard art alias for module configuration table. More...
 

Public Member Functions

 TotallyCheatTracker (Parameters const &config)
 Constructor; see the class documentation for the configuration. More...
 
virtual void produce (art::Event &event) override
 
bool acceptParticle (simb::MCParticle const &particle) const
 Returns whether the particle satisfies the selection criteria. More...
 

Private Attributes

art::InputTag particleTag
 Label of the input data product. More...
 
double minLength
 Minimum particle length [cm]. More...
 
double minEnergy
 Minimum energy [GeV]. More...
 
lar::example::TotallyCheatTrackingAlg trackMaker
 Reconstruction algorithm. More...
 

Detailed Description

Module: creates tracks from simulated particles.

See Also
TotallyCheatTracks example overview

This module creates one LArSoft reconstructed track (lar::example::CheatTrack) for each input simulated particle (simb::MCParticle) passing the selection criteria.

Input

A collection of simb::MCParticle is required.

Output

A collection of lar::example::CheatTrack is produced, a one-to-one association of each of them to its original simb::MCParticle. Associations are inserted in the same order as the trajectories.

Configuration parameters

Definition at line 73 of file TotallyCheatTracker_module.cc.

Member Typedef Documentation

using lar::example::TotallyCheatTracker::Parameters = art::EDProducer::Table<Config>

Standard art alias for module configuration table.

Definition at line 110 of file TotallyCheatTracker_module.cc.

Constructor & Destructor Documentation

lar::example::TotallyCheatTracker::TotallyCheatTracker ( Parameters const &  config)
explicit

Constructor; see the class documentation for the configuration.

Definition at line 144 of file TotallyCheatTracker_module.cc.

145  : EDProducer{config}
146  , particleTag(config().particles())
147  , minLength(config().minLength())
148  , minEnergy(config().minEnergy())
149  , trackMaker(config().algoConfig())
150 {
151 
152  consumes<std::vector<simb::MCParticle>>(particleTag);
153 
154  produces<std::vector<lar::example::CheatTrack>>();
155  produces<art::Assns<lar::example::CheatTrack, simb::MCParticle>>();
156 
157 } // lar::example::TotallyCheatTracker::TotallyCheatTracker()
double minLength
Minimum particle length [cm].
lar::example::TotallyCheatTrackingAlg trackMaker
Reconstruction algorithm.
art::InputTag particleTag
Label of the input data product.

Member Function Documentation

bool lar::example::TotallyCheatTracker::acceptParticle ( simb::MCParticle const &  particle) const

Returns whether the particle satisfies the selection criteria.

Definition at line 228 of file TotallyCheatTracker_module.cc.

229 {
230  // skip empty particle
231  if (particle.NumberTrajectoryPoints() == 0) return false;
232 
233  // energy at the first point
234  if (particle.E() < minEnergy) return false;
235 
236  // path length
237  if (particle.Trajectory().TotalLength() < minLength) return false;
238 
239  // good enough!
240  return true;
241 
242 } // lar::example::TotallyCheatTracker::acceptParticle()
double minLength
Minimum particle length [cm].
void lar::example::TotallyCheatTracker::produce ( art::Event &  event)
overridevirtual

Definition at line 161 of file TotallyCheatTracker_module.cc.

161  {
162 
163  //
164  // read the input
165  //
166  auto particleHandle
167  = event.getValidHandle<std::vector<simb::MCParticle>>(particleTag);
168  auto const& particles = *particleHandle;
169 
170  //
171  // prepare the output structures
172  //
173  auto tracks = std::make_unique<std::vector<lar::example::CheatTrack>>();
174  auto trackToPart =
175  std::make_unique<art::Assns<lar::example::CheatTrack, simb::MCParticle>>();
176 
177  art::PtrMaker<simb::MCParticle> makePartPtr(event, particleHandle.id());
178  art::PtrMaker<lar::example::CheatTrack> makeTrackPtr(event);
179 
180 
181  //
182  // set up the algorithm
183  //
184  trackMaker.setup();
185 
186  //
187  // run the algorithm
188  //
189  for (std::size_t iParticle = 0U; iParticle < particles.size(); ++iParticle) {
190  simb::MCParticle const& particle = particles[iParticle];
191 
192  //
193  // apply filters
194  //
195  if (!acceptParticle(particle)) continue;
196 
197  //
198  // run the algorithm
199  //
200  tracks->push_back(trackMaker.makeTrack(particle));
201 
202  //
203  // create the association
204  //
205  auto const iTrack = tracks->size() - 1;
206  art::Ptr<lar::example::CheatTrack> const trackPtr = makeTrackPtr(iTrack);
207  art::Ptr<simb::MCParticle> const partPtr = makePartPtr(iParticle);
208  trackToPart->addSingle(trackPtr, partPtr);
209 
210  } // for
211 
212  //
213  // store the data products into the event (and print a short summary)
214  //
215  mf::LogInfo("TotallyCheatTracker")
216  << "Reconstructed " << tracks->size() << " tracks out of "
217  << particleHandle->size() << " particles from '"
218  << particleTag.encode() << "'";
219 
220  event.put(std::move(tracks));
221  event.put(std::move(trackToPart));
222 
223 } // lar::example::TotallyCheatTracker::produce()
ClusterModuleLabel join with tracks
bool acceptParticle(simb::MCParticle const &particle) const
Returns whether the particle satisfies the selection criteria.
lar::example::CheatTrack makeTrack(simb::MCParticle const &mcParticle) const
Returns a reconstructed track from the specified particle.
void setup()
Set up the algorithm (currently no operation).
lar::example::TotallyCheatTrackingAlg trackMaker
Reconstruction algorithm.
art::InputTag particleTag
Label of the input data product.

Member Data Documentation

double lar::example::TotallyCheatTracker::minEnergy
private

Minimum energy [GeV].

Definition at line 127 of file TotallyCheatTracker_module.cc.

double lar::example::TotallyCheatTracker::minLength
private

Minimum particle length [cm].

Definition at line 126 of file TotallyCheatTracker_module.cc.

art::InputTag lar::example::TotallyCheatTracker::particleTag
private

Label of the input data product.

Definition at line 124 of file TotallyCheatTracker_module.cc.

lar::example::TotallyCheatTrackingAlg lar::example::TotallyCheatTracker::trackMaker
private

Reconstruction algorithm.

Definition at line 130 of file TotallyCheatTracker_module.cc.


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