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
void StartOfAthenaEvent ()
G4bool ProcessHits (G4Step *, G4TouchableHistory *) override final
void EndOfAthenaEvent ()

Private Member Functions

 FRIEND_TEST (ALFA_SensitiveDetectortest, Initialize)
 FRIEND_TEST (ALFA_SensitiveDetectortest, ProcessHits1)
 FRIEND_TEST (ALFA_SensitiveDetectortest, ProcessHits2)
 FRIEND_TEST (ALFA_SensitiveDetectortest, ProcessHits3)
 FRIEND_TEST (ALFA_SensitiveDetectortest, StartOfAthenaEvent)
 FRIEND_TEST (ALFA_SensitiveDetectortest, EndOfAthenaEvent)

Private Attributes

int m_hitID {}
 Templated method to stuff a single hit into the sensitive detector class.
int m_eventNumber {}
int m_numberOfHits {}
int m_numberOfODHits {}
SG::WriteHandle< ALFA_HitCollectionm_HitCollection
SG::WriteHandle< ALFA_ODHitCollectionm_ODHitCollection
int m_pos1 {}
int m_pos2 {}
int m_num [3] {}

Detailed Description

Definition at line 23 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 23 of file ALFA_SensitiveDetector.cxx.

24 : G4VSensitiveDetector( name ),
25 m_HitCollection(hitCollectionName),
26 m_ODHitCollection(ODhitCollectionName)
27{
28
29 m_hitID = -1;
30
31 m_eventNumber = 0;
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}
SG::WriteHandle< ALFA_ODHitCollection > m_ODHitCollection
int m_hitID
Templated method to stuff a single hit into the sensitive detector class.
SG::WriteHandle< ALFA_HitCollection > m_HitCollection

◆ ~ALFA_SensitiveDetector()

ALFA_SensitiveDetector::~ALFA_SensitiveDetector ( )
inline

Definition at line 36 of file ALFA_SensitiveDetector.h.

36{}

Member Function Documentation

◆ EndOfAthenaEvent()

void ALFA_SensitiveDetector::EndOfAthenaEvent ( )

Definition at line 259 of file ALFA_SensitiveDetector.cxx.

260{
261 G4cout << " Total number of hits in MD: " << m_numberOfHits << G4endl;
262 G4cout << " Total number of hits in OD: " << m_numberOfODHits << G4endl;
263 G4cout << "*************************************************************" << G4endl;
264
266
267 m_numberOfHits = 0;
269}

◆ FRIEND_TEST() [1/6]

ALFA_SensitiveDetector::FRIEND_TEST ( ALFA_SensitiveDetectortest ,
EndOfAthenaEvent  )
private

◆ FRIEND_TEST() [2/6]

ALFA_SensitiveDetector::FRIEND_TEST ( ALFA_SensitiveDetectortest ,
Initialize  )
private

◆ FRIEND_TEST() [3/6]

ALFA_SensitiveDetector::FRIEND_TEST ( ALFA_SensitiveDetectortest ,
ProcessHits1  )
private

◆ FRIEND_TEST() [4/6]

ALFA_SensitiveDetector::FRIEND_TEST ( ALFA_SensitiveDetectortest ,
ProcessHits2  )
private

◆ FRIEND_TEST() [5/6]

ALFA_SensitiveDetector::FRIEND_TEST ( ALFA_SensitiveDetectortest ,
ProcessHits3  )
private

◆ FRIEND_TEST() [6/6]

ALFA_SensitiveDetector::FRIEND_TEST ( ALFA_SensitiveDetectortest ,
StartOfAthenaEvent  )
private

◆ Initialize()

void ALFA_SensitiveDetector::Initialize ( G4HCofThisEvent * )
finaloverride

Definition at line 51 of file ALFA_SensitiveDetector.cxx.

52{
53 if (!m_HitCollection.isValid()) m_HitCollection = std::make_unique<ALFA_HitCollection>(m_HitCollection.name());
54 if (!m_ODHitCollection.isValid()) m_ODHitCollection = std::make_unique<ALFA_ODHitCollection>(m_ODHitCollection.name());
55}

◆ ProcessHits()

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

Definition at line 57 of file ALFA_SensitiveDetector.cxx.

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;
107 if(m_HitCollection.isValid())
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);
114 }
115 else
116 {
117 G4ExceptionDescription description;
118 description << "ProcessHits: Can't access HitCollection with key " << m_HitCollection.key() << " from store " << m_HitCollection.store();
119 G4Exception("ALFA_SensitiveDetector", "InvalidHitColl1", FatalException, description);
120 return false; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
121 }
122 }
123
124 if (vol_test_str.compare("ALFA_Fi") == 0)
125 {
126 if (std::abs(energyDeposit)<std::numeric_limits<double>::epsilon()) { return true; }
127 m_pos2 = 10;
128 std::string substring (vol_name);
129 std::string num_string (vol_name);
130
131
132 std::string test_str ("A");
133 test_str = substring.substr(m_pos2,1);
134 int sign_fiber(0);
135 if (test_str.compare("U") == 0)
136 {
137 sign_fiber = 1;
138 }
139
140 if (test_str.compare("V") == 0)
141 {
142 sign_fiber = -1;
143 }
144
145
146 for ( int k = 0; k < 3; k++ )
147 {
148 substring = substring.substr(m_pos2+1);
149 m_pos1 = int(substring.find('['));
150 m_pos2 = int(substring.find(']'));
151 num_string = substring.substr(m_pos1+1,m_pos2-1);
152 std::istringstream is(num_string);
153 is >> m_num[k];
154 }
155
156 n_station = m_num[0];
157 n_plate = m_num[1];
158 n_fiber = m_num[2];
159
160
161 if(m_HitCollection.isValid())
162 {
163 m_HitCollection->Emplace(m_hitID,
164 trackID,
165 particleEncoding,
166 (float) kineticEnergy,
167 (float) energyDeposit,
168 (float) preStepX, (float) preStepY, (float) preStepZ,
169 (float) postStepX, (float) postStepY, (float) postStepZ,
170 (float) globalTime,
171 (int) sign_fiber, (int) n_plate, (int) n_fiber, (int) n_station
172 );
174 }
175 else
176 {
177 G4ExceptionDescription description;
178 description << "ProcessHits: Can't access HitCollection with key " << m_HitCollection.key() << " from store " << m_HitCollection.store();
179 G4Exception("ALFA_SensitiveDetector", "InvalidHitColl2", FatalException, description);
180 return false; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
181 }
182 }
183
184 if (vol_test_str.compare("ODFiber") == 0)
185 {
186 if (std::abs(energyDeposit)<std::numeric_limits<double>::epsilon()) { return true; }
187 m_pos2 = 7;
188 std::string substring (vol_name);
189 std::string num_string (std::move(vol_name));
190
191 std::string test_str = substring.substr(m_pos2,1);
192 int sign_fiber(0);
193 if (test_str.compare("U") == 0)
194 {
195 sign_fiber = 1;
196 }
197
198 if (test_str.compare("V") == 0)
199 {
200 sign_fiber = -1;
201 }
202
203 std::string test_str_side ("A");
204 test_str_side = substring.substr(m_pos2+1,1);
205
206 int OD_side(0);
207 if (test_str_side.compare("0") == 0)
208 {
209 OD_side = 0;
210 }
211
212 if (test_str_side.compare("1") == 0)
213 {
214 OD_side = 1;
215 }
216
217 for ( int k = 0; k < 3; k++ )
218 {
219 substring = substring.substr(m_pos2+1);
220 m_pos1 = int(substring.find('['));
221 m_pos2 = int(substring.find(']'));
222 num_string = substring.substr(m_pos1+1,m_pos2-1);
223 std::istringstream is(num_string);
224 is >> m_num[k];
225 }
226
227 n_station = m_num[0];
228 n_plate = m_num[1];
229 n_fiber = m_num[2];
230
231 if(m_ODHitCollection.isValid())
232 {
233 m_ODHitCollection->Emplace(m_hitID,
234 trackID,
235 particleEncoding,
236 (float) kineticEnergy,
237 (float) energyDeposit,
238 (float) preStepX, (float) preStepY, (float) preStepZ,
239 (float) postStepX, (float) postStepY, (float) postStepZ,
240 (float) globalTime,
241 (int) sign_fiber, (int) OD_side, (int) n_plate, (int) n_fiber, (int) n_station
242 );
244 }
245 else
246 {
247 G4ExceptionDescription description;
248 description << "ProcessHits: Can't access HitCollection with key " << m_ODHitCollection.key() << " from store " << m_ODHitCollection.store();
249 G4Exception("ALFA_SensitiveDetector", "InvalidHitColl3", FatalException, description);
250 return false; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
251 }
252
253 }
254
255
256 return true;
257}
std::string description
glabal timer - how long have I taken so far?
Definition hcg.cxx:91
@ energyDeposit

◆ StartOfAthenaEvent()

void ALFA_SensitiveDetector::StartOfAthenaEvent ( )

Definition at line 44 of file ALFA_SensitiveDetector.cxx.

45{
48}

Member Data Documentation

◆ m_eventNumber

int ALFA_SensitiveDetector::m_eventNumber {}
private

Definition at line 54 of file ALFA_SensitiveDetector.h.

54{};

◆ m_HitCollection

SG::WriteHandle<ALFA_HitCollection> ALFA_SensitiveDetector::m_HitCollection
private

Definition at line 59 of file ALFA_SensitiveDetector.h.

◆ m_hitID

int ALFA_SensitiveDetector::m_hitID {}
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 52 of file ALFA_SensitiveDetector.h.

52{};

◆ m_num

int ALFA_SensitiveDetector::m_num[3] {}
private

Definition at line 64 of file ALFA_SensitiveDetector.h.

64{};

◆ m_numberOfHits

int ALFA_SensitiveDetector::m_numberOfHits {}
private

Definition at line 55 of file ALFA_SensitiveDetector.h.

55{};

◆ m_numberOfODHits

int ALFA_SensitiveDetector::m_numberOfODHits {}
private

Definition at line 56 of file ALFA_SensitiveDetector.h.

56{};

◆ m_ODHitCollection

SG::WriteHandle<ALFA_ODHitCollection> ALFA_SensitiveDetector::m_ODHitCollection
private

Definition at line 60 of file ALFA_SensitiveDetector.h.

◆ m_pos1

int ALFA_SensitiveDetector::m_pos1 {}
private

Definition at line 62 of file ALFA_SensitiveDetector.h.

62{}, m_pos2{};

◆ m_pos2

int ALFA_SensitiveDetector::m_pos2 {}
private

Definition at line 62 of file ALFA_SensitiveDetector.h.

62{}, m_pos2{};

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