source: JEM-EUSO/esaf_lal/tags/v1_r0/esafdoc/DevelopersGuide/ClassFormat.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: 8.7 KB
Line 
1%------------------------------------------------------------------------------
2\section{Classes coding conventions}
3%------------------------------------------------------------------------------
4
5%------------------------------------------------------------------------------
6\subsection{Files}
7%------------------------------------------------------------------------------
8All files belonging to the ESAF CVS are required to have basic information stored in a standard header like the following:
9
10\begin{displaycode}
11// $Id: ClassFormat.tex 1117 2004-09-29 10:07:43Z thea $
12// Author: A.Thea   2004/07/19
13
14/*****************************************************************************
15 * ESAF: Euso Simulation and Analysis Framework                              *
16 *                                                                           *
17 *  Id: ParamOpticalSystem                                                   *
18 *  Package: Optics                                                          *
19 *  Coordinator: Alessandro.Thea                                             *
20 *                                                                           *
21 *****************************************************************************/
22\end{displaycode}
23
24\begin{description}
25\item{\verb+$Id: ClassFormat.tex 1117 2004-09-29 10:07:43Z thea $+}: CVS file informations.
26\item{\verb+Author+}: the name of the creator and the creation date. It is read by the automatic documentation system.
27
28\item{\verb+Id+}: string that identifies the file (i.e. the class name or the namespace name).
29\item{\verb+Package+}: the name of the package it belongs to.
30\item{\verb+Coordinator+}: the package coordinator identifier, $<FirstName>.<LastName>$.
31\end{description}
32
33The ESAF header must be present in header, source and config files (\code{.hh},\code{.cc},\code{.cfg}).
34
35
36%------------------------------------------------------------------------------
37\section{Comments}
38%------------------------------------------------------------------------------
39
40In a projects as big as \ESAF{}, commenting the code is essential.
41Moreover, comments written in the right format can be intercepted and included them in the documentation.
42In \ESAF{} we use this approach so each developer has to keep up-to-date only the code documentation and
43 the automatic documentation system takes care of producing the package documentation.
44
45For each class three different type of comments are required:
46\begin{enumerate}
47    \item A header inside the header file,
48    \item Class and class' parameter description in the source file,
49    \item Class' member functions explanation in the source file.
50\end{enumerate}
51
52%------------------------------------------------------------------------------
53\subsection{Header files}
54%------------------------------------------------------------------------------
55
56A typical \ESAF{} class looks like:
57
58\begin{displaycode}
59////////////////////////////////////////////////////////////////////////////////
60//                                                                            //
61// ParamOpticalSystem                                                         //
62//                                                                            //
63// Parameterized optical system                                               //
64//                                                                            //
65////////////////////////////////////////////////////////////////////////////////
66
67class ParamOpticalSystem : public OpticalSystem {
68public:
69    ParamOpticalSystem();
70    virtual ~ParamOpticalSystem();
71   
72private:
73
74    enum EPsfType { kPointLike, kGaussian };
75
76    void Init();
77    Double_t *fIntegral;         // fNbins+1 size array containing the
78                                 // line integral of the fs profile
79    Int_t fNbins;                // size of fIntegral
80
81    EsafConfigClass(Optics,ParamOpticalSystem)
82
83    ClassDef(ParamOpticalSystem,1)
84};
85\end{displaycode}
86
87For each class or namespace, two comments are required: class/namespace title before its declaration, and class data members description.
88
89%------------------------------------------------------------------------------
90\subsubsection{Class title}
91%------------------------------------------------------------------------------
92
93Just before the class declaration there is a brief description of the class (few words).
94In case of a single class header may be redundant but becomes useful when several classes are defined in the same file.
95
96\begin{displaycode}
97////////////////////////////////////////////////////////////////////////////////
98//                                                                            //
99// ParamOpticalSystem                                                         //
100//                                                                            //
101// Parameterized optical system                                               //
102//                                                                            //
103////////////////////////////////////////////////////////////////////////////////
104\end{displaycode}
105
106%------------------------------------------------------------------------------
107\subsubsection{Data members}
108%------------------------------------------------------------------------------
109
110The descriptions must follow data member declaration, inline or in the following line.
111
112Sometime special keywords can be found after \verb+//+. These information are used by the dictionary generator \path{rootcint} Special comments (\code{ClassVersionID != 0})%(\ref{Automatic Generated Streamers, ROOT UG, pag 202})
113like \code{EShower}, \code{EAtmosphere} and \code{EDetector}.
114
115\begin{displaycode}
116Double_t *fIntegral;         
117// fNbins+1 size array containing line integral of the fs profile
118
119Int_t fNbins;                // size of fIntegral
120\end{displaycode}
121
122%------------------------------------------------------------------------------
123\subsection{Source files}
124%------------------------------------------------------------------------------
125
126\subsubsection{Class Documentation}
127The information stored in the class documentation block is twofold. First, features and proposes are explained in detail.
128Then, if class uses \ESAF{} configuration system, the list of the config file parameters follows.
129
130\begin{displaycode}
131//_____________________________________________________________________________
132//   Parameterized Optical System
133//   ===========================
134//
135//   Parameterized optical system. This Optical System is done to reproduce the
136//   behaviour of an optics design through a set of parameters.
137//   The main pourpose is to simulate and OS with a given Triggering efficacy
138//   without the need of the full MC simulation.
139//
140//   ParamOpticalSystem behaves as an ideal optical system with a given focal
141//   surface.
142//
143//   The position an incoming photon hits the focal surface is calculated
144//   accordingly the relation
145//
146//   d = (Dmax/ThetaMax)*theta
147//
148//   where:
149//   d is the distance of the impact point on the FS from the center of the FS
150//   calculated along the FS.
151//
152//   Dmax is the maximum distancs.
153//
154//   theta is the angle between the incoming photon direction and the optical
155//   axis.
156//
157//   ThetaMax is the maximum value of theta accepted by the optics.
158//
159//   Config file parameters:
160//   =======================
161//
162//   fPos.Z [mm] : Z coordinate of the bottom base of the OpticalSystem in
163//   Detector reference System.
164//
165//   fPsfType [option]: type of PSF to use.
166//   - options
167//        point: No spread.
168//        gauss: Gaussian psf. RMS and angles of incidence listed in
169//               fGaussSpread.filename
170//
171\end{displaycode}
172
173Note that EVERYTHING until the first non-commented line is considered as a valid class description block.
174
175
176Parameters can be numbers or strings.
177Unit of measure must be specified when the parameter is not pure numbers, otherwise the  \code{[string]} keyword, in case of strings.
178
179In the latter case all the valid options must be listed after the parameter description.
180
181%------------------------------------------------------------------------------
182\subsubsection{Member fuctions}
183%------------------------------------------------------------------------------
184 A member function description block starts immediately after '\verb+{+' and looks like this:
185
186\begin{displaycode}
187//______________________________________________________________________________
188Double_t ParamOpticalSystem::FocalSurfProfile( Double_t r ) const {
189    //
190    // Profile of the focal surface Z(r)
191    //
192
193    if ( r < 0 || r > fRmax ) return 0;
194
195    return fFocalSurfShape->Eval(r);
196}
197\end{displaycode}
198
199Like in a class description block, EVERYTHING until the first non-commented line is considered as a valid member function description block.
200
201
202
203
204
205
206 
207
208
209
Note: See TracBrowser for help on using the repository browser.