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

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

MAJ de doc Sophya overview - Reza 21/11/2000

File size: 15.9 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 \\
27E. Aubourg & aubourg@hep.saclay.cea.fr \\
28G. Le Meur & lemeur@lal.in2p3.fr \\
29C. Magneville & cmv@hep.saclay.cea.fr \\
30S. Henrot-Versille & versille@in2p3.fr
31}
32% \auteursall
33% The title page - bottom of the page with the paper number
34\titrebp{1}
35\end{titlepage}
36
37\tableofcontents
38
39\newpage
40
41\section{Introduction}
42
43 {\bf SOPHYA} ({\bf SO}ftware for {\bf PHY}sics {\bf A}nalysis)
44is a collection of C++ classes designed for numerical and
45physics analysis software development. Our goal is to provide
46easy to use, yet powerful classes which can be used by scientists.
47We have decided to use as much as possible available
48numerical analysis libraries, encapsulating them whenever
49possible.
50
51 The SOPHYA design and implementation has been carried out
52with the specific goal of providing the general framework for
53the Planck-HFI data processing software. However, most of the
54packages presented here have a more general scope than the CMB analysis
55and Planck mission problem.
56 The source directory tree
57\footnote{ CVS server: cvsserver.lal.in2p3.fr:/projects/Eros/CVSPlanck}
58is organised into a number of modules.
59
60\begin{itemize}
61\item[] {\bf Mgr/} Scripts for code management,
62makefile generation and software installation
63\item[] {\bf SysTools/} General architecture support classes such
64as {\tt PPersist, NDataBlock<T>}, and few utility classes
65({\tt DataCard, DVList} \ldots).
66\item[] {\bf TArray/} template numerical arrays, vectors and matrices \\
67({\tt PixelMap<T> SphericalMap<T>} \ldots)
68\item[] {\bf NTools/} Some standard numerical analysis tools
69(linear, and non linear parameter fitting, FFT, \ldots)
70\item[] {\bf HiStats/} Histogram-ming and data set handling classes \\
71({\tt Histo Histo2D NTuple XNTuple} \ldots)
72\end{itemize}
73
74The modules listed below are more tightly related to the
75CMB (Cosmic Microwave Background) data analysis problem:
76\begin{itemize}
77\item[] {\bf SkyMap/} Local and full sky maps, and few geometry
78handling utility classes. \\
79({\tt PixelMap<T>, LocalMap<T>, SphericalMap<T>, \ldots})
80\item[] {\bf SkyT/}
81classes for spectral emission and detector frequency response modelling \\
82({\tt SpectralResponse, RadSpectra, BlackBody} \ldots)
83\item[] {\bf Samba/} Spherical harmonic analysis.
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 (libfftw.a)
93\end{itemize}
94
95Other modules:
96\begin{itemize}
97\item[] {\bf Tests/} Simple test programs
98\item[] {\bf PrgUtil/} Various utility programs (runcxx, scanppf, scanfits, \ldots)
99\item[] {\bf PMixer/} skymixer and related programs
100\item[] {\bf ProgPI/} interactive analysis tool - It should be noted that
101this module uses the SOPHYA class library and is based on {\bf PI}
102which is a C++ library defining a complete GUI program
103architecture. An additional module (PIext) define the interactive
104analysis program framework and the interfaces with the objects
105in SOPHYA. The {\bf PI/} \footnote{the PI package documentation
106is available from {\bf http://www.lal.in2p3.fr/recherche/eros/PeidaDoc/} }
107and {\bf PIext/} modules are not currently part
108of the SOPHYA CVS structure.
109\end{itemize}
110
111\newpage
112
113\section{Using Sophya}
114Two environment variables {\bf DPCBASEREP} and {\bf EROSCXX} are used
115to define the path where the Sophya libraries and executable are installed.
116{\bf DPCBASEREP} defines the base directory path and {\bf EROSCXX} the
117name of the C++ compiler. The complete path is built using {\bf DPCBASEREP},
118the operating system name (as obtained by the {\tt uname} command), and
119the compiler name. In the example below, we show the complete path
120for a {\tt Linux} system, using the GNU g++ compiler:
121
122\begin{itemize}
123\item \$DPCBASEREP/Include : Include (.h) files
124\item \$DPCBASEREP/Linux-g++/Libs : Path for the archive libraries (.a)
125\item \$DPCBASEREP/Linux-g++/ShLibs : Shared library path (.so)
126\item \$DPCBASEREP/Linux-g++/Exec : Executable file path
127\end{itemize}
128
129In order to use the shared libraries, the {\bf LD\_LIBRARY\_PATH} variable
130should contain the Sophya shared library path
131({\tt \$DPCBASEREP/Linux-g++/ShLibs } when using g++ compiler on Linux)
132
133For modules using external libraries, the {\bf EXTLIBDIR}
134environment variable should contain the path to these libraries
135and corresponding include files.
136C-FitsIO anf FFTW include files should be accessible through: \\
137{\tt \$EXTLIBDIR/Include/FitsIO } \\
138{\tt \$EXTLIBDIR/Include/FFTW } \\
139The corresponding libraries are expected to be found in: \\
140{\tt \$EXTLIBDIR/Linux-g++/Libs} \\
141
142The file {\tt \$DPCBASEREP/Include/MakefileUser.h} defines the compilation
143flags and the list of Sophya libraries. It should be included in the
144user's makefile. The default compilation rules assumes that the object (.o)
145and executable files would be put in the following diretories: \\
146{\tt \$HOME/`uname`-\$EROSCXX/Objs} \\
147{\tt \$HOME/`uname`-\$EROSCXX/Exec}.
148In the case of a {\tt Linux} system and using {\tt g++} as the C++ compiler,
149these two directories would be translated to \\
150{\tt \$HOME/Linux-g++/Objs} and {\tt \$HOME/Linux-g++/Exec}.
151The GNU make program should be used.
152\par
153The file {\tt \$DPCBASEREP/Include/makefile\_auto} defines the rules to compile
154a given source program, and link it against the Sophya libraries to produce
155an executable. The example below shows the steps to compile a program named
156{\tt trivial.cc }.
157\begin{verbatim}
158csh> cp \$DPCBASEREP/Include/makefile_auto makefile
159csh> make trivial
160\end{verbatim}
161This command should compile the {\tt trivial.cc} file,
162and link it against the sophya libraries. The object and executable
163file names are: \\
164{\tt \$HOME/`uname`-\$EROSCXX/Objs/trivial.o} \\
165{\tt \$HOME/`uname`-\$EROSCXX/Exec/trivial}.
166\par
167The file {\tt \$DPCBASEREP/Include/makefile\_example} provides another
168example makefile.
169
170Basic usage of Sophya classes are described in in the following sections.
171Complete Sophya documentation can be found at our web site: \\
172{\bf http://hfi-l2.in2p3.fr}.
173
174
175\section{Module SysTools}
176
177{\bf SysTools} contains utility classes such as {\tt DataCards} or
178{\tt DVlist}, an hierarchy of exception classes for Sophya, a template
179class {\tcls{NDataBlock}} for handling reference counting on numerical
180arrays, as well as classes providing the services for implementing simple
181serialization.
182\vspace*{5mm}
183
184\subsection{SOPHYA persistence}
185\begin{figure}[hbt]
186\dclsa{PPersist}
187\dclsbb{PIOPersist}{PInPersist}
188\dclsb{POutPersist}
189\caption{partial class diagram for classes handling persistence in Sophya}
190\end{figure}
191A simple persistence mechanism is defined in SOPHYA. Its main
192features are:
193\begin{itemize}
194\item[] Portable file format, containing the description of the data structures
195and object hierarchy. \\
196{\bf PPF} {\bf P}ortable {\bf P}ersistence file {\bf F}ormat.
197\item[] Handling of read/write for mutiply referenced objects.
198\item[] All write operations are carried using sequential access only. This
199holds also for read operations, unless positional tags are used.
200SOPHYA persistence services can thus be used to transfer objects
201through network links.
202\end{itemize}
203The example below shows writing of objects through the use of overloaded
204operator $ << $ :
205\begin{verbatim}
206#include "fiondblock.h"
207// ...
208POutPersist pos("aa.ppf");
209NDataBlock<r_4> rdb(40);
210rdb = 567.89;
211pos << rdb;
212// We can also use the PutObject method
213NDataBlock<int_4> idb(20);
214idb = 123;
215pos.PutObject(idb);
216\end{verbatim}
217The following sample programs show the reading of the created PPF file :
218\begin{verbatim}
219PInPersist pis("aa.ppf");
220NDataBlock<r_4> rdb;
221pis >> rdb;
222cout << rdb;
223NDataBlock<int_4> idb;
224cout << idb;
225\end{verbatim}
226
227\subsection{Using DataCards}
228The {\bf DataCards} class can be used to read parameters from a file.
229Each line in the file starting with \@ defines a set of values
230associated with a keyword. In the example below, we read the
231parameters corresponding with the keyword {\tt SIZE} from the
232file {\tt ex.d}. We suppose that {\tt ex.d} contains the line: \\
233{\tt @SIZE 400 250} \\
234\begin{verbatim}
235#include "datacards.h"
236// ...
237// Initializing DataCards object dc from file ex.d
238DataCards dc( "ex.d" );
239// Getting the first and second parameters for keyword size
240// We define a default value 100
241int size_x = dc.IParam("SIZE", 0, 100);
242int size_y = dc.IParam("SIZE", 1, 100);
243cout << " size_x= " << size_x << " size_y= " << size_y << endl;
244\end{verbatim}
245
246\subsection{Dynamic linker}
247The class {\bf PDynLinkMgr} can be used for managing shared libraries
248at run time. The example below shows the run time linking of a function:\\
249{\tt extern "C" { void myfunc(); } } \\
250\begin{verbatim}
251#include "pdlmgr.h"
252// ...
253string soname = "mylib.so";
254string funcname = "myfunc";
255PDynLinkMgr dyl(soname);
256DlFunction f = dyl.GetFunction(funcname);
257if (f != NULL) {
258// Calling the function
259 f();
260}
261\end{verbatim}
262
263\section{Module TArray}
264{\bf TArray} module contains template classes for handling standard
265operations on numerical arrays. Using the class {\tt \tcls{TArray} },
266it is possible to create and manipulate up to 5-dimension numerical
267arrays {\tt (int, float, double, complex, \ldots)}.
268
269\begin{figure}[hbt]
270\dclsccc{AnyDataObj}{BaseArray}{\tcls{TArray}}
271\ldots \\
272\dclsccc{\tcls{TArray}}{\tcls{TMatrix}}{\tcls{TVector}}
273\caption{partial class diagram for arrays, matrices and vectors}
274\end{figure}
275
276\subsection{Using arrays}
277
278The example below shows basic usage of arrays:
279\begin{verbatim}
280#include "array.h"
281// ...
282// Creation , filling of a Matrix
283 TMatrix<r_4> ma(7,9);
284 ma = RegularSequence(0.1, 0.05);
285 cout << "\n ma = " << ma << endl;
286\end{verbatim}
287
288Example of a simple low-pass filter on a one dimensional array (Vector)
289\begin{verbatim}
290// Input Vector containing a noisy periodic signal
291 Vector in(1024), out(1024);
292 in = RandomSequence(RandomSequence::Gaussian, 0., 1.);
293 for(int kk=0; kk<in.Size(); kk++)
294 in(kk) += 2*sin(kk*0.05);
295// Compute the output vector by a simple low pass filter
296 Vector out(1024);
297 int w = 2;
298 for(int k=w; k<in.Size()-w; k++)
299 out(k) = in(Range(k-w, k+w).Sum()/(2.*w+1.);
300\end{verbatim}
301
302\newpage
303
304\section{Module HiStats}
305\begin{figure}[hbt]
306\dclsccc{AnyDataObj}{Histo}{HProf}
307\dclsbb{AnyDataObj}{Histo2D}
308\dclsbb{AnyDataObj}{Ntuple}
309\dclsb{XNtuple}
310\caption{partial class diagram for histograms and ntuples}
311\end{figure}
312
313\section{Module SkyMap}
314
315\section{Module NTools}
316
317\section{Module Samba}
318
319\section{Module SkyT}
320
321
322\newpage
323\section{Building and installing Sophya}
324Presently, the Sophya library compilation has been tested with the following
325compiler/platform pairs:
326
327\begin{center}
328\begin{tabular}{ll}
329Compaq/DEC OSF1 & cxx (6.0 , 6.2) \\
330Linux & g++ (2.91 , 2.95) \\
331Linux & KCC (3.4) \\
332Solaris & g++ (2.95) \\
333SGI IRIX64 & CC \\
334\end{tabular}
335\end{center}
336
337Some of the modules in the Sophya package uses external libraries. The
338{\bf FitsIOServer} is the example of such a module, where the {\tt libcfitsio.a}
339is used.
340The build procedure expects to find the include files and the libraries in: \\
341{\tt \$EXTLIBDIR/Include/FitsIO } \\
342{\tt \$EXTLIBDIR/`uname`-\$EROSCXX/Libs} \\
343
344The object files from a given Sophya module are grouped in an archive library
345with the module's name ({\tt libmodulename.a}). All Sophya modules
346 are grouped in a single shared library ({\tt libsophya.so}), while the
347modules with reference to external libraries are grouped in
348({\tt libextsophya.so}). The {\bf PI} and {\bf PIext} modules are
349grouped in ({\tt libPI.so}).
350
351The environment variables {\bf DPCDEVREP}, {\bf EXTLIBDIR} and {\bf EROSCXX}
352must be defined in order to install the Sophya package.
353In the example below, we assume that we want to install Sophya from a
354released (tagged) version in the source directory {\tt \$SRC} in the
355{\tt /usr/local/Sophya} diretory, using {\tt g++}. We assume that
356the external libraries directory tree has been set up in
357{\tt /usr/local/ExtLibs/}. \\[3mm]
358\centerline{
359 \rule{20mm}{0.5mm}
360 {\bf \large the use of GNU make is mandatory}
361 \rule{20mm}{0.5mm} }
362
363\vspace*{3mm}
364\begin{verbatim}
365# We select our C++ compiler
366csh> setenv EROSCXX g++
367# Setup the build directory
368csh> mkdir /usr/local/Sophya/
369csh> setenv DPCDEVREP /usr/local/Sophya/
370csh> setenv EXTLIBDIR /usr/local/ExtLibs/
371# Use the top level makefile in Mgr/
372csh> cd \$SRC
373csh> cp Mgr/Makefile Makefile
374# Step 1: Create the directory tree and copy the include files (.h)
375csh> make depend
376# Step 2: Compile the modules without external library reference
377csh> make libs
378# Step 3: Compile the modules WITH external library reference (optional)
379csh> make extlibs
380# Step 4: Build libsophya.so
381csh> make slb
382# Step 5: Build libextsophya.so (optional)
383csh> make slbext
384# Step 6: Compile the PI and PIext modules (optional)
385csh> make PI
386# Step 7: Build the corresponding shared library libPI.so (optional)
387csh> make slbpi
388\end{verbatim}
389
390To compile all modules and build the shared libraries, it is possible
391to use:
392\begin{verbatim}
393# Step 2,3,6
394csh> make all
395# Step 4,5,7
396csh> make slball
397\end{verbatim}
398
399At this step, all libraries sould have been made. Programs using
400Sophya libraries can now be built:
401\begin{verbatim}
402# To compile test programs
403csh> cd Tests
404csh> make arrt ...
405csh> cd ..
406# To compile other programs, for example from the PMixer module
407csh> cd PMixer
408csh> make
409csh> cd ..
410# To build (s)piapp (libPI.so is needed)
411csh> cd ProgPI
412csh> make
413csh> cd ..
414\end{verbatim}
415
416\subsection{Mgr module}
417This module contains scripts which can be used for generating the
418makefiles for each module.
419\begin{itemize}
420\item {\bf Makefile} Top level Makefile for builiding the libraries.
421\item {\bf Makefile.h} contains the defintion of compilation flags for the
422different compilers and systems. This file is used for building the
423library and generating {\bf MakefileUser.h} (to be included in makefiles).
424\item {\bf Makefile.slb} contains the rules for building shared libraries
425for the different compilers and systems. (to be included in makefiles)
426\item {\bf crerep\_sophya} c-shell script for creating the directory tree
427under {\tt \$DPCBASEREP} and {\tt \$DPCDEVREP}
428\item {\bf install\_sophya} c-shell script for installing the Sophya package.
429Usually from {\tt \$DPCDEVREP} to {\tt \$DPCBASEREP}
430\item {\bf mkmflien} c-shell script for making symbolic links or copying
431include files to {\tt \$DPCDEVREP/Include} or {\tt \$DPCBASEREP/Include}
432\item {\bf mkmf} c-shell script for generating module makefiles and the
433top level makefile (named GNUmakefile)
434\item {\bf mkmflib} c-shell script for generating each library module
435makefile (named GNUmakefile)
436\item {\bf mkmfprog} c-shell script for generating makefile for a module
437containing the source for executable programs (named GNUmakefile).
438\item {\bf mkmfPI} c-shell script for generating makefile for PI and PIext
439modules (named GNUmakefile)
440\item {\bf libdirs} List of Sophya modules without reference to external
441libraries.
442\item {\bf extlibdirs} List of Sophya modules with reference to external
443libraries.
444
445\end{itemize}
446
447\newpage
448\appendix
449\section{Exception handling: An example}
450For simple programs, it is a good practice to handle
451the exceptions at least at high level, in the {\tt main()} function.
452The example below shows the exception handling and the usage
453of Sophya persistence.
454
455\input{ex1.inc}
456
457
458\end{document}
Note: See TracBrowser for help on using the repository browser.