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