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)
98 * FMD ring bits for skipping
113 AliFMDHistCollector();
117 * @param title Name of object
119 AliFMDHistCollector(const char* title);
123 * @param o Object to copy from
125 AliFMDHistCollector(const AliFMDHistCollector& o);
130 virtual ~AliFMDHistCollector();
132 * Assignement operator
134 * @param o Object to assign from
136 * @return Reference to this object
138 AliFMDHistCollector& operator=(const AliFMDHistCollector&);
142 * @param vtxAxis @f$ v_z@f$ axis
143 * @param etaAxis @f$ \eta@f$ axis
145 virtual void Init(const TAxis& vtxAxis,
146 const TAxis& etaAxis);
148 * Do the calculations
150 * @param hists Cache of histograms
151 * @param sums Cache to sum ring histograms in
152 * @param vtxBin Vertex bin (1 based)
153 * @param out Output histogram
155 * @return true on successs
157 virtual Bool_t Collect(const AliForwardUtil::Histos& hists,
158 AliForwardUtil::Histos& sums,
162 * Output diagnostic histograms to directory
164 * @param dir List to write in
166 virtual void DefineOutput(TList* dir);
168 * Set the merge method
172 void SetMergeMethod(MergeMethod m) { fMergeMethod = m; }
174 * Set the method for finding the fidicual area of the secondary maps
178 void SetFiducialMethod(FiducialMethod m) { fFiducialMethod = m; }
180 * Set the number of extra bins (beyond the secondary map border)
183 * @param n Number of bins
185 void SetNCutBins(UInt_t n=2) { fNCutBins = n; }
187 * Set the correction cut, that is, when bins in the secondary
188 * correction maps have a value lower than this cut, they are
189 * considered uncertain and not used
193 void SetCorrectionCut(Float_t cut=0.5) { fCorrectionCut = cut; }
195 * Set FMD rings to skip. Argument should be kFirstRingToSkip|kSecondRingToSkip...
197 * @param mask bit pattern
199 void SetFMDRingsToSkip(UShort_t mask) { fSkipFMDRings = mask; }
201 * Set whether to make bg maps or not
203 * @param use make them
205 void SetMakeBGHitMaps(Bool_t use) { fBgAndHitMaps = use; }
208 * Set the debug level. The higher the value the more output
210 * @param dbg Debug level
213 void SetDebug(Int_t dbg=1) { fDebug = dbg; }
217 * @param option Not used
219 void Print(Option_t* option="") const;
222 * Get the first and last eta bin to use for a given ring and vertex
226 * @param vtxBin Vertex bin (1 based)
227 * @param first On return, the first eta bin to use
228 * @param last On return, the last eta bin to use
230 virtual void GetFirstAndLast(UShort_t d, Char_t r, UShort_t vtxBin,
231 Int_t& first, Int_t& last) const;
233 * Get the first and last eta bin to use for a given ring and vertex
235 * @param idx Ring index as given by GetIdx
236 * @param vtxBin Vertex bin (1 based)
237 * @param first On return, the first eta bin to use
238 * @param last On return, the last eta bin to use
240 virtual void GetFirstAndLast(Int_t idx, UShort_t vtxBin,
241 Int_t& first, Int_t& last) const;
243 * Get the first eta bin to use for a given ring and vertex
247 * @param v vertex bin (1 based)
249 * @return First eta bin to use, or -1 in case of problems
251 Int_t GetFirst(UShort_t d, Char_t r, UShort_t v) const;
253 * Get the first eta bin to use for a given ring and vertex
255 * @param idx Ring index as given by GetIdx
256 * @param v vertex bin (1 based)
258 * @return First eta bin to use, or -1 in case of problems
260 Int_t GetFirst(Int_t idx, UShort_t v) const;
262 * Get the last eta bin to use for a given ring and vertex
266 * @param v vertex bin (1 based)
268 * @return Last eta bin to use, or -1 in case of problems
270 Int_t GetLast(UShort_t d, Char_t r, UShort_t v) const;
272 * Get the last eta bin to use for a given ring and vertex
274 * @param idx Ring index as given by GetIdx
275 * @param v vertex bin (1 based)
277 * @return Last eta bin to use, or -1 in case of problems
279 Int_t GetLast(Int_t idx, UShort_t v) const;
281 * Get the detector and ring from the ring index
283 * @param idx Ring index
284 * @param d On return, the detector or 0 in case of errors
285 * @param r On return, the ring id or '0' in case of errors
287 void GetDetRing(Int_t idx, UShort_t& d, Char_t& r) const;
289 * Get the ring index from detector number and ring identifier
292 * @param r Ring identifier
294 * @return ring index or -1 in case of problems
296 Int_t GetIdx(UShort_t d, Char_t r) const;
298 * Get the possibly overlapping histogram of eta bin @a e in
304 * @param v Vertex bin (1 based)
306 * @return Overlapping histogram index or -1
308 Int_t GetOverlap(UShort_t d, Char_t r, Int_t e, UShort_t v) const;
310 * Get the possibly overlapping histogram of eta bin @a e in
313 * @param i Ring index
315 * @param v Vertex bin (1 based)
317 * @return Overlapping histogram index or -1
319 Int_t GetOverlap(Int_t i, Int_t e, UShort_t v) const;
321 * Check if there's an overlapping histogram with this eta bin of
322 * the detector and ring
327 * @param v Vertex bin (1 based)
329 * @return True if there's an overlapping histogram
331 Bool_t HasOverlap(UShort_t d, Char_t r, Int_t e, UShort_t v) const;
333 * Check if there's an overlapping histogram with this eta bin of
336 * @param i Ring index
338 * @param v Vertex bin
340 * @return True if there's an overlapping histogram
342 Bool_t HasOverlap(Int_t i, Int_t e, UShort_t v) const;
344 * Check if we should include the bin in the data range
346 * @param bg Secondary map histogram
350 * @return True if to be used
352 Bool_t CheckCorrection(const TH2D* bg, Int_t ie, Int_t ip) const;
354 * Merge bins accoring to set method
356 * @param c Current content
357 * @param e Current error
358 * @param oc Old content
359 * @param oe Old error
360 * @param rc On return, the new content
361 * @param re On return, tne new error
363 void MergeBins(Double_t c, Double_t e,
364 Double_t oc, Double_t oe,
365 Double_t& rc, Double_t& re) const;
368 Int_t fNCutBins; // Number of additional bins to cut away
369 Float_t fCorrectionCut; // Cut-off on secondary corrections
370 TArrayI fFirstBins; // Array of first eta bins
371 TArrayI fLastBins; // Array of last eta bins
372 Int_t fDebug; // Debug level
373 TList* fList; // Output list
374 TH2D* fSumRings; // Sum per ring (on y-axis)
375 TH2D* fCoverage; // Sum per ring (on y-axis)
376 MergeMethod fMergeMethod; // Merge methiod for overlapping bins
377 FiducialMethod fFiducialMethod; // Fidicual method
378 UShort_t fSkipFMDRings; // FMD rings to ignore
379 Bool_t fBgAndHitMaps; // Make hit/bg maps or not
381 ClassDef(AliFMDHistCollector,2); // Calculate Nch density
384 //____________________________________________________________________
386 AliFMDHistCollector::GetFirstAndLast(UShort_t d, Char_t r, UShort_t vtxbin,
387 Int_t& first, Int_t& last) const
389 GetFirstAndLast(GetIdx(d,r), vtxbin, first, last);
391 //____________________________________________________________________
393 AliFMDHistCollector::GetFirst(UShort_t d, Char_t r, UShort_t v) const
395 return GetFirst(GetIdx(d,r), v);
397 //____________________________________________________________________
399 AliFMDHistCollector::GetLast(UShort_t d, Char_t r, UShort_t v) const
401 return GetLast(GetIdx(d, r), v);
403 //____________________________________________________________________
405 AliFMDHistCollector::HasOverlap(UShort_t d, Char_t r, Int_t e, UShort_t v) const
407 return GetOverlap(d,r,e,v) >= 0;
409 //____________________________________________________________________
411 AliFMDHistCollector::HasOverlap(Int_t i, Int_t e, UShort_t v) const
413 return GetOverlap(i,e,v) >= 0;