Geant4
11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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 "
G4FastHit.hh
"
31
#include "
G4FastTrack.hh
"
32
#include "
G4TouchableHistory.hh
"
33
#include "
G4VReadOutGeometry.hh
"
34
#include "
G4VSensitiveDetector.hh
"
35
36
/**
37
* @brief Base class for the sensitive detector used within the fast simulation
38
*
39
* Base class for a sensitive detector that allows to store hits created in the
40
* fast simulation models. It must me used in addition to inheritance from the
41
* usual base class `G4VSensitiveDetector` for processing of energy deposited
42
* in G4Step.
43
* ProcessHits(...) method must be implemented and describe how hits should be
44
* saved in the hit collections. It is invoked by Hit method which is public and
45
* can be called directly in the fast simulation model (if sensitive detector is
46
* known to the model), or via the helper class G4FastSimHitMaker that will
47
* locate appropriate volume and retrieve its sensitive detector.
48
* An extended example extended/parameterisations/Par03 demonstrates how to use
49
* G4VFastSimSensitiveDetector to deposit energy from fast simulation and
50
* compare it to the detailed simulation.
51
*
52
*/
53
54
class
G4VFastSimSensitiveDetector
55
{
56
public
:
57
virtual
~G4VFastSimSensitiveDetector
() =
default
;
58
59
/// Create a hit.
60
///
61
/// It checks if G4VSensitiveDetector is also used as a base class,
62
/// and takes into account the readout geometry, if it is defined.
63
/// User instruction on how to deposit energy needs to be implemented in
64
/// ProcessHits method.
65
/// @param[in] aHit Created hit (energy and position)
66
/// @param[in] aTrack Fast track with access to particle's track and
67
/// properties in envelope's local coordinates
68
/// @param[in] aTouchable Touchable with relevant transformations
69
inline
G4bool
Hit
(
const
G4FastHit
* aHit,
const
G4FastTrack
* aTrack,
70
G4TouchableHandle
* aTouchable)
71
{
72
G4bool
result =
true
;
73
auto
sensDet =
dynamic_cast<
G4VSensitiveDetector
*
>
(
this
);
74
if
(sensDet ==
nullptr
) {
75
G4Exception
(
"G4VFastSimSensitiveDetector::Hit()"
,
"InvalidSetup"
,
FatalException
,
76
"Sensitive detector needs also to inherit also from "
77
"G4VSensitiveDetector if full "
78
"simulation is used instead!"
);
79
}
80
if
(sensDet->isActive()) {
81
G4VReadOutGeometry
* ROgeometry = sensDet->GetROgeometry();
82
G4TouchableHistory
* ROhistory =
nullptr
;
83
84
if
(ROgeometry !=
nullptr
) {
85
// create fake pre-step point updating the touchable from read-out
86
// geometry.
87
G4Step
fakeStep;
88
const
G4Track
* currentTrack = aTrack->
GetPrimaryTrack
();
89
G4StepPoint
* tmpPoint = fakeStep.
GetPreStepPoint
();
90
tmpPoint->
SetTouchableHandle
(*aTouchable);
91
tmpPoint->
SetPosition
(aHit->
GetPosition
());
92
tmpPoint->
SetMomentumDirection
(currentTrack->
GetMomentumDirection
());
93
result = ROgeometry->
CheckROVolume
(&fakeStep, ROhistory);
94
}
95
else
{
96
ROhistory =
static_cast<
G4TouchableHistory
*
>
((*aTouchable)());
97
}
98
if
(result) result = ProcessHits(aHit, aTrack, ROhistory);
99
}
100
else
{
101
result =
false
;
102
}
103
return
result;
104
}
105
106
private
:
107
/// Describes how energy and position of deposits are inserted into the hits
108
/// collection. It is a private method and it will be invoked by Hit() method
109
/// of the base class once the readout geometry that may be associated to the
110
/// corresponding G4VSensitiveDetector is taken into account.
111
/// It needs to be implemented in the derived class.
112
/// @param[in] aHit Created hit (energy and position)
113
/// @param[in] aTrack Fast track with access to particle's track and
114
/// properties in envelope's local coordinates
115
/// @param[in] aROHistory Touchable history with relevant transformations
116
virtual
G4bool
ProcessHits(
const
G4FastHit
* aHit,
const
G4FastTrack
* aTrack,
117
G4TouchableHistory
* aROHistory) = 0;
118
};
119
#endif
/* G4VFASTSIMSENSITIVEDETECTOR_HH */
FatalException
@ FatalException
Definition
G4ExceptionSeverity.hh:67
G4Exception
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition
G4Exception.cc:59
G4FastHit.hh
G4FastTrack.hh
G4TouchableHandle
G4ReferenceCountedHandle< G4VTouchable > G4TouchableHandle
G4TouchableHandle is a type providing reference counting mechanism for any kind of touchable objects....
Definition
G4TouchableHandle.hh:53
G4TouchableHistory.hh
G4bool
bool G4bool
Definition
G4Types.hh:86
G4VReadOutGeometry.hh
G4VSensitiveDetector.hh
G4FastHit
Minimal hit created in the fast simulation.
Definition
G4FastHit.hh:48
G4FastHit::GetPosition
G4ThreeVector GetPosition() const
Get position.
Definition
G4FastHit.hh:63
G4FastTrack
Definition
G4FastTrack.hh:74
G4FastTrack::GetPrimaryTrack
const G4Track * GetPrimaryTrack() const
Definition
G4FastTrack.hh:193
G4StepPoint
Definition
G4StepPoint.hh:56
G4StepPoint::SetTouchableHandle
void SetTouchableHandle(const G4TouchableHandle &apValue)
G4StepPoint::SetPosition
void SetPosition(const G4ThreeVector &aValue)
G4StepPoint::SetMomentumDirection
void SetMomentumDirection(const G4ThreeVector &aValue)
G4Step
Definition
G4Step.hh:61
G4Step::GetPreStepPoint
G4StepPoint * GetPreStepPoint() const
G4TouchableHistory
G4TouchableHistory is an object representing a touchable detector element, and its history in the geo...
Definition
G4TouchableHistory.hh:107
G4Track
Definition
G4Track.hh:66
G4Track::GetMomentumDirection
const G4ThreeVector & GetMomentumDirection() const
G4VFastSimSensitiveDetector
Base class for the sensitive detector used within the fast simulation.
Definition
G4VFastSimSensitiveDetector.hh:55
G4VFastSimSensitiveDetector::~G4VFastSimSensitiveDetector
virtual ~G4VFastSimSensitiveDetector()=default
G4VFastSimSensitiveDetector::Hit
G4bool Hit(const G4FastHit *aHit, const G4FastTrack *aTrack, G4TouchableHandle *aTouchable)
Definition
G4VFastSimSensitiveDetector.hh:69
G4VReadOutGeometry
Definition
G4VReadOutGeometry.hh:40
G4VReadOutGeometry::CheckROVolume
virtual G4bool CheckROVolume(G4Step *, G4TouchableHistory *&)
Definition
G4VReadOutGeometry.cc:126
G4VSensitiveDetector
Definition
G4VSensitiveDetector.hh:51
geant4-v11.4.0
source
processes
parameterisation
include
G4VFastSimSensitiveDetector.hh
Generated by
1.16.1