26#include "Gaudi/Property.h"
27#include "GaudiKernel/ThreadLocalContext.h"
38 const std::string& name,
39 ISvcLocator* pSvcLocator)
56 ATH_MSG_INFO(
"InDetForwardTrackParticles thinning not required");
58 ATH_MSG_INFO(
"InDetForwardTrackParticles will be thinned");
63 return StatusCode::FAILURE;
67 ATH_MSG_DEBUG(
"==> done with initialize " << name() <<
"...");
69 return StatusCode::SUCCESS;
79 <<
" were SiliconAssociatedForward muons");
81 <<
" of the SiliconAssociatedForward muons were "
82 "associated with InDetForwardTrackParticles");
84 return StatusCode::SUCCESS;
95 return StatusCode::SUCCESS;
102 std::vector<bool> trackMask;
103 unsigned int nTracks = tracks->size();
105 trackMask.assign(nTracks,
false);
107 unsigned int nSiFwdAssoc = 0;
108 unsigned int nSiFwdMuons = 0;
117 m_nMuons.fetch_add(muons->size(), std::memory_order_relaxed);
119 for (
const auto* muon : *muons) {
120 if (muon->muonType() == xAOD::Muon::SiliconAssociatedForwardMuon) {
123 if (muon->inDetTrackParticleLink().isValid())
124 muTrk = *(muon->inDetTrackParticleLink());
125 if (muTrk !=
nullptr) {
126 auto search = std::find(tracks->begin(), tracks->end(), muTrk);
127 if (
search != tracks->end()) {
129 trackMask[(*search)->index()] =
true;
136 m_nSiFwdAssoc.fetch_add(nSiFwdAssoc, std::memory_order_relaxed);
137 m_nSiFwdMuons.fetch_add(nSiFwdMuons, std::memory_order_relaxed);
140 unsigned int nTracksThinned = 0;
141 for (
unsigned int i = 0; i < nTracks; ++i) {
147 tracks.
keep(trackMask);
149 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
Handle class for reading from StoreGate.
Handle for requesting thinning for a data object.
An algorithm that can be simultaneously executed in multiple threads.
void keep(size_t ndx)
Mark that index ndx in the container should be kept (not thinned away).
Handle for requesting thinning for a data object.
std::atomic< unsigned long > m_nSiFwdAssoc
std::atomic< unsigned long > m_nEventsProcessed
Counters.
std::atomic< unsigned long > m_nTracksThinned
StringProperty m_streamName
ThinInDetForwardTrackParticlesAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
virtual StatusCode initialize() override
Athena algorithm's initalize hook.
std::atomic< unsigned long > m_nSiFwdMuons
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_tracksKey
virtual StatusCode execute(const EventContext &ctx) const override
Athena algorithm's execute hook.
virtual StatusCode finalize() override
Athena algorithm's finalize hook.
std::atomic< unsigned long > m_nMuons
SG::ReadHandleKey< xAOD::MuonContainer > m_muonsKey
std::atomic< unsigned long > m_nTracksProcessed
BooleanProperty m_doThinning
Should the thinning run?
void search(TDirectory *td, const std::string &s, std::string cwd, node *n)
recursive directory search for TH1 and TH2 and TProfiles
TrackParticle_v1 TrackParticle
Reference the current persistent version: