File indexing completed on 2025-01-31 09:21:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043 #include "G4HCofThisEvent.hh"
0044 #include "G4Step.hh"
0045 #include "G4SDManager.hh"
0046 #include "G4SystemOfUnits.hh"
0047
0048 #include "TrackerSD.hh"
0049 #include "ConfigurationManager.hh"
0050
0051 TrackerSD::TrackerSD(G4String name)
0052 : G4VSensitiveDetector(name)
0053 {
0054 G4String HCname = name + "_HC";
0055 collectionName.insert(HCname);
0056 G4cout << collectionName.size() << " TrackerSD name: " << name
0057 << " collection Name: " << HCname << G4endl;
0058 fHCID = -1;
0059 verbose = ConfigurationManager::getInstance()->isEnable_verbose();
0060 }
0061
0062 void TrackerSD::Initialize(G4HCofThisEvent* hce)
0063 {
0064 fTrackerHitsCollection =
0065 new TrackerHitsCollection(SensitiveDetectorName, collectionName[0]);
0066 if(fHCID < 0)
0067 {
0068 if(verbose)
0069 G4cout << "TrackerSD::Initialize: " << SensitiveDetectorName << " "
0070 << collectionName[0] << G4endl;
0071 fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
0072 }
0073 hce->AddHitsCollection(fHCID, fTrackerHitsCollection);
0074 }
0075
0076 G4bool TrackerSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
0077 {
0078 G4double edep = aStep->GetTotalEnergyDeposit();
0079 if(edep == 0. || aStep->GetTrack()->GetDynamicParticle()->GetCharge() == 0)
0080 {
0081 return false;
0082 }
0083 TrackerHit* newHit =
0084 new TrackerHit(edep, aStep->GetPostStepPoint()->GetPosition(),
0085 aStep->GetPostStepPoint()->GetGlobalTime() / ns);
0086 fTrackerHitsCollection->insert(newHit);
0087 return true;
0088 }
0089
0090 void TrackerSD::EndOfEvent(G4HCofThisEvent*)
0091 {
0092 G4int NbHits = fTrackerHitsCollection->entries();
0093 if(verbose)
0094 G4cout << " Number of TrackerHits: " << NbHits << G4endl;
0095 }