Warning, /DD4hep/doc/usermanuals/DDG4/sections/HighLevel.tex is written in an unsupported language. File is not indexed.
0001
0002 %=============================================================================
0003 \section{Higher Level Components}
0004 \label{sec:ddg4-implementation-higher-level-components}
0005 %=============================================================================
0006 \noindent
0007 Layered components, which base on the general framework implement higher
0008 level functionality such as the handling of Monte-Carlo truth associations
0009 between simulated energy deposits and the corresponding particles or the
0010 generic handling of input to the simulation.
0011
0012 \noindent
0013 To generalize such common behavior it is mandatory that the participating
0014 components collaborate and understand the data components they commonly access.
0015 The data model is shown in Figure~\ref{fig:ddg4-event-data-model}.
0016 \begin{figure}[t]
0017 \begin{center}
0018 \includegraphics[width=120mm] {DDG4_event_data_model}
0019 \caption{The DDG4 event data model.}
0020 \label{fig:ddg4-event-data-model}
0021 \end{center}
0022 \end{figure}
0023
0024 \noindent
0025 {\bf{Please note}}, that this data model is by no means to be made persistent
0026 and used for physics user analysis. This model is optimized to support
0027 the simulation process and the necessary user actions to handle MC truth,
0028 to easily and relatively fast look up and modify parent-daughter
0029 relationships etc. This choice is based on the assumption, that the
0030 additional overhead to convert particles at the input/output
0031 stage is small compared to the actual resource consumption of Geant4
0032 to simulate the proper detector response.
0033 On the other hand this choice has numerous advantages:
0034 \begin{itemize}\itemcompact
0035 \item Accepting the fact to convert input records allows to adapt
0036 DDG4 in a simple and flexible manner to any input format. Currently
0037 supported is the input from raw {\tts{LCIO}} files, {\tts{StdHep}}
0038 records using {\tts{LCIO}} and {\tts{ASCII}} files using the
0039 {\tts{HEPEvt}} format.
0040 \item Similarly as for the input stage, also the output format
0041 can be freely chosen by the clients.
0042 \item No assumptions was made concerning the structure to store
0043 information from energy deposits. Any information extract produced
0044 by the sensitive actions can be adapted provided at the output
0045 stage the proper conversion mechanism is present. The sensitive
0046 detectors provided by DDG4 are {\bf{optional only and by no means mandatory}}.
0047 User defined classes may be provided at any time. Appropriate tools
0048 to extract MC truth information is provided at the output stage.
0049 \item The modular approach of the action sequences described
0050 in~\ref{sec:ddg4-user-manual-implementation-geant4action-sequences}
0051 allows to easily extend the generation sequence to handle multiple
0052 simultaneous interactions, event overlay or spillover response
0053 very easily~\footnote{The handling of spillover is only possible
0054 if during the digitization step the correct signal shape corresponding
0055 to the shift of signal creation is taken into account.}
0056 \end{itemize}
0057
0058 \noindent
0059 In section~\ref{sec:ddg4-implementation-input-handling} the generic mechanism
0060 of input data handling is described. \\
0061 In section~\ref{sec:ddg4-implementation-particle-handling} the MC truth
0062 handling is discussed. \\
0063 In section~\ref{sec:ddg4-implementation-output-handling} we describe the
0064 output mechanism.
0065 \newpage
0066
0067 %=============================================================================
0068 \subsection{Input Data Handling}
0069 \label{sec:ddg4-implementation-input-handling}
0070 %=============================================================================
0071 \begin{figure}[t]
0072 \begin{center}
0073 \includegraphics[width=160mm] {DDG4_input_stage}
0074 \caption{The generic handling of input sources to DDG4.}
0075 \label{fig:ddg4-input-stage}
0076 \end{center}
0077 \end{figure}
0078
0079 \noindent
0080 Input handling has several stages and uses several modules:
0081 \begin{itemize}\itemcompact
0082 \item First the data structures \tts{Geant4PrimaryEvent},
0083 \tts{Geant4PrimaryInteraction} and \tts{Geant4\-Primary}\-\tts{Map} are initialized
0084 by the action \tts{Geant4GenerationActionInit}
0085 and attached to the {\tts{Geant4Event}} structure.
0086 \item The initialization is then followed by any number of input modules.
0087 Typically each input module add one interaction. Each interaction has a
0088 unique identifier, which is propagated later to all particles. Hence all
0089 primary particles can later be unambiguously be correlated to one of the
0090 initial interactions.
0091 Each instance of a \tts{Geant4InputAction} creates and fills a separate instance
0092 of a \tts{Geant4PrimaryInteraction}.
0093 In section~\ref{sec:ddg4-implementation-geant4inputaction} the functionality and
0094 extensions are discussed in more detail.
0095 \item All individual primary interactions are then merged to only single record
0096 using the \tts{Geant4}\-\tts{Interaction}\-\tts{Merger} component.
0097 This components fills the \tts{Geant4PrimaryInteraction} registered to the
0098 \tts{Geant4Event}, which serves as input record for the next component,
0099 \item the \tts{Geant4PrimaryHandler}. The primary handler creates the proper
0100 \tts{G4PrimaryParticle} and \tts{G4PrimaryVertex} objects passed to \tts{Geant4}.
0101 After this step all event related user interaction with Geant4 has completed,
0102 and the detector simulation may commence.
0103 \end{itemize}
0104 All modules used are subclasses of the {\tts{Geant4}\-\tts{Generator}\-\tts{Action}} and must be
0105 added to the \tts{Geant4}\-\tts{Generator}\-\tts{Action}\-\tts{Sequence} as described
0106 in~\ref{sec:ddg4-user-manual-implementation-geant4action-sequences}.
0107
0108 \noindent
0109 An object of type {\tts{Geant4PrimaryEvent}} exists exactly once for
0110 every event to be simulated. The empty {\tts{Geant4PrimaryEvent}} is created by the
0111 {\tts{Geant4GenerationActionInit}} component. All higher level components may then
0112 access the {\tts{Geant4PrimaryEvent}} object and subsequently an individual interaction
0113 from the {\tts{Geant4Context}} using the extension mechanism as shown in
0114 the following code:
0115 \begin{code}
0116 /// Event generation action callback
0117 void SomeGenerationComponent::operator()(G4Event* event) {
0118 /// Access the primary event object from the context
0119 Geant4PrimaryEvent* evt = context()->event().extension<Geant4PrimaryEvent>();
0120 /// Access the container of interactions
0121 const std::vector<Geant4PrimaryEvent::Interaction*>& inter = evt->interactions();
0122 /// Access one single interaction to be manipulated by this component
0123 Geant4PrimaryInteraction* evt->get(m_myInteraction_identifier);
0124 ....
0125 \end{code}
0126 {\bf{Please note:}} To keep components simple, each component should
0127 only act on one interaction the component has to uniquely identify.
0128 The identification may be implemented by e.g. an access mask passed to the
0129 component as a property.
0130
0131 %=============================================================================
0132 \subsection{Anatomy of the Input Action}
0133 \label{sec:ddg4-implementation-geant4inputaction}
0134 %=============================================================================
0135 \noindent
0136 One input action fills one primary interaction.
0137 \tts{Geant4InputAction} instances may be followed by decorators, which
0138 allow to to smear primary vertex (\tts{Geant4InteractionVertexSmear}) or
0139 to boost the primary vertex \tts{Geant4InteractionVertexBoost} and all
0140 related particles/vertices.
0141
0142
0143 Please note, that a possible reduction of particles in
0144 the output record may break this unambiguous relationship between
0145 "hits" and particles.
0146 ......
0147
0148 %=============================================================================
0149 \subsection{Monte-Carlo Truth Handling}
0150 \label{sec:ddg4-implementation-particle-handling}
0151 %=============================================================================
0152 As any other component in \DDG, the was
0153 designed using the plugin mechanism ie. the default implementation
0154 which was inspired by the original implementation of the MC thruth
0155 handler developed by the Linear Collider community may easily be
0156 overloaded.
0157
0158 \noindent
0159 The Monte-Carlo thruth handler takes care that
0160 \begin{itemize}
0161 \item the proper MC particles are associated with the corresponding hits
0162 and tracks.
0163 \item To compress the particle record. Geant4 creates a large amount
0164 of temporary particles in particluar in dense areas of the
0165 detector such as calorimeters. In calorimeters however, the
0166 hits within a confined volume should be assigned to the incoming
0167 track. In addition a track is only supposed to be kept if it
0168 satisfies certain criteria.
0169 \end{itemize}
0170 To achieve this functionality the Monte-Carlo thruth handler implemented
0171 in the class \tts{Geant4ParticleHandler} firstly
0172 \begin{itemize}
0173 \item implements the interface \tts{Geant4MonteCarloTruth} which gets
0174 called whenever an interaction occurs in a sensitive volume
0175 which is modeled by an instance of a instance of
0176 \tts{Geant4SensitiveAction}.
0177 \item to properly manager the MC particle records the
0178 \tts{Geant4ParticleHandler} either inherits or uses
0179 the callbacks provided by the DDG4 interfaces to the
0180 \begin{itemize}
0181 \item \tts{Geant4GeneratorAction}
0182 \item \tts{Geant4EventAction}
0183 \item \tts{Geant4TrackingAction}
0184 \item \tts{Geant4SteppingAction}.
0185 \end{itemize}
0186 While the response of one track is simulated, all relevant
0187 information is extracted in the callbacks and at the end of the
0188 simulation of the track response a decision is taken whether to
0189 store the information of the Geant4 track in the MC particle
0190 record or not.
0191 \item A Geant4 track is saved in the MC track record if
0192 \begin{itemize}
0193 \item the track did not intercat with the detector, but
0194 is part of the Monte-Carlo record originating
0195 from the original generator consisting of quarks,
0196 leptons, gluons, gammas etc.
0197 \item the track was declared to Geant4 as a Geant4 primary
0198 track from the generator action. These are either
0199 long-living remnants of the underlying hard interaction
0200 of particles decaying macroscopically inside the
0201 experiment volume like e.g. B-mesons.
0202 \item the track exits the world volume.
0203 \item the track is mother particle to secondaries.
0204 \item the track created a hit in a \it{"tracker"}-type
0205 sensitive volume.
0206 \item the track is above a certain energy threshold and
0207 has at least one associated hit either in a
0208 \it{calorimter}-type volume of a \it{tracker}-type
0209 volume.
0210 \end{itemize}
0211 For all tracks purged from the MC particle record, any resulting
0212 energy deposit is associated to the last parent particle
0213 stored in the MC particle record.
0214 \item To fine-tune the Monte-Carlo truth handler in \DDG a
0215 use class with interface \tts{Geant4UserParticleHandler}
0216 may be supplied, which allows to customize and fine tune
0217 if a given MC particle is supposed to be kept in the final
0218 record or not. This user class receives the identical callbacks
0219 as the truth handler, but at the end of the simulation of each
0220 track (the end-tracking-action) a call is issued by the truth
0221 handler and allows to override the decision whether to keep
0222 or dismiss storing a track.
0223 \end{itemize}
0224
0225 \noindent
0226 As mentioned above this implementation is only an example how
0227 to realize such a Monte-Carlo truth logic. It is assumed that the
0228 interface \tts{Geant4ParticleHandler} together with the easy-to-use
0229 subscription mechanism to all callbacks provided by Geant4
0230 allow to easily implement other Monte-Carlo truth mechanisms.
0231
0232 \vspace{0.3cm}
0233 \noindent
0234 The following table shows all properties accepted by the
0235 \DDG Monte-Carlo truth handler.
0236
0237 \vspace{0.3cm}
0238 \noindent
0239 \begin{tabular}{ l p{10cm} }
0240 \hline
0241 \bold{Class name} & \tts{Geant4ParticleHandler} \\
0242 \bold{File name} & \tts{DDG4/src/Geant4ParticleHandler.cpp} \\
0243 \bold{Type} & \tts{Geant4Action} \\
0244 \hline
0245 \bold{Component Properties:} & defaults apply \\
0246 \bold{PrintEndTracking} (bool) & \tts{Extra printout at the end of the } \\
0247 & \tts{tracking action for debugging} \\
0248 \bold{PrintStartTracking} (bool) & \tts{Extra printout at the start of the } \\
0249 & \tts{tracking action for debugging} \\
0250 \bold{KeepAllParticles} (bool) & \tts{Flag to override any NC particle removal} \\
0251 \bold{SaveProcesses} (bool) & \tts{Save all produces of the specified} \\
0252 & \tts{Geant4 particle processes} \\
0253 \bold{MinimalKineticEnergy} (bool) & \tts{Minimal energy cut required to accept a MC particle} \\
0254 \bold{MinDistToParentVertex} (bool) & \tts{Minimal distance to the parent's }\\
0255 & \tts{start-vertex in order to become an independent particle} \\
0256 & \tts{Used to e.g. suppress Delta-rays} \\
0257 \end{tabular}
0258
0259 \newpage
0260
0261 %=============================================================================
0262 \section{Output Data Handling}
0263 \label{sec:ddg4-implementation-output-handling}
0264 %=============================================================================
0265
0266 \noindent
0267 The output of the data record of the accepted MC particle record
0268 and the corresponding sets of hits in the various subdetectors is
0269 basic to further handing data originating from simulated particle
0270 collisions. In \DDG the handling of output data is implemented as
0271 a specialization of a \tts{Geant4EventAction} since the output
0272 needs to written at the end of each simulated event.
0273
0274 \noindent
0275 Currently there are three types of output formats implemented:
0276 \begin{itemize}
0277 \item Writing the MC particle record and the Geant4 hits
0278 natively as ROOT objects to a ROOT file.
0279 This is a very simple solution, writes the entire event
0280 as a ROOT TTree object. The persistent data format of the
0281 objects is the same as the transition data format in memory
0282 used during the simulation step.
0283 \item Writing the particle record and the hit structures in LCIO
0284 data format. For details of the LCIO data format
0285 please consult the LCIO manual.
0286 \item Writing the particle record and the hit structures in
0287 the EDMS data format developed by the CERN/SFT data format.
0288 For details of the LCIO data format please consult the LCIO
0289 manual.
0290 \end{itemize}
0291
0292 Unless the native ROOT format is used for data output,
0293 the data format of the transient representation
0294 of Monte-Carlo particles and the resulting tracker- and
0295 calorimeter hits differes from the persistent representation
0296 and requires data conversion. The overheads of such conversions however
0297 are typically neglidgeble with respect to the rather large resource
0298 usage required for simulation.
0299
0300 \vspace{0.3cm}
0301 \noindent
0302 The component properties of the generic output class:
0303
0304 \vspace{0.3cm}
0305 \noindent
0306 \begin{tabular}{ l p{10cm} }
0307 \hline
0308 \bold{Class name} & \tts{Geant4OutputAction} \\
0309 \bold{File name} & \tts{DDG4/src/Geant4OutputAction.cpp} \\
0310 \bold{Type} & \tts{Geant4Action} \\
0311 \hline
0312 \bold{Component Properties:} & defaults apply \\
0313 \bold{Output} (string) & \tts{String representation of the output-file} \\
0314 \bold{HandleErrorsAsFatal} (bool) & \tts{Convert any error of the concrete implementation}\\
0315 & \tts{into a fatal exception causing \DDG to stop processing.}\\
0316 \end{tabular}
0317
0318 \vspace{0.3cm}
0319 \noindent
0320 The component properties of the ROOT output class:
0321
0322 \vspace{0.3cm}
0323 \noindent
0324 \begin{tabular}{ l p{10cm} }
0325 \hline
0326 \bold{Class name} & \tts{Geant4Output2ROOT} \\
0327 \bold{File name} & \tts{DDG4/src/Geant4Output2ROOT.cpp} \\
0328 \bold{Type} & \tts{Geant4Action} \\
0329 \hline
0330 \bold{Component Properties:} & defaults apply \\
0331 \bold{Section} (string) & \tts{Name of the ROOT TTree to store the event data.}\\
0332 & \tts{Default: EVENT} \\
0333 \bold{HandleMCTruth} (bool) & \tts{Handle the results of the Monte-Carlo thruth handler}\\
0334 & \tts{when outputting data}\\
0335 \bold{DisabledCollections} & \tts{vector<string>}\\
0336 & \tts{Geant4 filled collections, which should be excluded}\\
0337 & \tts{from the output record.}\\
0338 \bold{DisableParticles} (bool) & \tts{Inhibit the output of the particle record.}
0339
0340 \end{tabular}
0341
0342
0343 \newpage