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);
30 const std::vector<std::string_view>& lvNames = clg.
logicalNames(iname);
32 for (
auto& lvname : lvNames) {
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);
Log< level::Info, true > LogVerbatim
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const
~SensitiveDetector() override
constexpr bool isNotFinite(T x)
SensitiveDetector(const std::string &iname, const SensitiveDetectorCatalog &, bool calo)
const std::vector< std::string_view > logicalNames(const std::string &readoutName) const
void AssignSD(const std::string &vname)
std::vector< std::string > m_namesOfSD
std::string const collectionName[nCollections]
Local3DPoint FinalStepPosition(const G4Step *step, coordinates) const
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
void EndOfEvent(G4HCofThisEvent *eventHC) override
Local3DPoint LocalPostStepPosition(const G4Step *step) const
void setNames(const std::vector< std::string > &)
Local3DPoint LocalPreStepPosition(const G4Step *step) const
Log< level::Warning, false > LogWarning
void Initialize(G4HCofThisEvent *eventHC) override
void NaNTrap(const G4Step *step) const
Local3DPoint InitialStepPosition(const G4Step *step, coordinates) const