 |
Belle II Software
release-05-01-25
|
13 #ifndef VXD_SIMULATION_SENSITIVEDETECTOR_H
14 #define VXD_SIMULATION_SENSITIVEDETECTOR_H
16 #include <vxd/simulation/SensitiveDetectorBase.h>
17 #include <framework/datastore/StoreArray.h>
18 #include <framework/datastore/RelationArray.h>
21 #ifdef VXD_SENSITIVEDETECTOR_DEBUG
22 #include <vxd/simulation/SensitiveDetectorDebugHelper.h>
98 std::vector<std::pair<unsigned int, float>> simHitIndices)
override;
107 return std::array<float, 3> {{(float)vec.x(), (float)vec.y(), (float)vec.z()}};
124 template <
class SimHitClass,
class TrueHitClass>
139 template <
class SimHitClass,
class TrueHitClass>
146 auto posEntry = vecToFloat(traversal.front().position);
147 auto posMidPoint = vecToFloat(midPoint.
position);
148 auto posExit = vecToFloat(traversal.back().position);
149 auto momEntry = vecToFloat(traversal.front().momentum);
150 auto momMidPoint = vecToFloat(midPoint.
momentum);
151 auto momExit = vecToFloat(traversal.back().momentum);
156 int trueHitIndex = m_truehits.getEntries();
157 m_truehits.appendNew(getSensorID(), posEntry.data(), posMidPoint.data(), posExit.data(),
158 momEntry.data(), momMidPoint.data(), momExit.data(), energyDep, midPoint.
time);
159 #ifdef VXD_SENSITIVEDETECTOR_DEBUG
165 template <
class SimHitClass,
class TrueHitClass>
170 auto posIn = vecToFloat(points.first->position);
171 auto posOut = vecToFloat(points.second->position);
172 auto electronProfile = simplifyEnergyDeposit(points);
175 int simHitIndex = m_simhits.getEntries();
176 SimHitClass* simhit = m_simhits.appendNew(getSensorID(), traversal.
getPDGCode(), points.first->time,
177 posIn.data(), posOut.data());
178 simhit->setEnergyDeposit(electronProfile);
179 #ifdef VXD_SENSITIVEDETECTOR_DEBUG
180 int startPoint = std::distance(traversal.begin(), (SensorTraversal::const_iterator)points.first);
181 int endPoint = std::distance(traversal.begin(), (SensorTraversal::const_iterator)points.second);
187 template <
class SimHitClass,
class TrueHitClass>
189 int trueHitIndex, std::vector<std::pair<unsigned int, float>> simHitIndices)
191 m_relMCSimHits.add(traversal.
getTrackID(), simHitIndices.begin(), simHitIndices.end());
193 if (trueHitIndex >= 0) {
195 m_relTrueSimHits.add(trueHitIndex, simHitIndices.begin(), simHitIndices.end());
Low-level class to create/modify relations between StoreArrays.
Class to keep track of the traversal of the sensitive volume for one track.
@ c_negativeWeight
Flip the sign of the weight to become negative if the original element got re-attributed.
RelationArray m_relMCSimHits
Relation between MCParticle and SimHits.
double getElectrons() const
get total number of deposited electrons so far
Base class for Sensitive Detector implementation of PXD and SVD.
Base class to provide Sensor Information for PXD and SVD.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
void addSimHit(const VXDSimHit *simhit, int startPoint, int endPoint)
Write the information normally used when creating SimHits to the entry.
static void registerMCParticleRelation(const std::string &name, RelationArray::EConsolidationAction ignoreAction=RelationArray::c_negativeWeight)
Register an relation involving MCParticles.
RelationArray m_relMCTrueHits
Relation between MCParticle and TrueHits.
StoreArray< SimHitClass > m_simhits
StoreArray for the SimHits.
int getPDGCode() const
get PDG code of the particle
void saveRelations(const SensorTraversal &traversal, int trueHitIndex, std::vector< std::pair< unsigned int, float >> simHitIndices) override
Save the relations between MCParticle, TrueHit and SimHits.
int getTrackID() const
get Geant4 trackID
Abstract base class for different kinds of events.
@ c_deleteElement
Delete the whole relation element if the original element got re-attributed.
std::pair< iterator, iterator > range
Iterator pair for a set of points.
int saveTrueHit(const SensorTraversal &traversal) override
Save the actual TrueHit for a given sensor traversal information.
void addTrueHit(const VXDTrueHit *truehit)
Write the information normally used when creating TrueHits to the entry.
SensitiveDetector(VXD::SensorInfoBase *sensorInfo)
Construct instance and take over ownership of the sensorInfo pointer.
static SensitiveDetectorDebugHelper & getInstance()
Singleton class: get instance.
std::array< float, 3 > vecToFloat(const G4ThreeVector &vec)
Convert G4ThreeVector (aka Hep3Vector) to float array to store in TrueHit/SimHit classes.
StoreArray< TrueHitClass > m_truehits
StoreArray for the TrueHits.
int saveSimHit(const SensorTraversal &traversal, const SensorTraversal::range &points) override
Save a SimHit for a track along the given points.
StoreArray< MCParticle > m_mcparticles
StoreArray for the MCParticles, needed by relations.
Sensitive Detector implementation of PXD and SVD.
static const double ehEnergy
Energy needed to create an electron-hole pair in Si at std.
RelationArray m_relTrueSimHits
Relation between TrueHits and SimHits.