11#include <vxd/simulation/SensitiveDetectorBase.h>
12#include <framework/datastore/StoreArray.h>
13#include <framework/datastore/RelationArray.h>
16#ifdef VXD_SENSITIVEDETECTOR_DEBUG
17#include <vxd/simulation/SensitiveDetectorDebugHelper.h>
93 std::vector<std::pair<unsigned int, float>> simHitIndices)
override;
102 return std::array<float, 3> {{(float)vec.x(), (float)vec.y(), (float)vec.z()}};
119 template <
class SimHitClass,
class TrueHitClass>
134 template <
class SimHitClass,
class TrueHitClass>
141 auto posEntry =
vecToFloat(traversal.front().position);
143 auto posExit =
vecToFloat(traversal.back().position);
144 auto momEntry =
vecToFloat(traversal.front().momentum);
146 auto momExit =
vecToFloat(traversal.back().momentum);
153 momEntry.data(), momMidPoint.data(), momExit.data(), energyDep, midPoint.
time);
154#ifdef VXD_SENSITIVEDETECTOR_DEBUG
160 template <
class SimHitClass,
class TrueHitClass>
165 auto posIn =
vecToFloat(points.first->position);
166 auto posOut =
vecToFloat(points.second->position);
170 int simHitIndex =
m_simhits.getEntries();
172 posIn.data(), posOut.data());
173 simhit->setEnergyDeposit(electronProfile);
174#ifdef VXD_SENSITIVEDETECTOR_DEBUG
175 int startPoint = std::distance(traversal.begin(), (SensorTraversal::const_iterator)points.first);
176 int endPoint = std::distance(traversal.begin(), (SensorTraversal::const_iterator)points.second);
182 template <
class SimHitClass,
class TrueHitClass>
184 int trueHitIndex, std::vector<std::pair<unsigned int, float>> simHitIndices)
188 if (trueHitIndex >= 0) {
190 m_relTrueSimHits.add(trueHitIndex, simHitIndices.begin(), simHitIndices.end());
static const double ehEnergy
Energy needed to create an electron-hole pair in Si at std.
Low-level class to create/modify relations between StoreArrays.
@ c_negativeWeight
Flip the sign of the weight to become negative if the original element got re-attributed.
@ c_deleteElement
Delete the whole relation element if the original element got re-attributed.
Class to keep track of the traversal of the sensitive volume for one track.
int getPDGCode() const
get PDG code of the particle
double getElectrons() const
get total number of deposited electrons so far
int getTrackID() const
get Geant4 trackID
std::pair< iterator, iterator > range
Iterator pair for a set of points.
static void registerMCParticleRelation(const std::string &name, RelationArray::EConsolidationAction ignoreAction=RelationArray::c_negativeWeight)
Register an relation involving MCParticles.
Accessor to arrays stored in the data store.
SensitiveDetectorBase(SensorInfoBase *info)
Constructor.
StepInformation findMidPoint(const SensorTraversal &traversal)
Find the mid-point of the track traversal.
VxdID getSensorID() const
Return the VxdID belonging to this sensitive detector.
std::vector< unsigned int > simplifyEnergyDeposit(const SensorTraversal::range &points)
Simplify the energy deposition profile using Douglas-Peuker-Algorithm We normally force a Geant4 step...
static SensitiveDetectorDebugHelper & getInstance()
Singleton class: get instance.
void addSimHit(const VXDSimHit *simhit, int startPoint, int endPoint)
Write the information normally used when creating SimHits to the entry.
void addTrueHit(const VXDTrueHit *truehit)
Write the information normally used when creating TrueHits to the entry.
int saveSimHit(const SensorTraversal &traversal, const SensorTraversal::range &points) override
Save a SimHit for a track along the given points.
RelationArray m_relMCTrueHits
std::array< float, 3 > vecToFloat(const G4ThreeVector &vec)
Convert G4ThreeVector (aka Hep3Vector) to float array to store in TrueHit/SimHit classes.
int saveTrueHit(const SensorTraversal &traversal) override
Save the actual TrueHit for a given sensor traversal information.
StoreArray< MCParticle > m_mcparticles
RelationArray m_relMCSimHits
RelationArray m_relTrueSimHits
void saveRelations(const SensorTraversal &traversal, int trueHitIndex, std::vector< std::pair< unsigned int, float > > simHitIndices) override
Save the relations between MCParticle, TrueHit and SimHits.
SensitiveDetector(VXD::SensorInfoBase *sensorInfo)
Construct instance and take over ownership of the sensorInfo pointer.
StoreArray< PXDTrueHit > m_truehits
StoreArray< PXDSimHit > m_simhits
Base class to provide Sensor Information for PXD and SVD.
SensitiveDetector()
Constructor.
Namespace to provide code needed by both Vertex Detectors, PXD and SVD, and also testbeam telescopes.
Abstract base class for different kinds of events.