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