3 #include "HepMC/GenEvent.h" 4 #include "HepMC/Units.h" 5 #include "HepPDT/ParticleDataTable.hh" 24 : genEvent_(&genEvent),
25 genParticleIterator_(genEvent_->particles_begin()),
26 genParticleEnd_(genEvent_->particles_end()),
28 particleDataTable_(&particleDataTable),
29 beamPipeRadius2_(beamPipeRadius * beamPipeRadius),
30 deltaRchargedMother_(deltaRchargedMother),
31 particleFilter_(&particleFilter),
32 simTracks_(&simTracks),
33 simVertices_(&simVertices)
43 momentumUnitConversionFactor_(conversion_factor(genEvent_->momentum_unit(),
HepMC::Units::GEV)),
44 lengthUnitConversionFactor_(conversion_factor(genEvent_->length_unit(),
HepMC::Units::LengthUnit::CM)),
45 lengthUnitConversionFactor2_(lengthUnitConversionFactor_ * lengthUnitConversionFactor_),
50 if (genEvent.vertices_begin() !=
genEvent_->vertices_end()) {
51 const HepMC::FourVector&
position = (*genEvent.vertices_begin())->
position();
63 std::unique_ptr<fastsim::Particle> particle;
83 if (!particle->remainingProperLifeTimeIsSet() || !particle->chargeIsSet()) {
89 particle->setRemainingProperLifeTimeC(0.);
90 particle->setCharge(0.);
94 if (!particle->remainingProperLifeTimeIsSet()) {
97 double width = particleData->totalWidth().value();
98 if (width > 1.0
e-35) {
99 particle->setRemainingProperLifeTimeC(-
log(random.
flatShoot()) * 6.582119
e-25 / width / 10.);
101 particle->setStable();
106 if (!particle->chargeIsSet()) {
107 particle->setCharge(particleData->charge());
112 unsigned simTrackIndex =
addSimTrack(particle.get());
113 particle->setSimTrackIndex(simTrackIndex);
120 int parentSimTrackIndex,
121 std::vector<std::unique_ptr<Particle> >& secondaries,
129 if (secondaries.empty()) {
134 unsigned simVertexIndex =
addSimVertex(vertexPosition, parentSimTrackIndex);
141 for (
auto& secondary : secondaries) {
143 if (secondary->getMotherDeltaR() != -1) {
146 secondary->resetMother();
148 if (secondary->getMotherDeltaR() <
distMin) {
149 distMin = secondary->getMotherDeltaR();
158 for (
auto& secondary : secondaries) {
162 if (secondary->getMotherDeltaR() != -1 && idx != idxMin) {
163 secondary->resetMother();
168 secondary->setSimVertexIndex(simVertexIndex);
184 simVertices_->emplace_back(position.Vect(), position.T(), parentSimTrackIndex, simVertexIndex);
185 return simVertexIndex;
193 return simTrackIndex;
207 const HepMC::GenVertex* productionVertex = particle.production_vertex();
208 const HepMC::GenVertex* endVertex = particle.end_vertex();
211 if (!productionVertex) {
226 std::unique_ptr<Particle> newParticle(
240 double labFrameLifeTime =
242 newParticle->setRemainingProperLifeTimeC(labFrameLifeTime / newParticle->gamma() *
248 bool foundVtx =
false;
250 if (
std::abs(simVtx.position().x() - newParticle->position().x()) < 1E-3 &&
251 std::abs(simVtx.position().y() - newParticle->position().y()) < 1E-3 &&
252 std::abs(simVtx.position().z() - newParticle->position().z()) < 1E-3) {
253 newParticle->setSimVertexIndex(simVtx.vertexId());
259 newParticle->setSimVertexIndex(
addSimVertex(newParticle->position(), -1));
268 return std::unique_ptr<Particle>();
Implementation of a generic detector layer (base class for forward/barrel layers).
const math::XYZTLorentzVector & position() const
Return position of the particle.
double flatShoot(double xmin=0.0, double xmax=1.0) const
HepPDT::ParticleDataTable ParticleDataTable
const double deltaRchargedMother_
For FastSim (cheat) tracking: cut on the angle between a charged mother and charged daughter...
bool accepts(const Particle &particle) const
Check all if all criteria are fullfilled.
const ParticleFilter *const particleFilter_
(Kinematic) cuts on the particles that have to be propagated.
int genParticleIndex() const
Return index of the particle in the genParticle vector.
double momentumUnitConversionFactor_
Convert pythia units to GeV (FastSim standard)
std::vector< std::unique_ptr< Particle > > particleBuffer_
The vector of all secondaries that are not yet propagated in the event.
static double constexpr speedOfLight
Speed of light [cm / ns].
virtual bool isForward() const =0
Returns false/true depending if the object is a (non-abstract) barrel/forward layer.
HepMC::GenEvent::particle_const_iterator genParticleIterator_
Iterator to keep track on which GenParticles where already considered.
int pdgId() const
Return pdgId of the particle.
const HepMC::GenEvent *const genEvent_
The GenEvent.
const HepMC::GenEvent::particle_const_iterator genParticleEnd_
The last particle of the GenEvent.
double lengthUnitConversionFactor2_
Convert pythia unis to cm^2 (FastSim standard)
unsigned addSimTrack(const Particle *particle)
Add a simTrack (simTrack contains some basic info about the particle, e.g. pdgId).
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
int simVertexIndex() const
Return index of the origin vertex.
const double beamPipeRadius2_
(Radius of the beampipe)^2
ParticleManager(const HepMC::GenEvent &genEvent, const HepPDT::ParticleDataTable &particleDataTable, double beamPipeRadius, double deltaRchargedMother, const ParticleFilter &particleFilter, std::vector< SimTrack > &simTracks, std::vector< SimVertex > &simVertices)
Constructor.
~ParticleManager()
Default destructor.
Abs< T >::type abs(const T &t)
void addSecondaries(const math::XYZTLorentzVector &vertexPosition, int motherSimTrackId, std::vector< std::unique_ptr< Particle > > &secondaries, const SimplifiedGeometry *layer=nullptr)
Adds secondaries that are produced by any of the interactions (or particle decay) to the buffer...
std::unique_ptr< Particle > nextParticle(const RandomEngineAndDistribution &random)
Returns the next particle that has to be propagated (secondary or genParticle).
HepPDT::ParticleData ParticleData
int simTrackIndex() const
Return index of the SimTrack.
std::vector< SimTrack > * simTracks_
The generated SimTrack of this event.
std::unique_ptr< Particle > nextGenParticle()
Returns next particle from the GenEvent that has to be propagated.
double lengthUnitConversionFactor_
Convert pythia unis to cm (FastSim standard)
const HepPDT::ParticleDataTable *const particleDataTable_
Necessary to get information like lifetime and charge of a particle if unknown.
double timeUnitConversionFactor_
Convert pythia unis to ns (FastSim standard)
int index() const
Return index of this layer (layers are numbered according to their position in the detector)...
static int position[264][3]
std::vector< SimVertex > * simVertices_
The generated SimVertices of this event.
const math::XYZTLorentzVector & momentum() const
Return momentum of the particle.
(Kinematic) cuts on the particles that are propagated.
Definition of a generic FastSim Particle which can be propagated through the detector (formerly Parti...
int genParticleIndex_
Index of particle in the GenEvent (if it is a GenParticle)
unsigned addSimVertex(const math::XYZTLorentzVector &position, int motherIndex)
Add a simVertex (simVertex contains information about the track it was produced). ...
unsigned addEndVertex(const Particle *particle)
Necessary to add an end vertex to a particle.
bool acceptsVtx(const math::XYZTLorentzVector &originVertexPosition) const
Vertex within tracker volume.