File indexing completed on 2026-06-10 07:53:07
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 "ExN04CalorimeterSD.hh"
0030
0031 #include "ExN04CalorimeterHit.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 ExN04CalorimeterSD::ExN04CalorimeterSD(G4String name)
0045 : G4VSensitiveDetector(name), fCalCollection(NULL), fnumberOfCellsInZ(20), fnumberOfCellsInPhi(48)
0046 {
0047 G4String HCname;
0048 collectionName.insert(HCname = "calCollection");
0049 }
0050
0051
0052 ExN04CalorimeterSD::~ExN04CalorimeterSD() {}
0053
0054
0055 void ExN04CalorimeterSD::Initialize(G4HCofThisEvent*)
0056 {
0057 fCalCollection = new ExN04CalorimeterHitsCollection(SensitiveDetectorName, collectionName[0]);
0058
0059 for (G4int j = 0; j < fnumberOfCellsInZ; j++) {
0060 for (G4int k = 0; k < fnumberOfCellsInPhi; k++) {
0061 fCellID[j][k] = -1;
0062 }
0063 }
0064
0065 verboseLevel = 0;
0066 }
0067
0068
0069 G4bool ExN04CalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory* ROhist)
0070 {
0071 if (!ROhist) return false;
0072 G4double edep = aStep->GetTotalEnergyDeposit();
0073 if (verboseLevel > 1) G4cout << "Next step edep(MeV) = " << edep / MeV << G4endl;
0074 if (edep == 0.) return false;
0075
0076 G4VPhysicalVolume* physVol = ROhist->GetVolume();
0077
0078
0079 G4int copyIDinZ = ROhist->GetReplicaNumber();
0080 G4int copyIDinPhi = ROhist->GetReplicaNumber(1);
0081
0082 if (fCellID[copyIDinZ][copyIDinPhi] == -1) {
0083 ExN04CalorimeterHit* calHit =
0084 new ExN04CalorimeterHit(physVol->GetLogicalVolume(), copyIDinZ, copyIDinPhi);
0085 calHit->SetEdep(edep);
0086 G4AffineTransform aTrans = ROhist->GetHistory()->GetTopTransform();
0087 aTrans.Invert();
0088 calHit->SetPos(aTrans.NetTranslation());
0089 calHit->SetRot(aTrans.NetRotation());
0090 G4int icell = fCalCollection->insert(calHit);
0091 fCellID[copyIDinZ][copyIDinPhi] = icell - 1;
0092 if (verboseLevel > 0) {
0093 G4cout << " New Calorimeter Hit on CellID " << copyIDinZ << " " << copyIDinPhi << G4endl;
0094 }
0095 }
0096 else {
0097 (*fCalCollection)[fCellID[copyIDinZ][copyIDinPhi]]->AddEdep(edep);
0098 if (verboseLevel > 0) {
0099 G4cout << " Energy added to CellID " << copyIDinZ << " " << copyIDinPhi << G4endl;
0100 }
0101 }
0102
0103 return true;
0104 }
0105
0106
0107 void ExN04CalorimeterSD::EndOfEvent(G4HCofThisEvent* HCE)
0108 {
0109 static G4int HCID = -1;
0110 if (HCID < 0) {
0111 HCID = GetCollectionID(0);
0112 }
0113 HCE->AddHitsCollection(HCID, fCalCollection);
0114 }
0115
0116
0117 void ExN04CalorimeterSD::clear() {}
0118
0119
0120 void ExN04CalorimeterSD::DrawAll() {}
0121
0122
0123 void ExN04CalorimeterSD::PrintAll() {}