17 #include "nusimdata/SimulationBase/MCParticle.h"
20 #include "art/Framework/Core/EDProducer.h"
21 #include "art/Framework/Core/ModuleMacros.h"
22 #include "art/Framework/Principal/Event.h"
23 #include "art/Framework/Principal/Handle.h"
24 #include "art/Persistency/Common/PtrMaker.h"
25 #include "canvas/Persistency/Common/Assns.h"
26 #include "canvas/Persistency/Common/Ptr.h"
27 #include "canvas/Utilities/InputTag.h"
28 #include "messagefacility/MessageLogger/MessageLogger.h"
29 #include "fhiclcpp/types/Atom.h"
30 #include "fhiclcpp/types/Table.h"
85 Comment(
"the data product of simulated particles to be processed"),
91 Comment(
"minimum length of particle trajectory [cm]"),
97 Comment(
"minimum energy of particle [GeV]"),
101 fhicl::Table<lar::example::TotallyCheatTrackingAlg::Config>
algoConfig {
103 Comment(
"configuration of TotallyCheatTrackingAlg algorithm"),
116 virtual void produce(art::Event& event)
override;
146 , particleTag(config().particles())
147 , minLength(config().minLength())
148 , minEnergy(config().minEnergy())
149 , trackMaker(config().algoConfig())
152 consumes<std::vector<simb::MCParticle>>(particleTag);
154 produces<std::vector<lar::example::CheatTrack>>();
155 produces<art::Assns<lar::example::CheatTrack, simb::MCParticle>>();
167 =
event.getValidHandle<std::vector<simb::MCParticle>>(
particleTag);
168 auto const& particles = *particleHandle;
173 auto tracks = std::make_unique<std::vector<lar::example::CheatTrack>>();
175 std::make_unique<art::Assns<lar::example::CheatTrack, simb::MCParticle>>();
177 art::PtrMaker<simb::MCParticle> makePartPtr(event, particleHandle.id());
178 art::PtrMaker<lar::example::CheatTrack> makeTrackPtr(event);
189 for (std::size_t iParticle = 0U; iParticle < particles.size(); ++iParticle) {
190 simb::MCParticle
const& particle = particles[iParticle];
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);
215 mf::LogInfo(
"TotallyCheatTracker")
216 <<
"Reconstructed " <<
tracks->size() <<
" tracks out of "
217 << particleHandle->size() <<
" particles from '"
220 event.put(std::move(
tracks));
221 event.put(std::move(trackToPart));
228 (simb::MCParticle
const& particle)
const
231 if (particle.NumberTrajectoryPoints() == 0)
return false;
234 if (particle.E() < minEnergy)
return false;
237 if (particle.Trajectory().TotalLength() < minLength)
return false;
art::EDProducer::Table< Config > Parameters
Standard art alias for module configuration table.
Reconstructs tracks from simulated particles.
ClusterModuleLabel join with tracks
virtual void produce(art::Event &event) override
double minLength
Minimum particle length [cm].
Algorithm to "reconstruct" trajectories from simulated particles.
fhicl::Table< lar::example::TotallyCheatTrackingAlg::Config > algoConfig
double minEnergy
Minimum energy [GeV].
Pseudo-track data product for TotallyCheatTracks example.
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.
BEGIN_PROLOG vertical distance to the surface Name
void setup()
Set up the algorithm (currently no operation).
fhicl::Atom< double > minLength
lar::example::TotallyCheatTrackingAlg trackMaker
Reconstruction algorithm.
Module: creates tracks from simulated particles.
fhicl::Atom< double > minEnergy
Module configuration data.
TotallyCheatTracker(Parameters const &config)
Constructor; see the class documentation for the configuration.
fhicl::Atom< art::InputTag > particles
art::InputTag particleTag
Label of the input data product.