3 #include "G4SDManager.hh"
5 #include "G4StepPoint.hh"
6 #include "G4Transform3D.hh"
7 #include "G4LogicalVolumeStore.hh"
17 G4VSensitiveDetector(iname),
name(iname) {}
25 G4SDManager * SDman = G4SDManager::GetSDMpointer();
26 SDman->AddNewDetector(
this);
31 G4LogicalVolumeStore * theStore = G4LogicalVolumeStore::GetInstance();
32 G4LogicalVolumeStore::const_iterator it;
33 for (it = theStore->begin(); it != theStore->end(); it++)
35 G4LogicalVolume *
v = *it;
36 if (vname==v->GetName()) v->SetSensitiveDetector(
this);
42 #include "G4TouchableHistory.hh"
47 G4StepPoint * preStepPoint =
currentStep->GetPreStepPoint();
48 G4ThreeVector globalCoordinates = preStepPoint->GetPosition();
50 G4TouchableHistory * theTouchable=(G4TouchableHistory *)
51 (preStepPoint->GetTouchable());
52 G4ThreeVector localCoordinates = theTouchable->GetHistory()
53 ->GetTopTransform().TransformPoint(globalCoordinates);
60 G4StepPoint * postStepPoint =
currentStep->GetPostStepPoint();
61 G4StepPoint * preStepPoint =
currentStep->GetPreStepPoint();
62 G4ThreeVector globalCoordinates = postStepPoint->GetPosition();
64 G4TouchableHistory * theTouchable = (G4TouchableHistory *)
65 (preStepPoint->GetTouchable());
66 G4ThreeVector localCoordinates = theTouchable->GetHistory()
67 ->GetTopTransform().TransformPoint(globalCoordinates);
81 G4Track* CurrentTrk = aStep->GetTrack() ;
82 G4ThreeVector CurrentPos = CurrentTrk->GetPosition() ;
83 G4ThreeVector CurrentMom = CurrentTrk->GetMomentum() ;
84 G4VPhysicalVolume* pCurrentVol = CurrentTrk->GetVolume() ;
86 if ( pCurrentVol !=
NULL )
88 NameOfVol = pCurrentVol->GetName() ;
92 NameOfVol =
"CorruptedVolumeInfo" ;
98 xyz[0] = CurrentPos.x() ;
99 xyz[1] = CurrentPos.y() ;
100 xyz[2] = CurrentPos.z() ;
110 throw SimG4Exception(
"SimG4CoreSensitiveDetector: Corrupted Event - NaN detected (position)" ) ;
113 xyz[0] = CurrentMom.x() ;
114 xyz[1] = CurrentMom.y() ;
115 xyz[2] = CurrentMom.z() ;
116 if ( !(xyz[0]==xyz[0]) || !(xyz[1]==xyz[1]) || !(xyz[2]==xyz[2]) ||
119 std::cout <<
" NaN detected in volume " << NameOfVol << std::endl ;
120 throw SimG4Exception(
"SimG4CoreSensitiveDetector: Corrupted Event - NaN detected (3-momentum)" ) ;
virtual ~SensitiveDetector()
Local3DPoint ConvertToLocal3DPoint(G4ThreeVector point)
SensitiveDetector(std::string &iname, const DDCompactView &cpv, SensitiveDetectorCatalog &, edm::ParameterSet const &p)
type of data representation of DDCompactView
void NaNTrap(G4Step *step)
Point3DBase< float, LocalTag > Local3DPoint
virtual void AssignSD(std::string &vname)
virtual void EndOfEvent(G4HCofThisEvent *eventHC)
Local3DPoint FinalStepPosition(G4Step *s, coordinates)
Local3DPoint InitialStepPosition(G4Step *s, coordinates)
virtual void Initialize(G4HCofThisEvent *eventHC)