source: JEM-EUSO/esaf_lal/tags/v1_r0/esafdoc/UserGuide/RecoCode.tex @ 117

Last change on this file since 117 was 117, checked in by moretto, 11 years ago

ESAF version compilable on mac OS

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