Belle II Software development
SensitiveDetectorBase.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#ifndef VXD_SENSITIVEDETECTORBASE_H
10#define VXD_SENSITIVEDETECTORBASE_H
11
12//If this is defined, we create a root file with all information necessary to
13//check functionality of the implementation
14//#define VXD_SENSITIVEDETECTOR_DEBUG
15
16#include <simulation/kernel/SensitiveDetectorBase.h>
17#include <vxd/simulation/SensorTraversal.h>
18#include <vxd/geometry/SensorInfoBase.h>
19#include <stack>
20#include <vector>
21
22namespace Belle2 {
28 namespace VXD {
38 public:
46 Simulation::SensitiveDetectorBase((info->getType() == SensorInfoBase::PXD ? "PXD " : "SVD ") + (std::string)info->getID(),
47 info->getType() == SensorInfoBase::PXD ? Const::PXD : Const::SVD), m_info(info) {};
48
60 void setOptions(bool seeNeutrons, bool onlyPrimaryTrueHits, float distanceTolerance,
61 float electronTolerance, float minimumElectrons)
62 {
63 m_seeNeutrons = seeNeutrons;
64 m_onlyPrimaryTrueHits = onlyPrimaryTrueHits;
65 m_distanceTolerance = distanceTolerance;
66 m_electronTolerance = electronTolerance;
67 m_minimumElectrons = minimumElectrons;
68 }
69
71 virtual ~SensitiveDetectorBase() override
72 {
73 if (m_info) delete m_info;
74 }
75
78
80 VxdID getSensorID() const { return m_info->getID(); }
81
82 protected:
90 virtual int saveTrueHit(const SensorTraversal& traversal) = 0;
91
101 virtual int saveSimHit(const SensorTraversal& traversal, const SensorTraversal::range& points) = 0;
102
110 virtual void saveRelations(const SensorTraversal& traversal, int trueHitIndex,
111 std::vector<std::pair<unsigned int, float>> simHitIndices) = 0;
112
125 std::vector<unsigned int> simplifyEnergyDeposit(const SensorTraversal::range& points);
126
138 private:
144 bool step(G4Step* step, G4TouchableHistory*) override;
145
149 bool finishTrack();
150
160 std::vector<std::pair<unsigned int, float>> createSimHits();
161
165 std::stack<SensorTraversal> m_tracks;
177 bool m_seeNeutrons {false};
180 };
181 }
183} //Belle2 namespace
184#endif
This class provides a set of constants for the framework.
Definition: Const.h:34
Class to keep track of the traversal of the sensitive volume for one track.
std::pair< iterator, iterator > range
Iterator pair for a set of points.
Base class for all Sensitive Detectors to create hits during simulation.
Base class for Sensitive Detector implementation of PXD and SVD.
void setOptions(bool seeNeutrons, bool onlyPrimaryTrueHits, float distanceTolerance, float electronTolerance, float minimumElectrons)
Set all common options.
float m_minimumElectrons
minimum number of electrons a track must deposit for SimHit/TrueHits to be created
SensitiveDetectorBase(SensorInfoBase *info)
Constructor.
StepInformation findMidPoint(const SensorTraversal &traversal)
Find the mid-point of the track traversal.
virtual ~SensitiveDetectorBase() override
Destructor freeing the sensor Info.
bool finishTrack()
Process a track once all steps are known.
SensorInfoBase * m_info
Pointer to the SensorInfo associated with this instance.
float m_distanceTolerance
maximum distance between step point and linear interpolation of sensor traversal before a new simhit ...
virtual int saveSimHit(const SensorTraversal &traversal, const SensorTraversal::range &points)=0
Save a SimHit for this track including the given points.
bool m_onlyPrimaryTrueHits
only create TrueHits for primary particles
std::stack< SensorTraversal > m_tracks
stack of SensorTraversal information for all tracks not finished so far
std::vector< std::pair< unsigned int, float > > createSimHits()
Determine which SimHits to create.
virtual void saveRelations(const SensorTraversal &traversal, int trueHitIndex, std::vector< std::pair< unsigned int, float > > simHitIndices)=0
Save the relations between MCParticle, TrueHit and SimHits.
SensorInfoBase * getSensorInfo()
Return a pointer to the SensorInfo associated with this instance.
float m_electronTolerance
maximum relative difference between electron density of two steps where they can be considered simila...
VxdID getSensorID() const
Return the VxdID belonging to this sensitive detector.
virtual int saveTrueHit(const SensorTraversal &traversal)=0
Save the actual TrueHit for this sensor traversal.
bool m_seeNeutrons
also create SimHit/TrueHit objects for neutrons (or charged particles which deposit less than m_minim...
std::vector< unsigned int > simplifyEnergyDeposit(const SensorTraversal::range &points)
Simplify the energy deposition profile using Douglas-Peuker-Algorithm We normally force a Geant4 step...
bool step(G4Step *step, G4TouchableHistory *) override
Process a single Geant4 Step.
Base class to provide Sensor Information for PXD and SVD.
VxdID getID() const
Return the ID of the Sensor.
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
int getID(const std::vector< double > &breaks, double t)
get id of the time point t
Definition: calibTools.h:60
Abstract base class for different kinds of events.
STL namespace.
Simple struct to keep information about steps in the sensitive detector.