File indexing completed on 2026-04-29 07:39:59
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 #include "RE05CalorimeterSD.hh"
0030
0031 #include "RE05CalorimeterHit.hh"
0032
0033 #include "G4LogicalVolume.hh"
0034 #include "G4ParticleDefinition.hh"
0035 #include "G4Step.hh"
0036 #include "G4SystemOfUnits.hh"
0037 #include "G4TouchableHistory.hh"
0038 #include "G4Track.hh"
0039 #include "G4VPhysicalVolume.hh"
0040 #include "G4VTouchable.hh"
0041 #include "G4ios.hh"
0042
0043
0044
0045 RE05CalorimeterSD::RE05CalorimeterSD(G4String name)
0046 : G4VSensitiveDetector(name), fNumberOfCellsInZ(20), fNumberOfCellsInPhi(48)
0047 {
0048 G4String HCname;
0049 collectionName.insert(HCname = "calCollection");
0050 }
0051
0052
0053
0054 RE05CalorimeterSD::~RE05CalorimeterSD() {}
0055
0056
0057
0058 void RE05CalorimeterSD::Initialize(G4HCofThisEvent*)
0059 {
0060 fCalCollection = new RE05CalorimeterHitsCollection(SensitiveDetectorName, collectionName[0]);
0061 for (G4int j = 0; j < fNumberOfCellsInZ; j++)
0062 for (G4int k = 0; k < fNumberOfCellsInPhi; k++) {
0063 fCellID[j][k] = -1;
0064 }
0065 verboseLevel = 0;
0066 }
0067
0068
0069
0070 G4bool RE05CalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
0071 {
0072
0073
0074
0075
0076
0077 G4double edep = aStep->GetTotalEnergyDeposit();
0078 if (verboseLevel > 1) G4cout << "Next step edep(MeV) = " << edep / MeV << G4endl;
0079 if (edep == 0.) return false;
0080
0081 const G4VTouchable* touchable = aStep->GetPreStepPoint()->GetTouchable();
0082 G4int copyIDinZ = touchable->GetReplicaNumber(0);
0083 G4int copyIDinPhi = touchable->GetReplicaNumber(1);
0084
0085 if (fCellID[copyIDinZ][copyIDinPhi] == -1) {
0086 RE05CalorimeterHit* calHit =
0087 new RE05CalorimeterHit(touchable->GetVolume()->GetLogicalVolume(), copyIDinZ, copyIDinPhi);
0088 calHit->SetEdep(edep);
0089 G4AffineTransform aTrans = touchable->GetHistory()->GetTopTransform();
0090 aTrans.Invert();
0091 calHit->SetPos(aTrans.NetTranslation());
0092 calHit->SetRot(aTrans.NetRotation());
0093 G4int icell = fCalCollection->insert(calHit);
0094 fCellID[copyIDinZ][copyIDinPhi] = icell - 1;
0095 if (verboseLevel > 0) {
0096 G4cout << " New Calorimeter Hit on fCellID " << copyIDinZ << " " << copyIDinPhi << G4endl;
0097 }
0098 }
0099 else {
0100 (*fCalCollection)[fCellID[copyIDinZ][copyIDinPhi]]->AddEdep(edep);
0101 if (verboseLevel > 0) {
0102 G4cout << " Energy added to fCellID " << copyIDinZ << " " << copyIDinPhi << G4endl;
0103 }
0104 }
0105
0106 return true;
0107 }
0108
0109
0110
0111 void RE05CalorimeterSD::EndOfEvent(G4HCofThisEvent* HCE)
0112 {
0113 static G4int HCID = -1;
0114 if (HCID < 0) {
0115 HCID = GetCollectionID(0);
0116 }
0117 HCE->AddHitsCollection(HCID, fCalCollection);
0118 }
0119
0120
0121
0122 void RE05CalorimeterSD::clear() {}
0123
0124
0125
0126 void RE05CalorimeterSD::DrawAll() {}
0127
0128
0129
0130 void RE05CalorimeterSD::PrintAll() {}
0131
0132