ATLAS Offline Software
IsolationTool_AthTest.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // IsolationTool includes
7 // #include "xAODTracking/TrackingPrimitives.h"
8 // #include "xAODTracking/TrackParticleContainer.h"
9 
10 static const int NDIFF = xAOD::Iso::ptvarcone20 - xAOD::Iso::ptcone20;
11 
12 IsolationTool_AthTest::IsolationTool_AthTest( const std::string& name, ISvcLocator* pSvcLocator ) : AthAlgorithm( name, pSvcLocator ),
13 m_trackIsolationTool(),
14 m_caloIsolationTool(),
15 m_decorators(xAOD::Iso::numIsolationTypes, nullptr)
16 {
17 
18  //declareProperty( "Property", m_nProperty ); //example property declaration
19 declareProperty("TrackIsolationTool", m_trackIsolationTool);
20 declareProperty("CaloIsolationTool", m_caloIsolationTool);
21 declareProperty("TargetContainer", m_containerName = "InDetTrackParticles");
22 declareProperty("ptcones", m_ptcones);
23 declareProperty("topoetcones", m_topoetcones);
24 declareProperty("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 retrived 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){
53  m_decorators[c] = new SG::AuxElement::Decorator< float >(m_prefix+xAOD::Iso::toCString(t));
54  m_decorators[c+NDIFF] = new SG::AuxElement::Decorator< float >(m_prefix+xAOD::Iso::toCString(static_cast<xAOD::Iso::IsolationType>(c+NDIFF)));
55  m_ptconeTypes.push_back(t);
56  }
57  m_topoetconeTypes.clear();
58  for(auto c: m_topoetcones) {
60  m_decorators[c] = new SG::AuxElement::Decorator< float >(m_prefix+xAOD::Iso::toCString(t));
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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
xAOD::Iso::ptvarcone20
@ ptvarcone20
Mini-Isolation http://arxiv.org/abs/1007.2221.
Definition: IsolationType.h:55
IsolationTool_AthTest::finalize
virtual StatusCode finalize()
Definition: IsolationTool_AthTest.cxx:67
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::TrackIsolation::ptvarcones_10GeVDivPt
std::vector< float > ptvarcones_10GeVDivPt
Definition: IsolationCommon.h:37
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
IsolationTool_AthTest::m_prefix
std::string m_prefix
Definition: IsolationTool_AthTest.h:25
hist_file_dump.d
d
Definition: hist_file_dump.py:137
xAOD::Iso::coreTrackPtr
@ coreTrackPtr
tracks pointer
Definition: Event/xAOD/xAODPrimitives/xAODPrimitives/IsolationCorrection.h:66
IsolationTool_AthTest::m_decorators
std::vector< SG::AuxElement::Decorator< float > * > m_decorators
Definition: IsolationTool_AthTest.h:36
IsolationTool_AthTest::m_trkCorrList
xAOD::TrackCorrection m_trkCorrList
Definition: IsolationTool_AthTest.h:31
xAOD::TrackCorrection::trackbitset
Iso::IsolationTrackCorrectionBitset trackbitset
Definition: IsolationCommon.h:19
xAOD::Iso::ptcone20
@ ptcone20
Track isolation.
Definition: IsolationType.h:40
IsolationTool_AthTest::initialize
virtual StatusCode initialize()
Definition: IsolationTool_AthTest.cxx:31
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
IsolationTool_AthTest::m_topoetconeTypes
std::vector< xAOD::Iso::IsolationType > m_topoetconeTypes
Definition: IsolationTool_AthTest.h:32
IsolationTool_AthTest::m_ptcones
std::vector< int > m_ptcones
Definition: IsolationTool_AthTest.h:30
xAOD::CaloIsolation
Definition: IsolationCommon.h:22
CP::Iso
@ Iso
Definition: MuonEfficiencyType.h:16
IsolationTool_AthTest::m_topoetcones
std::vector< int > m_topoetcones
Definition: IsolationTool_AthTest.h:33
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::Iso::IsolationType
IsolationType
Overall enumeration for isolation types in xAOD files.
Definition: IsolationType.h:26
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
IsolationTool_AthTest::m_trackIsolationTool
ToolHandle< xAOD::ITrackIsolationTool > m_trackIsolationTool
Definition: IsolationTool_AthTest.h:27
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
AthAlgorithm
Definition: AthAlgorithm.h:47
IsolationTool_AthTest::execute
virtual StatusCode execute()
Definition: IsolationTool_AthTest.cxx:75
xAOD::TrackIsolation
Definition: IsolationCommon.h:33
IsolationTool_AthTest::~IsolationTool_AthTest
virtual ~IsolationTool_AthTest()
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
xAOD::CaloIsolation::etcones
std::vector< float > etcones
Definition: IsolationCommon.h:30
xAOD::Iso::coreCone
@ coreCone
core energy (in dR<0.1).
Definition: Event/xAOD/xAODPrimitives/xAODPrimitives/IsolationCorrection.h:29
xAOD::TrackIsolation::ptcones
std::vector< float > ptcones
Definition: IsolationCommon.h:36
IsolationTool_AthTest::IsolationTool_AthTest
IsolationTool_AthTest(const std::string &name, ISvcLocator *pSvcLocator)
Definition: IsolationTool_AthTest.cxx:12
IsolationTool_AthTest::m_containerName
std::string m_containerName
Definition: IsolationTool_AthTest.h:24
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
xAOD::Iso::numIsolationTypes
@ numIsolationTypes
Definition: IsolationType.h:118
IsolationTool_AthTest::m_caloCorrList
xAOD::CaloCorrection m_caloCorrList
Definition: IsolationTool_AthTest.h:34
IsolationTool_AthTest.h
python.compressB64.c
def c
Definition: compressB64.py:93
IsolationTool_AthTest::m_caloIsolationTool
ToolHandle< xAOD::ICaloTopoClusterIsolationTool > m_caloIsolationTool
Definition: IsolationTool_AthTest.h:28
IsolationTool_AthTest::m_ptconeTypes
std::vector< xAOD::Iso::IsolationType > m_ptconeTypes
Definition: IsolationTool_AthTest.h:29
xAOD::CaloCorrection::calobitset
Iso::IsolationCaloCorrectionBitset calobitset
Definition: IsolationCommon.h:15
xAOD::Iso::pileupCorrection
@ pileupCorrection
fully corrected
Definition: Event/xAOD/xAODPrimitives/xAODPrimitives/IsolationCorrection.h:35