10#ifndef VXD_SIMULATION_SENSITIVEDETECTOR_H
11#define VXD_SIMULATION_SENSITIVEDETECTOR_H
13#include <vxd/simulation/SensitiveDetectorBase.h>
14#include <framework/datastore/StoreArray.h>
15#include <framework/datastore/RelationArray.h>
18#ifdef VXD_SENSITIVEDETECTOR_DEBUG
19#include <vxd/simulation/SensitiveDetectorDebugHelper.h>
95 std::vector<std::pair<unsigned int, float>> simHitIndices)
override;
104 return std::array<float, 3> {{(float)vec.x(), (float)vec.y(), (float)vec.z()}};
121 template <
class SimHitClass,
class TrueHitClass>
136 template <
class SimHitClass,
class TrueHitClass>
143 auto posEntry = vecToFloat(traversal.front().position);
144 auto posMidPoint = vecToFloat(midPoint.
position);
145 auto posExit = vecToFloat(traversal.back().position);
146 auto momEntry = vecToFloat(traversal.front().momentum);
147 auto momMidPoint = vecToFloat(midPoint.
momentum);
148 auto momExit = vecToFloat(traversal.back().momentum);
153 int trueHitIndex = m_truehits.getEntries();
154 m_truehits.appendNew(getSensorID(), posEntry.data(), posMidPoint.data(), posExit.data(),
155 momEntry.data(), momMidPoint.data(), momExit.data(), energyDep, midPoint.
time);
156#ifdef VXD_SENSITIVEDETECTOR_DEBUG
162 template <
class SimHitClass,
class TrueHitClass>
167 auto posIn = vecToFloat(points.first->position);
168 auto posOut = vecToFloat(points.second->position);
169 auto electronProfile = simplifyEnergyDeposit(points);
172 int simHitIndex = m_simhits.getEntries();
173 SimHitClass* simhit = m_simhits.appendNew(getSensorID(), traversal.
getPDGCode(), points.first->time,
174 posIn.data(), posOut.data());
175 simhit->setEnergyDeposit(electronProfile);
176#ifdef VXD_SENSITIVEDETECTOR_DEBUG
177 int startPoint = std::distance(traversal.begin(), (SensorTraversal::const_iterator)points.first);
178 int endPoint = std::distance(traversal.begin(), (SensorTraversal::const_iterator)points.second);
184 template <
class SimHitClass,
class TrueHitClass>
186 int trueHitIndex, std::vector<std::pair<unsigned int, float>> simHitIndices)
188 m_relMCSimHits.add(traversal.
getTrackID(), simHitIndices.begin(), simHitIndices.end());
190 if (trueHitIndex >= 0) {
192 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.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
Accessor to arrays stored in the data store.
Base class for Sensitive Detector implementation of PXD and SVD.
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.
Sensitive Detector implementation of PXD and SVD.
int saveSimHit(const SensorTraversal &traversal, const SensorTraversal::range &points) override
Save a SimHit for a track along the given points.
RelationArray m_relMCTrueHits
Relation between MCParticle and TrueHits.
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
StoreArray for the MCParticles, needed by relations.
RelationArray m_relMCSimHits
Relation between MCParticle and SimHits.
RelationArray m_relTrueSimHits
Relation between TrueHits and SimHits.
void saveRelations(const SensorTraversal &traversal, int trueHitIndex, std::vector< std::pair< unsigned int, float > > simHitIndices) override
Save the relations between MCParticle, TrueHit and SimHits.
StoreArray< TrueHitClass > m_truehits
StoreArray for the TrueHits.
StoreArray< SimHitClass > m_simhits
StoreArray for the SimHits.
Base class to provide Sensor Information for PXD and SVD.
SensitiveDetector()
Constructor.
Abstract base class for different kinds of events.