File indexing completed on 2025-02-23 09:22:30
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 "ExGflash1SensitiveDetector.hh"
0032
0033 #include "ExGflash1DetectorConstruction.hh"
0034 #include "ExGflashHit.hh"
0035
0036 #include "G4GFlashSpot.hh"
0037 #include "G4Step.hh"
0038 #include "G4TouchableHistory.hh"
0039 #include "G4VPhysicalVolume.hh"
0040 #include "G4VTouchable.hh"
0041
0042
0043
0044
0045
0046 ExGflash1SensitiveDetector::ExGflash1SensitiveDetector(G4String name,
0047 ExGflash1DetectorConstruction* det)
0048 : G4VSensitiveDetector(name), fDetector(det)
0049 {
0050 G4String caloname = "ExGflashCollection";
0051 collectionName.insert(caloname);
0052 }
0053
0054
0055
0056 ExGflash1SensitiveDetector::~ExGflash1SensitiveDetector() = default;
0057
0058
0059
0060 void ExGflash1SensitiveDetector::Initialize(G4HCofThisEvent* HCE)
0061 {
0062 if (fHCID < 0) {
0063 fHCID = GetCollectionID(0);
0064 }
0065 fCaloHitsCollection =
0066 new ExGflashHitsCollection(SensitiveDetectorName, collectionName[0]);
0067 HCE->AddHitsCollection(fHCID, fCaloHitsCollection);
0068 }
0069
0070
0071
0072 void ExGflash1SensitiveDetector::EndOfEvent(G4HCofThisEvent*) {}
0073
0074
0075
0076 G4bool ExGflash1SensitiveDetector::ProcessHits(G4Step* aStep, G4TouchableHistory* ROhist)
0077 {
0078 G4double e = aStep->GetTotalEnergyDeposit();
0079 if (e <= 0.) return false;
0080
0081 auto theTouchable = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable());
0082
0083
0084
0085
0086
0087 auto caloHit = new ExGflashHit();
0088 caloHit->SetEdep(e);
0089 caloHit->SetPos(aStep->GetPreStepPoint()->GetPosition());
0090 fCaloHitsCollection->insert(caloHit);
0091 if (ROhist) {
0092 ;
0093 }
0094 G4VPhysicalVolume* physVol = theTouchable->GetVolume();
0095 G4int crystalnum = 0;
0096 for (int i = 0; i < 100; i++)
0097 {
0098 if (physVol == fDetector->GetCristal(i)) crystalnum = i;
0099 }
0100 caloHit->SetCrystalNum(crystalnum);
0101
0102 return true;
0103 }
0104
0105
0106
0107
0108 G4bool ExGflash1SensitiveDetector::ProcessHits(G4GFlashSpot* aSpot, G4TouchableHistory* ROhist)
0109 {
0110 G4double e = aSpot->GetEnergySpot()->GetEnergy();
0111 if (e <= 0.) return false;
0112
0113 G4VPhysicalVolume* pCurrentVolume = aSpot->GetTouchableHandle()->GetVolume();
0114
0115 auto caloHit = new ExGflashHit();
0116 caloHit->SetEdep(e);
0117 caloHit->SetPos(aSpot->GetEnergySpot()->GetPosition());
0118 fCaloHitsCollection->insert(caloHit);
0119 if (ROhist) {
0120 ;
0121 }
0122
0123 G4int crystalnum = 0;
0124 for (int i = 0; i < 100; i++)
0125 {
0126 if (pCurrentVolume == fDetector->GetCristal(i)) crystalnum = i;
0127 }
0128 caloHit->SetCrystalNum(crystalnum);
0129
0130 return true;
0131 }
0132
0133