]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/older/AliFMDHistCollector.h
New implementation of the forward multiplicity analysis.
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / older / 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 class TH1I;
10 class TH1F;
11
12 /** 
13  * This class collects the event histograms into single histograms, 
14  * one for each ring in each vertex bin.  
15  *
16  * @par Input:
17  *   - AliESDFMD object possibly corrected for sharing
18  *
19  * @par Output:
20  *   - 5 RingHistos objects - each with a number of vertex dependent 
21  *     2D histograms of the inclusive charge particle density 
22  * 
23  * @par HistCollector used: 
24  *   - AliFMDAnaCalibBackgroundCorrection
25  *
26  * @ingroup pwg2_forward_analysis 
27  */
28 class AliFMDHistCollector : public TNamed
29 {
30 public:
31   /** 
32    * Constructor 
33    */
34   AliFMDHistCollector();
35   /** 
36    * Constructor 
37    * 
38    * @param name Name of object
39    */
40   AliFMDHistCollector(const char* name);
41   /** 
42    * Copy constructor 
43    * 
44    * @param o Object to copy from 
45    */
46   AliFMDHistCollector(const AliFMDHistCollector& o);
47   /** 
48    * Destructor 
49    */
50   virtual ~AliFMDHistCollector();
51   /** 
52    * Assignement operator
53    * 
54    * @param o Object to assign from 
55    * 
56    * @return Reference to this object
57    */
58   AliFMDHistCollector& operator=(const AliFMDHistCollector&);
59   /** 
60    * Intialise 
61    * 
62    * @param vtxAxis  Vertex axis 
63    * @param etaAxis  Eta axis 
64    */  
65   virtual void Init(const TAxis& vtxAxis, const TAxis& etaAxis);
66   /** 
67    * Do the calculations 
68    * 
69    * @param hists    Cache of histograms 
70    * @param vtxBin   Vertex bin 
71    * @param out      Output histogram
72    * 
73    * @return true on successs 
74    */
75   virtual Bool_t Collect(AliForwardUtil::Histos& hists, Int_t vtxBin, 
76                          TH2D& out);
77   /** 
78    * Scale the histograms to the total number of events 
79    * 
80    * @param nEvents Number of events 
81    */
82   void ScaleHistograms(const TH1I& nEvents);
83   /** 
84    * Output diagnostic histograms to directory 
85    * 
86    * @param dir List to write in
87    */  
88   void Output(TList* dir);
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    * Whether to use the eta range from the data 
106    * 
107    * @param use 
108    */
109   void UseEtaFromData(Bool_t use=kTRUE) { fUseEtaFromData = use; }
110 protected:
111   /** 
112    * Add the 5 input histograms to our internal sum of vertex
113    * dependent histograms
114    * 
115    * @param hists   Result 
116    * @param vtxBin  Vertex bin 
117    */
118   virtual void Store(AliForwardUtil::Histos& hists, Int_t vtxBin);
119   /** 
120    * Merge the 5 input histograms into a single histogram
121    * 
122    * @param hists   Result
123    * @param vtxBin  Vertex bin
124    * @param out     Output histogram 
125    */
126   virtual void Merge(AliForwardUtil::Histos& hists, Int_t vtxBin, TH2D& out);
127   /** 
128    * Get the first and last eta bin to use for a given ring and vertex 
129    * 
130    * @param d        Detector
131    * @param r        Ring 
132    * @param vtxBin   Vertex bin 
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(UShort_t d, Char_t r, Int_t vtxBin, 
137                                Int_t& first, Int_t& last) const;
138   /** 
139    * Get the first and last eta bin to use for a given ring and vertex 
140    * 
141    * @param idx      Ring index as given by GetIdx
142    * @param vtxBin   Vertex bin 
143    * @param first    On return, the first eta bin to use 
144    * @param last     On return, the last eta bin to use 
145    */
146   virtual void GetFirstAndLast(Int_t idx, Int_t vtxBin, 
147                                Int_t& first, Int_t& last) const;
148   /** 
149    * Get the first eta bin to use for a given ring and vertex 
150    * 
151    * @param d Detector 
152    * @param r Ring 
153    * @param v vertex bin
154    * 
155    * @return First eta bin to use, or -1 in case of problems 
156    */  
157   Int_t GetFirst(UShort_t d, Char_t r, Int_t v) const; 
158   /** 
159    * Get the first eta bin to use for a given ring and vertex 
160    * 
161    * @param i Ring index as given by GetIdx
162    * @param v vertex bin
163    * 
164    * @return First eta bin to use, or -1 in case of problems 
165    */  
166   Int_t GetFirst(Int_t idx, Int_t v) const; 
167   /** 
168    * Get the last eta bin to use for a given ring and vertex 
169    * 
170    * @param d Detector 
171    * @param r Ring 
172    * @param v vertex bin
173    * 
174    * @return Last eta bin to use, or -1 in case of problems 
175    */  
176   Int_t GetLast(UShort_t d, Char_t r, Int_t v) const;
177   /** 
178    * Get the last eta bin to use for a given ring and vertex 
179    * 
180    * @param i Ring index as given by GetIdx
181    * @param v vertex bin
182    * 
183    * @return Last eta bin to use, or -1 in case of problems 
184    */  
185   Int_t GetLast(Int_t idx, Int_t v) const; 
186   /** 
187    * Get the detector and ring from the ring index 
188    * 
189    * @param idx Ring index 
190    * @param d   On return, the detector or 0 in case of errors 
191    * @param r   On return, the ring id or '\0' in case of errors 
192    */
193   void GetDetRing(Int_t idx, UShort_t& d, Char_t& r) const;
194   /** 
195    * Get the ring index from detector number and ring identifier 
196    * 
197    * @param d Detector
198    * @param r Ring identifier 
199    * 
200    * @return ring index or -1 in case of problems 
201    */
202   Int_t GetIdx(UShort_t d, Char_t r) const;
203   /** 
204    * Get the possibly overlapping histogram of eta bin @a e in 
205    * detector and ring 
206    * 
207    * @param d Detector
208    * @param r Ring 
209    * @param e Eta bin
210    * @param v Vertex bin
211    *
212    * @return Overlapping histogram index or -1
213    */
214   Int_t GetOverlap(UShort_t d, Char_t r, Int_t e, Int_t v) const;
215   /** 
216    * Get the possibly overlapping histogram of eta bin @a e in 
217    * detector and ring 
218    * 
219    * @param i Ring index
220    * @param e Eta bin
221    * @param v Vertex bin
222    *
223    * @return Overlapping histogram index or -1
224    */
225   Int_t GetOverlap(Int_t i, Int_t e, Int_t v) const;
226   /** 
227    * Check if there's an overlapping histogram with this eta bin of
228    * the detector and ring
229    * 
230    * @param d Detector 
231    * @param r Ring 
232    * @param e eta bin
233    * @param v Vertex bin
234    * 
235    * @return True if there's an overlapping histogram 
236    */
237   Bool_t HasOverlap(UShort_t d, Char_t r, Int_t e, Int_t v) const;
238   /** 
239    * Check if there's an overlapping histogram with this eta bin of
240    * ring
241    * 
242    * @param i Ring index
243    * @param e eta bin
244    * @param v Vertex bin
245    * 
246    * @return True if there's an overlapping histogram 
247    */
248   Bool_t HasOverlap(Int_t i, Int_t e, Int_t v) const;
249
250
251   TList       fList;            // List of histogram containers
252   const TH1I* fNEvents;         // Reference event histogram 
253   Int_t       fNCutBins;        // Number of additional bins to cut away
254   Float_t     fCorrectionCut;   // Cut-off on secondary corrections 
255   TArrayI     fFirstBins;       // Array of first eta bins 
256   TArrayI     fLastBins;        // Array of last eta bins 
257   Bool_t      fUseEtaFromData;  // Wether to use the data for the limits
258   TH1F*       fEtaNorm;         // Normalisation in eta 
259   TList       fOutput;
260
261   ClassDef(AliFMDHistCollector,1); // Calculate Nch density 
262 };
263
264 //____________________________________________________________________
265 inline void
266 AliFMDHistCollector::GetFirstAndLast(UShort_t d, Char_t r, Int_t vtxbin, 
267                                      Int_t& first, Int_t& last) const
268 {
269   GetFirstAndLast(GetIdx(d,r), vtxbin, first, last);
270 }
271 //____________________________________________________________________
272 inline Int_t
273 AliFMDHistCollector::GetFirst(UShort_t d, Char_t r, Int_t v) const 
274 {
275   return GetFirst(GetIdx(d,r), v);
276 }
277 //____________________________________________________________________
278 inline Int_t
279 AliFMDHistCollector::GetLast(UShort_t d, Char_t r, Int_t v) const 
280 {
281   return GetLast(GetIdx(d, r), v);
282 }
283 //____________________________________________________________________
284 inline Bool_t
285 AliFMDHistCollector::HasOverlap(UShort_t d, Char_t r, Int_t e, Int_t v) const
286 {
287   return GetOverlap(d,r,e,v) >= 0;
288 }
289 //____________________________________________________________________
290 inline Bool_t
291 AliFMDHistCollector::HasOverlap(Int_t i, Int_t e, Int_t v) const
292 {
293   return GetOverlap(i,e,v) >= 0;
294 }
295
296 #endif
297 // Local Variables:
298 //   mode: C++
299 // End:
300