1 | %------------------------------------------------------------------------------ |
---|
2 | \section{Classes coding conventions} |
---|
3 | %------------------------------------------------------------------------------ |
---|
4 | |
---|
5 | %------------------------------------------------------------------------------ |
---|
6 | \subsection{Files} |
---|
7 | %------------------------------------------------------------------------------ |
---|
8 | All 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 | |
---|
33 | The 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 | |
---|
40 | In a projects as big as \ESAF{}, commenting the code is essential. |
---|
41 | Moreover, comments written in the right format can be intercepted and included them in the documentation. |
---|
42 | In \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 | |
---|
45 | For 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 | |
---|
56 | A typical \ESAF{} class looks like: |
---|
57 | |
---|
58 | \begin{displaycode} |
---|
59 | //////////////////////////////////////////////////////////////////////////////// |
---|
60 | // // |
---|
61 | // ParamOpticalSystem // |
---|
62 | // // |
---|
63 | // Parameterized optical system // |
---|
64 | // // |
---|
65 | //////////////////////////////////////////////////////////////////////////////// |
---|
66 | |
---|
67 | class ParamOpticalSystem : public OpticalSystem { |
---|
68 | public: |
---|
69 | ParamOpticalSystem(); |
---|
70 | virtual ~ParamOpticalSystem(); |
---|
71 | |
---|
72 | private: |
---|
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 | |
---|
87 | For 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 | |
---|
93 | Just before the class declaration there is a brief description of the class (few words). |
---|
94 | In 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 | |
---|
110 | The descriptions must follow data member declaration, inline or in the following line. |
---|
111 | |
---|
112 | Sometime 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}) |
---|
113 | like \code{EShower}, \code{EAtmosphere} and \code{EDetector}. |
---|
114 | |
---|
115 | \begin{displaycode} |
---|
116 | Double_t *fIntegral; |
---|
117 | // fNbins+1 size array containing line integral of the fs profile |
---|
118 | |
---|
119 | Int_t fNbins; // size of fIntegral |
---|
120 | \end{displaycode} |
---|
121 | |
---|
122 | %------------------------------------------------------------------------------ |
---|
123 | \subsection{Source files} |
---|
124 | %------------------------------------------------------------------------------ |
---|
125 | |
---|
126 | \subsubsection{Class Documentation} |
---|
127 | The information stored in the class documentation block is twofold. First, features and proposes are explained in detail. |
---|
128 | Then, 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 | |
---|
173 | Note that EVERYTHING until the first non-commented line is considered as a valid class description block. |
---|
174 | |
---|
175 | |
---|
176 | Parameters can be numbers or strings. |
---|
177 | Unit of measure must be specified when the parameter is not pure numbers, otherwise the \code{[string]} keyword, in case of strings. |
---|
178 | |
---|
179 | In 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 | //______________________________________________________________________________ |
---|
188 | Double_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 | |
---|
199 | Like 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 | |
---|