Geant4-11
G4VFastSimSensitiveDetector.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26
27#ifndef G4VFASTSIMSENSITIVEDETECTOR_HH
28#define G4VFASTSIMSENSITIVEDETECTOR_HH
29
30#include "G4VReadOutGeometry.hh"
31#include "G4TouchableHistory.hh"
33#include "G4FastHit.hh"
34#include "G4FastTrack.hh"
35
55{
56 public:
67 inline G4bool Hit(const G4FastHit* aHit, const G4FastTrack* aTrack,
68 G4TouchableHandle* aTouchable)
69 {
70 G4bool result = true;
71 G4VSensitiveDetector* sensDet = dynamic_cast<G4VSensitiveDetector*>(this);
72 if(sensDet == nullptr)
73 {
74 G4Exception("G4VFastSimSensitiveDetector::Hit()", "InvalidSetup",
76 "Sensitive detector needs also to inherit also from "
77 "G4VSensitiveDetector if full "
78 "simulation is used instead!");
79 }
80 if(sensDet->isActive())
81 {
82 G4VReadOutGeometry* ROgeometry = sensDet->GetROgeometry();
83 G4TouchableHistory* ROhistory = 0;
84
85 if(ROgeometry)
86 {
87 // create fake pre-step point updating the touchable from read-out
88 // geometry.
89 G4Step fakeStep;
90 const G4Track* currentTrack = aTrack->GetPrimaryTrack();
91 G4StepPoint* tmpPoint = fakeStep.GetPreStepPoint();
92 tmpPoint->SetTouchableHandle(*aTouchable);
93 tmpPoint->SetPosition(aHit->GetPosition());
94 tmpPoint->SetMomentumDirection(currentTrack->GetMomentumDirection());
95 result = ROgeometry->CheckROVolume(&fakeStep, ROhistory);
96 } else {
97 ROhistory = static_cast<G4TouchableHistory*>((*aTouchable)());
98 }
99 if(result)
100 result = ProcessHits(aHit, aTrack, ROhistory);
101 }
102 else
103 {
104 result = false;
105 }
106 return result;
107 }
108
109 private:
119 virtual G4bool ProcessHits(const G4FastHit* aHit, const G4FastTrack* aTrack,
120 G4TouchableHistory* aROHistory) = 0;
121};
122#endif /* G4VFASTSIMSENSITIVEDETECTOR_HH */
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
bool G4bool
Definition: G4Types.hh:86
Minimal hit created in the fast simulation.
Definition: G4FastHit.hh:48
G4ThreeVector GetPosition() const
Get position.
Definition: G4FastHit.hh:65
const G4Track * GetPrimaryTrack() const
Definition: G4FastTrack.hh:206
void SetTouchableHandle(const G4TouchableHandle &apValue)
void SetPosition(const G4ThreeVector &aValue)
void SetMomentumDirection(const G4ThreeVector &aValue)
Definition: G4Step.hh:62
G4StepPoint * GetPreStepPoint() const
const G4ThreeVector & GetMomentumDirection() const
Base class for the sensitive detector used within the fast simulation.
virtual G4bool ProcessHits(const G4FastHit *aHit, const G4FastTrack *aTrack, G4TouchableHistory *aROHistory)=0
G4bool Hit(const G4FastHit *aHit, const G4FastTrack *aTrack, G4TouchableHandle *aTouchable)
virtual G4bool CheckROVolume(G4Step *, G4TouchableHistory *&)
G4VReadOutGeometry * GetROgeometry() const