+//___________________________________________________________________________
+Double_t AliTRDcluster::GetSX(Int_t tb, Double_t z)
+{
+ //
+ // Returns the error parameterization in the radial direction for TRD clusters as function of
+ // the calibrated time bin (tb) and optionally distance to anode wire (z). By default (no z information)
+ // the mean value over all cluster to wire distance is chosen.
+ //
+ // There are several contributions which are entering in the definition of the radial errors of the clusters.
+ // Although an analytic defition should be possible for the moment this is not yet available but instead a
+ // numerical parameterization is provided (see AliTRDclusterResolution::ProcessSigma() for the calibration
+ // method). The result is displayed in the figure below as a 2D plot and also as the projection on the drift axis.
+ //
+ //Begin_Html
+ //<img src="TRD/clusterXerrorDiff2D.gif">
+ //End_Html
+ //
+ // Here is a list of uncertainty components:
+ // - Time Response Function (TRF) - the major contribution. since TRF is also not symmetric (even if tail is
+ // cancelled) it also creates a systematic shift dependent on the charge distribution before and after the cluster.
+ // - longitudinal diffusion - increase the width of TRF and scales with square root of drift length
+ // - variation in the drift velocity within the drift cell
+ //
+ // Author
+ // A.Bercuci <A.Bercuci@gsi.de>
+ //
+
+ if(tb<1 || tb>=24) return 10.; // return huge [10cm]
+ static const Double_t sx[24][10]={
+ {0.000e+00, 9.352e-01, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 2.309e+00},
+ {8.387e-02, 8.718e-02, 8.816e-02, 9.444e-02, 9.993e-02, 1.083e-01, 1.161e-01, 1.280e-01, 1.417e-01, 1.406e-01},
+ {1.097e-01, 1.105e-01, 1.127e-01, 1.151e-01, 1.186e-01, 1.223e-01, 1.272e-01, 1.323e-01, 1.389e-01, 1.490e-01},
+ {1.407e-01, 1.404e-01, 1.414e-01, 1.430e-01, 1.429e-01, 1.449e-01, 1.476e-01, 1.494e-01, 1.515e-01, 1.589e-01},
+ {1.681e-01, 1.679e-01, 1.666e-01, 1.657e-01, 1.656e-01, 1.649e-01, 1.652e-01, 1.662e-01, 1.671e-01, 1.694e-01},
+ {1.745e-01, 1.737e-01, 1.707e-01, 1.690e-01, 1.643e-01, 1.610e-01, 1.612e-01, 1.628e-01, 1.638e-01, 1.659e-01},
+ {1.583e-01, 1.558e-01, 1.535e-01, 1.488e-01, 1.445e-01, 1.419e-01, 1.428e-01, 1.451e-01, 1.462e-01, 1.494e-01},
+ {1.414e-01, 1.391e-01, 1.368e-01, 1.300e-01, 1.256e-01, 1.259e-01, 1.285e-01, 1.326e-01, 1.358e-01, 1.406e-01},
+ {1.307e-01, 1.289e-01, 1.261e-01, 1.216e-01, 1.193e-01, 1.165e-01, 1.201e-01, 1.241e-01, 1.274e-01, 1.344e-01},
+ {1.251e-01, 1.227e-01, 1.208e-01, 1.155e-01, 1.110e-01, 1.116e-01, 1.133e-01, 1.187e-01, 1.229e-01, 1.308e-01},
+ {1.234e-01, 1.209e-01, 1.175e-01, 1.127e-01, 1.094e-01, 1.093e-01, 1.109e-01, 1.155e-01, 1.210e-01, 1.275e-01},
+ {1.215e-01, 1.187e-01, 1.156e-01, 1.108e-01, 1.070e-01, 1.065e-01, 1.090e-01, 1.134e-01, 1.196e-01, 1.251e-01},
+ {1.202e-01, 1.180e-01, 1.151e-01, 1.108e-01, 1.070e-01, 1.058e-01, 1.089e-01, 1.127e-01, 1.183e-01, 1.256e-01},
+ {1.207e-01, 1.176e-01, 1.142e-01, 1.109e-01, 1.072e-01, 1.069e-01, 1.088e-01, 1.122e-01, 1.182e-01, 1.252e-01},
+ {1.213e-01, 1.182e-01, 1.156e-01, 1.102e-01, 1.076e-01, 1.063e-01, 1.091e-01, 1.132e-01, 1.181e-01, 1.243e-01},
+ {1.205e-01, 1.180e-01, 1.150e-01, 1.104e-01, 1.072e-01, 1.063e-01, 1.083e-01, 1.132e-01, 1.183e-01, 1.243e-01},
+ {1.212e-01, 1.195e-01, 1.135e-01, 1.107e-01, 1.070e-01, 1.065e-01, 1.097e-01, 1.126e-01, 1.185e-01, 1.238e-01},
+ {1.201e-01, 1.184e-01, 1.155e-01, 1.111e-01, 1.088e-01, 1.075e-01, 1.089e-01, 1.131e-01, 1.189e-01, 1.237e-01},
+ {1.197e-01, 1.186e-01, 1.147e-01, 1.113e-01, 1.085e-01, 1.077e-01, 1.105e-01, 1.137e-01, 1.188e-01, 1.245e-01},
+ {1.213e-01, 1.194e-01, 1.154e-01, 1.114e-01, 1.091e-01, 1.082e-01, 1.098e-01, 1.140e-01, 1.194e-01, 1.247e-01},
+ {1.210e-01, 1.189e-01, 1.155e-01, 1.119e-01, 1.088e-01, 1.080e-01, 1.105e-01, 1.141e-01, 1.195e-01, 1.244e-01},
+ {1.196e-01, 1.189e-01, 1.145e-01, 1.105e-01, 1.095e-01, 1.083e-01, 1.087e-01, 1.121e-01, 1.173e-01, 1.208e-01},
+ {1.123e-01, 1.129e-01, 1.108e-01, 1.110e-01, 1.080e-01, 1.065e-01, 1.056e-01, 1.066e-01, 1.071e-01, 1.095e-01},
+ {1.136e-01, 1.135e-01, 1.130e-01, 1.122e-01, 1.113e-01, 1.071e-01, 1.041e-01, 1.025e-01, 1.014e-01, 9.973e-02}
+ };
+ if(z>=0. && z<.25) return sx[tb][Int_t(z/.025)];
+
+ Double_t m = 0.; for(Int_t id=10; id--;) m+=sx[tb][id];
+ return m*.1;
+
+}
+
+//___________________________________________________________________________
+Double_t AliTRDcluster::GetSYdrift(Int_t tb, Int_t ly, Double_t/* z*/)
+{
+ //
+ // Returns the error parameterization for TRD clusters as function of the drift length (here calibrated time bin tb)
+ // and optionally distance to anode wire (z) for the LUT r-phi cluster shape. By default (no z information) the largest
+ // value over all cluster to wire values is chosen.
+ //
+ // For the LUT method the dependence of s_y with x and d is obtained via a fit to the cluster to MC
+ // resolution. (see class AliTRDclusterResolution for more details). A normalization to the reference radial position
+ // x0 = 0.675 (tb=5 for ideal vd) is also applied (see GetSYprf()). The function is *NOT* calibration aware !
+ // The result is displayed in the figure below as a 2D plot and also as the projection on the drift axis. A comparison
+ // with the GAUS parameterization is also given
+ //
+ // For the GAUS method the dependence of s_y with x is *analytic* and it is expressed by the relation.
+ // BEGIN_LATEX
+ // #sigma^{2}_{y} = #sigma^{2}_{PRF} + #frac{x#delta_{t}^{2}}{(1+tg(#alpha_{L}))^{2}}
+ // END_LATEX
+ // The result is displayed in the figure below as function of the drift time and compared with the LUT parameterization.
+ //Begin_Html
+ //<img src="TRD/clusterYerrorDiff2D.gif">
+ //<img src="TRD/clusterYerrorDiff1D.gif">
+ //End_Html
+ //
+ // Author
+ // A.Bercuci <A.Bercuci@gsi.de>
+ //
+
+ if(tb<1 || tb>=24) return 10.; // return huge [10cm]
+ static const Float_t lSy[6][24] = {
+ {75.7561, 0.0325, 0.0175, 0.0174, 0.0206, 0.0232,
+ 0.0253, 0.0262, 0.0265, 0.0264, 0.0266, 0.0257,
+ 0.0258, 0.0261, 0.0259, 0.0253, 0.0257, 0.0261,
+ 0.0255, 0.0250, 0.0259, 0.0266, 0.0278, 0.0319
+ },
+ {49.2252, 0.0371, 0.0204, 0.0189, 0.0230, 0.0261,
+ 0.0281, 0.0290, 0.0292, 0.0286, 0.0277, 0.0279,
+ 0.0285, 0.0281, 0.0291, 0.0281, 0.0281, 0.0282,
+ 0.0272, 0.0282, 0.0282, 0.0284, 0.0310, 0.0334
+ },
+ {55.1674, 0.0388, 0.0212, 0.0200, 0.0239, 0.0271,
+ 0.0288, 0.0299, 0.0306, 0.0300, 0.0296, 0.0303,
+ 0.0293, 0.0290, 0.0291, 0.0294, 0.0295, 0.0290,
+ 0.0293, 0.0292, 0.0292, 0.0293, 0.0316, 0.0358
+ },
+ {45.1004, 0.0411, 0.0225, 0.0215, 0.0249, 0.0281,
+ 0.0301, 0.0315, 0.0320, 0.0308, 0.0318, 0.0321,
+ 0.0312, 0.0311, 0.0316, 0.0315, 0.0310, 0.0308,
+ 0.0313, 0.0303, 0.0314, 0.0314, 0.0324, 0.0369
+ },
+ {43.8614, 0.0420, 0.0239, 0.0224, 0.0268, 0.0296,
+ 0.0322, 0.0336, 0.0333, 0.0326, 0.0321, 0.0325,
+ 0.0329, 0.0326, 0.0323, 0.0322, 0.0326, 0.0320,
+ 0.0329, 0.0319, 0.0314, 0.0329, 0.0341, 0.0373
+ },
+ {40.5440, 0.0434, 0.0246, 0.0236, 0.0275, 0.0311,
+ 0.0332, 0.0345, 0.0347, 0.0347, 0.0340, 0.0336,
+ 0.0339, 0.0344, 0.0339, 0.0341, 0.0341, 0.0342,
+ 0.0345, 0.0328, 0.0341, 0.0332, 0.0356, 0.0398
+ },
+ };
+ // adjusted ...
+ return TMath::Max(lSy[ly][tb]-0.0150, 0.0010);
+
+/* const Double_t sy[24][10]={
+ {0.000e+00, 2.610e-01, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 0.000e+00, 4.680e-01},
+ {3.019e-02, 3.036e-02, 3.131e-02, 3.203e-02, 3.294e-02, 3.407e-02, 3.555e-02, 3.682e-02, 3.766e-02, 3.824e-02},
+ {1.773e-02, 1.778e-02, 1.772e-02, 1.790e-02, 1.807e-02, 1.833e-02, 1.873e-02, 1.905e-02, 1.958e-02, 2.029e-02},
+ {1.774e-02, 1.772e-02, 1.746e-02, 1.738e-02, 1.756e-02, 1.756e-02, 1.739e-02, 1.720e-02, 1.743e-02, 1.769e-02},
+ {2.064e-02, 2.078e-02, 2.069e-02, 2.060e-02, 2.033e-02, 2.024e-02, 2.022e-02, 1.961e-02, 1.922e-02, 1.901e-02},
+ {2.382e-02, 2.379e-02, 2.371e-02, 2.333e-02, 2.318e-02, 2.285e-02, 2.255e-02, 2.244e-02, 2.174e-02, 2.132e-02},
+ {2.615e-02, 2.589e-02, 2.539e-02, 2.493e-02, 2.420e-02, 2.396e-02, 2.362e-02, 2.342e-02, 2.321e-02, 2.330e-02},
+ {2.640e-02, 2.638e-02, 2.577e-02, 2.548e-02, 2.477e-02, 2.436e-02, 2.416e-02, 2.401e-02, 2.399e-02, 2.402e-02},
+ {2.647e-02, 2.632e-02, 2.587e-02, 2.546e-02, 2.465e-02, 2.447e-02, 2.429e-02, 2.415e-02, 2.429e-02, 2.475e-02},
+ {2.657e-02, 2.637e-02, 2.580e-02, 2.525e-02, 2.492e-02, 2.441e-02, 2.446e-02, 2.441e-02, 2.478e-02, 2.491e-02},
+ {2.640e-02, 2.608e-02, 2.583e-02, 2.539e-02, 2.478e-02, 2.440e-02, 2.456e-02, 2.464e-02, 2.486e-02, 2.533e-02},
+ {2.636e-02, 2.630e-02, 2.584e-02, 2.542e-02, 2.483e-02, 2.451e-02, 2.449e-02, 2.467e-02, 2.496e-02, 2.554e-02},
+ {2.634e-02, 2.629e-02, 2.583e-02, 2.526e-02, 2.480e-02, 2.460e-02, 2.458e-02, 2.472e-02, 2.518e-02, 2.549e-02},
+ {2.629e-02, 2.621e-02, 2.581e-02, 2.527e-02, 2.480e-02, 2.458e-02, 2.451e-02, 2.485e-02, 2.516e-02, 2.547e-02},
+ {2.629e-02, 2.607e-02, 2.573e-02, 2.543e-02, 2.485e-02, 2.464e-02, 2.452e-02, 2.476e-02, 2.505e-02, 2.550e-02},
+ {2.635e-02, 2.613e-02, 2.578e-02, 2.523e-02, 2.491e-02, 2.465e-02, 2.470e-02, 2.467e-02, 2.515e-02, 2.564e-02},
+ {2.613e-02, 2.602e-02, 2.587e-02, 2.526e-02, 2.507e-02, 2.482e-02, 2.456e-02, 2.486e-02, 2.509e-02, 2.572e-02},
+ {2.620e-02, 2.599e-02, 2.563e-02, 2.528e-02, 2.484e-02, 2.462e-02, 2.464e-02, 2.476e-02, 2.513e-02, 2.571e-02},
+ {2.634e-02, 2.596e-02, 2.565e-02, 2.519e-02, 2.497e-02, 2.457e-02, 2.450e-02, 2.481e-02, 2.511e-02, 2.540e-02},
+ {2.593e-02, 2.589e-02, 2.563e-02, 2.511e-02, 2.472e-02, 2.453e-02, 2.452e-02, 2.474e-02, 2.501e-02, 2.543e-02},
+ {2.576e-02, 2.582e-02, 2.526e-02, 2.505e-02, 2.462e-02, 2.446e-02, 2.445e-02, 2.466e-02, 2.486e-02, 2.510e-02},
+ {2.571e-02, 2.549e-02, 2.533e-02, 2.501e-02, 2.453e-02, 2.443e-02, 2.445e-02, 2.450e-02, 2.448e-02, 2.469e-02},
+ {2.812e-02, 2.786e-02, 2.776e-02, 2.723e-02, 2.695e-02, 2.650e-02, 2.642e-02, 2.617e-02, 2.612e-02, 2.610e-02},
+ {3.251e-02, 3.267e-02, 3.223e-02, 3.183e-02, 3.125e-02, 3.106e-02, 3.067e-02, 3.010e-02, 2.936e-02, 2.927e-02}
+ };
+ if(z>=0. && z<.25) return sy[tb][Int_t(z/.025)] - sy[5][Int_t(z/.025)];
+
+ Double_t m = -1.e8; for(Int_t id=10; id--;) if((sy[tb][id] - sy[5][id])>m) m=sy[tb][id]-sy[5][id];
+
+ return m;*/
+}
+
+//___________________________________________________________________________
+Double_t AliTRDcluster::GetSYcharge(Float_t q)
+{
+ //
+ // Parameterization of the r-phi resolution component due to cluster charge.
+ // The value is the offset from the nominal cluster resolution defined as the
+ // cluster resolution at average cluster charge (q0).
+ //
+ // BEGIN_LATEX
+ // #Delta #sigma_{y}(q) = a*(#frac{1}{q} - #frac{1}{q_{0}})
+ // q_{0} #approx 50
+ // END_LATEX
+ // The definition is *NOT* robust against gain fluctuations and thus two approaches are possible
+ // when residual miscalibration are available:
+ // - determine parameterization with a resolution matching those of the gain
+ // - define an analytic model which scales with the gain.
+ //
+ // For more details please see AliTRDclusterResolution::ProcessCharge()
+ //
+ //Begin_Html
+ //<img src="TRD/clusterQerror.gif">
+ //End_Html
+ //
+ // Author
+ // A.Bercuci <A.Bercuci@gsi.de>
+ //
+
+ const Float_t sq0inv = 0.019962; // [1/q0]
+ const Float_t sqb = 0.037328; // [cm]
+
+ return sqb*(1./q - sq0inv);
+}
+
+//___________________________________________________________________________
+Double_t AliTRDcluster::GetSYprf(Int_t ly, Double_t center, Double_t s2)
+{
+ //
+ // Parameterization of the cluster error in the r-phi direction due to charge sharing between
+ // adiacent pads. Should be identical to what is provided in the OCDB as PRF [TODO]
+ //
+ // The parameterization is obtained from fitting cluster resolution at phi=exb and |x-0.675|<0.225.
+ // For more details see AliTRDclusterResolution::ProcessCenter().
+ //
+ //Begin_Html
+ //<img src="TRD/clusterPRFerror.gif">
+ //End_Html
+ //
+ // Author
+ // A.Bercuci <A.Bercuci@gsi.de>
+ //
+
+/* const Float_t scy[AliTRDgeometry::kNlayer][4] = {
+ {2.827e-02, 9.600e-04, 4.296e-01, 2.271e-02},
+ {2.952e-02,-2.198e-04, 4.146e-01, 2.339e-02},
+ {3.090e-02, 1.514e-03, 4.020e-01, 2.402e-02},
+ {3.260e-02,-2.037e-03, 3.946e-01, 2.509e-02},
+ {3.439e-02,-3.601e-04, 3.883e-01, 2.623e-02},
+ {3.510e-02, 2.066e-03, 3.651e-01, 2.588e-02},
+ };*/
+ const Float_t lPRF[] = {0.438, 0.403, 0.393, 0.382, 0.376, 0.345};
+
+ return s2*TMath::Gaus(center, 0., lPRF[ly]);
+}
+
+
+//___________________________________________________________________________
+Double_t AliTRDcluster::GetXcorr(Int_t tb, Double_t z)
+{
+ //
+ // Drift length correction [cm]. Due to variation of mean drift velocity along the drift region
+ // from nominal vd at xd->infinity. For drift velocity determination based on tracking information
+ // the correction should be negligible.
+ //Begin_Html
+ //<img src="TRD/clusterXcorr.gif">
+ //End_Html
+ // TODO to be parametrized in term of drift velocity at infinite drift length
+ // A.Bercuci (Mar 28 2009)
+ //
+
+ if(tb<0 || tb>=24) return 0.;
+ const Int_t nd = 5;
+ static const Double_t dx[24][nd]={
+ {+1.747e-01,+3.195e-01,+1.641e-01,+1.607e-01,+6.002e-01},
+ {+5.468e-02,+5.760e-02,+6.365e-02,+8.003e-02,+1.067e-01},
+ {-6.327e-02,-6.339e-02,-6.423e-02,-6.900e-02,-7.949e-02},
+ {-1.417e-01,-1.424e-01,-1.450e-01,-1.465e-01,-1.514e-01},
+ {-1.637e-01,-1.619e-01,-1.622e-01,-1.613e-01,-1.648e-01},
+ {-1.386e-01,-1.334e-01,-1.261e-01,-1.276e-01,-1.314e-01},
+ {-8.799e-02,-8.299e-02,-7.861e-02,-8.038e-02,-8.436e-02},
+ {-5.139e-02,-4.849e-02,-4.641e-02,-4.965e-02,-5.286e-02},
+ {-2.927e-02,-2.773e-02,-2.807e-02,-3.021e-02,-3.378e-02},
+ {-1.380e-02,-1.229e-02,-1.335e-02,-1.547e-02,-1.984e-02},
+ {-4.168e-03,-4.601e-03,-5.462e-03,-8.164e-03,-1.035e-02},
+ {+2.044e-03,+1.889e-03,+9.603e-04,-1.342e-03,-3.736e-03},
+ {+3.568e-03,+3.581e-03,+2.391e-03,+2.942e-05,-1.585e-03},
+ {+4.403e-03,+4.571e-03,+3.509e-03,+8.703e-04,-1.425e-03},
+ {+4.941e-03,+4.808e-03,+3.284e-03,+1.105e-03,-1.208e-03},
+ {+5.124e-03,+5.022e-03,+4.305e-03,+2.023e-03,-1.145e-03},
+ {+4.882e-03,+4.008e-03,+3.408e-03,+7.886e-04,-1.356e-03},
+ {+3.852e-03,+3.539e-03,+2.057e-03,+1.670e-04,-1.993e-03},
+ {+2.154e-03,+2.111e-03,+5.723e-04,-1.254e-03,-3.256e-03},
+ {+1.755e-03,+2.101e-03,+9.516e-04,-1.649e-03,-3.394e-03},
+ {+1.617e-03,+1.662e-03,+4.169e-04,-9.843e-04,-4.309e-03},
+ {-9.204e-03,-9.069e-03,-1.182e-02,-1.458e-02,-1.880e-02},
+ {-6.727e-02,-6.820e-02,-6.804e-02,-7.134e-02,-7.615e-02},
+ {-1.802e-01,-1.733e-01,-1.633e-01,-1.601e-01,-1.632e-01}
+ };
+// const Double_t dx[24][nd]={
+// {+0.000e+00,+0.000e+00,+0.000e+00,+0.000e+00,+0.000e+00,+0.000e+00,+0.000e+00,+0.000e+00,+0.000e+00,+0.000e+00},
+// {-2.763e-04,-2.380e-04,-6.286e-04,-9.424e-04,+1.046e-03,+1.932e-03,+1.620e-03,+1.951e-03,-1.321e-03,-1.115e-03},
+// {-1.825e-03,-9.245e-04,-1.012e-03,-8.215e-04,+2.703e-05,+1.403e-03,+2.340e-03,+2.577e-03,+2.017e-03,+8.006e-04},
+// {-3.070e-03,-8.563e-04,-1.257e-03,+8.491e-05,+4.503e-04,-2.467e-05,-1.793e-04,+5.085e-04,+1.321e-03,+4.056e-04},
+// {-3.637e-03,-2.857e-03,-3.098e-03,-2.304e-03,-1.467e-03,-1.755e-03,+4.585e-04,+2.757e-03,+3.184e-03,+3.525e-03},
+// {-9.884e-03,-7.695e-03,-7.290e-03,-3.990e-03,-9.982e-04,+2.226e-03,+3.375e-03,+6.419e-03,+7.209e-03,+6.891e-03},
+// {-6.844e-03,-5.807e-03,-4.012e-03,-1.566e-03,+5.035e-04,+2.024e-03,+3.225e-03,+3.918e-03,+5.942e-03,+6.024e-03},
+// {-2.628e-03,-2.201e-03,-4.562e-04,+9.832e-04,+3.411e-03,+2.062e-03,+1.526e-03,+9.350e-04,+8.842e-04,+1.007e-03},
+// {+6.603e-04,+1.545e-03,+1.681e-03,+1.918e-03,+2.165e-03,+1.825e-03,+1.691e-03,-1.923e-04,+1.835e-04,-1.284e-03},
+// {+1.895e-03,+1.586e-03,+2.000e-03,+3.537e-03,+2.526e-03,+1.316e-03,+8.229e-04,-7.671e-05,-2.175e-03,-3.528e-03},
+// {+2.927e-03,+3.369e-03,+3.603e-03,+2.675e-03,+2.737e-03,+1.133e-03,+4.318e-04,-1.215e-03,-2.443e-03,-3.116e-03},
+// {+3.072e-03,+3.564e-03,+3.612e-03,+3.149e-03,+2.768e-03,+1.186e-03,+3.083e-04,-1.447e-03,-2.480e-03,-3.263e-03},
+// {+2.697e-03,+3.565e-03,+3.759e-03,+2.855e-03,+2.909e-03,+6.564e-04,-5.224e-04,-3.309e-04,-1.636e-03,-3.739e-03},
+// {+3.633e-03,+3.232e-03,+3.727e-03,+3.024e-03,+3.365e-03,+1.598e-03,-6.903e-04,-1.039e-03,-3.176e-03,-4.472e-03},
+// {+2.999e-03,+3.942e-03,+3.322e-03,+3.162e-03,+1.978e-03,+1.657e-03,-4.760e-04,-8.343e-04,-2.346e-03,-3.281e-03},
+// {+3.734e-03,+3.098e-03,+3.435e-03,+2.512e-03,+2.651e-03,+1.745e-03,+9.424e-04,-1.404e-03,-3.177e-03,-4.444e-03},
+// {+3.204e-03,+4.003e-03,+3.068e-03,+2.697e-03,+3.187e-03,+3.878e-04,-1.124e-04,-1.855e-03,-2.584e-03,-3.807e-03},
+// {+2.653e-03,+3.631e-03,+2.327e-03,+3.460e-03,+1.810e-03,+1.244e-03,-3.651e-04,-2.664e-04,-2.307e-03,-3.642e-03},
+// {+2.538e-03,+3.208e-03,+2.390e-03,+3.519e-03,+1.763e-03,+1.330e-04,+1.669e-04,-1.422e-03,-1.685e-03,-3.519e-03},
+// {+2.605e-03,+2.465e-03,+2.771e-03,+2.966e-03,+2.361e-03,+6.029e-04,-4.435e-04,-1.876e-03,-1.694e-03,-3.757e-03},
+// {+2.866e-03,+3.315e-03,+3.146e-03,+2.117e-03,+1.933e-03,+9.339e-04,+9.556e-04,-1.314e-03,-3.615e-03,-3.558e-03},
+// {+4.002e-03,+3.543e-03,+3.631e-03,+4.127e-03,+1.919e-03,-2.852e-04,-9.484e-04,-2.060e-03,-4.477e-03,-5.491e-03},
+// {+6.029e-03,+5.147e-03,+4.286e-03,+2.215e-03,+9.240e-04,-1.554e-03,-2.366e-03,-3.635e-03,-5.372e-03,-6.467e-03},
+// {+3.941e-03,+3.995e-03,+5.638e-04,-3.332e-04,-2.539e-03,-3.764e-03,-3.647e-03,-4.900e-03,-5.414e-03,-5.202e-03}
+// };
+ if(z>=0. && z<.25) return dx[tb][Int_t(z/.025)];
+
+ Double_t m = 0.; for(Int_t id=nd; id--;) m+=dx[tb][id];
+ return m/nd;
+}
+
+//___________________________________________________________________________
+Double_t AliTRDcluster::GetYcorr(Int_t ly, Float_t y)
+{
+ //
+ // PRF correction for the LUT r-phi cluster shape.
+ //Begin_Html
+ //<img src="TRD/clusterYcorr.gif">
+ //End_Html
+ //
+
+ static const Float_t cy[AliTRDgeometry::kNlayer][3] = {
+ { 4.014e-04, 8.605e-03, -6.880e+00},
+ {-3.061e-04, 9.663e-03, -6.789e+00},
+ { 1.124e-03, 1.105e-02, -6.825e+00},
+ {-1.527e-03, 1.231e-02, -6.777e+00},
+ { 2.150e-03, 1.387e-02, -6.783e+00},
+ {-1.296e-03, 1.486e-02, -6.825e+00}
+ };
+
+ return cy[ly][0] + cy[ly][1] * TMath::Sin(cy[ly][2] * y);
+}
+
+//_____________________________________________________________________________
+Float_t AliTRDcluster::GetXloc(Double_t t0, Double_t vd
+ , const Double_t *const /*q*/
+ , const Double_t *const /*xq*/
+ , Double_t /*z*/)
+{
+ //
+ // (Re)Calculate cluster position in the x direction in local chamber coordinates (with respect to the anode wire
+ // position) using all available information from tracking.
+ // Input parameters:
+ // t0 - calibration aware trigger delay [us]
+ // vd - drift velocity in the region of the cluster [cm/us]
+ // z - distance to the anode wire [cm]. By default average over the drift cell width.
+ // q & xq - array of charges and cluster positions from previous clusters in the tracklet [a.u.]
+ // Output values :
+ // return x position of the cluster with respect to the
+ // anode wire using all tracking information
+ //
+ // The estimation of the radial position is based on calculating the drift time and the drift velocity at the point of
+ // estimation. The drift time can be estimated according to the expression:
+ // BEGIN_LATEX
+ // t_{drift} = t_{bin} - t_{0} - t_{cause}(x) - t_{TC}(q_{i-1}, q_{i-2}, ...)
+ // END_LATEX
+ // where t_0 is the delay of the trigger signal. t_cause is the causality delay between ionisation electrons hitting
+ // the anode and the registration of maximum signal by the electronics - it is due to the rising time of the TRF
+ // A second order correction here comes from the fact that the time spreading of charge at anode is the convolution of
+ // TRF with the diffusion and thus cross-talk between clusters before and after local clusters changes with drift length.
+ // t_TC is the residual charge from previous (in time) clusters due to residual tails after tail cancellation.
+ // This tends to push cluster forward and depends on the magnitude of their charge.
+ //
+ // The drift velocity varies with the drift length (and distance to anode wire) as described by cell structure simulation.
+ // Thus one, in principle, can calculate iteratively the drift length from the expression:
+ // BEGIN_LATEX
+ // x = t_{drift}(x)*v_{drift}(x)
+ // END_LATEX
+ // In practice we use a numerical approach (AliTRDcluster::GetXcorr()) to correct for anisochronity obtained from MC
+ // comparison (see AliTRDclusterResolution::ProcessSigma()). Also the calibration of 0 approximation (no x dependence)
+ // for t_cause is obtained from MC comparisons and impossible to disentangle in real life from trigger delay.
+ //
+ // Author
+ // Alex Bercuci <A.Bercuci@gsi.de>
+ //
+
+ AliTRDCommonParam *cp = AliTRDCommonParam::Instance();
+ Double_t fFreq = cp->GetSamplingFrequency();
+
+ //drift time corresponding to the center of the time bin
+ Double_t td = (fPadTime + .5)/fFreq; // [us]
+ // correction for t0
+ td -= t0;
+ // time bin corrected for t0
+ // Bug in TMath::Nint().root-5.23.02
+ // TMath::Nint(3.5) = 4 and TMath::Nint(4.5) = 4
+ Double_t tmp = td*fFreq;
+ fLocalTimeBin = Char_t(TMath::Floor(tmp));
+ if(tmp-fLocalTimeBin > .5) fLocalTimeBin++;
+ if(td < .2) return 0.;
+ // TRF rising time (fitted)
+ // It should be absorbed by the t0. For the moment t0 is 0 for simulations.
+ // A.Bercuci (Mar 26 2009)
+ td -= 0.189;
+
+ // apply fitted correction
+ Float_t x = td*vd + (HasXcorr() ? GetXcorr(fLocalTimeBin) : 0.);
+ if(x>0.&&x<.5*AliTRDgeometry::CamHght()+AliTRDgeometry::CdrHght()) SetInChamber();
+
+ return x;
+}
+
+//_____________________________________________________________________________
+Float_t AliTRDcluster::GetYloc(Double_t y0, Double_t s2, Double_t W
+ , Double_t *const y1, Double_t *const y2)
+{
+ //
+ // Calculate, in tracking cooordinate system, the r-phi offset the cluster
+ // from the middle of the center pad. Three possible methods are implemented:
+ // - Center of Gravity (COG) see AliTRDcluster::GetDYcog()
+ // - Look-up Table (LUT) see AliTRDcluster::GetDYlut()
+ // - Gauss shape (GAUS) see AliTRDcluster::GetDYgauss()
+ // In addition for the case of LUT method position corrections are also
+ // applied (see AliTRDcluster::GetYcorr())
+ //
+
+ if(IsRPhiMethod(kCOG)) GetDYcog();
+ else if(IsRPhiMethod(kLUT)) GetDYlut();
+ else if(IsRPhiMethod(kGAUS)) GetDYgauss(s2/W/W, y1, y2);
+ else return 0.;
+
+ if(y1) (*y1)*=W;
+ if(y2) (*y2)*=W;
+
+ return y0+fCenter*W+(IsRPhiMethod(kLUT)?GetYcorr(AliTRDgeometry::GetLayer(fDetector), fCenter):0.);
+}
+
+//___________________________________________________________________________
+void AliTRDcluster::SetSigmaY2(Float_t s2, Float_t dt, Float_t exb, Float_t x, Float_t z, Float_t tgp)
+{
+ //
+ // Set variance of TRD cluster in the r-phi direction for each method.
+ // Parameters :
+ // - s2 - variance due to PRF width for the case of Gauss model. Replaced by parameterization in case of LUT.
+ // - dt - transversal diffusion coeficient
+ // - exb - tg of lorentz angle
+ // - x - drift length - with respect to the anode wire
+ // - z - offset from the anode wire
+ // - tgp - local tangent of the track momentum azimuthal angle
+ //
+ // The ingredients from which the error is computed are:
+ // - PRF (charge sharing on adjacent pads) - see AliTRDcluster::GetSYprf()
+ // - diffusion (dependence with drift length and [2nd order] distance to anode wire) - see AliTRDcluster::GetSYdrift()
+ // - charge of the cluster (complex dependence on gain and tail cancellation) - see AliTRDcluster::GetSYcharge()
+ // - lorentz angle (dependence on the drift length and [2nd order] distance to anode wire) - see AliTRDcluster::GetSX()
+ // - track angle (superposition of charges on the anode wire) - see AliTRDseedV1::Fit()
+ // - projection of radial(x) error on r-phi due to fixed value assumed in tracking for x - see AliTRDseedV1::Fit()
+ //
+ // The last 2 contributions to cluster error can be estimated only during tracking when the track angle
+ // is known (tgp). For this reason the errors (and optional position) of TRD clusters are recalculated during
+ // tracking and thus clusters attached to tracks might differ from bare clusters.
+ //
+ // Taking into account all contributions one can write the the TRD cluster error parameterization as:
+ // BEGIN_LATEX
+ // #sigma_{y}^{2} = (#sigma_{diff}*Gauss(0, s_{ly}) + #delta_{#sigma}(q))^{2} + tg^{2}(#alpha_{L})*#sigma_{x}^{2} + tg^{2}(#phi-#alpha_{L})*#sigma_{x}^{2}+[tg(#phi-#alpha_{L})*tg(#alpha_{L})*x]^{2}/12
+ // END_LATEX
+ // From this formula one can deduce a that the simplest calibration method for PRF and diffusion contributions is
+ // by measuring resolution at B=0T and phi=0. To disentangle further the two remaining contributions one has
+ // to represent s2 as a function of drift length.
+ //
+ // In the gaussian model the diffusion contribution can be expressed as:
+ // BEGIN_LATEX
+ // #sigma^{2}_{y} = #sigma^{2}_{PRF} + #frac{x#delta_{t}^{2}}{(1+tg(#alpha_{L}))^{2}}
+ // END_LATEX
+ // thus resulting the PRF contribution. For the case of the LUT model both contributions have to be determined from
+ // the fit (see AliTRDclusterResolution::ProcessCenter() for details).
+ //
+ // Author:
+ // A.Bercuci <A.Bercuci@gsi.de>
+ //
+
+ Float_t sigmaY2 = 0.;
+ Int_t ly = AliTRDgeometry::GetLayer(fDetector);
+ if(IsRPhiMethod(kCOG)) sigmaY2 = 4.e-4;
+ else if(IsRPhiMethod(kLUT)){
+ Float_t sd = GetSYdrift(fLocalTimeBin, ly, z); //printf("drift[%6.2f] ", 1.e4*sd);
+ sigmaY2 = GetSYprf(ly, fCenter, sd); //printf("PRF[%6.2f] ", 1.e4*sigmaY2);
+ // add charge contribution TODO scale with respect to s2
+ sigmaY2+= GetSYcharge(TMath::Abs(fQ)); //printf("Q[%6.2f] ", 1.e4*sigmaY2);
+ sigmaY2 = TMath::Max(sigmaY2, Float_t(0.0010)); //!! protection
+ sigmaY2*= sigmaY2;
+ } else if(IsRPhiMethod(kGAUS)){
+ // PRF contribution
+ sigmaY2 = s2;
+ // Diffusion contribution
+ Double_t sD2 = dt/(1.+exb); sD2 *= sD2; sD2 *= x;
+ sigmaY2+= sD2;
+ // add charge contribution TODO scale with respect to s2
+ //sigmaY2+= GetSYcharge(TMath::Abs(fQ));
+ }
+
+ // store tg^2(phi-a_L) and tg^2(a_L)
+ // limit parametrization to a maximum angle of 25 deg
+ if(TMath::Abs(tgp)>0.466) tgp = (tgp>0.)?0.466:-0.466;
+ Double_t tgg = (tgp-exb)/(1.+tgp*exb); tgg *= tgg;
+ Double_t exb2= exb*exb;
+
+ // Lorentz angle shift contribution
+ Float_t sx = GetSX(fLocalTimeBin, z); sx*=sx;
+ sigmaY2+= exb2*sx; //printf("Al[%6.2f] ", 1.e4*TMath::Sqrt(sigmaY2));
+
+ // Radial contribution due to not measuring x in Kalman model
+ sigmaY2+= tgg*sx; //printf("x[%6.2f] ", 1.e4*TMath::Sqrt(sigmaY2));
+
+ // Track angle contribution
+ sigmaY2+= tgg*x*x*exb2/12.; //printf("angle[%6.2f]\n", 1.e4*TMath::Sqrt(sigmaY2));
+
+ AliCluster::SetSigmaY2(sigmaY2);
+
+}