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