]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDReconstructor.h
coverity fix
[u/mrichter/AliRoot.git] / FMD / AliFMDReconstructor.h
1 #ifndef ALIFMDRECONSTRUCTOR_H
2 #define ALIFMDRECONSTRUCTOR_H
3 //
4 //  Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights
5 //  reserved. 
6 //
7 //  See cxx source for full Copyright notice                               
8 //
9 //  AliFMDReconstructor.h 
10 //  Task Class for making TreeR for FMD                        
11 //
12 //-- Authors: Evgeny Karpechev (INR) and Alla Maevskaia (INR)
13 //   Latest changes by Christian Holm Christensen <cholm@nbi.dk>
14 /* $Id$ */
15 /** @file    AliFMDReconstructor.h
16     @author  Christian Holm Christensen <cholm@nbi.dk>
17     @date    Mon Mar 27 12:47:09 2006
18     @brief   FMD reconstruction 
19 */
20
21 //____________________________________________________________________
22 // Header guards in the header files speeds up the compilation
23 // considerably.  Please leave them in. 
24 #ifndef ALIRECONSTRUCTOR_H
25 # include <AliReconstructor.h>
26 #endif
27 #include "AliLog.h"
28 #include <AliFMDBoolMap.h>
29
30 //____________________________________________________________________
31 class TTree;
32 class TClonesArray;
33 class AliFMDDigit;
34 class AliRawReader;
35 class AliESDEvent;
36 class AliESDFMD;
37 class AliFMDRecoParam;
38 class TH1;
39
40
41 /** @defgroup FMD_rec Reconstruction */
42 //____________________________________________________________________
43 /** 
44  * @brief This is a class that reconstructs AliFMDRecPoint objects
45  *        from of Digits.  
46  *
47  * This class reads either digits from a TClonesArray or raw data
48  * from a DDL file (or similar), and applies calibrations to get
49  * psuedo-inclusive multiplicities per strip.
50  * 
51  * @ingroup FMD_rec
52  */
53 class AliFMDReconstructor: public AliReconstructor 
54 {
55 public:
56   /** 
57    * CTOR 
58    */
59   AliFMDReconstructor();
60   /** 
61    * DTOR 
62    */
63   virtual ~AliFMDReconstructor();
64
65   /** 
66    * Initialize the reconstructor.  Here, we initialize the geometry
67    * manager, and finds the local to global transformations from the
68    * geometry.   The calibration parameter manager is also
69    * initialized (meaning that the calibration parameters is read
70    * from CDB).
71    */
72   virtual void   Init();
73   /** 
74    * Flag that we can convert raw data into digits. 
75    *
76    * @return always @c true 
77    */
78   virtual Bool_t HasDigitConversion() const { return kTRUE; }
79   /** 
80    * Convert raw data read from the AliRawReader @a reader into
81    * digits.  This is done using AliFMDRawReader and
82    * AliFMDAltroReader.  The digits are put in the passed TTree @a
83    * digitsTree. 
84    *
85    * @param reader     Raw reader. 
86    * @param digitsTree Tree to store read digits in. 
87    */
88   virtual void   ConvertDigits(AliRawReader* reader, TTree* digitsTree) const;
89   /** 
90    * Reconstruct one event from the digits passed in @a digitsTree.
91    * The member function creates AliFMDRecPoint objects and stores
92    * them on the output tree @a clusterTree.  An FMD ESD object is
93    * created in parallel. 
94    *
95    * @param digitsTree  Tree holding the digits of this event
96    * @param clusterTree Tree to store AliFMDRecPoint objects in. 
97    */
98   virtual void   Reconstruct(TTree* digitsTree, TTree* clusterTree) const;
99   /** 
100    * Not used 
101    * @todo Implement this, such that we'll reconstruct directly from
102    *       the read ADC values rather than going via an intermedant
103    *       TClonesArray of AliFMDDigits
104    */
105   virtual void   Reconstruct(AliRawReader *, TTree*) const;
106   /** 
107    * Put in the ESD data, the FMD ESD data.  The object created by
108    * the Reconstruct member function is copied to the ESD object. 
109    *
110    * @param digitsTree   Tree of digits for this event - not used
111    * @param clusterTree  Tree of reconstructed points for this event -
112    *        not used.
113    * @param esd ESD object to store data in. 
114    */
115   virtual void   FillESD(TTree* digitsTree, TTree* clusterTree, 
116                          AliESDEvent* esd) const;
117   /** 
118    * Forwards to above member function 
119    */
120   virtual void   FillESD(AliRawReader*, TTree* clusterTree, 
121                          AliESDEvent* esd) const;
122
123   /** 
124    * Create SDigits from raw data
125    * 
126    * @param reader  The raw reader
127    * @param sdigits Array to fill with AliFMDSDigit objects. 
128    */  
129   virtual void Digitize(AliRawReader* reader, 
130                         TClonesArray* sdigits) const;
131   
132   /** 
133    * Not used 
134    */
135   virtual void   SetESD(AliESDEvent* esd) { fESD = esd; }
136   /** 
137    * Set the noise factor 
138    *
139    * @param f Factor to use 
140    */
141   virtual void SetNoiseFactor(Float_t f=3) { fNoiseFactor = f; }
142   /** 
143    * Set whether we should do angle correction or nor 
144    *
145    * @param use If true, do angle correction 
146    */
147   virtual void SetAngleCorrect(Bool_t use=kTRUE) { fAngleCorrect = use; }
148   /** 
149    * Set whether we want to do diagnostics.  If this is enabled, a
150    * file named @c FMD.Diag.root will be made.  It contains a set of
151    * histograms for each event, filed in separate directories in the
152    * file.  The histograms are 
153    * @verbatim 
154    * diagStep1   Read ADC vs. Noise surpressed ADC 
155    * diagStep2   Noise surpressed ADC vs. calculated Energy dep.
156    * diagStep3   Energy deposition vs. angle corrected Energy dep.
157    * diagStep4   Energy deposition vs. calculated multiplicity
158    * diagAll     Read ADC vs. calculated multiplicity
159    * @endverbatim 
160    *
161    * @param use If true, make the diagnostics file 
162    */
163   void SetDiagnose(Bool_t use=kTRUE) { fDiagnostics = use; }
164     
165 protected:
166   /** 
167    * Copy CTOR 
168    *
169    * @param other Object to copy from. 
170    */
171   AliFMDReconstructor(const AliFMDReconstructor&); //Not implemented
172   /** 
173    * Assignment operator 
174    *
175    * @param other Object to assign from
176    *
177    * @return reference to this object 
178    */
179   AliFMDReconstructor& operator=(const AliFMDReconstructor&); //Not implemented
180   /** 
181    * Try to get the vertex from either ESD or generator header.  Sets
182    * @c fCurrentVertex to the found Z posistion of the vertex (if 
183    * found), and sets the flag @c fVertexType accordingly 
184    *
185    * @param esd ESD structure to get Vz from
186    */
187   virtual void GetVertex(AliESDEvent* esd) const;
188   /** 
189    * Process AliFMDDigit objects in @a digits.  For each digit, find
190    * the psuedo-rapidity @f$ \eta@f$, azimuthal angle @f$ \varphi@f$,
191    * energy deposited @f$ E@f$, and psuedo-inclusive multiplicity @f$
192    * M@f$.
193    * 
194    * @param digits Array of digits. 
195    */
196   virtual void     ProcessDigits(TClonesArray* digits) const;
197   /** 
198    * Process a single digit 
199    * 
200    * @param digit Digiti to process
201    */ 
202   virtual void ProcessDigit(AliFMDDigit* digit) const;
203   /** 
204    * Process the signal from a single strip. 
205    * 
206    * @param det Detector number 
207    * @param rng Ring identifier 
208    * @param sec Sector number
209    * @param str Strip number 
210    * @param adc Number of ADC counts for this strip
211    */  
212   virtual void ProcessSignal(UShort_t det, 
213                              Char_t   rng, 
214                              UShort_t sec, 
215                              UShort_t str, 
216                              Short_t  adc) const;
217   /** 
218    * Process the signal from a single strip. 
219    * 
220    * @param sdigits Array to fill
221    * @param det     Detector number 
222    * @param rng     Ring identifier 
223    * @param sec     Sector number
224    * @param str     Strip number 
225    * @param sam     Sample number 
226    * @param adc     Number of ADC counts for this strip
227    */  
228   virtual void DigitizeSignal(TClonesArray* sdigits, 
229                               UShort_t      det, 
230                               Char_t         rng, 
231                               UShort_t       sec, 
232                               UShort_t       str, 
233                               UShort_t       sam,
234                               Short_t        adc) const;
235   /** 
236    * Subtract the pedestal off the ADC counts. 
237    * 
238    * @param det           Detector number
239    * @param rng           Ring identifier
240    * @param sec           Sector number
241    * @param str           Strip number
242    * @param adc           ADC counts
243    * @param noiseFactor   If pedestal substracted pedestal is less then
244    *        this times the noise, then consider this to be 0. 
245    * @param zsEnabled     Whether zero-suppression is on.
246    * @param zsNoiseFactor Noise factor used in on-line pedestal
247    *        subtraction. 
248    * 
249    * @return The pedestal subtracted ADC counts (possibly 0), or @c
250    *         USHRT_MAX in case of problems.
251    */  
252   virtual UShort_t SubtractPedestal(UShort_t det, 
253                                     Char_t   rng, 
254                                     UShort_t sec, 
255                                     UShort_t str, 
256                                     UShort_t adc, 
257                                     Float_t  noiseFactor,
258                                     Bool_t   zsEnabled, 
259                                     UShort_t zsNoiseFactor) const;
260   /** 
261    * Substract pedestals from raw ADC in @a digit
262    * 
263    * @param det   Detector number  
264    * @param rng   Ring identifier 
265    * @param sec   Sector number
266    * @param str   Strip number 
267    * @param adc   Number of ADC counts
268    *
269    * @return Pedestal subtracted ADC count. 
270    */
271   virtual UShort_t SubtractPedestal(UShort_t det, 
272                                     Char_t   rng, 
273                                     UShort_t sec, 
274                                     UShort_t str, 
275                                     Short_t  adc) const;
276   /** 
277    * Converts number of ADC counts to energy deposited.   This is
278    * done by 
279    * @f[
280    * E_i = A_i g_i
281    * @f]
282    * where @f$ A_i@f$ is the pedestal subtracted ADC counts, and @f$
283    * g_i@f$ is the gain for the @f$ i^{\mbox{th}}@f$ strip. 
284    * 
285    * @param det   Detector number  
286    * @param rng   Ring identifier 
287    * @param sec   Sector number
288    * @param str   Strip number 
289    * @param eta   Psuedo-rapidity of digit.
290    * @param count Pedestal subtracted ADC counts
291    *
292    * @return Energy deposited @f$ E_i@f$ 
293    */
294   virtual Float_t  Adc2Energy(UShort_t det, 
295                               Char_t   rng, 
296                               UShort_t sec, 
297                               UShort_t str, 
298                               UShort_t count) const;
299   /** 
300    * Converts number of ADC counts to energy deposited.   This is
301    * done by 
302    * @f[
303    * E_i = A_i g_i
304    * @f]
305    * where @f$ A_i@f$ is the pedestal subtracted ADC counts, and @f$
306    * g_i@f$ is the gain for the @f$ i^{\mbox{th}}@f$ strip. 
307    * 
308    * @param det   Detector number  
309    * @param rng   Ring identifier 
310    * @param sec   Sector number
311    * @param str   Strip number 
312    * @param eta   Psuedo-rapidity of digit.
313    * @param count Pedestal subtracted ADC counts
314    *
315    * @return Energy deposited @f$ E_i@f$ 
316    */
317   virtual Float_t  Adc2Energy(UShort_t det, 
318                               Char_t   rng, 
319                               UShort_t sec, 
320                               UShort_t str, 
321                               Float_t  eta, 
322                               UShort_t count) const;
323   /** 
324    * Converts an energy signal to number of particles. In this
325    * implementation, it's done by 
326    * @f[
327    * M_i = E_i / E_{\mbox{MIP}}
328    * @f]
329    * where @f$ E_i@f$ is the energy deposited, and 
330    * @f$ E_{\mbox{MIP}}@f$ is the average energy deposited by a
331    * minimum ionizing particle
332    * 
333    * @param det   Detector number  
334    * @param rng   Ring identifier 
335    * @param sec   Sector number
336    * @param str   Strip number 
337    * @param eta   On return, psuedo-rapidity @f$ \eta@f$
338    * @param phi   On return, azimuthal angle @f$ \varphi@f$ 
339    * @param edep Energy deposited @f$ E_i@f$
340    *
341    * @return Psuedo-inclusive multiplicity @f$ M@f$ 
342    */
343   virtual Float_t  Energy2Multiplicity(UShort_t det, 
344                                        Char_t   rng, 
345                                        UShort_t sec, 
346                                        UShort_t str, 
347                                        Float_t  edep) const;
348   /** 
349    * Calculate the physical coordinates psuedo-rapidity @f$ \eta@f$,
350    * azimuthal angle @f$ \varphi@f$ of the strip corresponding to
351    * the digit @a digit.   This is done by using the information
352    * obtained, and previously cached by AliFMDGeometry, from the
353    * TGeoManager. 
354    * 
355    * @param det   Detector number  
356    * @param rng   Ring identifier 
357    * @param sec   Sector number
358    * @param str   Strip number 
359    * @param eta   On return, psuedo-rapidity @f$ \eta@f$
360    * @param phi   On return, azimuthal angle @f$ \varphi@f$ 
361    */
362   virtual void     PhysicalCoordinates(UShort_t det, 
363                                        Char_t   rng, 
364                                        UShort_t sec, 
365                                        UShort_t str, 
366                                        Float_t& eta, 
367                                        Float_t& phi) const;
368   /** 
369    * Mark dead channels as invalid, and those that are marked as invalid 
370    * but are not dead, get the zero signal. 
371    * 
372    * @param esd ESD object to modify. 
373    */
374   void MarkDeadChannels(AliESDFMD* esd) const;
375
376   /** 
377    * Set-up reconstructor to use values from reconstruction
378    * parameters, if present, for this event.   If the argument @a set
379    * is @c false, then restore preset values. 
380    * 
381    * @param set 
382    */  
383   virtual void UseRecoParam(Bool_t set=kTRUE) const;
384   /** 
385    * Utility member function to get the reconstruction parameters for 
386    * this event
387    * 
388    * @return Pointer to AliFMDRecoParam object or null if not
389    * available. 
390    */
391   const AliFMDRecoParam* GetParameters() const;
392   /** 
393    * Get the numeric identifier of this detector
394    * 
395    * @return Should be 12
396    */  
397   Int_t GetIdentifier() const;
398   enum Vertex_t {
399     kNoVertex,   // Got no vertex
400     kGenVertex,  // Got generator vertex 
401     kESDVertex   // Got ESD vertex 
402   };
403   mutable TClonesArray* fMult;          // Cache of RecPoints
404   mutable Int_t         fNMult;         // Number of entries in fMult 
405   mutable TTree*        fTreeR;         // Output tree 
406   mutable Float_t       fCurrentVertex; // Z-coordinate of primary vertex
407   mutable AliESDFMD*    fESDObj;        // ESD output object
408   mutable Float_t       fNoiseFactor;   // Factor of noise to check
409   mutable Bool_t        fAngleCorrect;  // Whether to angle correct
410   mutable Vertex_t      fVertexType;    // What kind of vertex we got
411   AliESDEvent*          fESD;           // ESD object(?)
412   Bool_t                fDiagnostics;   // Wheter to do diagnostics
413   TH1*                  fDiagStep1;     // Diagnostics histogram
414   TH1*                  fDiagStep2;     // Diagnostics histogram
415   TH1*                  fDiagStep3;     // Diagnostics histogram
416   TH1*                  fDiagStep4;     // Diagnostics histogram
417   TH1*                  fDiagAll;       // Diagnostics histogram
418   mutable Bool_t        fZS[3];         // Zero-suppredded?
419   mutable UShort_t      fZSFactor[3];   // Noise factor for Zero-suppression
420   mutable AliFMDBoolMap fBad;           // Strip marked bad
421 private:
422    
423   ClassDef(AliFMDReconstructor, 3)  // class for the FMD reconstruction
424 }; 
425 #endif
426 //____________________________________________________________________
427 //
428 // Local Variables:
429 //   mode: C++
430 // End:
431 //
432 // EOF
433 //