@@ -26,7 +26,7 @@ namespace fastsim
2626FastTracker::FastTracker ()
2727{
2828 // base constructor
29- magneticField = 5 ; // in kiloGauss
29+ magneticField = 20 ; // in kiloGauss
3030 applyZacceptance = false ;
3131 covMatFactor = 0 .99f ;
3232 verboseLevel = 0 ;
@@ -45,6 +45,20 @@ void FastTracker::AddLayer(TString name, float r, float z, float x0, float xrho,
4545 layers.push_back (newLayer);
4646}
4747
48+ DetLayer FastTracker::GetLayer (int layer, bool ignoreBarrelLayers)
49+ {
50+ int layerIdx = layer;
51+ if (ignoreBarrelLayers) {
52+ for (int il = 0 , trackingLayerIdx = 0 ; trackingLayerIdx <= layer; il++) {
53+ if (layers[il].type == 0 )
54+ continue ;
55+ trackingLayerIdx++;
56+ layerIdx = il;
57+ }
58+ }
59+ return layers[layerIdx];
60+ }
61+
4862void FastTracker::Print ()
4963{
5064 // print out layer setup
@@ -170,31 +184,58 @@ int FastTracker::FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa
170184 std::array<float , 3 > posIni; // provision for != PV
171185 inputTrack.getXYZGlo (posIni);
172186 float initialRadius = std::hypot (posIni[0 ], posIni[1 ]);
187+ float kTrackingMargin = 0.1 ;
188+ int xrhosteps = 100 ;
189+ bool applyAngularCorrection = true ;
173190
174191 // +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+
175192 // Outward pass to find intercepts
176193 int firstLayerReached = -1 ;
177194 int lastLayerReached = -1 ;
195+ new (&outputTrack)(o2::track::TrackParCov)(inputTrack);
178196 for (uint32_t il = 0 ; il < layers.size (); il++) {
179197 // check if layer is doable
180198 if (layers[il].r < initialRadius)
181199 continue ; // this layer should not be attempted, but go ahead
182- if (layers[il].type == 0 )
183- continue ; // inert layer, skip
184200
185201 // check if layer is reached
186202 float targetX = 1e+3 ;
203+ bool ok = true ;
187204 inputTrack.getXatLabR (layers[il].r , targetX, magneticField);
188205 if (targetX > 999 )
189206 break ; // failed to find intercept
190207
191- if (!inputTrack.propagateTo (targetX, magneticField)) {
192- break ; // failed to propagate
208+ ok = inputTrack.propagateTo (targetX, magneticField);
209+ if (ok && applyMSCorrection && layers[il].x0 > 0 ) {
210+ ok = inputTrack.correctForMaterial (layers[il].x0 , 0 , applyAngularCorrection);
211+ }
212+ if (ok && applyElossCorrection && layers[il].xrho > 0 ) { // correct in small steps
213+ for (int ise = xrhosteps; ise--;) {
214+ ok = inputTrack.correctForMaterial (0 , -layers[il].xrho / xrhosteps, applyAngularCorrection);
215+ if (!ok)
216+ break ;
217+ }
218+ }
219+
220+ // was there a problem on this layer?
221+ if (!ok && il > 0 ) { // may fail to reach target layer due to the eloss
222+ float rad2 = inputTrack.getX () * inputTrack.getX () + inputTrack.getY () * inputTrack.getY ();
223+ float fMinRadTrack = 132 .;
224+ float maxR = layers[il - 1 ].r + kTrackingMargin * 2 ;
225+ float minRad = (fMinRadTrack > 0 && fMinRadTrack < maxR) ? fMinRadTrack : maxR;
226+ if (rad2 - minRad * minRad < kTrackingMargin * kTrackingMargin ) { // check previously reached layer
227+ return -5 ; // did not reach min requested layer
228+ } else {
229+ break ;
230+ }
193231 }
194232 if (std::abs (inputTrack.getZ ()) > layers[il].z && applyZacceptance) {
195233 break ; // out of acceptance bounds
196234 }
197235
236+ if (layers[il].type == 0 )
237+ continue ; // inert layer, skip
238+
198239 // layer is reached
199240 if (firstLayerReached < 0 )
200241 firstLayerReached = il;
@@ -204,7 +245,7 @@ int FastTracker::FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa
204245
205246 // +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+
206247 // initialize track at outer point
207- new (&outputTrack)( o2::track::TrackParCov) (inputTrack);
248+ o2::track::TrackParCov inwardTrack (inputTrack);
208249
209250 // Enlarge covariance matrix
210251 std::array<float , 5 > trPars = {0 .};
@@ -241,14 +282,12 @@ int FastTracker::FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa
241282 largeCov[kSnp2 ] = largeCov[kTgl2 ] = kLargeErr2Dir ;
242283 largeCov[kPtI2 ] = kLargeErr2PtI * trPars[kPtI ] * trPars[kPtI ];
243284
244- outputTrack .setCov (largeCov);
245- outputTrack .checkCovariance ();
285+ inwardTrack .setCov (largeCov);
286+ inwardTrack .checkCovariance ();
246287
247288 // +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+
248289 // Inward pass to calculate covariances
249290 for (int il = lastLayerReached; il >= firstLayerReached; il--) {
250- if (layers[il].type == 0 )
251- continue ; // inert layer, skip
252291
253292 float targetX = 1e+3 ;
254293 inputTrack.getXatLabR (layers[il].r , targetX, magneticField);
@@ -258,6 +297,7 @@ int FastTracker::FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa
258297 if (!inputTrack.propagateTo (targetX, magneticField)) {
259298 continue ; // failed to propagate
260299 }
300+
261301 if (std::abs (inputTrack.getZ ()) > layers[il].z && applyZacceptance) {
262302 continue ; // out of acceptance bounds but continue inwards
263303 }
@@ -268,20 +308,42 @@ int FastTracker::FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa
268308 std::vector<float > thisHit = {spacePoint[0 ], spacePoint[1 ], spacePoint[2 ]};
269309
270310 // towards adding cluster: move to track alpha
271- double alpha = outputTrack .getAlpha ();
311+ double alpha = inwardTrack .getAlpha ();
272312 double xyz1[3 ]{
273313 TMath::Cos (alpha) * spacePoint[0 ] + TMath::Sin (alpha) * spacePoint[1 ],
274314 -TMath::Sin (alpha) * spacePoint[0 ] + TMath::Cos (alpha) * spacePoint[1 ],
275315 spacePoint[2 ]};
276- if (!(outputTrack .propagateTo (xyz1[0 ], magneticField) ))
316+ if (!inwardTrack .propagateTo (xyz1[0 ], magneticField))
277317 continue ;
278318
279- const o2::track::TrackParametrization<float >::dim2_t hitpoint = {
280- static_cast <float >(xyz1[1 ]),
281- static_cast <float >(xyz1[2 ])};
282- const o2::track::TrackParametrization<float >::dim3_t hitpointcov = {layers[il].resRPhi * layers[il].resRPhi , 0 .f , layers[il].resZ * layers[il].resZ };
283- outputTrack.update (hitpoint, hitpointcov);
284- outputTrack.checkCovariance ();
319+ if (layers[il].type != 0 ) { // only update covm for tracker hits
320+ const o2::track::TrackParametrization<float >::dim2_t hitpoint = {
321+ static_cast <float >(xyz1[1 ]),
322+ static_cast <float >(xyz1[2 ])};
323+ const o2::track::TrackParametrization<float >::dim3_t hitpointcov = {layers[il].resRPhi * layers[il].resRPhi , 0 .f , layers[il].resZ * layers[il].resZ };
324+
325+ inwardTrack.update (hitpoint, hitpointcov);
326+ inwardTrack.checkCovariance ();
327+ }
328+
329+ if (applyMSCorrection && layers[il].x0 > 0 ) {
330+ if (!inputTrack.correctForMaterial (layers[il].x0 , 0 , applyAngularCorrection)) {
331+ return -6 ;
332+ }
333+ if (!inwardTrack.correctForMaterial (layers[il].x0 , 0 , applyAngularCorrection)) {
334+ return -6 ;
335+ }
336+ }
337+ if (applyElossCorrection && layers[il].xrho > 0 ) {
338+ for (int ise = xrhosteps; ise--;) { // correct in small steps
339+ if (!inputTrack.correctForMaterial (0 , layers[il].xrho / xrhosteps, applyAngularCorrection)) {
340+ return -7 ;
341+ }
342+ if (!inwardTrack.correctForMaterial (0 , layers[il].xrho / xrhosteps, applyAngularCorrection)) {
343+ return -7 ;
344+ }
345+ }
346+ }
285347
286348 if (layers[il].type == 1 )
287349 nSiliconPoints++; // count silicon hits
@@ -293,18 +355,21 @@ int FastTracker::FastTrack(o2::track::TrackParCov inputTrack, o2::track::TrackPa
293355
294356 // backpropagate to original radius
295357 float finalX = 1e+3 ;
296- outputTrack .getXatLabR (initialRadius, finalX, magneticField);
358+ inwardTrack .getXatLabR (initialRadius, finalX, magneticField);
297359 if (finalX > 999 )
298360 return -3 ; // failed to find intercept
299361
300- if (!outputTrack .propagateTo (finalX, magneticField)) {
362+ if (!inwardTrack .propagateTo (finalX, magneticField)) {
301363 return -4 ; // failed to propagate
302364 }
303365
304366 // only attempt to continue if intercepts are at least four
305367 if (nIntercepts < 4 )
306368 return nIntercepts;
307369
370+ outputTrack.setCov (inwardTrack.getCov ());
371+ outputTrack.checkCovariance ();
372+
308373 // Use covariance matrix based smearing
309374 std::array<double , 15 > covMat = {0 .};
310375 for (int ii = 0 ; ii < 15 ; ii++)
0 commit comments