ATLAS Offline Software
PFTrackMuonCaloTaggingAlg.cxx
Go to the documentation of this file.
2 #include "StoreGate/ReadHandle.h"
5 
6 PFTrackMuonCaloTaggingAlg::PFTrackMuonCaloTaggingAlg(const std::string &name, ISvcLocator *pSvcLocator)
7  : AthReentrantAlgorithm(name, pSvcLocator)
8 {
9 }
10 
12 
14 {
16  ATH_CHECK(m_caloExtensionKey.initialize());
19  ATH_CHECK(m_looseMuonTagTool.retrieve());
20  ATH_CHECK(m_tightMuonTagTool.retrieve());
21  ATH_CHECK(m_muonScoreTool.retrieve());
22  ATH_CHECK(m_depositInCaloTool.retrieve());
23  return StatusCode::SUCCESS;
24 }
25 
26 StatusCode PFTrackMuonCaloTaggingAlg::execute(const EventContext &ctx) const
27 {
29  if (!inputTracks.isValid())
30  {
31  ATH_MSG_ERROR("Failed to retrieve " << m_inputTracksKey);
32  return StatusCode::FAILURE;
33  }
34  auto inputCells = SG::makeHandle(m_inputCellsKey, ctx);
35  if (!inputCells.isValid())
36  {
37  ATH_MSG_ERROR("Failed to retrieve " << m_inputCellsKey);
38  return StatusCode::FAILURE;
39  }
40  auto inputCaloExtensions = SG::makeHandle(m_caloExtensionKey, ctx);
41  if (!inputCaloExtensions.isValid())
42  {
43  ATH_MSG_ERROR("Failed to retrieve " << m_caloExtensionKey);
44  return StatusCode::FAILURE;
45  }
46  auto outputHandle = SG::makeHandle(m_outputTracksKey, ctx);
47 
48  auto outputTracks = std::make_unique<ConstDataVector<xAOD::TrackParticleContainer>>(SG::VIEW_ELEMENTS);
49  for (const xAOD::TrackParticle *itrk : *inputTracks)
50  {
51  if (itrk->pt() > m_minPt)
52  {
53  std::vector<DepositInCalo> deposits = m_depositInCaloTool->getDeposits(itrk, inputCells.ptr(), inputCaloExtensions.ptr());
54  int looseTag = m_looseMuonTagTool->caloMuonTag(deposits, itrk->eta(), itrk->pt());
55  int tightTag = m_tightMuonTagTool->caloMuonTag(deposits, itrk->eta(), itrk->pt());
56  float score = m_muonScoreTool->getMuonScore(itrk, inputCells.ptr(), inputCaloExtensions.ptr());
57  if (tightTag || (score > m_caloMuonScoreCut && looseTag))
58  // This means that the track is tagged as a muon, so don't output it
59  continue;
60  }
61  outputTracks->push_back(itrk);
62  }
63  ATH_CHECK(outputHandle.put(ctx, std::move(outputTracks)) != nullptr);
64  return StatusCode::SUCCESS;
65 }
PFTrackMuonCaloTaggingAlg::m_muonScoreTool
ToolHandle< ICaloMuonScoreTool > m_muonScoreTool
Definition: PFTrackMuonCaloTaggingAlg.h:51
PFTrackMuonCaloTaggingAlg::m_looseMuonTagTool
ToolHandle< ICaloMuonTag > m_looseMuonTagTool
Definition: PFTrackMuonCaloTaggingAlg.h:47
PFTrackMuonCaloTaggingAlg::PFTrackMuonCaloTaggingAlg
PFTrackMuonCaloTaggingAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: PFTrackMuonCaloTaggingAlg.cxx:6
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
PFTrackMuonCaloTaggingAlg::m_outputTracksKey
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_outputTracksKey
The output tracks, excluding those identified as muons.
Definition: PFTrackMuonCaloTaggingAlg.h:45
PFTrackMuonCaloTaggingAlg::m_caloExtensionKey
SG::ReadHandleKey< CaloExtensionCollection > m_caloExtensionKey
The input calorimeter extension.
Definition: PFTrackMuonCaloTaggingAlg.h:39
PFTrackMuonCaloTaggingAlg::m_minPt
Gaudi::Property< float > m_minPt
Definition: PFTrackMuonCaloTaggingAlg.h:55
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
WriteHandle.h
Handle class for recording to StoreGate.
PFTrackMuonCaloTaggingAlg::~PFTrackMuonCaloTaggingAlg
virtual ~PFTrackMuonCaloTaggingAlg() override
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
python.TrigInDetConfig.inputTracks
inputTracks
Definition: TrigInDetConfig.py:168
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
PFTrackMuonCaloTaggingAlg::initialize
virtual StatusCode initialize() override
Definition: PFTrackMuonCaloTaggingAlg.cxx:13
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
PFTrackMuonCaloTaggingAlg::m_inputCellsKey
SG::ReadHandleKey< CaloCellContainer > m_inputCellsKey
Input cells. It's generally more efficient to pass these in this way.
Definition: PFTrackMuonCaloTaggingAlg.h:42
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
PFTrackMuonCaloTaggingAlg::m_caloMuonScoreCut
Gaudi::Property< float > m_caloMuonScoreCut
Definition: PFTrackMuonCaloTaggingAlg.h:57
PFTrackMuonCaloTaggingAlg.h
xAOD::score
@ score
Definition: TrackingPrimitives.h:513
PFTrackMuonCaloTaggingAlg::m_depositInCaloTool
ToolHandle< ITrackDepositInCaloTool > m_depositInCaloTool
Definition: PFTrackMuonCaloTaggingAlg.h:53
PFTrackMuonCaloTaggingAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: PFTrackMuonCaloTaggingAlg.cxx:26
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
ReadHandle.h
Handle class for reading from StoreGate.
PFTrackMuonCaloTaggingAlg::m_inputTracksKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_inputTracksKey
The input track collection.
Definition: PFTrackMuonCaloTaggingAlg.h:36
PFTrackMuonCaloTaggingAlg::m_tightMuonTagTool
ToolHandle< ICaloMuonTag > m_tightMuonTagTool
Definition: PFTrackMuonCaloTaggingAlg.h:49