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