45 typedef std::pair<const GeomDet*, TrajectoryStateOnSurface>
DetWithState;
71 std::vector<std::unique_ptr<Particle>>& secondaries,
93 double layerThickness,
124 simHitContainer_ = std::make_unique<edm::PSimHitContainer>();
129 std::vector<std::unique_ptr<Particle>>& secondaries,
138 if (!doHitsFromInboundParticles_) {
156 if (!
layer.getDetLayer()) {
170 if (particle.
charge() == 0) {
177 if (particle.
momentum().Perp2() < minMomentum_ * minMomentum_) {
185 auto plane =
layer.getDetLayer()->surface().tangentPlane(
position);
192 std::vector<DetWithState> compatibleDetectors =
layer.getDetLayer()->compatibleDets(trajectory,
propagator, est);
202 std::map<double, std::unique_ptr<PSimHit>> distAndHits;
214 for (
const auto& detectorWithState : compatibleDetectors) {
220 std::pair<double, std::unique_ptr<PSimHit>> hitPair = createHitOnDetector(particleState,
227 if (hitPair.second) {
228 distAndHits.insert(distAndHits.end(),
std::move(hitPair));
232 for (
const auto component :
detector.components()) {
233 std::pair<double, std::unique_ptr<PSimHit>> hitPair =
234 createHitOnDetector(particleState,
241 if (hitPair.second) {
242 distAndHits.insert(distAndHits.end(),
std::move(hitPair));
249 for (
std::map<
double, std::unique_ptr<PSimHit>>::const_iterator it = distAndHits.begin(); it != distAndHits.end();
251 simHitContainer_->push_back(*(it->second));
259 double layerThickness,
280 std::pair<bool, double>
path = crossing.pathLength(
detector.surface());
289 return std::pair<double, std::unique_ptr<PSimHit>>(0, std::unique_ptr<PSimHit>(
nullptr));
296 double pZ = localMomentum.
z();
298 LocalPoint exit = localPosition + (halfThick / pZ) * localMomentum;
302 double boundX = detectorPlane.
bounds().
width() / 2.;
305 unsigned subdet =
DetId(
detector.geographicalId()).subdetId();
306 if (subdet == 4 || subdet == 6)
307 boundX *= 1. - localPosition.
y() / detectorPlane.
position().
perp();
308 if (fabs(localPosition.
x()) > boundX || fabs(localPosition.
y()) > boundY) {
309 return std::pair<double, std::unique_ptr<PSimHit>>(0, std::unique_ptr<PSimHit>(
nullptr));
316 eLoss *= (2. * halfThick - 0.003) / (9.36 * layerThickness);
321 return std::pair<double, std::unique_ptr<PSimHit>>((hitPos - refPos).
mag(),
322 std::make_unique<PSimHit>(
entry,
330 localMomentum.
theta(),
331 localMomentum.
phi()));
TrackerSimHitProducer(const std::string &name, const edm::ParameterSet &cfg)
Constructor.
int getMotherSimTrackIndex() const
Get index of simTrack of mother particle (only makes sense if mother and daughter charged)...
Implementation of a generic detector layer (base class for forward/barrel layers).
virtual float length() const =0
LocalPoint localPosition() const
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
void registerProducts(edm::ProducesCollector) const override
Register the SimHit collection.
Geom::Phi< T > phi() const
Global3DPoint GlobalPoint
static double constexpr speedOfLight
Speed of light [cm / ns].
const math::XYZTLorentzVector & position() const
Return position of the particle.
std::unique_ptr< edm::PSimHitContainer > simHitContainer_
The SimHit.
constexpr std::array< uint8_t, layerIndexSize > layer
virtual float thickness() const =0
~TrackerSimHitProducer() override
Default destructor.
Base class for any interaction model between a particle and a tracker layer.
Produces SimHits in the tracker layers.
void setLooper()
This particle is about to do a loop in the tracker or the direction of the momentum is going inwards...
bool doHitsFromInboundParticles_
If not set, incoming particles (negative speed relative to center of detector) don't create a SimHits...
GlobalPoint globalPosition() const
std::pair< double, std::unique_ptr< PSimHit > > createHitOnDetector(const TrajectoryStateOnSurface &particle, int pdgId, double layerThickness, double eLoss, int simTrackId, const GeomDet &detector, GlobalPoint &refPos)
Helper funtion to create the actual SimHit on a detector (sub-) module.
double getEnergyDeposit() const
Return the energy the particle deposited in the tracker layer that was last hit (ionization).
LocalVector localMomentum() const
int simTrackIndex() const
Return index of the SimTrack.
const BasicVectorType & basicVector() const
int pdgId() const
Return pdgId of the particle.
double isLooper() const
Check if this particle is about to do a loop in the tracker or the direction of the momentum is going...
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const PositionType & position() const
double minMomentum_
Set the minimal momentum of incoming particle.
void storeProducts(edm::Event &iEvent) override
Store the SimHit collection.
double transverseCurvature() const
const math::XYZTLorentzVector & momentum() const
Return momentum of the particle.
GlobalVector globalMomentum() const
void interact(Particle &particle, const SimplifiedGeometry &layer, std::vector< std::unique_ptr< Particle >> &secondaries, const RandomEngineAndDistribution &random) override
Perform the interaction.
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
double charge() const
Return charge of the particle.
static int position[264][3]
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< PSimHit > PSimHitContainer
Vector3DBase unit() const
virtual float width() const =0
void setEnergyDeposit(double energyDeposit)
Set the energy the particle deposited in the tracker layer that was last hit (ionization).
Global3DVector GlobalVector
Geom::Theta< T > theta() const
const double onSurfaceTolerance_
Max distance between particle and active (sub-) module. Otherwise particle has to be propagated...
const Bounds & bounds() const