7 #include "G4SDManager.hh"
10 #include "G4StepPoint.hh"
11 #include "G4Transform3D.hh"
12 #include "G4LogicalVolumeStore.hh"
13 #include "G4TouchableHistory.hh"
14 #include "G4VUserTrackInformation.hh"
19 : G4VSensitiveDetector(iname), m_isCalo(
calo) {
27 G4SDManager* SDman = G4SDManager::GetSDMpointer();
28 SDman->AddNewDetector(
this);
33 this->
AssignSD({lvname.data(), lvname.size()});
36 edm::LogVerbatim(
"SensitiveDetector") <<
" <" << iname <<
"> : Assigns SD to LVs " <<
ss.str();
46 G4LogicalVolumeStore* theStore = G4LogicalVolumeStore::GetInstance();
47 for (
auto& lv : *theStore) {
48 if (vname == lv->GetName()) {
49 lv->SetSensitiveDetector(
this);
55 const G4StepPoint* preStepPoint =
step->GetPreStepPoint();
56 const G4ThreeVector& globalCoordinates = preStepPoint->GetPosition();
60 const G4TouchableHistory* theTouchable = static_cast<const G4TouchableHistory*>(preStepPoint->GetTouchable());
61 const G4ThreeVector localCoordinates =
62 theTouchable->GetHistory()->GetTopTransform().TransformPoint(globalCoordinates);
67 const G4StepPoint* postStepPoint =
step->GetPostStepPoint();
68 const G4ThreeVector& globalCoordinates = postStepPoint->GetPosition();
72 const G4StepPoint* preStepPoint =
step->GetPreStepPoint();
73 const G4ThreeVector localCoordinates =
74 preStepPoint->GetTouchable()->GetHistory()->GetTopTransform().TransformPoint(globalCoordinates);
79 const G4StepPoint* preStepPoint =
step->GetPreStepPoint();
80 G4ThreeVector localCoordinates =
81 preStepPoint->GetTouchable()->GetHistory()->GetTopTransform().TransformPoint(preStepPoint->GetPosition());
86 const G4ThreeVector& globalCoordinates =
step->GetPostStepPoint()->GetPosition();
87 G4ThreeVector localCoordinates =
88 step->GetPreStepPoint()->GetTouchable()->GetHistory()->GetTopTransform().TransformPoint(globalCoordinates);
95 edm::LogWarning(
"SensitiveDetector") <<
" no TrackInformation available for trackID= " << aTrack->GetTrackID();
96 throw SimG4Exception(
"SimG4CoreSensitiveDetector: cannot handle hits for " + GetName());
107 const G4Track* CurrentTrk = aStep->GetTrack();
108 const G4ThreeVector& CurrentPos = CurrentTrk->GetPosition();
109 double xyz = CurrentPos.x() + CurrentPos.y() + CurrentPos.z();
110 const G4ThreeVector& CurrentMom = CurrentTrk->GetMomentum();
111 xyz += CurrentMom.x() + CurrentMom.y() + CurrentMom.z();
114 const G4VPhysicalVolume* pCurrentVol = aStep->GetPreStepPoint()->GetPhysicalVolume();
115 const G4String& NameOfVol = pCurrentVol->GetName();
116 throw SimG4Exception(
"SimG4CoreSensitiveDetector: Corrupted Event - NaN detected in volume " + NameOfVol);