1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ////////////////////////////////////////////////////////////////////////////
20 // The TRD track seed //
23 // Alex Bercuci <A.Bercuci@gsi.de> //
24 // Markus Fasel <M.Fasel@gsi.de> //
26 ////////////////////////////////////////////////////////////////////////////
29 #include "TLinearFitter.h"
32 #include "AliMathBase.h"
34 #include "AliTRDseedV1.h"
35 #include "AliTRDcluster.h"
36 #include "AliTRDtrack.h"
37 #include "AliTRDcalibDB.h"
38 #include "AliTRDstackLayer.h"
39 #include "AliTRDrecoParam.h"
40 #include "AliTRDgeometry.h"
41 #include "Cal/AliTRDCalPID.h"
45 ClassImp(AliTRDseedV1)
47 //____________________________________________________________________
48 AliTRDseedV1::AliTRDseedV1(Int_t layer, AliTRDrecoParam *p)
58 for(int islice=0; islice < knSlices; islice++) fdEdx[islice] = 0.;
59 for(int itb=0; itb < knTimebins; itb++){
63 for(int ispec=0; ispec<AliPID::kSPECIES; ispec++) fProb[ispec] = -1.;
66 //____________________________________________________________________
67 AliTRDseedV1::AliTRDseedV1(const AliTRDseedV1 &ref)
68 :AliTRDseed((AliTRDseed&)ref)
72 ,fRecoParam(ref.fRecoParam)
75 // Copy Constructor performing a deep copy
79 if(ref.fOwner) SetOwner();
80 for(int islice=0; islice < knSlices; islice++) fdEdx[islice] = ref.fdEdx[islice];
81 for(int itb=0; itb < knTimebins; itb++){
82 fdQdl[itb] = ref.fdQdl[itb];
83 fdQ[itb] = ref.fdQ[itb];
85 for(int ispec=0; ispec<AliPID::kSPECIES; ispec++) fProb[ispec] = ref.fProb[ispec];
89 //____________________________________________________________________
90 AliTRDseedV1& AliTRDseedV1::operator=(const AliTRDseedV1 &ref)
93 // Assignment Operator using the copy function
104 //____________________________________________________________________
105 AliTRDseedV1::~AliTRDseedV1()
108 // Destructor. The RecoParam object belongs to the underlying tracker.
111 //AliInfo(Form("fOwner[%s]", fOwner?"YES":"NO"));
114 for(int itb=0; itb<knTimebins; itb++){
115 if(!fClusters[itb]) continue;
116 //AliInfo(Form("deleting c %p @ %d", fClusters[itb], itb));
117 delete fClusters[itb];
118 fClusters[itb] = 0x0;
122 //____________________________________________________________________
123 void AliTRDseedV1::Copy(TObject &ref) const
130 AliTRDseedV1 &target = (AliTRDseedV1 &)ref;
132 target.fPlane = fPlane;
134 target.fRecoParam = fRecoParam;
136 for(int islice=0; islice < knSlices; islice++) target.fdEdx[islice] = fdEdx[islice];
137 for(int itb=0; itb < knTimebins; itb++){
138 target.fdQdl[itb] = fdQdl[itb];
139 target.fdQ[itb] = fdQ[itb];
141 for(int ispec=0; ispec<AliPID::kSPECIES; ispec++) target.fProb[ispec] = fProb[ispec];
143 AliTRDseed::Copy(target);
147 //____________________________________________________________
148 void AliTRDseedV1::Init(AliTRDtrack *track)
150 // Initialize this tracklet using the track information
153 // track - the TRD track used to initialize the tracklet
155 // Detailed description
156 // The function sets the starting point and direction of the
157 // tracklet according to the information from the TRD track.
160 // The TRD track has to be propagated to the beginning of the
161 // chamber where the tracklet will be constructed
165 track->GetProlongation(fX0, y, z);
167 fYref[1] = track->GetSnp()/(1. - track->GetSnp()*track->GetSnp());
169 fZref[1] = track->GetTgl();
171 //printf("Tracklet ref x[%7.3f] y[%7.3f] z[%7.3f], snp[%f] tgl[%f]\n", fX0, fYref[0], fZref[0], track->GetSnp(), track->GetTgl());
174 //____________________________________________________________________
175 Double_t* AliTRDseedV1::GetProbability()
177 // Fill probability array for tracklet from the DB.
182 // returns pointer to the probability array and 0x0 if missing DB access
184 // Detailed description
187 // retrive calibration db
188 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
190 AliError("No access to calibration data");
194 // Retrieve the CDB container class with the parametric detector response
195 const AliTRDCalPID *pd = calibration->GetPIDObject(fRecoParam->GetPIDMethod());
197 AliError("No access to AliTRDCalPID object");
201 // calculate tracklet length TO DO
202 Float_t length = (AliTRDgeometry::AmThick() + AliTRDgeometry::DrThick());
203 /// TMath::Sqrt((1.0 - fSnp[iPlane]*fSnp[iPlane]) / (1.0 + fTgl[iPlane]*fTgl[iPlane]));
206 CookdEdx(fRecoParam->GetNdEdxSlices());
208 // Sets the a priori probabilities
209 for(int ispec=0; ispec<AliPID::kSPECIES; ispec++) {
210 fProb[ispec] = pd->GetProbability(ispec, fMom, &fdEdx[0], length, fPlane);
216 //____________________________________________________________________
217 void AliTRDseedV1::CookdEdx(Int_t nslices)
219 // Calculates average dE/dx for all slices and store them in the internal array fdEdx.
222 // nslices : number of slices for which dE/dx should be calculated
225 // Detailed description
226 // Calculates average dE/dx for all slices. Depending on the PID methode
227 // the number of slices can be 3 (LQ) or 8(NN). The calculation is based
228 // on previously calculated quantities dQ/dl of each cluster. The
229 // following effects are included in the calculation:
230 // 1. calibration values for t0 and vdrift
231 // 2. cluster sharing (optional see AliTRDrecoParam::SetClusterSharing())
234 Int_t nclusters[knSlices];
235 for(int i=0; i<knSlices; i++){
240 AliTRDcluster *cluster = 0x0;
241 for(int ic=0; ic<fgTimeBins; ic++){
242 if(!(cluster = fClusters[ic])) continue;
243 Int_t tb = cluster->GetLocalTimeBin();
245 // consider calibration effects
246 if(tb < fTimeBin0 || tb >= fTimeBin0+fTimeBinsRange) continue;
248 // consider cluster sharing ... TO DO
249 //if(fRecoParam->GetClusterSharing() && cluster->GetSharing()) continue;
251 Int_t slice = (tb-fTimeBin0)*nslices/fTimeBinsRange;
252 fdEdx[slice] += fdQdl[ic];
254 } // End of loop over clusters
256 // calculate mean charge per slice
257 for(int is=0; is<nslices; is++) if(nclusters[is]) fdEdx[is] /= nclusters[is];
260 //____________________________________________________________________
261 Float_t AliTRDseedV1::GetQuality(Bool_t kZcorr) const
264 // Returns a quality measurement of the current seed
267 Float_t zcorr = kZcorr ? fTilt * (fZProb - fZref[0]) : 0.;
268 return .5 * (18.0 - fN2)
269 + 10.* TMath::Abs(fYfit[1] - fYref[1])
270 + 5.* TMath::Abs(fYfit[0] - fYref[0] + zcorr)
271 + 2. * TMath::Abs(fMeanz - fZref[0]) / fPadLength;
274 //____________________________________________________________________
275 void AliTRDseedV1::GetCovAt(Double_t /*x*/, Double_t *cov) const
277 // Computes covariance in the y-z plane at radial point x
279 const Float_t k0= .2; // to be checked in FindClusters
280 Double_t sy20 = k0*TMath::Tan(fYfit[1]); sy20 *= sy20;
282 Double_t sy2 = fSigmaY2*fSigmaY2 + sy20;
283 Double_t sz2 = fPadLength/12.;
285 //printf("Yfit[1] %f sy20 %f SigmaY2 %f\n", fYfit[1], sy20, fSigmaY2);
288 cov[1] = fTilt*(sy2-sz2);
292 //____________________________________________________________________
293 void AliTRDseedV1::SetdQdl(Double_t length)
295 for(int ic=0; ic<fgTimeBins; ic++) fdQdl[ic] = fdQ[ic] *length;
298 //____________________________________________________________________
299 void AliTRDseedV1::SetOwner(Bool_t own)
301 //AliInfo(Form("own [%s] fOwner[%s]", own?"YES":"NO", fOwner?"YES":"NO"));
304 for(int ic=0; ic<knTimebins; ic++){
305 if(!fClusters[ic]) continue;
306 fClusters[ic] = new AliTRDcluster(*fClusters[ic]);
311 for(int ic=0; ic<knTimebins; ic++){
312 if(!fClusters[ic]) continue;
313 delete fClusters[ic];
314 //fClusters[ic] = tracker->GetClusters(index) TODO
321 //____________________________________________________________________
322 Bool_t AliTRDseedV1::AttachClustersIter(AliTRDstackLayer *layer
328 // Iterative process to register clusters to the seed.
329 // In iteration 0 we try only one pad-row and if quality not
330 // sufficient we try 2 pad-rows (about 5% of tracks cross 2 pad-rows)
334 AliError("Seed can not be used without a valid RecoParam.");
338 //AliInfo(Form("TimeBins = %d TimeBinsRange = %d", fgTimeBins, fTimeBinsRange));
341 Double_t kroady = fRecoParam->GetRoad1y();
342 Double_t kroadz = fPadLength * .5 + 1.;
344 // initialize configuration parameters
345 Float_t zcorr = kZcorr ? fTilt * (fZProb - fZref[0]) : 0.;
346 Int_t niter = kZcorr ? 1 : 2;
351 for (Int_t iter = 0; iter < niter; iter++) {
352 //AliInfo(Form("iter = %i", iter));
354 for (Int_t iTime = 0; iTime < fgTimeBins; iTime++) {
355 // define searching configuration
356 Double_t dxlayer = layer[iTime].GetX() - fX0;
359 //Try 2 pad-rows in second iteration
361 zexp = fZref[0] + fZref[1] * dxlayer - zcorr;
362 if (zexp > c->GetZ()) zexp = c->GetZ() + fPadLength*0.5;
363 if (zexp < c->GetZ()) zexp = c->GetZ() - fPadLength*0.5;
365 } else zexp = fZref[0];
366 yexp = fYref[0] + fYref[1] * dxlayer - zcorr;
368 // printf("xexp = %3.3f ,yexp = %3.3f, zexp = %3.3f\n",layer[iTime].GetX(),yexp,zexp);
369 // printf("layer[%i].GetNClusters() = %i\n", iTime, layer[iTime].GetNClusters());
370 Int_t index = layer[iTime].SearchNearestCluster(yexp, zexp, kroady, kroadz);
372 // printf("%d[%d] x[%7.3f | %7.3f] y[%7.3f] z[%7.3f]\n", iTime, layer[iTime].GetNClusters(), dxlayer, layer[iTime].GetX(), yexp, zexp);
373 // for(Int_t iclk = 0; iclk < layer[iTime].GetNClusters(); iclk++){
374 // AliTRDcluster *testcl = layer[iTime].GetCluster(iclk);
375 // printf("Cluster %i: %d x = %7.3f, y = %7.3f, z = %7.3f\n", iclk, testcl->GetLocalTimeBin(), testcl->GetX(), testcl->GetY(), testcl->GetZ());
377 // printf("Index = %i\n",index);
379 if (index < 0) continue;
382 AliTRDcluster *cl = (AliTRDcluster*) layer[iTime].GetCluster(index);
384 //printf("Cluster %i(0x%x): x = %3.3f, y = %3.3f, z = %3.3f\n", index, cl, cl->GetX(), cl->GetY(), cl->GetZ());
386 Int_t globalIndex = layer[iTime].GetGlobalIndex(index);
387 fIndexes[iTime] = globalIndex;
388 fClusters[iTime] = cl;
390 fY[iTime] = cl->GetY();
391 fZ[iTime] = cl->GetZ();
392 fdQ[iTime] = cl->GetQ()/layer[iTime].GetdX();
399 // Int_t nclusters = 0;
400 // Float_t fD[iter] = 0.;
401 // for(int ic=0; ic<fgTimeBins+1; ic++){
402 // AliTRDcluster *ci = fClusters[ic];
404 // for(int jc=ic+1; jc<fgTimeBins+1; jc++){
405 // AliTRDcluster *cj = fClusters[jc];
407 // fD[iter] += TMath::Sqrt((ci->GetY()-cj->GetY())*(ci->GetY()-cj->GetY())+
408 // (ci->GetZ()-cj->GetZ())*(ci->GetZ()-cj->GetZ()));
412 // if(nclusters) fD[iter] /= float(nclusters);
415 AliTRDseed::Update();
418 tquality = GetQuality(kZcorr);
419 if(tquality < quality) break;
420 else quality = tquality;
424 if (!IsOK()) return kFALSE;
431 //____________________________________________________________________
432 Bool_t AliTRDseedV1::AttachClusters(AliTRDstackLayer *layer
436 // Projective algorithm to attach clusters to seeding tracklets
442 // Detailed description
443 // 1. Collapse x coordinate for the full detector plane
444 // 2. truncated mean on y (r-phi) direction
446 // 4. truncated mean on z direction
452 AliError("Seed can not be used without a valid RecoParam.");
456 const Int_t kClusterCandidates = 2 * knTimebins;
459 Double_t kroady = fRecoParam->GetRoad1y();
460 Double_t kroadz = fPadLength * 1.5 + 1.;
461 // correction to y for the tilting angle
462 Float_t zcorr = kZcorr ? fTilt * (fZProb - fZref[0]) : 0.;
465 AliTRDcluster *clusters[kClusterCandidates];
466 Double_t cond[4], yexp[knTimebins], zexp[knTimebins],
467 yres[kClusterCandidates], zres[kClusterCandidates];
468 Int_t ncl, *index = 0x0, tboundary[knTimebins];
470 // Do cluster projection
471 Int_t nYclusters = 0; Bool_t kEXIT = kFALSE;
472 for (Int_t iTime = 0; iTime < fgTimeBins; iTime++) {
473 fX[iTime] = layer[iTime].GetX() - fX0;
474 zexp[iTime] = fZref[0] + fZref[1] * fX[iTime];
475 yexp[iTime] = fYref[0] + fYref[1] * fX[iTime] - zcorr;
477 // build condition and process clusters
478 cond[0] = yexp[iTime] - kroady; cond[1] = yexp[iTime] + kroady;
479 cond[2] = zexp[iTime] - kroadz; cond[3] = zexp[iTime] + kroadz;
480 layer[iTime].GetClusters(cond, index, ncl);
481 for(Int_t ic = 0; ic<ncl; ic++){
482 AliTRDcluster *c = layer[iTime].GetCluster(index[ic]);
483 clusters[nYclusters] = c;
484 yres[nYclusters++] = c->GetY() - yexp[iTime];
485 if(nYclusters >= kClusterCandidates) {
486 AliWarning(Form("Cluster candidates reached limit %d. Some may be lost.", kClusterCandidates));
491 tboundary[iTime] = nYclusters;
495 // Evaluate truncated mean on the y direction
496 Double_t mean, sigma;
497 AliMathBase::EvaluateUni(nYclusters, yres, mean, sigma, Int_t(nYclusters*.8)-2);
498 //purge cluster candidates
499 Int_t nZclusters = 0;
500 for(Int_t ic = 0; ic<nYclusters; ic++){
501 if(yres[ic] - mean > 4. * sigma){
505 zres[nZclusters++] = clusters[ic]->GetZ() - zexp[clusters[ic]->GetLocalTimeBin()];
508 // Evaluate truncated mean on the z direction
509 AliMathBase::EvaluateUni(nZclusters, zres, mean, sigma, Int_t(nZclusters*.8)-2);
510 //purge cluster candidates
511 for(Int_t ic = 0; ic<nZclusters; ic++){
512 if(zres[ic] - mean > 4. * sigma){
519 // Select only one cluster/TimeBin
520 Int_t lastCluster = 0;
522 for (Int_t iTime = 0; iTime < fgTimeBins; iTime++) {
523 ncl = tboundary[iTime] - lastCluster;
525 AliTRDcluster *c = 0x0;
527 c = clusters[lastCluster];
529 Float_t dold = 9999.; Int_t iptr = lastCluster;
530 for(int ic=lastCluster; ic<tboundary[iTime]; ic++){
531 if(!clusters[ic]) continue;
532 Float_t y = yexp[iTime] - clusters[ic]->GetY();
533 Float_t z = zexp[iTime] - clusters[ic]->GetZ();
534 Float_t d = y * y + z * z;
535 if(d > dold) continue;
541 //Int_t GlobalIndex = layer[iTime].GetGlobalIndex(index);
542 //fIndexes[iTime] = GlobalIndex;
543 fClusters[iTime] = c;
544 fY[iTime] = c->GetY();
545 fZ[iTime] = c->GetZ();
546 fdQ[iTime] = c->GetQ()/layer[iTime].GetdX();
547 lastCluster = tboundary[iTime];
551 // number of minimum numbers of clusters expected for the tracklet
552 Int_t kClmin = Int_t(fRecoParam->GetFindableClusters()*fgTimeBins);
554 AliWarning(Form("Not enough clusters to fit the tracklet %d [%d].", fN2, kClmin));
559 // update used clusters
561 for (Int_t iTime = 0; iTime < fgTimeBins; iTime++) {
562 if(!fClusters[iTime]) continue;
563 if((fClusters[iTime]->IsUsed())) fNUsed++;
566 if (fN2-fNUsed < kClmin){
567 AliWarning(Form("Too many clusters already in use %d (from %d).", fNUsed, fN2));
575 //____________________________________________________________________
576 Bool_t AliTRDseedV1::Fit()
579 // Linear fit of the tracklet
584 // True if successful
586 // Detailed description
587 // 2. Check if tracklet crosses pad row boundary
588 // 1. Calculate residuals in the y (r-phi) direction
589 // 3. Do a Least Square Fit to the data
592 //Float_t sigmaexp = 0.05 + TMath::Abs(fYref[1] * 0.25); // Expected r.m.s in y direction
593 Float_t ycrosscor = fPadLength * fTilt * 0.5; // Y correction for crossing
594 Float_t anglecor = fTilt * fZref[1]; // Correction to the angle
596 // calculate residuals
597 Float_t yres[knTimebins]; // y (r-phi) residuals
598 Int_t zint[knTimebins], // Histograming of the z coordinate
599 zout[2*knTimebins];//
602 for (Int_t iTime = 0; iTime < fTimeBinsRange; iTime++) {
603 if (!fClusters[iTime]) continue;
604 yres[iTime] = fY[iTime] - fYref[0] - (fYref[1] + anglecor) * fX[iTime];
605 zint[fN] = Int_t(fZ[iTime]);
609 // calculate pad row boundary crosses
610 Int_t kClmin = Int_t(fRecoParam->GetFindableClusters()*fTimeBinsRange);
611 Int_t nz = AliMathBase::Freq(fN, zint, zout, kFALSE);
613 if(nz <= 1) zout[3] = 0;
614 if(zout[1] + zout[3] < kClmin) {
615 AliWarning(Form("Not enough clusters to fit the cross boundary tracklet %d [%d].", zout[1]+zout[3], kClmin));
618 // Z distance bigger than pad - length
619 if (TMath::Abs(zout[0]-zout[2]) > fPadLength) zout[3]=0;
632 // we will use only the clusters which are in the detector range
633 for(int iTime=0; iTime<fTimeBinsRange; iTime++){
634 fUsable[iTime] = kFALSE;
635 if (!fClusters[iTime]) continue;
636 npads = fClusters[iTime]->GetNPads();
638 fUsable[iTime] = kTRUE;
641 Float_t weight = 1.0;
642 if(npads > 5) weight = 0.2;
643 else if(npads > 4) weight = 0.5;
645 sumwx += fX[iTime] * weight;
646 sumwx2 += fX[iTime] * fX[iTime] * weight;
647 sumwy += weight * yres[iTime];
648 sumwxy += weight * yres[iTime] * fX[iTime];
649 sumwz += weight * fZ[iTime];
650 sumwxz += weight * fZ[iTime] * fX[iTime];
653 AliWarning(Form("Not enough clusters to fit the tracklet %d [%d].", fN2, kClmin));
657 fMeanz = sumwz / sumw;
660 // Tracklet on boundary
661 Float_t correction = 0;
663 if (fMeanz < fZProb) correction = ycrosscor;
664 if (fMeanz > fZProb) correction = -ycrosscor;
667 Double_t det = sumw * sumwx2 - sumwx * sumwx;
668 fYfitR[0] = (sumwx2 * sumwy - sumwx * sumwxy) / det;
669 fYfitR[1] = (sumw * sumwxy - sumwx * sumwy) / det;
672 for (Int_t i = 0; i < fTimeBinsRange+1; i++) {
673 if (!fUsable[i]) continue;
674 Float_t delta = yres[i] - fYfitR[0] - fYfitR[1] * fX[i];
675 fSigmaY2 += delta*delta;
677 fSigmaY2 = TMath::Sqrt(fSigmaY2 / Float_t(fN2-2));
679 fZfitR[0] = (sumwx2 * sumwz - sumwx * sumwxz) / det;
680 fZfitR[1] = (sumw * sumwxz - sumwx * sumwz) / det;
681 fZfit[0] = (sumwx2 * sumwz - sumwx * sumwxz) / det;
682 fZfit[1] = (sumw * sumwxz - sumwx * sumwz) / det;
683 fYfitR[0] += fYref[0] + correction;
684 fYfitR[1] += fYref[1];
685 fYfit[0] = fYfitR[0];
686 fYfit[1] = fYfitR[1];
691 //_____________________________________________________________________________
692 Float_t AliTRDseedV1::FitRiemanTilt(AliTRDseedV1 *cseed, Bool_t terror)
695 // Fit the Rieman tilt
698 // Fitting with tilting pads - kz not fixed
699 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
700 Int_t nTimeBins = cal->GetNumberOfTimeBins();
701 TLinearFitter fitterT2(4,"hyp4");
702 fitterT2.StoreData(kTRUE);
703 Float_t xref2 = (cseed[2].fX0 + cseed[3].fX0) * 0.5; // Reference x0 for z
706 fitterT2.ClearPoints();
708 for (Int_t iLayer = 0; iLayer < 6; iLayer++) {
709 // printf("\nLayer %d\n", iLayer);
710 // cseed[iLayer].Print();
711 if (!cseed[iLayer].IsOK()) continue;
712 Double_t tilt = cseed[iLayer].fTilt;
714 for (Int_t itime = 0; itime < nTimeBins+1; itime++) {
715 // printf("\ttime %d\n", itime);
716 if (!cseed[iLayer].fUsable[itime]) continue;
717 // x relative to the midle chamber
718 Double_t x = cseed[iLayer].fX[itime] + cseed[iLayer].fX0 - xref2;
719 Double_t y = cseed[iLayer].fY[itime];
720 Double_t z = cseed[iLayer].fZ[itime];
726 Double_t x2 = cseed[iLayer].fX[itime] + cseed[iLayer].fX0; // Global x
727 Double_t t = 1.0 / (x2*x2 + y*y);
729 uvt[0] = 2.0 * x2 * uvt[1];
730 uvt[2] = 2.0 * tilt * uvt[1];
731 uvt[3] = 2.0 * tilt *uvt[1] * x;
732 uvt[4] = 2.0 * (y + tilt * z) * uvt[1];
734 Double_t error = 2.0 * uvt[1];
736 error *= cseed[iLayer].fSigmaY;
739 error *= 0.2; //Default error
741 // printf("\tadd point :\n");
742 // for(int i=0; i<5; i++) printf("%f ", uvt[i]);
744 fitterT2.AddPoint(uvt,uvt[4],error);
751 Double_t rpolz0 = fitterT2.GetParameter(3);
752 Double_t rpolz1 = fitterT2.GetParameter(4);
755 // Linear fitter - not possible to make boundaries
756 // non accept non possible z and dzdx combination
758 Bool_t acceptablez = kTRUE;
759 for (Int_t iLayer = 0; iLayer < 6; iLayer++) {
760 if (cseed[iLayer].IsOK()) {
761 Double_t zT2 = rpolz0 + rpolz1 * (cseed[iLayer].fX0 - xref2);
762 if (TMath::Abs(cseed[iLayer].fZProb - zT2) > cseed[iLayer].fPadLength * 0.5 + 1.0) {
763 acceptablez = kFALSE;
768 Double_t zmf = cseed[2].fZref[0] + cseed[2].fZref[1] * (xref2 - cseed[2].fX0);
769 Double_t dzmf = (cseed[2].fZref[1] + cseed[3].fZref[1]) * 0.5;
770 fitterT2.FixParameter(3,zmf);
771 fitterT2.FixParameter(4,dzmf);
773 fitterT2.ReleaseParameter(3);
774 fitterT2.ReleaseParameter(4);
775 rpolz0 = fitterT2.GetParameter(3);
776 rpolz1 = fitterT2.GetParameter(4);
779 Double_t chi2TR = fitterT2.GetChisquare() / Float_t(npointsT);
781 params[0] = fitterT2.GetParameter(0);
782 params[1] = fitterT2.GetParameter(1);
783 params[2] = fitterT2.GetParameter(2);
784 Double_t curvature = 1.0 + params[1] * params[1] - params[2] * params[0];
786 for (Int_t iLayer = 0; iLayer < 6; iLayer++) {
788 Double_t x = cseed[iLayer].fX0;
795 Double_t res2 = (x * params[0] + params[1]);
797 res2 = 1.0 - params[2]*params[0] + params[1]*params[1] - res2;
799 res2 = TMath::Sqrt(res2);
800 y = (1.0 - res2) / params[0];
804 Double_t x0 = -params[1] / params[0];
805 if (-params[2]*params[0] + params[1]*params[1] + 1 > 0) {
806 Double_t rm1 = params[0] / TMath::Sqrt(-params[2]*params[0] + params[1]*params[1] + 1);
807 if (1.0/(rm1*rm1) - (x-x0) * (x-x0) > 0.0) {
808 Double_t res = (x - x0) / TMath::Sqrt(1.0 / (rm1*rm1) - (x-x0)*(x-x0));
809 if (params[0] < 0) res *= -1.0;
813 z = rpolz0 + rpolz1 * (x - xref2);
815 cseed[iLayer].fYref[0] = y;
816 cseed[iLayer].fYref[1] = dy;
817 cseed[iLayer].fZref[0] = z;
818 cseed[iLayer].fZref[1] = dz;
819 cseed[iLayer].fC = curvature;
827 //___________________________________________________________________
828 void AliTRDseedV1::Print()
831 // Printing the seedstatus
834 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
835 Int_t nTimeBins = cal->GetNumberOfTimeBins();
837 printf("Seed status :\n");
838 printf(" fTilt = %f\n", fTilt);
839 printf(" fPadLength = %f\n", fPadLength);
840 printf(" fX0 = %f\n", fX0);
841 for(int ic=0; ic<nTimeBins; ic++) {
842 const Char_t *isUsable = fUsable[ic]?"Yes":"No";
843 printf(" %d X[%f] Y[%f] Z[%f] Indexes[%d] clusters[%p] usable[%s]\n"
849 , ((void*) fClusters[ic])
853 printf(" fYref[0] =%f fYref[1] =%f\n", fYref[0], fYref[1]);
854 printf(" fZref[0] =%f fZref[1] =%f\n", fZref[0], fZref[1]);
855 printf(" fYfit[0] =%f fYfit[1] =%f\n", fYfit[0], fYfit[1]);
856 printf(" fYfitR[0]=%f fYfitR[1]=%f\n", fYfitR[0], fYfitR[1]);
857 printf(" fZfit[0] =%f fZfit[1] =%f\n", fZfit[0], fZfit[1]);
858 printf(" fZfitR[0]=%f fZfitR[1]=%f\n", fZfitR[0], fZfitR[1]);
859 printf(" fSigmaY =%f\n", fSigmaY);
860 printf(" fSigmaY2=%f\n", fSigmaY2);
861 printf(" fMeanz =%f\n", fMeanz);
862 printf(" fZProb =%f\n", fZProb);
863 printf(" fLabels[0]=%d fLabels[1]=%d\n", fLabels[0], fLabels[1]);
864 printf(" fN =%d\n", fN);
865 printf(" fN2 =%d (>8 isOK)\n",fN2);
866 printf(" fNUsed =%d\n", fNUsed);
867 printf(" fFreq =%d\n", fFreq);
868 printf(" fNChange=%d\n", fNChange);
869 printf(" fMPads =%f\n", fMPads);
871 printf(" fC =%f\n", fC);
872 printf(" fCC =%f\n",fCC);
873 printf(" fChi2 =%f\n", fChi2);
874 printf(" fChi2Z =%f\n", fChi2Z);