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.
82 * Just sum the signals
87 * How to obtain the fiducial cuts
91 * Select bins by fixed cut. Bins with a secondary correction
92 * less than the cut is considered as non-valid
96 * A bin is considered non-valid, if it is less then twice as
97 * large as it's neighbors (in eta)
102 * FMD ring bits for skipping
109 kFMD2 =kFMD2I|kFMD2O,
117 AliFMDHistCollector();
121 * @param title Name of object
123 AliFMDHistCollector(const char* title);
127 * @param o Object to copy from
129 AliFMDHistCollector(const AliFMDHistCollector& o);
134 virtual ~AliFMDHistCollector();
136 * Assignement operator
138 * @param o Object to assign from
140 * @return Reference to this object
142 AliFMDHistCollector& operator=(const AliFMDHistCollector&);
146 * @param vtxAxis @f$ v_z@f$ axis
147 * @param etaAxis @f$ \eta@f$ axis
149 virtual void Init(const TAxis& vtxAxis,
150 const TAxis& etaAxis);
152 * Do the calculations
154 * @param hists Cache of histograms
155 * @param sums Cache to sum ring histograms in
156 * @param vtxBin Vertex bin (1 based)
157 * @param out Output histogram
159 * @return true on successs
161 virtual Bool_t Collect(const AliForwardUtil::Histos& hists,
162 AliForwardUtil::Histos& sums,
166 * Output diagnostic histograms to directory
168 * @param dir List to write in
170 virtual void DefineOutput(TList* dir);
172 * Set the merge method
176 void SetMergeMethod(MergeMethod m) { fMergeMethod = m; }
178 * Set the method for finding the fidicual area of the secondary maps
182 void SetFiducialMethod(FiducialMethod m) { fFiducialMethod = m; }
184 * Set the number of extra bins (beyond the secondary map border)
187 * @param n Number of bins
189 void SetNCutBins(UInt_t n=2) { fNCutBins = n; }
191 * Set the correction cut, that is, when bins in the secondary
192 * correction maps have a value lower than this cut, they are
193 * considered uncertain and not used
197 void SetCorrectionCut(Float_t cut=0.5) { fCorrectionCut = cut; }
199 * Set FMD rings to skip. Argument should be
200 * kFirstRingToSkip|kSecondRingToSkip...
202 * @param mask bit pattern
204 void SetFMDRingsToSkip(UShort_t mask) { fSkipFMDRings = mask; }
206 * Set whether to make bg maps or not
208 * @param use make them
210 void SetMakeBGHitMaps(Bool_t use) { fBgAndHitMaps = use; }
213 * Set the debug level. The higher the value the more output
215 * @param dbg Debug level
218 void SetDebug(Int_t dbg=1) { fDebug = dbg; }
222 * @param option Not used
224 void Print(Option_t* option="") const;
227 * Get the first and last eta bin to use for a given ring and vertex
231 * @param vtxBin Vertex bin (1 based)
232 * @param first On return, the first eta bin to use
233 * @param last On return, the last eta bin to use
235 virtual void GetFirstAndLast(UShort_t d, Char_t r, UShort_t vtxBin,
236 Int_t& first, Int_t& last) const;
238 * Get the first and last eta bin to use for a given ring and vertex
240 * @param idx Ring index as given by GetIdx
241 * @param vtxBin Vertex bin (1 based)
242 * @param first On return, the first eta bin to use
243 * @param last On return, the last eta bin to use
245 virtual void GetFirstAndLast(Int_t idx, UShort_t vtxBin,
246 Int_t& first, Int_t& last) const;
248 * Get the first eta bin to use for a given ring and vertex
252 * @param v vertex bin (1 based)
254 * @return First eta bin to use, or -1 in case of problems
256 Int_t GetFirst(UShort_t d, Char_t r, UShort_t v) const;
258 * Get the first eta bin to use for a given ring and vertex
260 * @param idx Ring index as given by GetIdx
261 * @param v vertex bin (1 based)
263 * @return First eta bin to use, or -1 in case of problems
265 Int_t GetFirst(Int_t idx, UShort_t v) const;
267 * Get the last eta bin to use for a given ring and vertex
271 * @param v vertex bin (1 based)
273 * @return Last eta bin to use, or -1 in case of problems
275 Int_t GetLast(UShort_t d, Char_t r, UShort_t v) const;
277 * Get the last eta bin to use for a given ring and vertex
279 * @param idx Ring index as given by GetIdx
280 * @param v vertex bin (1 based)
282 * @return Last eta bin to use, or -1 in case of problems
284 Int_t GetLast(Int_t idx, UShort_t v) const;
286 * Get the detector and ring from the ring index
288 * @param idx Ring index
289 * @param d On return, the detector or 0 in case of errors
290 * @param r On return, the ring id or '0' in case of errors
292 void GetDetRing(Int_t idx, UShort_t& d, Char_t& r) const;
294 * Get the ring index from detector number and ring identifier
297 * @param r Ring identifier
299 * @return ring index or -1 in case of problems
301 Int_t GetIdx(UShort_t d, Char_t r) const;
303 * Get the possibly overlapping histogram of eta bin @a e in
309 * @param v Vertex bin (1 based)
311 * @return Overlapping histogram index or -1
313 Int_t GetOverlap(UShort_t d, Char_t r, Int_t e, UShort_t v) const;
315 * Get the possibly overlapping histogram of eta bin @a e in
318 * @param i Ring index
320 * @param v Vertex bin (1 based)
322 * @return Overlapping histogram index or -1
324 Int_t GetOverlap(Int_t i, Int_t e, UShort_t v) const;
326 * Check if there's an overlapping histogram with this eta bin of
327 * the detector and ring
332 * @param v Vertex bin (1 based)
334 * @return True if there's an overlapping histogram
336 Bool_t HasOverlap(UShort_t d, Char_t r, Int_t e, UShort_t v) const;
338 * Check if there's an overlapping histogram with this eta bin of
341 * @param i Ring index
343 * @param v Vertex bin
345 * @return True if there's an overlapping histogram
347 Bool_t HasOverlap(Int_t i, Int_t e, UShort_t v) const;
349 * Check if we should include the bin in the data range
351 * @param bg Secondary map histogram
355 * @return True if to be used
357 Bool_t CheckCorrection(const TH2D* bg, Int_t ie, Int_t ip) const;
359 * Merge bins accoring to set method
361 * @param c Current content
362 * @param e Current error
363 * @param oc Old content
364 * @param oe Old error
365 * @param rc On return, the new content
366 * @param re On return, tne new error
368 void MergeBins(Double_t c, Double_t e,
369 Double_t oc, Double_t oe,
370 Double_t& rc, Double_t& re) const;
373 Int_t fNCutBins; // Number of additional bins to cut away
374 Float_t fCorrectionCut; // Cut-off on secondary corrections
375 TArrayI fFirstBins; // Array of first eta bins
376 TArrayI fLastBins; // Array of last eta bins
377 Int_t fDebug; // Debug level
378 TList* fList; // Output list
379 TH2D* fSumRings; // Sum per ring (on y-axis)
380 TH2D* fCoverage; // Sum per ring (on y-axis)
381 MergeMethod fMergeMethod; // Merge methiod for overlapping bins
382 FiducialMethod fFiducialMethod; // Fidicual method
383 UShort_t fSkipFMDRings; // FMD rings to ignore
384 Bool_t fBgAndHitMaps; // Make hit/bg maps or not
386 ClassDef(AliFMDHistCollector,3); // Calculate Nch density
389 //____________________________________________________________________
391 AliFMDHistCollector::GetFirstAndLast(UShort_t d, Char_t r, UShort_t vtxbin,
392 Int_t& first, Int_t& last) const
394 GetFirstAndLast(GetIdx(d,r), vtxbin, first, last);
396 //____________________________________________________________________
398 AliFMDHistCollector::GetFirst(UShort_t d, Char_t r, UShort_t v) const
400 return GetFirst(GetIdx(d,r), v);
402 //____________________________________________________________________
404 AliFMDHistCollector::GetLast(UShort_t d, Char_t r, UShort_t v) const
406 return GetLast(GetIdx(d, r), v);
408 //____________________________________________________________________
410 AliFMDHistCollector::HasOverlap(UShort_t d, Char_t r, Int_t e, UShort_t v) const
412 return GetOverlap(d,r,e,v) >= 0;
414 //____________________________________________________________________
416 AliFMDHistCollector::HasOverlap(Int_t i, Int_t e, UShort_t v) const
418 return GetOverlap(i,e,v) >= 0;