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 **************************************************************************/
16 ///////////////////////////////////////////////////////
19 // Tracklet object created in the local tracking //
22 ///////////////////////////////////////////////////////
30 #include "AliTRDcalibDB.h"
31 #include "AliTRDCommonParam.h"
32 #include "AliTRDpadPlane.h"
33 #include "AliTRDgeometry.h"
34 #include "AliTRDmcmTracklet.h"
36 ClassImp(AliTRDmcmTracklet)
38 //_____________________________________________________________________________
39 AliTRDmcmTracklet::AliTRDmcmTracklet()
56 // AliTRDmcmTracklet default constructor
59 for (Int_t time = 0; time < kNtimeBins; time++) {
60 for (Int_t icl = 0; icl < kNclsPads; icl++) {
63 for (Int_t it = 0; it < kNdict; it++) {
64 fTrack[time][it] = -1;
72 //_____________________________________________________________________________
73 AliTRDmcmTracklet::AliTRDmcmTracklet(Int_t det, Int_t row, Int_t n)
90 // AliTRDmcmTracklet default constructor
93 for (Int_t time = 0; time < kNtimeBins; time++) {
94 for (Int_t icl = 0; icl < kNclsPads; icl++) {
97 for (Int_t it = 0; it < kNdict; it++) {
98 fTrack[time][it] = -1;
104 fGPos = new TGraph(0);
105 fGAmp = new TGraph(0);
109 //_____________________________________________________________________________
110 AliTRDmcmTracklet::AliTRDmcmTracklet(const AliTRDmcmTracklet &t)
112 ,fDetector(t.fDetector)
114 ,fTrackLabel(t.fTrackLabel)
115 ,fNclusters(t.fNclusters)
127 // AliTRDmcmTracklet copy constructor
130 for (Int_t time = 0; time < kNtimeBins; time++) {
131 for (Int_t icl = 0; icl < kNclsPads; icl++) {
132 ((AliTRDmcmTracklet &) t).fADC[time][icl] = 0;
134 for (Int_t it = 0; it < kNdict; it++) {
135 ((AliTRDmcmTracklet &) t).fTrack[time][it] = -1;
137 ((AliTRDmcmTracklet &) t).fTime[time] = 0;
138 ((AliTRDmcmTracklet &) t).fCol[time] = 0;
143 //_____________________________________________________________________________
144 AliTRDmcmTracklet::~AliTRDmcmTracklet()
147 // AliTRDmcmTracklet destructor
150 if (fGPos != 0) delete fGPos;
151 if (fGAmp != 0) delete fGAmp;
155 //_____________________________________________________________________________
156 AliTRDmcmTracklet &AliTRDmcmTracklet::operator=(const AliTRDmcmTracklet &t)
159 // Assignment operator
162 if (this != &t) ((AliTRDmcmTracklet &) t).Copy(*this);
167 //_____________________________________________________________________________
168 void AliTRDmcmTracklet::Copy(TObject &t) const
174 ((AliTRDmcmTracklet &) t).fDetector = fDetector;
175 ((AliTRDmcmTracklet &) t).fRow = fRow;
176 ((AliTRDmcmTracklet &) t).fTrackLabel = fTrackLabel;
177 ((AliTRDmcmTracklet &) t).fNclusters = fNclusters;
178 ((AliTRDmcmTracklet &) t).fN = fN;
179 ((AliTRDmcmTracklet &) t).fGPos = NULL;
180 ((AliTRDmcmTracklet &) t).fGAmp = NULL;
181 ((AliTRDmcmTracklet &) t).fTime0 = fTime0;
182 ((AliTRDmcmTracklet &) t).fRowz = fRowz;
183 ((AliTRDmcmTracklet &) t).fSlope = fSlope;
184 ((AliTRDmcmTracklet &) t).fOffset = fOffset;
185 ((AliTRDmcmTracklet &) t).fPt = fPt;
186 ((AliTRDmcmTracklet &) t).fdQdl = fdQdl;
188 for (Int_t time = 0; time < kNtimeBins; time++) {
189 for (Int_t icl = 0; icl < kNclsPads; icl++) {
190 ((AliTRDmcmTracklet &) t).fADC[time][icl] = 0;
192 for (Int_t it = 0; it < kNdict; it++) {
193 ((AliTRDmcmTracklet &) t).fTrack[time][it] = -1;
195 ((AliTRDmcmTracklet &) t).fTime[time] = 0;
196 ((AliTRDmcmTracklet &) t).fCol[time] = 0;
201 //_____________________________________________________________________________
202 void AliTRDmcmTracklet::Reset()
205 // Reset the tracklet information
211 for (Int_t time = 0; time < kNtimeBins; time++) {
212 for (Int_t icl = 0; icl < kNclsPads; icl++) {
215 for (Int_t it = 0; it < kNdict; it++) {
216 fTrack[time][it] = -1;
238 //_____________________________________________________________________________
239 void AliTRDmcmTracklet::AddCluster(Int_t icol, Int_t itb, Float_t *adc, Int_t *track)
242 // Add a cluster to the tracklet
245 if (fNclusters >= kNtimeBins) return;
247 for (Int_t icl = 0; icl < kNclsPads; icl++) {
248 fADC[fNclusters][icl] = adc[icl];
251 fTrack[fNclusters][0] = track[0];
252 fTrack[fNclusters][1] = track[1];
253 fTrack[fNclusters][2] = track[2];
254 fTime[fNclusters] = itb;
255 fCol[fNclusters] = icol;
261 //_____________________________________________________________________________
262 void AliTRDmcmTracklet::MakeTrackletGraph(AliTRDgeometry *geo, Float_t field)
265 // Tracklet graph of positions (global coordinates, rotated [cm])
269 AliError("No geometry.");
273 AliTRDCommonParam* commonParam = AliTRDCommonParam::Instance();
275 AliError("No common parameters.");
279 AliTRDcalibDB* calibration = AliTRDcalibDB::Instance();
281 AliError("No instance of AliTRDcalibDB.");
287 iplan = geo->GetPlane(fDetector);
288 icham = geo->GetChamber(fDetector);
290 AliTRDpadPlane *padPlane = commonParam->GetPadPlane(iplan,icham);
292 Float_t samplFreq = calibration->GetSamplingFrequency();
296 Float_t xpos, ypos, xzero, colSize, timeBinSize;
297 Float_t vDrift, omegaTau, lorentzAngle, thetaSlope;
298 Float_t tiltingAngle;
301 for (Int_t icl = 0; icl < fNclusters; icl++) {
303 time = GetClusterTime(icl);
305 amp[0] = GetClusterADC(icl)[0];
306 amp[1] = GetClusterADC(icl)[1];
307 amp[2] = GetClusterADC(icl)[2];
309 col = GetClusterCol(icl);
311 if (amp[0] < 0.0 || amp[1] < 0.0 || amp[2] < 0.0) continue;
313 ypos = GetClusY(amp,iplan);
315 colSize = padPlane->GetColSize(col);
316 vDrift = calibration->GetVdrift(fDetector,col,fRow);
317 timeBinSize = vDrift/samplFreq;
319 // From v4-03-Release to HEAD28Mar06 the sign has changed from "-" to "+"
320 // due to a change in the digitizer
321 omegaTau = TMath::Sign(1.0,(Double_t)field)*GetOmegaTau(vDrift,TMath::Abs(field));
322 lorentzAngle = TMath::ATan(omegaTau)*180.0/TMath::Pi();
324 xpos = (time+0.5) * timeBinSize;
325 xpos = geo->GetTime0(iplan) - xpos;
327 ypos = padPlane->GetColPos(col) - (ypos + 0.5) * colSize;
330 xzero = geo->GetTime0(iplan);
331 ypos = ypos + (xpos-xzero) * omegaTau;
333 // tilted pads correction
334 thetaSlope = - padPlane->GetRowPos(fRow)/geo->GetTime0(iplan);
335 tiltingAngle = padPlane->GetTiltingAngle()/180.0*TMath::Pi();
336 ypos = ypos - (xpos-xzero) * thetaSlope * TMath::Sin(tiltingAngle);
338 fGPos->SetPoint(npg,(Double_t)xpos,(Double_t)ypos);
345 fTime0 = geo->GetTime0(iplan) - AliTRDgeometry::CdrHght() - 0.5*AliTRDgeometry::CamHght();
346 fRowz = padPlane->GetRowPos(fRow) - padPlane->GetRowSize(fRow)/2.0;
351 fGPos->GetPoint(0 ,x,y);
353 fGPos->GetPoint(npg-1,x,y);
356 TF1 *line = new TF1("line","[0]+x*[1]",xMin,xMax);
357 fGPos->Fit(line,"WRQ0");
359 fOffset = line->Eval(fTime0);
360 fSlope = TMath::ATan(line->GetParameter(1))*180.0/TMath::Pi();
365 Float_t fy = fOffset;
367 Float_t infSlope = TMath::ATan(fy/fx)/TMath::Pi()*180.0;
368 Float_t alpha = fSlope - infSlope;
369 Float_t r = TMath::Sqrt(fx*fx + fy*fy)/(2.0*TMath::Sin(alpha/180.0*TMath::Pi()));
371 fPt = 0.3 * field * 0.01 * r;
377 //_____________________________________________________________________________
378 void AliTRDmcmTracklet::MakeClusAmpGraph()
381 // Tracklet graph of cluster charges
389 for (Int_t icl = 0; icl < fNclusters; icl++) {
391 time = GetClusterTime(icl);
393 amp[0] = GetClusterADC(icl)[0];
394 amp[1] = GetClusterADC(icl)[1];
395 amp[2] = GetClusterADC(icl)[2];
397 fGAmp->SetPoint(npg,(Double_t)(time+0.5),(Double_t)(amp[0]+amp[1]+amp[2]));
400 fdQdl += amp[0]+amp[1]+amp[2];
406 fdQdl /= (Float_t)npg;
412 //_____________________________________________________________________________
413 Float_t AliTRDmcmTracklet::GetClusY(Float_t *adc, Int_t pla) const
416 // Cluster position in the phi direction in pad units (relative to the pad border)
425 Float_t t1, t2, w1 ,w2;
427 Float_t w = 1.0; // pad units
433 sigma = 0.515; break;
435 sigma = 0.501; break;
437 sigma = 0.491; break;
439 sigma = 0.481; break;
441 sigma = 0.471; break;
443 sigma = 0.463; break;
445 AliError("Wrong plane number.");
456 t1 = w1*((sigma*sigma)/w*TMath::Log(a1/a0)-0.5*w);
463 t2 = w2*((sigma*sigma)/w*TMath::Log(a2/a1)+0.5*w);
466 ypos = w*(t1+t2)/(w1+w2); // range: -0.5*w ... +0.5*w
472 //_____________________________________________________________________________
473 void AliTRDmcmTracklet::CookLabel(Float_t frac)
476 // Cook the track label from cluster labels
479 const Int_t kMaxTracks = 10;
480 Int_t trackLabel[kMaxTracks];
481 Int_t trackCount[kMaxTracks];
482 for (Int_t it = 0; it < kMaxTracks; it++) {
488 Int_t label, nTracks = 0;
489 for (Int_t icl = 0; icl < fNclusters; icl++) {
491 for (Int_t id = 0; id < kNdict; id++) {
493 if (fTrack[icl][id] == -1) continue;
495 label = fTrack[icl][id];
498 for (Int_t it = 0; it < nTracks; it++) {
499 if (label == trackLabel[it]) {
506 trackLabel[nTracks] = label;
507 trackCount[nTracks]++;
509 if (nTracks == kMaxTracks) {
510 AliWarning("Too many tracks for this tracklet.");
520 for (Int_t it = 0; it < kMaxTracks; it++) {
521 if (trackCount[it] >= (Int_t)(frac*fNclusters)) {
522 fTrackLabel = trackLabel[it];
529 //_____________________________________________________________________________
530 Float_t AliTRDmcmTracklet::GetOmegaTau(Float_t vdrift, Float_t field) const
533 // Returns omega*tau (tan(Lorentz-angle)) for a given drift velocity <vd>
534 // and a B-field <b> for Xe/CO2 (15%).
535 // The values are according to a GARFIELD simulation.
539 // Copy of the "AliTRDcalibDB" function, taking as argument the magnetic field too
543 Float_t p0[kNb] = { 0.004810, 0.007412, 0.010252, 0.013409, 0.016888 };
544 Float_t p1[kNb] = { 0.054875, 0.081534, 0.107333, 0.131983, 0.155455 };
545 Float_t p2[kNb] = { -0.008682, -0.012896, -0.016987, -0.020880, -0.024623 };
546 Float_t p3[kNb] = { 0.000155, 0.000238, 0.000330, 0.000428, 0.000541 };
548 Int_t ib = ((Int_t) (10 * (field - 0.15)));
549 ib = TMath::Max( 0,ib);
550 ib = TMath::Min(kNb,ib);
552 Float_t alphaL = p0[ib]
554 + p2[ib] * vdrift*vdrift
555 + p3[ib] * vdrift*vdrift*vdrift;
557 return TMath::Tan(alphaL);