ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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. More...
 
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 22 of file ALFA_SensitiveDetector.cxx.

23  : G4VSensitiveDetector( name ),
24  m_HitCollection(hitCollectionName),
25  m_ODHitCollection(ODhitCollectionName)
26 {
27 
28  m_hitID = -1;
29 
30  m_eventNumber = 0;
31  m_numberOfHits = 0;
32  m_numberOfODHits = 0;
33 
34  m_pos1 = 0;
35  m_pos2 = 0;
36 
37  m_num[0] = 0;
38  m_num[1] = 0;
39  m_num[2] = 0;
40 
41 }

◆ ~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 284 of file ALFA_SensitiveDetector.cxx.

285 {
286  G4cout << " Total number of hits in MD: " << m_numberOfHits << G4endl;
287  G4cout << " Total number of hits in OD: " << m_numberOfODHits << G4endl;
288  G4cout << "*************************************************************" << G4endl;
289 
290  ++m_eventNumber;
291 
292  m_numberOfHits = 0;
293  m_numberOfODHits = 0;
294 }

◆ 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 50 of file ALFA_SensitiveDetector.cxx.

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

◆ ProcessHits()

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

Definition at line 56 of file ALFA_SensitiveDetector.cxx.

57 {
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 
99 
100  if(vol_name.find("GVS") != std::string::npos)
101  {
102 
103  if(vol_name.find("B7L1") != std::string::npos) n_station=0;
104  else if(vol_name.find("A7L1") != std::string::npos) n_station=1;
105  else if(vol_name.find("A7R1") != std::string::npos) n_station=2;
106  else if(vol_name.find("B7R1") != std::string::npos) n_station=3;
107  else n_station=-1;
108  if(m_HitCollection.isValid())
109  {
110  m_HitCollection->Emplace(m_hitID, trackID, particleEncoding, (float) kineticEnergy,
111  (float) energyDeposit,(float) preStepX, (float) preStepY, (float) preStepZ,
112  (float) postStepX, (float) postStepY, (float) postStepZ,(float) globalTime,
113  -1, 100, -1, (int) n_station);
114  m_numberOfHits++;
115  }
116  else
117  {
118  G4ExceptionDescription description;
119  description << "ProcessHits: Can't access HitCollection with key " << m_HitCollection.key() << " from store " << m_HitCollection.store();
120  G4Exception("ALFA_SensitiveDetector", "InvalidHitColl1", FatalException, description);
121  return false; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
122  }
123  }
124 
125  if (vol_test_str.compare("ALFA_Fi") == 0)
126  {
127  if (std::abs(energyDeposit)<std::numeric_limits<double>::epsilon()) { return true; }
128  m_pos2 = 10;
129  std::string substring (vol_name);
130  std::string num_string (vol_name);
131 
134 
135  std::string test_str ("A");
136  test_str = substring.substr(m_pos2,1);
137  int sign_fiber(0);
138  if (test_str.compare("U") == 0)
139  {
140  sign_fiber = 1;
142  }
143 
144  if (test_str.compare("V") == 0)
145  {
146  sign_fiber = -1;
148  }
149 
150 
151  for ( int k = 0; k < 3; k++ )
152  {
153  substring = substring.substr(m_pos2+1);
155  m_pos1 = int(substring.find('['));
157  m_pos2 = int(substring.find(']'));
159  num_string = substring.substr(m_pos1+1,m_pos2-1);
161  std::istringstream is(num_string);
162  is >> m_num[k];
164  }
165 
166  n_station = m_num[0];
167  n_plate = m_num[1];
168  n_fiber = m_num[2];
169 
171 
172  if(m_HitCollection.isValid())
173  {
174  m_HitCollection->Emplace(m_hitID,
175  trackID,
176  particleEncoding,
177  (float) kineticEnergy,
178  (float) energyDeposit,
179  (float) preStepX, (float) preStepY, (float) preStepZ,
180  (float) postStepX, (float) postStepY, (float) postStepZ,
181  (float) globalTime,
182  (int) sign_fiber, (int) n_plate, (int) n_fiber, (int) n_station
183  );
184  ++m_numberOfHits;
185  }
186  else
187  {
188  G4ExceptionDescription description;
189  description << "ProcessHits: Can't access HitCollection with key " << m_HitCollection.key() << " from store " << m_HitCollection.store();
190  G4Exception("ALFA_SensitiveDetector", "InvalidHitColl2", FatalException, description);
191  return false; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
192  }
193  }
194 
195  if (vol_test_str.compare("ODFiber") == 0)
196  {
197  if (std::abs(energyDeposit)<std::numeric_limits<double>::epsilon()) { return true; }
198  m_pos2 = 7;
199  std::string substring (vol_name);
200  std::string num_string (vol_name);
201 
204 
205  std::string test_str = substring.substr(m_pos2,1);
206  int sign_fiber(0);
207  if (test_str.compare("U") == 0)
208  {
209  sign_fiber = 1;
211  }
212 
213  if (test_str.compare("V") == 0)
214  {
215  sign_fiber = -1;
217  }
218 
219  std::string test_str_side ("A");
220  test_str_side = substring.substr(m_pos2+1,1);
221 
223  int OD_side(0);
224  if (test_str_side.compare("0") == 0)
225  {
226  OD_side = 0;
228  }
229 
230  if (test_str_side.compare("1") == 0)
231  {
232  OD_side = 1;
234  }
235 
236  for ( int k = 0; k < 3; k++ )
237  {
238  substring = substring.substr(m_pos2+1);
240  m_pos1 = int(substring.find('['));
242  m_pos2 = int(substring.find(']'));
244  num_string = substring.substr(m_pos1+1,m_pos2-1);
246  std::istringstream is(num_string);
247  is >> m_num[k];
249  }
250 
251  n_station = m_num[0];
252  n_plate = m_num[1];
253  n_fiber = m_num[2];
254 
256  if(m_ODHitCollection.isValid())
257  {
258  m_ODHitCollection->Emplace(m_hitID,
259  trackID,
260  particleEncoding,
261  (float) kineticEnergy,
262  (float) energyDeposit,
263  (float) preStepX, (float) preStepY, (float) preStepZ,
264  (float) postStepX, (float) postStepY, (float) postStepZ,
265  (float) globalTime,
266  (int) sign_fiber, (int) OD_side, (int) n_plate, (int) n_fiber, (int) n_station
267  );
269  }
270  else
271  {
272  G4ExceptionDescription description;
273  description << "ProcessHits: Can't access HitCollection with key " << m_ODHitCollection.key() << " from store " << m_ODHitCollection.store();
274  G4Exception("ALFA_SensitiveDetector", "InvalidHitColl3", FatalException, description);
275  return false; //The G4Exception call above should abort the job, but Coverity does not seem to pick this up.
276  }
277 
278  }
279 
280 
281  return true;
282 }

◆ StartOfAthenaEvent()

void ALFA_SensitiveDetector::StartOfAthenaEvent ( )

Definition at line 43 of file ALFA_SensitiveDetector.cxx.

44 {
45  m_numberOfHits = 0;
46  m_numberOfODHits = 0;
47 }

Member Data Documentation

◆ m_eventNumber

int ALFA_SensitiveDetector::m_eventNumber
private

Definition at line 54 of file ALFA_SensitiveDetector.h.

◆ 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.

◆ m_num

int ALFA_SensitiveDetector::m_num[3]
private

Definition at line 64 of file ALFA_SensitiveDetector.h.

◆ m_numberOfHits

int ALFA_SensitiveDetector::m_numberOfHits
private

Definition at line 55 of file ALFA_SensitiveDetector.h.

◆ m_numberOfODHits

int ALFA_SensitiveDetector::m_numberOfODHits
private

Definition at line 56 of file ALFA_SensitiveDetector.h.

◆ 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.

◆ m_pos2

int ALFA_SensitiveDetector::m_pos2
private

Definition at line 62 of file ALFA_SensitiveDetector.h.


The documentation for this class was generated from the following files:
ALFA_SensitiveDetector::m_HitCollection
SG::WriteHandle< ALFA_HitCollection > m_HitCollection
Definition: ALFA_SensitiveDetector.h:59
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
ALFA_SensitiveDetector::m_ODHitCollection
SG::WriteHandle< ALFA_ODHitCollection > m_ODHitCollection
Definition: ALFA_SensitiveDetector.h:60
ALFA_SensitiveDetector::m_numberOfODHits
int m_numberOfODHits
Definition: ALFA_SensitiveDetector.h:56
Trk::energyDeposit
@ energyDeposit
Definition: MeasurementType.h:32
ALFA_SensitiveDetector::m_num
int m_num[3]
Definition: ALFA_SensitiveDetector.h:64
ALFA_SensitiveDetector::m_eventNumber
int m_eventNumber
Definition: ALFA_SensitiveDetector.h:54
ALFA_SensitiveDetector::m_hitID
int m_hitID
Templated method to stuff a single hit into the sensitive detector class.
Definition: ALFA_SensitiveDetector.h:52
ALFA_SensitiveDetector::m_numberOfHits
int m_numberOfHits
Definition: ALFA_SensitiveDetector.h:55
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
ALFA_SensitiveDetector::m_pos2
int m_pos2
Definition: ALFA_SensitiveDetector.h:62
ALFA_SensitiveDetector::m_pos1
int m_pos1
Definition: ALFA_SensitiveDetector.h:62
fitman.k
k
Definition: fitman.py:528
description
std::string description
glabal timer - how long have I taken so far?
Definition: hcg.cxx:88