Correct raw data reconstruction in case of trigger
[u/mrichter/AliRoot.git] / FMD / AliFMDDigitizer.h
CommitLineData
66d2ede1 1#ifndef ALIFMDDIGITIZER_H
2#define ALIFMDDIGITIZER_H
4347b38f 3/* Copyright(c) 1998-2000, ALICE Experiment at CERN, All rights
4 * reserved.
5 *
6 * See cxx source for full Copyright notice
7 */
c2fc1258 8/** @file AliFMDDigitizer.h
9 @author Christian Holm Christensen <cholm@nbi.dk>
10 @date Mon Mar 27 12:38:26 2006
11 @brief FMD Digitizers declaration
12*/
4347b38f 13#ifndef ALIDIGITIZER_H
14# include <AliDigitizer.h>
15#endif
16#ifndef ALIRUNDIGITIZER_H
17# include <AliRunDigitizer.h>
18#endif
e802be3e 19#ifndef ALIFMDEdepMAP_H
97961cbd 20# include "AliFMDEdepMap.h"
4347b38f 21#endif
22#ifndef __UTILITY__
23# include <utility>
24#endif
25// #ifndef ROOT_TArrayF
26// # include <TArrayF.h>
27// #endif
88cb7938 28
4347b38f 29//====================================================================
88cb7938 30class TClonesArray;
4347b38f 31class AliFMD;
32class AliLoader;
33class AliRunLoader;
8f6ee336 34class AliFMDDigit;
4347b38f 35
4347b38f 36
37//====================================================================
9f662337 38/** @class AliFMDBaseDigitizer AliFMDDigitizer.h <FMD/AliFMDDigitizer>
39 @brief Base class for digitizers.
40
41 This class contains the procedures simulation ADC signal for the
42 Forward Multiplicity detector : Hits->Digits and Hits->SDigits
43
44 Digits consists of
45 - Detector #
46 - Ring ID
47 - Sector #
48 - Strip #
49 - ADC count in this channel
50
51 Summable digits consists of
52 - Detector #
53 - Ring ID
54 - Sector #
55 - Strip #
56 - Total energy deposited in the strip
57 - ADC count in this channel
58
59 As the Digits and SDigits have so much in common, the classes
60 AliFMDDigitizer and AliFMDSDigitizer are implemented via a base
61 class AliFMDBaseDigitizer.
62 @verbatim
63 +---------------------+
64 | AliFMDBaseDigitizer |
65 +---------------------+
66 ^
67 |
68 +----------+---------+
69 | |
70 +-----------------+ +------------------+
71 | AliFMDDigitizer | | AliFMDSDigitizer |
72 +-----------------+ +------------------+
73 @endverbatim
74 These classes uses parameters fetched from the AliFMDParameters
75 manager.
76
77 The shaping function of the VA1 is generally given by
78 @f[
79 f(x) = A(1 - \exp(-Bx))
80 @f]
81 where A is the total charge collected in the pre-amp., and B is a
82 paramter that depends on the shaping time of the VA1 circut.
83
84 When simulating the shaping function of the VA1 pre-amp. chip, we
85 have to take into account, that the shaping function depends on
86 the previous value of read from the pre-amp.
87
88 That results in the following algorithm:
89 @code
90 last = 0;
91 for (i=0; i < n_pre_amp_charge; i++) {
92 charge = GetCharge(i);
93 if (last < charge)
94 f(t) = (charge - last) * (1 - exp(-B * t)) + last
95 else
96 f(t) = (last - charge) * exp(-B * t) + charge)
97 for (j=0; j < sample_rate; j++)
98 adc[j] = f(i / (# samples))
99 last = charge
100 }
101 @endcode
102 Here, the first loop is over all charges collected by the VA1
103 chip, and the @c sample_rate is how many times the ALTRO ADC
104 samples each of the 128 charges from the pre-amp.
105
106 The @c charge is the total charge @f$ Q@f$ collected by the VA1
107 pre-amplifier for a strip. @f$ Q@f$ is then given by
108 @f[
109 Q = \frac{E}{e}\frac{S}{r}
110 @f]
111 where @f$ E@f$ is the total energy deposited in a silicon strip,
112 @f$ R@f$ is the dynamic range of the VA1 pre-amp, @f$ e@f$ is the
113 energy deposited by a single MIP, and @f$ S@f$ ALTRO channel size
114 in each time step.
115
116 The energy deposited per MIP is given by
117 @f$
118 e = M \rho w
119 @f$
120 where @f$ M@f$ is the universal number
121 @f$ 1.664 \mbox{keV}\mbox{cm}^{2}\mbox{g}^{-1}@f$, @f$ \rho@f$ is
122 the density of silicon, and @f$ w@f$ is the depth of the silicon
123 sensor.
124
125 The final ADC count is given by
126 @f[
127 C' = C + P
128 @f]
129 where @f$ P@f$ is the (randomized) pedestal.
130
131 This class uses the class template AliFMDEdepMap to make an
132 internal cache of the energy deposted of the hits. The class
133 template is instantasized as
134
135 The first member of the values is the summed energy deposition in a
136 given strip, while the second member of the values is the number of
137 hits in a given strip. Using the second member, it's possible to
138 do some checks on just how many times a strip got hit, and what
139 kind of error we get in our reconstructed hits. Note, that this
140 information is currently not written to the digits tree. I think a
141 QA (Quality Assurance) digit tree is better suited for that task.
142 However, the information is there to be used in the future.
143 @ingroup FMD_sim
144 */
4347b38f 145class AliFMDBaseDigitizer : public AliDigitizer
146{
147public:
9f662337 148 /** CTOR */
4347b38f 149 AliFMDBaseDigitizer();
9f662337 150 /** Normal CTOR
151 @param manager Manager of digitization */
4347b38f 152 AliFMDBaseDigitizer(AliRunDigitizer * manager);
9f662337 153 /** Normal ctor
154 @param name Name
155 @param title Title */
4347b38f 156 AliFMDBaseDigitizer(const Char_t* name, const Char_t* title);
9f662337 157 /** DTOR */
4347b38f 158 virtual ~AliFMDBaseDigitizer();
4110645f 159
9f662337 160 /** Initialize */
4347b38f 161 virtual Bool_t Init();
162
9f662337 163 /** The response shape of the VA1 shaping circuit is approximently
164 given by
165 @f[
166 f(x) = A(1 - \exp(-Bx))
167 @f]
168 where @f$ A@f$ is the total charge collected by the pre-amp.,
169 and @f$ B@f$ is parameter that depends on the shaping time of
170 the @b VA1 pre-amp. This member function sets the parameter @f$
171 B@f$
172 @param B */
173 void SetShapingTime(Float_t B=10) { fShapingTime = B; }
174 /** @return Get the shaping time */
4347b38f 175 Float_t GetShapingTime() const { return fShapingTime; }
176protected:
9f662337 177 /** Sum energy deposited contributions from each hit in a cache
178 @param fmd Pointer to detector */
4347b38f 179 virtual void SumContributions(AliFMD* fmd);
9f662337 180 /** For the stored energy contributions in the cache, convert the
181 energy signal to ADC counts, and store the created digit in
182 the digits array
183 @param fmd Pointer to detector */
4347b38f 184 virtual void DigitizeHits(AliFMD* fmd) const;
9f662337 185 /** Convert the total energy deposited to a (set of) ADC count(s).
186 See also the class description for more details.
187 @param edep Total energy deposited in detector
188 @param last Last charge collected in previous VA1 channnel
189 @param detector Detector #
190 @param ring Ring ID
191 @param sector Sector #
192 @param strip Strip #
193 @param counts Array holding the counts on return */
4347b38f 194 virtual void ConvertToCount(Float_t edep,
e802be3e 195 Float_t last,
8f6ee336 196 UShort_t detector,
197 Char_t ring,
198 UShort_t sector,
199 UShort_t strip,
4347b38f 200 TArrayI& counts) const;
9f662337 201 /** Make a pedestal
202 @param detector Detector #
203 @param ring Ring ID
204 @param sector Sector #
205 @param strip Strip #
206 @return Pedestal value */
8f6ee336 207 virtual UShort_t MakePedestal(UShort_t detector,
208 Char_t ring,
209 UShort_t sector,
210 UShort_t strip) const;
9f662337 211 /** Add noise to each sample */
4347b38f 212 virtual void AddNoise(TArrayI&) const {}
9f662337 213 /** Add a digit to output */
4347b38f 214 virtual void AddDigit(AliFMD* /* fmd */,
215 UShort_t /* detector */,
216 Char_t /* ring */,
217 UShort_t /* sector */,
218 UShort_t /* strip */,
219 Float_t /* edep */,
220 UShort_t /* count1 */,
221 Short_t /* count2 */,
222 Short_t /* count3 */) const {}
66d2ede1 223
e5c81efd 224 AliRunLoader* fRunLoader; //! Run loader
4347b38f 225 AliFMDEdepMap fEdep; // Cache of Energy from hits
4347b38f 226 Float_t fShapingTime; // Shaping profile parameter
227
9f662337 228 /** Copy CTOR
229 @param o object to copy from */
088f8e79 230 AliFMDBaseDigitizer(const AliFMDBaseDigitizer& o)
231 : AliDigitizer(o) {}
9f662337 232 /** Assignment operator
233 @return Reference to this object */
088f8e79 234 AliFMDBaseDigitizer& operator=(const AliFMDBaseDigitizer&) { return *this; }
e5c81efd 235 ClassDef(AliFMDBaseDigitizer,2) // Base class for FMD digitizers
4347b38f 236};
237
238//====================================================================
9f662337 239/** @class AliFMDDigitizer
240 @brief Concrete digitizer to make digits from hits. See also
241 AliFMDBaseDigitizer documentation.
242 @ingroup FMD_sim
243 */
4347b38f 244class AliFMDDigitizer : public AliFMDBaseDigitizer
245{
246public:
9f662337 247 /** CTOR */
4347b38f 248 AliFMDDigitizer();
9f662337 249 /** CTOR
250 @param manager Manager of digitization */
4347b38f 251 AliFMDDigitizer(AliRunDigitizer * manager);
9f662337 252 /** DTOR */
4347b38f 253 virtual ~AliFMDDigitizer() {}
9f662337 254 /** Do everything
255 @param option Not used */
4347b38f 256 virtual void Exec(Option_t* option=0);
4347b38f 257protected:
9f662337 258 /** Add a digit to output.
259 @param fmd Pointer to detector object
260 @param detector Detector #
261 @param ring Ring ID
262 @param sector Sector number
263 @param strip Strip number
264 @param edep Energy deposited (not used)
265 @param count1 ADC count 1
266 @param count2 ADC count 2 (-1 if not used)
267 @param count3 ADC count 3 (-1 if not used) */
4347b38f 268 virtual void AddDigit(AliFMD* fmd,
269 UShort_t detector,
270 Char_t ring,
271 UShort_t sector,
272 UShort_t strip,
273 Float_t edep,
274 UShort_t count1,
275 Short_t count2,
276 Short_t count3) const;
9f662337 277 /** MAke a pedestal
278 @param detector Detector #
279 @param ring Ring ID
280 @param sector Sector number
281 @param strip Strip number
282 @return Random noise */
8f6ee336 283 virtual UShort_t MakePedestal(UShort_t detector,
284 Char_t ring,
285 UShort_t sector,
286 UShort_t strip) const;
9f662337 287 /** Check that digit data is consistent
288 @param digit Digit
289 @param nhits Number of hits
290 @param counts ADC counts */
8f6ee336 291 virtual void CheckDigit(AliFMDDigit* digit,
4347b38f 292 UShort_t nhits,
293 const TArrayI& counts);
8f6ee336 294 ClassDef(AliFMDDigitizer,1) // Make Digits from Hits
4347b38f 295};
4110645f 296
4347b38f 297//====================================================================
9f662337 298/** @class AliFMDSDigitizer AliFMDDigitizer.h <FMD/AliFMDDigitizer.h>
299 @brief Concrete implementation to make summable digits.
300 See also class documentation of AliFMDBaseDigitizer
301 @ingroup FMD_sim
302 */
4347b38f 303class AliFMDSDigitizer : public AliFMDBaseDigitizer
304{
305public:
9f662337 306 /** CTOR */
4347b38f 307 AliFMDSDigitizer();
9f662337 308 /** CTOR
309 @param headerFile Where to write headings
310 @param sdigFile Where to write digits. */
4347b38f 311 AliFMDSDigitizer(const Char_t* headerFile, const Char_t* sdigFile="");
9f662337 312 /** DTOR */
4347b38f 313 virtual ~AliFMDSDigitizer();
9f662337 314 /** Do it all
315 @param option Not used */
4347b38f 316 virtual void Exec(Option_t* option=0);
317protected:
9f662337 318 /** Add a digit to output.
319 @param fmd Pointer to detector object
320 @param detector Detector #
321 @param ring Ring ID
322 @param sector Sector number
323 @param strip Strip number
324 @param edep Energy deposited (not used)
325 @param count1 ADC count 1
326 @param count2 ADC count 2 (-1 if not used)
327 @param count3 ADC count 3 (-1 if not used) */
4347b38f 328 virtual void AddDigit(AliFMD* fmd,
329 UShort_t detector,
330 Char_t ring,
331 UShort_t sector,
332 UShort_t strip,
333 Float_t edep,
334 UShort_t count1,
335 Short_t count2,
336 Short_t count3) const;
337 ClassDef(AliFMDSDigitizer,0) // Make Summable Digits from Hits
338};
4110645f 339
340
4347b38f 341
342#endif
343//____________________________________________________________________
344//
0d0e6995 345// Local Variables:
346// mode: C++
347// End:
348//
349//
4347b38f 350// EOF
351//
352