7 #include "G4SDManager.hh" 10 #include "G4StepPoint.hh" 11 #include "G4Transform3D.hh" 12 #include "G4LogicalVolumeStore.hh" 13 #include "G4TouchableHistory.hh" 14 #include "G4VUserTrackInformation.hh" 23 : G4VSensitiveDetector(iname), m_isCalo(calo) {
31 G4SDManager* SDman = G4SDManager::GetSDMpointer();
32 SDman->AddNewDetector(
this);
34 const std::vector<std::string_view>& lvNames = clg.
logicalNames(iname);
36 for (
auto& lvname : lvNames) {
37 this->
AssignSD({lvname.data(), lvname.size()});
40 edm::LogVerbatim(
"SensitiveDetector") <<
" <" << iname <<
"> : Assigns SD to LVs " << ss.str();
50 G4LogicalVolumeStore* theStore = G4LogicalVolumeStore::GetInstance();
51 for (
auto& lv : *theStore) {
52 if (vname == lv->GetName()) {
53 lv->SetSensitiveDetector(
this);
59 const G4StepPoint* preStepPoint = step->GetPreStepPoint();
60 const G4ThreeVector& globalCoordinates = preStepPoint->GetPosition();
64 const G4TouchableHistory* theTouchable =
static_cast<const G4TouchableHistory*
>(preStepPoint->GetTouchable());
65 const G4ThreeVector localCoordinates =
66 theTouchable->GetHistory()->GetTopTransform().TransformPoint(globalCoordinates);
71 const G4StepPoint* postStepPoint = step->GetPostStepPoint();
72 const G4ThreeVector& globalCoordinates = postStepPoint->GetPosition();
76 const G4StepPoint* preStepPoint = step->GetPreStepPoint();
77 const G4ThreeVector localCoordinates =
78 preStepPoint->GetTouchable()->GetHistory()->GetTopTransform().TransformPoint(globalCoordinates);
83 const G4StepPoint* preStepPoint = step->GetPreStepPoint();
84 G4ThreeVector localCoordinates =
85 preStepPoint->GetTouchable()->GetHistory()->GetTopTransform().TransformPoint(preStepPoint->GetPosition());
90 const G4ThreeVector& globalCoordinates = step->GetPostStepPoint()->GetPosition();
91 G4ThreeVector localCoordinates =
92 step->GetPreStepPoint()->GetTouchable()->GetHistory()->GetTopTransform().TransformPoint(globalCoordinates);
99 edm::LogWarning(
"SensitiveDetector") <<
" no TrackInformation available for trackID= " << aTrack->GetTrackID();
100 throw SimG4Exception(
"SimG4CoreSensitiveDetector: cannot handle hits for " + GetName());
111 const G4Track* CurrentTrk = aStep->GetTrack();
112 const G4ThreeVector& CurrentPos = CurrentTrk->GetPosition();
113 double xyz = CurrentPos.x() + CurrentPos.y() + CurrentPos.z();
114 const G4ThreeVector& CurrentMom = CurrentTrk->GetMomentum();
115 xyz += CurrentMom.x() + CurrentMom.y() + CurrentMom.z();
118 const G4VPhysicalVolume* pCurrentVol = aStep->GetPreStepPoint()->GetPhysicalVolume();
119 const G4String& NameOfVol = pCurrentVol->GetName();
120 throw SimG4Exception(
"SimG4CoreSensitiveDetector: Corrupted Event - NaN detected in volume " + NameOfVol);
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const
~SensitiveDetector() override
constexpr bool isNotFinite(T x)
const std::vector< std::string_view > logicalNames(const std::string &readoutName) const
void AssignSD(const std::string &vname)
std::vector< std::string > m_namesOfSD
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
SensitiveDetector(const std::string &iname, const edm::EventSetup &es, const SensitiveDetectorCatalog &, edm::ParameterSet const &p, bool calo)
void Initialize(G4HCofThisEvent *eventHC) override
void NaNTrap(const G4Step *step) const
Local3DPoint InitialStepPosition(const G4Step *step, coordinates) const