Warning, /DD4hep/doc/usermanuals/DDG4/sections/Implementation.tex is written in an unsupported language. File is not indexed.
0001
0002 %=============================================================================
0003 \section{DDG4 Implementation}
0004 \label{sec:ddg4-user-manual-implementation}
0005 %=============================================================================
0006
0007 \noindent
0008 A basic design criteria of the a \DDG simulation application was to
0009 process any user defined hook provided by Geant4 as a series of algorithmic
0010 procedures, which could be implemented either using inheritance or by
0011 a callback mechanism registering functions fulfilling a given signature.
0012 Such sequences are provided for all actions mentioned in the list in
0013 Section~\ref{sec:ddg4-user-manual-geant4-interface} as well as for
0014 the callbacks to sensitive detectors.
0015
0016 \noindent
0017 The callback mechanism was introduced to allow for weak coupling between
0018 the various actions. For example could an action performing monitoring
0019 using histograms at the event level initialize or reset its histograms
0020 at the start/end of each run. To do so, clearly a callback at the
0021 start/end of a run would be necessary.
0022
0023 \noindent
0024 In the following sections a flexible and extensible interface to hooks
0025 of Geant4 is discussed starting with the description of the basic
0026 components \tts{Geant4Kernel} and \tts{Geant4Action} followed by the
0027 implementation of the relevant specializations.
0028 The specializations exposed are sequences of such actions,
0029 which also call registered objects.
0030 In later section the configuration and the combination of these components
0031 forming a functional simulation application is presented.
0032
0033 %=============================================================================
0034 \subsection{The Application Core Object: Geant4Kernel}
0035 \label{sec:ddg4-user-manual-implementation-geant4kernel}
0036 %=============================================================================
0037
0038 \noindent
0039 The kernel object is the central context of a \DDG simulation application and
0040 gives all clients access to the user hooks (see Figure~\ref{fig:ddg4-geant4-kernel}).
0041 All Geant4 callback structures are exposed so that clients can easily
0042 objects implementing the required interface or register callbacks with the
0043 correct signature. Each of these action sequences is connected to an instance
0044 of a Geant4 provided callback structure as it is shown in
0045 Figure~\ref{fig:ddg4-g4runmanager-anatomy}.
0046 \begin{figure}[h]
0047 \begin{center}
0048 \includegraphics[height=65mm] {DDG4-Geant4Kernel}
0049 \caption{The main application object gives access to all sequencing actions
0050 in a \DDG4 application. Sequence actions are only container of user actions
0051 calling one user action after the other. Optionally single callbacks may
0052 be registered to a user action.}
0053 \label{fig:ddg4-geant4-kernel}
0054 \end{center}
0055 \end{figure}
0056
0057 %=============================================================================
0058 \subsection{Action Sequences}
0059 \label{sec:ddg4-user-manual-implementation-geant4action-sequences}
0060 %=============================================================================
0061
0062 \noindent
0063 As shown in
0064
0065 %=============================================================================
0066 \subsection{The Base Class of DDG4 Actions: Geant4Action}
0067 \label{sec:ddg4-user-manual-implementation-geant4action-base}
0068 %=============================================================================
0069
0070 \noindent
0071 The class \tts{Geant4Action} is a common component interface providing
0072 the basic interface to the framework to
0073 \begin{itemize}\itemcompact
0074 \item configure the component using a property mechanism
0075 \item provide an appropriate interface to Geant4 interactivity. The interactivity
0076 included a generic way to change and access properties from the Geant4 UI
0077 prompt as well as executing registered commands.
0078 \item As shown in Figure~\ref{fig:ddg4-implementation-geant4-action}, the
0079 base class also provides to its sub-class a reference to the \tts{Geant4Kernel}
0080 objects through the \tts{Geant4Context}.
0081 \end{itemize}
0082 The \tts{Geant4Action} is a named entity and can be uniquely identified within
0083 a sequence attached to one Geant4 user callback.
0084 %=============================================================================
0085 \begin{figure}[h]
0086 \begin{center}
0087 \includegraphics[height=30mm] {DDG4-Geant4Action}
0088 \caption{The design of the common base class \tts{Geant4Action}.}
0089 \label{fig:ddg4-implementation-geant4-action}
0090 \end{center}
0091 \end{figure}
0092
0093 \noindent
0094 \DDG knows two types of actions: global actions and anonymous actions.
0095 Global actions are accessible externally from the \tts{Geant4Kernel} instance.
0096 Global actions are also re-usable and hence may be contribute to several
0097 action sequences (see the following chapters for details). Global actions
0098 are uniquely identified by their name.
0099 Anonymous actions are known only within one sequence and normally
0100 are not shared between sequences.
0101
0102 %=============================================================================
0103 \subsubsection{The Properties of \bold{Geant4Action} Instances}
0104 \label{sec:ddg4-implementation-geant4-action-properties}
0105 %=============================================================================
0106
0107 \noindent
0108 Nearly any subclass of a \tts{Geant4Action} needs a flexible configuration
0109 in order to be reused, modified etc. The implementation of the mechanism
0110 uses a very flexible value conversion mechanism using \tts{boost::spirit},
0111 which support also conversions between unrelated types provided a dictionary
0112 is present.
0113
0114 \noindent
0115 Properties are supposed to be member variables of a given action object.
0116 To publish a property it needs to be declared in the constructor as shown here:
0117 \begin{unnumberedcode}
0118 declareProperty("OutputLevel", m_outputLevel = INFO);
0119 declareProperty("Control", m_needsControl = false);
0120 \end{unnumberedcode}
0121 The internal setup of the \tts{Geant4Action} objects then ensure that
0122 all declared properties will be set after the object construction to the
0123 values set in the setup file.
0124
0125 \noindent
0126 \bold{Note:} Because the values can only be set \bold{after} the object
0127 was constructed, the actual values may not be used in the constructor
0128 of any base or sub-class.
0129
0130 %=============================================================================
0131 \subsection{Geant4 Action Sequences}
0132 \label{sec:ddg4-user-manual-implementation-geant4action-sequences}
0133 %=============================================================================
0134
0135 \noindent
0136 All Geant4 user hooks are realized as action sequences. As shown in
0137 Figure~\ref{fig:ddg4-geant4-kernel} these sequences are accessible to the user,
0138 who may attach specialized actions to the different action sequences. This
0139 allows a flexible handing of specialized user actions e.g. to dynamically
0140 add monitoring actions filling histograms or to implement alternative hit
0141 creation mechanism in a sensitive detector for detailed detector studies.
0142 Figure~\ref{fig:ddg4-implementation-sequence-calls} shows the schematic
0143 call structure of an example {\tt{Geant4TrackingActionSequence}}:\\
0144 \begin{figure}[h]
0145 \begin{center}
0146 \includegraphics[width=150mm] {DDG4-TrackingActionCalls}
0147 \caption{The design of the tracking action sequence. Specialized
0148 tracking action objects inherit from the \tts{Geant4TrackingAction}
0149 object and must be attached to the sequence.}
0150 \label{fig:ddg4-implementation-sequence-calls}
0151 \end{center}
0152 \end{figure}
0153
0154 \noindent
0155 Geant4 calls the function from the virtual interface (\tts{G4UserTrackingAction}),
0156 which is realised by the \tts{Geant4UserTrackingAction} with the single purpose to
0157 propagate the call to the action sequence, which then calls all registered clients
0158 of type \tts{Geant4TrackingAction}.
0159
0160 \noindent
0161 The main action sequences have a fixed name. These are
0162 \begin{itemize}
0163
0164 \item The \bold{RunAction} attached to the \tts{G4UserRunAction}, implemented
0165 by the \tts{Geant4RunActionSequence} class and is called at the start and the end of
0166 every run (beamOn). Members of the \tts{Geant4RunActionSequence} are of type
0167 \tts{Geant4RunAction} and receive the callbacks by overloading the two routines:
0168 \begin{unnumberedcode}
0169 /// begin-of-run callback
0170 virtual void begin(const G4Run* run);
0171 /// End-of-run callback
0172 virtual void end(const G4Run* run);
0173 \end{unnumberedcode}
0174 or register a callback with the signature {\tts{void (T::*)(const G4Run*)}}
0175 either to receive begin-of-run or end-or-calls using the methods:
0176 \begin{unnumberedcode}
0177 /// Register begin-of-run callback. Types Q and T must be polymorph!
0178 template <typename Q, typename T> void callAtBegin(Q* p, void (T::*f)(const G4Run*));
0179 /// Register end-of-run callback. Types Q and T must be polymorph!
0180 template <typename Q, typename T> void callAtEnd(Q* p, void (T::*f)(const G4Run*));
0181 \end{unnumberedcode}
0182 of the \tts{Geant4RunActionSequence} from the \tts{Geant4Context} object.
0183
0184
0185 \item The \bold{EventAction} attached to the \tts{G4UserEventAction}, implemented
0186 by the \tts{EventActionSequence} class and is called at the start and the end of
0187 every event. Members of the \tts{Geant4EventActionSequence} are of type
0188 \tts{Geant4EventAction} and receive the callbacks by overloading the two routines:
0189 \begin{unnumberedcode}
0190 /// Begin-of-event callback
0191 virtual void begin(const G4Event* event);
0192 /// End-of-event callback
0193 virtual void end(const G4Event* event);
0194 \end{unnumberedcode}
0195 or register a callback with the signature {\tts{void (T::*)(const G4Event*)}}
0196 either to receive begin-of-run or end-or-calls using the methods:
0197 \begin{unnumberedcode}
0198 /// Register begin-of-event callback
0199 template <typename Q, typename T> void callAtBegin(Q* p, void (T::*f)(const G4Event*));
0200 /// Register end-of-event callback
0201 template <typename Q, typename T> void callAtEnd(Q* p, void (T::*f)(const G4Event*));
0202 \end{unnumberedcode}
0203 of the \tts{Geant4EventActionSequence} from the \tts{Geant4Context} object.
0204
0205
0206 \item The \bold{GeneratorAction} attached to the \tts{G4VUserPrimaryGeneratorAction}, implemented
0207 by the \tts{Geant4GeneratorActionSequence} class and is called at the start of
0208 every event and provided all initial tracks from the Monte-Carlo generator.
0209 Members of the \tts{Geant4GeneratorActionSequence} are of type
0210 \tts{Geant4EventAction} and receive the callbacks by overloading the member function:
0211 \begin{unnumberedcode}
0212 /// Callback to generate primary particles
0213 virtual void operator()(G4Event* event);
0214 \end{unnumberedcode}
0215 or register a callback with the signature {\tts{void (T::*)(G4Event*)}}
0216 to receive calls using the method:
0217 \begin{unnumberedcode}
0218 /// Register primary particle generation callback.
0219 template <typename Q, typename T> void call(Q* p, void (T::*f)(G4Event*));
0220 \end{unnumberedcode}
0221 of the \tts{Geant4GeneratorActionSequence} from the \tts{Geant4Context} object.
0222
0223 \end{itemize}
0224 \begin{figure}[t]
0225 \begin{center}
0226 \includegraphics[width=160mm] {DDG4-TrackingAction}
0227 \caption{The design of the tracking action sequence. Specialized
0228 tracking action objects inherit from the \tts{Geant4TrackingAction}
0229 object and must be attached to the sequence.}
0230 \label{fig:ddg4-implementation-tracking-action}
0231 \end{center}
0232 \end{figure}
0233
0234 \begin{itemize}
0235 \item The \bold{TrackingAction} attached to the \tts{G4UserTrackingAction},
0236 implemented by the \tts{Geant4-} \tts{Tracking\-Action\-Sequence} class
0237 and is called at the start and the end of tracking one single particle
0238 trace through the material of the detector.
0239 Members of the \tts{Geant4\-Tracking\-ActionSequence} are of type
0240 \tts{Geant4TrackingAction} and receive the callbacks by overloading the member function:
0241 \begin{unnumberedcode}
0242 /// Pre-tracking action callback
0243 virtual void begin(const G4Track* trk);
0244 /// Post-tracking action callback
0245 virtual void end(const G4Track* trk);
0246 \end{unnumberedcode}
0247 or register a callback with the signature {\tts{void (T::*)(const G4Step*, G4SteppingManager*)}}
0248 to receive calls using the method:
0249 \begin{unnumberedcode}
0250 /// Register Pre-track action callback
0251 template <typename Q, typename T> void callAtBegin(Q* p, void (T::*f)(const G4Track*));
0252 /// Register Post-track action callback
0253 template <typename Q, typename T> void callAtEnd(Q* p, void (T::*f)(const G4Track*));
0254 \end{unnumberedcode}
0255 Figure~\ref{fig:ddg4-implementation-tracking-action} show as an example
0256 the design (class-diagram) of the \tts{Geant4TrackingAction}.
0257
0258
0259 \item The \bold{SteppingAction} attached to the \tts{G4UserSteppingAction}, implemented
0260 by the \tts{Geant4-} \tts{SteppingActionSequence} class and is called for each
0261 step when tracking a particle.
0262 Members of the \tts{Geant4SteppingActionSequence} are of type
0263 \tts{Geant4SteppingAction} and receive the callbacks by overloading the member function:
0264 \begin{unnumberedcode}
0265 /// User stepping callback
0266 virtual void operator()(const G4Step* step, G4SteppingManager* mgr);
0267 \end{unnumberedcode}
0268 or register a callback with the signature {\tts{void (T::*)(const G4Step*, G4SteppingManager*)}}
0269 to receive calls using the method:
0270 \begin{unnumberedcode}
0271 /// Register stepping action callback.
0272 template <typename Q, typename T> void call(Q* p, void (T::*f)(const G4Step*,
0273 G4SteppingManager*));
0274 \end{unnumberedcode}
0275
0276
0277 \item The \bold{StackingAction} attached to the
0278 {\tts{G4UserStackingAction}}, implemented by the \tts{Geant4-}\\
0279 \tts{StackingActionSequence} class.
0280 Members of the \tts{Geant4StackingActionSequence} are of type\\
0281 \detdesc{html/class_d_d4hep_1_1_simulation_1_1_geant4_stacking_action.html}
0282 {\tts{Geant4StackingAction}} and receive the callbacks by overloading the member functions:
0283 \begin{unnumberedcode}
0284 /// New-stage callback
0285 virtual void newStage();
0286 /// Preparation callback
0287 virtual void prepare();
0288 \end{unnumberedcode}
0289 or register a callback with the signature {\tts{void (T::*)()}}
0290 to receive calls using the method:
0291 \begin{unnumberedcode}
0292 /// Register begin-of-event callback. Types Q and T must be polymorph!
0293 template <typename T> void callAtNewStage(T* p, void (T::*f)());
0294 /// Register end-of-event callback. Types Q and T must be polymorph!
0295 template <typename T> void callAtPrepare(T* p, void (T::*f)());
0296 \end{unnumberedcode}
0297 \end{itemize}
0298
0299 \noindent
0300 All sequence types support the method \tts{void adopt(T* member\_reference)}
0301 to add the members. Once adopted, the sequence takes ownership and manages
0302 the member. The design of all sequences is very similar.
0303
0304 %=============================================================================
0305 \subsection{Sensitive Detectors}
0306 \label{sec:ddg4-user-manual-geant4sensitivedetectors}
0307 %=============================================================================
0308
0309 \noindent
0310 Sensitive detectors are associated by the detector designers to all active
0311 materials, which would produce a signal which can be read out. In Geant4 this concept
0312 is realized by using a base class \tts{G4VSensitiveDetector}.
0313 The mandate of a sensitive detector is the construction of hit objects
0314 using information from steps along a particle track.
0315 The \tts{G4VSensitiveDetector} receives
0316 a callback at the begin and the end of the event processing and at each step
0317 inside the active material whenever an energy deposition occurred.
0318
0319 \begin{figure}[t]
0320 \begin{center}
0321 \includegraphics[height=110mm] {DDG4-Sensitive-detector}
0322 \caption{The sensitive detector design. The actual energy deposits are
0323 collected in user defined subclasses of the \tts{Geant4Sensitive}.
0324 Here, as an example possible actions called \tts{TrackerHitCollector},
0325 \tts{TrackerDetailedHitCollector} and \tts{TrackerHitMonitor} are shown.}
0326 \label{fig:ddg4-implementation-sensitive-detector}
0327 \end{center}
0328 \end{figure}
0329
0330 \noindent
0331 The sensitive actions do not necessarily deal only the collection of energy
0332 deposits, but could also be used to simply monitor the performance of the
0333 active element e.g. by producing histograms of the absolute value or the
0334 spacial distribution of the depositions.
0335
0336 \noindent
0337 Within \DDG the concept of sensitive detectors is implemented as a
0338 configurable action sequence of type
0339 \detdesc{html/class_d_d4hep_1_1_simulation_1_1_geant4_sens_det_action_sequence.html}
0340 {\tts{Geant4SensDetActionSequence}}
0341 calling members of the type
0342 \detdesc{html/struct_d_d4hep_1_1_simulation_1_1_geant4_sensitive.html}
0343 {\tts{Geant4Sensitive}} as shown in
0344 Figure~\ref{fig:ddg4-implementation-sensitive-detector}. The actual processing
0345 part of such a sensitive action is only called if the and of a set of
0346 required filters of type \tts{Geant4Filter} is positive (see also
0347 section~\ref{sec:ddg4-implementation-sensitive-detector-filters}). No filter
0348 is also positive. Possible filters are e.g. particle filters, which ignore the
0349 sensitive detector action if the particle is a \tts{geantino} or if the
0350 energy deposit is below a given threshold.
0351
0352 \noindent
0353 Objects of type \tts{Geant4Sensitive} receive the callbacks by overloading the
0354 member function:
0355 \begin{unnumberedcode}
0356 /// Method invoked at the beginning of each event.
0357 virtual void begin(G4HCofThisEvent* hce);
0358 /// Method invoked at the end of each event.
0359 virtual void end(G4HCofThisEvent* hce);
0360 /// Method for generating hit(s) using the information of G4Step object.
0361 virtual bool process(G4Step* step, G4TouchableHistory* history);
0362 /// Method invoked if the event was aborted.
0363 virtual void clear(G4HCofThisEvent* hce);
0364 \end{unnumberedcode}
0365 or register a callback with the signature {\tts{void (T::*)(G4HCofThisEvent*)}}
0366 respectively {\tts{void (T::*)(G4Step*, G4TouchableHistory*)}}
0367 to receive callbacks using the methods:
0368 \begin{unnumberedcode}
0369 /// Register begin-of-event callback
0370 template <typename T> void callAtBegin(T* p, void (T::*f)(G4HCofThisEvent*));
0371 /// Register end-of-event callback
0372 template <typename T> void callAtEnd(T* p, void (T::*f)(G4HCofThisEvent*));
0373 /// Register process-hit callback
0374 template <typename T> void callAtProcess(T* p, void (T::*f)(G4Step*, G4TouchableHistory*));
0375 /// Register clear callback
0376 template <typename T> void callAtClear(T* p, void (T::*f)(G4HCofThisEvent*));
0377 \end{unnumberedcode}
0378 Please refer to the Geant4 Applications manual from the Geant4 web page for
0379 further details about the concept of sensitive detectors.
0380
0381 %=============================================================================
0382 \subsubsection{Helpers of Sensitive Detectors: The Geant4VolumeManager}
0383 \label{sec:ddg4-user-manual-geant4volumemanager}%=============================================================================
0384
0385 \noindent
0386 Sooner or later, when a hit is created in a sensitive placed volume, the
0387 hit must be associated with this volume. For this purpose \DDhep provides
0388 the concept of the \tts{VolumeManager}, which identifies placed volumes uniquely
0389 by a 64-bit identifier, the $CellID$. This mechanism allows to quickly
0390 retrieve a given volume given the hit data containing the $CellID$.
0391 The $CellID$ is a very compressed representation for any element in the
0392 hierarchy of placed volumes to the sensitive volume in question.
0393
0394 \noindent
0395 During the simulation the reverse mechanism must be applied: Geant4 provides
0396 the hierarchy of \tts{G4PhysicalVolumes} to the hit location and the local coordinates
0397 of the hit within the sensitive volume. Hence to determine the volume identifier
0398 is essential to store hits so that they can be later accessed and processed efficiently.
0399 This mechanism is provided by the \tts{Geant4VolumeManager}. Clients typically do not
0400 interact with this object, any access necessary is provided by the
0401 \tts{Geant4Sensitive} action:
0402 \begin{unnumberedcode}
0403 /// Method for generating hit(s) using the information of G4Step object.
0404 bool MySensitiveAction:process(G4Step* step,G4TouchableHistory* /*hist*/ ) {
0405 ...
0406 Hit* hit = new Hit();
0407 // *** Retrieve the cellID ***
0408 hit->cellID = cellID(step);
0409 ...
0410 }
0411 \end{unnumberedcode}
0412 The call is realized using a member function provided by the
0413 \tts{Geant4Sensitive} action:
0414 \begin{unnumberedcode}
0415 /// Returns the cellID of the sensitive volume corresponding to the step
0416 /** The CellID is the VolumeID + the local coordinates of the sensitive area.
0417 * Calculated by combining the VolIDS of the complete geometry path (Geant4TouchableHistory)
0418 * from the current sensitive volume to the world volume
0419 */
0420 long long int cellID(G4Step* step);
0421 \end{unnumberedcode}
0422
0423 \noindent
0424 \bold{Note:}\\
0425 The \tts{Geant4VolumeManager} functionality is not for free! It requires that
0426
0427
0428 \noindent
0429 -- match Geant4 volume with TGeo volume
0430
0431 %=============================================================================
0432 \subsubsection{DDG4 Intrinsic Sensitive Detectors}
0433 %=============================================================================
0434 \noindent
0435 Currently there are two generic sensitive detectors implemented in DDG4:
0436 \begin{itemize}\itemcompact
0437 \item The \tts{Geant4TrackerAction}, which may be used to handle tracking devices.
0438 This sensitive detector produces one hit for every energy deposition of Geant4
0439 i.e. for every callback to
0440 \begin{unnumberedcode}
0441 /// Method for generating hit(s) using the information of G4Step object.
0442 virtual bool process(G4Step* step, G4TouchableHistory* history);
0443 \end{unnumberedcode}
0444 See the implementation file
0445 \detdesc{html/_geant4_s_d_actions_8cpp_source.html}{DDG4/plugins/Geant4SDAction.cpp}
0446 for details. The produced hits are of type
0447 \detdesc{html/_geant4_data_8h_source.html}{Geant4Tracker::Hit}.
0448
0449 \item The \tts{Geant4CalorimeterAction}, which may be used to handle
0450 generic calorimeter like devices.
0451 This sensitive detector produces at most one hit for every cell in the calorimeter.
0452 If several tracks contribute to the energy deposit of this cell, the contributions
0453 are added up.
0454 See the implementation file
0455 \detdesc{html/_geant4_s_d_actions_8cpp_source.html}{DDG4/plugins/Geant4SDAction.cpp}
0456 for details. The produced hits are of type
0457 \detdesc{html/_geant4_data_8h_source.html}{Geant4Calorimeter::Hit}.
0458 propagate the MC truth information with respect to each track kept in the
0459 particle record.
0460 \end{itemize}
0461
0462 \noindent
0463 Both sensitive detectors use the \tts{Geant4VolumeManager} discussed in
0464 section~\ref{sec:ddg4-user-manual-geant4volumemanager} to identify the sensitive elements.
0465
0466 \noindent
0467 \bold{PLEASE NOTE:}\\
0468 The above palette of generic sensitive detectors only contains two very
0469 often used implementations. We hope, that this palette over time grows from
0470 external contributions of other generic sensitive detectors. We would be happy
0471 to extend this palette with other generic implementations. One example would
0472 be the handling of the simulation response for optical detectors like RICH-Cerenkov
0473 detectors.
0474
0475 %=============================================================================
0476 \subsubsection{Sensitive Detector Filters}
0477 \label{sec:ddg4-implementation-sensitive-detector-filters}
0478 %=============================================================================
0479
0480 \noindent
0481 The concept of filters allows to build more flexible sensitive detectors by
0482 restricting the hit processing of a given instance of a sensitive action.
0483
0484 \begin{itemize}\itemcompact
0485 \item Examples would be to demand a given particle type before a sensitive action is
0486 invoked: a sensitive action dealing with optical photons (RICH detectors, etc),
0487 would e.g. not be interested in energy depositions of other particles.
0488 A filter object restricting the particle type to optical photons would
0489 be appropriate.
0490 \item Another example would be to implement a special action instance, which would
0491 be only called if the filter requires a minimum energy deposit.
0492 \end{itemize}
0493 There are plenty of possible applications, hence we would like
0494 to introduce this feature here.
0495
0496 \noindent
0497 Filters are called by Geant4 before the
0498 hit processing in the sensitive detectors start. The global filters
0499 may be shared between many sensitive detectors. Alternatively filters
0500 may be directly attached to the sensitive detector in question.
0501 Attributes are directly passed as properties to the filter action.
0502
0503 \noindent
0504 Technically do \tts{Geant4Filter} objects inherit from the base class
0505 \tts{Geant4Filter} (see Figure~\ref{fig:ddg4-implementation-sensitive-detector-filters}.
0506 Any filter inherits from the common base class \tts{Geant4Filter}, then
0507 several specializations may be configured like filters to select/reject
0508 particles, to specify the minimal energy deposit to be processed etc.
0509 A sensitive detector is called if the filter callback with the signature
0510 returns a true result:
0511 \begin{unnumberedcode}
0512 /// Filter action. Return true if hits should be processed
0513 virtual bool operator()(const G4Step* step) const;
0514 \end{unnumberedcode}
0515 \begin{figure}[h]
0516 \begin{center}
0517 \includegraphics[height=65mm] {DDG4-SensitiveFilterClasses}
0518 \caption{The sensitive detector filters design. The shown class
0519 diagram is actually implemented.}
0520 \label{fig:ddg4-implementation-sensitive-detector-filters}
0521 \end{center}
0522 \end{figure}
0523
0524 \newpage
0525
0526 %=============================================================================
0527 \subsection{The Geant4 Physics List}
0528 \label{sec:ddg4-implementation-physics-list}
0529 %=============================================================================
0530 \noindent
0531 Geant4 provides the base class \tts{G4VUserPhysicsList}, which allows users
0532 to implement customized physics according to the studies to be made.
0533 Any user defined physics list must provide this interface. DDG4 provides such an interface
0534 through the ROOT plugin mechanism using the class \tts{G4VModularPhysicsList}.
0535 The flexibility of \DDG allows for several possibilities to setup the Geant4
0536 physics list. Instead of explicitly coding the physics list, \DDG foresees the
0537 usage of the plugin mechanism to instantiate the necessary calls to Geant4 in a
0538 sequence of actions:
0539 \begin{itemize}
0540 \item The \bold{physics list} is realized as a sequence of actions of type
0541 \detdesc{html/class_d_d4hep_1_1_simulation_1_1_geant4_physics_list_action_sequence.html}
0542 {\tts{Geant4PhysicsListActionSequence}}.
0543 Members of the \detdesc{html/class_d_d4hep_1_1_simulation_1_1_geant4_physics_list_action_sequence.html}
0544 {\tts{Geant4PhysicsListActionSequence}} are of type
0545 \detdesc{html/class_d_d4hep_1_1_simulation_1_1_geant4_physics_list.html}
0546 {\tts{Geant4PhysicsList}} and receive the callbacks by overloading
0547 the member functions:
0548 \begin{unnumberedcode}
0549 /// Callback to construct the physics constructors
0550 virtual void constructProcess(Geant4UserPhysics* interface);
0551 /// constructParticle callback
0552 virtual void constructParticles(Geant4UserPhysics* particle);
0553 /// constructPhysics callback
0554 virtual void constructPhysics(Geant4UserPhysics* physics);
0555 \end{unnumberedcode}
0556 or register a callback with the signature {\tts{void (T::*)(Geant4UserPhysics*)}}
0557 to receive calls using the method:
0558 \begin{unnumberedcode}
0559 /// Register process construction callback t
0560 template <typename Q, typename T> void constructProcess(Q* p, void (T::*f)(Geant4UserPhysics*));
0561 /// Register particle construction callback
0562 template <typename Q, typename T> void constructParticle(Q* p, void (T::*f)(Geant4UserPhysics*));
0563 \end{unnumberedcode}
0564 The argument of type \detdesc{html/class_d_d4hep_1_1_simulation_1_1_geant4_user_physics.html}
0565 {\tts{Geant4UserPhysics}} provides a basic interface to the original
0566 \tts{G4VModular}- \tts{PhysicsList}, which allows to register physics constructors etc.
0567
0568 \item In most of the cases the above approach is an overkill and often even too flexible.
0569 Hence, alternatively, the physics list may consist of a single entry of type
0570 \detdesc{html/class_d_d4hep_1_1_simulation_1_1_geant4_physics_list.html}
0571 {\tts{Geant4PhysicsList}}.
0572 \end{itemize}
0573
0574 \noindent
0575 The basic implementation of the \tts{Geant4PhysicsList} supports the usage of various
0576 \begin{itemize}\itemcompact
0577 \item \detdesc{html/_geant4_particles_8cpp_source.html}{particle constructors},
0578 such as single particle constructors like
0579 \tts{G4Gamma} or \tts{G4Proton}, or whole particle groups like
0580 \tts{G4BosonConstructor} or \tts{G4IonConstrutor},
0581 \item \detdesc{html/_geant4_processes_8cpp_source.html}{physics process constructors},
0582 such as e.g. \tts{G4GammaConversion},
0583 \tts{G4PhotoElectricEffect} or\\ \tts{G4ComptonScattering},
0584 \item \detdesc{html/_geant4_physics_constructors_8cpp_source.html}{physics constructors}
0585 combining particles and the corresponding
0586 interactions, such as\\ e.g. \tts{G4OpticalPhysics},
0587 \tts{HadronPhysicsLHEP} or \tts{G4HadronElasticPhysics} and
0588 \item \detdesc{html/_geant4_particles_8cpp_source.html}{predefined Geant4 physics lists},
0589 such as \tts{FTFP\_BERT},
0590 \tts{CHIPS} or \tts{QGSP\_INCLXX}. This option is triggered by the
0591 content of the string property "extends" of the \tts{Geant4Kernel::physicsList()} action.
0592 \end{itemize}
0593 These constructors are internally connected to the above callbacks to register themselves.
0594 The constructors are instantiated using the ROOT plugin mechanism.
0595
0596 \noindent
0597 The description of the above interface is only for completeness. The basic idea is,
0598 that the physics list with its particle and physics constructors is configured
0599 entirely data driven using the setup mechanism described in the following
0600 chapter. However, DDG4 is not limited to the data driven approach. Specialized
0601 physics lists may be supplied, but there should be no need.
0602 New physics lists could always be composed by actually providing new physics
0603 constructors and actually publishing these using the factory methods:
0604 \begin{code}
0605 // Framework include files
0606 #include "DDG4/Factories.h"
0607
0608 #include "My_Very_Own_Physics_Constructor.h"
0609 DECLARE_GEANT4_PHYSICS(My_Very_Own_Physics_Constructor)
0610 \end{code}
0611 where \tts{My\_Very\_Own\_Physics\_Constructor} represents a sub-class of
0612 \tts{G4VPhysicsConstructor}.
0613
0614 \newpage
0615 %=============================================================================
0616 \subsection{The Support of the Geant4 UI: \tts{Geant4UIMessenger}}
0617 \label{sec:ddg4-user-manual-geant4action-base}
0618 %=============================================================================
0619
0620 \noindent
0621 The support of interactivity in Geant4 is mandatory to debug detector
0622 setups in small steps. The Geant4 toolkit did provide for this reason
0623 a machinery of UI commands.
0624 \begin{figure}[h]
0625 \begin{center}
0626 \includegraphics[height=70mm] {DDG4-UIMessenger}
0627 \caption{The design of the \tts{Geant4UIMessenger} class responsible for
0628 the interaction between the user and the components of \DDG and Geant4.}
0629 \label{fig:ddg4-tracking-action}
0630 \end{center}
0631 \end{figure}
0632
0633 \noindent
0634 The UI control is enabled, as soon as the property "Control" (boolean) is set to true.
0635 Be default all properties of the action are exported.
0636 Similar to the callback mechanism described above it is also feasible to
0637 register any object callback invoking a method of a \tts{Geant4Action}-subclass.
0638
0639 \noindent
0640 The following (shortened) screen dump illustrates the usage of the
0641 generic interface any Geant4Action offers:
0642 \begin{unnumberedcode}
0643 Idle> ls
0644 Command directory path : /
0645 Sub-directories :
0646 /control/ UI control commands.
0647 /units/ Available units.
0648 /process/ Process Table control commands.
0649 /ddg4/ Control for all named Geant4 actions
0650 ...
0651 Idle> cd /ddg4
0652 Idle> ls
0653 ...
0654 Control for all named Geant4 actions
0655
0656 Sub-directories :
0657 /ddg4/RunInit/ Control hierarchy for Geant4 action:RunInit
0658 /ddg4/RunAction/ Control hierarchy for Geant4 action:RunAction
0659 /ddg4/EventAction/ Control hierarchy for Geant4 action:EventAction
0660 /ddg4/GeneratorAction/ Control hierarchy for Geant4 action:GeneratorAction
0661 /ddg4/LCIO1/ Control hierarchy for Geant4 action:LCIO1
0662 /ddg4/Smear1/ Control hierarchy for Geant4 action:Smear1
0663 /ddg4/PrimaryHandler/ Control hierarchy for Geant4 action:PrimaryHandler
0664 /ddg4/TrackingAction/ Control hierarchy for Geant4 action:TrackingAction
0665 /ddg4/SteppingAction/ Control hierarchy for Geant4 action:SteppingAction
0666 /ddg4/ParticleHandler/ Control hierarchy for Geant4 action:ParticleHandler
0667 /ddg4/UserParticleHandler/ Control hierarchy for Geant4 action:UserParticleHandler
0668 ...
0669 Idle> ls Smear1
0670 Command directory path : /ddg4/Smear1/
0671 ...
0672 Commands :
0673 show * Show all properties of Geant4 component:Smear1
0674 Control * Property item of type bool
0675 Mask * Property item of type int
0676 Name * Property item of type std::string
0677 Offset * Property item of type ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >
0678 OutputLevel * Property item of type int
0679 Sigma * Property item of type ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >
0680 name * Property item of type std::string
0681 Idle> Smear1/show
0682 PropertyManager: Property Control = True
0683 PropertyManager: Property Mask = 1
0684 PropertyManager: Property Name = 'Smear1'
0685 PropertyManager: Property Offset = ( -20 , -10 , -10 , 0 )
0686 PropertyManager: Property OutputLevel = 4
0687 PropertyManager: Property Sigma = ( 12 , 8 , 8 , 0 )
0688 PropertyManager: Property name = 'Smear1'
0689
0690 Idle> Smear1/Offset (200*mm, -3*mm, 15*mm, 10*ns)
0691 Geant4UIMessenger: +++ Smear1> Setting property value Offset = (200*mm, -3*mm, 15*mm, 10*ns)
0692 native:( 200 , -3 , 15 , 10 ).
0693 Idle> Smear1/show
0694 ...
0695 PropertyManager: Property Offset = ( 200 , -3 , 15 , 10 )
0696
0697 \end{unnumberedcode}
0698
0699 \newpage