]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/UPGRADE/AliITSUTrackerGlo.cxx
-update of v2 task
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUTrackerGlo.cxx
CommitLineData
32d38de2 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 TO CHECK
18 GetBz usage
19
20 */
21
22//-------------------------------------------------------------------------
23// Implementation of the ITS Upgrade tracker mother class.
24//-------------------------------------------------------------------------
25#include <TTree.h>
26#include <Riostream.h>
27#include <TMath.h>
28
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"
c61e50c3 38#include "AliITSUClusterPix.h"
32d38de2 39using namespace AliITSUAux;
40using namespace TMath;
41
42
c8d1f258 43//----------------- tmp stuff -----------------
44Int_t currLabel=-1;
45
46
32d38de2 47ClassImp(AliITSUTrackerGlo)
48//_________________________________________________________________________
49AliITSUTrackerGlo::AliITSUTrackerGlo(AliITSUReconstructor* rec)
50: fReconstructor(rec)
51 ,fITS(0)
0091e9f0 52 ,fCurrESDtrack(0)
32d38de2 53 ,fCurrMass(kPionMass)
c61e50c3 54 ,fSeedsLr(0)
55 ,fSeedsPool("AliITSUSeed",0)
c8d1f258 56 ,fTrCond()
32d38de2 57{
58 // Default constructor
59 if (rec) Init(rec);
60}
61
62//_________________________________________________________________________
63AliITSUTrackerGlo::~AliITSUTrackerGlo()
64{
65 // Default destructor
66 //
67 delete fITS;
c61e50c3 68 delete[] fSeedsLr;
32d38de2 69 //
70}
71
72//_________________________________________________________________________
73void AliITSUTrackerGlo::Init(AliITSUReconstructor* rec)
74{
75 // init with external reconstructor
c61e50c3 76 //
32d38de2 77 fITS = new AliITSURecoDet(rec->GetGeom(),"ITSURecoInterface");
78 for (int ilr=fITS->GetNLayersActive();ilr--;) {
79 fITS->GetLayerActive(ilr)->SetClusters(rec->GetClusters(ilr));
80 }
c61e50c3 81 //
82 fSeedsPool.ExpandCreateFast(1000); // RS TOCHECK
83 int n = fITS->GetNLayersActive()+1;
84 fSeedsLr = new TObjArray[n];
85 //
c8d1f258 86 fTrCond.SetNLayers(fITS->GetNLayersActive());
87 fTrCond.AddNewCondition(5);
88 fTrCond.AddGroupPattern( (0x1<<0)|(0x1<<1) );
89 fTrCond.AddGroupPattern( (0x1<<3)|(0x1<<4) );
90 fTrCond.AddGroupPattern( (0x1<<5)|(0x1<<6) );
91 //
92 fTrCond.AddNewCondition(5);
93 fTrCond.AddGroupPattern( (0x1<<0)|(0x1<<2) );
94 fTrCond.AddGroupPattern( (0x1<<3)|(0x1<<4) );
95 fTrCond.AddGroupPattern( (0x1<<5)|(0x1<<6) );
96 //
97 fTrCond.AddNewCondition(5);
98 fTrCond.AddGroupPattern( (0x1<<1)|(0x1<<2) );
99 fTrCond.AddGroupPattern( (0x1<<3)|(0x1<<4) );
100 fTrCond.AddGroupPattern( (0x1<<5)|(0x1<<6) );
101 //
102 printf("Tracking Conditions: ");
103 fTrCond.Print();
32d38de2 104}
105
106//_________________________________________________________________________
107Int_t AliITSUTrackerGlo::Clusters2Tracks(AliESDEvent *esdEv)
108{
109 //
110 //
dde91d5d 111 AliITSUReconstructor::GetRecoParam()->Print();
112
32d38de2 113 fITS->ProcessClusters();
114 // select ESD tracks to propagate
115 int nTrESD = esdEv->GetNumberOfTracks();
116 for (int itr=0;itr<nTrESD;itr++) {
117 AliESDtrack *esdTr = esdEv->GetTrack(itr);
0091e9f0 118 AliInfo(Form("Processing track %d | MCLabel: %d",itr,esdTr->GetTPCLabel()));
c8d1f258 119 currLabel = Abs(esdTr->GetTPCLabel());
32d38de2 120 FindTrack(esdTr);
121 }
122
123 return 0;
124}
125
126//_________________________________________________________________________
127Int_t AliITSUTrackerGlo::PropagateBack(AliESDEvent * /*event*/)
128{
129 //
130 // To be implemented
131 //
132
133 Info("PropagateBack","To be implemented");
134 return 0;
135}
136
137//_________________________________________________________________________
138Int_t AliITSUTrackerGlo::RefitInward(AliESDEvent * /*event*/)
139{
140 //
141 // To be implemented
142 //
143
144 Info("RefitInward","To be implemented");
145 return 0;
146}
147
148//_________________________________________________________________________
149Int_t AliITSUTrackerGlo::LoadClusters(TTree * treeRP)
150{
151 // read from tree (if pointer provided) or directly from the ITS reco interface
152 //
153 return fReconstructor->LoadClusters(treeRP);
154}
155
156//_________________________________________________________________________
157void AliITSUTrackerGlo::UnloadClusters()
158{
159 //
160 // To be implemented
161 //
162
163 Info("UnloadClusters","To be implemented");
164}
165//_________________________________________________________________________
166AliCluster * AliITSUTrackerGlo::GetCluster(Int_t /*index*/) const
167{
168 //
169 // To be implemented
170 //
171
172 Info("GetCluster","To be implemented");
173 return 0x0;
174}
175
176//_________________________________________________________________________
177Bool_t AliITSUTrackerGlo::NeedToProlong(AliESDtrack* esdTr)
178{
179 // do we need to match this track to ITS?
180 //
181 static double bz = GetBz();
182 if (!esdTr->IsOn(AliESDtrack::kTPCin) ||
183 esdTr->IsOn(AliESDtrack::kTPCout) ||
184 esdTr->IsOn(AliESDtrack::kITSin) ||
185 esdTr->GetKinkIndex(0)>0) return kFALSE;
186 //
c61e50c3 187 if (esdTr->Pt()<AliITSUReconstructor::GetRecoParam()->GetMinPtForProlongation()) return kFALSE;
32d38de2 188 //
189 float dtz[2];
190 esdTr->GetDZ(GetX(),GetY(),GetZ(),bz,dtz);
191 // if track is not V0 candidata but has large offset wrt IP, reject it. RS TOCHECK
c61e50c3 192 if ( !(esdTr->GetV0Index(0)>0 && dtz[0]>AliITSUReconstructor::GetRecoParam()->GetMaxDforV0dghtrForProlongation())
193 && (Abs(dtz[0])>AliITSUReconstructor::GetRecoParam()->GetMaxDForProlongation() ||
194 Abs(dtz[1])>AliITSUReconstructor::GetRecoParam()->GetMaxDZForProlongation())) return kFALSE;
32d38de2 195 //
196 return kTRUE;
197}
198
199//_________________________________________________________________________
200void AliITSUTrackerGlo::FindTrack(AliESDtrack* esdTr)
201{
202 // find prolongaion candidates finding for single seed
203 //
204 if (!NeedToProlong(esdTr)) return; // are we interested in this track?
c61e50c3 205 if (!InitSeed(esdTr)) return; // initialize prolongations hypotheses tree
32d38de2 206 //
173b3073 207 AliITSURecoSens *hitSens[AliITSURecoSens::kNNeighbors+1];
f8832015 208 AliITSUSeed seedUC; // copy of the seed from the upper layer
209 AliITSUSeed seedT; // transient seed between the seedUC and new prolongation hypothesis
210 //
c61e50c3 211 TObjArray clArr; // container for transfer of clusters matching to seed
32d38de2 212 //
213 for (int ila=fITS->GetNLayersActive();ila--;) {
214 int ilaUp = ila+1; // prolong seeds from layer above
215 int nSeedsUp = GetNSeeds(ilaUp);
216 for (int isd=0;isd<nSeedsUp;isd++) {
c61e50c3 217 AliITSUSeed* seedU = GetSeed(ilaUp,isd); // seed on prev.active layer to prolong
3dd9c283 218 seedUC = *seedU; // its copy will be prolonged
f8832015 219 seedUC.SetParent(seedU);
32d38de2 220 // go till next active layer
c8d1f258 221 AliInfo(Form("working on Lr:%d Seed:%d of %d",ila,isd,nSeedsUp));
f8832015 222 if (!TransportToLayer(&seedUC, fITS->GetLrIDActive(ilaUp), fITS->GetLrIDActive(ila)) ) {
32d38de2 223 //
0091e9f0 224 AliInfo("Transport failed");
32d38de2 225 // Check if the seed satisfies to track definition
3dd9c283 226 if (NeedToKill(&seedUC,kTransportFailed)) seedU->Kill();
32d38de2 227 continue; // RS TODO: decide what to do with tracks stopped on higher layers w/o killing
228 }
229 AliITSURecoLayer* lrA = fITS->GetLayerActive(ila);
f8832015 230 if (!GetRoadWidth(&seedUC, ila)) { // failed to find road width on the layer
3dd9c283 231 if (NeedToKill(&seedUC,kRWCheckFailed)) seedU->Kill();
32d38de2 232 continue;
233 }
173b3073 234 int nsens = lrA->FindSensors(&fTrImpData[kTrPhi0], hitSens); // find detectors which may be hit by the track
0091e9f0 235 AliInfo(Form("Will check %d sensors on lr:%d ",nsens,ila));
32d38de2 236 //
237 for (int isn=nsens;isn--;) {
f8832015 238 seedT = seedUC;
c61e50c3 239 AliITSURecoSens* sens = hitSens[isn];
f8832015 240 //
241 if (!seedT.Propagate(sens->GetPhiTF(),sens->GetXTF(),GetBz())) continue; // propagation failed, seedT is intact
242 int clID0 = sens->GetFirstClusterId();
c61e50c3 243 for (int icl=sens->GetNClusters();icl--;) {
f8832015 244 int res = CheckCluster(&seedT,ila,clID0+icl);
245 //
246 if (res==kStopSearchOnSensor) break; // stop looking on this sensor
247 if (res==kClusterNotMatching) continue; // cluster does not match
248 // cluster is matching and it was added to the hypotheses tree
c61e50c3 249 }
32d38de2 250 }
f8832015 251 // cluster search is done. Do we need ta have a version of this seed skipping current layer
252 seedT.SetLr(ila);
253 if (!NeedToKill(&seedT,kMissingCluster)) AddProlongationHypothesis(NewSeedFromPool(&seedT) ,ila);
32d38de2 254 }
c8d1f258 255 printf(">>> All hypotheses on lr %d: \n",ila);
256 for (int ih=0;ih<GetNSeeds(ila);ih++) {
257 printf(" #%3d ",ih); GetSeed(ila,ih)->Print();
258 }
32d38de2 259 }
260 //
c61e50c3 261 ResetSeedTree();
32d38de2 262}
263
264//_________________________________________________________________________
265Bool_t AliITSUTrackerGlo::InitSeed(AliESDtrack *esdTr)
266{
c61e50c3 267 // init prolongaion candidates finding for single seed
32d38de2 268 fCurrMass = esdTr->GetMass();
0091e9f0 269 fCurrESDtrack = esdTr;
32d38de2 270 if (fCurrMass<kPionMass*0.9) fCurrMass = kPionMass; // don't trust to mu, e identification from TPCin
c61e50c3 271 //
c8d1f258 272 //
c61e50c3 273 AliITSUSeed* seed = NewSeedFromPool();
dde91d5d 274 seed->SetLr(fITS->GetNLayersActive()); // fake layer
c61e50c3 275 seed->AliExternalTrackParam::operator=(*esdTr);
276 seed->SetParent(esdTr);
f8832015 277 AddProlongationHypothesis(seed,fITS->GetNLayersActive());
32d38de2 278 return kTRUE;
279 // TO DO
280}
281
c61e50c3 282//_________________________________________________________________________
283void AliITSUTrackerGlo::ResetSeedTree()
284{
285 // reset current hypotheses tree
c8d1f258 286 for (int i=fITS->GetNLayersActive()+1;i--;) fSeedsLr[i].Clear();
c61e50c3 287}
288
32d38de2 289//_________________________________________________________________________
290Bool_t AliITSUTrackerGlo::TransportToLayer(AliITSUSeed* seed, Int_t lFrom, Int_t lTo)
291{
292 // transport seed from layerFrom to the entrance of layerTo
293 //
294 const double kToler = 1e-6; // tolerance for layer on-surface check
295 //
296 int dir = lTo > lFrom ? 1:-1;
297 AliITSURecoLayer* lrFr = fITS->GetLayer(lFrom); // this can be 0 when extrapolation from TPC to ITS is requested
298 Bool_t checkFirst = kTRUE;
299 while(lFrom!=lTo) {
300 double curR2 = seed->GetX()*seed->GetX() + seed->GetY()*seed->GetY(); // current radius
301 if (lrFr) {
302 Bool_t doLayer = kTRUE;
303 double xToGo = dir>0 ? lrFr->GetRMax() : lrFr->GetRMin();
304 if (checkFirst) { // do we need to track till the surface of the current layer ?
305 checkFirst = kFALSE;
306 if (dir>0) { if (curR2-xToGo*xToGo>kToler) doLayer = kFALSE; } // on the surface or outside of the layer
307 else if (dir<0) { if (xToGo*xToGo-curR2>kToler) doLayer = kFALSE; } // on the surface or outside of the layer
308 }
309 if (doLayer) {
310 if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE;
311 // go via layer to its boundary, applying material correction.
44785f3e 312 if (!PropagateSeed(seed,xToGo,fCurrMass, lrFr->GetMaxStep())) return kFALSE;
32d38de2 313 }
314 }
315 AliITSURecoLayer* lrTo = fITS->GetLayer( (lFrom+=dir) );
316 if (!lrTo) AliFatal(Form("Layer %d does not exist",lFrom));
317 //
318 // go the entrance of the layer, assuming no materials in between
319 double xToGo = dir>0 ? lrTo->GetRMin() : lrTo->GetRMax();
dde91d5d 320 if (!seed->GetXatLabR(xToGo,xToGo,GetBz(),dir)) return kFALSE;
44785f3e 321 if (!PropagateSeed(seed,xToGo,fCurrMass,100, kFALSE )) return kFALSE;
32d38de2 322 lrFr = lrTo;
323 }
324 return kTRUE;
325 //
326}
327
328//_________________________________________________________________________
c61e50c3 329Bool_t AliITSUTrackerGlo::GetRoadWidth(AliITSUSeed* seed, int ilrA)
32d38de2 330{
331 // calculate road width in terms of phi and z for the track which MUST be on the external radius of the layer
332 // as well as some aux info
333 double bz = GetBz();
334 AliITSURecoLayer* lrA = fITS->GetLayerActive(ilrA);
c61e50c3 335 seed->GetXYZ(&fTrImpData[kTrXIn]); // lab position at the entrance from above
32d38de2 336 //
c61e50c3 337 fTrImpData[kTrPhiIn] = ATan2(fTrImpData[kTrYIn],fTrImpData[kTrXIn]);
338 if (!seed->Rotate(fTrImpData[kTrPhiIn])) return kFALSE; // go to the frame of the entry point into the layer
339 double dr = lrA->GetDR(); // approximate X dist at the inner radius
340 if (!seed->GetXYZAt(seed->GetX()-dr, bz, fTrImpData + kTrXOut)) {
32d38de2 341 // special case: track does not reach inner radius, might be tangential
342 double r = seed->GetD(0,0,bz);
343 double x;
344 if (!seed->GetXatLabR(r,x,bz,-1)) {
345 AliError(Form("This should not happen: r=%f",r));
346 seed->Print();
347 return kFALSE;
348 }
349 dr = Abs(seed->GetX() - x);
c61e50c3 350 if (!seed->GetXYZAt(x, bz, fTrImpData + kTrXOut)) {
32d38de2 351 AliError(Form("This should not happen: x=%f",x));
352 seed->Print();
353 return kFALSE;
354 }
355 }
356 //
c61e50c3 357 fTrImpData[kTrPhiOut] = ATan2(fTrImpData[kTrYOut],fTrImpData[kTrXOut]);
358 double sgy = seed->GetSigmaY2() + dr*dr*seed->GetSigmaSnp2() + AliITSUReconstructor::GetRecoParam()->GetSigmaY2(ilrA);
359 double sgz = seed->GetSigmaZ2() + dr*dr*seed->GetSigmaTgl2() + AliITSUReconstructor::GetRecoParam()->GetSigmaZ2(ilrA);
360 sgy = Sqrt(sgy)*AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadY();
361 sgz = Sqrt(sgz)*AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadZ();
362 fTrImpData[kTrPhi0] = 0.5*(fTrImpData[kTrPhiOut]+fTrImpData[kTrPhiIn]);
173b3073 363 fTrImpData[kTrZ0] = 0.5*(fTrImpData[kTrZOut]+fTrImpData[kTrZIn]);
c61e50c3 364 fTrImpData[kTrDPhi] = 0.5*Abs(fTrImpData[kTrPhiOut]-fTrImpData[kTrPhiIn]) + sgy/lrA->GetR();
173b3073 365 fTrImpData[kTrDZ] = 0.5*Abs(fTrImpData[kTrZOut]-fTrImpData[kTrZIn]) + sgz;
32d38de2 366 //
367 return kTRUE;
368}
369
370//_________________________________________________________________________
c61e50c3 371AliITSUSeed* AliITSUTrackerGlo::NewSeedFromPool(const AliITSUSeed* src)
32d38de2 372{
373 // create new seed, optionally copying from the source
374 return src ?
375 new(fSeedsPool[fSeedsPool.GetEntriesFast()]) AliITSUSeed(*src) :
376 new(fSeedsPool[fSeedsPool.GetEntriesFast()]) AliITSUSeed();
377}
f8832015 378
379//_________________________________________________________________________
380Int_t AliITSUTrackerGlo::CheckCluster(AliITSUSeed* track, Int_t lr, Int_t clID)
381{
382 // Check if the cluster (in tracking frame!) is matching to track.
383 // The track must be already propagated to sensor tracking frame.
384 // Returns: kStopSearchOnSensor if the search on given sensor should be stopped,
385 // kClusterMatching if the cluster is matching
386 // kClusterMatching otherwise
387 //
388 // The seed is already propagated to cluster
389 const double kTolerX = 5e-4;
390 AliCluster *cl = fITS->GetLayerActive(lr)->GetCluster(clID);
391 //
c8d1f258 392 Bool_t goodCl = kFALSE;
393 for (int i=0;i<3;i++) if (cl->GetLabel(i)>=0 && cl->GetLabel(i)==currLabel) goodCl = kTRUE;
394 //
f8832015 395 if (TMath::Abs(cl->GetX())>kTolerX) { // if due to the misalingment X is large, propagate track only
c8d1f258 396 if (!track->PropagateParamOnlyTo(track->GetX()+cl->GetX(),GetBz())) {
3dd9c283 397 if (goodCl) {printf("Loose good cl: Failed propagation. |"); cl->Print();}
c8d1f258 398 return kStopSearchOnSensor; // propagation failed, seedT is intact
399 }
f8832015 400 }
3dd9c283 401 double dy = cl->GetY()-track->GetY();
c8d1f258 402 double dz = cl->GetZ()-track->GetZ();
0091e9f0 403 //
f8832015 404 double dy2 = dy*dy;
405 double tol2 = (track->GetSigmaY2() + AliITSUReconstructor::GetRecoParam()->GetSigmaY2(lr))*
406 AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadY()*AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadY(); // RS TOOPTIMIZE
407 if (dy2>tol2) { // the clusters are sorted in Z(col) then in Y(row).
3dd9c283 408 if (goodCl) {printf("Loose good cl: dy2=%e > tol2=%e |",dy2,tol2); cl->Print();}
f8832015 409 if (dy>0) return kStopSearchOnSensor; // No chance that other cluster of this sensor will match (all Y's will be even larger)
410 else return kClusterNotMatching; // Other clusters may match
411 }
c8d1f258 412 double dz2 = dz*dz;
f8832015 413 tol2 = (track->GetSigmaZ2() + AliITSUReconstructor::GetRecoParam()->GetSigmaZ2(lr))*
414 AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadZ()*AliITSUReconstructor::GetRecoParam()->GetNSigmaRoadZ(); // RS TOOPTIMIZE
c8d1f258 415 if (dz2>tol2) {
3dd9c283 416 if (goodCl) {printf("Loose good cl: dz2=%e > tol2=%e |",dz2,tol2); cl->Print();}
c8d1f258 417 return kClusterNotMatching; // Other clusters may match
418 }
f8832015 419 //
420 // check chi2
421 Double_t p[2]={cl->GetY(), cl->GetZ()};
422 Double_t cov[3]={cl->GetSigmaY2(), cl->GetSigmaYZ(), cl->GetSigmaZ2()};
423 double chi2 = track->GetPredictedChi2(p,cov);
c8d1f258 424 if (chi2>AliITSUReconstructor::GetRecoParam()->GetMaxTr2ClChi2(lr)) {
3dd9c283 425 if (goodCl) {
426 printf("Loose good cl: Chi2=%e > Chi2Max=%e \n",chi2,AliITSUReconstructor::GetRecoParam()->GetMaxTr2ClChi2(lr));
427 track->Print("etp");
428 cl->Print("");
429 }
c8d1f258 430 return kClusterNotMatching;
431 }
f8832015 432 //
433 track = NewSeedFromPool(track); // input track will be reused, use its clone for updates
c8d1f258 434 if (!track->Update(p,cov)) {
3dd9c283 435 if (goodCl) {printf("Loose good cl: Failed update |"); cl->Print();}
c8d1f258 436 return kClusterNotMatching;
437 }
f8832015 438 track->SetChi2Cl(chi2);
439 track->SetLrClusterID(lr,clID);
440 cl->IncreaseClusterUsage();
441 //
c8d1f258 442 AliInfo(Form("AddCl Cl%d lr:%d: dY:%+8.4f dZ:%+8.4f (MC: %5d %5d %5d) |Chi2=%f",clID,lr,dy,dz2,cl->GetLabel(0),cl->GetLabel(1),cl->GetLabel(2), chi2));
443 //
f8832015 444 AddProlongationHypothesis(track,lr);
445 //
446 return kClusterMatching;
447}
c8d1f258 448
449//_________________________________________________________________________
450Bool_t AliITSUTrackerGlo::NeedToKill(AliITSUSeed *seed, Int_t flag)
451{
452 // check if the seed should not be discarded
453 const UShort_t kMask = 0xffff;
454 if (flag==kMissingCluster) {
455 int lastChecked = seed->GetLayerID();
456 UShort_t patt = seed->GetHitsPattern();
457 if (lastChecked) patt |= ~(kMask<<lastChecked); // not all layers were checked, complete unchecked once by potential hits
458 Bool_t seedOK = fTrCond.CheckPattern(patt);
459 return !seedOK;
460 }
461 return kTRUE;
462}
44785f3e 463
464//______________________________________________________________________________
465Bool_t AliITSUTrackerGlo::PropagateSeed(AliITSUSeed *seed, Double_t xToGo, Double_t mass, Double_t maxStep, Bool_t matCorr)
466{
467 // propagate seed to given x applying material correction if requested
468 const Double_t kEpsilon = 1e-5;
469 Double_t xpos = seed->GetX();
470 Int_t dir = (xpos<xToGo) ? 1:-1;
471 Double_t xyz0[3],xyz1[3],param[7];
472 //
473 if (matCorr) seed->GetXYZ(xyz1); //starting global position
474 while ( (xToGo-xpos)*dir > kEpsilon){
475 Double_t step = dir*TMath::Min(TMath::Abs(xToGo-xpos), maxStep);
476 Double_t x = xpos+step;
477 Double_t bz=GetBz(); // getting the local Bz
478 if (!seed->PropagateToX(x,bz)) return kFALSE;
479 if (matCorr) {
480 xyz0[0]=xyz1[0]; // global pos at the beginning of step
481 xyz0[1]=xyz1[1];
482 xyz0[2]=xyz1[2];
483 seed->GetXYZ(xyz1); // // global pos at the end of step
484 MeanMaterialBudget(xyz0,xyz1,param);
485 Double_t xrho=param[0]*param[4], xx0=param[1];
486 if (dir>0) xrho = -xrho; // outward should be negative
487 if (!seed->ApplyMaterialCorrection(xx0,xrho,mass,kFALSE)) return kFALSE;
488 }
489 xpos = seed->GetX();
490 }
491 return kTRUE;
492}