File indexing completed on 2025-02-23 09:21:14
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 #include "SAXSSensitiveDetector.hh"
0032
0033 #include "SAXSSensitiveDetectorHit.hh"
0034
0035 #include "G4HCofThisEvent.hh"
0036 #include "G4Navigator.hh"
0037 #include "G4SDManager.hh"
0038 #include "G4Step.hh"
0039 #include "G4TouchableHistory.hh"
0040 #include "G4Track.hh"
0041 #include "G4ios.hh"
0042
0043
0044
0045 SAXSSensitiveDetector::SAXSSensitiveDetector(G4String name) : G4VSensitiveDetector(name)
0046 {
0047 G4String HCname;
0048 collectionName.insert(HCname = "collection");
0049 fHCID = -1;
0050
0051 fVarStopAndKill = true;
0052
0053 fSDMessenger = new SAXSSensitiveDetectorMessenger(this);
0054 }
0055
0056
0057
0058 SAXSSensitiveDetector::~SAXSSensitiveDetector() {}
0059
0060
0061
0062 void SAXSSensitiveDetector::Initialize(G4HCofThisEvent* HCE)
0063 {
0064 fHitsCollection = new SensitiveDetectorHitsCollection(SensitiveDetectorName, collectionName[0]);
0065 if (fHCID < 0) fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(fHitsCollection);
0066 HCE->AddHitsCollection(fHCID, fHitsCollection);
0067 }
0068
0069
0070
0071 bool SAXSSensitiveDetector::ProcessHits(G4Step* aStep, G4TouchableHistory*)
0072 {
0073 G4Track* vTrack = aStep->GetTrack();
0074
0075 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
0076
0077 G4ThreeVector worldPosition = preStepPoint->GetPosition();
0078 G4ThreeVector localPosition =
0079 preStepPoint->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(
0080 worldPosition);
0081
0082 G4ThreeVector mom = preStepPoint->GetMomentumDirection();
0083
0084
0085 if (!(preStepPoint->GetStepStatus() == fGeomBoundary)) {
0086 return false;
0087 }
0088
0089 G4int vType = -1;
0090 if (preStepPoint->GetMass() == 0 && preStepPoint->GetCharge() == 0) {
0091 vType = 0;
0092 }
0093 else if (preStepPoint->GetMass() != 0 && preStepPoint->GetCharge() == 0) {
0094 vType = 1;
0095 }
0096 else if (preStepPoint->GetMass() != 0 && preStepPoint->GetCharge() > 0) {
0097 vType = 2;
0098 }
0099 else if (preStepPoint->GetMass() != 0 && preStepPoint->GetCharge() < 0) {
0100 vType = 3;
0101 }
0102
0103
0104 SAXSSensitiveDetectorHit* aHit = new SAXSSensitiveDetectorHit();
0105 aHit->SetPos(localPosition);
0106 aHit->SetMom(mom);
0107 aHit->SetType(vType);
0108 aHit->SetEnergy(preStepPoint->GetKineticEnergy());
0109 aHit->SetTime(preStepPoint->GetGlobalTime());
0110 aHit->SetTrackID(vTrack->GetTrackID());
0111 aHit->SetWeight(vTrack->GetWeight());
0112 fHitsCollection->insert(aHit);
0113
0114 if (fVarStopAndKill) {
0115 vTrack->SetTrackStatus(fStopAndKill);
0116 }
0117
0118 return true;
0119 }
0120
0121
0122 void SAXSSensitiveDetector::EndOfEvent(G4HCofThisEvent*) {}
0123
0124