ATLAS Offline Software
Loading...
Searching...
No Matches
IsolationTool_AthTest.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// IsolationTool includes
7// #include "xAODTracking/TrackingPrimitives.h"
8// #include "xAODTracking/TrackParticleContainer.h"
9
11
12IsolationTool_AthTest::IsolationTool_AthTest( const std::string& name, ISvcLocator* pSvcLocator ) : AthAlgorithm( name, pSvcLocator ),
15m_decorators(xAOD::Iso::numIsolationTypes, nullptr)
16{
17
18 //declareProperty( "Property", m_nProperty ); //example property declaration
19declareProperty("TrackIsolationTool", m_trackIsolationTool);
20declareProperty("CaloIsolationTool", m_caloIsolationTool);
21declareProperty("TargetContainer", m_containerName = "InDetTrackParticles");
22declareProperty("ptcones", m_ptcones);
23declareProperty("topoetcones", m_topoetcones);
24declareProperty("Prefix", m_prefix="");
25}
26
27
29
30
32 ATH_MSG_INFO ("Initializing " << name() << "...");
33
34 // load the matching tool
35 if( ! m_caloIsolationTool.empty() ) {
36 CHECK( m_caloIsolationTool.retrieve() );
37 ATH_MSG_INFO( "Successfully retrieved the CaloIsolationTool!" );
38 }
39
40 if( ! m_trackIsolationTool.empty() ) {
41 CHECK( m_trackIsolationTool.retrieve() );
42 ATH_MSG_INFO( "Successfully retrived the CaloIsolationTool!" );
43 }
44
45 m_trkCorrList.trackbitset.set(static_cast<unsigned int>(xAOD::Iso::coreTrackPtr));
46 m_caloCorrList.calobitset.set(static_cast<unsigned int>(xAOD::Iso::coreCone));
47 m_caloCorrList.calobitset.set(static_cast<unsigned int>(xAOD::Iso::pileupCorrection));
48
50 m_ptconeTypes.clear();
51 for(auto c: m_ptcones){
55 m_ptconeTypes.push_back(t);
56 }
57 m_topoetconeTypes.clear();
58 for(auto c: m_topoetcones) {
61 m_topoetconeTypes.push_back(t);
62 }
63
64 return StatusCode::SUCCESS;
65}
66
68 ATH_MSG_INFO ("Finalizing " << name() << "...");
69
70 for(auto *d: m_decorators) {if(d) delete d;}
71
72 return StatusCode::SUCCESS;
73}
74
76 ATH_MSG_DEBUG ("Executing " << name() << "...");
77
78 // retrieve tag (muon) container
79 const xAOD::IParticleContainer* toDecorate = nullptr;
80 if(evtStore()->retrieve(toDecorate, m_containerName).isFailure()) {
81 ATH_MSG_FATAL( "Unable to retrieve " << m_containerName );
82 return StatusCode::FAILURE;
83 }
84
86 for(const auto *particle : *toDecorate) {
87
89 xAOD::TrackIsolation resultTrack;
90 if (m_trackIsolationTool->trackIsolation(resultTrack, *particle, m_ptconeTypes, m_trkCorrList)){
91 for(unsigned int i=0; i<m_ptcones.size(); i++){
92 (*(m_decorators[m_ptcones[i]]))(*particle) = resultTrack.ptcones[i];
93 (*(m_decorators[m_ptcones[i]+NDIFF]))(*particle) = resultTrack.ptvarcones_10GeVDivPt[i];
94 ATH_MSG_DEBUG("ptcone" << i << " " << resultTrack.ptcones[i] << " & " << resultTrack.ptvarcones_10GeVDivPt[i]);
95 }
96 }else{
97 ATH_MSG_WARNING("Failed to apply the track isolation for a particle");
98 }
99
101 xAOD::CaloIsolation resultCalo;
102 if (m_caloIsolationTool->caloTopoClusterIsolation(resultCalo, *particle, m_topoetconeTypes, m_caloCorrList)){
103 for(unsigned int i=0; i<m_topoetcones.size(); i++){
104 (*(m_decorators[m_topoetcones[i]]))(*particle) = resultCalo.etcones[i];
105 ATH_MSG_DEBUG("topoetcone" << i << " " << resultCalo.etcones[i]);
106 }
107 }else {
108 ATH_MSG_WARNING("Failed to apply the calo isolation for a particle");
109 }
110 }
111
112 return StatusCode::SUCCESS;
113}
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
static const int NDIFF
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::vector< int > m_ptcones
std::vector< int > m_topoetcones
std::vector< SG::AuxElement::Decorator< float > * > m_decorators
std::vector< xAOD::Iso::IsolationType > m_ptconeTypes
xAOD::CaloCorrection m_caloCorrList
virtual ~IsolationTool_AthTest()
ToolHandle< xAOD::ICaloTopoClusterIsolationTool > m_caloIsolationTool
virtual StatusCode initialize()
IsolationTool_AthTest(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode finalize()
virtual StatusCode execute()
xAOD::TrackCorrection m_trkCorrList
std::vector< xAOD::Iso::IsolationType > m_topoetconeTypes
ToolHandle< xAOD::ITrackIsolationTool > m_trackIsolationTool
SG::Decorator< T, ALLOC > Decorator
Definition AuxElement.h:575
IsolationType
Overall enumeration for isolation types in xAOD files.
@ ptcone20
Track isolation.
@ ptvarcone20
Mini-Isolation http://arxiv.org/abs/1007.2221.
static const char * toCString(IsolationConeSize conesize)
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
std::vector< float > etcones
std::vector< float > ptcones
std::vector< float > ptvarcones_10GeVDivPt