Back to home page

EIC code displayed by LXR

 
 

    


Warning, /DD4hep/doc/usermanuals/DDAlign/DDAlignManual.tex is written in an unsupported language. File is not indexed.

0001 %=============================================================================
0002 \documentclass[10pt,a4paper]{article}
0003 %
0004 \input{./setup/DD4hep-setup.tex}
0005 \input{./setup/AIDA2020-setup.tex}
0006 %
0007 \pagestyle{fancyplain}{\fancyfoot[C]{\sffamily{DDAlign User Manual}}}
0008 %
0009 \usepackage{amsmath}
0010 \graphicspath{{./figs/}}
0011 \begin{document}   
0012 %
0013 \mytitle{
0014 DDAlign
0015 }{
0016 Alignment Support for the \\
0017 \vspace{0.5cm}
0018 DD4hep Geometry Description \\
0019 \vspace{0.5cm}
0020 Toolkit
0021 \vspace{2cm}
0022 }
0023 {M. Frank \\
0024 {CERN, 1211 Geneva 23, Switzerland}}
0025 
0026 %
0027 %
0028 %==  Abstract  ===============================================================
0029 \pagestyle{plain}
0030 \pagenumbering{Roman}
0031 \setcounter{page}{1}
0032 \begin{abstract}
0033 %=============================================================================
0034 
0035 \noindent
0036 \normalsize
0037 Experimental setups in High Energy Physics are highly complex assemblies 
0038 consisting of various detector devices typically called {\it{subdetectors}}.
0039 Contrary to the ideal world, where all these components are of perfect shape 
0040 and at exact positions, existing devices have imperfections both in their 
0041 shape and their relative and absolute positions. These are described by the
0042 alignment parameters.\\
0043 To still measure the detector response from particle collisions with the highest
0044 possible precision, these imperfections are taken into account when converting
0045 measured signals to space-points in the measurement devices. This procedure
0046 is called {\it{detector alignment}}. \DDhep does not want to solve the exact 
0047 problem of the detector alignment itself, but rather support firstly algorithms 
0048 determining the alignment parameters and secondly support the application which 
0049 apply the measured alignment parameters and apply them to the ideal geometry 
0050 for further event data processing.\\
0051 We will present the tools to support the detector alignment procedures using 
0052 the \DDhep detector description toolkit. 
0053 The \DDA toolkit implements a modular and flexible approach to introduce and
0054 access the alignment parameters.\\
0055 The design is strongly driven by easy of use;
0056 developers of detector descriptions and applications using
0057 them should provide minimal information and minimal specific
0058 code to achieve the desired result.
0059 
0060 \end{abstract}
0061 
0062 \vspace{8cm}
0063 
0064 \begin{center}
0065 {\large{\bf{
0066 \begin{tabular} {| l | l | l |}
0067 \hline
0068 \multicolumn{3}{| c |}{} \\[0.2cm]
0069 \multicolumn{3}{| c |}{Document History} \\[0.2cm]
0070 \multicolumn{3}{| c |}{} \\[0.2cm]
0071 \hline
0072                  &      &        \\
0073 Document         &      &        \\
0074 version          & Date & Author \\[0.2cm] \hline
0075                  &      &        \\
0076 1.0              & 01/04/2014 & Markus Frank CERN/LHCb  \\
0077 1.1              & 30/04/2014 & Markus Frank CERN/LHCb  \\
0078 1.2              & 28/02/2017 & Markus Frank CERN/LHCb  \\
0079                  &      &        \\        \hline 
0080 \end{tabular}
0081 }}}
0082 \end{center}
0083 
0084 \clearpage
0085 %
0086 %
0087 %==  TOC  ====================================================================
0088 \tableofcontents
0089 \clearpage
0090 %
0091 %
0092 %=============================================================================
0093 % Manual
0094 %=============================================================================
0095 \pagenumbering{arabic}
0096 \setcounter{page}{1}
0097 
0098 %=============================================================================
0099 \section{Introduction}
0100 \label{sec:ddalign-user-manual-introduction}
0101 %=============================================================================
0102 \noindent
0103 This manual should introduce to the \DDA framework. 
0104 One goal of \DDA is to easily model geometrical imperfections applied to
0105 the ideal geometry of detection devices as they are typically used in 
0106 high energy physics experiments.
0107 
0108 \noindent
0109 To avoid confusion within this document, a few terms need to be defined
0110 with respect to detector alignment:
0111 \begin{itemize}\itemcompact
0112 \item The {\it{ideal geometry}} describes the detector as it was designed.
0113     Such a detector is an utopia, which can never be realized in terms
0114     of the placement of the individual components as such.
0115 \item The {\it{actual geometry}} describes - as a first approximation 
0116     to the real world - the real detector at a given time valid for a rather
0117     significant amount of time  e.g. for a year of data taking.
0118     The {\it{actual geometry}} typically includes corrections deduced 
0119     e.g. from optical surveys etc. The {\it{actual geometry}} does not 
0120     change during the life-time of an analysis or calibration process. 
0121     In the following this is called {\it{Global Alignment}}. 
0122     The transformation of the ideal geometry to the actual geometry 
0123     is steered by alignment parameters aka {\it{Alignment Deltas}}. 
0124     Such {\it{deltas}} may be applied at any level of the geometrical 
0125     hierarchy. 
0126     In short, the {\it{actual geometry}} results from the {\it{ideal geometry}}
0127     after applying the global {\it{Alignment Deltas}} and is then 
0128     the {\it{geometry in memory}}. The ROOT geometry
0129     toolkit is the only one, which allows for global alignment procedures
0130     \footnote{A conversion of this geometry e.g. to Geant4 (using the functionality
0131     provided by \DDG allow to simulate distorted geometries with the Geant4 toolkit.}.
0132 \item {\it{Realignment}} then defines the procedures to correct data 
0133     collected in particle collisions. These data are taken with the real, 
0134     a priori unknown geometry, which on top of the actual geometry suffers 
0135     from small shifts e.g. due to temperature or pressure changes. These 
0136     shifts normally are frequently computed by specialized applications 
0137     with respect to the to the actual geometry and typically are valid 
0138     for relatively short time periods \cal{O}(1 hour). These shifts, called 
0139     {\it{Alignment Deltas}}, are used to re-align the detector response 
0140     for physics analysis. This process in the following is called 
0141     {\it{Local Alignment}}.
0142     The handling of the {\it{Alignment Deltas}} for local alignments in fact 
0143     is very similar to the handling of detector conditions implemented in the
0144     package \DDC\cite{bib:DDCond}. 
0145     In section~\ref{sect:ddalign-local-aligments} 
0146     this issue is further elaborated.
0147 \end{itemize}
0148 
0149 \noindent
0150 Technically the {\it{Alignment Deltas}} used for the global alignment 
0151 and the {\it{Alignment Deltas}} used for the local alignment are identical.
0152 Though it should be stressed that the use is entirely different:
0153 Whereas the first actually alter the geometry, the latter are only used 
0154 to properly interpret the data collected.
0155 
0156 \noindent
0157 \DDA formalizes both the access and the application of alignment parameters 
0158 to the ideal geometry. The possibility to properly describe actual geometries 
0159 with respect to ideal geometries is essential to understand the detector response
0160 to particle collisions and to connect response of geometrical independent
0161 areas of the experiment e.g. to one single track.
0162 
0163 \noindent
0164 In this manual we will shortly describe the model used
0165 to describe an experiments detector description and then in more detail 
0166 document the support for alignment with its programming interfaces.
0167 
0168 %=============================================================================
0169 \begin{figure}[h]
0170   \begin{center}
0171     \includegraphics[height=90mm] {DD4hep_classes}
0172     \caption{Class diagram with the main classes and their relations 
0173              for the Generic Detector Description Model. The implementing
0174              ROOT classes are shown in brackets.}
0175     \label{fig:dd4hep-detector-model}
0176   \end{center}
0177 \end{figure}
0178 \vspace{-0.1cm}
0179 %=============================================================================
0180 \subsection{Generic Detector Description Model}
0181 \label{subsec:generic-model}
0182 %=============================================================================
0183 
0184 \noindent
0185 This is the heart of the DD4hep detector description toolkit. Its purpose is 
0186 to build in memory a model of the detector including its geometrical aspects
0187 as well as structural and functional aspects. The design reuses the elements 
0188 from the ROOT geometry package and extends them in case required functionality 
0189 is not available. Figure~\ref{fig:dd4hep-detector-model} illustrates the main
0190 players and their relationships~\cite{bib:DD4hep}.
0191 Any detector is modeled as a tree of $Detector$ $Elements$, the entity 
0192 central to this design, which is represented in the implementation by 
0193 the $DetElement$ class~\cite{bib:LHCb-geometry}. It offers all
0194 applications a natural entry point to any detector part of the experiment
0195 and represents a complete sub-detector (e.g. TPC), a part of a 
0196 sub-detector (e.g. TPC-Endcap), a detector module or any other convenient 
0197 detector device. 
0198 The main purpose is to give access to the data associated 
0199 to the detector device. For example, if the user writes some TPC reconstruction 
0200 code, accessing the TPC detector element from this code will provide access 
0201 the all TPC geometrical dimensions, the alignment and calibration constants 
0202 and other slow varying conditions such as the gas pressure, end-plate 
0203 temperatures etc. The $Detector$ $Element$ acts as a data concentrator. 
0204 Applications may access the full experiment geometry and all connected data
0205 through a singleton object of type $Detector$, which provides 
0206 management, bookkeeping and ownership to the model instances.
0207 
0208 \noindent
0209 The geometry is implemented using the ROOT geometry classes, which are used
0210 directly without unnecessary interfaces to isolate the end-user from the 
0211 actual ROOT based implementation.
0212 \DDA allows client to access, manage and apply alignment parameters or 
0213 smallish changes to the ideal geometry. The mechanism to achieve this 
0214 is described in the following.
0215 
0216 
0217 %=============================================================================
0218 \begin{figure}[h]
0219   \begin{center}
0220     \includegraphics[height=75mm] {DD4hep_detelement_tree}
0221     \caption{The object diagram of a hypothetical TPC detector showing in
0222     parallel the $Detector$ $Element$ and the $Geometry$ hierarchy and the 
0223     relationships between the objects.}
0224     \label{fig:dd4hep-hierarchies}
0225   \end{center}
0226   \vspace{-0.5cm}
0227 \end{figure}
0228 
0229 
0230 %=============================================================================
0231 \subsection{Detector Element Tree and the Geometry Hierarchy}
0232 \label{subsect:detelement-hierarchy}
0233 %=============================================================================
0234 \noindent
0235 The geometry part of the detector description is delegated to the ROOT classes.
0236 $Logical$ $Volumes$ are the basic objects used in building the geometrical hierarchy. 
0237 A $Logical$ $Volume$ is a shape with its dimensions and consist of a given material. 
0238 They represent unpositioned objects which store all information about 
0239 the placement of possibly embedded volumes. The same
0240 volume can be replicated several times in the geometry. The $Logical$ $Volume$ 
0241 also represents a system of reference with respect to its containing volumes.
0242 The reuse of instances of $Logical$ $Volumes$ for different placements 
0243 optimizes the memory consumption and detailed geometries for complex setups
0244 consisting of millions of volumes may be realized with reasonable amount of memory.
0245 The difficulty is to identify a given positioned volume 
0246 in space and e.g. apply alignment parameters to one of these volumes. 
0247 The relationship between the Detector Element and the placements
0248 is not defined by a single reference to the placement, but the full path 
0249 from the top of the detector geometry model to resolve existing
0250 ambiguities due to the reuse of $Logical$ $Volumes$.
0251 Hence, individual volumes must be identified by their full path from mother 
0252 to daughter starting from the top-level volume. 
0253 
0254 \noindent
0255 The tree structure of
0256 $Detector$ $Elements$ is a parallel structure to the geometrical hierarchy.
0257 This structure will probably not be as deep as the geometrical one since 
0258 there would not need to associate detector information at very fine-grain 
0259 level - it is unlikely that every little metallic screw
0260 needs associated detector information such as alignment, conditions, etc.
0261 Though this screw and many other replicas must be described in the geometry 
0262 description since it may be important e.g. for its material contribution 
0263 in the simulation application. Thus, the tree of Detector Elements is
0264 fully degenerate and each detector element object will be placed only 
0265 once in the detector element tree as illustrated for a hypothetical
0266 Time Projection Chamber (TPC) detector in 
0267 Figure~\ref{fig:dd4hep-hierarchies} with an ideal geometry,
0268 where no positioning corrections are applied to neither child. 
0269 It is essential to realize that the geometry tree in an ideal geometry is
0270 degenerate contrary to the tree of detector elements.
0271 
0272 \noindent
0273 It should be noted, that alignment parameters may be applied to any volume 
0274 of the ideal geometry. The alignment only affects the actual position of 
0275 a volume it is e.g. irrelevant if the volume is sensitive or not.
0276 
0277 %=============================================================================
0278 \begin{figure}[h]
0279   \begin{center}
0280     \includegraphics[width=160mm] {DDAlign_detelement_aligned_tree}
0281     \caption{The object diagram of a hypothetical TPC detector showing in
0282     parallel the $Detector$ $Element$ and the $Geometry$ hierarchy and examples
0283     of mispositioned detector parts: (a) mispositioned entire subdetector 
0284     (translation), (b) mispositioned end-cap (tilt) and (c) mispositioned
0285     individual sectors within one endcap.}
0286     \label{fig:dd4hep-aligned-hierarchies}
0287   \end{center}
0288 \end{figure}
0289 
0290 %=============================================================================
0291 \section{Global Alignment}
0292 \label{sect:ddalign-global-aligments}
0293 %=============================================================================
0294 \subsection{Global Alignment of Detector Components}
0295 \label{subsect:ddalign-intro-aligments}
0296 %=============================================================================
0297 \noindent
0298 In this section the backgrounds of the {\it{Global Alignment}} is described.
0299 Alignment parameters never apply in the same way to {\it{all}} placements of the 
0300 same volume in this hierarchy. Hence, to (re-)align a volume in the hierarchy
0301 means to logically lift a full branch of placements from the top volume down to
0302 the element to be (re-)aligned out of this shared hierarchy and apply
0303 a correction matrix to the last node. This procedure is illustrated in 
0304 Figure~\ref{fig:dd4hep-aligned-hierarchies}. Re-alignment of volumes may occur
0305 at any level. In the above example of a TPC this results in the following effects:
0306 
0307 \noindent
0308 \begin{itemize}\itemcompact
0309 \item A realignment of the entire subdetector, i.e. the TPC as a whole, 
0310     would affect consequently move all contained children with respect to the 
0311     top level coordinate system. An example is shown in 
0312     Figure~\ref{fig:dd4hep-aligned-hierarchies} (a). A movement of the subdetector
0313     would affect all transformation between local coordinates of any part of the
0314     subdetector to the top level coordinate system. Such effects would be visible 
0315     at all stages of the data processing e.g. when translating signals from 
0316     particles into global coordinates.
0317 \item A realignment of parts of a subdetector affects only the partial subdetector
0318     itself and child volumes at lower levels. As in the example, where the entire
0319     subdetector is moved, here only the sectors on one 
0320     side of the TPC would be affected
0321     as shown in Figure~\ref{fig:dd4hep-aligned-hierarchies} (b).
0322 \item In Figure~\ref{fig:dd4hep-aligned-hierarchies} (c) within one 
0323     end-cap of the TPC
0324     individual sectors may not be positioned at the ideal location
0325     (Figure~\ref{fig:dd4hep-aligned-hierarchies} (c) exaggerates: 
0326     ''flying sectors'' are a rather rare case in reality).
0327     Finally also the sectors itself could be fragmented and be assemblies of other
0328     shapes, which are not ideally placed and may need correction.
0329 \end{itemize}
0330 The origin of the volume misplacements may be many-fold:
0331 \begin{itemize}\itemcompact
0332 \item Elements may be weak and assembled parts move due to weak support
0333     structures.
0334     This is a common problem e.g. for tracking detectors, where heavy and solid 
0335     structures dramatically influence the measurement result.
0336     Misplaced sectors could e.g. be the consequence of a deforming 
0337     end-cap frame due to the weight of the sectors.
0338 \item Environmental conditions such as the temperature may influence the 
0339     position or the shape of a volume.
0340 \item Some of the measurement equipment may be moved from a parking position into 
0341     a data taking position such as the two halves of the LHCb vertex detector. 
0342     Whereas the position of the sensors on each half are known to a very high 
0343     precision, the position of the absolute position of the two halves with
0344     respect to the full experiment may change after each movement.
0345 \end{itemize}
0346 Changes to the volume placement do not only affect sensitive material 
0347 i.e. detector components with an active readout, but also passive material. 
0348 The placement of any volume, passive or active, may be corrected using \DDA. 
0349 The determination of the alignment parameters of passive components however may
0350 be more difficult in the absence of located signals resulting 
0351 e.g. from the traversal of a track.
0352 
0353 \noindent
0354 All effects resulting from such causes obviously need to be corrected in order to 
0355 fully explore the capabilities of the detection devices and to minimize 
0356 measurement errors. In general any deviation from the ideal position of a volume
0357 can be described by two elementary transformations:
0358 \begin{itemize}\itemcompact
0359 \item a translation
0360 \item a rotation around a pivot point.
0361 \end{itemize}
0362 giving a full transformation matrix of the form:
0363 \begin{equation}
0364 T = L * P * R * P^{-1}
0365 \end{equation}
0366 where 
0367 \begin{itemize}\itemcompact
0368 \item $T$ is the full transformation in 3D space containing the change to the 
0369 exiting placement transformation. The existing placement is the placement 
0370 transformation of the volume with respect to the mother volume.
0371 \item $L$ is a translation specifying the position change with respect to the 
0372     mother volume.
0373 \item $P * R * P^{-1}$ describes a rotation around a pivot point specified 
0374     int he mother volume's coordinate system.
0375 \item $P$ is the translation vector from the mother volumes origin to the 
0376     pivot point. The concept of a pivot point does not introduce a new 
0377     set of parameters. Pivot points only help to increase the numerical
0378     precision.
0379 \end{itemize}
0380 Most of the changes do not require the full set of parameters. Very often 
0381 the changes only require the application of only a translation, only a
0382 rotation or both with a pivot point in the origin. These simplifications 
0383 are supported  in the user interface described in 
0384 Section~\ref{sec:ddalign-user-manual-ddalign-interface}.
0385 
0386 %=============================================================================
0387 \begin{figure}[t]
0388   \begin{center}
0389     \includegraphics[width=160mm] {DDAlign-iterative-misalignment}
0390     \caption{The iterative application of alignment parameters as described
0391     in Section~\ref{subsect:ddalign-intro-iterative-alignments}.
0392     For each interval of validity 
0393     ($[T_0,T_1]$, $[T_2,T_3]$, $[T_4,T_5]$, ...)
0394     a seperate set of alignment constants is applied to the ideal geometry.
0395     The two steps to reset the misaligned geometry back to the ideal
0396     geometry and
0397     to re-apply a new set of alignment constants may be executed as 
0398     often as necessary when processing data from particle collisions.}
0399     \label{fig:ddalign-aligned-iterative}
0400   \end{center}
0401 \end{figure}
0402 
0403 %=============================================================================
0404 \subsection{Iterative Application of Global Alignments}
0405 \label{subsect:ddalign-intro-iterative-alignments}
0406 %=============================================================================
0407 \noindent
0408 Technically it is possible to apply global alignment procedures iteratively.
0409 This however id {\bf{deprecated}} and violates thread safety for the simple reason
0410 that the {\it{geometry in memory}} is altered. If applied, it is duty of the 
0411 client framework to ensure that during the change of global alignment 
0412 no processing of event data is ongoing.
0413 Hence, the procedure is described here only for completeness:
0414 \begin{enumerate}\itemcompact
0415 \item Create the ideal detector using an ideal geometry.
0416 \item Apply a set of alignment parameters for a given time 
0417     interval corresponding to the 
0418     time a set of particle collisions were collected in the experiment.
0419 \item Process the set of collected particle collisions.
0420 \item Reset the misaligned detector to the ideal.
0421 \item Choose new event data input corresponding to another time interval
0422     and restart at item 2.
0423 \end{enumerate}
0424 Graphically this use case is illustrated in 
0425 Figure~\ref{fig:ddalign-aligned-iterative}. In 
0426 Section~\ref{sec:ddalign-user-manual-ddalign-interface} the implementation 
0427 to realize this use case is described.
0428 
0429 %=============================================================================
0430 \subsection{Procedures to Determine Global Alignment Parameters}
0431 \label{subsect:ddalign-intro-determine-alignment-params}
0432 %=============================================================================
0433 \noindent
0434 Typically the determination of alignment parameters requires a starting point
0435 which is not necessarily identical to the ideal position of a 
0436 volume~\cite{bib:chris-parkes-priv-comm}. These volume positions are the result
0437 of a survey measurement or the result of internal position measurements 
0438 of a sub-volume within a sub-detector e.g. on a measurement bench.
0439 In the following we call these parameters {\it{survey parameters}}. 
0440 {\it{Survey parameters}} default to the ideal volume position if not supplied,
0441 alternatively, if set, to the provided position. {\it{Survey parameters}}
0442 are, like the alignment parameters, provided in terms of {\it{changes}} with 
0443 respect to the ideal position and hence may be treated in a similar way.
0444 
0445 \noindent 
0446 The survey parameters are accessible to users
0447 through the interface offered by the $DetElement$ objects.
0448 
0449 %=============================================================================
0450 \subsection{Simulation of Non-Ideal Detector Geometries}
0451 \label{subsect:ddalign-intro-simulate-misaligned-geometries}
0452 %=============================================================================
0453 \noindent
0454 It is a standard procedure in high energy physics to at least verify 
0455 the measured detector response of a given physics process in particle 
0456 collisions with the expected simulated detector response.
0457 For most purposes the simulation of an ideal detector is certainly is
0458 sufficient - though not describing the full truth. Sometimes however, the
0459 detector geometry must be simulated with a geometry as close to the 
0460 known geometry as possible.
0461 
0462 \noindent
0463 The simulation of such a geometry with applied alignment parameters can 
0464 rather easily be realized using using the \DDhep, \DDA and the \DDG frameworks:
0465 \begin{itemize}\itemcompact
0466 \item The ideal geometry is constructed using the standard procedures
0467     of \DDhep~\cite{bib:DD4hep}.
0468 \item Then the alignment parameters are applied and finally
0469 \item the corrected geometry is translated to $Geant4$~\cite{bib:geant4}
0470     using the \DDG~\cite{bib:DDG4} package.
0471     All particle collisions simulated with this translated geometry 
0472     correspond to the modified geometry including the geometry
0473     modifications.
0474 \end{itemize}
0475 There is a caveat though: The application of alignment parameters can
0476 easily create volume overlaps, which are highly disliked by the $Geant4$ 
0477 runtime. If the above described procedure is applied, it is highly advised 
0478 to check the resulting geometry for overlaps. Both, 
0479 $ROOT$~\cite{bib:ROOT-tgeo} and $Geant4$~\cite{bib:geant4} offer tools 
0480 to perform such tests.
0481 
0482 \noindent
0483 To simulate distorted geometries clients should use the 
0484 $Global$ $Alignment$  interface described in 
0485 section~\ref{sec:ddalign-user-manual-ddalign-global-interface}.
0486 
0487 \newpage
0488 %=============================================================================
0489 \subsection{The Global Alignment Interface}
0490 \label{sec:ddalign-user-manual-ddalign-global-interface}
0491 %=============================================================================
0492 
0493 \noindent
0494 In this chapter will be documented how to use the $Global$ $Alignment$ 
0495 interface of \DDA. As already mentioned in 
0496 section~\ref{sec:ddalign-user-manual-introduction}, 
0497 this interface allows to alter the layout of the 
0498 geometry in memory. Use cases are e.g. the simulation of 
0499 non-ideal geometries.
0500 
0501 \noindent
0502 Global alignment can be applied to detector elements using a specialized
0503 interface {\it{GlobalDetectorAlignment}}~\footnote{See the header file
0504 $DDAlign/GlobalDetectorAlignment.h$ for details.}. This interface 
0505 provides the API to apply global changes to the geometry provided
0506 the presence of alignment parameters as shown in the following 
0507 code snippet:
0508 
0509 \begin{code}
0510   /// First install the global alignment cache to build proper transactions
0511   Detector& detector = ...;
0512   GlobalAlignmentCache* cache = GlobalAlignmentCache::install(detector);
0513   
0514   /// Now create the tranaction context. There may only be one context present
0515   GlobalAlignmentStack::create();
0516   GlobalAlignmentStack& stack = GlobalAlignmentStack::get();
0517 
0518   /// Now we can push any number of global alignment entries to the stack:
0519   DetElement        elt       = ...detector element containing the volume to be re-aligned ...;
0520   string            placement = "/full/path/to/the/volume/to/be/realigned";  
0521   Alignments::Delta delta     = ...;
0522   double            ovl       = allowed_overlap_in cm; // e.g. 0.001;
0523 
0524   // Create the new stack entry and insert it to the stack
0525   dd4hep_ptr<StackEntry> entry(new StackEntry(elt,placement,delta,ovl));
0526   stack->insert(entry);
0527 
0528   /// Finally we commit the stacked entries and release the stack.
0529   cache->commit(stack);
0530   GlobalAlignmentStack::get().release();
0531 \end{code}
0532 
0533 \noindent
0534 {\bf{Explanation:}} \\
0535 \begin{tabular} {l||p{0cm}}
0536 \docline{Line}{}
0537 \docline{3}{Install the $GlobalAlignmentCache$. Required to be done
0538 once. The object is registered to the $Detector$ instance and kept there.}
0539 \docline{3-8}{The fact that the classes $GlobalAlignmentCache$ and 
0540 $GlobalAlignmentStack$ are singletons is not a fundamental issue.
0541 However, we want to call the XML parser (or other database sources)
0542 iteratively and currently cannot chain a context (stack).}
0543 \docline{16-21}{The created stacked entries are automatically released 
0544 once the transaction is committed.}
0545 \end{tabular}
0546 
0547 \noindent
0548 Please note, that this interface normally is not directly invoked
0549 by users, but rather called by plugin mechanisms as the one described below
0550 capable of reading the global misalignments from XML.
0551 
0552 \noindent
0553 %=============================================================================
0554 \subsubsection{Loading Global Geometrical Imperfections from XML}
0555 \label{sec:ddalign-user-manual-global-misalignment-manip-xml}
0556 %=============================================================================
0557 \noindent
0558 In this section we describe how to load global geometry 
0559 imperfections and to apply them
0560 to an existing geometry. Loading the XML file is done automatically using the 
0561 standard XML loader plugin provided by \DDhep. This mechanism is favoured and 
0562 much simpler than programming the global misalignment directly.
0563 This plugin is interfaced to 
0564 the {\tt Detector} instance and invoked from code as follows:
0565 \begin{code}
0566     Detector& detector = ....;
0567     detector.fromXML("file:AlepTPC_alignment.xml");
0568 \end{code}
0569 To fully exploit the capabilities it is important to understand the interpreted 
0570 structure of the XML file being processed. At the top level of the primary 
0571 input file (i.e. the file given to the XML processor) the following structure 
0572 is expected:
0573 \begin{code}
0574 <global_alignment>
0575   <!-- Open the alignment transaction  -->
0576   <open_transaction/>
0577   <subdetectors>         <!-- Container with the list of subdetectors to be processed. -->
0578     <detelement path="TPC" reset="true" reset_children="true">
0579       <!-- Move the entire TPC in the world volume                                     -->
0580       <position="" x="30"   y="30"  z="80"/>
0581 
0582       <!-- Now add daughter detector elements                                          -->
0583 
0584       <!-- Twist a bit the entire endcap by rotating it around the x and the y axis    -->
0585       <detelement path="/world/TPC/TPC_SideA" check_overlaps="false">
0586         <position x="0"   y="0"  z="0"/>
0587         <rotation x="-0.2" y="-0.2"  z="0"/>
0588         <!-- Apply corrections of type Translation*Rotation to a single sector           
0589         <detelement path="TPC_SideA_sector02" check_overlaps="true">
0590           <position x="0"   y="0"   z="0"/>
0591           <rotation x="0.5" y="0.1" z="0.2"/>     
0592         </detelement>
0593       </detelement>
0594 
0595       <!-- And the full shooting match of transformations for this sector              -->
0596       <detelement path="TPC_SideA/TPC_SideA_sector03" check_overlaps="true">
0597         <position x="0" y="0"    z="290.0*mm"/>
0598         <rotation x="0" y="pi/2" z="0"/>     
0599         <pivot    x="0" y="0"    z="100"/>     
0600       </detelement>
0601 
0602       ....
0603 
0604       <!-- Include alignment files to be processed in the context of the "TPC" DetElement
0605       <include ref="file-name"/>
0606 
0607     </detElement>            
0608   </subdetectors>
0609 
0610   <!-- Include alignment files to be processed at the top level context               -->
0611   <include ref="file-name"/>
0612 
0613   <!-- Close the alignment transaction  -->
0614   <close_transaction/>
0615 </global_alignment>
0616 \end{code}
0617 
0618 \noindent
0619 The structure of the alignment file explained quickly:
0620 
0621 \begin{tabular} {l||p{0cm}}
0622 \docline{Line}{}
0623 \docline{1}{The {\tt root} tag for the primary alignment file is {\tt <alignment/>}.
0624     The primary tag name is mandatory and actually is used to invoke the correct interpreter.}
0625 \docline{2,41}{Trigger the alignment transaction by specifying the transaction tags in 
0626         the main XML file.}
0627 \docline{4}{Defintion of the set of {\tt subdetectors} to be processed. A valid alias for this
0628         directove is {\tt detelements}.}
0629 \docline{5}{The first subdetector: {\tt TPC}. The subdetector tag is {\tt detelement}
0630         Each {\tt detelement} may recursively contain other {\tt detelement} tags.
0631         as they were defined in the {\tt DetElement} hierarchy.
0632         Internal {\tt detelement} elements are processed in the context of the outer
0633         element i.e. pathes may be specified relative to the parent or as absolute pathes
0634         with respect to the world (starting with a '/').}
0635 \docline{7}{Global movement of the TPC}
0636 \docline{12-20}{Realignment entry for the TPC endcap A named {\tt TPC\_SideA}}
0637 \docline{16-19}{Realignment entry for sector named {\tt TPC\_SideA\_sector02} of the TPC endcap A.
0638     Here the sector is specified directly as a daughter of the endcap. The name 
0639     of the {\tt DetElement} is relative to the parent.}
0640 \docline{23-27}{Realignment entry for sector named {\tt TPC\_SideA\_sector03} of the TPC endcap A
0641         containing a full transformation: $Translation * Pivot * Rotation * Pivot^{-1}$}
0642 \docline{32}{Optionally {\tt detelement} elements may include other alignment files specifying
0643         lower volume levels. These files are interpreted in the context of the calling 
0644         detector element. }
0645 \docline{38}{Optionally the subdetector alignment constants may be fragmented 
0646         into several files,   which can be loaded using the {\tt include} 
0647         directive. Each file could for example describe one single detector.}
0648 \end{tabular}
0649 
0650 \vspace{0.5cm}
0651 \noindent
0652 The specification of any transformation element is optional:
0653 \begin{itemize}\itemcompact
0654 \item The absence of a translation implies the origin (0,0,0)
0655 \item The absence of a pivot point implies the origin (0,0,0)
0656 \item The absence of a rotation implies the identity rotation.
0657     Any supplied pivot point in this case is ignored.
0658 \end{itemize}
0659 The absence of a transformation element is absolutely legal and does not
0660 issue any warning or error.
0661 
0662 \noindent
0663 All transformations describe the change of placement with respect to the 
0664 coordinate system of the closest mother-volume in the volume hierarchy,
0665 i.e. translations, rotations and pivot points are local to the 
0666 mother coordinate system.
0667 
0668 \noindent
0669 Included files may directly start with the {\tt root} tags {\tt subdetectors}, 
0670 {\tt detelements} or {\tt detelement} and may recursively include other
0671 files. Except for the top level these files are processed in the calling context.
0672 The result of this procedure is shown in Figure~\ref{fig:dd4hep-aligned-hierarchies}.
0673 
0674 %=============================================================================
0675 \begin{figure}[h]
0676   \begin{center}
0677     \includegraphics[width=160mm] {DDAlign-misaligned-TPC}
0678     \caption{The ALEPH TPC after the import of the alignment file.
0679     Note, that the geometry in $memory$ changed. The original
0680     geometry desciption is no longer present.
0681     }
0682     \label{fig:dd4hep-aligned-hierarchies}
0683   \end{center}
0684 \end{figure}
0685 
0686 
0687 \noindent
0688 %=============================================================================
0689 \subsubsection{Export Geometrical Imperfections to XML}
0690 \label{sec:ddalign-user-misalignment-expotr-xml}
0691 %=============================================================================
0692 \noindent
0693 In this section we describe how to export geometry imperfections to an XML file.
0694 A small helper class {\tt AlignmentWriter} achieves this task as shown in 
0695 the snippet:
0696 \begin{code}
0697   Detector&  detector = ....;
0698   DetElement top = detector.world();
0699   if ( top.isValid() )   {
0700     AlignmentWriter wr(detector);
0701     return wr.write(top,output,enable\_transactions);
0702   }
0703 \end{code}
0704 This code will dump all alignment constants contained in the {\tt DetElement}
0705 hierarchy of {\tt top} to the output file {\tt output}. The optional argument
0706 {\tt enable\_transactions} (default: true) will add the tags 
0707 {\tt <open\_transaction/>} and {\tt <close\_transaction/>} to the output 
0708 file. The output file conforms to the specifications described in 
0709 Section~\ref{sec:ddalign-user-manual-misalignment-manip-xml} and may later
0710 be imported by another process.
0711 
0712 \noindent
0713 {\bf{FIXME: This chapter sort of still has to be written/completed!!!!}}
0714 
0715 \newpage
0716 
0717 \section{Up to here the manual should be pretty much correct.\\
0718 Everything below is at least questionable.}
0719 
0720 %=============================================================================
0721 \section{Local Alignment}
0722 \label{sect:ddalign-local-aligments}
0723 %=============================================================================
0724 bla bla bla
0725 
0726 %%%% Here we are now.
0727 
0728 
0729 
0730 
0731 
0732 
0733 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0734 
0735 
0736 \noindent
0737 Generally such a behavior can be achieved in two ways. The usage strongly depends
0738 on the use-case required by the client:
0739 \begin{enumerate}
0740 \item either the ideal geometry in memory is changed directly to 
0741       reflect the  measured geometry. This approach has the 
0742       disadvantage, that all measurement points on a daughter 
0743       volume can only be transformed to the global coordinate
0744       system using one single transformation. Time-dependent changes of 
0745       these transformations cannot be modeled. Hence, for multi-threaded
0746       systems this approach is of limited use. However, this is the 
0747       perfect approach to simulate distorted geometries. This approach 
0748       is naturally supported by the ROOT geometry toolkit.
0749 \item The second possibility is to not modify the ideal geometry in memory,
0750       but to provide instead transformations to move measured coordinates 
0751       to their correct place in space. This approach allows to keep 
0752       several - also time-dependent - transformations in memory. 
0753       Ideal to support multi-threaded data processing frameworks, 
0754       which become more and more popular.
0755 \end{enumerate}
0756 
0757 \noindent
0758 \DDA supports both possibilities as will be described in the following sections.
0759 
0760 
0761 
0762 \vspace{3cm}
0763 
0764 \newpage
0765 %=============================================================================
0766 \section{The Local Alignment Interface}
0767 \label{sec:ddalign-user-manual-ddalign-interface}
0768 %=============================================================================
0769 
0770 \noindent
0771 \DDA implements a machinery to apply and access the alignment parameters
0772 describing the difference between an ideal detector given by an ideal geometry
0773 and the geometry of the actually built assembly in real life.
0774 To ease its usage for the clients and to shield clients from the 
0775 internals when actually dealing with realigned geometries, a set of 
0776 helper classes was designed. The access to the alignment parameters 
0777 in read-only mode was separated from the import or export thereof.
0778 
0779 \noindent
0780 As a basic concept within \DDhep any {\it{sizable}} detector component
0781 can be realigned. {\it{Sizable}} as a rule of thumb is anything, which 
0782 is manufactured as an individual piece and which you may ''hold in your hands''.
0783 Such objects are also described by a $detector$ $element$ of type {\tt DetElement}.
0784 An example is e.g. a single silicon wafer of a tracking device or the entire
0785 tracking detector itself.
0786 The access to the alignment parameters is possible from each {\tt DetElement}
0787 instance as described in Section~\ref{sec:ddalign-user-manual-misalignment-access}.
0788 The interface assumes ''planar'' alignment parameters i.e. the shape of 
0789 a given volume does not change~\footnote{This is a restriction to the 
0790 possibilities provided by the ROOT implemetation~\cite{bib:ROOT-tgeo}
0791 based on experience~\cite{bib:chris-parkes-priv-comm}.
0792 If at a later time the need arises the provided alignment interface may 
0793 be extended to support shape changes.}.
0794 
0795 \noindent
0796 As mentioned earlier, in the local alignment \DDA allowed to retrieve 
0797 time dependent alignment parameters and transformations. This time
0798 dependency was relatively easy achieved by re-using the conditions 
0799 mechanism from \DDC. In this spirit Alignment transformations are 
0800 practically no different from conditions like temperatures, pressures etc.
0801 To access the $alignment$ $conditions$ clearly not only some 
0802 identifier must be provided, but also a $interval$ $of$ $validity$,
0803 which defines from which point in the past to which point in the future
0804 the required alignment constants may be applied.
0805 
0806 \noindent
0807 Please be aware that the extensive use of misalignments is highly memory
0808 consuming.
0809 
0810 \noindent
0811 %=============================================================================
0812 \subsection{Access to Alignment Parameters from the Detector Element}
0813 \label{sec:ddalign-user-manual-misalignment-access}
0814 %=============================================================================
0815 
0816 \noindent
0817 The $DetAlign$ class as shown in Figure~\ref{fig:dd4hep-detector-model}
0818 gives the user access to the alignment structure of type $Alignment$ as 
0819 illustrated in the following example:
0820 \begin{code}
0821     ConditionsSlice slice = ...  // Prepared slice containing all condiitons
0822     DetElement wafer_det  = ...  // Valid handle to a detector element
0823     DetAlign   wafer = wafer_det;
0824     Alignment  wafer_alignment = wafer.get();
0825     if ( wafer_alignment.isValid() )  {
0826         // This wafer's placement differs from the ideal geometry when
0827         // alignment parameters are present.
0828         
0829         // Access the misalignment transformation with respect to the parent volume:
0830         Transform3D tr = wafer_alignment.toMotherDelta();
0831     }
0832 \end{code}
0833 The access to details of an invalid alignment object results in a runtime 
0834 exception. The following calls allow clients to access alignment information
0835 from the $DetElement$ structure:
0836 \begin{code}
0837       /// Access to the actual alignment information
0838       Alignment alignment() const;
0839 
0840       /// Access to the survey alignment information
0841       Alignment surveyAlignment() const;
0842 \end{code}
0843 The call to $alignment()$ return the parameters $applied$ to the the existing
0844 ideal geometry. The call $surveyAlignment()$ returns optional constants used 
0845 to perform numerical calculations as described in 
0846 section~\ref{subsect:ddalign-intro-determine-alignment-params}.
0847 
0848 \noindent
0849 All functionality of the DetElement, which depends on applied alignment parameters
0850 are automatically updated in the event of changes. These are typically the geometry 
0851 transformations with respect to the mother- and the world volume:
0852 \begin{code}
0853       /// Create cached matrix to transform to world coordinates
0854       const TGeoHMatrix& worldTransformation() const;
0855 
0856       /// Create cached matrix to transform to parent coordinates
0857       const TGeoHMatrix& parentTransformation() const;
0858  
0859       /// Transformation from local coordinates of the placed volume to the world system
0860       bool localToWorld(const Position& local, Position& global) const;
0861 
0862       /// Transformation from local coordinates of the placed volume to the parent system
0863       bool localToParent(const Position& local, Position& parent) const;
0864 
0865       /// Transformation from world coordinates of the local placed volume coordinates
0866       bool worldToLocal(const Position& global, Position& local) const;
0867 
0868       /// Transformation from world coordinates of the local placed volume coordinates
0869       bool parentToLocal(const Position& parent, Position& local) const;
0870 \end{code}
0871 it is worth noting that the update of cached information is performed by the $DetElement$ 
0872 objects, other user defined cached information is {\bf{not}} updated. To update 
0873 user caches it is mandatory to provide a user defined update callback to the $DetElement$:
0874 \begin{code}
0875     template <typename Q, typename T> 
0876     void callAtUpdate(unsigned int type, Q* pointer, 
0877                       void (T::*pmf)(unsigned long typ, DetElement& det, void* opt_par)) const;
0878 \end{code}
0879 
0880 \noindent
0881 The interface of the $Alignment$ structure to access detector 
0882 alignment parameters is as follows (see also the corresponding header file DD4hep/Alignment.h):
0883 \begin{code}
0884       /// Number of nodes in this branch (=depth of the placement hierarchy from the top level volume)
0885       int numNodes() const;
0886       
0887       /// Access the placement of this node
0888       PlacedVolume placement()   const;
0889 
0890       /// Access the placement of the mother of this node
0891       PlacedVolume motherPlacement(int level_up = 1)   const;
0892 
0893       /// Access the placement of a node in the chain of placements for this branch
0894       PlacedVolume nodePlacement(int level=-1)   const;
0895 
0896       /// Access the currently applied alignment/placement matrix with respect to the world
0897       Transform3D toGlobal(int level=-1) const;
0898 
0899       /// Transform a point from local coordinates of a given level to global coordinates
0900       Position toGlobal(const Position& localPoint, int level=-1) const;
0901 
0902       /// Transform a point from global coordinates to local coordinates of a given level
0903       Position globalToLocal(const Position& globalPoint, int level=-1) const;
0904 
0905       /// Access the currently applied alignment/placement matrix with respect to mother volume
0906       Transform3D toMother(int level=-1) const;
0907 
0908       /// Access the currently applied alignment/placement matrix (mother to daughter)
0909       Transform3D nominal() const;
0910 
0911       /// Access the currently applied correction matrix (delta) (mother to daughter)
0912       Transform3D delta() const;
0913 
0914       /// Access the inverse of the currently applied correction matrix (delta) (mother to daughter)
0915       Transform3D invDelta() const;
0916 \end{code}
0917 \begin{itemize}\itemcompact
0918 \item The calls in line 3-8 allow access to the relative position of the $nth.$ element
0919     in the alignment stack with respect to its next level parent. 
0920     Element $numNodes()-1$ denotes the lowest level and element $0$ is the world 
0921     volume. The default argument $(-1)$ addresses the lowest placement in the hierarchy.
0922 \item Calls in line 9-12 allow to access/execute transformations from a given level
0923     in the placement hierarchy to coordinates in the top level volume (world).
0924 \item The call in line 14 allows to transform a global coordinate to the local coordinate
0925     system in a given level of the hierarchy.
0926 \item The call $toMother$ in line 16 returns the local transformation of the node at
0927     a given level to the mother's coordinate system.
0928 \item The calls in line 17-20 give access to the nominal placement matrix of the realigned
0929     node with respect to the parent volume and the changes thereof.
0930 \end{itemize}
0931 Besides these convenience calls the full interface to the class {\tt TGeoPhysicalNode}, 
0932 which implements in the ROOT geometry package alignment changes, is accessible 
0933 from the $Alignment$ handle using the overloaded $operator->()$.
0934 Further documentation is available directly from the \tgeo{TGeoPhysicalNode}{ROOT site}.
0935 
0936 \noindent
0937 %=============================================================================
0938 \subsection{Manipulation of Alignment Parameters}
0939 \label{sec:ddalign-user-manual-misalignment-manip}
0940 %=============================================================================
0941 There are multiple possibilities to apply alignment parameters:
0942 \begin{itemize}\itemcompact
0943 \item The pedestrian way ''by hand'' using C++ as described in 
0944     Subsection~\ref{sec:ddalign-user-manual-misalignment-manip-cxx}
0945 \item Loading a whole set of misalignment constants from XML, the ''poor man's'' database.
0946     This mechanism is described in
0947     Subsection~\ref{sec:ddalign-user-manual-misalignment-manip-xml}
0948 \item Loading a whole set of misalignment constants from a database.
0949     This possibility depends heavily on the database and its schema used.
0950     A typical use case is to load misalignment constants depending on the
0951     experiment conditions at the time the event data were collected.
0952     \DDA does not provide an implementation.
0953     This possibility here is only mentioned for completeness and will be subject 
0954     to further developments to support conditions in \DDhep. 
0955 \end{itemize}
0956 
0957 \noindent
0958 %=============================================================================
0959 \subsubsection{Manipulation of Alignment Parameters for Pedestrians using C++}
0960 \label{sec:ddalign-user-manual-misalignment-manip-cxx}
0961 %=============================================================================
0962 \noindent
0963 In this section we describe how to apply geometry imperfections to an existing 
0964 detector geometry in memory using {\tt C++}. To apply misalignment to an existing
0965 geometry two classes are collaborating, the {\tt AlignmentCache} attached to
0966 the geometry container {\tt Detector} and a temporary structure the {\tt AlignmentStack}.
0967 The {\tt AlignmentCache} allows to access all existing alignment entries 
0968 based on their subdetector.
0969 The {\tt AlignmentStack} may exist in exactly one instance and is used to
0970 insert a consistent set of alignment entries. Consistency is important because
0971 changes may occur at any hierarchical level and internal transformation caches
0972 of the ROOT geometry package must be revalidated for all branches containing
0973 a higher level node.
0974 {\bf For this reason it is highly advisable to apply realignment constants 
0975 for a complete subdetector.}
0976 Note that this restriction is not imposed, in principle a consistent set 
0977 of misalignments may be applied at any level of the geometry hierarchy.
0978 
0979 \noindent
0980 Though the application of alignment is much simpler using XML files, the following
0981 description should give an insight on the mechanisms used behind the scene and
0982 to understand the concept.
0983 
0984 \noindent
0985 Any manipulations are transaction based must be embraced by the following two calls
0986 opening and closing a transaction:
0987 \begin{code}
0988 // Required include file(s)
0989 #include "DDAlign/AlignmentCache.h"
0990 
0991     Detector& detector = ....;
0992     AlignmentCache* cache = detector.extension<Geometry::AlignmentCache>();
0993 
0994     // First things first: open the transaction.
0995     cache->openTransaction();
0996 
0997     // Prepare the entry containing the alignment data
0998     AlignmentStack::StackEntry* entry =  .....;
0999     //.... and add the element to the AlignmentStack .....
1000     AlignmentStack::insert(entry);
1001 
1002     // Finally close the transaction. At this moment the changes are applied.
1003     cache->closeTransaction();
1004 \end{code}
1005 In the following we describe the mechanism to create and prepare the 
1006 {\tt StackEntry} instances of the above code snippet. The calls to open and close
1007 the alignment transaction do not have to be in the same code fragment where also
1008 the alignment entries are prepared. However, all changes are only applied when 
1009 the transaction is closed. The alignment entries do not necessarily have to 
1010 be prepared in the sequence of the hierarchy they should be applied, internally
1011 the entries are re-ordered and follow the geometry hierarchy top to bottom
1012 i.e. mother volumes are always re-aligned {\it\bf before} the daughters 
1013 are re-aligned.
1014 
1015 \noindent
1016 The {\tt StackEntry} instances carry all information to apply the re-alignment 
1017 of a given volume. This information contains:
1018 \begin{itemize}\itemcompact
1019 \item The transformation matrix describing the positional change of the volume
1020     with respect to its mother volume.
1021 \item The placement path of the volume to be realigned.
1022 \item A flag to reset the volume to its ideal position {\it\bf before} the 
1023     change is applied.
1024 \item A flag to also reset all daughter volumes to their 
1025     ideal position {\it\bf before} the change is applied.
1026 \item A flag to check for overlaps after the application of the change and
1027 \item the actual precision used to perform this check.
1028 \end{itemize}
1029 
1030 \noindent
1031 The {\tt ROOT::Math} library provides several ways to construct the required
1032 3D transformation as described in Section~\ref{subsect:ddalign-intro-aligments}:
1033 \begin{code}
1034 // Required include file(s)
1035 #include "DD4hep/Objects.h"
1036 
1037     Position      trans(x_translation, y_translation, z_translation);
1038     RotationZYX   rot  (z_angle, y_angle, x_angle);
1039     Translation3D pivot(x_pivot, y_pivot, z_pivot);
1040 
1041     Transform3D trafo;
1042     /// Construct a 3D transformation for a translation and a rotation around a pivot point:
1043     trafo = Transform3D(Translation3D(trans)*pivot*rot*(pivot.Inverse()));
1044 
1045     /// Construct a 3D transformation for a translation and a rotation around the origin
1046     trafo = Transform3D(rot,pos);
1047 
1048     /// Construct a 3D transformation for a rotation around a pivot point
1049     trafo = Transform3D(piv*rot*(piv.Inverse()));
1050 
1051     /// Construct a 3D transformation for a rotation around the origin
1052     trafo = Transform3D(rot);
1053 
1054     /// Construct a 3D transformation for simple translation
1055     trafo = Transform3D(pos);
1056 
1057 \end{code}
1058 
1059 \noindent
1060 The following code snippet shows how to extract this information from the
1061 {\tt DetElement} and prepare such a {\tt StackEntry} instance:
1062 \begin{code}
1063 // Required include file(s)
1064 #include "DDAlign/AlignmentStack.h"
1065 
1066     // Prepare the entry containing the alignment data
1067     typedef AlignmentStack::StackEntry Entry;
1068     /// Detector element to be realigned
1069     DetElement element = ...;
1070     /// The transformation describing the relative change with respect to the mother volume
1071     Transform3D trafo = ...;
1072     /// Instantiate a new alignment entry
1073     Entry* entry = new Entry(element);
1074     entry->setTransformation(trafo)                         // Apply the transformation matrix
1075         .applyReset(/* argument default: true */)           // Set the reset flag
1076         .applyResetChildren(/* argument default: true */)   // Set the daughter reset flag
1077         .checkOverlaps(/* argument default: true */)        // Set flag to check overlaps
1078         .overlapPrecision(0.001/mm);                        // With this precision in mm
1079 
1080     /// Now add the entry to the alignment stack:
1081     AlignmentStack::insert(entry);
1082 \end{code}
1083 The constructor will automatically determine the volumes placement path
1084 from the {\tt DetElement}. Then the transformation is applied and the flags
1085 to reset the volume, its children and to trigger the overlap checks with 
1086 the given precision.
1087 
1088 \noindent
1089 When passing the entry to the {\tt AlignmentStack} the {\tt AlignmentStack}
1090 takes ownership and subsequently the entry is deleted after being applied to
1091 the geometry. For further shortcuts in the calling sequence please consult the
1092 {\tt AlignmentStack} header file.
1093 
1094 
1095 
1096 \newpage
1097 %=============================================================================
1098 \begin{thebibliography}{9}
1099 \bibitem{bib:DD4hep} M. Frank et al, "DD4hep: A Detector Description Toolkit 
1100                 for High Energy Physics Experiments",
1101                 International Conference on Computing in High Energy and Nuclear Physics  
1102                 (CHEP 2013), \\
1103                 Amsterdam, Netherlands, 2013, proceedings.
1104 
1105 \bibitem{bib:LHCb-geometry} S. Ponce et al., 
1106                 "Detector Description Framework in LHCb", 
1107                 International Conference on Computing in High Energy and Nuclear Physics  (CHEP 2003), 
1108                 La Jolla, CA, 2003, proceedings. 
1109 \bibitem{bib:chris-parkes-priv-comm} C. Parkes, private communications.
1110 \bibitem{bib:DDG4} M.Frank, "DDG4 - A Simulation Toolkit for High Energy 
1111                 Physics Experiments using Geant4 \\
1112                 and the DD4hep Geometry Description".
1113 \bibitem{bib:ROOT-tgeo} R.Brun, A.Gheata, M.Gheata, "The ROOT geometry package",\\
1114                     Nuclear Instruments and Methods {\bf{A}} 502 (2003) 676-680.
1115 \bibitem{bib:geant4}  S. Agostinelli et al., 
1116                    "Geant4 - A Simulation Toolkit", \\
1117                     Nuclear Instruments and Methods {\bf{A}} 506 (2003) 250-303.
1118 \bibitem{bib:DDCond} M.Frank, "DDCond -- Conditions Support for the DD4hep Geometry Description Toolkit".
1119 
1120 \end{thebibliography}
1121 %=============================================================================
1122 \end{document}