1 #ifndef ALIROOT_PWG2_FORWARD_ALIFORWARDUTIL_H
2 #define ALIROOT_PWG2_FORWARD_ALIFORWARDUTIL_H
14 * Utilities used in the forward multiplcity analysis
16 * @ingroup pwg2_forward
18 class AliForwardUtil : public TObject
21 //==================================================================
24 * @name Collision/run parameters
27 * Defined collision types
29 enum ECollisionSystem {
34 //__________________________________________________________________
36 * Parse a collision system spec given in a string. Known values are
38 * - "pp", "p-p" which returns kPP
39 * - "PbPb", "Pb-Pb", "A-A", which returns kPbPb
40 * - Everything else gives kUnknown
42 * @param sys Collision system spec
44 * @return Collision system id
46 static UShort_t ParseCollisionSystem(const char* sys);
48 * Get a string representation of the collision system
50 * @param sys Collision system
53 * - anything else gives "unknown"
55 * @return String representation of the collision system
57 static const char* CollisionSystemString(UShort_t sys);
58 //__________________________________________________________________
60 * Parse the center of mass energy given as a float and return known
61 * values as a unsigned integer
63 * @param sys Collision system (needed for AA)
64 * @param cms Center of mass energy * total charge
66 * @return Center of mass energy per nucleon
68 static UShort_t ParseCenterOfMassEnergy(UShort_t sys, Float_t cms);
70 * Get a string representation of the center of mass energy per nuclean
72 * @param cms Center of mass energy per nucleon
74 * @return String representation of the center of mass energy per nuclean
76 static const char* CenterOfMassEnergyString(UShort_t cms);
77 //__________________________________________________________________
79 * Parse the magnetic field (in kG) as given by a floating point number
81 * @param field Magnetic field in kG
83 * @return Short integer value of magnetic field in kG
85 static Short_t ParseMagneticField(Float_t field);
87 * Get a string representation of the magnetic field
89 * @param field Magnetic field in kG
91 * @return String representation of the magnetic field
93 static const char* MagneticFieldString(Short_t field);
98 * @name Energy stragling functions
100 //__________________________________________________________________
102 * Number of steps to do in the Landau, Gaussiam convolution
104 static Int_t fgConvolutionSteps;
105 //------------------------------------------------------------------
107 * How many sigma's of the Gaussian in the Landau, Gaussian
108 * convolution to integrate over
110 static Double_t fgConvolutionNSigma;
111 //------------------------------------------------------------------
113 * Calculate the shifted Landau
115 * f'_{L}(x;\Delta,\xi) = f_L(x;\Delta+0.22278298\xi)
118 * where @f$ f_{L}@f$ is the ROOT implementation of the Landau
119 * distribution (known to have @f$ \Delta_{p}=-0.22278298@f$ for
120 * @f$\Delta=0,\xi=1@f$.
122 * @param x Where to evaluate @f$ f'_{L}@f$
123 * @param delta Most probable value
124 * @param xi The 'width' of the distribution
126 * @return @f$ f'_{L}(x;\Delta,\xi) @f$
128 static Double_t Landau(Double_t x, Double_t delta, Double_t xi);
130 //------------------------------------------------------------------
132 * Calculate the value of a Landau convolved with a Gaussian
135 * f(x;\Delta,\xi,\sigma') = \frac{1}{\sigma' \sqrt{2 \pi}}
136 * \int_{-\infty}^{+\infty} d\Delta' f'_{L}(x;\Delta',\xi)
137 * \exp{-\frac{(\Delta-\Delta')^2}{2\sigma'^2}}
140 * where @f$ f'_{L}@f$ is the Landau distribution, @f$ \Delta@f$ the
141 * energy loss, @f$ \xi@f$ the width of the Landau, and
142 * @f$ \sigma'^2=\sigma^2-\sigma_n^2 @f$. Here, @f$\sigma@f$ is the
143 * variance of the Gaussian, and @f$\sigma_n@f$ is a parameter modelling
144 * noise in the detector.
146 * Note that this function uses the constants fgConvolutionSteps and
147 * fgConvolutionNSigma
150 * - <a href="http://dx.doi.org/10.1016/0168-583X(84)90472-5">Nucl.Instrum.Meth.B1:16</a>
151 * - <a href="http://dx.doi.org/10.1103/PhysRevA.28.615">Phys.Rev.A28:615</a>
152 * - <a href="http://root.cern.ch/root/htmldoc/tutorials/fit/langaus.C.html">ROOT implementation</a>
154 * @param x where to evaluate @f$ f@f$
155 * @param delta @f$ \Delta@f$ of @f$ f(x;\Delta,\xi,\sigma')@f$
156 * @param xi @f$ \xi@f$ of @f$ f(x;\Delta,\xi,\sigma')@f$
157 * @param sigma @f$ \sigma@f$ of @f$\sigma'^2=\sigma^2-\sigma_n^2 @f$
158 * @param sigma_n @f$ \sigma_n@f$ of @f$\sigma'^2=\sigma^2-\sigma_n^2 @f$
160 * @return @f$ f@f$ evaluated at @f$ x@f$.
162 static Double_t LandauGaus(Double_t x, Double_t delta, Double_t xi,
163 Double_t sigma, Double_t sigma_n);
165 //------------------------------------------------------------------
169 * f_i(x;\Delta,\xi,\sigma') = f(x;\Delta_i,\xi_i,\sigma_i')
171 * corresponding to @f$ i@f$ particles i.e., with the substitutions
173 * \Delta \rightarrow \Delta_i &=& i(\Delta + \xi\log(i))\\
174 * \xi \rightarrow \xi_i &=& i \xi\\
175 * \sigma \rightarrow \sigma_i &=& \sqrt{i}\sigma\\
176 * \sigma'^2 \rightarrow \sigma_i'^2 &=& \sigma_n^2 + \sigma_i^2
179 * @param x Where to evaluate
180 * @param delta @f$ \Delta@f$
181 * @param xi @f$ \xi@f$
182 * @param sigma @f$ \sigma@f$
183 * @param sigma_n @f$ \sigma_n@f$
186 * @return @f$ f_i @f$ evaluated
188 static Double_t ILandauGaus(Double_t x, Double_t delta, Double_t xi,
189 Double_t sigma, Double_t sigma_n, Int_t i);
191 //------------------------------------------------------------------
193 * Numerically evaluate
195 * \left.\frac{\partial f_i}{\partial p_i}\right|_{x}
197 * where @f$ p_i@f$ is the @f$ i^{\mbox{th}}@f$ parameter. The mapping
198 * of the parameters is given by
203 * - 3: @f$\sigma_n@f$
205 * This is the partial derivative with respect to the parameter of
206 * the response function corresponding to @f$ i@f$ particles i.e.,
207 * with the substitutions
209 * \Delta \rightarrow \Delta_i = i(\Delta + \xi\log(i))\\
210 * \xi \rightarrow \xi_i = i \xi\\
211 * \sigma \rightarrow \sigma_i = \sqrt{i}\sigma\\
212 * \sigma'^2 \rightarrow \sigma_i'^2 = \sigma_n^2 + \sigma_i^2
215 * @param x Where to evaluate
216 * @param ipar Parameter number
217 * @param dp @f$ \epsilon\delta p_i@f$ for some value of @f$\epsilon@f$
218 * @param delta @f$ \Delta@f$
219 * @param xi @f$ \xi@f$
220 * @param sigma @f$ \sigma@f$
221 * @param sigma_n @f$ \sigma_n@f$
224 * @return @f$ f_i@f$ evaluated
226 static Double_t IdLandauGausdPar(Double_t x, UShort_t ipar, Double_t dp,
227 Double_t delta, Double_t xi,
228 Double_t sigma, Double_t sigma_n, Int_t i);
230 //------------------------------------------------------------------
234 * f_N(x;\Delta,\xi,\sigma') = \sum_{i=1}^N a_i f_i(x;\Delta,\xi,\sigma'a)
237 * where @f$ f(x;\Delta,\xi,\sigma')@f$ is the convolution of a
238 * Landau with a Gaussian (see LandauGaus). Note that
239 * @f$ a_1 = 1@f$, @f$\Delta_i = i(\Delta_1 + \xi\log(i))@f$,
240 * @f$\xi_i=i\xi_1@f$, and @f$\sigma_i'^2 = \sigma_n^2 + i\sigma_1^2@f$.
243 * - <a href="http://dx.doi.org/10.1016/0168-583X(84)90472-5">Nucl.Instrum.Meth.B1:16</a>
244 * - <a href="http://dx.doi.org/10.1103/PhysRevA.28.615">Phys.Rev.A28:615</a>
245 * - <a href="http://root.cern.ch/root/htmldoc/tutorials/fit/langaus.C.html">ROOT implementation</a>
247 * @param x Where to evaluate @f$ f_N@f$
248 * @param delta @f$ \Delta_1@f$
249 * @param xi @f$ \xi_1@f$
250 * @param sigma @f$ \sigma_1@f$
251 * @param sigma_n @f$ \sigma_n@f$
252 * @param n @f$ N@f$ in the sum above.
253 * @param a Array of size @f$ N-1@f$ of the weights @f$ a_i@f$ for
256 * @return @f$ f_N(x;\Delta,\xi,\sigma')@f$
258 static Double_t NLandauGaus(Double_t x, Double_t delta, Double_t xi,
259 Double_t sigma, Double_t sigma_n, Int_t n,
262 * Generate a TF1 object of @f$ f_I@f$
265 * @param delta @f$ \Delta@f$
266 * @param xi @f$ \xi_1@f$
267 * @param sigma @f$ \sigma_1@f$
268 * @param sigma_n @f$ \sigma_n@f$
269 * @param i @f$ i@f$ - the number of particles
270 * @param xmin Least value of range
271 * @param xmax Largest value of range
273 * @return Newly allocated TF1 object
275 static TF1* MakeILandauGaus(Double_t c,
276 Double_t delta, Double_t xi,
277 Double_t sigma, Double_t sigma_n,
279 Double_t xmin, Double_t xmax);
281 * Generate a TF1 object of @f$ f_N@f$
284 * @param delta @f$ \Delta@f$
285 * @param xi @f$ \xi_1@f$
286 * @param sigma @f$ \sigma_1@f$
287 * @param sigma_n @f$ \sigma_n@f$
288 * @param n @f$ N@f$ - how many particles to sum to
289 * @param a Array of size @f$ N-1@f$ of the weights @f$ a_i@f$ for
291 * @param xmin Least value of range
292 * @param xmax Largest value of range
294 * @return Newly allocated TF1 object
296 static TF1* MakeNLandauGaus(Double_t c,
297 Double_t delta, Double_t xi,
298 Double_t sigma, Double_t sigma_n,
299 Int_t n, Double_t* a,
300 Double_t xmin, Double_t xmax);
302 //__________________________________________________________________
304 * Structure to do fits to the energy loss spectrum
306 * @ingroup pwg2_forward
322 * @param lowCut Lower cut of spectrum - data below this cuts is ignored
323 * @param maxRange Maximum range to fit to
324 * @param minusBins The number of bins below maximum to use
326 ELossFitter(Double_t lowCut, Double_t maxRange, UShort_t minusBins);
327 virtual ~ELossFitter();
329 * Clear internal arrays
334 * Fit a 1-particle signal to the passed energy loss distribution
336 * Note that this function clears the internal arrays first
338 * @param dist Data to fit the function to
339 * @param sigman If larger than zero, the initial guess of the
340 * detector induced noise. If zero or less, then this
341 * parameter is ignored in the fit (fixed at 0)
343 * @return The function fitted to the data
345 TF1* Fit1Particle(TH1* dist, Double_t sigman=-1);
347 * Fit a N-particle signal to the passed energy loss distribution
349 * If there's no 1-particle fit present, it does that first
351 * @param dist Data to fit the function to
352 * @param n Number of particle signals to fit
353 * @param sigman If larger than zero, the initial guess of the
354 * detector induced noise. If zero or less, then this
355 * parameter is ignored in the fit (fixed at 0)
357 * @return The function fitted to the data
359 TF1* FitNParticle(TH1* dist, UShort_t n, Double_t sigman=-1);
362 const Double_t fLowCut; // Lower cut on data
363 const Double_t fMaxRange; // Maximum range to fit
364 const UShort_t fMinusBins; // Number of bins from maximum to fit 1st peak
365 TObjArray fFitResults; // Array of fit results
366 TObjArray fFunctions; // Array of functions
371 //==================================================================
374 * @name Convenience containers
377 * Structure to hold histograms
379 * @ingroup pwg2_forward
381 struct Histos : public TObject
388 Histos() : fFMD1i(0), fFMD2i(0), fFMD2o(0), fFMD3i(0), fFMD3o(0) {}
392 * @param o Object to copy from
394 Histos(const Histos& o)
403 * Assignement operator
405 * @return Reference to this
407 Histos& operator=(const Histos&) { return *this;}
413 * Initialize the object
415 * @param etaAxis Eta axis to use
417 void Init(const TAxis& etaAxis);
423 * @param etaAxis Eta axis to use
425 * @return Newly allocated histogram
427 TH2D* Make(UShort_t d, Char_t r, const TAxis& etaAxis) const;
431 * @param option Not used
433 void Clear(Option_t* option="");
434 // const TH2D* Get(UShort_t d, Char_t r) const;
436 * Get the histogram for a particular detector,ring
441 * @return Histogram for detector,ring or nul
443 TH2D* Get(UShort_t d, Char_t r) const;
444 TH2D* fFMD1i; // Histogram for FMD1i
445 TH2D* fFMD2i; // Histogram for FMD2i
446 TH2D* fFMD2o; // Histogram for FMD2o
447 TH2D* fFMD3i; // Histogram for FMD3i
448 TH2D* fFMD3o; // Histogram for FMD3o
453 //__________________________________________________________________
455 * Base class for structure holding ring specific histograms
457 * @ingroup pwg2_forward
459 struct RingHistos : public TObject
465 RingHistos() : fDet(0), fRing('\0'), fName("") {}
472 RingHistos(UShort_t d, Char_t r)
473 : fDet(d), fRing(r), fName(TString::Format("FMD%d%c", d, r))
478 * @param o Object to copy from
480 RingHistos(const RingHistos& o)
481 : TObject(o), fDet(o.fDet), fRing(o.fRing), fName(o.fName)
486 virtual ~RingHistos() {}
488 * Assignement operator
490 * @param o Object to assign from
492 * @return Reference to this
494 RingHistos& operator=(const RingHistos& o)
496 TObject::operator=(o);
509 TList* DefineOutputList(TList* d) const;
517 TList* GetOutputList(TList* d) const;
526 TH1* GetOutputHist(TList* d, const char* name) const;
533 Color_t Color() const
535 return ((fDet == 1 ? kRed : (fDet == 2 ? kGreen : kBlue))
536 + ((fRing == 'I' || fRing == 'i') ? 2 : -2));
538 UShort_t fDet; // Detector
539 Char_t fRing; // Ring
540 TString fName; // Name
542 ClassDef(RingHistos,1)