1 #ifndef ALIROOT_PWG2_FORWARD_ANALYSIS2_ALIFMDHISTCOLLECTOR_H
2 #define ALIROOT_PWG2_FORWARD_ANALYSIS2_ALIFMDHISTCOLLECTOR_H
6 #include "AliForwardUtil.h"
13 * This class collects the event histograms into single histograms,
14 * one for each ring in each vertex bin.
17 * - AliESDFMD object possibly corrected for sharing
20 * - 5 RingHistos objects - each with a number of vertex dependent
21 * 2D histograms of the inclusive charge particle density
23 * @par HistCollector used:
24 * - AliFMDAnaCalibBackgroundCorrection
26 * @ingroup pwg2_forward_analysis
28 class AliFMDHistCollector : public TNamed
34 AliFMDHistCollector();
38 * @param name Name of object
40 AliFMDHistCollector(const char* name);
44 * @param o Object to copy from
46 AliFMDHistCollector(const AliFMDHistCollector& o);
50 virtual ~AliFMDHistCollector();
52 * Assignement operator
54 * @param o Object to assign from
56 * @return Reference to this object
58 AliFMDHistCollector& operator=(const AliFMDHistCollector&);
62 * @param vtxAxis Vertex axis
63 * @param etaAxis Eta axis
65 virtual void Init(const TAxis& vtxAxis, const TAxis& etaAxis);
69 * @param hists Cache of histograms
70 * @param vtxBin Vertex bin
71 * @param out Output histogram
73 * @return true on successs
75 virtual Bool_t Collect(AliForwardUtil::Histos& hists, Int_t vtxBin,
78 * Scale the histograms to the total number of events
80 * @param nEvents Number of events
82 void ScaleHistograms(const TH1I& nEvents);
84 * Output diagnostic histograms to directory
86 * @param dir List to write in
88 void Output(TList* dir);
90 * Set the number of extra bins (beyond the secondary map border)
93 * @param n Number of bins
95 void SetNCutBins(UInt_t n=2) { fNCutBins = n; }
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
103 void SetCorrectionCut(Float_t cut=0.5) { fCorrectionCut = cut; }
105 * Whether to use the eta range from the data
109 void UseEtaFromData(Bool_t use=kTRUE) { fUseEtaFromData = use; }
112 * Add the 5 input histograms to our internal sum of vertex
113 * dependent histograms
115 * @param hists Result
116 * @param vtxBin Vertex bin
118 virtual void Store(AliForwardUtil::Histos& hists, Int_t vtxBin);
120 * Merge the 5 input histograms into a single histogram
122 * @param hists Result
123 * @param vtxBin Vertex bin
124 * @param out Output histogram
126 virtual void Merge(AliForwardUtil::Histos& hists, Int_t vtxBin, TH2D& out);
128 * Get the first and last eta bin to use for a given ring and vertex
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
136 virtual void GetFirstAndLast(UShort_t d, Char_t r, Int_t vtxBin,
137 Int_t& first, Int_t& last) const;
139 * Get the first and last eta bin to use for a given ring and vertex
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
146 virtual void GetFirstAndLast(Int_t idx, Int_t vtxBin,
147 Int_t& first, Int_t& last) const;
149 * Get the first eta bin to use for a given ring and vertex
153 * @param v vertex bin
155 * @return First eta bin to use, or -1 in case of problems
157 Int_t GetFirst(UShort_t d, Char_t r, Int_t v) const;
159 * Get the first eta bin to use for a given ring and vertex
161 * @param i Ring index as given by GetIdx
162 * @param v vertex bin
164 * @return First eta bin to use, or -1 in case of problems
166 Int_t GetFirst(Int_t idx, Int_t v) const;
168 * Get the last eta bin to use for a given ring and vertex
172 * @param v vertex bin
174 * @return Last eta bin to use, or -1 in case of problems
176 Int_t GetLast(UShort_t d, Char_t r, Int_t v) const;
178 * Get the last eta bin to use for a given ring and vertex
180 * @param i Ring index as given by GetIdx
181 * @param v vertex bin
183 * @return Last eta bin to use, or -1 in case of problems
185 Int_t GetLast(Int_t idx, Int_t v) const;
187 * Get the detector and ring from the ring index
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
193 void GetDetRing(Int_t idx, UShort_t& d, Char_t& r) const;
195 * Get the ring index from detector number and ring identifier
198 * @param r Ring identifier
200 * @return ring index or -1 in case of problems
202 Int_t GetIdx(UShort_t d, Char_t r) const;
204 * Get the possibly overlapping histogram of eta bin @a e in
210 * @param v Vertex bin
212 * @return Overlapping histogram index or -1
214 Int_t GetOverlap(UShort_t d, Char_t r, Int_t e, Int_t v) const;
216 * Get the possibly overlapping histogram of eta bin @a e in
219 * @param i Ring index
221 * @param v Vertex bin
223 * @return Overlapping histogram index or -1
225 Int_t GetOverlap(Int_t i, Int_t e, Int_t v) const;
227 * Check if there's an overlapping histogram with this eta bin of
228 * the detector and ring
233 * @param v Vertex bin
235 * @return True if there's an overlapping histogram
237 Bool_t HasOverlap(UShort_t d, Char_t r, Int_t e, Int_t v) const;
239 * Check if there's an overlapping histogram with this eta bin of
242 * @param i Ring index
244 * @param v Vertex bin
246 * @return True if there's an overlapping histogram
248 Bool_t HasOverlap(Int_t i, Int_t e, Int_t v) const;
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
261 ClassDef(AliFMDHistCollector,1); // Calculate Nch density
264 //____________________________________________________________________
266 AliFMDHistCollector::GetFirstAndLast(UShort_t d, Char_t r, Int_t vtxbin,
267 Int_t& first, Int_t& last) const
269 GetFirstAndLast(GetIdx(d,r), vtxbin, first, last);
271 //____________________________________________________________________
273 AliFMDHistCollector::GetFirst(UShort_t d, Char_t r, Int_t v) const
275 return GetFirst(GetIdx(d,r), v);
277 //____________________________________________________________________
279 AliFMDHistCollector::GetLast(UShort_t d, Char_t r, Int_t v) const
281 return GetLast(GetIdx(d, r), v);
283 //____________________________________________________________________
285 AliFMDHistCollector::HasOverlap(UShort_t d, Char_t r, Int_t e, Int_t v) const
287 return GetOverlap(d,r,e,v) >= 0;
289 //____________________________________________________________________
291 AliFMDHistCollector::HasOverlap(Int_t i, Int_t e, Int_t v) const
293 return GetOverlap(i,e,v) >= 0;