]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCTracklet.cxx
Moved calibration and cleaning to RawDigiProducer
[u/mrichter/AliRoot.git] / TPC / AliTPCTracklet.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 ////
17 // This class stores a tracklet (a track that lives only in a single TPC
18 // sector). Its objects can be constructed out of TPCseeds, that are
19 // holding the necessary cluster information.
20 ////
21 ////
22 //// 
23
24
25 #include "AliTPCTracklet.h"
26 #include "TObjArray.h"
27 #include "AliTPCseed.h"
28 #include "AliESDVertex.h"
29
30 ClassImp(AliTPCTracklet)
31
32 AliTPCTracklet::AliTPCTracklet() 
33   : fNClusters(0),fSector(-1),fOuter(0),fInner(0),fPrimary(0) {
34   ////
35   // The default constructor. It is intended to be used for I/O only.
36   ////
37 }
38
39 AliTPCTracklet::AliTPCTracklet(const AliTPCseed *track,Int_t sector)
40   : fNClusters(0),fSector(sector),fOuter(0),fInner(0),fPrimary(0) {
41   ////
42   // Contructor for a tracklet out of a track. Only clusters within a given 
43   // sector are used.
44   ///
45   
46   AliTPCseed *t=new AliTPCseed(*track);
47
48   if (!t->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-t->GetAlpha())) {
49     delete t;
50     return;
51   }
52
53   // fit from inner to outer row
54   AliTPCseed *outerSeed=new AliTPCseed(*t);
55   Int_t n=0;
56   for (Int_t i=0;i<160;++i) {
57     AliTPCclusterMI *c=t->GetClusterPointer(i);
58     if (c&&c->GetDetector()==sector) {
59       if (n==1) {
60         outerSeed->ResetCovariance(100.);
61       }
62       ++n;
63       Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
64       Double_t cov[3]={0.1,0.,0.1}; //TODO: correct error parametrisation
65       if (!outerSeed->PropagateTo(r[0])
66           || !static_cast<AliExternalTrackParam*>(outerSeed)->Update(&r[1],cov)) {
67         delete outerSeed;
68         outerSeed=0;
69         break;
70       }
71     }
72   }
73   fNClusters=n;
74   if (outerSeed)
75     fOuter=new AliExternalTrackParam(*outerSeed);
76   delete outerSeed;
77   // fit from outer to inner rows
78   AliTPCseed *innerSeed=new AliTPCseed(*t);
79   n=0;
80   for (Int_t i=159;i>=0;--i) {
81     AliTPCclusterMI *c=t->GetClusterPointer(i);
82     if (c&&c->GetDetector()==sector) {
83       if (n==1) {
84         innerSeed->ResetCovariance(100.);
85       }
86       ++n;
87       Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
88       Double_t cov[3]={0.1,0.,0.1};
89       if (!innerSeed->PropagateTo(r[0])
90           || !static_cast<AliExternalTrackParam*>(innerSeed)->Update(&r[1],cov)) {
91         delete innerSeed;
92         innerSeed=0;
93         break;
94       }
95     }
96   }
97   fNClusters=TMath::Max(fNClusters,n);
98   if (innerSeed)
99     fInner=new AliExternalTrackParam(*outerSeed);
100   // propagate to the primary vertex
101   if (innerSeed) {
102     AliTPCseed *primarySeed=new AliTPCseed(*innerSeed);
103     Double_t pos[]={0.,0.,0.};
104     Double_t sigma[]={.1,.1,.1}; //TODO: is this correct?
105     AliESDVertex vertex(pos,sigma);
106     if (primarySeed->PropagateToVertex(&vertex))
107       fPrimary=new AliExternalTrackParam(*primarySeed);
108     delete primarySeed;
109   }
110   delete innerSeed;
111
112   if (!fOuter&&!fInner)
113     fNClusters=0;
114
115   delete t;
116 }
117
118 AliTPCTracklet::AliTPCTracklet(const AliTPCTracklet &t)
119   : fNClusters(t.fNClusters),fSector(t.fSector),fOuter(0),fInner(0),
120     fPrimary(0) {
121   ////
122   // The copy constructor. You can copy tracklets! 
123   ////
124
125   if (t.fOuter)
126     fOuter=new AliExternalTrackParam(*t.fOuter);
127   if (t.fInner)
128     fInner=new AliExternalTrackParam(*t.fInner);
129   if (t.fPrimary)
130     fPrimary=new AliExternalTrackParam(*t.fPrimary);
131 }
132
133 AliTPCTracklet& AliTPCTracklet::operator=(const AliTPCTracklet &t) {
134   ////
135   // The assignment constructor. You can assign tracklets!
136   ////
137   fNClusters=t.fNClusters;
138   fSector=t.fSector;
139   if (this!=&t) {
140     if (t.fOuter) {
141       if (fOuter)
142         *fOuter=*t.fOuter;
143       else
144         fOuter=new AliExternalTrackParam(*t.fOuter);
145     }
146     else {
147       delete fOuter;
148       fOuter=0;
149     }
150
151     if (t.fInner) {
152       if (fInner)
153         *fInner=*t.fInner;
154       else
155         fInner=new AliExternalTrackParam(*t.fInner);
156     }
157     else {
158       delete fInner;
159       fInner=0;
160     }
161
162     if (t.fPrimary) {
163       if (fPrimary)
164         *fPrimary=*t.fPrimary;
165       else
166         fPrimary=new AliExternalTrackParam(*t.fPrimary);
167     }
168     else {
169       delete fPrimary;
170       fPrimary=0;
171     }
172   }
173   return *this;
174 }
175
176 AliTPCTracklet::~AliTPCTracklet() {
177   //
178   // The destructor. Yes, you can even destruct tracklets.
179   //
180   delete fOuter;
181   delete fInner;
182   delete fPrimary;
183 }
184
185 TObjArray AliTPCTracklet::CreateTracklets(const AliTPCseed *s,
186                                           Int_t minClusters,
187                                           Int_t maxTracklets) {
188 // The tracklet factory: It creates several tracklets out of a track. They
189 // are created for sectors that fullfill the constraint of having enough
190 // clusters inside. Futhermore you can specify the maximum amount of
191 // tracklets that are to be created.
192 // The tracklets appear in a sorted fashion, beginning with those having the
193 // most clusters.
194
195   Int_t sectors[72]={0};
196   for (Int_t i=0;i<160;++i) {
197     AliTPCclusterMI *c=s->GetClusterPointer(i);
198     if (c)
199       ++sectors[c->GetDetector()];
200   }
201   Int_t indices[72];
202   TMath::Sort(72,sectors,indices);
203   TObjArray tracklets;
204   if (maxTracklets>72) maxTracklets=72; // just to protect against "users".
205   for (Int_t i=0;i<maxTracklets&&sectors[indices[i]]>=minClusters;++i) {
206     tracklets.Add(new AliTPCTracklet(s,indices[i]));
207   }
208   return tracklets;
209 }