From 261e891f441ba2af719ecb596b3559f8a0599711 Mon Sep 17 00:00:00 2001 From: Izaac Sanderswood <izaac.sanderswood@cern.ch> Date: Tue, 23 May 2023 11:28:06 +0200 Subject: [PATCH 1/3] Extrapolate to yz straight line intersection z for t-tracks --- Phys/VertexFit/src/ParticleVertexFitter.cpp | 40 ++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/Phys/VertexFit/src/ParticleVertexFitter.cpp b/Phys/VertexFit/src/ParticleVertexFitter.cpp index e350181cce4..62cc3f457f7 100644 --- a/Phys/VertexFit/src/ParticleVertexFitter.cpp +++ b/Phys/VertexFit/src/ParticleVertexFitter.cpp @@ -630,7 +630,45 @@ StatusCode ParticleVertexFitter::fit( const LHCb::Particle::ConstVector& origdau trajs[ntrajs++] = &( ownedtrajs.back() ); } } - if ( ntrajs == 2 ) { + bool parallelTracks = false; + if ( ntrajs == 2 && m_extrapolateTracksWithoutVelo ) { + // this is NOT default behaviour + // For T-tracks it does not make sense to use 3-D POCA starting position + // Trajectory in YZ plane is approx straight line + // calculate the yz intersection z and extrapolate there + + const float ty0 = daughters[0]->proto()->track()->firstState().ty(); + const float ty1 = daughters[1]->proto()->track()->firstState().ty(); + + if ( ty0 == ty1 ) { + debug() << "tracks are parallel in yz plane. Cannot calculate yz intersection. Default to 3-D POCA starting " + "position. " + << endmsg; + parallelTracks = true; + } else { + const float z0 = daughters[0]->proto()->track()->firstState().z(); + const float z1 = daughters[1]->proto()->track()->firstState().z(); + + const float y0 = daughters[0]->proto()->track()->firstState().y(); + const float y1 = daughters[1]->proto()->track()->firstState().y(); + + // calculate the y-axis intersection of each track + const float c0 = y0 - ty0 * z0; + const float c1 = y1 - ty1 * z1; + + // calculate the point in the yz-plane where the tracks intersect + const float yzIntersectionZ = ( c1 - c0 ) / ( ty0 - ty1 ); + const float yzIntersectionY = ty0 * yzIntersectionZ + c1; + + position.SetZ( yzIntersectionZ ); + position.SetY( yzIntersectionY ); + position.SetX( 0 ); + posinitialized = true; + } + } + + if ( ( ntrajs == 2 && !m_extrapolateTracksWithoutVelo ) || ( ntrajs == 2 && parallelTracks ) ) { + // this is the default behaviour double mu0( 0 ), mu1( 0 ); Gaudi::XYZVector deltaX; StatusCode sc = m_trajpoca->minimize( *( trajs[0] ), mu0, *( trajs[1] ), mu1, deltaX, 0.1 * Gaudi::Units::mm ); -- GitLab From c997935e7a9098f5a40454f4622f46539acaaaa3 Mon Sep 17 00:00:00 2001 From: Izaac Sanderswood <izaac.sanderswood@cern.ch> Date: Mon, 5 Jun 2023 12:01:57 +0200 Subject: [PATCH 2/3] Change extrapolateTracksWithoutVelo to extrapolateTtracks, add explicit check that are T-tracks when this flag is used, fail if not --- Phys/VertexFit/src/ParticleVertexFitter.cpp | 32 ++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/Phys/VertexFit/src/ParticleVertexFitter.cpp b/Phys/VertexFit/src/ParticleVertexFitter.cpp index 62cc3f457f7..1fe34ec0e06 100644 --- a/Phys/VertexFit/src/ParticleVertexFitter.cpp +++ b/Phys/VertexFit/src/ParticleVertexFitter.cpp @@ -78,12 +78,12 @@ private: StatusCode fit( const LHCb::Particle::ConstVector&, LHCb::Vertex&, LHCb::Particle*, const IGeometryInfo& ) const; private: - Gaudi::Property<int> m_maxnumiter{this, "MaxNumIter", 5}; - Gaudi::Property<double> m_maxdchisq{this, "MaxDeltaChi2", 0.01}; - Gaudi::Property<bool> m_extrapolateTracksWithoutVelo{this, "extrapolateTracksWithoutVelo", false}; - PublicToolHandle<ITrackStateProvider> m_stateprovider{this, "StateProvider", "TrackStateProvider"}; - ToolHandle<ITrajPoca> m_trajpoca{"TrajPoca"}; - const LHCb::IParticlePropertySvc* m_ppsvc{nullptr}; + Gaudi::Property<int> m_maxnumiter{this, "MaxNumIter", 5}; + Gaudi::Property<double> m_maxdchisq{this, "MaxDeltaChi2", 0.01}; + Gaudi::Property<bool> m_extrapolateTtracks{this, "extrapolateTtracks", false}; + PublicToolHandle<ITrackStateProvider> m_stateprovider{this, "StateProvider", "TrackStateProvider"}; + ToolHandle<ITrajPoca> m_trajpoca{"TrajPoca"}; + const LHCb::IParticlePropertySvc* m_ppsvc{nullptr}; mutable Gaudi::Accumulators::MsgCounter<MSG::WARNING> m_matrix_inversion_failed{this, "Problem inverting matrix!", 0}; }; @@ -591,7 +591,19 @@ StatusCode ParticleVertexFitter::fit( const LHCb::Particle::ConstVector& origdau // 1. if there are 'resonance' daughters, take the vertex position of the first. // 2. if not, use the states of the first two tracks with velo or composites // 3. if not, try with downstream tracks and trajpoca - bool posinitialized{false}; + bool posinitialized{false}; + if ( m_extrapolateTtracks ) { + // check these are T-tracks + bool confirmedTtracks = true; + for ( const auto daughter : daughters ) { + if ( daughter->proto()->track()->hasUT() || daughter->proto()->track()->hasVelo() ) confirmedTtracks = false; + } + if ( !confirmedTtracks ) { + error() << "extrapolateTtracks is set to true, but one or more tracks are not T-tracks" << endmsg; + return StatusCode::FAILURE; + } + } + Gaudi::XYZPoint position; if ( counttypes[Resonance] > 0 ) { // try 1 @@ -631,7 +643,7 @@ StatusCode ParticleVertexFitter::fit( const LHCb::Particle::ConstVector& origdau } } bool parallelTracks = false; - if ( ntrajs == 2 && m_extrapolateTracksWithoutVelo ) { + if ( ntrajs == 2 && m_extrapolateTtracks ) { // this is NOT default behaviour // For T-tracks it does not make sense to use 3-D POCA starting position // Trajectory in YZ plane is approx straight line @@ -667,7 +679,7 @@ StatusCode ParticleVertexFitter::fit( const LHCb::Particle::ConstVector& origdau } } - if ( ( ntrajs == 2 && !m_extrapolateTracksWithoutVelo ) || ( ntrajs == 2 && parallelTracks ) ) { + if ( ( ntrajs == 2 && !m_extrapolateTtracks ) || ( ntrajs == 2 && parallelTracks ) ) { // this is the default behaviour double mu0( 0 ), mu1( 0 ); Gaudi::XYZVector deltaX; @@ -713,7 +725,7 @@ StatusCode ParticleVertexFitter::fit( const LHCb::Particle::ConstVector& origdau } } break; case TrackWithoutVelo: { - if ( !m_extrapolateTracksWithoutVelo ) { + if ( !m_extrapolateTtracks ) { // this is the default behaviour const LHCb::Track* track = p->proto()->track(); const LHCb::TrackTraj* tracktraj = m_stateprovider->trajectory( *( p->proto()->track() ), geometry ); -- GitLab From 4b722afe087e700d9327a362efc3cacc47446f44 Mon Sep 17 00:00:00 2001 From: Izaac Sanderswood <izaac.sanderswood@cern.ch> Date: Tue, 6 Jun 2023 10:52:28 +0200 Subject: [PATCH 3/3] remove check for T-tracks --- Phys/VertexFit/src/ParticleVertexFitter.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/Phys/VertexFit/src/ParticleVertexFitter.cpp b/Phys/VertexFit/src/ParticleVertexFitter.cpp index 1fe34ec0e06..6bddbab7a10 100644 --- a/Phys/VertexFit/src/ParticleVertexFitter.cpp +++ b/Phys/VertexFit/src/ParticleVertexFitter.cpp @@ -592,17 +592,6 @@ StatusCode ParticleVertexFitter::fit( const LHCb::Particle::ConstVector& origdau // 2. if not, use the states of the first two tracks with velo or composites // 3. if not, try with downstream tracks and trajpoca bool posinitialized{false}; - if ( m_extrapolateTtracks ) { - // check these are T-tracks - bool confirmedTtracks = true; - for ( const auto daughter : daughters ) { - if ( daughter->proto()->track()->hasUT() || daughter->proto()->track()->hasVelo() ) confirmedTtracks = false; - } - if ( !confirmedTtracks ) { - error() << "extrapolateTtracks is set to true, but one or more tracks are not T-tracks" << endmsg; - return StatusCode::FAILURE; - } - } Gaudi::XYZPoint position; if ( counttypes[Resonance] > 0 ) { -- GitLab