13 #include "nusimdata/SimulationBase/MCParticle.h"
16 #include "art/Framework/Core/EDProducer.h"
17 #include "art/Framework/Core/ModuleMacros.h"
18 #include "art/Framework/Principal/Event.h"
19 #include "messagefacility/MessageLogger/MessageLogger.h"
20 #include "fhiclcpp/types/Atom.h"
21 #include "fhiclcpp/types/Sequence.h"
22 #include "fhiclcpp/types/Table.h"
26 #include "TLorentzVector.h"
71 Comment(
"length of the particle path [cm]")
76 Comment(
"initial energy of the particle [GeV]")
81 Comment(
"particle type (as PDG ID)")
91 fhicl::Sequence<fhicl::Table<ParticleConfig>>
particles{
93 Comment(
"list of particle specification")
104 virtual void produce(art::Event& event)
override;
142 auto const& particleSpecs = config().particles();
143 fParticleSpecs.assign(particleSpecs.begin(), particleSpecs.end());
148 produces<std::vector<simb::MCParticle>>();
161 auto particles = std::make_unique<std::vector<simb::MCParticle>>();
166 static std::array<TVector3, 6U>
const Dirs = {{
177 for (
auto const& specs: fParticleSpecs) {
179 int const motherID = trackID - 1;
180 if (motherID >= 0) (*particles)[motherID].AddDaughter(trackID);
182 particles->emplace_back(
188 simb::MCParticle& particle = particles->back();
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);
207 mf::LogInfo(
"ParticleMaker")
208 <<
"Created " << particles->size() <<
" space points.";
210 event.put(std::move(particles));
fhicl::Atom< double > energy
virtual void produce(art::Event &event) override
Create and add the particles (the same for all events).
Creates a collection of simulated particles.
art::EDProducer::Table< Config > Parameters
ParticleMaker(Parameters const &config)
Constructor; see the class documentation for the configuration.
Definitions of geometry vector data types.
fhicl::Sequence< fhicl::Table< ParticleConfig > > particles
Utilities to extend the interface of geometry vectors.
BEGIN_PROLOG vertical distance to the surface Name
Vector rounded01(Vector const &v, Scalar tol)
Returns a vector with all components rounded if close to 0, -1 or +1.
std::vector< ParticleSpecs > fParticleSpecs
Settings for particles.
ParticleSpecs(ParticleConfig const &config)
fhicl::Atom< double > length