]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/AliFMDHistCollector.h
New energy fitter that uses Landaus convolved with gaussians.
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / AliFMDHistCollector.h
1 #ifndef ALIROOT_PWG2_FORWARD_ANALYSIS2_ALIFMDHISTCOLLECTOR_H
2 #define ALIROOT_PWG2_FORWARD_ANALYSIS2_ALIFMDHISTCOLLECTOR_H
3 #include <TNamed.h>
4 #include <TList.h>
5 #include <TArrayI.h>
6 #include "AliForwardUtil.h"
7 class AliESDFMD;
8 class TH2D;
9
10 /** 
11  * This class collects the event histograms into single histograms, 
12  * one for each ring in each vertex bin.  
13  *
14  * @par Input:
15  *   - AliESDFMD object possibly corrected for sharing
16  *
17  * @par Output:
18  *   - 5 RingHistos objects - each with a number of vertex dependent 
19  *     2D histograms of the inclusive charge particle density 
20  * 
21  * @par HistCollector used: 
22  *   - AliFMDAnaCalibBackgroundCorrection
23  *
24  * @ingroup pwg2_forward_analysis 
25  */
26 class AliFMDHistCollector : public TNamed
27 {
28 public:
29   /** 
30    * Constructor 
31    */
32   AliFMDHistCollector() 
33     : fNCutBins(0), fCorrectionCut(0), fFirstBins(), fLastBins()
34   {}
35   /** 
36    * Constructor 
37    * 
38    * @param title Name of object
39    */
40   AliFMDHistCollector(const char* title)
41     : TNamed("fmdHistCollector", title), 
42       fNCutBins(1), fCorrectionCut(0.5), fFirstBins(1), fLastBins(1)
43   {}
44   /** 
45    * Copy constructor 
46    * 
47    * @param o Object to copy from 
48    */
49   AliFMDHistCollector(const AliFMDHistCollector& o)
50     : TNamed(o), 
51       fNCutBins(o.fNCutBins), fCorrectionCut(o.fCorrectionCut),
52       fFirstBins(o.fFirstBins), fLastBins(o.fLastBins) 
53   {}
54
55   /** 
56    * Destructor 
57    */
58   virtual ~AliFMDHistCollector() {}
59   /** 
60    * Assignement operator
61    * 
62    * @return Reference to this object
63    */
64   AliFMDHistCollector& operator=(const AliFMDHistCollector&);
65   /** 
66    * Intialise 
67    * 
68    * @param vtxAxis  Vertex axis 
69    */  
70   virtual void Init(const TAxis& vtxAxis);
71   /** 
72    * Do the calculations 
73    * 
74    * @param hists    Cache of histograms 
75    * @param vtxBin   Vertex bin 
76    * @param out      Output histogram
77    * 
78    * @return true on successs 
79    */
80   virtual Bool_t Collect(AliForwardUtil::Histos& hists, Int_t vtxBin, 
81                          TH2D& out);
82   /** 
83    * Set the number of extra bins (beyond the secondary map border) 
84    * to cut away. 
85    * 
86    * @param n Number of bins 
87    */
88   void SetNCutBins(UInt_t n=2) { fNCutBins = n; }
89   /** 
90    * Set the correction cut, that is, when bins in the secondary
91    * correction maps have a value lower than this cut, they are
92    * considered uncertain and not used
93    * 
94    * @param cut Cut-off 
95    */
96   void SetCorrectionCut(Float_t cut=0.5) { fCorrectionCut = cut; }
97 protected:
98   /** 
99    * Get the first and last eta bin to use for a given ring and vertex 
100    * 
101    * @param d        Detector
102    * @param r        Ring 
103    * @param vtxBin   Vertex bin 
104    * @param first    On return, the first eta bin to use 
105    * @param last     On return, the last eta bin to use 
106    */
107   virtual void GetFirstAndLast(UShort_t d, Char_t r, Int_t vtxBin, 
108                                Int_t& first, Int_t& last) const;
109   /** 
110    * Get the first and last eta bin to use for a given ring and vertex 
111    * 
112    * @param idx      Ring index as given by GetIdx
113    * @param vtxBin   Vertex bin 
114    * @param first    On return, the first eta bin to use 
115    * @param last     On return, the last eta bin to use 
116    */
117   virtual void GetFirstAndLast(Int_t idx, Int_t vtxBin, 
118                                Int_t& first, Int_t& last) const;
119   /** 
120    * Get the first eta bin to use for a given ring and vertex 
121    * 
122    * @param d Detector 
123    * @param r Ring 
124    * @param v vertex bin
125    * 
126    * @return First eta bin to use, or -1 in case of problems 
127    */  
128   Int_t GetFirst(UShort_t d, Char_t r, Int_t v) const; 
129   /** 
130    * Get the first eta bin to use for a given ring and vertex 
131    * 
132    * @param idx Ring index as given by GetIdx
133    * @param v vertex bin
134    * 
135    * @return First eta bin to use, or -1 in case of problems 
136    */  
137   Int_t GetFirst(Int_t idx, Int_t v) const; 
138   /** 
139    * Get the last eta bin to use for a given ring and vertex 
140    * 
141    * @param d Detector 
142    * @param r Ring 
143    * @param v vertex bin
144    * 
145    * @return Last eta bin to use, or -1 in case of problems 
146    */  
147   Int_t GetLast(UShort_t d, Char_t r, Int_t v) const;
148   /** 
149    * Get the last eta bin to use for a given ring and vertex 
150    * 
151    * @param idx Ring index as given by GetIdx
152    * @param v vertex bin
153    * 
154    * @return Last eta bin to use, or -1 in case of problems 
155    */  
156   Int_t GetLast(Int_t idx, Int_t v) const; 
157   /** 
158    * Get the detector and ring from the ring index 
159    * 
160    * @param idx Ring index 
161    * @param d   On return, the detector or 0 in case of errors 
162    * @param r   On return, the ring id or '0' in case of errors 
163    */
164   void GetDetRing(Int_t idx, UShort_t& d, Char_t& r) const;
165   /** 
166    * Get the ring index from detector number and ring identifier 
167    * 
168    * @param d Detector
169    * @param r Ring identifier 
170    * 
171    * @return ring index or -1 in case of problems 
172    */
173   Int_t GetIdx(UShort_t d, Char_t r) const;
174   /** 
175    * Get the possibly overlapping histogram of eta bin @a e in 
176    * detector and ring 
177    * 
178    * @param d Detector
179    * @param r Ring 
180    * @param e Eta bin
181    * @param v Vertex bin
182    *
183    * @return Overlapping histogram index or -1
184    */
185   Int_t GetOverlap(UShort_t d, Char_t r, Int_t e, Int_t v) const;
186   /** 
187    * Get the possibly overlapping histogram of eta bin @a e in 
188    * detector and ring 
189    * 
190    * @param i Ring index
191    * @param e Eta bin
192    * @param v Vertex bin
193    *
194    * @return Overlapping histogram index or -1
195    */
196   Int_t GetOverlap(Int_t i, Int_t e, Int_t v) const;
197   /** 
198    * Check if there's an overlapping histogram with this eta bin of
199    * the detector and ring
200    * 
201    * @param d Detector 
202    * @param r Ring 
203    * @param e eta bin
204    * @param v Vertex bin
205    * 
206    * @return True if there's an overlapping histogram 
207    */
208   Bool_t HasOverlap(UShort_t d, Char_t r, Int_t e, Int_t v) const;
209   /** 
210    * Check if there's an overlapping histogram with this eta bin of
211    * ring
212    * 
213    * @param i Ring index
214    * @param e eta bin
215    * @param v Vertex bin
216    * 
217    * @return True if there's an overlapping histogram 
218    */
219   Bool_t HasOverlap(Int_t i, Int_t e, Int_t v) const;
220
221
222   Int_t       fNCutBins;        // Number of additional bins to cut away
223   Float_t     fCorrectionCut;   // Cut-off on secondary corrections 
224   TArrayI     fFirstBins;       // Array of first eta bins 
225   TArrayI     fLastBins;        // Array of last eta bins 
226
227   ClassDef(AliFMDHistCollector,1); // Calculate Nch density 
228 };
229
230 //____________________________________________________________________
231 inline void
232 AliFMDHistCollector::GetFirstAndLast(UShort_t d, Char_t r, Int_t vtxbin, 
233                                      Int_t& first, Int_t& last) const
234 {
235   GetFirstAndLast(GetIdx(d,r), vtxbin, first, last);
236 }
237 //____________________________________________________________________
238 inline Int_t
239 AliFMDHistCollector::GetFirst(UShort_t d, Char_t r, Int_t v) const 
240 {
241   return GetFirst(GetIdx(d,r), v);
242 }
243 //____________________________________________________________________
244 inline Int_t
245 AliFMDHistCollector::GetLast(UShort_t d, Char_t r, Int_t v) const 
246 {
247   return GetLast(GetIdx(d, r), v);
248 }
249 //____________________________________________________________________
250 inline Bool_t
251 AliFMDHistCollector::HasOverlap(UShort_t d, Char_t r, Int_t e, Int_t v) const
252 {
253   return GetOverlap(d,r,e,v) >= 0;
254 }
255 //____________________________________________________________________
256 inline Bool_t
257 AliFMDHistCollector::HasOverlap(Int_t i, Int_t e, Int_t v) const
258 {
259   return GetOverlap(i,e,v) >= 0;
260 }
261
262 #endif
263 // Local Variables:
264 //   mode: C++
265 // End:
266