ATLAS Offline Software
Loading...
Searching...
No Matches
ALFA_SensitiveDetector Class Reference

#include <ALFA_SensitiveDetector.h>

Inheritance diagram for ALFA_SensitiveDetector:
Collaboration diagram for ALFA_SensitiveDetector:

Public Member Functions

 ALFA_SensitiveDetector (const std::string &name, const std::string &hitCollectionName, const std::string &ODhitCollectionName)
 ~ALFA_SensitiveDetector ()
void Initialize (G4HCofThisEvent *) override final
G4bool ProcessHits (G4Step *, G4TouchableHistory *) override final

Private Member Functions

 FRIEND_TEST (ALFA_SensitiveDetectortest, ProcessHits1)
 FRIEND_TEST (ALFA_SensitiveDetectortest, ProcessHits2)
 FRIEND_TEST (ALFA_SensitiveDetectortest, ProcessHits3)
ALFA_HitCollectiongetHitCollection () const
 Templated method to stuff a single hit into the sensitive detector class.
ALFA_ODHitCollectiongetODHitCollection () const

Private Attributes

int m_hitID {}
std::string m_hitCollectionName
std::string m_ODHitCollectionName
ALFA_HitCollectionm_HitCollection {}
ALFA_ODHitCollectionm_ODHitCollection {}
int m_pos1 {}
int m_pos2 {}
int m_num [3] {}

Detailed Description

Definition at line 22 of file ALFA_SensitiveDetector.h.

Constructor & Destructor Documentation

◆ ALFA_SensitiveDetector()

ALFA_SensitiveDetector::ALFA_SensitiveDetector ( const std::string & name,
const std::string & hitCollectionName,
const std::string & ODhitCollectionName )

Definition at line 27 of file ALFA_SensitiveDetector.cxx.

28 : G4VSensitiveDetector( name ),
29 m_hitCollectionName(hitCollectionName),
30 m_ODHitCollectionName(ODhitCollectionName)
31{
32
33 m_hitID = -1;
34
35 m_pos1 = 0;
36 m_pos2 = 0;
37
38 m_num[0] = 0;
39 m_num[1] = 0;
40 m_num[2] = 0;
41
42}

◆ ~ALFA_SensitiveDetector()

ALFA_SensitiveDetector::~ALFA_SensitiveDetector ( )
inline

Definition at line 32 of file ALFA_SensitiveDetector.h.

32{}

Member Function Documentation

◆ FRIEND_TEST() [1/3]

ALFA_SensitiveDetector::FRIEND_TEST ( ALFA_SensitiveDetectortest ,
ProcessHits1  )
private

◆ FRIEND_TEST() [2/3]

ALFA_SensitiveDetector::FRIEND_TEST ( ALFA_SensitiveDetectortest ,
ProcessHits2  )
private

◆ FRIEND_TEST() [3/3]

ALFA_SensitiveDetector::FRIEND_TEST ( ALFA_SensitiveDetectortest ,
ProcessHits3  )
private

◆ getHitCollection()

ALFA_HitCollection * ALFA_SensitiveDetector::getHitCollection ( ) const
private

Templated method to stuff a single hit into the sensitive detector class.

This could get rather tricky, but the idea is to allow fast simulations to use the very same SD classes as the standard simulation.

Definition at line 256 of file ALFA_SensitiveDetector.cxx.

257{
258 auto* eventInfo = AtlasG4EventUserInfo::GetEventUserInfo();
259 if (!eventInfo) {
260 return nullptr;
261 }
262 auto hitCollections = eventInfo->GetHitCollectionMap();
263 return hitCollections ? hitCollections->Find<ALFA_HitCollection>(m_hitCollectionName) : nullptr;
264}
AtlasHitsVector< ALFA_Hit > ALFA_HitCollection
static AtlasG4EventUserInfo * GetEventUserInfo()

◆ getODHitCollection()

ALFA_ODHitCollection * ALFA_SensitiveDetector::getODHitCollection ( ) const
private

Definition at line 266 of file ALFA_SensitiveDetector.cxx.

267{
268 auto* eventInfo = AtlasG4EventUserInfo::GetEventUserInfo();
269 if (!eventInfo) {
270 return nullptr;
271 }
272 auto hitCollections = eventInfo->GetHitCollectionMap();
273 return hitCollections ? hitCollections->Find<ALFA_ODHitCollection>(m_ODHitCollectionName) : nullptr;
274}
AtlasHitsVector< ALFA_ODHit > ALFA_ODHitCollection

◆ Initialize()

void ALFA_SensitiveDetector::Initialize ( G4HCofThisEvent * )
finaloverride

Definition at line 45 of file ALFA_SensitiveDetector.cxx.

46{
49}
ALFA_ODHitCollection * getODHitCollection() const
ALFA_HitCollection * m_HitCollection
ALFA_ODHitCollection * m_ODHitCollection
ALFA_HitCollection * getHitCollection() const
Templated method to stuff a single hit into the sensitive detector class.

◆ ProcessHits()

bool ALFA_SensitiveDetector::ProcessHits ( G4Step * pStep,
G4TouchableHistory *  )
finaloverride

Definition at line 51 of file ALFA_SensitiveDetector.cxx.

52{
53 if (!m_HitCollection) {
55 }
56 if (!m_ODHitCollection) {
58 }
59
60 const double energyDeposit(pStep->GetTotalEnergyDeposit());
61
62 // Get kinetic energy of depositing particle
63
64 const G4StepPoint *pPreStepPoint(pStep->GetPreStepPoint());
65 const G4StepPoint *pPostStepPoint(pStep->GetPostStepPoint());
66
67 const double kineticEnergy(pPreStepPoint->GetKineticEnergy());
68
69 const G4ThreeVector preStepPoint(pPreStepPoint->GetPosition());
70 const G4ThreeVector postStepPoint(pPostStepPoint->GetPosition());
71
72 // Get name of physical volume
73 const G4String vol_name(pPreStepPoint->GetTouchableHandle()->GetVolume()->GetName());
74
75 const double preStepX(preStepPoint.x());
76 const double preStepY(preStepPoint.y());
77 const double preStepZ(preStepPoint.z());
78
79 const double postStepX(postStepPoint.x());
80 const double postStepY(postStepPoint.y());
81 const double postStepZ(postStepPoint.z());
82
83 int n_plate(0);
84 int n_fiber(0);
85 int n_station(0);
86
87 m_hitID++;
88
89 // particle encoding
90 const G4Track *pTrack(pStep->GetTrack());
91 const int particleEncoding(pTrack->GetDefinition()->GetPDGEncoding());
92
93 const double globalTime(pTrack->GetGlobalTime());
94 const int trackID(pTrack->GetTrackID()); //DC 2-29-04 use it as barcode
95
96 std::string vol_test_str = vol_name.substr(0,7);
97
98
99 if(vol_name.find("GVS") != std::string::npos)
100 {
101
102 if(vol_name.find("B7L1") != std::string::npos) n_station=0;
103 else if(vol_name.find("A7L1") != std::string::npos) n_station=1;
104 else if(vol_name.find("A7R1") != std::string::npos) n_station=2;
105 else if(vol_name.find("B7R1") != std::string::npos) n_station=3;
106 else n_station=-1;
108 {
109 m_HitCollection->Emplace(m_hitID, trackID, particleEncoding, (float) kineticEnergy,
110 (float) energyDeposit,(float) preStepX, (float) preStepY, (float) preStepZ,
111 (float) postStepX, (float) postStepY, (float) postStepZ,(float) globalTime,
112 -1, 100, -1, (int) n_station);
113 }
114 else
115 {
116 G4ExceptionDescription description;
117 description << "ProcessHits: Can't access HitCollection with key " << m_hitCollectionName;
118 G4Exception("ALFA_SensitiveDetector", "InvalidHitColl1", FatalException, description);
119 return false; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
120 }
121 }
122
123 if (vol_test_str.compare("ALFA_Fi") == 0)
124 {
125 if (std::abs(energyDeposit)<std::numeric_limits<double>::epsilon()) { return true; }
126 m_pos2 = 10;
127 std::string substring (vol_name);
128 std::string num_string (vol_name);
129
130
131 std::string test_str ("A");
132 test_str = substring.substr(m_pos2,1);
133 int sign_fiber(0);
134 if (test_str.compare("U") == 0)
135 {
136 sign_fiber = 1;
137 }
138
139 if (test_str.compare("V") == 0)
140 {
141 sign_fiber = -1;
142 }
143
144
145 for ( int k = 0; k < 3; k++ )
146 {
147 substring = substring.substr(m_pos2+1);
148 m_pos1 = int(substring.find('['));
149 m_pos2 = int(substring.find(']'));
150 num_string = substring.substr(m_pos1+1,m_pos2-1);
151 std::istringstream is(num_string);
152 is >> m_num[k];
153 }
154
155 n_station = m_num[0];
156 n_plate = m_num[1];
157 n_fiber = m_num[2];
158
159
161 {
162 m_HitCollection->Emplace(m_hitID,
163 trackID,
164 particleEncoding,
165 (float) kineticEnergy,
166 (float) energyDeposit,
167 (float) preStepX, (float) preStepY, (float) preStepZ,
168 (float) postStepX, (float) postStepY, (float) postStepZ,
169 (float) globalTime,
170 (int) sign_fiber, (int) n_plate, (int) n_fiber, (int) n_station
171 );
172 }
173 else
174 {
175 G4ExceptionDescription description;
176 description << "ProcessHits: Can't access HitCollection with key " << m_hitCollectionName;
177 G4Exception("ALFA_SensitiveDetector", "InvalidHitColl2", FatalException, description);
178 return false; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
179 }
180 }
181
182 if (vol_test_str.compare("ODFiber") == 0)
183 {
184 if (std::abs(energyDeposit)<std::numeric_limits<double>::epsilon()) { return true; }
185 m_pos2 = 7;
186 std::string substring (vol_name);
187 std::string num_string (std::move(vol_name));
188
189 std::string test_str = substring.substr(m_pos2,1);
190 int sign_fiber(0);
191 if (test_str.compare("U") == 0)
192 {
193 sign_fiber = 1;
194 }
195
196 if (test_str.compare("V") == 0)
197 {
198 sign_fiber = -1;
199 }
200
201 std::string test_str_side ("A");
202 test_str_side = substring.substr(m_pos2+1,1);
203
204 int OD_side(0);
205 if (test_str_side.compare("0") == 0)
206 {
207 OD_side = 0;
208 }
209
210 if (test_str_side.compare("1") == 0)
211 {
212 OD_side = 1;
213 }
214
215 for ( int k = 0; k < 3; k++ )
216 {
217 substring = substring.substr(m_pos2+1);
218 m_pos1 = int(substring.find('['));
219 m_pos2 = int(substring.find(']'));
220 num_string = substring.substr(m_pos1+1,m_pos2-1);
221 std::istringstream is(num_string);
222 is >> m_num[k];
223 }
224
225 n_station = m_num[0];
226 n_plate = m_num[1];
227 n_fiber = m_num[2];
228
230 {
231 m_ODHitCollection->Emplace(m_hitID,
232 trackID,
233 particleEncoding,
234 (float) kineticEnergy,
235 (float) energyDeposit,
236 (float) preStepX, (float) preStepY, (float) preStepZ,
237 (float) postStepX, (float) postStepY, (float) postStepZ,
238 (float) globalTime,
239 (int) sign_fiber, (int) OD_side, (int) n_plate, (int) n_fiber, (int) n_station
240 );
241 }
242 else
243 {
244 G4ExceptionDescription description;
245 description << "ProcessHits: Can't access HitCollection with key " << m_ODHitCollectionName;
246 G4Exception("ALFA_SensitiveDetector", "InvalidHitColl3", FatalException, description);
247 return false; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
248 }
249
250 }
251
252
253 return true;
254}
std::string description
glabal timer - how long have I taken so far?
Definition hcg.cxx:93
@ energyDeposit

Member Data Documentation

◆ m_HitCollection

ALFA_HitCollection* ALFA_SensitiveDetector::m_HitCollection {}
private

Definition at line 53 of file ALFA_SensitiveDetector.h.

53{};

◆ m_hitCollectionName

std::string ALFA_SensitiveDetector::m_hitCollectionName
private

Definition at line 50 of file ALFA_SensitiveDetector.h.

◆ m_hitID

int ALFA_SensitiveDetector::m_hitID {}
private

Definition at line 47 of file ALFA_SensitiveDetector.h.

47{};

◆ m_num

int ALFA_SensitiveDetector::m_num[3] {}
private

Definition at line 58 of file ALFA_SensitiveDetector.h.

58{};

◆ m_ODHitCollection

ALFA_ODHitCollection* ALFA_SensitiveDetector::m_ODHitCollection {}
private

Definition at line 54 of file ALFA_SensitiveDetector.h.

54{};

◆ m_ODHitCollectionName

std::string ALFA_SensitiveDetector::m_ODHitCollectionName
private

Definition at line 51 of file ALFA_SensitiveDetector.h.

◆ m_pos1

int ALFA_SensitiveDetector::m_pos1 {}
private

Definition at line 56 of file ALFA_SensitiveDetector.h.

56{}, m_pos2{};

◆ m_pos2

int ALFA_SensitiveDetector::m_pos2 {}
private

Definition at line 56 of file ALFA_SensitiveDetector.h.

56{}, m_pos2{};

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