6 #include "G4SDManager.hh" 9 #include "G4StepPoint.hh" 10 #include "G4Transform3D.hh" 11 #include "G4LogicalVolumeStore.hh" 12 #include "G4TouchableHistory.hh" 13 #include "G4VUserTrackInformation.hh" 18 : G4VSensitiveDetector(iname), m_isCalo(
calo) {
26 G4SDManager* SDman = G4SDManager::GetSDMpointer();
27 SDman->AddNewDetector(
this);
32 this->
AssignSD({lvname.data(), lvname.size()});
33 ss <<
" " << lvname <<
"\n";
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);
94 if (
nullptr ==
info) {
95 edm::LogWarning(
"SensitiveDetector") <<
" no TrackInformation available for trackID= " << aTrack->GetTrackID()
96 <<
" inside SD " << GetName();
98 "SensitiveDetector::cmsTrackInformation()",
"sd01", FatalException,
"cannot handle hits without trackinfo");
109 G4Track* currentTrk = aStep->GetTrack();
110 double ekin = currentTrk->GetKineticEnergy();
112 const G4VPhysicalVolume* pCurrentVol = aStep->GetPreStepPoint()->GetPhysicalVolume();
113 edm::LogWarning(
"SensitiveDetector") <<
"Negative kinetic energy Ekin(MeV)=" << ekin / CLHEP::MeV <<
" of " 114 << currentTrk->GetDefinition()->GetParticleName()
115 <<
" trackID= " << currentTrk->GetTrackID() <<
" inside " 116 << pCurrentVol->GetName();
117 currentTrk->SetKineticEnergy(0.0);
119 const G4ThreeVector& currentPos = currentTrk->GetPosition();
120 double xyz = currentPos.x() + currentPos.y() + currentPos.z();
121 const G4ThreeVector& currentMom = currentTrk->GetMomentum();
122 xyz += currentMom.x() + currentMom.y() + currentMom.z();
125 const G4VPhysicalVolume* pCurrentVol = aStep->GetPreStepPoint()->GetPhysicalVolume();
126 edm::LogWarning(
"SensitiveDetector") <<
"NaN detected for trackID= " << currentTrk->GetTrackID() <<
" inside " 127 << pCurrentVol->GetName();
128 G4Exception(
"SensitiveDetector::NaNTrap()",
"sd01", FatalException,
"corrupted event or step");
Log< level::Info, true > LogVerbatim
~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)
Local3DPoint FinalStepPosition(const G4Step *step, coordinates) const
std::vector< std::string > m_namesOfSD
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const
Local3DPoint InitialStepPosition(const G4Step *step, coordinates) const
TrackInformation * cmsTrackInformation(const G4Track *aTrack)
Local3DPoint LocalPreStepPosition(const G4Step *step) const
void EndOfEvent(G4HCofThisEvent *eventHC) override
void setNames(const std::vector< std::string > &)
Local3DPoint LocalPostStepPosition(const G4Step *step) const
Log< level::Warning, false > LogWarning
void Initialize(G4HCofThisEvent *eventHC) override
void NaNTrap(const G4Step *step) const