@@ -448,81 +448,6 @@ struct OnTheFlyTofPid {
448448 return outerTOFLayer.isTrackInActiveArea (track);
449449 }
450450
451- // / function to calculate track length of this track up to a certain radius
452- // / \param track the input track
453- // / \param radius the radius of the layer you're calculating the length to
454- // / \param magneticField the magnetic field to use when propagating
455- static float computeTrackLength (o2::track::TrackParCov track, float radius, float magneticField)
456- {
457- // don't make use of the track parametrization
458- float length = -100 ;
459-
460- o2::math_utils::CircleXYf_t trcCircle;
461- float sna, csa;
462- track.getCircleParams (magneticField, trcCircle, sna, csa);
463-
464- // distance between circle centers (one circle is at origin -> easy)
465- const float centerDistance = std::hypot (trcCircle.xC , trcCircle.yC );
466-
467- // condition of circles touching - if not satisfied returned length will be -100
468- if (centerDistance < trcCircle.rC + radius && centerDistance > std::fabs (trcCircle.rC - radius)) {
469- length = 0 .0f ;
470-
471- // base radical direction
472- const float ux = trcCircle.xC / centerDistance;
473- const float uy = trcCircle.yC / centerDistance;
474- // calculate perpendicular vector (normalized) for +/- displacement
475- const float vx = -uy;
476- const float vy = +ux;
477- // calculate coordinate for radical line
478- const float radical = (centerDistance * centerDistance - trcCircle.rC * trcCircle.rC + radius * radius) / (2 .0f * centerDistance);
479- // calculate absolute displacement from center-to-center axis
480- const float displace = (0 .5f / centerDistance) * std::sqrt (
481- (-centerDistance + trcCircle.rC - radius) *
482- (-centerDistance - trcCircle.rC + radius) *
483- (-centerDistance + trcCircle.rC + radius) *
484- (centerDistance + trcCircle.rC + radius));
485-
486- // possible intercept points of track and TOF layer in 2D plane
487- const float point1[2 ] = {radical * ux + displace * vx, radical * uy + displace * vy};
488- const float point2[2 ] = {radical * ux - displace * vx, radical * uy - displace * vy};
489-
490- // decide on correct intercept point
491- std::array<float , 3 > mom;
492- track.getPxPyPzGlo (mom);
493- const float scalarProduct1 = point1[0 ] * mom[0 ] + point1[1 ] * mom[1 ];
494- const float scalarProduct2 = point2[0 ] * mom[0 ] + point2[1 ] * mom[1 ];
495-
496- // get start point
497- std::array<float , 3 > startPoint;
498- track.getXYZGlo (startPoint);
499-
500- float cosAngle = -1000 , modulus = -1000 ;
501-
502- if (scalarProduct1 > scalarProduct2) {
503- modulus = std::hypot (point1[0 ] - trcCircle.xC , point1[1 ] - trcCircle.yC ) * std::hypot (startPoint[0 ] - trcCircle.xC , startPoint[1 ] - trcCircle.yC );
504- cosAngle = (point1[0 ] - trcCircle.xC ) * (startPoint[0 ] - trcCircle.xC ) + (point1[1 ] - trcCircle.yC ) * (startPoint[1 ] - trcCircle.yC );
505- } else {
506- modulus = std::hypot (point2[0 ] - trcCircle.xC , point2[1 ] - trcCircle.yC ) * std::hypot (startPoint[0 ] - trcCircle.xC , startPoint[1 ] - trcCircle.yC );
507- cosAngle = (point2[0 ] - trcCircle.xC ) * (startPoint[0 ] - trcCircle.xC ) + (point2[1 ] - trcCircle.yC ) * (startPoint[1 ] - trcCircle.yC );
508- }
509- cosAngle /= modulus;
510- length = trcCircle.rC * std::acos (cosAngle);
511- length *= std::sqrt (1 .0f + track.getTgl () * track.getTgl ());
512- }
513- return length;
514- }
515-
516- // / returns velocity in centimeters per picoseconds
517- // / \param momentum the momentum of the tarck
518- // / \param mass the mass of the particle
519- float computeParticleVelocity (float momentum, float mass)
520- {
521- const float a = momentum / mass;
522- // uses light speed in cm/ps so output is in those units
523- return o2::constants::physics::LightSpeedCm2PS * a / std::sqrt ((1 .f + a * a));
524- }
525-
526451 struct TracksWithTime {
527452 TracksWithTime (int pdgCode,
528453 std::pair<float , float > innerTOFTime,
@@ -696,8 +621,8 @@ struct OnTheFlyTofPid {
696621 }
697622 float trackLengthInnerTOF = -1 , trackLengthOuterTOF = -1 ;
698623 if (xPv > kTrkXThreshold ) {
699- trackLengthInnerTOF = computeTrackLength (o2track, simConfig.innerTOFRadius , mMagneticField );
700- trackLengthOuterTOF = computeTrackLength (o2track, simConfig.outerTOFRadius , mMagneticField );
624+ trackLengthInnerTOF = o2::upgrade:: computeTrackLength (o2track, simConfig.innerTOFRadius , mMagneticField );
625+ trackLengthOuterTOF = o2::upgrade:: computeTrackLength (o2track, simConfig.outerTOFRadius , mMagneticField );
701626 }
702627
703628 // Check if the track hit a sensitive area of the TOF
@@ -707,9 +632,7 @@ struct OnTheFlyTofPid {
707632 } else {
708633 float x = 0 .f ;
709634 o2track.getXatLabR (simConfig.innerTOFRadius , x, mMagneticField );
710- if (plotsConfig.doQAplots ) {
711- histos.fill (HIST (" iTOF/h2HitMap" ), o2track.getZAt (x, mMagneticField ), simConfig.innerTOFRadius * o2track.getPhiAt (x, mMagneticField ));
712- }
635+ histos.fill (HIST (" iTOF/h2HitMap" ), o2track.getZAt (x, mMagneticField ), simConfig.innerTOFRadius * o2track.getPhiAt (x, mMagneticField ));
713636 }
714637
715638 const bool activeOuterTOF = isInOuterTOFActiveArea (o2track);
@@ -718,9 +641,7 @@ struct OnTheFlyTofPid {
718641 } else {
719642 float x = 0 .f ;
720643 o2track.getXatLabR (simConfig.outerTOFRadius , x, mMagneticField );
721- if (plotsConfig.doQAplots ) {
722- histos.fill (HIST (" oTOF/h2HitMap" ), o2track.getZAt (x, mMagneticField ), simConfig.outerTOFRadius * o2track.getPhiAt (x, mMagneticField ));
723- }
644+ histos.fill (HIST (" oTOF/h2HitMap" ), o2track.getZAt (x, mMagneticField ), simConfig.outerTOFRadius * o2track.getPhiAt (x, mMagneticField ));
724645 }
725646
726647 // get mass to calculate velocity
@@ -730,7 +651,7 @@ struct OnTheFlyTofPid {
730651 upgradeTofMC (-999 .f , -999 .f , -999 .f , -999 .f );
731652 continue ;
732653 }
733- const float v = computeParticleVelocity (o2track.getP (), pdgInfo->Mass ());
654+ const float v = o2::upgrade:: computeParticleVelocity (o2track.getP (), pdgInfo->Mass ());
734655 const float expectedTimeInnerTOF = trackLengthInnerTOF > 0 ? trackLengthInnerTOF / v + eventCollisionTimePS : -999 .f ; // arrival time to the Inner TOF in ps
735656 const float expectedTimeOuterTOF = trackLengthOuterTOF > 0 ? trackLengthOuterTOF / v + eventCollisionTimePS : -999 .f ; // arrival time to the Outer TOF in ps
736657 upgradeTofMC (expectedTimeInnerTOF, trackLengthInnerTOF, expectedTimeOuterTOF, trackLengthOuterTOF);
@@ -748,8 +669,8 @@ struct OnTheFlyTofPid {
748669 xPv = recoTrack.getX ();
749670 }
750671 if (xPv > kTrkXThreshold ) {
751- trackLengthRecoInnerTOF = computeTrackLength (recoTrack, simConfig.innerTOFRadius , mMagneticField );
752- trackLengthRecoOuterTOF = computeTrackLength (recoTrack, simConfig.outerTOFRadius , mMagneticField );
672+ trackLengthRecoInnerTOF = o2::upgrade:: computeTrackLength (recoTrack, simConfig.innerTOFRadius , mMagneticField );
673+ trackLengthRecoOuterTOF = o2::upgrade:: computeTrackLength (recoTrack, simConfig.outerTOFRadius , mMagneticField );
753674 }
754675
755676 // cache the track info needed for the event time calculation
@@ -870,7 +791,7 @@ struct OnTheFlyTofPid {
870791 nSigmaOuterTOF[ii] = -100 ;
871792
872793 momentumHypotheses[ii] = rigidity * kParticleCharges [ii]; // Total momentum for this hypothesis
873- const float v = computeParticleVelocity (momentumHypotheses[ii], kParticleMasses [ii]);
794+ const float v = o2::upgrade:: computeParticleVelocity (momentumHypotheses[ii], kParticleMasses [ii]);
874795
875796 expectedTimeInnerTOF[ii] = trackLengthInnerTOF / v;
876797 expectedTimeOuterTOF[ii] = trackLengthOuterTOF / v;
@@ -942,15 +863,15 @@ struct OnTheFlyTofPid {
942863 }
943864 }
944865 }
866+ }
945867
946- const float deltaTrackLengthInnerTOF = std::abs (trackLengthInnerTOF - trackLengthRecoInnerTOF);
947- if (trackLengthInnerTOF > 0 && trackLengthRecoInnerTOF > 0 ) {
948- histos.fill (HIST (" iTOF/h2dDeltaTrackLengthInnerVsPt" ), noSmearingPt, deltaTrackLengthInnerTOF);
949- }
950- const float deltaTrackLengthOuterTOF = std::abs (trackLengthOuterTOF - trackLengthRecoOuterTOF);
951- if (trackLengthOuterTOF > 0 && trackLengthRecoOuterTOF > 0 ) {
952- histos.fill (HIST (" oTOF/h2dDeltaTrackLengthOuterVsPt" ), noSmearingPt, deltaTrackLengthOuterTOF);
953- }
868+ const float deltaTrackLengthInnerTOF = std::abs (trackLengthInnerTOF - trackLengthRecoInnerTOF);
869+ if (trackLengthInnerTOF > 0 && trackLengthRecoInnerTOF > 0 ) {
870+ histos.fill (HIST (" iTOF/h2dDeltaTrackLengthInnerVsPt" ), noSmearingPt, deltaTrackLengthInnerTOF);
871+ }
872+ const float deltaTrackLengthOuterTOF = std::abs (trackLengthOuterTOF - trackLengthRecoOuterTOF);
873+ if (trackLengthOuterTOF > 0 && trackLengthRecoOuterTOF > 0 ) {
874+ histos.fill (HIST (" oTOF/h2dDeltaTrackLengthOuterVsPt" ), noSmearingPt, deltaTrackLengthOuterTOF);
954875 }
955876
956877 // Sigmas have been fully calculated. Please populate the NSigma helper table (once per track)
0 commit comments