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 **************************************************************************/
22 //-------------------------------------------------------------------------
23 // Implementation of the ITS Upgrade tracker mother class.
24 //-------------------------------------------------------------------------
26 #include <Riostream.h>
29 #include "AliITSUTrackerGlo.h"
30 #include "AliESDEvent.h"
31 #include "AliESDtrack.h"
32 #include "AliITSURecoDet.h"
33 #include "AliITSURecoSens.h"
34 #include "AliITSUReconstructor.h"
35 #include "AliITSReconstructor.h"
36 #include "AliITSUSeed.h"
37 #include "AliITSUAux.h"
38 using namespace AliITSUAux;
39 using namespace TMath;
42 ClassImp(AliITSUTrackerGlo)
43 //_________________________________________________________________________
44 AliITSUTrackerGlo::AliITSUTrackerGlo(AliITSUReconstructor* rec)
48 ,fSeedsPool("AliITSUSeed",100)
50 // Default constructor
54 //_________________________________________________________________________
55 AliITSUTrackerGlo::~AliITSUTrackerGlo()
63 //_________________________________________________________________________
64 void AliITSUTrackerGlo::Init(AliITSUReconstructor* rec)
66 // init with external reconstructor
67 fITS = new AliITSURecoDet(rec->GetGeom(),"ITSURecoInterface");
68 for (int ilr=fITS->GetNLayersActive();ilr--;) {
69 fITS->GetLayerActive(ilr)->SetClusters(rec->GetClusters(ilr));
73 //_________________________________________________________________________
74 Int_t AliITSUTrackerGlo::Clusters2Tracks(AliESDEvent *esdEv)
78 fITS->ProcessClusters();
79 // select ESD tracks to propagate
80 int nTrESD = esdEv->GetNumberOfTracks();
81 for (int itr=0;itr<nTrESD;itr++) {
82 AliESDtrack *esdTr = esdEv->GetTrack(itr);
89 //_________________________________________________________________________
90 Int_t AliITSUTrackerGlo::PropagateBack(AliESDEvent * /*event*/)
96 Info("PropagateBack","To be implemented");
100 //_________________________________________________________________________
101 Int_t AliITSUTrackerGlo::RefitInward(AliESDEvent * /*event*/)
107 Info("RefitInward","To be implemented");
111 //_________________________________________________________________________
112 Int_t AliITSUTrackerGlo::LoadClusters(TTree * treeRP)
114 // read from tree (if pointer provided) or directly from the ITS reco interface
116 return fReconstructor->LoadClusters(treeRP);
119 //_________________________________________________________________________
120 void AliITSUTrackerGlo::UnloadClusters()
126 Info("UnloadClusters","To be implemented");
128 //_________________________________________________________________________
129 AliCluster * AliITSUTrackerGlo::GetCluster(Int_t /*index*/) const
135 Info("GetCluster","To be implemented");
139 //_________________________________________________________________________
140 Bool_t AliITSUTrackerGlo::NeedToProlong(AliESDtrack* esdTr)
142 // do we need to match this track to ITS?
144 static double bz = GetBz();
145 if (!esdTr->IsOn(AliESDtrack::kTPCin) ||
146 esdTr->IsOn(AliESDtrack::kTPCout) ||
147 esdTr->IsOn(AliESDtrack::kITSin) ||
148 esdTr->GetKinkIndex(0)>0) return kFALSE;
150 if (esdTr->Pt()<AliITSReconstructor::GetRecoParam()->GetMinPtForProlongation()) return kFALSE;
153 esdTr->GetDZ(GetX(),GetY(),GetZ(),bz,dtz);
154 // if track is not V0 candidata but has large offset wrt IP, reject it. RS TOCHECK
155 if ( !(esdTr->GetV0Index(0)>0 && dtz[0]>AliITSReconstructor::GetRecoParam()->GetMaxDforV0dghtrForProlongation())
156 && (Abs(dtz[0])>AliITSReconstructor::GetRecoParam()->GetMaxDForProlongation() ||
157 Abs(dtz[1])>AliITSReconstructor::GetRecoParam()->GetMaxDZForProlongation())) return kFALSE;
162 //_________________________________________________________________________
163 void AliITSUTrackerGlo::FindTrack(AliESDtrack* esdTr)
165 // find prolongaion candidates finding for single seed
167 if (!NeedToProlong(esdTr)) return; // are we interested in this track?
168 if (!InitSeed(esdTr)) return; // initialize prolongations hypotheses tree
170 double rwData[kNTrData];
171 AliITSURecoSens *hitSens[AliITSURecoSens::kNNeighbors];
174 for (int ila=fITS->GetNLayersActive();ila--;) {
175 int ilaUp = ila+1; // prolong seeds from layer above
176 int nSeedsUp = GetNSeeds(ilaUp);
177 for (int isd=0;isd<nSeedsUp;isd++) {
178 seed0 = *GetSeed(ilaUp,isd); // copy of the seed on prev.active layer
179 // go till next active layer
180 if (!TransportToLayer(&seed0, fITS->GetLrIDActive(ilaUp), fITS->GetLrIDActive(ila)) ) {
182 // Check if the seed satisfies to track definition
183 if (NeedToKill(&seed0,kTransportFailed)) KillSeed(ilaUp,isd);
184 continue; // RS TODO: decide what to do with tracks stopped on higher layers w/o killing
186 AliITSURecoLayer* lrA = fITS->GetLayerActive(ila);
187 if (!GetRoadWidth(&seed0, ila, rwData)) { // failed to find road width on the layer
188 if (NeedToKill(&seed0,kRWCheckFailed)) KillSeed(ilaUp,isd);
191 int nsens = lrA->FindSensors(&rwData[kTrPhi0], hitSens); // find detectors which may be hit by the track (max 4)
193 for (int isn=nsens;isn--;) {
203 //_________________________________________________________________________
204 Bool_t AliITSUTrackerGlo::InitSeed(AliESDtrack *esdTr)
206 // int prolongaion candidates finding for single seed
207 fCurrMass = esdTr->GetMass();
208 if (fCurrMass<kPionMass*0.9) fCurrMass = kPionMass; // don't trust to mu, e identification from TPCin
214 //_________________________________________________________________________
215 Bool_t AliITSUTrackerGlo::TransportToLayer(AliITSUSeed* seed, Int_t lFrom, Int_t lTo)
217 // transport seed from layerFrom to the entrance of layerTo
219 const double kToler = 1e-6; // tolerance for layer on-surface check
221 int dir = lTo > lFrom ? 1:-1;
222 AliITSURecoLayer* lrFr = fITS->GetLayer(lFrom); // this can be 0 when extrapolation from TPC to ITS is requested
223 Bool_t checkFirst = kTRUE;
225 double curR2 = seed->GetX()*seed->GetX() + seed->GetY()*seed->GetY(); // current radius
227 Bool_t doLayer = kTRUE;
228 double xToGo = dir>0 ? lrFr->GetRMax() : lrFr->GetRMin();
229 if (checkFirst) { // do we need to track till the surface of the current layer ?
231 if (dir>0) { if (curR2-xToGo*xToGo>kToler) doLayer = kFALSE; } // on the surface or outside of the layer
232 else if (dir<0) { if (xToGo*xToGo-curR2>kToler) doLayer = kFALSE; } // on the surface or outside of the layer
235 if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE;
236 // go via layer to its boundary, applying material correction.
237 if (!PropagateTrackTo(seed,xToGo,fCurrMass, lrFr->GetMaxStep(), kFALSE, -1, 0, kTRUE)) return kFALSE;
240 AliITSURecoLayer* lrTo = fITS->GetLayer( (lFrom+=dir) );
241 if (!lrTo) AliFatal(Form("Layer %d does not exist",lFrom));
243 // go the entrance of the layer, assuming no materials in between
244 double xToGo = dir>0 ? lrTo->GetRMin() : lrTo->GetRMax();
245 if (seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE;
246 if (!seed->PropagateTo(xToGo, GetBz())) return kFALSE; // RS: do we need BxByBz?
253 //_________________________________________________________________________
254 Bool_t AliITSUTrackerGlo::GetRoadWidth(AliITSUSeed* seed, int ilrA, double* rwData)
256 // calculate road width in terms of phi and z for the track which MUST be on the external radius of the layer
257 // as well as some aux info
259 AliITSURecoLayer* lrA = fITS->GetLayerActive(ilrA);
260 seed->GetXYZ(&rwData[kTrXIn]); // lab position at the entrance from above
262 rwData[kTrPhiIn] = ATan2(rwData[kTrYIn],rwData[kTrXIn]);
263 if (!seed->Rotate(rwData[kTrPhiIn])) return kFALSE; // go to the frame of the entry point into the layer
264 double dr = lrA->GetDR(); // approximate X dist at the inner radius
265 if (!seed->GetXYZAt(seed->GetX()-dr, bz, rwData + kTrXOut)) {
266 // special case: track does not reach inner radius, might be tangential
267 double r = seed->GetD(0,0,bz);
269 if (!seed->GetXatLabR(r,x,bz,-1)) {
270 AliError(Form("This should not happen: r=%f",r));
274 dr = Abs(seed->GetX() - x);
275 if (!seed->GetXYZAt(x, bz, rwData + kTrXOut)) {
276 AliError(Form("This should not happen: x=%f",x));
282 rwData[kTrPhiOut] = ATan2(rwData[kTrYOut],rwData[kTrXOut]);
283 double sgy = seed->GetSigmaY2() + dr*seed->GetSigmaSnp2() + AliITSReconstructor::GetRecoParam()->GetSigmaY2(ilrA);
284 double sgz = seed->GetSigmaZ2() + dr*seed->GetSigmaTgl2() + AliITSReconstructor::GetRecoParam()->GetSigmaZ2(ilrA);
285 sgy = Sqrt(sgy)*AliITSReconstructor::GetRecoParam()->GetNSigmaRoadY();
286 sgz = Sqrt(sgz)*AliITSReconstructor::GetRecoParam()->GetNSigmaRoadZ();
287 rwData[kTrPhi0] = 0.5*(rwData[kTrPhiOut]+rwData[kTrPhiIn]);
288 rwData[kTrZ0] = 0.5*(rwData[kTrZOut]+rwData[kTrPhiIn]);
289 rwData[kTrDPhi] = 0.5*Abs(rwData[kTrPhiOut]-rwData[kTrPhiIn]) + sgy/lrA->GetR();
290 rwData[kTrDZ] = 0.5*Abs(rwData[kTrZOut]-rwData[kTrPhiIn]) + sgz;
295 //_________________________________________________________________________
296 AliITSUSeed* AliITSUTrackerGlo::NewSeed(const AliITSUSeed* src)
298 // create new seed, optionally copying from the source
300 new(fSeedsPool[fSeedsPool.GetEntriesFast()]) AliITSUSeed(*src) :
301 new(fSeedsPool[fSeedsPool.GetEntriesFast()]) AliITSUSeed();