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