source: Sophya/trunk/SophyaLib/Manual/sophya.tex@ 1299

Last change on this file since 1299 was 1299, checked in by ansari, 25 years ago

ecriture documentation sophya.tex - commit depuis mac Reza 8/11/2000

File size: 13.6 KB
Line 
1\documentclass[twoside,11pt]{article}
2% Package standard : Utilisation de caracteres accentues, mode francais et graphique
3\usepackage{url}
4\usepackage[latin1]{inputenc}
5\usepackage[T1]{fontenc}
6\usepackage[english]{babel}
7\usepackage{graphicx}
8% package a mettre pour faire du pdf
9\usepackage{palatino}
10
11% Extension de symboles mathematiques
12\usepackage{amssymb}
13
14% Definition pour Docs Sophya
15\usepackage{defsophya}
16
17
18
19\begin{document}
20
21\begin{titlepage}
22% The title page - top of the page with the title of the paper
23\titrehp{Sophya \\ An overview }
24% Authors list
25\auteurs{
26R. Ansari & ansari@lal.in2p3.fr \\
27G. Le Meur & lemeur@lal.in2p3.fr \\
28C. Magneville & cmv@hep.saclay.cea.fr \\
29S. Henrot-Versille & versille@in2p3.fr
30}
31% \auteursall
32% The title page - bottom of the page with the paper number
33\titrebp{1}
34\end{titlepage}
35
36\tableofcontents
37
38\newpage
39
40\section{Introduction}
41
42 {\bf SOPHYA} ({\bf SO}ftware for {\bf PHY}sics {\bf A}nalysis)
43is a collection of C++ classes designed for numerical and
44physics analysis software development. Our goal is to provide
45easy to use, yet powerful classes which can be used by scientists.
46We have decided to use as much as possible available
47numerical analysis libraries, encapsulating them whenever
48possible.
49
50 The SOPHYA design and implementation has been carried out
51with the specific goal of providing the general framework for
52the Planck-HFI data processing software. However, most of the
53packages presented here have a more general scope than the CMB analysis
54and Planck surveyor mission problem.
55 The source directory tree
56\footnote{ CVS server: cvsserver.lal.in2p3.fr:/projects/Eros/CVSEros}
57is organised into a number of modules.
58
59\begin{itemize}
60\item[] {\bf Mgr/} Scripts for code management,
61makefile generation and software installation
62\item[] {\bf SysTools/} General architecture support classes such
63as {\tt PPersist, NDataBlock<T>}, and few utility classes
64({\tt DataCard, DVList} \ldots).
65\item[] {\bf TArray/} template numerical arrays, vectors and matrices
66({\tt PixelMap<T> SphericalMap<T>} \ldots)
67\item[] {\bf NTools/} Some standard numerical analysis tools
68(linear, and non linear parameter fitting, FFT, \ldots)
69\item[] {\bf HiStats/} Histogram-ming and data set handling classes \\
70({\tt Histo Histo2D NTuple XNTuple} \ldots)
71\end{itemize}
72
73The modules listed below are more tightly related to the
74CMB (Cosmic Microwave Background) data analysis problem:
75\begin{itemize}
76\item[] {\bf SkyMap/} Local and full sky maps, and few geometry
77handling utility classes. \\
78({\tt PixelMap<T>, LocalMap<T>, SphericalMap<T>, \ldots})
79\item[] {\bf SkyT/}
80classes for spectral emission and detector frequency response modelling \\
81({\tt SpectralResponse, RadSpectra, BlackBody} \ldots)
82\item[] {\bf Samba/} few classes for map and TOD analysis.
83\item[] {\bf PMixer/} skymixer and related programs
84\end{itemize}
85
86The following modules contain the interface classes with
87external libraries:
88\begin{itemize}
89\item[] {\bf FitsIOServer/} Classes for handling file input-output
90in FITS format using the cfitsio library.
91\item[] {\bf LinAlg/} Interface with Lapack linear algebra package
92\item[] {\bf IFFTW/} Interface with FFTW package
93\end{itemize}
94
95Other modules:
96\begin{itemize}
97\item[] {\bf Tests/} Simple test programs
98\item[] {\bf ProgPI/} interactive analysis tool - It should be noted that
99this module uses the SOPHYA class library and is based on {\bf PI}
100which is a C++ library defining a complete GUI program
101architecture. An additional module (PIext) define the interactive
102analysis program framework and the interfaces with the objects
103in SOPHYA. The {\bf PI/} \footnote{the PI package documentation
104is available from {\bf http://www.lal.in2p3.fr/recherche/eros/PeidaDoc/} }
105and {\bf PIext/} modules are not currently part
106of the SOPHYA CVS structure.
107\end{itemize}
108
109\newpage
110
111\section{Using Sophya}
112Two environment variables {\bf DPCBASEREP} and {\bf EROSCXX} are used
113to define the path where the Sophya libraries and executable are installed.
114{\bf DPCBASEREP} defines the base directory path and {\bf EROSCXX} the
115name of the C++ compiler. The complete path is built using {\bf DPCBASEREP},
116the operating system name (as obtained by the {\tt uname} command), and
117the compiler name. In the example below, we show the complete path
118for a {\tt Linux} system, using the GNU g++ compiler:
119
120\begin{itemize}
121\item \$DPCBASEREP/Include : Include (.h) files
122\item \$DPCBASEREP/Linux-g++/Libs : Path for the archive libraries (.a)
123\item \$DPCBASEREP/Linux-g++/ShLibs : Shared library path (.so)
124\item \$DPCBASEREP/Linux-g++/Exec : Executable file path
125\end{itemize}
126
127In order to use the shared libraries, the {\bf LD\_LIBRARY\_PATH} variable
128should contain the Sophya shared library path
129({\tt \$DPCBASEREP/Linux-g++/ShLibs } when using g++ compiler on Linux)
130
131The file {\tt \$DPCBASEREP/Include/MakefileUser.h} defines the compilation
132flags and the list of Sophya libraries. It should be included in the
133user's makefile. The default compilation rules assumes that the object (.o)
134and executable files would be put in the following diretories: \\
135{\tt \$HOME/`uname`-\$EROSCXX/Objs} \\
136{\tt \$HOME/`uname`-\$EROSCXX/Exec}.
137In the case of a {\tt Linux} system and using {\tt g++} as the C++ compiler,
138these two directories would be translated to \\
139{\tt \$HOME/Linux-g++/Objs} and {\tt \$HOME/Linux-g++/Exec}.
140The GNU make program should be used.
141\par
142The file {\tt \$DPCBASEREP/Include/makefile\_auto} defines the rules to compile
143a given source program, and link it against the Sophya libraries to produce
144an executable. The example below shows the steps to compile a program named
145{\tt trivial.cc }.
146\begin{verbatim}
147csh> cp \$DPCBASEREP/Include/makefile_auto makefile
148csh> make trivial
149\end{verbatim}
150This command should compile the {\tt trivial.cc} file,
151and link it against the sophya libraries. The object and executable
152file names are: \\
153{\tt \$HOME/`uname`-\$EROSCXX/Objs/trivial.o} \\
154{\tt \$HOME/`uname`-\$EROSCXX/Exec/trivial}.
155\par
156The file {\tt \$DPCBASEREP/Include/makefile\_example} provides another
157example makefile.
158
159Basic usage of Sophya classes are described in in the following sections.
160Complete Sophya documentation can be found at our web site: \\
161{\bf http://hfi-l2.in2p3.fr}.
162
163
164\section{Module SysTools}
165
166{\bf SysTools} contains utility classes such as {\tt DataCards} or
167{\tt DVlist}, an hierarchy of exception classes for Sophya, a template
168class {\tcls{NDataBlock}} for handling reference counting on numerical
169arrays, as well as classes providing the services for implementing simple
170serialization.
171\vspace*{5mm}
172
173\begin{figure}[hbt]
174\dclsa{PPersist}
175\dclsbb{PIOPersist}{PInPersist}
176\dclsb{POutPersist}
177\caption{partial class diagram for classes handling persistence in Sophya}
178\end{figure}
179
180\subsection{Using DataCards}
181The {\bf DataCards} class can be used to read parameters from a file.
182Each line in the file starting with \@ defines a set of values
183associated with a keyword. In the example below, we read the
184parameters corresponding with the keyword {\tt SIZE} from the
185file {\tt ex.d}. We suppose that {\tt ex.d} contains the line: \\
186{\tt @SIZE 400 250} \\
187\begin{verbatim}
188#include "datacards.h"
189// ...
190// Initializing DataCards object dc from file ex.d
191DataCards dc( "ex.d" );
192// Getting the first and second parameters for keyword size
193// We define a default value 100
194int size_x = dc.IParam("SIZE", 0, 100);
195int size_y = dc.IParam("SIZE", 1, 100);
196cout << " size_x= " << size_x << " size_y= " << size_y << endl;
197\end{verbatim}
198
199\subsection{Dynamic linker}
200The class {\bf PDynLinkMgr} can be used for managing shared libraries
201at run time. The example below shows the run time linking of a function:\\
202{\tt extern "C" { void myfunc(); } } \\
203\begin{verbatim}
204#include "pdlmgr.h"
205// ...
206string soname = "mylib.so";
207string funcname = "myfunc";
208PDynLinkMgr dyl(soname);
209DlFunction f = dyl.GetFunction(funcname);
210if (f != NULL) {
211// Calling the function
212 f();
213}
214\end{verbatim}
215
216\section{Module TArray}
217{\bf TArray} module contains template classes for handling standard
218operations on numerical arrays. Using the class {\tt \tcls{TArray} },
219it is possible to create and manipulate up to 5-dimension numerical
220arrays {\tt (int, float, double, complex, \ldots)}.
221
222\begin{figure}[hbt]
223\dclsccc{AnyDataObj}{BaseArray}{\tcls{TArray}}
224\ldots \\
225\dclsccc{\tcls{TArray}}{\tcls{TMatrix}}{\tcls{TVector}}
226\caption{partial class diagram for arrays, matrices and vectors}
227\end{figure}
228
229\subsection{Using arrays}
230
231\newpage
232
233\section{Module HiStats}
234\begin{figure}[hbt]
235\dclsccc{AnyDataObj}{Histo}{HProf}
236\dclsbb{AnyDataObj}{Histo2D}
237\dclsbb{AnyDataObj}{Ntuple}
238\dclsb{XNtuple}
239\caption{partial class diagram for histograms and ntuples}
240\end{figure}
241
242\section{Module SkyMap}
243
244\section{Module NTools}
245
246\section{Module Samba}
247
248\section{Module SkyT}
249
250
251
252\section{Building and installing Sophya}
253Presently, the Sophya library compilation has been tested with the following
254compiler/platform pairs:
255
256\begin{center}
257\begin{tabular}{ll}
258Compaq/DEC OSF1 & cxx (6.0 , 6.2) \\
259Linux & g++ (2.91 , 2.95) \\
260Linux & KCC (3.4) \\
261Solaris & g++ (2.95) \\
262SGI IRIX64 & CC \\
263\end{tabular}
264\end{center}
265
266Some of the modules in the Sophya package uses external libraries. The
267{\bf FitsIOServer} is the example of such a module, where the {\tt libcfitsio.a}
268is used.
269The build procedure expects to find the include files and the libraries in: \\
270{\tt \$EXTLIBDIR/Include/FitsIO } \\
271{\tt \$EXTLIBDIR/`uname`-\$EROSCXX/Libs} \\
272
273The object files from a given Sophya module are grouped in an archive library
274with the module's name ({\tt libmodulename.a}). All Sophya modules
275 are grouped in a single shared library ({\tt libsophya.so}), while the
276modules with reference to external libraries are grouped in
277({\tt libextsophya.so}). The {\bf PI} and {\bf PIext} modules are
278grouped in ({\tt libPI.so}).
279
280The environment variables {\bf DPCDEVREP}, {\bf EXTLIBDIR} and {\bf EROSCXX}
281must be defined in order to install the Sophya package.
282In the example below, we assume that we want to install Sophya from a
283released (tagged) version in the source directory {\tt \$SRC} in the
284{\tt /usr/local/Sophya} diretory, using {\tt g++}. We assume that
285the external libraries directory tree has been set up in
286{\tt /usr/local/ExtLibs/}. \\[3mm]
287\centerline{
288 \rule{20mm}{0.5mm}
289 {\bf \large the use of GNU make is mandatory}
290 \rule{20mm}{0.5mm} }
291
292\vspace*{3mm}
293\begin{verbatim}
294# We select our C++ compiler
295csh> setenv EROSCXX g++
296# Setup the build directory
297csh> mkdir /usr/local/Sophya/
298csh> setenv DPCDEVREP /usr/local/Sophya/
299csh> setenv EXTLIBDIR /usr/local/ExtLibs/
300# Use the top level makefile in Mgr/
301csh> cd \$SRC
302csh> cp Mgr/Makefile Makefile
303# Step 1: Create the directory tree and copy the include files (.h)
304csh> make depend
305# Step 2: Compile the modules without external library reference
306csh> make libs
307# Step 3: Compile the modules WITH external library reference (optional)
308csh> make extlibs
309# Step 4: Build libsophya.so
310csh> make slb
311# Step 5: Build libextsophya.so (optional)
312csh> make slbext
313# Step 6: Compile the PI and PIext modules (optional)
314csh> make PI
315# Step 7: Build the corresponding shared library libPI.so (optional)
316csh> make slbpi
317\end{verbatim}
318
319To compile all modules and build the shared libraries, it is possible
320to use:
321\begin{verbatim}
322# Step 2,3,6
323csh> make all
324# Step 4,5,7
325csh> make slball
326\end{verbatim}
327
328At this step, all libraries sould have been made. Programs using
329Sophya libraries can now be built:
330\begin{verbatim}
331# To compile test programs
332csh> cd Tests
333csh> make arrt ...
334csh> cd ..
335# To compile other programs, for example from the PMixer module
336csh> cd PMixer
337csh> make
338csh> cd ..
339# To build (s)piapp (libPI.so is needed)
340csh> cd ProgPI
341csh> make
342csh> cd ..
343\end{verbatim}
344
345\subsection{Mgr module}
346This module contains scripts which can be used for generating the
347makefiles for each module.
348\begin{itemize}
349\item {\bf Makefile} Top level Makefile for builiding the libraries.
350\item {\bf Makefile.h} contains the defintion of compilation flags for the
351different compilers and systems. This file is used for building the
352library and generating {\bf MakefileUser.h} (to be included in makefiles).
353\item {\bf Makefile.slb} contains the rules for building shared libraries
354for the different compilers and systems. (to be included in makefiles)
355\item {\bf crerep\_sophya} c-shell script for creating the directory tree
356under {\tt \$DPCBASEREP} and {\tt \$DPCDEVREP}
357\item {\bf install\_sophya} c-shell script for installing the Sophya package.
358Usually from {\tt \$DPCDEVREP} to {\tt \$DPCBASEREP}
359\item {\bf mkmflien} c-shell script for making symbolic links or copying
360include files to {\tt \$DPCDEVREP/Include} or {\tt \$DPCBASEREP/Include}
361\item {\bf mkmf} c-shell script for generating module makefiles and the
362top level makefile (named GNUmakefile)
363\item {\bf mkmflib} c-shell script for generating each library module
364makefile (named GNUmakefile)
365\item {\bf mkmfprog} c-shell script for generating makefile for a module
366containing the source for executable programs (named GNUmakefile).
367\item {\bf mkmfPI} c-shell script for generating makefile for PI and PIext
368modules (named GNUmakefile)
369\item {\bf libdirs} List of Sophya modules without reference to external
370libraries.
371\item {\bf extlibdirs} List of Sophya modules with reference to external
372libraries.
373
374\end{itemize}
375
376\newpage
377\appendix
378\section{Exception handling: An example}
379For simple programs, it is a good practice to handle
380the exceptions at least at high level, in the {\tt main()} function.
381The example below shows the exception handling and the usage
382of Sophya persistence.
383
384\input{ex1.inc}
385
386
387\end{document}
Note: See TracBrowser for help on using the repository browser.