diff --git a/Rec/Allen/CMakeLists.txt b/Rec/Allen/CMakeLists.txt index 1d33d5d0fc0b6aaa8fbe219897f7ebf5a0f5cd78..aa4715c8b2dc82383f7a42c23aaae9045a6507ae 100755 --- a/Rec/Allen/CMakeLists.txt +++ b/Rec/Allen/CMakeLists.txt @@ -18,7 +18,6 @@ gaudi_add_module(AllenWrapper src/GaudiAllenCaloToCaloClusters.cpp src/GaudiAllenCountAndDumpLineDecisions.cpp src/GaudiAllenForwardToV2Tracks.cpp - src/GaudiAllenSeedAndMatchNoUTToV2Tracks.cpp src/GaudiAllenReportsToRawEvent.cpp src/GaudiAllenLumiSummaryToRawEvent.cpp src/GaudiAllenSVsToRecVertexV2.cpp diff --git a/Rec/Allen/src/GaudiAllenSeedAndMatchNoUTToV2Tracks.cpp b/Rec/Allen/src/GaudiAllenSeedAndMatchNoUTToV2Tracks.cpp deleted file mode 100644 index cbe0654189df57f90498034bdaf8471210b54ad7..0000000000000000000000000000000000000000 --- a/Rec/Allen/src/GaudiAllenSeedAndMatchNoUTToV2Tracks.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/***************************************************************************** \ - * (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration * -\*****************************************************************************/ - -// Gaudi -#include "GaudiAlg/Transformer.h" -#include "GaudiKernel/StdArrayAsProperty.h" - -// LHCb -#include "Event/Track.h" - -// Allen -#include "Logger.h" -#include "ParKalmanFittedTrack.cuh" -#include "VeloConsolidated.cuh" -#include "SciFiConsolidated.cuh" - -class GaudiAllenSeedAndMatchNoUTToV2Tracks final - : public Gaudi::Functional::Transformer( - const std::vector&, - const std::vector&, - const std::vector&, - const std::vector&, - const std::vector&, - const std::vector&, - const std::vector&, - const std::vector&, - const std::vector&, - const std::vector&)> { - -public: - /// Standard constructor - GaudiAllenSeedAndMatchNoUTToV2Tracks(const std::string& name, ISvcLocator* pSvcLocator); - - /// initialization - StatusCode initialize() override; - - /// Algorithm execution - std::vector operator()( - const std::vector& offsets_all_velo_tracks, - const std::vector& offsets_velo_track_hit_number, - const std::vector& velo_track_hits, - const std::vector& atomics_scifi, - const std::vector& scifi_track_hit_number, - const std::vector& scifi_track_hits, - const std::vector& scifi_track_velo_indices, - const std::vector& scifi_qop, - const std::vector& scifi_states, - const std::vector& kf_tracks) const override; - -private: - const std::array m_default_covarianceValues {4.0, 400.0, 4.e-6, 1.e-4, 0.1}; - Gaudi::Property> m_covarianceValues {this, "COVARIANCEVALUES", m_default_covarianceValues}; -}; - -DECLARE_COMPONENT(GaudiAllenSeedAndMatchNoUTToV2Tracks) - -GaudiAllenSeedAndMatchNoUTToV2Tracks::GaudiAllenSeedAndMatchNoUTToV2Tracks( - const std::string& name, - ISvcLocator* pSvcLocator) : - Transformer( - name, - pSvcLocator, - // Inputs - {KeyValue {"offsets_all_velo_tracks", ""}, - KeyValue {"offsets_velo_track_hit_number", ""}, - KeyValue {"velo_track_hits", ""}, - KeyValue {"atomics_scifi", ""}, - KeyValue {"scifi_track_hit_number", ""}, - KeyValue {"scifi_track_hits", ""}, - KeyValue {"scifi_track_velo_indices", ""}, - KeyValue {"scifi_qop", ""}, - KeyValue {"scifi_states", ""}, - KeyValue {"kf_tracks", ""}}, - // Outputs - {KeyValue {"OutputTracks", "Allen/Track/v2/SeedAndMatchTracks"}}) -{} - -StatusCode GaudiAllenSeedAndMatchNoUTToV2Tracks::initialize() -{ - auto sc = Transformer::initialize(); - if (sc.isFailure()) return sc; - if (msgLevel(MSG::DEBUG)) debug() << "==> Initialize" << endmsg; - - return sc; -} - -std::vector GaudiAllenSeedAndMatchNoUTToV2Tracks::operator()( - const std::vector& offsets_all_velo_tracks, - const std::vector& offsets_velo_track_hit_number, - const std::vector& velo_track_hits, - const std::vector& atomics_scifi, - const std::vector& scifi_track_hit_number, - const std::vector& scifi_track_hits, - const std::vector& scifi_track_velo_indices, - const std::vector& scifi_qop, - const std::vector& scifi_states, - const std::vector& kf_tracks) const -{ - // Make the consolidated tracks. - const unsigned i_event = 0; - const unsigned number_of_events = 1; - const Velo::Consolidated::Tracks velo_tracks { - offsets_all_velo_tracks.data(), offsets_velo_track_hit_number.data(), i_event, number_of_events}; - - const SciFi::Consolidated::ConstTracks scifi_tracks {atomics_scifi.data(), - scifi_track_hit_number.data(), - scifi_qop.data(), - scifi_states.data(), - scifi_track_velo_indices.data(), - i_event, - number_of_events}; - - // Do the conversion - const unsigned number_of_tracks = scifi_tracks.number_of_tracks(i_event); - if (msgLevel(MSG::DEBUG)) debug() << "Number of SciFi tracks to convert = " << number_of_tracks << endmsg; - - std::vector seed_and_match_tracks; - seed_and_match_tracks.reserve(number_of_tracks); - for (unsigned t = 0; t < number_of_tracks; t++) { - ParKalmanFilter::FittedTrack track = kf_tracks[t]; - auto& newTrack = seed_and_match_tracks.emplace_back(); - - // set track flags - newTrack.setType(LHCb::Event::v2::Track::Type::Long); - newTrack.setHistory(LHCb::Event::v2::Track::History::PrForward); - newTrack.setPatRecStatus(LHCb::Event::v2::Track::PatRecStatus::PatRecIDs); - newTrack.setFitStatus(LHCb::Event::v2::Track::FitStatus::Fitted); - - // get momentum - float qop = track.state[4]; - float qopError = m_covarianceValues[4] * qop * qop; - - // closest to beam state - LHCb::State closesttobeam_state; - closesttobeam_state.setState( - track.state[0], track.state[1], track.z, track.state[2], track.state[3], track.state[4]); - - closesttobeam_state.covariance()(0, 0) = track.cov(0, 0); - closesttobeam_state.covariance()(0, 2) = track.cov(2, 0); - closesttobeam_state.covariance()(2, 2) = track.cov(2, 2); - closesttobeam_state.covariance()(1, 1) = track.cov(1, 1); - closesttobeam_state.covariance()(1, 3) = track.cov(3, 1); - closesttobeam_state.covariance()(3, 3) = track.cov(3, 3); - closesttobeam_state.covariance()(4, 4) = qopError; - - closesttobeam_state.setLocation(LHCb::State::Location::ClosestToBeam); - newTrack.addToStates(closesttobeam_state); - - // SciFi state - LHCb::State scifi_state; - const MiniState& state = scifi_tracks.states(t); - scifi_state.setState(state.x, state.y, state.z, state.tx, state.ty, qop); - - scifi_state.covariance()(0, 0) = m_covarianceValues[0]; - scifi_state.covariance()(0, 2) = 0.f; - scifi_state.covariance()(2, 2) = m_covarianceValues[2]; - scifi_state.covariance()(1, 1) = m_covarianceValues[1]; - scifi_state.covariance()(1, 3) = 0.f; - scifi_state.covariance()(3, 3) = m_covarianceValues[3]; - scifi_state.covariance()(4, 4) = qopError; - - scifi_state.setLocation(LHCb::State::Location::AtT); - - // set chi2 / chi2ndof - newTrack.setChi2PerDoF(LHCb::Event::v2::Track::Chi2PerDoF {track.chi2 / track.ndof, static_cast(track.ndof)}); - - // set LHCb IDs - std::vector lhcbids; - // add SciFi hits - std::vector scifi_ids = scifi_tracks.get_lhcbids_for_track(scifi_track_hits.data(), t); - for (const auto id : scifi_ids) { - const LHCb::LHCbID lhcbid = LHCb::LHCbID(id); - newTrack.addToLhcbIDs(lhcbid); - } - - // add Velo hits - const int velo_track_index = scifi_tracks.ut_track(t); - std::vector velo_ids = velo_tracks.get_lhcbids_for_track(velo_track_hits.data(), velo_track_index); - for (const auto id : velo_ids) { - const LHCb::LHCbID lhcbid = LHCb::LHCbID(id); - newTrack.addToLhcbIDs(lhcbid); - } - } - - return seed_and_match_tracks; -} diff --git a/Rec/Allen/src/GaudiAllenUTToV2Tracks.cpp b/Rec/Allen/src/GaudiAllenUTToV2Tracks.cpp index 8f7f2c9700e9cb164e1f6d6c61af4d813407e663..96a65691006eafc206d8c946f8d833f0e7a34638 100644 --- a/Rec/Allen/src/GaudiAllenUTToV2Tracks.cpp +++ b/Rec/Allen/src/GaudiAllenUTToV2Tracks.cpp @@ -25,34 +25,21 @@ #include "Logger.h" #include "VeloConsolidated.cuh" #include "UTConsolidated.cuh" +#include "States.cuh" class GaudiAllenUTToV2Tracks final : public Gaudi::Functional::Transformer( - const std::vector&, - const std::vector&, - const std::vector&, - const std::vector&, - const std::vector&, - const std::vector&, - const std::vector&, - const std::vector&, - const std::vector&, - const std::vector&)> { + const std::vector&, + const std::vector&, + const std::vector&)> { public: /// Standard constructor GaudiAllenUTToV2Tracks(const std::string& name, ISvcLocator* pSvcLocator); /// Algorithm execution std::vector operator()( - const std::vector&, - const std::vector&, - const std::vector&, - const std::vector&, - const std::vector&, - const std::vector&, - const std::vector&, - const std::vector&, - const std::vector&, - const std::vector&) const override; + const std::vector& allen_ut_tracks_mec, + const std::vector& allen_beamline_states, + const std::vector& allen_endvelo_states) const override; private: }; @@ -66,53 +53,25 @@ GaudiAllenUTToV2Tracks::GaudiAllenUTToV2Tracks(const std::string& name, ISvcLoca name, pSvcLocator, // Inputs - {KeyValue {"offsets_all_velo_tracks", ""}, - KeyValue {"offsets_velo_track_hit_number", ""}, - KeyValue {"velo_track_hits", ""}, - KeyValue {"velo_kalman_beamline_states", ""}, - KeyValue {"velo_kalman_endvelo_states", ""}, - KeyValue {"atomics_ut", ""}, - KeyValue {"ut_track_hit_number", ""}, - KeyValue {"ut_qop", ""}, - KeyValue {"ut_track_velo_indices", ""}, - KeyValue {"ut_track_hits", ""}}, + {KeyValue {"allen_ut_tracks_mec", ""}, + KeyValue {"allen_beamline_states_view", ""}, + KeyValue {"allen_endvelo_states_view", ""}}, // Outputs {KeyValue {"OutputTracks", "Allen/Track/v2/VeloUT"}}) {} std::vector GaudiAllenUTToV2Tracks::operator()( - const std::vector& offsets_all_velo_tracks, - const std::vector& offsets_velo_track_hit_number, - const std::vector& velo_track_hits, - const std::vector& velo_kalman_beamline_states, - const std::vector& velo_kalman_endvelo_states, - const std::vector& atomics_ut, - const std::vector& ut_track_hit_number, - const std::vector& ut_qop, - const std::vector& ut_track_velo_indices, - const std::vector& ut_track_hits) const + const std::vector& allen_ut_tracks_mec, + const std::vector& allen_beamline_states, + const std::vector& allen_endvelo_states) const { // Make the consolidated tracks. const unsigned i_event = 0; - const unsigned number_of_events = 1; - - const Velo::Consolidated::Tracks velo_tracks { - offsets_all_velo_tracks.data(), offsets_velo_track_hit_number.data(), i_event, number_of_events}; - const Velo::Consolidated::ConstStates velo_beamline_states( - velo_kalman_beamline_states.data(), velo_tracks.total_number_of_tracks()); - const Velo::Consolidated::ConstStates velo_endvelo_states( - velo_kalman_endvelo_states.data(), velo_tracks.total_number_of_tracks()); - const unsigned velo_event_tracks_offset = velo_tracks.tracks_offset(i_event); - - const UT::Consolidated::ConstExtendedTracks ut_tracks {atomics_ut.data(), - ut_track_hit_number.data(), - ut_qop.data(), - ut_track_velo_indices.data(), - i_event, - number_of_events}; - - const unsigned number_of_tracks = ut_tracks.number_of_tracks(i_event); + const auto ut_tracks_view = + static_cast(allen_ut_tracks_mec[0])->container(i_event); + const unsigned number_of_tracks = ut_tracks_view.size(); + std::vector output; output.reserve(number_of_tracks); @@ -122,44 +81,46 @@ std::vector GaudiAllenUTToV2Tracks::operator()( auto& newTrack = output.emplace_back(); // add UT hits - std::vector ut_ids = ut_tracks.get_lhcbids_for_track(ut_track_hits.data(), t); - for (const auto id : ut_ids) { + const auto track = ut_tracks_view.track(t); + const unsigned n_hits = track.number_of_ids(); + for (unsigned int i = 0; i < n_hits; i++) { + const auto id = track.id(i); const LHCb::LHCbID lhcbid = LHCb::LHCbID(id); newTrack.addToLhcbIDs(lhcbid); } // add Velo hits - const int velo_track_index = ut_tracks.velo_track(t); - std::vector velo_ids = velo_tracks.get_lhcbids_for_track(velo_track_hits.data(), velo_track_index); - for (const auto id : velo_ids) { + const auto velo_track = track.velo_track(); + const unsigned n_velo_hits = velo_track.number_of_ids(); + for (unsigned int i = 0; i < n_velo_hits; i++) { + const auto id = velo_track.id(i); const LHCb::LHCbID lhcbid = LHCb::LHCbID(id); newTrack.addToLhcbIDs(lhcbid); } // set state at beamline - const unsigned velo_state_index = velo_event_tracks_offset + velo_track_index; - const auto velo_beamline_state = velo_beamline_states.get(velo_state_index); + const auto velo_beamline_state = velo_track.state(allen_beamline_states[0]); LHCb::State closesttobeam_state; - const float qop = ut_tracks.qop(t); + const float qop = track.qop(); closesttobeam_state.setState( - velo_beamline_state.x, - velo_beamline_state.y, - velo_beamline_state.z, - velo_beamline_state.tx, - velo_beamline_state.ty, + velo_beamline_state.x(), + velo_beamline_state.y(), + velo_beamline_state.z(), + velo_beamline_state.tx(), + velo_beamline_state.ty(), qop); closesttobeam_state.setLocation(LHCb::State::Location::ClosestToBeam); newTrack.addToStates(closesttobeam_state); // set state at endvelo - const auto velo_endvelo_state = velo_endvelo_states.get(velo_state_index); + const auto velo_endvelo_state = velo_track.state(allen_endvelo_states[0]); LHCb::State endvelo_state; endvelo_state.setState( - velo_endvelo_state.x, - velo_endvelo_state.y, - velo_endvelo_state.z, - velo_endvelo_state.tx, - velo_endvelo_state.ty, + velo_endvelo_state.x(), + velo_endvelo_state.y(), + velo_endvelo_state.z(), + velo_endvelo_state.tx(), + velo_endvelo_state.ty(), qop); endvelo_state.setLocation(LHCb::State::Location::EndVelo); newTrack.addToStates(endvelo_state); diff --git a/Rec/Allen/src/GaudiAllenVeloToV2Tracks.cpp b/Rec/Allen/src/GaudiAllenVeloToV2Tracks.cpp index f46b408485d4539c821ea8b8a86fb2a2769bfa6b..c5ba743abd674ca6e6dd9b08f9aa045bd33cc059 100644 --- a/Rec/Allen/src/GaudiAllenVeloToV2Tracks.cpp +++ b/Rec/Allen/src/GaudiAllenVeloToV2Tracks.cpp @@ -12,26 +12,23 @@ // Allen #include "Logger.h" #include "VeloConsolidated.cuh" +#include "States.cuh" /** * Convert Velo::Consolidated::Tracks into LHCb::Event::v2::Track */ class GaudiAllenVeloToV2Tracks final : public Gaudi::Functional::Transformer( - const std::vector&, - const std::vector&, - const std::vector&, - const std::vector&)> { + const std::vector&, + const std::vector&)> { public: /// Standard constructor GaudiAllenVeloToV2Tracks(const std::string& name, ISvcLocator* pSvcLocator); /// Algorithm execution std::vector operator()( - const std::vector& allen_velo_track_atomics, - const std::vector& allen_velo_track_offsets, - const std::vector& allen_velo_track_hits, - const std::vector& allen_velo_kalman_states) const override; + const std::vector& allen_velo_tracks_mec, + const std::vector& allen_velo_kalman_states) const override; private: Gaudi::Property m_ptVelo {this, "ptVelo", 400 * Gaudi::Units::MeV, "Default pT for Velo tracks"}; @@ -44,30 +41,21 @@ GaudiAllenVeloToV2Tracks::GaudiAllenVeloToV2Tracks(const std::string& name, ISvc name, pSvcLocator, // Inputs - {KeyValue {"AllenVeloTrackOffsets", ""}, - KeyValue {"AllenVeloTrackHitOffsets", ""}, - KeyValue {"AllenVeloTrackHits", ""}, - KeyValue {"AllenVeloKalmanStates", ""}}, + {KeyValue {"allen_velo_tracks_mec", ""}, KeyValue {"allen_velo_states_view", ""}}, // Outputs {KeyValue {"OutputTracks", "Allen/Track/v2/Velo"}}) {} std::vector GaudiAllenVeloToV2Tracks::operator()( - const std::vector& allen_velo_track_offsets, - const std::vector& allen_velo_track_hit_offsets, - const std::vector& allen_velo_track_hits, - const std::vector& allen_velo_kalman_states) const + const std::vector& allen_velo_tracks_mec, + const std::vector& allen_velo_kalman_states) const { // Make the consolidated tracks. const unsigned i_event = 0; - const unsigned number_of_events = 1; - const Velo::Consolidated::Tracks velo_tracks { - allen_velo_track_offsets.data(), allen_velo_track_hit_offsets.data(), i_event, number_of_events}; - const Velo::Consolidated::ConstStates velo_states( - allen_velo_kalman_states.data(), velo_tracks.total_number_of_tracks()); - const unsigned event_tracks_offset = velo_tracks.tracks_offset(i_event); - - const unsigned number_of_tracks = velo_tracks.number_of_tracks(i_event); + const auto velo_tracks_view = + static_cast(allen_velo_tracks_mec[0])->container(i_event); + const unsigned number_of_tracks = velo_tracks_view.size(); + std::vector output; output.reserve(number_of_tracks); @@ -77,34 +65,29 @@ std::vector GaudiAllenVeloToV2Tracks::operator()( auto& newTrack = output.emplace_back(); // add Velo hits - Velo::Consolidated::ConstHits track_hits = velo_tracks.get_hits(allen_velo_track_hits.data(), t); - for (unsigned i = 0; i < velo_tracks.number_of_hits(t); ++i) { - const auto id = track_hits.id(i); + const auto track = velo_tracks_view.track(t); + const unsigned n_hits = track.number_of_ids(); + for (unsigned i = 0; i < n_hits; ++i) { + const auto id = track.id(i); const LHCb::LHCbID lhcbid {id}; newTrack.addToLhcbIDs(lhcbid); if (msgLevel(MSG::DEBUG)) debug() << "Adding LHCbID " << std::hex << id << std::dec << endmsg; } // set state at beamline - const unsigned current_track_offset = event_tracks_offset + t; + const auto state = track.state(allen_velo_kalman_states[0]); LHCb::State closesttobeam_state; - closesttobeam_state.setState( - velo_states.x(current_track_offset), - velo_states.y(current_track_offset), - velo_states.z(current_track_offset), - velo_states.tx(current_track_offset), - velo_states.ty(current_track_offset), - 0.f); - closesttobeam_state.covariance()(0, 0) = velo_states.c00(current_track_offset); - closesttobeam_state.covariance()(1, 1) = velo_states.c11(current_track_offset); - closesttobeam_state.covariance()(0, 2) = velo_states.c20(current_track_offset); - closesttobeam_state.covariance()(2, 2) = velo_states.c22(current_track_offset); - closesttobeam_state.covariance()(1, 3) = velo_states.c31(current_track_offset); - closesttobeam_state.covariance()(3, 3) = velo_states.c33(current_track_offset); + closesttobeam_state.setState(state.x(), state.y(), state.z(), state.tx(), state.ty(), 0.f); + closesttobeam_state.covariance()(0, 0) = state.c00(); + closesttobeam_state.covariance()(1, 1) = state.c11(); + closesttobeam_state.covariance()(0, 2) = state.c20(); + closesttobeam_state.covariance()(2, 2) = state.c22(); + closesttobeam_state.covariance()(1, 3) = state.c31(); + closesttobeam_state.covariance()(3, 3) = state.c33(); closesttobeam_state.setLocation(LHCb::State::Location::ClosestToBeam); newTrack.addToStates(closesttobeam_state); - const bool backward = closesttobeam_state.z() > track_hits.z(0); + const bool backward = closesttobeam_state.z() > track.hit(0).z(); if (backward) newTrack.setType(LHCb::Event::v2::Track::Type::VeloBackward); diff --git a/Rec/Allen/src/GaudiAllenVeloToV2Tracks.h b/Rec/Allen/src/GaudiAllenVeloToV2Tracks.h deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000