1 | % ESAF User Guide |
---|
2 | % $Id: RecoCode.tex 1034 2004-09-17 17:04:57Z thea $ |
---|
3 | % M.Pallavicini, A. Thea - created |
---|
4 | |
---|
5 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
6 | % reco code |
---|
7 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
8 | |
---|
9 | \section{The Reconstruction code} |
---|
10 | %\addcontentsline{toc}{section}{The Reconstruction code} |
---|
11 | |
---|
12 | \subsection{Overview} |
---|
13 | %\addcontentsline{toc}{subsection}{Overview} |
---|
14 | \label{sec:over} |
---|
15 | |
---|
16 | In this section we describe the structure of the Reco code. The logic here |
---|
17 | is slightly different from the previous section, because even normal user must |
---|
18 | have a good understanding of the Reconstruction framework in order to use |
---|
19 | it efficiently. Therefore, some more insight of the internal structure of |
---|
20 | the framework is given, even if Rule number 0 of the software developer should |
---|
21 | always be remembered: the only document that is always up to date is the code! |
---|
22 | |
---|
23 | The proposed scheme for the organization of the \esaf{} reconstruction module |
---|
24 | is sketched in figure~\ref{fig:recoscheme}. Input data comes either from |
---|
25 | the simulation module (Root file) or from the real data stream (pre-processed |
---|
26 | telemetry)\footnote{Right now, only data input from simulation \ROOT file |
---|
27 | is available}. |
---|
28 | |
---|
29 | From this figure, the following basic entities/structures can be |
---|
30 | identified: |
---|
31 | |
---|
32 | \begin{itemize} |
---|
33 | |
---|
34 | \item |
---|
35 | Input module |
---|
36 | |
---|
37 | This modules handles the reading of the events for reconstruction. Foreseen |
---|
38 | are the reading of a Root simulation file (already supported) and the |
---|
39 | reading of events from the real data stream (pre-processed telemetry). |
---|
40 | |
---|
41 | \item |
---|
42 | Event container |
---|
43 | |
---|
44 | This is the container structure for the input event which we are going to |
---|
45 | reconstruct. |
---|
46 | The event container will allow the access the objects holding: event header |
---|
47 | information, trigger information and readout information at macrocell and |
---|
48 | pixel level. In principle the available information should correspond |
---|
49 | exactly to the one available in real data, although test modes in which |
---|
50 | the ``Monte Carlo truth'' is available are also foreseen. |
---|
51 | |
---|
52 | \item |
---|
53 | Reconstruction framework |
---|
54 | |
---|
55 | This is the main structure, which actually builds the chain of modules which |
---|
56 | will reconstruct the event. Event reconstruction is divided into different |
---|
57 | tasks (e.g. direction reconstruction, energy reconstruction, ...) and for |
---|
58 | each task different possible modules may be available. |
---|
59 | The use of a structure allows to easily replace or exclude a given processing |
---|
60 | module. |
---|
61 | In this way different algorithms or algorithm combinations can be compared |
---|
62 | and tests can be performed. |
---|
63 | |
---|
64 | \item |
---|
65 | Modules |
---|
66 | |
---|
67 | This is the set of processing modules, possibly several alternative modules |
---|
68 | for each specific task, that can actually be picked by the user and included in |
---|
69 | the reconstruction chain build by the framework. |
---|
70 | |
---|
71 | \item |
---|
72 | Configuration files |
---|
73 | |
---|
74 | Configuration data includes the name and location of the input file and |
---|
75 | the definition of the processing modules to load. |
---|
76 | |
---|
77 | The configuration definition in \Reco{} is rather simple for the user point of |
---|
78 | view but corresponds to a relatively complex implementation (see below). It allows to change |
---|
79 | the base directory for all configuration files, thus allowing to define and use |
---|
80 | different full configurations stored in different places. |
---|
81 | |
---|
82 | The reconstruction uses the files stored in \code{config/Reco} directory. |
---|
83 | |
---|
84 | \item |
---|
85 | Access to databases |
---|
86 | |
---|
87 | Access to databases will be a major issue in \Reco{}. The reconstruction |
---|
88 | procedure will naturally require the access to a run conditions database, as |
---|
89 | well as to the detector calibration database. Furthermore, access to |
---|
90 | atmospheric data (both collected by the EUSO atmospheric sounding devices or |
---|
91 | originating from external sources and databases) will have to be accessed. |
---|
92 | |
---|
93 | This part of the code is, at this early stage, not yet implemented. |
---|
94 | See below (future developments) for more information. |
---|
95 | |
---|
96 | \end{itemize} |
---|
97 | |
---|
98 | This structure is shown in the interactions diagram in figure~\ref{fig:objdiag}. |
---|
99 | |
---|
100 | \subsection{Class structure} |
---|
101 | %\addcontentsline{toc}{subsection}{Class structure} |
---|
102 | |
---|
103 | The basic class diagram of \Reco{} as its present stage is schematically |
---|
104 | shown in figure~\ref{fig:classdiag}. |
---|
105 | |
---|
106 | The different basic ``groups'' in the above classification |
---|
107 | are shown in different colours. The scheme is described in the sections |
---|
108 | below, where some design and implementation aspects are presented. |
---|
109 | |
---|
110 | \subsubsection{Input} |
---|
111 | %\addcontentsline{toc}{subsubsection}{Input} |
---|
112 | |
---|
113 | There is an abstract interface \code{InputModule} from which are built |
---|
114 | the different concrete input classes. The existing concrete classes are |
---|
115 | \code{RootInputModule} (for simulation file reading) and \code{TestInputModule} |
---|
116 | (for test purposes only, not to be used by normal users). |
---|
117 | |
---|
118 | \subsubsection{Event} |
---|
119 | %\addcontentsline{toc}{subsubsection}{Event} |
---|
120 | |
---|
121 | The main class is the event container, \code{RecoEvent}. The event header is |
---|
122 | stored separately in a RecoEventHeader class. For each \code{RecoEvent} a \code{RecoEventHeader} |
---|
123 | is required. Event information is kept in the objects \code{RecoCellHit}, with macrocell |
---|
124 | level information (this is the class defining a hit), |
---|
125 | \code{RecoPixelData}, a generalisation of the previous one containing |
---|
126 | pixel level information. Furthermore, \code{RecoCellInfo} contains trigger and |
---|
127 | macrocell level information and \code{RecoAnalogData} holds analog readout |
---|
128 | information and \code{RecoPhotoElectronData} contains informations about the photoelectrons for test and debugging. |
---|
129 | |
---|
130 | \subsubsection{Framework} |
---|
131 | %\addcontentsline{toc}{subsubsection}{Framework} |
---|
132 | |
---|
133 | The \emph{framework} is responsible for creating a \emph{factory} which will |
---|
134 | generate \emph{modules} according to pre-defined models. Different module types |
---|
135 | can be selected/unselected. One and only one input module should exist. |
---|
136 | |
---|
137 | The central class is the \code{RecoFramework} class, which will create a \emph{factory}, |
---|
138 | \code{ModuleFactory}, able to generate modules according to a given model. |
---|
139 | \code{RecoModule} is the abstract interface from which are built the different concrete |
---|
140 | classes defining the different types of modules. \code{TestRecoModule} is an example |
---|
141 | concrete implementation. \code{RecoSequence} is meant to define a special type of |
---|
142 | composite module. |
---|
143 | |
---|
144 | |
---|
145 | \subsubsection{Modules} |
---|
146 | %\addcontentsline{toc}{subsubsection}{Modules} |
---|
147 | |
---|
148 | A set of modules will be available for the different reconstruction tasks. |
---|
149 | As an example, a basic clustering algorithm is implemented in the class |
---|
150 | \code{BaseClusteringModule}, which, just like \code{TestRecoModule}, inherits from |
---|
151 | the abstract interface \code{RecoModule}. This section of the code is currently |
---|
152 | being implemented, the diagram corresponds to the status on January 23$^{rd}$. |
---|
153 | |
---|
154 | |
---|
155 | \subsubsection{Configuration and utilities} |
---|
156 | %\addcontentsline{toc}{subsubsection}{Configuration and utilities} |
---|
157 | |
---|
158 | In this category are included different software tools of interest for both |
---|
159 | the simulation and the reconstruction parts of \esaf{}. This includes code |
---|
160 | for the following purposes: |
---|
161 | configuration handling, object persistency (\ROOT{}), graphic user interface, |
---|
162 | basic data and mathematical procedures (units, constants, random number |
---|
163 | handling, time/orbit info, ISS time/orbit description...), atmosphere description. |
---|
164 | As seen in the diagram, |
---|
165 | at present configuration handling is already implemented and can serve here as an |
---|
166 | example: |
---|
167 | \code{EusoConfigurable} is the abstract interface that should be used by all classes |
---|
168 | that need to access configuration data, in order to create \code{Config}, a singleton object |
---|
169 | in which the relevant information is stored. |
---|
170 | All the classes that need to access configuration data should inherit from |
---|
171 | \code{EusoConfigurable} |
---|
172 | (and call in their definition the macro \code{EusoConfigurable(type,name)}. |
---|
173 | The method \code{Conf()} returns a pointer to |
---|
174 | a \code{ConfigFileParser} object that contains all the parameter values |
---|
175 | (identifies the file containing the configuration parameters |
---|
176 | for the object considered, parses the file, and stores the parname=parvalue |
---|
177 | pairs in maps). |
---|
178 | The \code{ConfigFileParser} objects are created by a factory, \code{Config}, This object is a |
---|
179 | singleton. |
---|
180 | |
---|
181 | |
---|
182 | \subsection{Time sequence} |
---|
183 | %\addcontentsline{toc}{subsection}{Time sequence} |
---|
184 | |
---|
185 | This section presents a rough and simple-minded temporal sequence view of the control flow |
---|
186 | and object interaction during and \Reco{} test run. |
---|
187 | The purpose is to clarify the ideas and provide the reader with a simple picture |
---|
188 | of how it works. A schematic representation is given in figure~\ref{fig:seqdiag}. |
---|
189 | In the description below, the pure object lifecycle view is here mixed with a more code-oriented |
---|
190 | description of the program flow (usually given in parentheses). |
---|
191 | |
---|
192 | \begin{itemize} |
---|
193 | |
---|
194 | \item |
---|
195 | Building the Framework: |
---|
196 | |
---|
197 | \begin{enumerate} |
---|
198 | |
---|
199 | \item |
---|
200 | A \code{RecoFramework} object is created (\code{RecoFramework} constructor called in \code{reco-main.cc}): |
---|
201 | |
---|
202 | \begin{displaycode} |
---|
203 | RecoFramework theFrameWork; |
---|
204 | \end{displaycode} |
---|
205 | \item get name of the file with module list and read module list (within \code{RecoFramework} constructor); |
---|
206 | \begin{displaycode} |
---|
207 | string sName = Conf()->getStr("RecoFramework.ModuleFile"); |
---|
208 | sName = "./config/Reco/"+sName; |
---|
209 | \end{displaycode} |
---|
210 | |
---|
211 | \item create factory object \code{ModuleFactory} and build module (within |
---|
212 | \code{RecoFramework} constructor, calling \code{ModuleFactory} constructor with |
---|
213 | module list as arguments. In there, modules are built using the |
---|
214 | \code{MakeModule()}, \code{MakeInputModule()} methods of the |
---|
215 | \code{ModuleFactory}). |
---|
216 | \begin{displaycode} |
---|
217 | // build factory |
---|
218 | ModuleFactory factory( sName ); |
---|
219 | |
---|
220 | // build modules |
---|
221 | if ( identifier == "InputModule" ) { |
---|
222 | MakeInputModule(name); |
---|
223 | } |
---|
224 | else if ( identifier == "Module" ) { |
---|
225 | MakeModule( name ); |
---|
226 | } |
---|
227 | else if ( identifier == "Sequence" ) { |
---|
228 | MakeSequence( name ); |
---|
229 | } |
---|
230 | else { |
---|
231 | throw runtime_error("Syntax error in file" |
---|
232 | +sName+" line "+dummy); |
---|
233 | } |
---|
234 | \end{displaycode} |
---|
235 | |
---|
236 | \end{enumerate} |
---|
237 | |
---|
238 | \item |
---|
239 | Executing the module chain: |
---|
240 | |
---|
241 | \begin{enumerate} |
---|
242 | |
---|
243 | \item |
---|
244 | Call \code{Execute()} method of \code{RecoFramework} (back to main, perform |
---|
245 | some information dump and then execute framework); |
---|
246 | \begin{displaycode} |
---|
247 | theFrameWork.Dump(); |
---|
248 | theFrameWork.ParseCommandLine(argc,argv); |
---|
249 | try { |
---|
250 | theFrameWork.Execute(); |
---|
251 | } |
---|
252 | catch( exception &e ) { |
---|
253 | cerr << "RECO Error: " << e.what() << endl; |
---|
254 | cerr << "Euso Reco Program Exiting" << endl; |
---|
255 | exit(1); |
---|
256 | } |
---|
257 | \end{displaycode} |
---|
258 | |
---|
259 | |
---|
260 | \item |
---|
261 | initialize input module and the other modules (\code{Init()} methods of |
---|
262 | \code{TestInputModule} and \code{TestRecoModule} classes); |
---|
263 | |
---|
264 | \begin{displaycode} |
---|
265 | // init input module |
---|
266 | fInputModule->Init(); |
---|
267 | |
---|
268 | // init all modules |
---|
269 | for( it = fModules.begin(); it != fModules.end(); it++) { |
---|
270 | if ( ! it->second->Init() ) { |
---|
271 | cerr << "Module " << it->first << " failed\n"; |
---|
272 | throw runtime_error("Init failed"); |
---|
273 | } |
---|
274 | \end{displaycode} |
---|
275 | |
---|
276 | \item |
---|
277 | get event into a \code{RecoEvent} object (a \code{RecoEvent} object is created |
---|
278 | and the \code{GetEvent}() method of \code{TestInputModule} is invoked); |
---|
279 | |
---|
280 | \begin{displaycode} |
---|
281 | // run |
---|
282 | while ( RecoEvent *anEvent = fInputModule->GetEvent() ) { |
---|
283 | \end{displaycode} |
---|
284 | |
---|
285 | \item |
---|
286 | process the event through each module (the methods \code{PreProcess()}, |
---|
287 | \code{Process()} and \code{PostProcess()} of TestRecoModule are invoked); |
---|
288 | |
---|
289 | \begin{displaycode} |
---|
290 | for( it = fModules.begin(); it != fModules.end(); it++) { |
---|
291 | if ( ! it->second->PreProcess() ) |
---|
292 | break; |
---|
293 | if ( ! it->second->Process( anEvent ) ) |
---|
294 | break; |
---|
295 | if ( ! it->second->PostProcess() ) |
---|
296 | break; |
---|
297 | } |
---|
298 | \end{displaycode} |
---|
299 | |
---|
300 | \item |
---|
301 | destroy the event (method \code{DestroyEvent()} of \code{TestInputModule}); |
---|
302 | |
---|
303 | \begin{displaycode} |
---|
304 | fInputModule->DestroyEvent(); |
---|
305 | \end{displaycode} |
---|
306 | |
---|
307 | \item |
---|
308 | done with all modules (\code{Done()} methods of input and other modules). |
---|
309 | |
---|
310 | \begin{displaycode} |
---|
311 | // end all modules |
---|
312 | fInputModule->Done(); |
---|
313 | for( it = fModules.begin(); it != fModules.end(); it++) { |
---|
314 | it->second->Done(); |
---|
315 | } |
---|
316 | \end{displaycode} |
---|
317 | |
---|
318 | \end{enumerate} |
---|
319 | |
---|
320 | Procedures 1 to 5 are obviously repeated for each event, and persistency is |
---|
321 | handled before the event is destroyed. |
---|
322 | |
---|
323 | \end{itemize} |
---|
324 | |
---|