diff --git a/PhysicsAnalysis/NtupleDumper/CMakeLists.txt b/PhysicsAnalysis/NtupleDumper/CMakeLists.txt index 875c81e610384e642599b15accd892bfe87be6c8..56d8fd54b7983d5725af044dd365b39a551920cb 100644 --- a/PhysicsAnalysis/NtupleDumper/CMakeLists.txt +++ b/PhysicsAnalysis/NtupleDumper/CMakeLists.txt @@ -8,7 +8,7 @@ atlas_add_component( src/NtupleDumperAlg.cxx src/component/NtupleDumper_entries.cxx - LINK_LIBRARIES AthenaBaseComps StoreGateLib xAODFaserWaveform xAODFaserCalorimeter xAODFaserTrigger xAODFaserLHC ScintIdentifier FaserCaloIdentifier GeneratorObjects FaserActsGeometryLib TrackerSimEvent TrackerSimData TrackerIdentifier TrackerReadoutGeometry TrkTrack GeoPrimitives TrackerRIO_OnTrack TrackerSpacePoint FaserActsKalmanFilterLib AtlasHepMCLib WaveformConditionsToolsLib # FIXME: FaserActsmanVertexingLib + LINK_LIBRARIES AthenaBaseComps StoreGateLib xAODFaserWaveform xAODFaserCalorimeter xAODFaserTrigger xAODFaserLHC ScintIdentifier FaserCaloIdentifier GeneratorObjects FaserActsGeometryLib TrackerSimEvent TrackerSimData TrackerIdentifier TrackerReadoutGeometry TrkTrack GeoPrimitives TrackerRIO_OnTrack TrackerSpacePoint FaserActsKalmanFilterLib AtlasHepMCLib WaveformConditionsToolsLib FaserActsmanVertexingLib PRIVATE_LINK_LIBRARIES nlohmann_json::nlohmann_json ) atlas_install_python_modules( python/*.py ) diff --git a/PhysicsAnalysis/NtupleDumper/src/NtupleDumperAlg.cxx b/PhysicsAnalysis/NtupleDumper/src/NtupleDumperAlg.cxx index 470d836b0f72edc3f2d6e76e481a166dde6777c4..284cf59e713f1b61b12196b6d48eda70ea2a30e6 100644 --- a/PhysicsAnalysis/NtupleDumper/src/NtupleDumperAlg.cxx +++ b/PhysicsAnalysis/NtupleDumper/src/NtupleDumperAlg.cxx @@ -243,8 +243,7 @@ StatusCode NtupleDumperAlg::initialize() ATH_CHECK(m_trackingGeometryTool.retrieve()); ATH_CHECK(m_trackTruthMatchingTool.retrieve()); ATH_CHECK(m_fiducialParticleTool.retrieve()); - // TODO - fix vertexing - // ATH_CHECK(m_vertexingTool.retrieve()); + ATH_CHECK(m_vertexingTool.retrieve()); ATH_CHECK(m_mappingTool.retrieve()); ATH_CHECK(m_spacePointContainerKey.initialize()); @@ -1513,40 +1512,57 @@ StatusCode NtupleDumperAlg::execute(const EventContext &ctx) const m_longTracks++; } - // if (m_runVertexing && goodTracks.size() >= 2) { - // // sort tracks my momentum and reconstruct vertex - // std::sort(goodTracks.begin(), goodTracks.end(), [](const Trk::Track *lhs, const Trk::Track *rhs){ - // return lhs->trackParameters()->front()->momentum().z() < rhs->trackParameters()->front()->momentum().z(); - // }); - // std::vector<const Trk::Track*> lowMomentumTracks {goodTracks[0], goodTracks[1]}; - - // std::optional<FaserTracking::POCA> vertex = m_vertexingTool->getVertex(lowMomentumTracks); - // if (vertex) { - // Eigen::Vector3d position = vertex->position; - // m_vertex_x = position.x(); - // m_vertex_y = position.y(); - // m_vertex_z = position.z(); - // m_vertex_chi2 = vertex->chi2; - - // // get track parameters of two tracks with lowest momentum at vertex - // auto vertexTrackParameters0 = m_vertexingTool->extrapolateTrack(goodTracks[0], m_vertex_z); - // if (vertexTrackParameters0 != nullptr) { - // // convert momentum from GeV to MeV - // m_vertex_px0 = vertexTrackParameters0->momentum().x() * 1e3; - // m_vertex_py0 = vertexTrackParameters0->momentum().y() * 1e3; - // m_vertex_pz0 = vertexTrackParameters0->momentum().z() * 1e3; - // m_vertex_p0 = std::sqrt(m_vertex_px0*m_vertex_px0 + m_vertex_py0*m_vertex_py0 + m_vertex_pz0*m_vertex_pz0); - // } - // auto vertexTrackParameters1 = m_vertexingTool->extrapolateTrack(goodTracks[1], m_vertex_z); - // if (vertexTrackParameters1 != nullptr) { - // // convert momentum from GeV to MeV - // m_vertex_px1 = vertexTrackParameters1->momentum().x() * 1e3; - // m_vertex_py1 = vertexTrackParameters1->momentum().y() * 1e3; - // m_vertex_pz1 = vertexTrackParameters1->momentum().z() * 1e3; - // m_vertex_p1 = std::sqrt(m_vertex_px1*m_vertex_px1 + m_vertex_py1*m_vertex_py1 + m_vertex_pz1*m_vertex_pz1); - // } - // } - //} + // Clear old vertex values + m_vertex_x = 0.; + m_vertex_y = 0.; + m_vertex_z = 0.; + m_vertex_chi2 = -1.; + m_vertex_px0 = 0.; + m_vertex_py0 = 0.; + m_vertex_pz0 = 0.; + m_vertex_p0 = 0.; + m_vertex_px1 = 0.; + m_vertex_py1 = 0.; + m_vertex_pz1 = 0.; + m_vertex_p1 = 0.; + + if (m_runVertexing && goodTracks.size() >= 2) { + m_two_tracks ++; + + // sort tracks by momentum and reconstruct vertex + std::sort(goodTracks.begin(), goodTracks.end(), [](const Trk::Track *lhs, const Trk::Track *rhs){ + return lhs->trackParameters()->front()->momentum().z() < rhs->trackParameters()->front()->momentum().z(); + }); + std::vector<const Trk::Track*> lowMomentumTracks {goodTracks[0], goodTracks[1]}; + + std::optional<FaserTracking::POCA> vertex = m_vertexingTool->getVertex(lowMomentumTracks); + if (vertex) { + Eigen::Vector3d position = vertex->position; + m_vertex_x = position.x(); + m_vertex_y = position.y(); + m_vertex_z = position.z(); + m_vertex_chi2 = vertex->chi2; + m_verticies++; + + // get track parameters of two tracks with lowest momentum at vertex + auto vertexTrackParameters0 = m_vertexingTool->extrapolateTrack(goodTracks[0], m_vertex_z); + if (vertexTrackParameters0) { + // convert momentum from GeV to MeV + m_vertex_px0 = vertexTrackParameters0->momentum().x() * 1e3; + m_vertex_py0 = vertexTrackParameters0->momentum().y() * 1e3; + m_vertex_pz0 = vertexTrackParameters0->momentum().z() * 1e3; + m_vertex_p0 = std::sqrt(m_vertex_px0*m_vertex_px0 + m_vertex_py0*m_vertex_py0 + m_vertex_pz0*m_vertex_pz0); + } + auto vertexTrackParameters1 = m_vertexingTool->extrapolateTrack(goodTracks[1], m_vertex_z); + if (vertexTrackParameters1) { + // convert momentum from GeV to MeV + m_vertex_px1 = vertexTrackParameters1->momentum().x() * 1e3; + m_vertex_py1 = vertexTrackParameters1->momentum().y() * 1e3; + m_vertex_pz1 = vertexTrackParameters1->momentum().z() * 1e3; + m_vertex_p1 = std::sqrt(m_vertex_px1*m_vertex_px1 + m_vertex_py1*m_vertex_py1 + m_vertex_pz1*m_vertex_pz1); + } + } + } if (!isMC) { if (m_doTrackFilter) { // filter events: colliding bunches have at least one long track, non-colliding bunches have at least one long track or one calo module with raw_peak > 3 mV @@ -1665,6 +1681,8 @@ StatusCode NtupleDumperAlg::finalize() { ATH_MSG_INFO("Number of events passed Ntuple selection = " << m_eventsPassed); ATH_MSG_INFO("Number of events failing GRL selection = " << m_eventsFailedGRL); + ATH_MSG_INFO("Number of 2-track events = " << m_two_tracks); + ATH_MSG_INFO("Number of verticies = " << m_verticies); return StatusCode::SUCCESS; } diff --git a/PhysicsAnalysis/NtupleDumper/src/NtupleDumperAlg.h b/PhysicsAnalysis/NtupleDumper/src/NtupleDumperAlg.h index 06142aa14356be830264c4cff22f3ecb9a8398c4..ef4c227c2661a1c1faa115d19b6bb9d2d59f09c8 100644 --- a/PhysicsAnalysis/NtupleDumper/src/NtupleDumperAlg.h +++ b/PhysicsAnalysis/NtupleDumper/src/NtupleDumperAlg.h @@ -22,8 +22,7 @@ #include "FaserActsKalmanFilter/ITrackTruthMatchingTool.h" #include "TrackerSimEvent/FaserSiHitCollection.h" #include "xAODEventInfo/EventInfo.h" -// TODO - fix vertexing -//#include "FaserActsVertexing/IVertexingTool.h" +#include "FaserActsVertexing/IVertexingTool.h" #include "GeneratorObjects/McEventCollection.h" #include <boost/dynamic_bitset.hpp> @@ -114,8 +113,7 @@ private: ToolHandle<IFaserActsTrackingGeometryTool> m_trackingGeometryTool {this, "TrackingGeometryTool", "FaserActsTrackingGeometryTool"}; ToolHandle<ITrackTruthMatchingTool> m_trackTruthMatchingTool {this, "TrackTruthMatchingTool", "TrackTruthMatchingTool"}; ToolHandle<IFiducialParticleTool> m_fiducialParticleTool {this, "FiducialParticleTool", "FiducialParticleTool"}; - // TODO - fix vertexing - // ToolHandle<FaserTracking::IVertexingTool> m_vertexingTool { this, "VertexingTool", "FaserTracking::PointOfClosestApproachSearchTool"}; + ToolHandle<FaserTracking::IVertexingTool> m_vertexingTool { this, "VertexingTool", "FaserTracking::PointOfClosestApproachSearchTool"}; ToolHandle<IWaveformCableMappingTool> m_mappingTool { this, "WaveformCableMappingTool", "WaveformCableMappingTool" }; const TrackerDD::SCT_DetectorManager* m_detMgr {nullptr}; @@ -421,7 +419,9 @@ private: mutable int m_eventsPassed = 0; mutable int m_eventsFailedGRL = 0; - + mutable int m_two_tracks = 0; + mutable int m_verticies = 0; + mutable double m_vertex_x; // components of reconstructed vertex in mm mutable double m_vertex_y; mutable double m_vertex_z; diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsVertexing/FaserActsVertexing/IVertexingTool.h b/Tracking/Acts/FaserActsKalmanFilter/FaserActsVertexing/FaserActsVertexing/IVertexingTool.h index 3c6f93714b6cf07f2428a80c157318399d7b632e..6941cf4d45a74d05237fdd93139432c1e2911db7 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/FaserActsVertexing/FaserActsVertexing/IVertexingTool.h +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsVertexing/FaserActsVertexing/IVertexingTool.h @@ -28,7 +28,7 @@ public: virtual std::optional<POCA> getVertex(const std::vector<const Trk::Track *> &tracks) const = 0; // Get bound track parameters at given z position. - virtual std::unique_ptr<const Acts::BoundTrackParameters> + virtual std::optional<const Acts::BoundTrackParameters> extrapolateTrack(const Trk::Track *track, double targetPosition) const = 0; }; diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsVertexing/src/PointOfClosestApproachSearchTool.cxx b/Tracking/Acts/FaserActsKalmanFilter/FaserActsVertexing/src/PointOfClosestApproachSearchTool.cxx index ea423d703372dbfcc954dc2089b8169282cdc634..1debf76ec55c267dbe764e7858e828345e861caa 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/FaserActsVertexing/src/PointOfClosestApproachSearchTool.cxx +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsVertexing/src/PointOfClosestApproachSearchTool.cxx @@ -93,16 +93,16 @@ Eigen::Vector2d PointOfClosestApproachSearchTool::getCenter( } // Extrapolate track to given z positon. -std::unique_ptr<const Acts::BoundTrackParameters> +std::optional<const Acts::BoundTrackParameters> PointOfClosestApproachSearchTool::extrapolateTrack(const Trk::Track *track, double targetPosition) const { Acts::BoundTrackParameters startParameters = getParametersFromTrack(track->trackParameters()->front()); auto targetSurface = Acts::Surface::makeShared<Acts::PlaneSurface>( Acts::Vector3(0, 0, targetPosition), Acts::Vector3(0, 0, 1)); - Acts::NavigationDirection navigationDirection = - targetPosition > startParameters.referenceSurface().center(m_gctx).z() ? Acts::forward - : Acts::backward; + Acts::Direction navigationDirection = + targetPosition > startParameters.referenceSurface().center(m_gctx).z() ? Acts::Direction::Forward + : Acts::Direction::Backward; return m_extrapolationTool->propagate(m_ctx, startParameters, *targetSurface, navigationDirection); } @@ -112,11 +112,12 @@ PointOfClosestApproachSearchTool::extrapolateTrackParameters( const Acts::BoundTrackParameters &startParameters, double z) const { auto targetSurface = Acts::Surface::makeShared<Acts::PlaneSurface>(Acts::Vector3(0, 0, z), Acts::Vector3(0, 0, 1)); - Acts::NavigationDirection navigationDirection = - z > startParameters.referenceSurface().center(m_gctx).z() ? Acts::forward : Acts::backward; - std::unique_ptr<const Acts::BoundTrackParameters> targetParameters = + Acts::Direction navigationDirection = + z > startParameters.referenceSurface().center(m_gctx).z() ? Acts::Direction::Forward : Acts::Direction::Backward; + std::optional<const Acts::BoundTrackParameters> targetParameters = m_extrapolationTool->propagate(m_ctx, startParameters, *targetSurface, navigationDirection); - if (targetParameters != nullptr && targetParameters->covariance().has_value()) { + //if (targetParameters != nullptr && targetParameters->covariance().has_value()) { + if (targetParameters) { // extrapolate covariance matrix? // return TrackPosition{targetParameters->position(m_gctx), // startParameters.covariance().value().topLeftCorner(2, 2)}; @@ -193,7 +194,7 @@ Acts::BoundTrackParameters PointOfClosestApproachSearchTool::getParametersFromTr ATH_MSG_WARNING("FreeToBound parameter transformation failed"); } // convert covariance matrix to GeV - Acts::BoundSymMatrix cov = Acts::BoundSymMatrix::Identity(); + Acts::BoundSquareMatrix cov = Acts::BoundSquareMatrix::Identity(); cov.topLeftCorner(5, 5) = *trackParameters->covariance(); for (int i = 0; i < cov.rows(); i++) { cov(i, 4) = cov(i, 4) / 1_MeV; @@ -201,7 +202,9 @@ Acts::BoundTrackParameters PointOfClosestApproachSearchTool::getParametersFromTr for (int i = 0; i < cov.cols(); i++) { cov(4, i) = cov(4, i) / 1_MeV; } - return Acts::BoundTrackParameters{surface, bound.value(), trackParameters->charge(), cov}; + + //return Acts::BoundTrackParameters{surface, bound.value(), trackParameters->charge(), cov}; + return Acts::BoundTrackParameters{surface, bound.value(), cov, Acts::ParticleHypothesis::muon()}; } void PointOfClosestApproachSearchTool::clear() const { diff --git a/Tracking/Acts/FaserActsKalmanFilter/FaserActsVertexing/src/PointOfClosestApproachSearchTool.h b/Tracking/Acts/FaserActsKalmanFilter/FaserActsVertexing/src/PointOfClosestApproachSearchTool.h index 9ed794948483ee01fcfb13203971ba7a897657da..e572cfb993d98d2dbb64563dd2fe6a63da3daa25 100644 --- a/Tracking/Acts/FaserActsKalmanFilter/FaserActsVertexing/src/PointOfClosestApproachSearchTool.h +++ b/Tracking/Acts/FaserActsKalmanFilter/FaserActsVertexing/src/PointOfClosestApproachSearchTool.h @@ -21,7 +21,7 @@ public: std::optional<POCA> getVertex(const std::vector<const Trk::Track *> &tracks) const override; - std::unique_ptr<const Acts::BoundTrackParameters> + std::optional<const Acts::BoundTrackParameters> extrapolateTrack(const Trk::Track *track, double targetPosition) const override; private: @@ -34,7 +34,7 @@ private: }; struct TrackPosition { - TrackPosition(const Acts::Vector3 &position, const Acts::BoundSymMatrix &covariance) { + TrackPosition(const Acts::Vector3 &position, const Acts::BoundSquareMatrix &covariance) { pos << position.x(), position.y(); cov << covariance(1, 1), 0, 0, covariance(0, 0); inv = cov.inverse(); diff --git a/package_filters.txt b/package_filters.txt index 341ee378810a20b3df6211f2b228969c1db16ccc..453e10b1017f8cc4c73086d16da1377b65b11a11 100644 --- a/package_filters.txt +++ b/package_filters.txt @@ -61,15 +61,7 @@ +Tracker/TrackerRecTools/TruthSeededTrackFinderTool +Tracker/TrackerSimEvent -Tracker/.* -+Tracking/Acts/FaserActsGeometry -+Tracking/Acts/FaserActsGeometryInterfaces -+Tracking/Acts/ActsInterop -+Tracking/Acts/FaserActsKalmanFilter -#+Tracking/Acts/FaserActsKalmanFilter/FaserActsVertexing -+Tracking/TrkEventCnv/TrkEventAthenaPool -+Tracking/TrkEventCnv/TrkEventCnvTools -+Tracking/TrkEventCnv/TrkEventTopLevelCnv --Tracking/.* ++Tracking/.* +Trigger/FaserTrigEventCnv/FaserTriggerByteStream #-Trigger/.* +Waveform/.*