9#include "GaudiKernel/SystemOfUnits.h"
11constexpr float invGeV = 1./CLHEP::GeV;
38 return StatusCode::SUCCESS;
51 ATH_CHECK(eflowRecTracksWriteHandle.
record(std::make_unique<eflowRecTrackContainer>()));
55 if (!tracksReadHandle.
isValid()) {
56 ATH_MSG_WARNING(
"Can not retrieve xAOD::TrackParticleContainer with name: " << tracksReadHandle.
key());
57 return StatusCode::FAILURE;
61 std::optional<SG::ReadHandle<xAOD::ElectronContainer>> electronsReadHandle;
64 ATH_CHECK(electronsReadHandle->isValid());
65 electrons = electronsReadHandle->cptr();
68 std::optional<SG::ReadHandle<xAOD::MuonContainer>> muonsReadHandle;
72 muons = muonsReadHandle->cptr();
76 eflowRecTracksWriteHandle->reserve(
static_cast<size_t>(0.8*tracksReadHandle->size()));
79 for (
const auto *thisTrack : *tracksReadHandle){
86 ATH_MSG_DEBUG(
"Have track with E, pt, eta and phi of " << thisTrack->e() <<
", " << thisTrack->pt() <<
", "
87 << thisTrack->eta() <<
" and " << thisTrack->phi());
91 if (rejectTrack)
continue;
101 eta_track = thisTrack->eta();
102 pt_track = thisTrack->pt() *
invGeV;
106 unsigned int trackIndex = thisTrack->index();
108 thisEFRecTrack->setTrackId(trackIndex);
109 eflowRecTracksWriteHandle->push_back(std::move(thisEFRecTrack));
117 N_tracks = eflowRecTracksWriteHandle->size();
119 return StatusCode::SUCCESS;
143 unsigned int nTrack = thisElectron->nTrackParticles();
148 if (track == origTrack) {
153 ATH_MSG_WARNING(
"Electron object map has NULL pointer to original TrackParticle");
173 ATH_MSG_DEBUG(
"Considering muon in isMuon with e,pt, eta and phi of "
174 << theMuon->e() <<
", " << theMuon->pt() <<
", " << theMuon->eta() <<
" and " << theMuon->phi());
175 const xAOD::TrackParticle* ID_track = theMuon->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle);
176 if (track == ID_track){
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
xAOD::ElectronContainer * electronContainer
xAOD::MuonContainer * muonContainer
An algorithm that can be simultaneously executed in multiple threads.
ElementLink implementation for ROOT usage.
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
Helper class to create a scoped timer.
bool selectTrack(const xAOD::TrackParticle &track) const
This applys a selection criteria to the track using the tracking CP track selection tool.
bool isMuon(const xAOD::TrackParticle *track, const xAOD::MuonContainer *muonContainer) const
check if track belongs to an muon
SG::WriteHandleKey< eflowRecTrackContainer > m_eflowRecTracksWriteHandleKey
WriteHandleKey for the eflowRecTrackContainer to write out.
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexKey
PFTrackSelector(const std::string &name, ISvcLocator *pSvcLocator)
Default constructor.
StatusCode initialize()
Gaudi AthReentrantAlgorithm hooks.
ToolHandle< eflowTrackExtrapolatorBaseAlgTool > m_theTrackExtrapolatorTool
ToolHandle for track extrapolation to calorimeter tool.
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_tracksReadHandleKey
ReadHandleKey for the TrackParticleContainer to be used as input.
StatusCode execute(const EventContext &ctx) const
ToolHandle< InDet::IInDetTrackSelectionTool > m_trackSelectorTool
ToolHandle to track selection tool provided by tracking CP.
SG::ReadHandleKey< xAOD::MuonContainer > m_muonsReadHandleKey
ReadHandleKey for the MuonContainer to be used as input.
ToolHandle< GenericMonitoringTool > m_monTool
Online monitoring tool for recording histograms of the alg in action.
bool isElectron(const xAOD::TrackParticle *track, const xAOD::ElectronContainer *electronContainer) const
check if track belongs to an electron
SG::ReadHandleKey< xAOD::ElectronContainer > m_electronsReadHandleKey
ReadHandleKey for the ElectronContainer to be used as input.
Gaudi::Property< float > m_upperTrackPtCut
Upper limit on track Pt for input tracks.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
const xAOD::TrackParticle * getOriginalTrackParticle(const xAOD::Electron *el)
Helper function for getting the "Original" Track Particle (i.e before GSF) via the electron.
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".