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::tests::ParticleMaker Class Reference

Creates a collection of simulated particles. More...

Inheritance diagram for lar::example::tests::ParticleMaker:

Classes

struct  Config
 
struct  ParticleConfig
 
struct  ParticleSpecs
 

Public Types

using Parameters = art::EDProducer::Table< Config >
 

Public Member Functions

 ParticleMaker (Parameters const &config)
 Constructor; see the class documentation for the configuration. More...
 
virtual void produce (art::Event &event) override
 Create and add the particles (the same for all events). More...
 

Private Attributes

std::vector< ParticleSpecsfParticleSpecs
 Settings for particles. More...
 

Detailed Description

Creates a collection of simulated particles.

A collection of simb::MCParticle is added to the event. The particles are one starting where the previous one ended (starting from the origin). The configuration specifies the number, type and energy of the particles, and their path length.

Configuration parameters

Definition at line 60 of file ParticleMaker_module.cc.

Member Typedef Documentation

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

Definition at line 98 of file ParticleMaker_module.cc.

Constructor & Destructor Documentation

lar::example::tests::ParticleMaker::ParticleMaker ( Parameters const &  config)
explicit

Constructor; see the class documentation for the configuration.

Definition at line 138 of file ParticleMaker_module.cc.

139  : EDProducer{config}
140 {
141 
142  auto const& particleSpecs = config().particles();
143  fParticleSpecs.assign(particleSpecs.begin(), particleSpecs.end());
144 
145  // consumes: nothing
146 
147  // produces:
148  produces<std::vector<simb::MCParticle>>();
149 
150 } // lar::example::tests::ParticleMaker::ParticleMaker()
std::vector< ParticleSpecs > fParticleSpecs
Settings for particles.

Member Function Documentation

void lar::example::tests::ParticleMaker::produce ( art::Event &  event)
overridevirtual

Create and add the particles (the same for all events).

Definition at line 154 of file ParticleMaker_module.cc.

154  {
155 
156  //
157  // set up
158  //
159 
160  // container for the data product
161  auto particles = std::make_unique<std::vector<simb::MCParticle>>();
162 
163  //
164  // creation of the particles
165  //
166  static std::array<TVector3, 6U> const Dirs = {{
167  geo::vect::rounded01( geo::Xaxis<TVector3>(), 1e-8),
168  geo::vect::rounded01( geo::Yaxis<TVector3>(), 1e-8),
169  geo::vect::rounded01( geo::Zaxis<TVector3>(), 1e-8),
170  geo::vect::rounded01(-geo::Xaxis<TVector3>(), 1e-8),
171  geo::vect::rounded01(-geo::Yaxis<TVector3>(), 1e-8),
172  geo::vect::rounded01(-geo::Zaxis<TVector3>(), 1e-8)
173  }}; // Dirs
174 
175  int trackID = 0;
176  TLorentzVector pos;
177  for (auto const& specs: fParticleSpecs) {
178 
179  int const motherID = trackID - 1;
180  if (motherID >= 0) (*particles)[motherID].AddDaughter(trackID);
181 
182  particles->emplace_back(
183  trackID // track ID
184  , specs.type // pdg
185  , "magic" // process
186  , motherID // mother
187  );
188  simb::MCParticle& particle = particles->back();
189 
190  auto const& dir = Dirs[trackID % 6];
191  TLorentzVector const mom{ specs.energy * dir, specs.energy };
192  unsigned int const nSteps = std::ceil(specs.length);
193  particle.AddTrajectoryPoint(pos, mom);
194  for (unsigned int i = 1; i <= nSteps; ++i) {
195  double const stepSize = std::min(specs.length - double(i - 1), 1.0);
196  pos += TLorentzVector{ dir * stepSize, 1.0 };
197  particle.AddTrajectoryPoint(pos, mom);
198  } // for
199 
200  ++trackID;
201 
202  } // for specs
203 
204  //
205  // result storage
206  //
207  mf::LogInfo("ParticleMaker")
208  << "Created " << particles->size() << " space points.";
209 
210  event.put(std::move(particles));
211 
212 } // lar::example::tests::ParticleMaker::produce()
Vector rounded01(Vector const &v, Scalar tol)
Returns a vector with all components rounded if close to 0, -1 or +1.
tuple dir
Definition: dropbox.py:28
std::vector< ParticleSpecs > fParticleSpecs
Settings for particles.
do i e

Member Data Documentation

std::vector<ParticleSpecs> lar::example::tests::ParticleMaker::fParticleSpecs
private

Settings for particles.

Definition at line 120 of file ParticleMaker_module.cc.


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