]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/AliFMDDensityCalculator.h
Renames and new scripts
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / AliFMDDensityCalculator.h
1 // This class calculates the inclusive charged particle density
2 // in each for the 5 FMD rings. 
3 //
4 #ifndef ALIFMDDENSITYCALCULATOR_H
5 #define ALIFMDDENSITYCALCULATOR_H
6 #include <TNamed.h>
7 #include <TList.h>
8 #include <TArrayI.h>
9 #include "AliForwardUtil.h"
10 class AliESDFMD;
11 class TH2D;
12 class TH1D;
13 class TProfile;
14 class AliFMDCorrELossFit;
15
16 /** 
17  * This class calculates the inclusive charged particle density
18  * in each for the 5 FMD rings. 
19  *
20  * @par Input:
21  *   - AliESDFMD object possibly corrected for sharing
22  *
23  * @par Output:
24  *   - 5 RingHistos objects - each with a number of vertex dependent 
25  *     2D histograms of the inclusive charge particle density 
26  * 
27  * @par Corrections used: 
28  *   - AliFMDAnaCalibEnergyDistribution 
29  *   - AliFMDDoubleHitCorrection 
30  *   - AliFMDDeadCorrection 
31  *
32  * @ingroup pwg2_forward_algo
33  */
34 class AliFMDDensityCalculator : public TNamed
35 {
36 public:
37   /** 
38    * Constructor 
39    */
40   AliFMDDensityCalculator();
41   /** 
42    * Constructor 
43    * 
44    * @param name Name of object
45    */
46   AliFMDDensityCalculator(const char* name);
47   /** 
48    * Copy constructor 
49    * 
50    * @param o Object to copy from 
51    */
52   AliFMDDensityCalculator(const AliFMDDensityCalculator& o);
53   /** 
54    * Destructor 
55    */
56   virtual ~AliFMDDensityCalculator();
57   /** 
58    * Assignement operator
59    * 
60    * @param o Object to assign from 
61    * 
62    * @return Reference to this object
63    */
64   AliFMDDensityCalculator& operator=(const AliFMDDensityCalculator& o);
65   /** 
66    * Initialize this sub-algorithm
67    * 
68    * @param etaAxis Not used 
69    */
70   virtual void Init(const TAxis& etaAxis);
71   /** 
72    * Do the calculations 
73    * 
74    * @param fmd      AliESDFMD object (possibly) corrected for sharing
75    * @param hists    Histogram cache
76    * @param vtxBin   Vertex bin 
77    * @param lowFlux  Low flux flag. 
78    * 
79    * @return true on successs 
80    */
81   virtual Bool_t Calculate(const AliESDFMD& fmd, 
82                            AliForwardUtil::Histos& hists, 
83                            UShort_t vtxBin, Bool_t lowFlux);
84   /** 
85    * Scale the histograms to the total number of events 
86    * 
87    * @param dir     where to put the output
88    * @param nEvents Number of events 
89    */
90   virtual void ScaleHistograms(TList* dir, Int_t nEvents);
91   /** 
92    * Output diagnostic histograms to directory 
93    * 
94    * @param dir List to write in
95    */  
96   virtual void DefineOutput(TList* dir);
97   /** 
98    * Set the debug level.  The higher the value the more output 
99    * 
100    * @param dbg Debug level 
101    */
102   void SetDebug(Int_t dbg=1) { fDebug = dbg; }
103   /** 
104    * Maximum particle weight to use 
105    * 
106    * @param m 
107    */
108   void SetMaxParticles(UShort_t m) { fMaxParticles = m; }  
109   /** 
110    * Set the lower multiplicity cut.  This overrides the setting in
111    * the energy loss fits.
112    * 
113    * @param cut Cut to use 
114    */
115   void SetMultCut(Double_t cut) { fMultCut = cut; }
116   /** 
117    * Get the multiplicity cut.  If the user has set fMultCut (via
118    * SetMultCut) then that value is used.  If not, then the lower
119    * value of the fit range for the enery loss fits is returned.
120    * 
121    * @return Lower cut on multiplicity
122    */
123   Double_t GetMultCut() const;
124   /** 
125    * Print information 
126    * 
127    * @param option Print options 
128    *   - max  Print max weights 
129    */
130   void Print(Option_t* option="") const;
131 protected:
132   /** 
133    * Find the max weight to use for FMD<i>dr</i> in eta bin @a iEta
134    * 
135    * @param cor   Correction
136    * @param d     Detector 
137    * @param r     Ring 
138    * @param iEta  Eta bin 
139    */
140   Int_t FindMaxWeight(AliFMDCorrELossFit* cor,
141                       UShort_t d, Char_t r, Int_t iEta) const;
142
143   /** 
144    * Find the max weights and cache them 
145    * 
146    */  
147   void CacheMaxWeights();
148   /** 
149    * Find the (cached) maximum weight for FMD<i>dr</i> in 
150    * @f$\eta@f$ bin @a iEta
151    * 
152    * @param d     Detector
153    * @param r     Ring
154    * @param iEta  Eta bin
155    * 
156    * @return max weight or <= 0 in case of problems 
157    */
158   Int_t GetMaxWeight(UShort_t d, Char_t r, Int_t iEta) const;
159   /** 
160    * Find the (cached) maximum weight for FMD<i>dr</i> iat
161    * @f$\eta@f$ 
162    * 
163    * @param d     Detector
164    * @param r     Ring
165    * @param eta   Eta bin
166    * 
167    * @return max weight or <= 0 in case of problems 
168    */
169   Int_t GetMaxWeight(UShort_t d, Char_t r, Float_t eta) const;
170
171   /** 
172    * Get the number of particles corresponding to the signal mult
173    * 
174    * @param mult     Signal
175    * @param d        Detector
176    * @param r        Ring 
177    * @param s        Sector 
178    * @param t        Strip (not used)
179    * @param v        Vertex bin 
180    * @param eta      Pseudo-rapidity 
181    * @param lowFlux  Low-flux flag 
182    * 
183    * @return The number of particles 
184    */
185   virtual Float_t NParticles(Float_t mult, 
186                              UShort_t d, Char_t r, UShort_t s, UShort_t t, 
187                              UShort_t v, Float_t eta, Bool_t lowFlux) const;
188   /** 
189    * Get the inverse correction factor.  This consist of
190    * 
191    * - acceptance correction (corners of sensors) 
192    * - double hit correction (for low-flux events) 
193    * - dead strip correction 
194    * 
195    * @param d        Detector
196    * @param r        Ring 
197    * @param s        Sector 
198    * @param t        Strip (not used)
199    * @param v        Vertex bin 
200    * @param eta      Pseudo-rapidity 
201    * @param lowFlux  Low-flux flag 
202    * 
203    * @return 
204    */
205   virtual Float_t Correction(UShort_t d, Char_t r, UShort_t s, UShort_t t, 
206                              UShort_t v, Float_t eta, Bool_t lowFlux) const;
207   /** 
208    * Get the acceptance correction for strip @a t in an ring of type @a r
209    * 
210    * @param r  Ring type ('I' or 'O')
211    * @param t  Strip number 
212    * 
213    * @return Inverse acceptance correction 
214    */
215   virtual Float_t AcceptanceCorrection(Char_t r, UShort_t t) const;
216   /** 
217    * Generate the acceptance corrections 
218    * 
219    * @param r Ring to generate for 
220    * 
221    * @return Newly allocated histogram of acceptance corrections
222    */
223   virtual TH1D*   GenerateAcceptanceCorrection(Char_t r) const;
224   /** 
225    * Internal data structure to keep track of the histograms
226    */
227   struct RingHistos : public AliForwardUtil::RingHistos
228   { 
229     /** 
230      * Default CTOR
231      */
232     RingHistos();
233     /** 
234      * Constructor
235      * 
236      * @param d detector
237      * @param r ring 
238      */
239     RingHistos(UShort_t d, Char_t r);
240     /** 
241      * Copy constructor 
242      * 
243      * @param o Object to copy from 
244      */
245     RingHistos(const RingHistos& o);
246     /** 
247      * Assignment operator 
248      * 
249      * @param o Object to assign from 
250      * 
251      * @return Reference to this 
252      */
253     RingHistos& operator=(const RingHistos& o);
254     /** 
255      * Destructor 
256      */
257     ~RingHistos();
258     /** 
259      * Make output 
260      * 
261      * @param dir Where to put it 
262      */
263     void Output(TList* dir);
264     /** 
265      * Scale the histograms to the total number of events 
266      * 
267      * @param dir     Where the output is 
268      * @param nEvents Number of events 
269      */
270     void ScaleHistograms(TList* dir, Int_t nEvents);
271     TH2D*     fEvsN;         // Correlation of Eloss vs uncorrected Nch
272     TH2D*     fEvsM;         // Correlation of Eloss vs corrected Nch
273     TProfile* fEtaVsN;       // Average uncorrected Nch vs eta
274     TProfile* fEtaVsM;       // Average corrected Nch vs eta
275     TProfile* fCorr;         // Average correction vs eta
276     TH2D*     fDensity;      // Distribution inclusive Nch
277     ClassDef(RingHistos,1);
278   };
279   /** 
280    * Get the ring histogram container 
281    * 
282    * @param d Detector
283    * @param r Ring 
284    * 
285    * @return Ring histogram container 
286    */
287   RingHistos* GetRingHistos(UShort_t d, Char_t r) const;
288
289   TList    fRingHistos;    //  List of histogram containers
290   Double_t fMultCut;       //  Low cut on scaled energy loss
291   TH1D*    fSumOfWeights;  //  Histogram
292   TH1D*    fWeightedSum;   //  Histogram
293   TH1D*    fCorrections;   //  Histogram
294   UShort_t fMaxParticles;  //  Maximum particle weight to use 
295   TH1D*    fAccI;          //  Acceptance correction for inner rings
296   TH1D*    fAccO;          //  Acceptance correction for outer rings
297   TArrayI  fFMD1iMax;      //  Array of max weights 
298   TArrayI  fFMD2iMax;      //  Array of max weights 
299   TArrayI  fFMD2oMax;      //  Array of max weights 
300   TArrayI  fFMD3iMax;      //  Array of max weights 
301   TArrayI  fFMD3oMax;      //  Array of max weights 
302   Int_t    fDebug;         //  Debug level 
303
304   ClassDef(AliFMDDensityCalculator,1); // Calculate Nch density 
305 };
306
307 #endif
308 // Local Variables:
309 //   mode: C++
310 // End:
311