]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/AliFMDHistCollector.h
Improved eloss fitting - see NIM B1, 16
[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(), fDebug(0)
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), 
43       fFirstBins(1), fLastBins(1), fDebug(0)
44   {}
45   /** 
46    * Copy constructor 
47    * 
48    * @param o Object to copy from 
49    */
50   AliFMDHistCollector(const AliFMDHistCollector& o)
51     : TNamed(o), 
52       fNCutBins(o.fNCutBins), fCorrectionCut(o.fCorrectionCut),
53       fFirstBins(o.fFirstBins), fLastBins(o.fLastBins), fDebug(o.fDebug) 
54   {}
55
56   /** 
57    * Destructor 
58    */
59   virtual ~AliFMDHistCollector() {}
60   /** 
61    * Assignement operator
62    * 
63    * @return Reference to this object
64    */
65   AliFMDHistCollector& operator=(const AliFMDHistCollector&);
66   /** 
67    * Intialise 
68    * 
69    * @param vtxAxis  Vertex axis 
70    */  
71   virtual void Init(const TAxis& vtxAxis);
72   /** 
73    * Do the calculations 
74    * 
75    * @param hists    Cache of histograms 
76    * @param vtxBin   Vertex bin 
77    * @param out      Output histogram
78    * 
79    * @return true on successs 
80    */
81   virtual Bool_t Collect(AliForwardUtil::Histos& hists, Int_t vtxBin, 
82                          TH2D& out);
83   /** 
84    * Set the number of extra bins (beyond the secondary map border) 
85    * to cut away. 
86    * 
87    * @param n Number of bins 
88    */
89   void SetNCutBins(UInt_t n=2) { fNCutBins = n; }
90   /** 
91    * Set the correction cut, that is, when bins in the secondary
92    * correction maps have a value lower than this cut, they are
93    * considered uncertain and not used
94    * 
95    * @param cut Cut-off 
96    */
97   void SetCorrectionCut(Float_t cut=0.5) { fCorrectionCut = cut; }
98   /** 
99    * Set the debug level.  The higher the value the more output 
100    * 
101    * @param dbg Debug level 
102    */
103   void SetDebug(Int_t dbg=1) { fDebug = dbg; }
104 protected:
105   /** 
106    * Get the first and last eta bin to use for a given ring and vertex 
107    * 
108    * @param d        Detector
109    * @param r        Ring 
110    * @param vtxBin   Vertex bin 
111    * @param first    On return, the first eta bin to use 
112    * @param last     On return, the last eta bin to use 
113    */
114   virtual void GetFirstAndLast(UShort_t d, Char_t r, Int_t vtxBin, 
115                                Int_t& first, Int_t& last) const;
116   /** 
117    * Get the first and last eta bin to use for a given ring and vertex 
118    * 
119    * @param idx      Ring index as given by GetIdx
120    * @param vtxBin   Vertex bin 
121    * @param first    On return, the first eta bin to use 
122    * @param last     On return, the last eta bin to use 
123    */
124   virtual void GetFirstAndLast(Int_t idx, Int_t vtxBin, 
125                                Int_t& first, Int_t& last) const;
126   /** 
127    * Get the first eta bin to use for a given ring and vertex 
128    * 
129    * @param d Detector 
130    * @param r Ring 
131    * @param v vertex bin
132    * 
133    * @return First eta bin to use, or -1 in case of problems 
134    */  
135   Int_t GetFirst(UShort_t d, Char_t r, Int_t v) const; 
136   /** 
137    * Get the first eta bin to use for a given ring and vertex 
138    * 
139    * @param idx Ring index as given by GetIdx
140    * @param v vertex bin
141    * 
142    * @return First eta bin to use, or -1 in case of problems 
143    */  
144   Int_t GetFirst(Int_t idx, Int_t v) const; 
145   /** 
146    * Get the last eta bin to use for a given ring and vertex 
147    * 
148    * @param d Detector 
149    * @param r Ring 
150    * @param v vertex bin
151    * 
152    * @return Last eta bin to use, or -1 in case of problems 
153    */  
154   Int_t GetLast(UShort_t d, Char_t r, Int_t v) const;
155   /** 
156    * Get the last eta bin to use for a given ring and vertex 
157    * 
158    * @param idx Ring index as given by GetIdx
159    * @param v vertex bin
160    * 
161    * @return Last eta bin to use, or -1 in case of problems 
162    */  
163   Int_t GetLast(Int_t idx, Int_t v) const; 
164   /** 
165    * Get the detector and ring from the ring index 
166    * 
167    * @param idx Ring index 
168    * @param d   On return, the detector or 0 in case of errors 
169    * @param r   On return, the ring id or '0' in case of errors 
170    */
171   void GetDetRing(Int_t idx, UShort_t& d, Char_t& r) const;
172   /** 
173    * Get the ring index from detector number and ring identifier 
174    * 
175    * @param d Detector
176    * @param r Ring identifier 
177    * 
178    * @return ring index or -1 in case of problems 
179    */
180   Int_t GetIdx(UShort_t d, Char_t r) const;
181   /** 
182    * Get the possibly overlapping histogram of eta bin @a e in 
183    * detector and ring 
184    * 
185    * @param d Detector
186    * @param r Ring 
187    * @param e Eta bin
188    * @param v Vertex bin
189    *
190    * @return Overlapping histogram index or -1
191    */
192   Int_t GetOverlap(UShort_t d, Char_t r, Int_t e, Int_t v) const;
193   /** 
194    * Get the possibly overlapping histogram of eta bin @a e in 
195    * detector and ring 
196    * 
197    * @param i Ring index
198    * @param e Eta bin
199    * @param v Vertex bin
200    *
201    * @return Overlapping histogram index or -1
202    */
203   Int_t GetOverlap(Int_t i, Int_t e, Int_t v) const;
204   /** 
205    * Check if there's an overlapping histogram with this eta bin of
206    * the detector and ring
207    * 
208    * @param d Detector 
209    * @param r Ring 
210    * @param e eta bin
211    * @param v Vertex bin
212    * 
213    * @return True if there's an overlapping histogram 
214    */
215   Bool_t HasOverlap(UShort_t d, Char_t r, Int_t e, Int_t v) const;
216   /** 
217    * Check if there's an overlapping histogram with this eta bin of
218    * ring
219    * 
220    * @param i Ring index
221    * @param e eta bin
222    * @param v Vertex bin
223    * 
224    * @return True if there's an overlapping histogram 
225    */
226   Bool_t HasOverlap(Int_t i, Int_t e, Int_t v) const;
227
228
229   Int_t       fNCutBins;        // Number of additional bins to cut away
230   Float_t     fCorrectionCut;   // Cut-off on secondary corrections 
231   TArrayI     fFirstBins;       // Array of first eta bins 
232   TArrayI     fLastBins;        // Array of last eta bins 
233   Int_t       fDebug;           // Debug level 
234
235   ClassDef(AliFMDHistCollector,1); // Calculate Nch density 
236 };
237
238 //____________________________________________________________________
239 inline void
240 AliFMDHistCollector::GetFirstAndLast(UShort_t d, Char_t r, Int_t vtxbin, 
241                                      Int_t& first, Int_t& last) const
242 {
243   GetFirstAndLast(GetIdx(d,r), vtxbin, first, last);
244 }
245 //____________________________________________________________________
246 inline Int_t
247 AliFMDHistCollector::GetFirst(UShort_t d, Char_t r, Int_t v) const 
248 {
249   return GetFirst(GetIdx(d,r), v);
250 }
251 //____________________________________________________________________
252 inline Int_t
253 AliFMDHistCollector::GetLast(UShort_t d, Char_t r, Int_t v) const 
254 {
255   return GetLast(GetIdx(d, r), v);
256 }
257 //____________________________________________________________________
258 inline Bool_t
259 AliFMDHistCollector::HasOverlap(UShort_t d, Char_t r, Int_t e, Int_t v) const
260 {
261   return GetOverlap(d,r,e,v) >= 0;
262 }
263 //____________________________________________________________________
264 inline Bool_t
265 AliFMDHistCollector::HasOverlap(Int_t i, Int_t e, Int_t v) const
266 {
267   return GetOverlap(i,e,v) >= 0;
268 }
269
270 #endif
271 // Local Variables:
272 //   mode: C++
273 // End:
274