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:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Classes

struct  Config
 Module configuration data. More...
 

Public Types

using Parameters = art::EDProducer::Table< Config >
 Standard art alias for module configuration table. More...
 
- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 

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...
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

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...
 

Additional Inherited Members

- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

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

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()
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
double minLength
Minimum particle length [cm].
static Config * config
Definition: config.cpp:1054
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

Implements art::EDProducer.

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()
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::string encode() const
Definition: InputTag.cc:97
def move(depos, offset)
Definition: depos.py:107
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.
Definition: tracks.py:1
art::InputTag particleTag
Label of the input data product.
Definition: fwd.h:31
EventID id() const
Definition: Event.cc:34

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: