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