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 ///////////////////////////////////////////////////////
28 #include "AliTRDcalibDB.h"
29 #include "AliTRDCommonParam.h"
30 #include "AliTRDpadPlane.h"
31 #include "AliTRDgeometry.h"
33 #include "AliTRDmcmTracklet.h"
35 ClassImp(AliTRDmcmTracklet)
37 //_____________________________________________________________________________
38 AliTRDmcmTracklet::AliTRDmcmTracklet()
42 // AliTRDmcmTracklet default constructor
48 for (Int_t time = 0; time < kNtimeBins; time++) {
49 for (Int_t icl = 0; icl < kNclsPads; icl++) {
52 for (Int_t it = 0; it < kNdict; it++) {
53 fTrack[time][it] = -1;
75 //_____________________________________________________________________________
76 AliTRDmcmTracklet::AliTRDmcmTracklet(Int_t det, Int_t row, Int_t n)
80 // AliTRDmcmTracklet default constructor
86 for (Int_t time = 0; time < kNtimeBins; time++) {
87 for (Int_t icl = 0; icl < kNclsPads; icl++) {
90 for (Int_t it = 0; it < kNdict; it++) {
91 fTrack[time][it] = -1;
103 fGPos = new TGraph(0);
104 fGAmp = new TGraph(0);
115 //_____________________________________________________________________________
116 AliTRDmcmTracklet::~AliTRDmcmTracklet()
120 // AliTRDmcmTracklet destructor
126 //_____________________________________________________________________________
127 AliTRDmcmTracklet &AliTRDmcmTracklet::operator=(const AliTRDmcmTracklet &t)
130 // assignment operator
133 if (this != &t) ((AliTRDmcmTracklet &) t).Copy(*this);
138 //_____________________________________________________________________________
139 void AliTRDmcmTracklet::Copy(TObject &t) const
145 ((AliTRDmcmTracklet &) t).fDetector = fDetector;
146 ((AliTRDmcmTracklet &) t).fRow = fRow;
147 ((AliTRDmcmTracklet &) t).fTrackLabel = fTrackLabel;
148 ((AliTRDmcmTracklet &) t).fNclusters = fNclusters;
149 ((AliTRDmcmTracklet &) t).fN = fN;
150 ((AliTRDmcmTracklet &) t).fGPos = NULL;
151 ((AliTRDmcmTracklet &) t).fGAmp = NULL;
152 ((AliTRDmcmTracklet &) t).fTime0 = fTime0;
153 ((AliTRDmcmTracklet &) t).fRowz = fRowz;
154 ((AliTRDmcmTracklet &) t).fSlope = fSlope;
155 ((AliTRDmcmTracklet &) t).fOffset = fOffset;
156 ((AliTRDmcmTracklet &) t).fPt = fPt;
157 ((AliTRDmcmTracklet &) t).fdQdl = fdQdl;
159 for (Int_t time = 0; time < kNtimeBins; time++) {
160 for (Int_t icl = 0; icl < kNclsPads; icl++) {
161 ((AliTRDmcmTracklet &) t).fADC[time][icl] = 0;
163 for (Int_t it = 0; it < kNdict; it++) {
164 ((AliTRDmcmTracklet &) t).fTrack[time][it] = -1;
166 ((AliTRDmcmTracklet &) t).fTime[time] = 0;
167 ((AliTRDmcmTracklet &) t).fCol[time] = 0;
172 //_____________________________________________________________________________
173 void AliTRDmcmTracklet::AddCluster(Int_t icol, Int_t itb, Float_t *adc, Int_t *track)
179 if (fNclusters >= kNtimeBins) return;
181 for (Int_t icl = 0; icl < kNclsPads; icl++) {
182 //fADC[fNclusters][icl] = (Int_t)adc[icl];
183 fADC[fNclusters][icl] = adc[icl];
186 fTrack[fNclusters][0] = track[0];
187 fTrack[fNclusters][1] = track[1];
188 fTrack[fNclusters][2] = track[2];
189 fTime[fNclusters] = itb;
190 fCol[fNclusters] = icol;
196 //_____________________________________________________________________________
197 void AliTRDmcmTracklet::MakeTrackletGraph(AliTRDgeometry *geo, Float_t field)
201 // Tracklet graph of positions (global coordinates, rotated [cm])
205 Error("MakeTrackletGraph","No geometry.");
209 AliTRDCommonParam* commonParam = AliTRDCommonParam::Instance();
212 Error("MakeTrackletGraph","No common params.");
216 AliTRDcalibDB* calibration = AliTRDcalibDB::Instance();
219 Error("MakeTrackletGraph","No instance of AliTRDcalibDB.");
225 iplan = geo->GetPlane(fDetector);
226 icham = geo->GetChamber(fDetector);
228 AliTRDpadPlane *padPlane = commonParam->GetPadPlane(iplan,icham);
230 Float_t samplFreq = calibration->GetSamplingFrequency();
234 Float_t xpos, ypos, xzero, colSize, timeBinSize;
235 Float_t vDrift, omegaTau, lorentzAngle, thetaSlope;
236 Float_t tiltingAngle;
239 for (Int_t icl = 0; icl < fNclusters; icl++) {
241 time = GetClusterTime(icl);
243 amp[0] = GetClusterADC(icl)[0];
244 amp[1] = GetClusterADC(icl)[1];
245 amp[2] = GetClusterADC(icl)[2];
247 col = GetClusterCol(icl);
249 if (amp[0] < 0.0 || amp[1] < 0.0 || amp[2] < 0.0) continue;
251 ypos = GetClusY(amp,iplan);
253 colSize = padPlane->GetColSize(col);
254 vDrift = calibration->GetVdrift(fDetector,col,fRow);
255 timeBinSize = vDrift/samplFreq;
257 // From v4-03-Release to HEAD28Mar06 the sign has changed from "-" to "+"
258 // due to a change in the digitizer
259 omegaTau = +TMath::Sign(1.0,(Double_t)field)*GetOmegaTau(vDrift,TMath::Abs(field));
260 lorentzAngle = TMath::ATan(omegaTau)*180.0/TMath::Pi();
262 xpos = (time+0.5) * timeBinSize;
263 xpos = geo->GetTime0(iplan) - xpos;
265 ypos = padPlane->GetColPos(col) - (ypos + 0.5) * colSize;
268 xzero = geo->GetTime0(iplan);
269 ypos = ypos + (xpos-xzero) * omegaTau;
271 // tilted pads correction
272 thetaSlope = - padPlane->GetRowPos(fRow)/geo->GetTime0(iplan);
273 tiltingAngle = padPlane->GetTiltingAngle()/180.0*TMath::Pi();
274 ypos = ypos - (xpos-xzero) * thetaSlope * TMath::Sin(tiltingAngle);
276 fGPos->SetPoint(npg,(Double_t)xpos,(Double_t)ypos);
283 fTime0 = geo->GetTime0(iplan) - AliTRDgeometry::CdrHght() - 0.5*AliTRDgeometry::CamHght();
284 fRowz = 0.5*(padPlane->GetRowPos(fRow) + padPlane->GetRowPos(fRow+1));
286 Double_t xMin = 0, xMax = 0, x, y;
287 fGPos->GetPoint(0 ,x,y); xMax = x + 0.1;
288 fGPos->GetPoint(npg-1,x,y); xMin = x - 0.1;
290 TF1 *line = new TF1("line","[0]+x*[1]",xMin,xMax);
291 fGPos->Fit(line,"WRQ0");
293 fOffset = line->Eval(fTime0);
294 fSlope = TMath::ATan(line->GetParameter(1))*180.0/TMath::Pi();
299 Float_t fy = fOffset;
301 Float_t infSlope = TMath::ATan(fy/fx)/TMath::Pi()*180.0;
302 Float_t alpha = fSlope - infSlope;
303 Float_t r = TMath::Sqrt(fx*fx + fy*fy)/(2.0*TMath::Sin(alpha/180.0*TMath::Pi()));
305 fPt = 0.3 * field * 0.01 * r;
311 //_____________________________________________________________________________
312 void AliTRDmcmTracklet::MakeClusAmpGraph()
315 // Tracklet graph of cluster charges
318 AliTRDcalibDB* calibration = AliTRDcalibDB::Instance();
321 Error("MakeClusAmpGraph","No instance of AliTRDcalibDB.");
329 for (Int_t icl = 0; icl < fNclusters; icl++) {
331 time = GetClusterTime(icl);
333 amp[0] = GetClusterADC(icl)[0];
334 amp[1] = GetClusterADC(icl)[1];
335 amp[2] = GetClusterADC(icl)[2];
337 fGAmp->SetPoint(npg,(Double_t)(time+0.5),(Double_t)(amp[0]+amp[1]+amp[2]));
340 fdQdl += amp[0]+amp[1]+amp[2];
346 fdQdl /= (Float_t)npg;
352 //_____________________________________________________________________________
353 Float_t AliTRDmcmTracklet::GetClusY(Float_t *adc, Int_t pla) const
356 // Cluster position in the phi direction in pad units (relative to the pad border)
365 Float_t t1, t2, w1 ,w2;
367 Float_t w = 1.0; // pad units
373 sigma = 0.515; break;
375 sigma = 0.501; break;
377 sigma = 0.491; break;
379 sigma = 0.481; break;
381 sigma = 0.471; break;
383 sigma = 0.463; break;
385 Error("GetClusY","Wrong plane number.");
396 t1 = w1*((sigma*sigma)/w*TMath::Log(a1/a0)-0.5*w);
403 t2 = w2*((sigma*sigma)/w*TMath::Log(a2/a1)+0.5*w);
406 ypos = w*(t1+t2)/(w1+w2); // range: -0.5*w ... +0.5*w
412 //_____________________________________________________________________________
413 void AliTRDmcmTracklet::CookLabel(Float_t frac)
416 // Cook the track label from cluster labels
419 const Int_t kMaxTracks = 10;
420 Int_t trackLabel[kMaxTracks];
421 Int_t trackCount[kMaxTracks];
422 for (Int_t it = 0; it < kMaxTracks; it++) {
428 Int_t label, nTracks = 0;
429 for (Int_t icl = 0; icl < fNclusters; icl++) {
431 for (Int_t id = 0; id < kNdict; id++) {
433 if (fTrack[icl][id] == -1) continue;
435 label = fTrack[icl][id];
438 for (Int_t it = 0; it < nTracks; it++) {
439 if (label == trackLabel[it]) {
446 trackLabel[nTracks] = label;
447 trackCount[nTracks]++;
449 if (nTracks == kMaxTracks) {
450 Warning("CookLabel","Too many tracks for this tracklet.");
460 for (Int_t it = 0; it < kMaxTracks; it++) {
461 if (trackCount[it] >= (Int_t)(frac*fNclusters)) {
462 fTrackLabel = trackLabel[it];
469 //_____________________________________________________________________________
470 Float_t AliTRDmcmTracklet::GetOmegaTau(Float_t vdrift, Float_t field) const
473 // Returns omega*tau (tan(Lorentz-angle)) for a given drift velocity <vd>
474 // and a B-field <b> for Xe/CO2 (15%).
475 // The values are according to a GARFIELD simulation.
479 // Copy of the "AliTRDcalibDB" function, taking as argument the magnetic field too
483 Float_t p0[kNb] = { 0.004810, 0.007412, 0.010252, 0.013409, 0.016888 };
484 Float_t p1[kNb] = { 0.054875, 0.081534, 0.107333, 0.131983, 0.155455 };
485 Float_t p2[kNb] = { -0.008682, -0.012896, -0.016987, -0.020880, -0.024623 };
486 Float_t p3[kNb] = { 0.000155, 0.000238, 0.000330, 0.000428, 0.000541 };
488 Int_t ib = ((Int_t) (10 * (field - 0.15)));
489 ib = TMath::Max( 0,ib);
490 ib = TMath::Min(kNb,ib);
492 Float_t alphaL = p0[ib]
494 + p2[ib] * vdrift*vdrift
495 + p3[ib] * vdrift*vdrift*vdrift;
497 return TMath::Tan(alphaL);