3 #include "G4SDManager.hh"
5 #include "G4StepPoint.hh"
6 #include "G4Transform3D.hh"
7 #include "G4LogicalVolumeStore.hh"
16 G4VSensitiveDetector(iname),
name(iname) {}
24 G4SDManager * SDman = G4SDManager::GetSDMpointer();
25 SDman->AddNewDetector(
this);
30 G4LogicalVolumeStore * theStore = G4LogicalVolumeStore::GetInstance();
31 G4LogicalVolumeStore::const_iterator it;
32 for (it = theStore->begin(); it != theStore->end(); it++)
34 G4LogicalVolume *
v = *it;
35 if (vname==v->GetName()) v->SetSensitiveDetector(
this);
41 #include "G4TouchableHistory.hh"
46 G4StepPoint * preStepPoint =
currentStep->GetPreStepPoint();
47 G4ThreeVector globalCoordinates = preStepPoint->GetPosition();
49 G4TouchableHistory * theTouchable=(G4TouchableHistory *)
50 (preStepPoint->GetTouchable());
51 G4ThreeVector localCoordinates = theTouchable->GetHistory()
52 ->GetTopTransform().TransformPoint(globalCoordinates);
59 G4StepPoint * postStepPoint =
currentStep->GetPostStepPoint();
60 G4StepPoint * preStepPoint =
currentStep->GetPreStepPoint();
61 G4ThreeVector globalCoordinates = postStepPoint->GetPosition();
63 G4TouchableHistory * theTouchable = (G4TouchableHistory *)
64 (preStepPoint->GetTouchable());
65 G4ThreeVector localCoordinates = theTouchable->GetHistory()
66 ->GetTopTransform().TransformPoint(globalCoordinates);
80 G4Track* CurrentTrk = aStep->GetTrack() ;
81 G4ThreeVector CurrentPos = CurrentTrk->GetPosition() ;
82 G4ThreeVector CurrentMom = CurrentTrk->GetMomentum() ;
83 G4VPhysicalVolume* pCurrentVol = CurrentTrk->GetVolume() ;
85 if ( pCurrentVol !=
NULL )
87 NameOfVol = pCurrentVol->GetName() ;
91 NameOfVol =
"CorruptedVolumeInfo" ;
97 xyz[0] = CurrentPos.x() ;
98 xyz[1] = CurrentPos.y() ;
99 xyz[2] = CurrentPos.z() ;
106 if(
isnan(xyz[0]+xyz[1]+xyz[2]) != 0 )
109 throw SimG4Exception(
"SimG4CoreSensitiveDetector: Corrupted Event - NaN detected (position)" ) ;
112 xyz[0] = CurrentMom.x() ;
113 xyz[1] = CurrentMom.y() ;
114 xyz[2] = CurrentMom.z() ;
115 if ( !(xyz[0]==xyz[0]) || !(xyz[1]==xyz[1]) || !(xyz[2]==xyz[2]) ||
118 std::cout <<
" NaN detected in volume " << NameOfVol << std::endl ;
119 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)