3 #include "G4SDManager.hh"
5 #include "G4StepPoint.hh"
6 #include "G4Transform3D.hh"
7 #include "G4LogicalVolumeStore.hh"
18 G4VSensitiveDetector(iname),
name(iname) {}
26 G4SDManager * SDman = G4SDManager::GetSDMpointer();
27 SDman->AddNewDetector(
this);
32 G4LogicalVolumeStore * theStore = G4LogicalVolumeStore::GetInstance();
33 G4LogicalVolumeStore::const_iterator it;
34 for (it = theStore->begin(); it != theStore->end(); it++)
36 G4LogicalVolume *
v = *it;
37 if (vname==v->GetName()) { v->SetSensitiveDetector(
this); }
43 #include "G4TouchableHistory.hh"
48 G4StepPoint * preStepPoint =
currentStep->GetPreStepPoint();
49 G4ThreeVector globalCoordinates = preStepPoint->GetPosition();
51 G4TouchableHistory * theTouchable=(G4TouchableHistory *)
52 (preStepPoint->GetTouchable());
53 G4ThreeVector localCoordinates = theTouchable->GetHistory()
54 ->GetTopTransform().TransformPoint(globalCoordinates);
61 G4StepPoint * postStepPoint =
currentStep->GetPostStepPoint();
62 G4StepPoint * preStepPoint =
currentStep->GetPreStepPoint();
63 G4ThreeVector globalCoordinates = postStepPoint->GetPosition();
65 G4TouchableHistory * theTouchable = (G4TouchableHistory *)
66 (preStepPoint->GetTouchable());
67 G4ThreeVector localCoordinates = theTouchable->GetHistory()
68 ->GetTopTransform().TransformPoint(globalCoordinates);
82 G4Track* CurrentTrk = aStep->GetTrack() ;
83 G4ThreeVector CurrentPos = CurrentTrk->GetPosition() ;
84 G4ThreeVector CurrentMom = CurrentTrk->GetMomentum() ;
85 G4VPhysicalVolume* pCurrentVol = CurrentTrk->GetVolume() ;
87 if ( pCurrentVol !=
NULL )
89 NameOfVol = pCurrentVol->GetName() ;
93 NameOfVol =
"CorruptedVolumeInfo" ;
100 xyz[0] = CurrentPos.x() ;
101 xyz[1] = CurrentPos.y() ;
102 xyz[2] = CurrentPos.z() ;
112 throw SimG4Exception(
"SimG4CoreSensitiveDetector: Corrupted Event - NaN detected (position)" );
115 xyz[0] = CurrentMom.x() ;
116 xyz[1] = CurrentMom.y() ;
117 xyz[2] = CurrentMom.z() ;
118 if ( !(xyz[0]==xyz[0]) || !(xyz[1]==xyz[1]) || !(xyz[2]==xyz[2]) ||
122 std::cout <<
" NaN detected in volume " << NameOfVol << std::endl ;
123 throw SimG4Exception(
"SimG4CoreSensitiveDetector: Corrupted Event - NaN detected (3-momentum)" ) ;
virtual ~SensitiveDetector()
type of data representation of DDCompactView
SensitiveDetector(std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &, edm::ParameterSet const &p)
virtual void AssignSD(const std::string &vname)
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point)
void NaNTrap(G4Step *step)
Point3DBase< float, LocalTag > Local3DPoint
return(e1-e2)*(e1-e2)+dp *dp
virtual void EndOfEvent(G4HCofThisEvent *eventHC)
Local3DPoint FinalStepPosition(G4Step *s, coordinates)
Local3DPoint InitialStepPosition(G4Step *s, coordinates)
virtual void Initialize(G4HCofThisEvent *eventHC)