File indexing completed on 2025-01-31 09:22:13
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 #include "GammaRayTelAnticoincidenceSD.hh"
0038 #include "GammaRayTelAnticoincidenceHit.hh"
0039 #include "GammaRayTelDetectorConstruction.hh"
0040
0041 #include "G4ios.hh"
0042 #include "G4RunManager.hh"
0043 #include "G4SDManager.hh"
0044 #include "G4Step.hh"
0045 #include "G4SystemOfUnits.hh"
0046 #include "G4TouchableHistory.hh"
0047 #include "G4VPhysicalVolume.hh"
0048 #include "G4VTouchable.hh"
0049
0050
0051
0052 GammaRayTelAnticoincidenceSD::GammaRayTelAnticoincidenceSD(G4String name) : G4VSensitiveDetector(name) {
0053 auto *runManager = G4RunManager::GetRunManager();
0054 detector = (GammaRayTelDetectorConstruction*) (runManager->GetUserDetectorConstruction());
0055
0056 numberOfACDLateralTiles = detector->GetNbOfACDLateralTiles();
0057 numberOfACDTopTiles = detector->GetNbOfACDTopTiles();
0058
0059 G4cout << numberOfACDLateralTiles << " LATERAL " << G4endl;
0060 G4cout << numberOfACDTopTiles << " TOP " << G4endl;
0061
0062 hitLateralID = new G4int[numberOfACDLateralTiles];
0063 hitTopID = new G4int[numberOfACDTopTiles];
0064 collectionName.insert("AnticoincidenceCollection");
0065 }
0066
0067
0068
0069 GammaRayTelAnticoincidenceSD::~GammaRayTelAnticoincidenceSD() {
0070 delete[] hitLateralID;
0071 delete[] hitTopID;
0072 }
0073
0074
0075
0076 void GammaRayTelAnticoincidenceSD::Initialize(G4HCofThisEvent*) {
0077 anticoincidenceCollection = new GammaRayTelAnticoincidenceHitsCollection(SensitiveDetectorName, collectionName[0]);
0078 for (auto i = 0; i < numberOfACDLateralTiles; i++) {
0079 hitLateralID[i] = -1;
0080 }
0081
0082 for (auto j = 0; j < numberOfACDTopTiles; j++) {
0083 hitTopID[j] = -1;
0084 }
0085 }
0086
0087
0088
0089 auto GammaRayTelAnticoincidenceSD::ProcessHits(G4Step *step, G4TouchableHistory*) -> G4bool {
0090 auto depositedEnergy = step->GetTotalEnergyDeposit();
0091 if (depositedEnergy / keV == 0.) {
0092 return false;
0093 }
0094
0095
0096 auto *theTouchable = (G4TouchableHistory*) (step->GetPreStepPoint()->GetTouchable());
0097
0098 auto *acdTile = theTouchable->GetVolume();
0099 auto acdTileNumber = acdTile->GetCopyNo();
0100 auto acdTileName = acdTile->GetName();
0101
0102
0103
0104 if (acdTileName == "ACT") {
0105 if (hitTopID[acdTileNumber] == -1) {
0106 auto *anticoincidenceHit = new GammaRayTelAnticoincidenceHit;
0107 anticoincidenceHit->SetACDType(0);
0108 anticoincidenceHit->AddEnergy(depositedEnergy);
0109 anticoincidenceHit->SetPosition(step->GetPreStepPoint()->GetPosition());
0110 anticoincidenceHit->SetACDTileNumber(acdTileNumber);
0111 hitTopID[acdTileNumber] = anticoincidenceCollection->insert(anticoincidenceHit) - 1;
0112 } else {
0113 (*anticoincidenceCollection)[hitTopID[acdTileNumber]]->AddEnergy(depositedEnergy);
0114 }
0115 }
0116
0117 if (acdTileName == "ACL1") {
0118 if (hitLateralID[acdTileNumber] == -1) {
0119 auto *anticoincidenceHit = new GammaRayTelAnticoincidenceHit;
0120 anticoincidenceHit->SetACDType(1);
0121 anticoincidenceHit->AddEnergy(depositedEnergy);
0122 anticoincidenceHit->SetPosition(step->GetPreStepPoint()->GetPosition());
0123 anticoincidenceHit->SetACDTileNumber(acdTileNumber);
0124 hitLateralID[acdTileNumber] = anticoincidenceCollection->insert(anticoincidenceHit) - 1;
0125 } else {
0126 (*anticoincidenceCollection)[hitLateralID[acdTileNumber]]->AddEnergy(depositedEnergy);
0127 }
0128 }
0129
0130 if (acdTileName == "ACL2") {
0131 if (hitLateralID[acdTileNumber] == -1) {
0132 auto *anticoincidenceHit = new GammaRayTelAnticoincidenceHit;
0133 anticoincidenceHit->SetACDType(2);
0134 anticoincidenceHit->AddEnergy(depositedEnergy);
0135 anticoincidenceHit->SetPosition(step->GetPreStepPoint()->GetPosition());
0136 anticoincidenceHit->SetACDTileNumber(acdTileNumber);
0137 hitLateralID[acdTileNumber] = anticoincidenceCollection->insert(anticoincidenceHit) - 1;
0138 } else {
0139 (*anticoincidenceCollection)[hitLateralID[acdTileNumber]]->AddEnergy(depositedEnergy);
0140 }
0141 }
0142
0143 return true;
0144 }
0145
0146
0147
0148 void GammaRayTelAnticoincidenceSD::EndOfEvent(G4HCofThisEvent *collection) {
0149 static G4int collectionIdentifier = -1;
0150 if (collectionIdentifier < 0) {
0151 collectionIdentifier = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
0152 }
0153 collection->AddHitsCollection(collectionIdentifier, anticoincidenceCollection);
0154
0155 for (auto i = 0; i < numberOfACDLateralTiles; i++) {
0156 hitLateralID[i] = -1;
0157 }
0158
0159 for (auto j = 0; j < numberOfACDTopTiles; j++) {
0160 hitTopID[j] = -1;
0161 }
0162 }
0163
0164
0165
0166 void GammaRayTelAnticoincidenceSD::clear() {
0167 }
0168
0169
0170
0171 void GammaRayTelAnticoincidenceSD::DrawAll() {
0172 }
0173
0174
0175
0176 void GammaRayTelAnticoincidenceSD::PrintAll() {
0177 }