//____________________________________________________________________
AliTRDseedV1::AliTRDseedV1(Int_t det)
- :AliTRDseed()
+ :TObject()
,fReconstructor(0x0)
,fClusterIter(0x0)
+ ,fExB(0.)
+ ,fVD(0.)
+ ,fT0(0.)
+ ,fS2PRF(0.)
+ ,fDiffL(0.)
+ ,fDiffT(0.)
,fClusterIdx(0)
+ ,fUsable(0)
+ ,fN2(0)
+ ,fNUsed(0)
,fDet(det)
+ ,fTilt(0.)
+ ,fPadLength(0.)
,fMom(0.)
- ,fSnp(0.)
- ,fTgl(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=kNTimeBins; ic--;) fIndexes[ic] = -1;
+ memset(fClusters, 0, kNTimeBins*sizeof(AliTRDcluster*));
+ 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
fRefCov[0] = 1.; fRefCov[1] = 0.; fRefCov[2] = 1.;
// covariance matrix [diagonal]
// default sy = 200um and sz = 2.3 cm
//____________________________________________________________________
AliTRDseedV1::AliTRDseedV1(const AliTRDseedV1 &ref)
- :AliTRDseed((AliTRDseed&)ref)
- ,fReconstructor(ref.fReconstructor)
+ :TObject((TObject&)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)
+ ,fUsable(0)
+ ,fN2(0)
+ ,fNUsed(0)
+ ,fDet(-1)
+ ,fTilt(0.)
+ ,fPadLength(0.)
+ ,fMom(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));
}
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<kNTimeBins; 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.fUsable = fUsable;
+ target.fN2 = fN2;
+ target.fNUsed = fNUsed;
target.fDet = fDet;
+ target.fTilt = fTilt;
+ target.fPadLength = fPadLength;
target.fMom = fMom;
- target.fSnp = fSnp;
- target.fTgl = fTgl;
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, kNTimeBins*sizeof(Int_t));
+ memcpy(target.fClusters, fClusters, kNTimeBins*sizeof(AliTRDcluster*));
+ 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;fUsable=0;
+ fN2=0;fNUsed=0;
+ fDet=-1;fTilt=0.;fPadLength=0.;
+ fMom=0.;
+ fdX=0.;fX0=0.; fX=0.; fY=0.; fZ=0.;
+ fS2Y=0.; fS2Z=0.;
+ fC=0.; fChi2 = 0.;
+
+ for(Int_t ic=kNTimeBins; ic--;) fIndexes[ic] = -1;
+ memset(fClusters, 0, kNTimeBins*sizeof(AliTRDcluster*));
+ 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
+ fRefCov[0] = 1.; fRefCov[1] = 0.; fRefCov[2] = 1.;
+ // 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();
+ Double_t fSnp = trk->GetSnp();
+ Double_t fTgl = trk->GetTgl();
fMom = trk->GetP();
fYref[1] = fSnp/(1. - fSnp*fSnp);
fZref[1] = fTgl;
fZref[0] = trk->GetZ() - dx*fZref[1];
}
+//_____________________________________________________________________________
+void AliTRDseedV1::UpdateUsed()
+{
+ //
+ // Update used seed
+ //
+
+ fNUsed = 0;
+ for (Int_t i = kNTimeBins; i--; ) {
+ if (!fClusters[i]) continue;
+ if(!TESTBIT(fUsable, i)) continue;
+ if((fClusters[i]->IsUsed())) fNUsed++;
+ }
+}
+
+//_____________________________________________________________________________
+void AliTRDseedV1::UseClusters()
+{
+ //
+ // Use clusters
+ //
+ AliTRDcluster **c = &fClusters[0];
+ for (Int_t ic=kNTimeBins; ic--; c++) {
+ if(!(*c)) continue;
+ if(!((*c)->IsUsed())) (*c)->Use();
+ }
+}
+
+
//____________________________________________________________________
void AliTRDseedV1::CookdEdx(Int_t nslices)
{
// 3. cluster size
//
- Int_t nclusters[knSlices];
- for(int i=0; i<knSlices; i++){
- fdEdx[i] = 0.;
- nclusters[i] = 0;
- }
+ Int_t nclusters[kNSlices];
+ memset(nclusters, 0, kNSlices*sizeof(Int_t));
+ memset(fdEdx, 0, kNSlices*sizeof(Float_t));
+
const Double_t kDriftLength = (.5 * AliTRDgeometry::AmThick() + AliTRDgeometry::DrThick());
AliTRDcluster *c = 0x0;
}
}
+//_____________________________________________________________________________
+void AliTRDseedV1::CookLabels()
+{
+ //
+ // Cook 2 labels for seed
+ //
+
+ Int_t labels[200];
+ Int_t out[200];
+ Int_t nlab = 0;
+ for (Int_t i = 0; i < kNTimeBins; 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++;
+ }
+ }
+ }
+
+ fLabels[2] = AliTRDtrackerV1::Freq(nlab,labels,out,kTRUE);
+ fLabels[0] = out[0];
+ if ((fLabels[2] > 1) && (out[3] > 1)) fLabels[1] = out[2];
+}
+
+
//____________________________________________________________________
void AliTRDseedV1::GetClusterXY(const AliTRDcluster *c, Double_t &x, Double_t &y)
{
}
//____________________________________________________________________
-Double_t* AliTRDseedV1::GetProbability()
+Float_t* AliTRDseedV1::GetProbability()
{
// Fill probability array for tracklet from the DB.
//
// Returns a quality measurement of the current seed
//
- Float_t zcorr = kZcorr ? fTilt * (fZProb - fZref[0]) : 0.;
+ Float_t zcorr = kZcorr ? fTilt * (fZfit[0] - fZref[0]) : 0.;
return
.5 * TMath::Abs(18.0 - fN2)
+ 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]) / fPadLength;
}
//____________________________________________________________________
//____________________________________________________________________
-void AliTRDseedV1::SetExB()
+void AliTRDseedV1::Calibrate()
{
-// Retrive the tg(a_L) from OCDB. The following information are used
+// 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(fN2){
Int_t ic = 0;
- while (ic<AliTRDseed::knTimebins && !(*c)){ic++; c++;}
+ while (ic<kNTimeBins && !(*c)){ic++; c++;}
if(*c){
col = (*c)->GetPadCol();
row = (*c)->GetPadRow();
}
}
- Double_t vd = fCalVdriftDet->GetValue(fDet) * fCalVdriftROC->GetValue(col, row);
- fExB = AliTRDCommonParam::Instance()->GetOmegaTau(vd);
+ 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<kNTimeBins; ic++){
if(!fClusters[ic]) continue;
fClusters[ic] = new AliTRDcluster(*fClusters[ic]);
}
Double_t kroadz = fPadLength * .5 + 1.;
// initialize configuration parameters
- Float_t zcorr = kZcorr ? fTilt * (fZProb - fZref[0]) : 0.;
+ Float_t zcorr = kZcorr ? fTilt * (fZfit[0] - fZref[0]) : 0.;
Int_t niter = kZcorr ? 1 : 2;
Double_t yexp, zexp;
fIndexes[iTime] = layer->GetGlobalIndex(index);
fClusters[iTime] = cl;
- fY[iTime] = cl->GetY();
- fZ[iTime] = cl->GetZ();
+// 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];
+ Int_t irp = 0; Float_t x[2]={0., 0.}; Int_t tb[2] = {0,0};
for (Int_t iTime = 0; iTime < AliTRDtrackerV1::GetNTimeBins(); iTime++) {
if(!fClusters[iTime]) continue;
x[irp] = fClusters[iTime]->GetX();
irp++;
if(irp==2) break;
}
- fdX = (x[1] - x[0]) / (tb[0] - tb[1]);
-
+ Int_t dtb = tb[1] - tb[0];
+ fdX = dtb ? (x[0] - x[1]) / dtb : 0.15;
+
// update X0 from the clusters (calibration/alignment aware)
for (Int_t iTime = 0; iTime < AliTRDtrackerV1::GetNTimeBins(); iTime++) {
if(!(layer = chamber->GetTB(iTime))) continue;
// 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();
- }
+// for (Int_t iTime = 0; iTime < AliTRDtrackerV1::GetNTimeBins(); iTime++) {
+// if(!fClusters[iTime]) continue;
+// fX[iTime] = fX0 - fClusters[iTime]->GetX();
+// }
- AliTRDseed::Update();
+ FitMI();
}
if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker)>=7) AliInfo(Form("iter = %d nclFit [%d] = %d", iter, fDet, fN2));
if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker)>=1) CookLabels();
- // set ExB angle
- SetExB();
+ // load calibration params
+ Calibrate();
UpdateUsed();
return kTRUE;
}
// working variables
const Int_t kNrows = 16;
- AliTRDcluster *clst[kNrows][knTimebins];
+ AliTRDcluster *clst[kNrows][kNTimeBins];
Double_t cond[4], dx, dy, yt, zt,
- yres[kNrows][knTimebins];
- Int_t idxs[kNrows][knTimebins], ncl[kNrows], ncls = 0;
+ yres[kNrows][kNTimeBins];
+ Int_t idxs[kNrows][kNTimeBins], ncl[kNrows], ncls = 0;
memset(ncl, 0, kNrows*sizeof(Int_t));
- memset(clst, 0, kNrows*knTimebins*sizeof(AliTRDcluster*));
+ memset(clst, 0, kNrows*kNTimeBins*sizeof(AliTRDcluster*));
// Do cluster projection
AliTRDcluster *c = 0x0;
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] >= kNTimeBins) {
+ AliWarning(Form("Cluster candidates reached limit %d. Some may be lost.", kNTimeBins));
kBUFFER = kTRUE;
break;
}
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]);
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(fClusters[it+kNtb] && fClusters[it+kNtb]->IsUsed()) fNUsed++;
}
if (fN2-fNUsed < kClmin){
//AliWarning(Form("Too many clusters already in use %d (from %d).", fNUsed, fN2));
return kFALSE;
}
- // 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]={0., 0.}; Int_t tb[2] = {0, 0};
+ 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;
- }
+ }
Int_t dtb = tb[1] - tb[0];
fdX = dtb ? (x[0] - x[1]) / dtb : 0.15;
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.;
+ //fSnp = fYref[1]/TMath::Sqrt(1+fYref[1]*fYref[1]);
+ //fTgl = fZref[1];
+ fN2 = 0;// fMPads = 0.;
AliTRDcluster **cit = &fClusters[0];
- for(Int_t ic = knTimebins; ic--; cit++){
+ for(Int_t ic = kNTimeBins; ic--; cit++){
if(!(*cit)) return;
- fN++; fN2++;
- fX[ic] = (*cit)->GetX() - fX0;
+ fN2++;
+/* fX[ic] = (*cit)->GetX() - fX0;
fY[ic] = (*cit)->GetY();
- fZ[ic] = (*cit)->GetZ();
+ fZ[ic] = (*cit)->GetZ();*/
}
- Update(); // Fit();
+ //Update(); //
+ Fit();
CookLabels();
GetProbability();
}
// 3. Do a Least Square Fit to the data
//
+ if(!IsCalibrated()){
+ AliWarning("Tracklet fit failed. Call Calibrate().");
+ return kFALSE;
+ }
+
const Int_t kClmin = 8;
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.);
// book cluster information
- Double_t q, xc[knTimebins], yc[knTimebins], zc[knTimebins], sy[knTimebins]/*, sz[knTimebins]*/;
-// Int_t zRow[knTimebins];
-
+ Double_t qc[kNTimeBins], xc[kNTimeBins], yc[kNTimeBins], zc[kNTimeBins], sy[kNTimeBins];
+
Int_t ily = AliTRDgeometry::GetLayer(fDet);
- fN = 0; //fXref = 0.; Double_t ssx = 0.;
+ Int_t fN = 0;
AliTRDcluster *c=0x0, **jc = &fClusters[0];
for (Int_t ic=0; ic<kNtb; ic++, ++jc) {
//zRow[ic] = -1;
if(c->GetNPads()>5) w = .2;
//zRow[fN] = c->GetPadRow();
+ qc[fN] = TMath::Abs(c->GetQ());
// correct cluster position for PRF and v drift
+ //Int_t jc = TMath::Max(fN-3, 0);
+ //xc[fN] = c->GetXloc(fT0, fVD, &qc[jc], &xc[jc]/*, z0 - c->GetX()*dzdx*/);
+ //Double_t s2 = fS2PRF + fDiffL*fDiffL*xc[fN]/(1.+2.*exb2)+tgg*xc[fN]*xc[fN]*exb2/12.;
+ //yc[fN] = c->GetYloc(s2, fPadLength, xc[fN], fExB);
+
+ // uncalibrated cluster correction
+ // TODO remove
Double_t x, y; GetClusterXY(c, x, y);
xc[fN] = fX0 - x;
yc[fN] = y;
// 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));
//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[fN] += sqb*(1./qc[fN] - 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];
// 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;
c->SetSigmaY2(sy[fN]);
sy[fN] = TMath::Sqrt(sy[fN]);
- fitterY.AddPoint(&xc[fN], yc[fN]/*-yt*/, sy[fN]);
+ fitterY.AddPoint(&xc[fN], yc[fN], sy[fN]);
fN++;
}
// to few clusters
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]; //fXref = fX0 - fXref;
// fit XZ
if(IsRowCross()){
}
+
+
+
+
+//_____________________________________________________________________________
+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 = fPadLength * fTilt * 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 = fTilt * 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] + fTilt*(fZ[i] - fZref[0]);
+ fX[i] = fX0 - c->GetX();
+ fY[i] = c->GetY();
+ fZ[i] = c->GetZ();
+ yres[i] = fY[i] - fTilt*(fZ[i] - (fZref[0] - fX[i]*fZref[1]));
+ zints[fN] = Int_t(fZ[i]);
+ fN++;
+ }
+
+ 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] /*+ fTilt*(fZ[i] - fZref[0])*/;
+ yres[i] = fY[i] - fTilt*(fZ[i] - (fZref[0] - fX[i]*fZref[1]));
+/* if (TMath::Abs(fZ[i] - fZProb) > 2) {
+ if (fZ[i] > fZProb) yres[i] += fTilt * fPadLength;
+ if (fZ[i] < fZProb) yres[i] -= fTilt * fPadLength;
+ }*/
+ }
+ }
+
+ 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
{
//
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("N[%2d] Nuse[%2d]", fN2, fNUsed));
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]))
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<kNTimeBins; 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 ( fTilt != inTracklet->fTilt ) return kFALSE;
+ if ( fPadLength != inTracklet->fPadLength ) 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 < 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->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 ( fN2 != inTracklet->fN2 ) 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 ( fMom != inTracklet->fMom ) return kFALSE;
+ if ( fdX != inTracklet->fdX ) return kFALSE;
- for (Int_t iCluster = 0; iCluster < knTimebins; iCluster++){
+ for (Int_t iCluster = 0; iCluster < kNTimeBins; iCluster++){
AliTRDcluster *curCluster = fClusters[iCluster];
- AliTRDcluster *inCluster = inTracklet->GetClusters(iCluster);
+ AliTRDcluster *inCluster = inTracklet->fClusters[iCluster];
if (curCluster && inCluster){
if (! curCluster->IsEqual(inCluster) ) {
curCluster->Print();