File indexing completed on 2025-01-31 09:22:04
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 #include "AnalysisManager.hh"
0028 #include "eRositaTrackerSD.hh"
0029 #include "eRositaTrackerHit.hh"
0030
0031 #include <fstream>
0032 #include <iostream>
0033
0034 #include "G4HCofThisEvent.hh"
0035 #include "G4ios.hh"
0036 #include "G4ParticleTypes.hh"
0037 #include "G4SDManager.hh"
0038 #include "G4Step.hh"
0039 #include "G4ThreeVector.hh"
0040
0041
0042
0043 eRositaTrackerSD::eRositaTrackerSD(G4String name) : G4VSensitiveDetector(name)
0044 {
0045 constexpr auto TRACKER_COLLECTION_NAME = "TrackerCollection";
0046 collectionName.insert(TRACKER_COLLECTION_NAME);
0047 }
0048
0049
0050
0051 eRositaTrackerSD::~eRositaTrackerSD()
0052 {
0053 }
0054
0055
0056
0057 void eRositaTrackerSD::Initialize(G4HCofThisEvent* collection)
0058 {
0059 trackerCollection = new eRositaTrackerHitsCollection(SensitiveDetectorName, collectionName[0]);
0060 static G4int collectionIdentifier = -1;
0061
0062 if (collectionIdentifier < 0) {
0063 collectionIdentifier = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
0064 }
0065 collection->AddHitsCollection(collectionIdentifier, trackerCollection);
0066 }
0067
0068
0069
0070 auto eRositaTrackerSD::ProcessHits(G4Step* step, G4TouchableHistory*) -> G4bool
0071 {
0072 if (step->GetTrack()->GetDefinition() != G4Gamma::GammaDefinition()) {
0073 return false;
0074 }
0075
0076
0077 auto depositedEnergy = step->GetPreStepPoint()->GetKineticEnergy();
0078 if (depositedEnergy == 0.) {
0079 return false;
0080 }
0081
0082 auto *newHit = new eRositaTrackerHit();
0083 newHit->SetTrackIdentifier(step->GetTrack()->GetTrackID());
0084
0085 newHit->SetDepositedEnergy(depositedEnergy);
0086 newHit->SetPosition(step->GetPostStepPoint()->GetPosition());
0087 trackerCollection->insert(newHit);
0088
0089
0090
0091
0092
0093
0094
0095
0096 return true;
0097 }
0098
0099
0100
0101 void eRositaTrackerSD::EndOfEvent(G4HCofThisEvent*)
0102 {
0103 G4int numberOfHits = trackerCollection->entries();
0104
0105 if (verboseLevel > 0) {
0106 G4cout << G4endl
0107 << "Hits collection: in this event there are " << numberOfHits
0108 << " hits in the tracker chambers: " << G4endl;
0109
0110 for (G4int i = 0; i < numberOfHits; i++) {
0111 (*trackerCollection)[i]->Print();
0112 }
0113 }
0114
0115 for (G4int i = 0; i < numberOfHits; i++) {
0116 (*trackerCollection)[i]->PrintToFile();
0117 };
0118 }