Warning, file /geant4/examples/basic/B5/src/HadCalorimeterSD.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 "HadCalorimeterSD.hh"
0031
0032 #include "Constants.hh"
0033 #include "HadCalorimeterHit.hh"
0034
0035 #include "G4AffineTransform.hh"
0036 #include "G4HCofThisEvent.hh"
0037 #include "G4SDManager.hh"
0038 #include "G4Step.hh"
0039 #include "G4StepPoint.hh"
0040
0041 namespace B5
0042 {
0043
0044
0045
0046 HadCalorimeterSD::HadCalorimeterSD(G4String name) : G4VSensitiveDetector(name)
0047 {
0048 collectionName.insert("HadCalorimeterColl");
0049 }
0050
0051
0052
0053 void HadCalorimeterSD::Initialize(G4HCofThisEvent* hce)
0054 {
0055 fHitsCollection = new HadCalorimeterHitsCollection(SensitiveDetectorName, collectionName[0]);
0056 if (fHCID < 0) {
0057 fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(fHitsCollection);
0058 }
0059 hce->AddHitsCollection(fHCID, fHitsCollection);
0060
0061
0062 for (auto column = 0; column < kNofHadColumns; column++) {
0063 for (auto row = 0; row < kNofHadRows; row++) {
0064 fHitsCollection->insert(new HadCalorimeterHit());
0065 }
0066 }
0067 }
0068
0069
0070
0071 G4bool HadCalorimeterSD::ProcessHits(G4Step* step, G4TouchableHistory*)
0072 {
0073 auto edep = step->GetTotalEnergyDeposit();
0074 if (edep == 0.) return true;
0075
0076 auto touchable = step->GetPreStepPoint()->GetTouchable();
0077 auto rowNo = touchable->GetCopyNumber(2);
0078 auto columnNo = touchable->GetCopyNumber(3);
0079 auto hitID = kNofHadRows * columnNo + rowNo;
0080 auto hit = (*fHitsCollection)[hitID];
0081
0082
0083 if (hit->GetColumnID() < 0) {
0084 hit->SetColumnID(columnNo);
0085 hit->SetRowID(rowNo);
0086 auto depth = touchable->GetHistory()->GetDepth();
0087 auto transform = touchable->GetHistory()->GetTransform(depth - 2);
0088 transform.Invert();
0089 hit->SetRot(transform.NetRotation());
0090 hit->SetPos(transform.NetTranslation());
0091 }
0092
0093 hit->AddEdep(edep);
0094
0095 return true;
0096 }
0097
0098
0099
0100 }