Belle II Software development
SensitiveDetector Class Reference

Sensitive Detector implementation of the PLUME detector. More...

#include <SensitiveDetector.h>

Inheritance diagram for SensitiveDetector:
SensitiveDetectorBase

Public Member Functions

 SensitiveDetector ()
 Constructor.
 
 ~SensitiveDetector ()
 Destructor.
 

Static Public Member Functions

static const std::map< std::string, RelationArray::EConsolidationAction > & getMCParticleRelations ()
 Return a list of all registered Relations with MCParticles.
 
static void setActive (bool activeStatus)
 Enable/Disable all Sensitive Detectors.
 
static void registerMCParticleRelation (const std::string &name, RelationArray::EConsolidationAction ignoreAction=RelationArray::c_negativeWeight)
 Register an relation involving MCParticles.
 
static void registerMCParticleRelation (const RelationArray &relation, RelationArray::EConsolidationAction ignoreAction=RelationArray::c_negativeWeight)
 Overload to make it easer to register MCParticle relations.
 

Protected Member Functions

bool step (G4Step *step, G4TouchableHistory *) override
 Step processing method.
 

Private Member Functions

virtual bool ProcessHits (G4Step *aStep, G4TouchableHistory *aROhist)
 Check if recording hits is enabled and if so call step() and set the correct MCParticle flag.
 

Private Attributes

int current_pdgID
 particle PDG id
 
int current_sensorID
 sensor ID
 
int current_trackID
 track ID
 
float current_trackVertex_x
 track production vertex x coordinates in G4 ref
 
float current_trackVertex_y
 track production vertex y coordinates in G4 ref
 
float current_trackVertex_z
 track production vertex z coordinates in G4 ref
 
float current_energyDep
 deposited energy in MeV
 
float current_nielDep
 non ionizing deposited energy
 
float current_posIN_x
 incoming track position x in G4 ref, in mm
 
float current_posIN_y
 incoming track position y in G4 ref, in mm
 
float current_posIN_z
 incoming track position z in G4 ref, in mm
 
float current_posIN_u
 incoming track position u in sensor ref, in mm
 
float current_posIN_v
 incoming track position v in sensor ref, in mm
 
float current_posIN_w
 incoming track position w in sensor ref, in mm
 
float current_posOUT_u
 outcoming track position u in sensor ref, in mm
 
float current_posOUT_v
 outcoming track position v in sensor ref, in mm
 
float current_posOUT_w
 outcoming track position w in sensor ref, in mm
 
float current_posOUT_x
 outcoming track position x in sensor ref, in mm
 
float current_posOUT_y
 outcoming track position y in sensor ref, in mm
 
float current_posOUT_z
 outcoming track position z in sensor ref, in mm
 
float current_momentum_x
 incoming track momentum, x coordinates in G4 ref, in GeV
 
float current_momentum_y
 incoming track momentum, y coordinates in G4 ref, in GeV
 
float current_momentum_z
 incoming track momentum, z coordinates in G4 ref, in GeV
 
float current_thetaAngle
 local (sensor ref) theta angle, out of sensor plane, in degree
 
float current_phiAngle
 local (sensor ref) phi angle, in sensor plane, in degree
 
float current_globalTime
 global time
 
Const::EDetector m_subdetector
 Subdetector the class belongs to.
 

Static Private Attributes

static std::map< std::string, RelationArray::EConsolidationActions_mcRelations
 Static set holding all relations which have to be updated at the end of the Event.
 
static bool s_active
 Static bool which indicates wether recording of hits is enabled.
 

Detailed Description

Sensitive Detector implementation of the PLUME detector.

Definition at line 22 of file SensitiveDetector.h.

Constructor & Destructor Documentation

◆ SensitiveDetector()

Constructor.

Definition at line 32 of file SensitiveDetector.cc.

32 :
33 Simulation::SensitiveDetectorBase("PlumeSensitiveDetector", Const::invalidDetector)
34 {
39 current_pdgID = 0;
41 current_posIN_u = 0.;
42 current_posIN_v = 0.;
43 current_posIN_w = 0.;
44 current_posIN_x = 0.;
45 current_posIN_y = 0.;
46 current_posIN_z = 0.;
57 current_nielDep = 0.;
58 current_thetaAngle = 0.; // local sensor frame
59 current_phiAngle = 0.; // local sensor frame
61
62 //Make sure all collections are registered
63 StoreArray<MCParticle> mcParticles;
64 StoreArray<PlumeSimHit> simHits;
65 StoreArray<PlumeHit> plumeHits;
66
67 RelationArray relMCSimHit(mcParticles, simHits);
68 RelationArray relMCplumeHit(mcParticles, plumeHits);
69
70 //Register all collections we want to modify and require those we want to use
71 mcParticles.registerInDataStore();
72 simHits.registerInDataStore();
73 plumeHits.registerInDataStore();
74 relMCSimHit.registerInDataStore();
75 relMCplumeHit.registerInDataStore();
76
77 //Register the Relation so that the TrackIDs get replaced by the actual
78 //MCParticle indices after simulating the events. This is needed as
79 //secondary particles might not be stored so everything relating to those
80 //particles will be attributed to the last saved mother particle
81 registerMCParticleRelation(relMCSimHit);
82 registerMCParticleRelation(relMCplumeHit);
83 }
static void registerMCParticleRelation(const std::string &name, RelationArray::EConsolidationAction ignoreAction=RelationArray::c_negativeWeight)
Register an relation involving MCParticles.
float current_trackVertex_z
track production vertex z coordinates in G4 ref
float current_posIN_v
incoming track position v in sensor ref, in mm
float current_posIN_u
incoming track position u in sensor ref, in mm
float current_momentum_z
incoming track momentum, z coordinates in G4 ref, in GeV
float current_posIN_y
incoming track position y in G4 ref, in mm
float current_momentum_y
incoming track momentum, y coordinates in G4 ref, in GeV
float current_posOUT_w
outcoming track position w in sensor ref, in mm
float current_energyDep
deposited energy in MeV
float current_trackVertex_x
track production vertex x coordinates in G4 ref
float current_posOUT_z
outcoming track position z in sensor ref, in mm
float current_posOUT_v
outcoming track position v in sensor ref, in mm
float current_posIN_z
incoming track position z in G4 ref, in mm
float current_thetaAngle
local (sensor ref) theta angle, out of sensor plane, in degree
float current_posOUT_u
outcoming track position u in sensor ref, in mm
float current_momentum_x
incoming track momentum, x coordinates in G4 ref, in GeV
float current_trackVertex_y
track production vertex y coordinates in G4 ref
float current_posOUT_y
outcoming track position y in sensor ref, in mm
float current_posIN_x
incoming track position x in G4 ref, in mm
float current_phiAngle
local (sensor ref) phi angle, in sensor plane, in degree
float current_nielDep
non ionizing deposited energy
float current_posIN_w
incoming track position w in sensor ref, in mm
float current_posOUT_x
outcoming track position x in sensor ref, in mm

◆ ~SensitiveDetector()

Destructor.

Definition at line 85 of file SensitiveDetector.cc.

86 {
87
88 }

Member Function Documentation

◆ getMCParticleRelations()

static const std::map< std::string, RelationArray::EConsolidationAction > & getMCParticleRelations ( )
inlinestaticinherited

Return a list of all registered Relations with MCParticles.

Definition at line 42 of file SensitiveDetectorBase.h.

42{ return s_mcRelations; }
static std::map< std::string, RelationArray::EConsolidationAction > s_mcRelations
Static set holding all relations which have to be updated at the end of the Event.

◆ ProcessHits()

bool ProcessHits ( G4Step *  aStep,
G4TouchableHistory *  aROhist 
)
inlineprivatevirtualinherited

Check if recording hits is enabled and if so call step() and set the correct MCParticle flag.

Called by Geant4 for each step inside the sensitive volumes attached

Definition at line 94 of file SensitiveDetectorBase.h.

95 {
96 if (!s_active) return false;
97 bool result = step(aStep, aROhist);
98 // Do not include hits from invalid detector (beast,teastbeam, etc.)
99 if (result && (m_subdetector != Const::invalidDetector)) TrackInfo::getInfo(*aStep->GetTrack()).addSeenInDetector(m_subdetector);
100 return result;
101 }
virtual bool step(G4Step *step, G4TouchableHistory *ROhist)=0
Process a Geant4 step in any of the sensitive volumes attached to this sensitive detector.
Const::EDetector m_subdetector
Subdetector the class belongs to.
static bool s_active
Static bool which indicates wether recording of hits is enabled.
static Payload getInfo(Carrier &obj)
Static function to just return UserInformation attached to the obj of type Carrier.
Definition: UserInfo.h:100

◆ registerMCParticleRelation() [1/2]

static void registerMCParticleRelation ( const RelationArray relation,
RelationArray::EConsolidationAction  ignoreAction = RelationArray::c_negativeWeight 
)
inlinestaticinherited

Overload to make it easer to register MCParticle relations.

Parameters
relationRelationArray to register
ignoreAction

Definition at line 66 of file SensitiveDetectorBase.h.

67 { registerMCParticleRelation(relation.getName(), ignoreAction); }

◆ registerMCParticleRelation() [2/2]

void registerMCParticleRelation ( const std::string &  name,
RelationArray::EConsolidationAction  ignoreAction = RelationArray::c_negativeWeight 
)
staticinherited

Register an relation involving MCParticles.

All Relations which point from an MCParticle to something have to be registered with addMCParticleRelation() because the index of the MCParticles might change at the end of the event. During simulation, the TrackID should be used as index of the MCParticle

Parameters
nameName of the relation to register
ignoreAction

Definition at line 22 of file SensitiveDetectorBase.cc.

23 {
24 std::pair<std::map<std::string, RelationArray::EConsolidationAction>::iterator, bool> insert = s_mcRelations.insert(std::make_pair(
25 name, ignoreAction));
26 //If the relation already exists and the ignoreAction is different we do have a problem
27 if (!insert.second && insert.first->second != ignoreAction) {
28 B2FATAL("MCParticle Relation " << name << " already registered with different ignore action.");
29 }
30 }

◆ setActive()

static void setActive ( bool  activeStatus)
inlinestaticinherited

Enable/Disable all Sensitive Detectors.

By default, all sensitive detectors won't create hits to make it possible to use the Geant4 Navigator for non-simulation purposes. Only during simulation the sensitive detectors will be enabled to record hits

Parameters
activeStatusbool to indicate wether hits should be recorded

Definition at line 50 of file SensitiveDetectorBase.h.

50{ s_active = activeStatus; }

◆ step()

bool step ( G4Step *  step,
G4TouchableHistory *   
)
overrideprotectedvirtual

Step processing method.

Parameters
stepthe G4Step with the current step information
Returns
true if a Hit has been created, false if the hit was ignored

Implements SensitiveDetectorBase.

Definition at line 91 of file SensitiveDetector.cc.

92 {
93
94 //Get track information, and pre- and post-step
95 const G4Track& track = *step->GetTrack();
96 const G4StepPoint& preStepPoint = *step->GetPreStepPoint();
97 const G4StepPoint& postStepPoint = *step->GetPostStepPoint();
98
99
100 // If new track, store general information from this first step
101 if (current_trackID != track.GetTrackID()) { // if new track
102 current_trackID = track.GetTrackID();
103 current_trackVertex_x = track.GetVertexPosition().x();
104 current_trackVertex_y = track.GetVertexPosition().y();
105 current_trackVertex_z = track.GetVertexPosition().z();
106 current_pdgID = track.GetDefinition()->GetPDGEncoding();
107 current_sensorID = preStepPoint.GetTouchableHandle()->GetReplicaNumber(1);
108
109 // since this is first step in volume store track incidence and momentum and reset energy loss
110 G4ThreeVector preStepPointPosition = preStepPoint.GetPosition();
111 G4ThreeVector trackMomentum = track.GetMomentum();
113 current_nielDep = 0.;
114
115 current_posIN_x = preStepPointPosition.x();
116 current_posIN_y = preStepPointPosition.y();
117 current_posIN_z = preStepPointPosition.z();
118 current_momentum_x = trackMomentum.x();
119 current_momentum_y = trackMomentum.y();
120 current_momentum_z = trackMomentum.z();
121
122 // We want the track angles of incidence on the local volume and the local position
123 G4TouchableHandle theTouchable = preStepPoint.GetTouchableHandle();
124 G4ThreeVector worldDirection = preStepPoint.GetMomentumDirection();
125 G4ThreeVector localDirection = theTouchable->GetHistory()->GetTopTransform().TransformAxis(worldDirection);
126
127 if (localDirection.z() < 0.) {
128 current_thetaAngle = M_PI - acos(-1. * localDirection.z());
129 } else {
130 current_thetaAngle = acos(localDirection.z());
131 }
132
133
134 if (localDirection.x() < 0. && localDirection.y() > 0.) {
135 current_phiAngle = atan(-1. * localDirection.x() / localDirection.y());
136 } else if (localDirection.x() < 0. && localDirection.y() < 0.) {
137 current_phiAngle = M_PI - atan(localDirection.x() / localDirection.y());
138 } else if (localDirection.x() > 0. && localDirection.y() < 0.) {
139 current_phiAngle = M_PI + atan(-1. * localDirection.x() / localDirection.y());
140 } else if (localDirection.x() > 0. && localDirection.y() > 0.) {
141 current_phiAngle = 2. * M_PI - atan(localDirection.x() / localDirection.y());
142 } else if (localDirection.x() < 0. && localDirection.y() == 0.) {
143 current_phiAngle = M_PI / 2.;
144 } else if (localDirection.x() > 0. && localDirection.y() == 0.) {
145 current_phiAngle = 3.* M_PI / 2.;
146 } else if (localDirection.x() == 0. && localDirection.y() > 0.) {
147 current_phiAngle = 0.;
148 } else if (localDirection.x() == 0. && localDirection.y() < 0.) {
149 current_phiAngle = M_PI;
150 }
151
152 G4ThreeVector localINPosition = theTouchable->GetHistory()->GetTopTransform().TransformPoint(preStepPointPosition);
153 current_posIN_u = localINPosition.y();
154 current_posIN_v = - localINPosition.x();
155 current_posIN_w = localINPosition.z();
156
157 current_globalTime = step->GetPreStepPoint()->GetGlobalTime();
158
159 } // end if new track
160
161 // Update information at each step
162 current_energyDep += step->GetTotalEnergyDeposit();
163 current_nielDep += step->GetNonIonizingEnergyDeposit();
164
165 // If track leaves volume or is killed, store final step info and save simHit
166 if (track.GetNextVolume() != track.GetVolume() || track.GetTrackStatus() >= fStopAndKill) { // if last step
167
168 G4ThreeVector postStepPointPosition = postStepPoint.GetPosition();
169
170 current_posOUT_x = postStepPointPosition.x();
171 current_posOUT_y = postStepPointPosition.y();
172 current_posOUT_z = postStepPointPosition.z();
173 G4ThreeVector localOUTPosition = preStepPoint.GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(
174 postStepPointPosition);
175 current_posOUT_u = localOUTPosition.y();
176 current_posOUT_v = - localOUTPosition.x();
177 current_posOUT_w = localOUTPosition.z();
178
179 //Get the datastore arrays
180 StoreArray<MCParticle> mcParticles;
181 StoreArray<PlumeSimHit> simHits;
182
183 if (current_energyDep > CLHEP::eV) {
184
185 RelationArray relMCSimHit(mcParticles, simHits);
186 PlumeSimHit* hit = simHits.appendNew(
190 current_trackVertex_x / CLHEP::mm,
191 current_trackVertex_y / CLHEP::mm,
192 current_trackVertex_z / CLHEP::mm,
193 current_energyDep / CLHEP::MeV,
194 current_nielDep / CLHEP::MeV,
195 current_posIN_x / CLHEP::mm,
196 current_posIN_y / CLHEP::mm,
197 current_posIN_z / CLHEP::mm,
198 current_posIN_u / CLHEP::mm,
199 current_posIN_v / CLHEP::mm,
200 current_posIN_w / CLHEP::mm,
201 current_posOUT_u / CLHEP::mm,
202 current_posOUT_v / CLHEP::mm,
203 current_posOUT_w / CLHEP::mm,
204 current_momentum_x / CLHEP::GeV,
205 current_momentum_y / CLHEP::GeV,
206 current_momentum_z / CLHEP::GeV,
207 current_thetaAngle / CLHEP::degree,
208 current_phiAngle / CLHEP::degree,
209 current_globalTime / CLHEP::nanosecond
210 );
211
212 //Add Relation between SimHit and MCParticle with a weight of 1. Since
213 //the MCParticle index is not yet defined we use the trackID from Geant4
214 relMCSimHit.add(current_trackID, hit->getArrayIndex(), 1.0);
215 }
216
217 //Reset TrackID
218 current_trackID = 0;
219
220 } // end if last
221
222
223 //Ignore everything below 1eV
224 if (current_energyDep < CLHEP::eV) return false;
225
226
227 return true;
228 }
bool step(G4Step *step, G4TouchableHistory *) override
Step processing method.
double atan(double a)
atan for double
Definition: beamHelpers.h:34

Member Data Documentation

◆ current_energyDep

float current_energyDep
private

deposited energy in MeV

Definition at line 50 of file SensitiveDetector.h.

◆ current_globalTime

float current_globalTime
private

global time

Definition at line 88 of file SensitiveDetector.h.

◆ current_momentum_x

float current_momentum_x
private

incoming track momentum, x coordinates in G4 ref, in GeV

Definition at line 78 of file SensitiveDetector.h.

◆ current_momentum_y

float current_momentum_y
private

incoming track momentum, y coordinates in G4 ref, in GeV

Definition at line 80 of file SensitiveDetector.h.

◆ current_momentum_z

float current_momentum_z
private

incoming track momentum, z coordinates in G4 ref, in GeV

Definition at line 82 of file SensitiveDetector.h.

◆ current_nielDep

float current_nielDep
private

non ionizing deposited energy

Definition at line 52 of file SensitiveDetector.h.

◆ current_pdgID

int current_pdgID
private

particle PDG id

Definition at line 38 of file SensitiveDetector.h.

◆ current_phiAngle

float current_phiAngle
private

local (sensor ref) phi angle, in sensor plane, in degree

Definition at line 86 of file SensitiveDetector.h.

◆ current_posIN_u

float current_posIN_u
private

incoming track position u in sensor ref, in mm

Definition at line 60 of file SensitiveDetector.h.

◆ current_posIN_v

float current_posIN_v
private

incoming track position v in sensor ref, in mm

Definition at line 62 of file SensitiveDetector.h.

◆ current_posIN_w

float current_posIN_w
private

incoming track position w in sensor ref, in mm

Definition at line 64 of file SensitiveDetector.h.

◆ current_posIN_x

float current_posIN_x
private

incoming track position x in G4 ref, in mm

Definition at line 54 of file SensitiveDetector.h.

◆ current_posIN_y

float current_posIN_y
private

incoming track position y in G4 ref, in mm

Definition at line 56 of file SensitiveDetector.h.

◆ current_posIN_z

float current_posIN_z
private

incoming track position z in G4 ref, in mm

Definition at line 58 of file SensitiveDetector.h.

◆ current_posOUT_u

float current_posOUT_u
private

outcoming track position u in sensor ref, in mm

Definition at line 66 of file SensitiveDetector.h.

◆ current_posOUT_v

float current_posOUT_v
private

outcoming track position v in sensor ref, in mm

Definition at line 68 of file SensitiveDetector.h.

◆ current_posOUT_w

float current_posOUT_w
private

outcoming track position w in sensor ref, in mm

Definition at line 70 of file SensitiveDetector.h.

◆ current_posOUT_x

float current_posOUT_x
private

outcoming track position x in sensor ref, in mm

Definition at line 72 of file SensitiveDetector.h.

◆ current_posOUT_y

float current_posOUT_y
private

outcoming track position y in sensor ref, in mm

Definition at line 74 of file SensitiveDetector.h.

◆ current_posOUT_z

float current_posOUT_z
private

outcoming track position z in sensor ref, in mm

Definition at line 76 of file SensitiveDetector.h.

◆ current_sensorID

int current_sensorID
private

sensor ID

Definition at line 40 of file SensitiveDetector.h.

◆ current_thetaAngle

float current_thetaAngle
private

local (sensor ref) theta angle, out of sensor plane, in degree

Definition at line 84 of file SensitiveDetector.h.

◆ current_trackID

int current_trackID
private

track ID

Definition at line 42 of file SensitiveDetector.h.

◆ current_trackVertex_x

float current_trackVertex_x
private

track production vertex x coordinates in G4 ref

Definition at line 44 of file SensitiveDetector.h.

◆ current_trackVertex_y

float current_trackVertex_y
private

track production vertex y coordinates in G4 ref

Definition at line 46 of file SensitiveDetector.h.

◆ current_trackVertex_z

float current_trackVertex_z
private

track production vertex z coordinates in G4 ref

Definition at line 48 of file SensitiveDetector.h.

◆ m_subdetector

Const::EDetector m_subdetector
privateinherited

Subdetector the class belongs to.

Definition at line 91 of file SensitiveDetectorBase.h.

◆ s_active

bool s_active
staticprivateinherited

Static bool which indicates wether recording of hits is enabled.

Definition at line 89 of file SensitiveDetectorBase.h.

◆ s_mcRelations

map< string, RelationArray::EConsolidationAction > s_mcRelations
staticprivateinherited

Static set holding all relations which have to be updated at the end of the Event.

Definition at line 87 of file SensitiveDetectorBase.h.


The documentation for this class was generated from the following files: