/* $Id$ */
////////////////////////////////////////////////////////////////////////////
-// //
-// The TRD track seed //
-// //
+////
+// The TRD offline tracklet
+//
+// The running horse of the TRD reconstruction. The following tasks are preformed:
+// 1. Clusters attachment to tracks based on prior information stored at tracklet level (see AttachClusters)
+// 2. Clusters position recalculation based on track information (see GetClusterXY and Fit)
+// 3. Cluster error parametrization recalculation (see Fit)
+// 4. Linear track approximation (Fit)
+// 5. Optimal position (including z estimate for pad row cross tracklets) and covariance matrix of the track fit inside one TRD chamber (Fit)
+// 6. Tilt pad correction and systematic effects (GetCovAt)
+// 7. dEdx calculation (CookdEdx)
+// 8. PID probabilities estimation (CookPID)
+//
// Authors: //
// Alex Bercuci <A.Bercuci@gsi.de> //
// Markus Fasel <M.Fasel@gsi.de> //
#include "AliTRDtrackerV1.h"
#include "AliTRDReconstructor.h"
#include "AliTRDrecoParam.h"
+#include "AliTRDCommonParam.h"
#include "Cal/AliTRDCalPID.h"
#include "Cal/AliTRDCalROC.h"
//____________________________________________________________________
AliTRDseedV1::AliTRDseedV1(Int_t det)
- :AliTRDseed()
+ :AliTRDtrackletBase()
,fReconstructor(0x0)
,fClusterIter(0x0)
+ ,fExB(0.)
+ ,fVD(0.)
+ ,fT0(0.)
+ ,fS2PRF(0.)
+ ,fDiffL(0.)
+ ,fDiffT(0.)
,fClusterIdx(0)
+ ,fN(0)
,fDet(det)
- ,fMom(0.)
- ,fSnp(0.)
- ,fTgl(0.)
+ ,fPt(0.)
,fdX(0.)
- ,fXref(0.)
- ,fExB(0.)
+ ,fX0(0.)
+ ,fX(0.)
+ ,fY(0.)
+ ,fZ(0.)
+ ,fS2Y(0.)
+ ,fS2Z(0.)
+ ,fC(0.)
+ ,fChi2(0.)
{
//
// Constructor
//
- for(int islice=0; islice < knSlices; islice++) fdEdx[islice] = 0.;
+ for(Int_t ic=kNclusters; ic--;) fIndexes[ic] = -1;
+ memset(fClusters, 0, kNclusters*sizeof(AliTRDcluster*));
+ memset(fPad, 0, 3*sizeof(Float_t));
+ fYref[0] = 0.; fYref[1] = 0.;
+ fZref[0] = 0.; fZref[1] = 0.;
+ fYfit[0] = 0.; fYfit[1] = 0.;
+ fZfit[0] = 0.; fZfit[1] = 0.;
+ memset(fdEdx, 0, kNslices*sizeof(Float_t));
for(int ispec=0; ispec<AliPID::kSPECIES; ispec++) fProb[ispec] = -1.;
- fRefCov[0] = 1.; fRefCov[1] = 0.; fRefCov[2] = 1.;
+ fLabels[0]=-1; fLabels[1]=-1; // most freq MC labels
+ fLabels[2]=0; // number of different labels for tracklet
+ memset(fRefCov, 0, 3*sizeof(Double_t));
// covariance matrix [diagonal]
// default sy = 200um and sz = 2.3 cm
fCov[0] = 4.e-4; fCov[1] = 0.; fCov[2] = 5.3;
+ SetStandAlone(kFALSE);
}
//____________________________________________________________________
AliTRDseedV1::AliTRDseedV1(const AliTRDseedV1 &ref)
- :AliTRDseed((AliTRDseed&)ref)
- ,fReconstructor(ref.fReconstructor)
+ :AliTRDtrackletBase((AliTRDtrackletBase&)ref)
+ ,fReconstructor(0x0)
,fClusterIter(0x0)
+ ,fExB(0.)
+ ,fVD(0.)
+ ,fT0(0.)
+ ,fS2PRF(0.)
+ ,fDiffL(0.)
+ ,fDiffT(0.)
,fClusterIdx(0)
- ,fDet(ref.fDet)
- ,fMom(ref.fMom)
- ,fSnp(ref.fSnp)
- ,fTgl(ref.fTgl)
- ,fdX(ref.fdX)
- ,fXref(ref.fXref)
- ,fExB(ref.fExB)
+ ,fN(0)
+ ,fDet(-1)
+ ,fPt(0.)
+ ,fdX(0.)
+ ,fX0(0.)
+ ,fX(0.)
+ ,fY(0.)
+ ,fZ(0.)
+ ,fS2Y(0.)
+ ,fS2Z(0.)
+ ,fC(0.)
+ ,fChi2(0.)
{
//
// Copy Constructor performing a deep copy
//
-
- //printf("AliTRDseedV1::AliTRDseedV1(const AliTRDseedV1 &)\n");
+ if(this != &ref){
+ ref.Copy(*this);
+ }
SetBit(kOwner, kFALSE);
- for(int islice=0; islice < knSlices; islice++) fdEdx[islice] = ref.fdEdx[islice];
- for(int ispec=0; ispec<AliPID::kSPECIES; ispec++) fProb[ispec] = ref.fProb[ispec];
- memcpy(fRefCov, ref.fRefCov, 3*sizeof(Double_t));
- memcpy(fCov, ref.fCov, 3*sizeof(Double_t));
+ SetStandAlone(ref.IsStandAlone());
}
SetBit(kOwner, kFALSE);
return *this;
-
}
//____________________________________________________________________
//printf("I-AliTRDseedV1::~AliTRDseedV1() : Owner[%s]\n", IsOwner()?"YES":"NO");
- if(IsOwner())
- for(int itb=0; itb<knTimebins; itb++){
+ if(IsOwner()) {
+ for(int itb=0; itb<kNclusters; itb++){
if(!fClusters[itb]) continue;
//AliInfo(Form("deleting c %p @ %d", fClusters[itb], itb));
delete fClusters[itb];
fClusters[itb] = 0x0;
}
+ }
}
//____________________________________________________________________
//AliInfo("");
AliTRDseedV1 &target = (AliTRDseedV1 &)ref;
+ target.fReconstructor = fReconstructor;
target.fClusterIter = 0x0;
+ target.fExB = fExB;
+ target.fVD = fVD;
+ target.fT0 = fT0;
+ target.fS2PRF = fS2PRF;
+ target.fDiffL = fDiffL;
+ target.fDiffT = fDiffT;
target.fClusterIdx = 0;
+ target.fN = fN;
target.fDet = fDet;
- target.fMom = fMom;
- target.fSnp = fSnp;
- target.fTgl = fTgl;
+ target.fPt = fPt;
target.fdX = fdX;
- target.fXref = fXref;
- target.fExB = fExB;
- target.fReconstructor = fReconstructor;
+ target.fX0 = fX0;
+ target.fX = fX;
+ target.fY = fY;
+ target.fZ = fZ;
+ target.fS2Y = fS2Y;
+ target.fS2Z = fS2Z;
+ target.fC = fC;
+ target.fChi2 = fChi2;
- for(int islice=0; islice < knSlices; islice++) target.fdEdx[islice] = fdEdx[islice];
- for(int ispec=0; ispec<AliPID::kSPECIES; ispec++) target.fProb[ispec] = fProb[ispec];
- memcpy(target.fRefCov, fRefCov, 3*sizeof(Double_t));
- memcpy(target.fCov, fCov, 3*sizeof(Double_t));
+ memcpy(target.fIndexes, fIndexes, kNclusters*sizeof(Int_t));
+ memcpy(target.fClusters, fClusters, kNclusters*sizeof(AliTRDcluster*));
+ memcpy(target.fPad, fPad, 3*sizeof(Float_t));
+ target.fYref[0] = fYref[0]; target.fYref[1] = fYref[1];
+ target.fZref[0] = fZref[0]; target.fZref[1] = fZref[1];
+ target.fYfit[0] = fYfit[0]; target.fYfit[1] = fYfit[1];
+ target.fZfit[0] = fZfit[0]; target.fZfit[1] = fZfit[1];
+ memcpy(target.fdEdx, fdEdx, kNslices*sizeof(Float_t));
+ memcpy(target.fProb, fProb, AliPID::kSPECIES*sizeof(Float_t));
+ memcpy(target.fLabels, fLabels, 3*sizeof(Int_t));
+ memcpy(target.fRefCov, fRefCov, 3*sizeof(Double_t));
+ memcpy(target.fCov, fCov, 3*sizeof(Double_t));
- AliTRDseed::Copy(target);
+ TObject::Copy(ref);
}
}
+//_____________________________________________________________________________
+void AliTRDseedV1::Reset()
+{
+ //
+ // Reset seed
+ //
+ fExB=0.;fVD=0.;fT0=0.;fS2PRF=0.;
+ fDiffL=0.;fDiffT=0.;
+ fClusterIdx=0;
+ fN=0;
+ fDet=-1;
+ fPt=0.;
+ fdX=0.;fX0=0.; fX=0.; fY=0.; fZ=0.;
+ fS2Y=0.; fS2Z=0.;
+ fC=0.; fChi2 = 0.;
+
+ for(Int_t ic=kNclusters; ic--;) fIndexes[ic] = -1;
+ memset(fClusters, 0, kNclusters*sizeof(AliTRDcluster*));
+ memset(fPad, 0, 3*sizeof(Float_t));
+ fYref[0] = 0.; fYref[1] = 0.;
+ fZref[0] = 0.; fZref[1] = 0.;
+ fYfit[0] = 0.; fYfit[1] = 0.;
+ fZfit[0] = 0.; fZfit[1] = 0.;
+ memset(fdEdx, 0, kNslices*sizeof(Float_t));
+ for(int ispec=0; ispec<AliPID::kSPECIES; ispec++) fProb[ispec] = -1.;
+ fLabels[0]=-1; fLabels[1]=-1; // most freq MC labels
+ fLabels[2]=0; // number of different labels for tracklet
+ memset(fRefCov, 0, 3*sizeof(Double_t));
+ // covariance matrix [diagonal]
+ // default sy = 200um and sz = 2.3 cm
+ fCov[0] = 4.e-4; fCov[1] = 0.; fCov[2] = 5.3;
+}
+
//____________________________________________________________________
void AliTRDseedV1::UpDate(const AliTRDtrackV1 *trk)
{
// update tracklet reference position from the TRD track
// Funny name to avoid the clash with the function AliTRDseed::Update() (has to be made obselete)
- fSnp = trk->GetSnp();
- fTgl = trk->GetTgl();
- fMom = trk->GetP();
- fYref[1] = fSnp/(1. - fSnp*fSnp);
+ Double_t fSnp = trk->GetSnp();
+ Double_t fTgl = trk->GetTgl();
+ fPt = trk->Pt();
+ fYref[1] = fSnp/TMath::Sqrt(1. - fSnp*fSnp);
fZref[1] = fTgl;
SetCovRef(trk->GetCovariance());
fZref[0] = trk->GetZ() - dx*fZref[1];
}
+//_____________________________________________________________________________
+void AliTRDseedV1::UpdateUsed()
+{
+ //
+ // Calculate number of used clusers in the tracklet
+ //
+
+ Int_t nused = 0, nshared = 0;
+ for (Int_t i = kNclusters; i--; ) {
+ if (!fClusters[i]) continue;
+ if(fClusters[i]->IsUsed()){
+ nused++;
+ } else if(fClusters[i]->IsShared()){
+ if(IsStandAlone()) nused++;
+ else nshared++;
+ }
+ }
+ SetNUsed(nused);
+ SetNShared(nshared);
+}
+
+//_____________________________________________________________________________
+void AliTRDseedV1::UseClusters()
+{
+ //
+ // Use clusters
+ //
+ // In stand alone mode:
+ // Clusters which are marked as used or shared from another track are
+ // removed from the tracklet
+ //
+ // In barrel mode:
+ // - Clusters which are used by another track become shared
+ // - Clusters which are attached to a kink track become shared
+ //
+ AliTRDcluster **c = &fClusters[0];
+ for (Int_t ic=kNclusters; ic--; c++) {
+ if(!(*c)) continue;
+ if(IsStandAlone()){
+ if((*c)->IsShared() || (*c)->IsUsed()){
+ if((*c)->IsShared()) SetNShared(GetNShared()-1);
+ else SetNUsed(GetNUsed()-1);
+ (*c) = 0x0;
+ fIndexes[ic] = -1;
+ SetN(GetN()-1);
+ continue;
+ }
+ } else {
+ if((*c)->IsUsed() || IsKink()){
+ (*c)->SetShared();
+ continue;
+ }
+ }
+ (*c)->Use();
+ }
+}
+
+
+
//____________________________________________________________________
void AliTRDseedV1::CookdEdx(Int_t nslices)
{
// Detailed description
// Calculates average dE/dx for all slices. Depending on the PID methode
// the number of slices can be 3 (LQ) or 8(NN).
-// The calculation of dQ/dl are done using the tracklet fit results (see AliTRDseedV1::GetdQdl(Int_t)) i.e.
-//
-// dQ/dl = qc/(dx * sqrt(1 + dy/dx^2 + dz/dx^2))
+// The calculation of dQ/dl are done using the tracklet fit results (see AliTRDseedV1::GetdQdl(Int_t))
//
// The following effects are included in the calculation:
// 1. calibration values for t0 and vdrift (using x coordinate to calculate slice)
// 3. cluster size
//
- Int_t nclusters[knSlices];
- for(int i=0; i<knSlices; i++){
- fdEdx[i] = 0.;
- nclusters[i] = 0;
- }
- Float_t clength = (/*.5 * */AliTRDgeometry::AmThick() + AliTRDgeometry::DrThick());
+ Int_t nclusters[kNslices];
+ memset(nclusters, 0, kNslices*sizeof(Int_t));
+ memset(fdEdx, 0, kNslices*sizeof(Float_t));
- AliTRDcluster *cluster = 0x0;
+ const Double_t kDriftLength = (.5 * AliTRDgeometry::AmThick() + AliTRDgeometry::DrThick());
+
+ AliTRDcluster *c = 0x0;
for(int ic=0; ic<AliTRDtrackerV1::GetNTimeBins(); ic++){
- if(!(cluster = fClusters[ic])) continue;
- Float_t x = cluster->GetX();
+ if(!(c = fClusters[ic]) && !(c = fClusters[ic+kNtb])) continue;
+ Float_t dx = TMath::Abs(fX0 - c->GetX());
// Filter clusters for dE/dx calculation
// 1.consider calibration effects for slice determination
- Int_t slice;
- if(cluster->IsInChamber()) slice = Int_t(TMath::Abs(fX0 - x) * nslices / clength);
- else slice = x < fX0 ? 0 : nslices-1;
-
+ Int_t slice;
+ if(dx<kDriftLength){ // TODO should be replaced by c->IsInChamber()
+ slice = Int_t(dx * nslices / kDriftLength);
+ } else slice = c->GetX() < fX0 ? nslices-1 : 0;
+
+
// 2. take sharing into account
- Float_t w = cluster->IsShared() ? .5 : 1.;
+ Float_t w = /*c->IsShared() ? .5 :*/ 1.;
// 3. take into account large clusters TODO
//w *= c->GetNPads() > 3 ? .8 : 1.;
} // End of loop over clusters
//if(fReconstructor->GetPIDMethod() == AliTRDReconstructor::kLQPID){
- if(nslices == AliTRDReconstructor::kLQslices){
+ if(nslices == AliTRDpidUtil::kLQslices){
// calculate mean charge per slice (only LQ PID)
for(int is=0; is<nslices; is++){
if(nclusters[is]) fdEdx[is] /= nclusters[is];
}
}
-//____________________________________________________________________
-void AliTRDseedV1::GetClusterXY(const AliTRDcluster *c, Double_t &x, Double_t &y)
+//_____________________________________________________________________________
+void AliTRDseedV1::CookLabels()
{
-// Return corrected position of the cluster taking into
-// account variation of the drift velocity with drift length.
-
+ //
+ // Cook 2 labels for seed
+ //
- // drift velocity correction TODO to be moved to the clusterizer
- const Float_t cx[] = {
- -9.6280e-02, 1.3091e-01,-1.7415e-02,-9.9221e-02,-1.2040e-01,-9.5493e-02,
- -5.0041e-02,-1.6726e-02, 3.5756e-03, 1.8611e-02, 2.6378e-02, 3.3823e-02,
- 3.4811e-02, 3.5282e-02, 3.5386e-02, 3.6047e-02, 3.5201e-02, 3.4384e-02,
- 3.2864e-02, 3.1932e-02, 3.2051e-02, 2.2539e-02,-2.5154e-02,-1.2050e-01,
- -1.2050e-01
- };
+ Int_t labels[200];
+ Int_t out[200];
+ Int_t nlab = 0;
+ for (Int_t i = 0; i < kNclusters; i++) {
+ if (!fClusters[i]) continue;
+ for (Int_t ilab = 0; ilab < 3; ilab++) {
+ if (fClusters[i]->GetLabel(ilab) >= 0) {
+ labels[nlab] = fClusters[i]->GetLabel(ilab);
+ nlab++;
+ }
+ }
+ }
- // PRF correction TODO to be replaced by the gaussian
- // approximation with full error parametrization and // moved to the clusterizer
- 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}
- };
-
- Int_t ily = AliTRDgeometry::GetLayer(c->GetDetector());
- x = c->GetX() - cx[c->GetLocalTimeBin()];
- y = c->GetY() + cy[ily][0] + cy[ily][1] * TMath::Sin(cy[ily][2] * c->GetCenter());
- return;
+ fLabels[2] = AliMathBase::Freq(nlab,labels,out,kTRUE);
+ fLabels[0] = out[0];
+ if ((fLabels[2] > 1) && (out[3] > 1)) fLabels[1] = out[2];
}
+
//____________________________________________________________________
Float_t AliTRDseedV1::GetdQdl(Int_t ic) const
{
- return fClusters[ic] ? TMath::Abs(fClusters[ic]->GetQ()) /fdX / TMath::Sqrt(1. + fYfit[1]*fYfit[1] + fZref[1]*fZref[1]) : 0.;
+// Using the linear approximation of the track inside one TRD chamber (TRD tracklet)
+// the charge per unit length can be written as:
+// BEGIN_LATEX
+// #frac{dq}{dl} = #frac{q_{c}}{dx * #sqrt{1 + #(){#frac{dy}{dx}}^{2}_{fit} + #(){#frac{dy}{dx}}^{2}_{ref}}}
+// END_LATEX
+// where qc is the total charge collected in the current time bin and dx is the length
+// of the time bin. For the moment (Jan 20 2009) only pad row cross corrections are
+// considered for the charge but none are applied for drift velocity variations along
+// the drift region or assymetry of the TRF
+//
+// Author : Alex Bercuci <A.Bercuci@gsi.de>
+//
+ Float_t dq = 0.;
+ if(fClusters[ic]) dq += TMath::Abs(fClusters[ic]->GetQ());
+ if(fClusters[ic+kNtb]) dq += TMath::Abs(fClusters[ic+kNtb]->GetQ());
+ if(dq<1.e-3 || fdX < 1.e-3) return 0.;
+
+ return dq/fdX/TMath::Sqrt(1. + fYfit[1]*fYfit[1] + fZref[1]*fZref[1]);
}
//____________________________________________________________________
-Double_t* AliTRDseedV1::GetProbability()
+Float_t* AliTRDseedV1::GetProbability(Bool_t force)
{
+ if(!force) return &fProb[0];
+ if(!CookPID()) return 0x0;
+ return &fProb[0];
+}
+
+//____________________________________________________________
+Bool_t AliTRDseedV1::CookPID()
+{
// Fill probability array for tracklet from the DB.
//
// Parameters
AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
if (!calibration) {
AliError("No access to calibration data");
- return 0x0;
+ return kFALSE;
}
if (!fReconstructor) {
AliError("Reconstructor not set.");
- return 0x0;
+ return kFALSE;
}
// Retrieve the CDB container class with the parametric detector response
const AliTRDCalPID *pd = calibration->GetPIDObject(fReconstructor->GetPIDMethod());
if (!pd) {
AliError("No access to AliTRDCalPID object");
- return 0x0;
+ return kFALSE;
}
//AliInfo(Form("Method[%d] : %s", fReconstructor->GetRecoParam() ->GetPIDMethod(), pd->IsA()->GetName()));
// Sets the a priori probabilities
for(int ispec=0; ispec<AliPID::kSPECIES; ispec++) {
- fProb[ispec] = pd->GetProbability(ispec, fMom, &fdEdx[0], length, GetPlane());
+ fProb[ispec] = pd->GetProbability(ispec, GetMomentum(), &fdEdx[0], length, GetPlane());
}
- return &fProb[0];
+ return kTRUE;
}
//____________________________________________________________________
// Returns a quality measurement of the current seed
//
- Float_t zcorr = kZcorr ? fTilt * (fZProb - fZref[0]) : 0.;
+ Float_t zcorr = kZcorr ? GetTilt() * (fZfit[0] - fZref[0]) : 0.;
return
- .5 * TMath::Abs(18.0 - fN2)
+ .5 * TMath::Abs(18.0 - GetN())
+ 10.* TMath::Abs(fYfit[1] - fYref[1])
+ 5. * TMath::Abs(fYfit[0] - fYref[0] + zcorr)
- + 2. * TMath::Abs(fMeanz - fZref[0]) / fPadLength;
+ + 2. * TMath::Abs(fZfit[0] - fZref[0]) / GetPadLength();
}
//____________________________________________________________________
Double_t xr = fX0-x;
Double_t sy2 = fCov[0] +2.*xr*fCov[1] + xr*xr*fCov[2];
- Double_t sz2 = fPadLength*fPadLength/12.;
+ Double_t sz2 = fS2Z;
+ //GetPadLength()*GetPadLength()/12.;
// insert systematic uncertainties
- Double_t sys[15];
- fReconstructor->GetRecoParam()->GetSysCovMatrix(sys);
- sy2 += sys[0];
- sz2 += sys[1];
-
+ if(fReconstructor){
+ Double_t sys[15]; memset(sys, 0, 15*sizeof(Double_t));
+ fReconstructor->GetRecoParam()->GetSysCovMatrix(sys);
+ sy2 += sys[0];
+ sz2 += sys[1];
+ }
// rotate covariance matrix
- Double_t t2 = fTilt*fTilt;
+ Double_t t2 = GetTilt()*GetTilt();
Double_t correction = 1./(1. + t2);
cov[0] = (sy2+t2*sz2)*correction;
- cov[1] = fTilt*(sz2 - sy2)*correction;
+ cov[1] = GetTilt()*(sz2 - sy2)*correction;
cov[2] = (t2*sy2+sz2)*correction;
+
+ //printf("C(%6.1f %+6.3f %6.1f) [%s]\n", 1.e4*TMath::Sqrt(cov[0]), cov[1], 1.e4*TMath::Sqrt(cov[2]), IsRowCross()?" RC ":"-");
}
+//____________________________________________________________
+Double_t AliTRDseedV1::GetCovSqrt(Double_t *c, Double_t *d)
+{
+// Helper function to calculate the square root of the covariance matrix.
+// The input matrix is stored in the vector c and the result in the vector d.
+// Both arrays have to be initialized by the user with at least 3 elements. Return negative in case of failure.
+//
+// For calculating the square root of the symmetric matrix c
+// the following relation is used:
+// BEGIN_LATEX
+// C^{1/2} = VD^{1/2}V^{-1}
+// END_LATEX
+// with V being the matrix with the n eigenvectors as columns.
+// In case C is symmetric the followings are true:
+// - matrix D is diagonal with the diagonal given by the eigenvalues of C
+// - V = V^{-1}
+//
+// Author A.Bercuci <A.Bercuci@gsi.de>
+// Date Mar 19 2009
+
+ Double_t L[2], // eigenvalues
+ V[3]; // eigenvectors
+ // the secular equation and its solution :
+ // (c[0]-L)(c[2]-L)-c[1]^2 = 0
+ // L^2 - L*Tr(c)+DET(c) = 0
+ // L12 = [Tr(c) +- sqrt(Tr(c)^2-4*DET(c))]/2
+ Double_t Tr = c[0]+c[2], // trace
+ DET = c[0]*c[2]-c[1]*c[1]; // determinant
+ if(TMath::Abs(DET)<1.e-20) return -1.;
+ Double_t DD = TMath::Sqrt(Tr*Tr - 4*DET);
+ L[0] = .5*(Tr + DD);
+ L[1] = .5*(Tr - DD);
+ if(L[0]<0. || L[1]<0.) return -1.;
+
+ // the sym V matrix
+ // | v00 v10|
+ // | v10 v11|
+ Double_t tmp = (L[0]-c[0])/c[1];
+ V[0] = TMath::Sqrt(1./(tmp*tmp+1));
+ V[1] = tmp*V[0];
+ V[2] = V[1]*c[1]/(L[1]-c[2]);
+ // the VD^{1/2}V is:
+ L[0] = TMath::Sqrt(L[0]); L[1] = TMath::Sqrt(L[1]);
+ d[0] = V[0]*V[0]*L[0]+V[1]*V[1]*L[1];
+ d[1] = V[0]*V[1]*L[0]+V[1]*V[2]*L[1];
+ d[2] = V[1]*V[1]*L[0]+V[2]*V[2]*L[1];
+
+ return 1.;
+}
+
+//____________________________________________________________
+Double_t AliTRDseedV1::GetCovInv(Double_t *c, Double_t *d)
+{
+// Helper function to calculate the inverse of the covariance matrix.
+// The input matrix is stored in the vector c and the result in the vector d.
+// Both arrays have to be initialized by the user with at least 3 elements
+// The return value is the determinant or 0 in case of singularity.
+//
+// Author A.Bercuci <A.Bercuci@gsi.de>
+// Date Mar 19 2009
+
+ Double_t Det = c[0]*c[2] - c[1]*c[1];
+ if(TMath::Abs(Det)<1.e-20) return 0.;
+ Double_t InvDet = 1./Det;
+ d[0] = c[2]*InvDet;
+ d[1] =-c[1]*InvDet;
+ d[2] = c[0]*InvDet;
+ return Det;
+}
//____________________________________________________________________
-void AliTRDseedV1::SetExB()
+UShort_t AliTRDseedV1::GetVolumeId() const
{
-// Retrive the tg(a_L) from OCDB. The following information are used
+ Int_t ic=0;
+ while(ic<kNclusters && !fClusters[ic]) ic++;
+ return fClusters[ic] ? fClusters[ic]->GetVolumeId() : 0;
+}
+
+
+//____________________________________________________________________
+void AliTRDseedV1::Calibrate()
+{
+// Retrieve calibration and position parameters from OCDB.
+// The following information are used
// - detector index
-// - column and row position of first attached cluster.
-//
-// If no clusters are attached to the tracklet a random central chamber
-// position (c=70, r=7) will be used to retrieve the drift velocity.
+// - column and row position of first attached cluster. If no clusters are attached
+// to the tracklet a random central chamber position (c=70, r=7) will be used.
+//
+// The following information is cached in the tracklet
+// t0 (trigger delay)
+// drift velocity
+// PRF width
+// omega*tau = tg(a_L)
+// diffusion coefficients (longitudinal and transversal)
//
// Author :
// Alex Bercuci <A.Bercuci@gsi.de>
return;
}
- AliTRDcalibDB *fCalib = AliTRDcalibDB::Instance();
- AliTRDCalROC *fCalVdriftROC = fCalib->GetVdriftROC(fDet);
- const AliTRDCalDet *fCalVdriftDet = fCalib->GetVdriftDet();
+ AliTRDcalibDB *calib = AliTRDcalibDB::Instance();
+ AliTRDCalROC *vdROC = calib->GetVdriftROC(fDet),
+ *t0ROC = calib->GetT0ROC(fDet);;
+ const AliTRDCalDet *vdDet = calib->GetVdriftDet();
+ const AliTRDCalDet *t0Det = calib->GetT0Det();
Int_t col = 70, row = 7;
AliTRDcluster **c = &fClusters[0];
- if(fN){
+ if(GetN()){
Int_t ic = 0;
- while (ic<AliTRDseed::knTimebins && !(*c)){ic++; c++;}
+ while (ic<kNclusters && !(*c)){ic++; c++;}
if(*c){
col = (*c)->GetPadCol();
row = (*c)->GetPadRow();
}
}
- Double_t vd = fCalVdriftDet->GetValue(fDet) * fCalVdriftROC->GetValue(col, row);
- fExB = fCalib->GetOmegaTau(vd, -0.1*AliTracker::GetBz());
+ fT0 = t0Det->GetValue(fDet) + t0ROC->GetValue(col,row);
+ fVD = vdDet->GetValue(fDet) * vdROC->GetValue(col, row);
+ fS2PRF = calib->GetPRFWidth(fDet, col, row); fS2PRF *= fS2PRF;
+ fExB = AliTRDCommonParam::Instance()->GetOmegaTau(fVD);
+ AliTRDCommonParam::Instance()->GetDiffCoeff(fDiffL,
+ fDiffT, fVD);
+ SetBit(kCalib, kTRUE);
}
//____________________________________________________________________
//AliInfo(Form("own [%s] fOwner[%s]", own?"YES":"NO", fOwner?"YES":"NO"));
if(TestBit(kOwner)) return;
- for(int ic=0; ic<knTimebins; ic++){
+ for(int ic=0; ic<kNclusters; ic++){
if(!fClusters[ic]) continue;
fClusters[ic] = new AliTRDcluster(*fClusters[ic]);
}
SetBit(kOwner);
}
-//____________________________________________________________________
-Bool_t AliTRDseedV1::AttachClustersIter(AliTRDtrackingChamber *chamber, Float_t quality, Bool_t kZcorr, AliTRDcluster *c)
+//____________________________________________________________
+void AliTRDseedV1::SetPadPlane(AliTRDpadPlane *p)
{
- //
- // Iterative process to register clusters to the seed.
- // In iteration 0 we try only one pad-row and if quality not
- // sufficient we try 2 pad-rows (about 5% of tracks cross 2 pad-rows)
- //
- // debug level 7
- //
-
- if(!fReconstructor->GetRecoParam() ){
- AliError("Seed can not be used without a valid RecoParam.");
- return kFALSE;
- }
-
- AliTRDchamberTimeBin *layer = 0x0;
- if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker)>=7){
- AliTRDtrackingChamber ch(*chamber);
- ch.SetOwner();
- TTreeSRedirector &cstreamer = *fReconstructor->GetDebugStream(AliTRDReconstructor::kTracker);
- cstreamer << "AttachClustersIter"
- << "chamber.=" << &ch
- << "tracklet.=" << this
- << "\n";
- }
-
- Float_t tquality;
- Double_t kroady = fReconstructor->GetRecoParam() ->GetRoad1y();
- Double_t kroadz = fPadLength * .5 + 1.;
-
- // initialize configuration parameters
- Float_t zcorr = kZcorr ? fTilt * (fZProb - fZref[0]) : 0.;
- Int_t niter = kZcorr ? 1 : 2;
-
- Double_t yexp, zexp;
- Int_t ncl = 0;
- // start seed update
- for (Int_t iter = 0; iter < niter; iter++) {
- ncl = 0;
- for (Int_t iTime = 0; iTime < AliTRDtrackerV1::GetNTimeBins(); iTime++) {
- if(!(layer = chamber->GetTB(iTime))) continue;
- if(!Int_t(*layer)) continue;
-
- // define searching configuration
- Double_t dxlayer = layer->GetX() - fX0;
- if(c){
- zexp = c->GetZ();
- //Try 2 pad-rows in second iteration
- if (iter > 0) {
- zexp = fZref[0] + fZref[1] * dxlayer - zcorr;
- if (zexp > c->GetZ()) zexp = c->GetZ() + fPadLength*0.5;
- if (zexp < c->GetZ()) zexp = c->GetZ() - fPadLength*0.5;
- }
- } else zexp = fZref[0] + (kZcorr ? fZref[1] * dxlayer : 0.);
- yexp = fYref[0] + fYref[1] * dxlayer - zcorr;
-
- // Get and register cluster
- Int_t index = layer->SearchNearestCluster(yexp, zexp, kroady, kroadz);
- if (index < 0) continue;
- AliTRDcluster *cl = (*layer)[index];
-
- fIndexes[iTime] = layer->GetGlobalIndex(index);
- fClusters[iTime] = cl;
- fY[iTime] = cl->GetY();
- fZ[iTime] = cl->GetZ();
- ncl++;
- }
- if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker)>=7) AliInfo(Form("iter = %d ncl [%d] = %d", iter, fDet, ncl));
-
- if(ncl>1){
- // calculate length of the time bin (calibration aware)
- Int_t irp = 0; Float_t x[2]; Int_t tb[2];
- for (Int_t iTime = 0; iTime < AliTRDtrackerV1::GetNTimeBins(); iTime++) {
- if(!fClusters[iTime]) continue;
- x[irp] = fClusters[iTime]->GetX();
- tb[irp] = iTime;
- irp++;
- if(irp==2) break;
- }
- fdX = (x[1] - x[0]) / (tb[0] - tb[1]);
-
- // update X0 from the clusters (calibration/alignment aware)
- for (Int_t iTime = 0; iTime < AliTRDtrackerV1::GetNTimeBins(); iTime++) {
- if(!(layer = chamber->GetTB(iTime))) continue;
- if(!layer->IsT0()) continue;
- if(fClusters[iTime]){
- fX0 = fClusters[iTime]->GetX();
- break;
- } else { // we have to infere the position of the anode wire from the other clusters
- for (Int_t jTime = iTime+1; jTime < AliTRDtrackerV1::GetNTimeBins(); jTime++) {
- if(!fClusters[jTime]) continue;
- fX0 = fClusters[jTime]->GetX() + fdX * (jTime - iTime);
- break;
- }
- }
- }
-
- // update YZ reference point
- // TODO
-
- // update x reference positions (calibration/alignment aware)
- for (Int_t iTime = 0; iTime < AliTRDtrackerV1::GetNTimeBins(); iTime++) {
- if(!fClusters[iTime]) continue;
- fX[iTime] = fX0 - fClusters[iTime]->GetX();
- }
-
- AliTRDseed::Update();
- }
- if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker)>=7) AliInfo(Form("iter = %d nclFit [%d] = %d", iter, fDet, fN2));
-
- if(IsOK()){
- tquality = GetQuality(kZcorr);
- if(tquality < quality) break;
- else quality = tquality;
- }
- kroadz *= 2.;
- } // Loop: iter
- if (!IsOK()) return kFALSE;
-
- if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker)>=1) CookLabels();
-
- // set ExB angle
- SetExB();
- UpdateUsed();
- return kTRUE;
+// Shortcut method to initialize pad geometry.
+ if(!p) return;
+ SetTilt(TMath::Tan(TMath::DegToRad()*p->GetTiltingAngle()));
+ SetPadLength(p->GetLengthIPad());
+ SetPadWidth(p->GetWidthIPad());
}
+
//____________________________________________________________________
Bool_t AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *chamber, Bool_t tilt)
{
//define roads
Double_t kroady = 1.;
//fReconstructor->GetRecoParam() ->GetRoad1y();
- Double_t kroadz = fPadLength * 1.5 + 1.;
+ Double_t kroadz = GetPadLength() * 1.5 + 1.;
if(kPRINT) printf("AttachClusters() sy[%f] road[%f]\n", syRef, kroady);
// working variables
const Int_t kNrows = 16;
- AliTRDcluster *clst[kNrows][knTimebins];
+ AliTRDcluster *clst[kNrows][kNclusters];
Double_t cond[4], dx, dy, yt, zt,
- yres[kNrows][knTimebins];
- Int_t idxs[kNrows][knTimebins], ncl[kNrows], ncls = 0;
+ yres[kNrows][kNclusters];
+ Int_t idxs[kNrows][kNclusters], ncl[kNrows], ncls = 0;
memset(ncl, 0, kNrows*sizeof(Int_t));
- memset(clst, 0, kNrows*knTimebins*sizeof(AliTRDcluster*));
+ memset(clst, 0, kNrows*kNclusters*sizeof(AliTRDcluster*));
// Do cluster projection
AliTRDcluster *c = 0x0;
for(Int_t ic = n; ic--;){
c = (*layer)[idx[ic]];
dy = yt - c->GetY();
- dy += tilt ? fTilt * (c->GetZ() - zt) : 0.;
+ dy += tilt ? GetTilt() * (c->GetZ() - zt) : 0.;
// select clusters on a 3 sigmaKalman level
/* if(tilt && TMath::Abs(dy) > 3.*syRef){
printf("too large !!!\n");
yres[r][ncl[r]] = dy;
ncl[r]++; ncls++;
- if(ncl[r] >= knTimebins) {
- AliWarning(Form("Cluster candidates reached limit %d. Some may be lost.", knTimebins));
+ if(ncl[r] >= kNclusters) {
+ AliWarning(Form("Cluster candidates reached limit %d. Some may be lost.", kNclusters));
kBUFFER = kTRUE;
break;
}
// We should consider here :
// 1. How far is the chamber boundary
// 2. How big is the mean
- fN2 = 0;
+ Int_t n = 0;
for (Int_t ir = 0; ir < nr; ir++) {
Int_t jr = row + ir*lr;
if(kPRINT) printf("\tattach %d clusters for row %d\n", ncl[jr], jr);
if(!(c = clst[jr][ic])) continue;
Int_t it = c->GetPadTime();
// TODO proper indexing of clusters !!
- fIndexes[it+35*ir] = chamber->GetTB(it)->GetGlobalIndex(idxs[jr][ic]);
- fClusters[it+35*ir] = c;
+ fIndexes[it+kNtb*ir] = chamber->GetTB(it)->GetGlobalIndex(idxs[jr][ic]);
+ fClusters[it+kNtb*ir] = c;
//printf("\tid[%2d] it[%d] idx[%d]\n", ic, it, fIndexes[it]);
- fN2++;
+ n++;
}
}
// number of minimum numbers of clusters expected for the tracklet
- if (fN2 < kClmin){
- AliWarning(Form("Not enough clusters to fit the tracklet %d [%d].", fN2, kClmin));
- fN2 = 0;
- return kFALSE;
- }
-
- // update used clusters and select
- fNUsed = 0;
- for (Int_t it = 0; it < AliTRDtrackerV1::GetNTimeBins(); it++) {
- if(fClusters[it] && fClusters[it]->IsUsed()) fNUsed++;
- if(fClusters[it+35] && fClusters[it+35]->IsUsed()) fNUsed++;
- }
- if (fN2-fNUsed < kClmin){
- //AliWarning(Form("Too many clusters already in use %d (from %d).", fNUsed, fN2));
- fN2 = 0;
+ if (n < kClmin){
+ //AliWarning(Form("Not enough clusters to fit the tracklet %d [%d].", n, kClmin));
return kFALSE;
}
+ SetN(n);
- // set the Lorentz angle for this tracklet
- SetExB();
+ // Load calibration parameters for this tracklet
+ Calibrate();
// calculate dx for time bins in the drift region (calibration aware)
- Int_t irp = 0; Float_t x[2]; Int_t tb[2];
+ Int_t irp = 0; Float_t x[2] = {0.,0.}; Int_t tb[2]={0,0};
for (Int_t it = t0; it < AliTRDtrackerV1::GetNTimeBins(); it++) {
if(!fClusters[it]) continue;
x[irp] = fClusters[it]->GetX();
tb[irp] = it;
irp++;
if(irp==2) break;
- }
- fdX = (x[1] - x[0]) / (tb[0] - tb[1]);
-
- // update X0 from the clusters (calibration/alignment aware) TODO remove dependence on x0 !!
- for (Int_t it = 0; it < AliTRDtrackerV1::GetNTimeBins(); it++) {
- if(!(layer = chamber->GetTB(it))) continue;
- if(!layer->IsT0()) continue;
- if(fClusters[it]){
- fX0 = fClusters[it]->GetX();
- break;
- } else { // we have to infere the position of the anode wire from the other clusters
- for (Int_t jt = it+1; jt < AliTRDtrackerV1::GetNTimeBins(); jt++) {
- if(!fClusters[jt]) continue;
- fX0 = fClusters[jt]->GetX() + fdX * (jt - it);
- break;
- }
- }
- }
+ }
+ Int_t dtb = tb[1] - tb[0];
+ fdX = dtb ? (x[0] - x[1]) / dtb : 0.15;
return kTRUE;
}
fReconstructor = rec;
AliTRDgeometry g;
AliTRDpadPlane *pp = g.GetPadPlane(fDet);
- fTilt = TMath::Tan(TMath::DegToRad()*pp->GetTiltingAngle());
- fPadLength = pp->GetLengthIPad();
- fSnp = fYref[1]/TMath::Sqrt(1+fYref[1]*fYref[1]);
- fTgl = fZref[1];
- fN = 0; fN2 = 0; fMPads = 0.;
+ fPad[0] = pp->GetLengthIPad();
+ fPad[1] = pp->GetWidthIPad();
+ fPad[3] = TMath::Tan(TMath::DegToRad()*pp->GetTiltingAngle());
+ //fSnp = fYref[1]/TMath::Sqrt(1+fYref[1]*fYref[1]);
+ //fTgl = fZref[1];
+ Int_t n = 0, nshare = 0, nused = 0;
AliTRDcluster **cit = &fClusters[0];
- for(Int_t ic = knTimebins; ic--; cit++){
+ for(Int_t ic = kNclusters; ic--; cit++){
if(!(*cit)) return;
- fN++; fN2++;
- fX[ic] = (*cit)->GetX() - fX0;
- fY[ic] = (*cit)->GetY();
- fZ[ic] = (*cit)->GetZ();
+ n++;
+ if((*cit)->IsShared()) nshare++;
+ if((*cit)->IsUsed()) nused++;
}
- Update(); // Fit();
+ SetN(n); SetNUsed(nused); SetNShared(nshare);
+ Fit();
CookLabels();
GetProbability();
}
//____________________________________________________________________
-Bool_t AliTRDseedV1::Fit(Bool_t tilt, Int_t errors)
+Bool_t AliTRDseedV1::Fit(Bool_t tilt, Bool_t zcorr)
{
//
// Linear fit of the tracklet
// 3. Do a Least Square Fit to the data
//
+ if(!IsCalibrated()) Calibrate();
+
const Int_t kClmin = 8;
{3.439e-02,-3.601e-04, 3.883e-01, 2.623e-02},
{3.510e-02, 2.066e-03, 3.651e-01, 2.588e-02},
};
- // 3. sy parallel to the track
- const Float_t sy0 = 2.649e-02; // [cm]
- const Float_t sya = -8.864e-04; // [cm]
- const Float_t syb = -2.435e-01; // [cm]
-
- // 4. sx parallel to the track
- const Float_t sxgc = 5.427e-02;
- const Float_t sxgm = 7.783e-01;
- const Float_t sxgs = 2.743e-01;
- const Float_t sxe0 =-2.065e+00;
- const Float_t sxe1 =-2.978e-02;
-
- // 5. sx perpendicular to the track
-// const Float_t sxd0 = 1.881e-02;
-// const Float_t sxd1 =-4.101e-01;
-// const Float_t sxd2 = 1.572e+00;
// get track direction
Double_t y0 = fYref[0];
Double_t dzdx = fZref[1];
Double_t yt, zt;
- const Int_t kNtb = AliTRDtrackerV1::GetNTimeBins();
+ // calculation of tg^2(phi - a_L) and tg^2(a_L)
+ Double_t tgg = (dydx-fExB)/(1.+dydx*fExB); tgg *= tgg;
+ //Double_t exb2= fExB*fExB;
+
//AliTRDtrackerV1::AliTRDLeastSquare fitterZ;
TLinearFitter fitterY(1, "pol1");
- // convertion factor from square to gauss distribution for sigma
- //Double_t convert = 1./TMath::Sqrt(12.);
+ TLinearFitter fitterZ(1, "pol1");
// book cluster information
- Double_t q, xc[knTimebins], yc[knTimebins], zc[knTimebins], sy[knTimebins]/*, sz[knTimebins]*/;
-// Int_t zRow[knTimebins];
-
+ Double_t qc[kNclusters], xc[kNclusters], yc[kNclusters], zc[kNclusters], sy[kNclusters];
+
Int_t ily = AliTRDgeometry::GetLayer(fDet);
- fN = 0; //fXref = 0.; Double_t ssx = 0.;
+ Int_t n = 0;
AliTRDcluster *c=0x0, **jc = &fClusters[0];
for (Int_t ic=0; ic<kNtb; ic++, ++jc) {
//zRow[ic] = -1;
yc[ic] = 999.;
zc[ic] = 999.;
sy[ic] = 0.;
- //sz[ic] = 0.;
if(!(c = (*jc))) continue;
if(!c->IsInChamber()) continue;
Float_t w = 1.;
if(c->GetNPads()>4) w = .5;
if(c->GetNPads()>5) w = .2;
+ Int_t tb = c->GetLocalTimeBin();
- //zRow[fN] = c->GetPadRow();
- // correct cluster position for PRF and v drift
- Double_t x, y; GetClusterXY(c, x, y);
- xc[fN] = fX0 - x;
- yc[fN] = y;
- zc[fN] = c->GetZ();
+ qc[n] = TMath::Abs(c->GetQ());
+ // Radial cluster position
+ //Int_t jc = TMath::Max(fN-3, 0);
+ //xc[fN] = c->GetXloc(fT0, fVD, &qc[jc], &xc[jc]/*, z0 - c->GetX()*dzdx*/);
+ xc[n] = fX0 - c->GetX();
+
+ //Double_t s2 = fS2PRF + fDiffL*fDiffL*xc[n]/(1.+2.*exb2)+tgg*xc[n]*xc[n]*exb2/12.;
+ //yc[fN] = c->GetYloc(s2, GetPadWidth(), xc[fN], fExB);
+ yc[n] = c->GetY()-AliTRDcluster::GetYcorr(ily, c->GetCenter());
+ zc[n] = c->GetZ();
// extrapolated y value for the track
- yt = y0 - xc[fN]*dydx;
+ yt = y0 - xc[n]*dydx;
// extrapolated z value for the track
- zt = z0 - xc[fN]*dzdx;
+ zt = z0 - xc[n]*dzdx;
// tilt correction
- if(tilt) yc[fN] -= fTilt*(zc[fN] - zt);
+ if(tilt) yc[n] -= GetTilt()*(zc[n] - zt);
// ELABORATE CLUSTER ERROR
- // TODO to be moved to AliTRDcluster
- q = TMath::Abs(c->GetQ());
- Double_t tgg = (dydx-fExB)/(1.+dydx*fExB); tgg *= tgg;
// basic y error (|| to track).
- sy[fN] = xc[fN] < AliTRDgeometry::CamHght() ? 2. : sy0 + sya*TMath::Exp(1./(xc[fN]+syb));
+ sy[n] = AliTRDcluster::GetSY(tb, zcorr?zt:-1.);
//printf("cluster[%d]\n\tsy[0] = %5.3e [um]\n", fN, sy[fN]*1.e4);
// y error due to total charge
- sy[fN] += sqb*(1./q - sq0inv);
+ sy[n] += sqb*(1./qc[n] - sq0inv);
//printf("\tsy[1] = %5.3e [um]\n", sy[fN]*1.e4);
// y error due to PRF
- sy[fN] += scy[ily][0]*TMath::Gaus(c->GetCenter(), scy[ily][1], scy[ily][2]) - scy[ily][3];
+ sy[n] += scy[ily][0]*TMath::Gaus(c->GetCenter(), scy[ily][1], scy[ily][2]) - scy[ily][3];
//printf("\tsy[2] = %5.3e [um]\n", sy[fN]*1.e4);
- sy[fN] *= sy[fN];
+ sy[n] *= sy[n];
// ADD ERROR ON x
// error of drift length parallel to the track
- Double_t sx = sxgc*TMath::Gaus(xc[fN], sxgm, sxgs) + TMath::Exp(sxe0+sxe1*xc[fN]); // [cm]
+ Double_t sx = AliTRDcluster::GetSX(tb, zcorr?zt:-1.); // [cm]
//printf("\tsx[0] = %5.3e [um]\n", sx*1.e4);
- // error of drift length perpendicular to the track
- //sx += sxd0 + sxd1*d + sxd2*d*d;
sx *= sx; // square sx
- // update xref
- //fXref += xc[fN]/sx; ssx+=1./sx;
// add error from ExB
- if(errors>0) sy[fN] += fExB*fExB*sx;
+ sy[n] += fExB*fExB*sx;
//printf("\tsy[3] = %5.3e [um^2]\n", sy[fN]*1.e8);
// global radial error due to misalignment/miscalibration
Double_t sx0 = 0.; sx0 *= sx0;
// add sx contribution to sy due to track angle
- if(errors>1) sy[fN] += tgg*(sx+sx0);
+ sy[n] += tgg*(sx+sx0);
// TODO we should add tilt pad correction here
//printf("\tsy[4] = %5.3e [um^2]\n", sy[fN]*1.e8);
- c->SetSigmaY2(sy[fN]);
+ c->SetSigmaY2(sy[n]);
- sy[fN] = TMath::Sqrt(sy[fN]);
- fitterY.AddPoint(&xc[fN], yc[fN]/*-yt*/, sy[fN]);
- fN++;
+ sy[n] = TMath::Sqrt(sy[n]);
+ fitterY.AddPoint(&xc[n], yc[n], sy[n]);
+ fitterZ.AddPoint(&xc[n], qc[n], 1.);
+ n++;
}
// to few clusters
- if (fN < kClmin) return kFALSE;
+ if (n < kClmin) return kFALSE;
// fit XY
fitterY.Eval();
fCov[2] = p[3]; // variance of dydx
// the ref radial position is set at the minimum of
// the y variance of the tracklet
- fXref = -fCov[1]/fCov[2]; //fXref = fX0 - fXref;
+ fX = -fCov[1]/fCov[2];
// fit XZ
- if(IsRowCross()){
- // TODO pad row cross position estimation !!!
- //AliInfo(Form("Padrow cross in detector %d", fDet));
- fZfit[0] = .5*(zc[0]+zc[fN-1]); fZfit[1] = 0.;
+ if(IsRowCross()){
+ Int_t ic=n=kNclusters-1; jc = &fClusters[ic];
+ for(; ic>kNtb; ic--, --jc){
+ if(!(c = (*jc))) continue;
+ if(!c->IsInChamber()) continue;
+ qc[n] = TMath::Abs(c->GetQ());
+ xc[n] = fX0 - c->GetX();
+ zc[n] = c->GetZ();
+ fitterZ.AddPoint(&xc[n], -qc[n], 1.);
+ n--;
+ }
+ // fit XZ
+ fitterZ.Eval();
+ if(fitterZ.GetParameter(1)!=0.){
+ fX = -fitterZ.GetParameter(0)/fitterZ.GetParameter(1);
+ fX=(fX<0.)?0.:fX;
+ Float_t dl = .5*AliTRDgeometry::CamHght()+AliTRDgeometry::CdrHght();
+ fX=(fX> dl)?dl:fX;
+ fX+=.055; // TODO to be understood
+ }
+
+ fZfit[0] = .5*(zc[0]+zc[kNclusters-1]); fZfit[1] = 0.;
+ fS2Z = 0.02+1.55*fZref[1]; fS2Z *= fS2Z;
} else {
fZfit[0] = zc[0]; fZfit[1] = 0.;
+ fS2Z = GetPadLength()*GetPadLength()/12.;
}
+ fS2Y = fCov[0] +2.*fX*fCov[1] + fX*fX*fCov[2];
+ return kTRUE;
+}
-// // determine z offset of the fit
-// Float_t zslope = 0.;
-// Int_t nchanges = 0, nCross = 0;
-// if(nz==2){ // tracklet is crossing pad row
-// // Find the break time allowing one chage on pad-rows
-// // with maximal number of accepted clusters
-// Int_t padRef = zRow[0];
-// for (Int_t ic=1; ic<fN; ic++) {
-// if(zRow[ic] == padRef) continue;
-//
-// // debug
-// if(zRow[ic-1] == zRow[ic]){
-// printf("ERROR in pad row change!!!\n");
-// }
-//
-// // evaluate parameters of the crossing point
-// Float_t sx = (xc[ic-1] - xc[ic])*convert;
-// fCross[0] = .5 * (xc[ic-1] + xc[ic]);
-// fCross[2] = .5 * (zc[ic-1] + zc[ic]);
-// fCross[3] = TMath::Max(dzdx * sx, .01);
-// zslope = zc[ic-1] > zc[ic] ? 1. : -1.;
-// padRef = zRow[ic];
-// nCross = ic;
-// nchanges++;
-// }
-// }
-//
-// // condition on nCross and reset nchanges TODO
-//
-// if(nchanges==1){
-// if(dzdx * zslope < 0.){
-// AliInfo("Tracklet-Track mismatch in dzdx. TODO.");
-// }
-//
-//
-// //zc[nc] = fitterZ.GetFunctionParameter(0);
-// fCross[1] = fYfit[0] - fCross[0] * fYfit[1];
-// fCross[0] = fX0 - fCross[0];
-// }
+/*
+//_____________________________________________________________________________
+void AliTRDseedV1::FitMI()
+{
+//
+// Fit the seed.
+// Marian Ivanov's version
+//
+// linear fit on the y direction with respect to the reference direction.
+// The residuals for each x (x = xc - x0) are deduced from:
+// dy = y - yt (1)
+// the tilting correction is written :
+// y = yc + h*(zc-zt) (2)
+// yt = y0+dy/dx*x (3)
+// zt = z0+dz/dx*x (4)
+// from (1),(2),(3) and (4)
+// dy = yc - y0 - (dy/dx + h*dz/dx)*x + h*(zc-z0)
+// the last term introduces the correction on y direction due to tilting pads. There are 2 ways to account for this:
+// 1. use tilting correction for calculating the y
+// 2. neglect tilting correction here and account for it in the error parametrization of the tracklet.
+ const Float_t kRatio = 0.8;
+ const Int_t kClmin = 5;
+ const Float_t kmaxtan = 2;
+
+ if (TMath::Abs(fYref[1]) > kmaxtan){
+ //printf("Exit: Abs(fYref[1]) = %3.3f, kmaxtan = %3.3f\n", TMath::Abs(fYref[1]), kmaxtan);
+ return; // Track inclined too much
+ }
+
+ Float_t sigmaexp = 0.05 + TMath::Abs(fYref[1] * 0.25); // Expected r.m.s in y direction
+ Float_t ycrosscor = GetPadLength() * GetTilt() * 0.5; // Y correction for crossing
+ Int_t fNChange = 0;
+
+ Double_t sumw;
+ Double_t sumwx;
+ Double_t sumwx2;
+ Double_t sumwy;
+ Double_t sumwxy;
+ Double_t sumwz;
+ Double_t sumwxz;
+
+ // Buffering: Leave it constant fot Performance issues
+ Int_t zints[kNtb]; // Histograming of the z coordinate
+ // Get 1 and second max probable coodinates in z
+ Int_t zouts[2*kNtb];
+ Float_t allowedz[kNtb]; // Allowed z for given time bin
+ Float_t yres[kNtb]; // Residuals from reference
+ //Float_t anglecor = GetTilt() * fZref[1]; // Correction to the angle
+
+ Float_t pos[3*kNtb]; memset(pos, 0, 3*kNtb*sizeof(Float_t));
+ Float_t *fX = &pos[0], *fY = &pos[kNtb], *fZ = &pos[2*kNtb];
+
+ Int_t fN = 0; AliTRDcluster *c = 0x0;
+ fN2 = 0;
+ for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins(); i++) {
+ yres[i] = 10000.0;
+ if (!(c = fClusters[i])) continue;
+ if(!c->IsInChamber()) continue;
+ // Residual y
+ //yres[i] = fY[i] - fYref[0] - (fYref[1] + anglecor) * fX[i] + GetTilt()*(fZ[i] - fZref[0]);
+ fX[i] = fX0 - c->GetX();
+ fY[i] = c->GetY();
+ fZ[i] = c->GetZ();
+ yres[i] = fY[i] - GetTilt()*(fZ[i] - (fZref[0] - fX[i]*fZref[1]));
+ zints[fN] = Int_t(fZ[i]);
+ fN++;
+ }
- UpdateUsed();
- return kTRUE;
-}
+ if (fN < kClmin){
+ //printf("Exit fN < kClmin: fN = %d\n", fN);
+ return;
+ }
+ Int_t nz = AliTRDtrackerV1::Freq(fN, zints, zouts, kFALSE);
+ Float_t fZProb = zouts[0];
+ if (nz <= 1) zouts[3] = 0;
+ if (zouts[1] + zouts[3] < kClmin) {
+ //printf("Exit zouts[1] = %d, zouts[3] = %d\n",zouts[1],zouts[3]);
+ return;
+ }
+
+ // Z distance bigger than pad - length
+ if (TMath::Abs(zouts[0]-zouts[2]) > 12.0) zouts[3] = 0;
+
+ Int_t breaktime = -1;
+ Bool_t mbefore = kFALSE;
+ Int_t cumul[kNtb][2];
+ Int_t counts[2] = { 0, 0 };
+
+ if (zouts[3] >= 3) {
+
+ //
+ // Find the break time allowing one chage on pad-rows
+ // with maximal number of accepted clusters
+ //
+ fNChange = 1;
+ for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins(); i++) {
+ cumul[i][0] = counts[0];
+ cumul[i][1] = counts[1];
+ if (TMath::Abs(fZ[i]-zouts[0]) < 2) counts[0]++;
+ if (TMath::Abs(fZ[i]-zouts[2]) < 2) counts[1]++;
+ }
+ Int_t maxcount = 0;
+ for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins(); i++) {
+ Int_t after = cumul[AliTRDtrackerV1::GetNTimeBins()][0] - cumul[i][0];
+ Int_t before = cumul[i][1];
+ if (after + before > maxcount) {
+ maxcount = after + before;
+ breaktime = i;
+ mbefore = kFALSE;
+ }
+ after = cumul[AliTRDtrackerV1::GetNTimeBins()-1][1] - cumul[i][1];
+ before = cumul[i][0];
+ if (after + before > maxcount) {
+ maxcount = after + before;
+ breaktime = i;
+ mbefore = kTRUE;
+ }
+ }
+ breaktime -= 1;
+ }
+
+ for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins()+1; i++) {
+ if (i > breaktime) allowedz[i] = mbefore ? zouts[2] : zouts[0];
+ if (i <= breaktime) allowedz[i] = (!mbefore) ? zouts[2] : zouts[0];
+ }
+
+ if (((allowedz[0] > allowedz[AliTRDtrackerV1::GetNTimeBins()]) && (fZref[1] < 0)) ||
+ ((allowedz[0] < allowedz[AliTRDtrackerV1::GetNTimeBins()]) && (fZref[1] > 0))) {
+ //
+ // Tracklet z-direction not in correspondance with track z direction
+ //
+ fNChange = 0;
+ for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins()+1; i++) {
+ allowedz[i] = zouts[0]; // Only longest taken
+ }
+ }
+
+ if (fNChange > 0) {
+ //
+ // Cross pad -row tracklet - take the step change into account
+ //
+ for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins()+1; i++) {
+ if (!fClusters[i]) continue;
+ if(!fClusters[i]->IsInChamber()) continue;
+ if (TMath::Abs(fZ[i] - allowedz[i]) > 2) continue;
+ // Residual y
+ //yres[i] = fY[i] - fYref[0] - (fYref[1] + anglecor) * fX[i] + GetTilt()*(fZ[i] - fZref[0]);
+ yres[i] = fY[i] - GetTilt()*(fZ[i] - (fZref[0] - fX[i]*fZref[1]));
+// if (TMath::Abs(fZ[i] - fZProb) > 2) {
+// if (fZ[i] > fZProb) yres[i] += GetTilt() * GetPadLength();
+// if (fZ[i] < fZProb) yres[i] -= GetTilt() * GetPadLength();
+ }
+ }
+ }
+
+ Double_t yres2[kNtb];
+ Double_t mean;
+ Double_t sigma;
+ for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins()+1; i++) {
+ if (!fClusters[i]) continue;
+ if(!fClusters[i]->IsInChamber()) continue;
+ if (TMath::Abs(fZ[i] - allowedz[i]) > 2) continue;
+ yres2[fN2] = yres[i];
+ fN2++;
+ }
+ if (fN2 < kClmin) {
+ //printf("Exit fN2 < kClmin: fN2 = %d\n", fN2);
+ fN2 = 0;
+ return;
+ }
+ AliMathBase::EvaluateUni(fN2,yres2,mean,sigma, Int_t(fN2*kRatio-2.));
+ if (sigma < sigmaexp * 0.8) {
+ sigma = sigmaexp;
+ }
+ //Float_t fSigmaY = sigma;
+
+ // Reset sums
+ sumw = 0;
+ sumwx = 0;
+ sumwx2 = 0;
+ sumwy = 0;
+ sumwxy = 0;
+ sumwz = 0;
+ sumwxz = 0;
+
+ fN2 = 0;
+ Float_t fMeanz = 0;
+ Float_t fMPads = 0;
+ fUsable = 0;
+ for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins()+1; i++) {
+ if (!fClusters[i]) continue;
+ if (!fClusters[i]->IsInChamber()) continue;
+ if (TMath::Abs(fZ[i] - allowedz[i]) > 2){fClusters[i] = 0x0; continue;}
+ if (TMath::Abs(yres[i] - mean) > 4.0 * sigma){fClusters[i] = 0x0; continue;}
+ SETBIT(fUsable,i);
+ fN2++;
+ fMPads += fClusters[i]->GetNPads();
+ Float_t weight = 1.0;
+ if (fClusters[i]->GetNPads() > 4) weight = 0.5;
+ if (fClusters[i]->GetNPads() > 5) weight = 0.2;
+
+
+ Double_t x = fX[i];
+ //printf("x = %7.3f dy = %7.3f fit %7.3f\n", x, yres[i], fY[i]-yres[i]);
+
+ sumw += weight;
+ sumwx += x * weight;
+ sumwx2 += x*x * weight;
+ sumwy += weight * yres[i];
+ sumwxy += weight * (yres[i]) * x;
+ sumwz += weight * fZ[i];
+ sumwxz += weight * fZ[i] * x;
+ }
+
+ if (fN2 < kClmin){
+ //printf("Exit fN2 < kClmin(2): fN2 = %d\n",fN2);
+ fN2 = 0;
+ return;
+ }
+ fMeanz = sumwz / sumw;
+ Float_t correction = 0;
+ if (fNChange > 0) {
+ // Tracklet on boundary
+ if (fMeanz < fZProb) correction = ycrosscor;
+ if (fMeanz > fZProb) correction = -ycrosscor;
+ }
+
+ Double_t det = sumw * sumwx2 - sumwx * sumwx;
+ fYfit[0] = (sumwx2 * sumwy - sumwx * sumwxy) / det;
+ fYfit[1] = (sumw * sumwxy - sumwx * sumwy) / det;
+
+ fS2Y = 0;
+ for (Int_t i = 0; i < AliTRDtrackerV1::GetNTimeBins()+1; i++) {
+ if (!TESTBIT(fUsable,i)) continue;
+ Float_t delta = yres[i] - fYfit[0] - fYfit[1] * fX[i];
+ fS2Y += delta*delta;
+ }
+ fS2Y = TMath::Sqrt(fS2Y / Float_t(fN2-2));
+ // TEMPORARY UNTIL covariance properly calculated
+ fS2Y = TMath::Max(fS2Y, Float_t(.1));
+
+ fZfit[0] = (sumwx2 * sumwz - sumwx * sumwxz) / det;
+ fZfit[1] = (sumw * sumwxz - sumwx * sumwz) / det;
+// fYfitR[0] += fYref[0] + correction;
+// fYfitR[1] += fYref[1];
+// fYfit[0] = fYfitR[0];
+ fYfit[1] = -fYfit[1];
+
+ UpdateUsed();
+}*/
//___________________________________________________________________
void AliTRDseedV1::Print(Option_t *o) const
// Printing the seedstatus
//
- AliInfo(Form("Det[%3d] Tilt[%+6.2f] Pad[%5.2f]", fDet, fTilt, fPadLength));
- AliInfo(Form("Nattach[%2d] Nfit[%2d] Nuse[%2d] pads[%f]", fN, fN2, fNUsed, fMPads));
- AliInfo(Form("x[%7.2f] y[%7.2f] z[%7.2f] dydx[%5.2f] dzdx[%5.2f]", fX0, fYfit[0], fZfit[0], fYfit[1], fZfit[1]));
- AliInfo(Form("Ref y[%7.2f] z[%7.2f] dydx[%5.2f] dzdx[%5.2f]", fYref[0], fZref[0], fYref[1], fZref[1]))
+ AliInfo(Form("Det[%3d] X0[%7.2f] Pad{L[%5.2f] W[%5.2f] Tilt[%+6.2f]}", fDet, fX0, GetPadLength(), GetPadWidth(), GetTilt()));
+ AliInfo(Form("N[%2d] Nused[%2d] Nshared[%2d] [%d]", GetN(), GetNUsed(), GetNShared(), fN));
+ AliInfo(Form("FLAGS : RC[%c] Kink[%c] SA[%c]", IsRowCross()?'y':'n', IsKink()?'y':'n', IsStandAlone()?'y':'n'));
+
+ Double_t cov[3], x=GetX();
+ GetCovAt(x, cov);
+ AliInfo(" | x[cm] | y[cm] | z[cm] | dydx | dzdx |");
+ AliInfo(Form("Fit | %7.2f | %7.2f+-%7.2f | %7.2f+-%7.2f| %5.2f | ----- |", x, GetY(), TMath::Sqrt(cov[0]), GetZ(), TMath::Sqrt(cov[2]), fYfit[1]));
+ AliInfo(Form("Ref | %7.2f | %7.2f+-%7.2f | %7.2f+-%7.2f| %5.2f | %5.2f |", x, fYref[0]-fX*fYref[1], TMath::Sqrt(fRefCov[2]), fZref[0]-fX*fYref[1], TMath::Sqrt(fRefCov[2]), fYref[1], fZref[1]))
if(strcmp(o, "a")!=0) return;
AliTRDcluster* const* jc = &fClusters[0];
- for(int ic=0; ic<AliTRDtrackerV1::GetNTimeBins(); ic++, jc++) {
+ for(int ic=0; ic<kNclusters; ic++, jc++) {
if(!(*jc)) continue;
(*jc)->Print(o);
}
if(!inTracklet) return kFALSE;
for (Int_t i = 0; i < 2; i++){
- if ( fYref[i] != inTracklet->GetYref(i) ) return kFALSE;
- if ( fZref[i] != inTracklet->GetZref(i) ) return kFALSE;
+ if ( fYref[i] != inTracklet->fYref[i] ) return kFALSE;
+ if ( fZref[i] != inTracklet->fZref[i] ) return kFALSE;
}
- if ( fSigmaY != inTracklet->GetSigmaY() ) return kFALSE;
- if ( fSigmaY2 != inTracklet->GetSigmaY2() ) return kFALSE;
- if ( fTilt != inTracklet->GetTilt() ) return kFALSE;
- if ( fPadLength != inTracklet->GetPadLength() ) return kFALSE;
+ if ( fS2Y != inTracklet->fS2Y ) return kFALSE;
+ if ( GetTilt() != inTracklet->GetTilt() ) return kFALSE;
+ if ( GetPadLength() != inTracklet->GetPadLength() ) return kFALSE;
- for (Int_t i = 0; i < knTimebins; i++){
- if ( fX[i] != inTracklet->GetX(i) ) return kFALSE;
- if ( fY[i] != inTracklet->GetY(i) ) return kFALSE;
- if ( fZ[i] != inTracklet->GetZ(i) ) return kFALSE;
- if ( fIndexes[i] != inTracklet->GetIndexes(i) ) return kFALSE;
- if ( fUsable[i] != inTracklet->IsUsable(i) ) return kFALSE;
+ for (Int_t i = 0; i < kNclusters; i++){
+// if ( fX[i] != inTracklet->GetX(i) ) return kFALSE;
+// if ( fY[i] != inTracklet->GetY(i) ) return kFALSE;
+// if ( fZ[i] != inTracklet->GetZ(i) ) return kFALSE;
+ if ( fIndexes[i] != inTracklet->fIndexes[i] ) return kFALSE;
}
+// if ( fUsable != inTracklet->fUsable ) return kFALSE;
for (Int_t i=0; i < 2; i++){
- if ( fYfit[i] != inTracklet->GetYfit(i) ) return kFALSE;
- if ( fZfit[i] != inTracklet->GetZfit(i) ) return kFALSE;
- if ( fYfitR[i] != inTracklet->GetYfitR(i) ) return kFALSE;
- if ( fZfitR[i] != inTracklet->GetZfitR(i) ) return kFALSE;
- if ( fLabels[i] != inTracklet->GetLabels(i) ) return kFALSE;
+ if ( fYfit[i] != inTracklet->fYfit[i] ) return kFALSE;
+ if ( fZfit[i] != inTracklet->fZfit[i] ) return kFALSE;
+ if ( fLabels[i] != inTracklet->fLabels[i] ) return kFALSE;
}
- if ( fMeanz != inTracklet->GetMeanz() ) return kFALSE;
- if ( fZProb != inTracklet->GetZProb() ) return kFALSE;
- if ( fN2 != inTracklet->GetN2() ) return kFALSE;
- if ( fNUsed != inTracklet->GetNUsed() ) return kFALSE;
- if ( fFreq != inTracklet->GetFreq() ) return kFALSE;
- if ( fNChange != inTracklet->GetNChange() ) return kFALSE;
- if ( fNChange != inTracklet->GetNChange() ) return kFALSE;
+/* if ( fMeanz != inTracklet->GetMeanz() ) return kFALSE;
+ if ( fZProb != inTracklet->GetZProb() ) return kFALSE;*/
+ if ( fN != inTracklet->fN ) return kFALSE;
+ //if ( fNUsed != inTracklet->fNUsed ) return kFALSE;
+ //if ( fFreq != inTracklet->GetFreq() ) return kFALSE;
+ //if ( fNChange != inTracklet->GetNChange() ) return kFALSE;
- if ( fC != inTracklet->GetC() ) return kFALSE;
- if ( fCC != inTracklet->GetCC() ) return kFALSE;
- if ( fChi2 != inTracklet->GetChi2() ) return kFALSE;
+ if ( fC != inTracklet->fC ) return kFALSE;
+ //if ( fCC != inTracklet->GetCC() ) return kFALSE;
+ if ( fChi2 != inTracklet->fChi2 ) return kFALSE;
// if ( fChi2Z != inTracklet->GetChi2Z() ) return kFALSE;
- if ( fDet != inTracklet->GetDetector() ) return kFALSE;
- if ( fMom != inTracklet->GetMomentum() ) return kFALSE;
- if ( fdX != inTracklet->GetdX() ) return kFALSE;
+ if ( fDet != inTracklet->fDet ) return kFALSE;
+ if ( fPt != inTracklet->fPt ) return kFALSE;
+ if ( fdX != inTracklet->fdX ) return kFALSE;
- for (Int_t iCluster = 0; iCluster < knTimebins; iCluster++){
+ for (Int_t iCluster = 0; iCluster < kNclusters; iCluster++){
AliTRDcluster *curCluster = fClusters[iCluster];
- AliTRDcluster *inCluster = inTracklet->GetClusters(iCluster);
+ AliTRDcluster *inCluster = inTracklet->fClusters[iCluster];
if (curCluster && inCluster){
if (! curCluster->IsEqual(inCluster) ) {
curCluster->Print();