2 // This class collects the event histograms into single histograms,
3 // one for each ring in each vertex bin.
5 #ifndef ALIFMDHISTCOLLECTOR_H
6 #define ALIFMDHISTCOLLECTOR_H
8 * @file AliFMDHistCollector.h
9 * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
10 * @date Wed Mar 23 14:03:01 2011
15 * @ingroup pwglf_forward_aod
20 #include "AliForwardUtil.h"
25 * This class collects the event histograms into single histograms,
26 * one for each ring in each vertex bin.
29 * - AliESDFMD object possibly corrected for sharing
32 * - 5 RingHistos objects - each with a number of vertex dependent
33 * 2D histograms of the inclusive charge particle density
35 * @par HistCollector used:
36 * - AliFMDCorrSecondaryMap
38 * @ingroup pwglf_forward_algo
39 * @ingroup pwglf_forward_aod
41 class AliFMDHistCollector : public TNamed
45 * Methods to use when merging overlapping bins @f$b_1@f$, @f$b_2@f$
46 * with content @f$c_1@f$, @f$c_2@f$, and errors @f$e_1@f$,
47 * @f$e_2@f$ into bin @f$ b@f$ with content @f$c@f$ and error @f$e@f$
52 * c = \frac{1}{2}(c_1+c_2)
55 * e = \sqrt{e_1^2+e_2^2}
60 * As above, exept zero's are ignored
65 * c = \frac{\frac{c_1}{e_1^2}+\frac{c_2}{e_2^2}}{
66 * \frac{1}{e_1^2}+\frac{1}{e_2^2}}
69 * e = \sqrt{\frac{1}{\frac{1}{e_1^2}+\frac{1}{e_2^2}}}
75 * c = \left\{\begin{array}{cl}
76 * c_1 & \mbox{if $e_1 < e_2$} \\
77 * c_2 & \mbox{otherwise}\end{array}\right.
83 * How to obtain the fiducial cuts
87 * Select bins by fixed cut. Bins with a secondary correction
88 * less than the cut is considered as non-valid
92 * A bin is considered non-valid, if it is less then twice as
93 * large as it's neighbors (in eta)
100 AliFMDHistCollector();
104 * @param title Name of object
106 AliFMDHistCollector(const char* title);
110 * @param o Object to copy from
112 AliFMDHistCollector(const AliFMDHistCollector& o);
117 virtual ~AliFMDHistCollector();
119 * Assignement operator
121 * @param o Object to assign from
123 * @return Reference to this object
125 AliFMDHistCollector& operator=(const AliFMDHistCollector&);
129 * @param vtxAxis @f$ v_z@f$ axis
130 * @param etaAxis @f$ \eta@f$ axis
132 virtual void Init(const TAxis& vtxAxis,
133 const TAxis& etaAxis);
135 * Do the calculations
137 * @param hists Cache of histograms
138 * @param sums Cache to sum ring histograms in
139 * @param vtxBin Vertex bin (1 based)
140 * @param out Output histogram
142 * @return true on successs
144 virtual Bool_t Collect(const AliForwardUtil::Histos& hists,
145 AliForwardUtil::Histos& sums,
149 * Output diagnostic histograms to directory
151 * @param dir List to write in
153 virtual void DefineOutput(TList* dir);
155 * Set the merge method
159 void SetMergeMethod(MergeMethod m) { fMergeMethod = m; }
161 * Set the method for finding the fidicual area of the secondary maps
165 void SetFiducialMethod(FiducialMethod m) { fFiducialMethod = m; }
167 * Set the number of extra bins (beyond the secondary map border)
170 * @param n Number of bins
172 void SetNCutBins(UInt_t n=2) { fNCutBins = n; }
174 * Set the correction cut, that is, when bins in the secondary
175 * correction maps have a value lower than this cut, they are
176 * considered uncertain and not used
180 void SetCorrectionCut(Float_t cut=0.5) { fCorrectionCut = cut; }
182 * Set the debug level. The higher the value the more output
184 * @param dbg Debug level
186 void SetDebug(Int_t dbg=1) { fDebug = dbg; }
190 * @param option Not used
192 void Print(Option_t* option="") const;
195 * Get the first and last eta bin to use for a given ring and vertex
199 * @param vtxBin Vertex bin (1 based)
200 * @param first On return, the first eta bin to use
201 * @param last On return, the last eta bin to use
203 virtual void GetFirstAndLast(UShort_t d, Char_t r, UShort_t vtxBin,
204 Int_t& first, Int_t& last) const;
206 * Get the first and last eta bin to use for a given ring and vertex
208 * @param idx Ring index as given by GetIdx
209 * @param vtxBin Vertex bin (1 based)
210 * @param first On return, the first eta bin to use
211 * @param last On return, the last eta bin to use
213 virtual void GetFirstAndLast(Int_t idx, UShort_t vtxBin,
214 Int_t& first, Int_t& last) const;
216 * Get the first eta bin to use for a given ring and vertex
220 * @param v vertex bin (1 based)
222 * @return First eta bin to use, or -1 in case of problems
224 Int_t GetFirst(UShort_t d, Char_t r, UShort_t v) const;
226 * Get the first eta bin to use for a given ring and vertex
228 * @param idx Ring index as given by GetIdx
229 * @param v vertex bin (1 based)
231 * @return First eta bin to use, or -1 in case of problems
233 Int_t GetFirst(Int_t idx, UShort_t v) const;
235 * Get the last eta bin to use for a given ring and vertex
239 * @param v vertex bin (1 based)
241 * @return Last eta bin to use, or -1 in case of problems
243 Int_t GetLast(UShort_t d, Char_t r, UShort_t v) const;
245 * Get the last eta bin to use for a given ring and vertex
247 * @param idx Ring index as given by GetIdx
248 * @param v vertex bin (1 based)
250 * @return Last eta bin to use, or -1 in case of problems
252 Int_t GetLast(Int_t idx, UShort_t v) const;
254 * Get the detector and ring from the ring index
256 * @param idx Ring index
257 * @param d On return, the detector or 0 in case of errors
258 * @param r On return, the ring id or '0' in case of errors
260 void GetDetRing(Int_t idx, UShort_t& d, Char_t& r) const;
262 * Get the ring index from detector number and ring identifier
265 * @param r Ring identifier
267 * @return ring index or -1 in case of problems
269 Int_t GetIdx(UShort_t d, Char_t r) const;
271 * Get the possibly overlapping histogram of eta bin @a e in
277 * @param v Vertex bin (1 based)
279 * @return Overlapping histogram index or -1
281 Int_t GetOverlap(UShort_t d, Char_t r, Int_t e, UShort_t v) const;
283 * Get the possibly overlapping histogram of eta bin @a e in
286 * @param i Ring index
288 * @param v Vertex bin (1 based)
290 * @return Overlapping histogram index or -1
292 Int_t GetOverlap(Int_t i, Int_t e, UShort_t v) const;
294 * Check if there's an overlapping histogram with this eta bin of
295 * the detector and ring
300 * @param v Vertex bin (1 based)
302 * @return True if there's an overlapping histogram
304 Bool_t HasOverlap(UShort_t d, Char_t r, Int_t e, UShort_t v) const;
306 * Check if there's an overlapping histogram with this eta bin of
309 * @param i Ring index
311 * @param v Vertex bin
313 * @return True if there's an overlapping histogram
315 Bool_t HasOverlap(Int_t i, Int_t e, UShort_t v) const;
317 * Check if we should include the bin in the data range
319 * @param bg Secondary map histogram
323 * @return True if to be used
325 Bool_t CheckCorrection(const TH2D* bg, Int_t ie, Int_t ip) const;
327 * Merge bins accoring to set method
329 * @param c Current content
330 * @param e Current error
331 * @param oc Old content
332 * @param oe Old error
333 * @param rc On return, the new content
334 * @param re On return, tne new error
336 void MergeBins(Double_t c, Double_t e,
337 Double_t oc, Double_t oe,
338 Double_t& rc, Double_t& re) const;
341 Int_t fNCutBins; // Number of additional bins to cut away
342 Float_t fCorrectionCut; // Cut-off on secondary corrections
343 TArrayI fFirstBins; // Array of first eta bins
344 TArrayI fLastBins; // Array of last eta bins
345 Int_t fDebug; // Debug level
346 TList* fList; // Output list
347 TH2D* fSumRings; // Sum per ring (on y-axis)
348 TH2D* fCoverage; // Sum per ring (on y-axis)
349 MergeMethod fMergeMethod; // Merge methiod for overlapping bins
350 FiducialMethod fFiducialMethod; // Fidicual method
352 ClassDef(AliFMDHistCollector,1); // Calculate Nch density
355 //____________________________________________________________________
357 AliFMDHistCollector::GetFirstAndLast(UShort_t d, Char_t r, UShort_t vtxbin,
358 Int_t& first, Int_t& last) const
360 GetFirstAndLast(GetIdx(d,r), vtxbin, first, last);
362 //____________________________________________________________________
364 AliFMDHistCollector::GetFirst(UShort_t d, Char_t r, UShort_t v) const
366 return GetFirst(GetIdx(d,r), v);
368 //____________________________________________________________________
370 AliFMDHistCollector::GetLast(UShort_t d, Char_t r, UShort_t v) const
372 return GetLast(GetIdx(d, r), v);
374 //____________________________________________________________________
376 AliFMDHistCollector::HasOverlap(UShort_t d, Char_t r, Int_t e, UShort_t v) const
378 return GetOverlap(d,r,e,v) >= 0;
380 //____________________________________________________________________
382 AliFMDHistCollector::HasOverlap(Int_t i, Int_t e, UShort_t v) const
384 return GetOverlap(i,e,v) >= 0;