File indexing completed on 2025-01-31 09:22:22
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 #include "SiliconPixelSD.hh"
0027
0028 #include "G4String.hh"
0029
0030 SiliconPixelSD::SiliconPixelSD(G4String name)
0031 : G4VSensitiveDetector("SiliconPixelHitCollection") {
0032 G4cout << "creating a sensitive detector with name: " << name << G4endl;
0033 collectionName.insert("SiliconPixelHitCollection");
0034 }
0035
0036
0037
0038 SiliconPixelSD::~SiliconPixelSD() {}
0039
0040
0041
0042 void SiliconPixelSD::Initialize(G4HCofThisEvent *HCE) {
0043 fHitCollection = new SiliconPixelHitCollection(GetName(), collectionName[0]);
0044
0045 if (fHCID < 0)
0046 fHCID = GetCollectionID(0);
0047 HCE->AddHitsCollection(fHCID, fHitCollection);
0048
0049 fTmpHits.clear();
0050 }
0051
0052
0053
0054 void SiliconPixelSD::EndOfEvent(G4HCofThisEvent *) {
0055 for (auto it = fTmpHits.begin(); it != fTmpHits.end(); ++it)
0056 fHitCollection->insert(it->second);
0057 }
0058
0059
0060
0061 G4bool SiliconPixelSD::ProcessHits(G4Step *step, G4TouchableHistory *) {
0062 G4TouchableHandle touchable = step->GetPreStepPoint()->GetTouchableHandle();
0063
0064 G4int copyNumCell = touchable->GetVolume(0)->GetCopyNo();
0065 G4int copyNumSensor = touchable->GetVolume(1)->GetCopyNo();
0066 int tmp_ID = 1000 * copyNumSensor + copyNumCell;
0067 if (fTmpHits.find(tmp_ID) == fTmpHits.end()) {
0068 G4String vol_name = touchable->GetVolume(0)->GetName();
0069 fTmpHits[tmp_ID] =
0070 new SiliconPixelHit(vol_name, copyNumSensor, copyNumCell);
0071 G4double hitX = (touchable->GetVolume(1)->GetTranslation().x() +
0072 touchable->GetVolume(0)->GetTranslation().x()) /
0073 CLHEP::cm;
0074 G4double hitY = (touchable->GetVolume(1)->GetTranslation().y() +
0075 touchable->GetVolume(0)->GetTranslation().y()) /
0076 CLHEP::cm;
0077 G4double hitZ = touchable->GetVolume(1)->GetTranslation().z() / CLHEP::cm;
0078 fTmpHits[tmp_ID]->SetPosition(hitX, hitY, hitZ);
0079 }
0080
0081 G4double edep = step->GetTotalEnergyDeposit() / CLHEP::keV;
0082 G4double edepNonIonizing = step->GetNonIonizingEnergyDeposit() / CLHEP::keV;
0083
0084 G4double timedep = step->GetPostStepPoint()->GetGlobalTime() / CLHEP::ns;
0085
0086 fTmpHits[tmp_ID]->AddEdep(edep, timedep);
0087 fTmpHits[tmp_ID]->AddEdepNonIonizing(edepNonIonizing, timedep);
0088
0089 return true;
0090 }
0091
0092