ATLAS Offline Software
trackIsolationDecorator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // trackIsolationDecorator.cxx, (c) ATLAS Detector software
8 // Author: Christopher Young (christopher.young@cern.ch)
11 #include <vector>
12 #include <string>
13 
16 
17 // Constructor
19  const std::string& n,
20  const IInterface* p):
21  base_class(t, n, p),
22  m_trackIsolationTool(),
23  m_decorators(xAOD::Iso::numIsolationTypes, 0)
24 {
25  declareProperty("TrackIsolationTool", m_trackIsolationTool);
26  declareProperty("TargetContainer", m_containerName = "InDetTrackParticles");
27  declareProperty("ptcones", m_ptcones);
28  declareProperty("Prefix", m_prefix="");
29 }
30 
31 // Destructor
33 }
34 
35 // Athena initialize and finalize
37 {
38  ATH_MSG_VERBOSE("initialize() ...");
39 
40  // load the matching tool
41  if( ! m_trackIsolationTool.empty() ) {
42  CHECK( m_trackIsolationTool.retrieve() );
43  ATH_MSG_INFO( "Successfully retrived the TrackIsolationTool!" );
44  }
45 
46  m_trkCorrList.trackbitset.set(static_cast<unsigned int>(xAOD::Iso::coreTrackPtr));
47 
49  m_ptconeTypes.clear();
50  for(auto c: m_ptcones){
52  m_decorators[c] = new SG::AuxElement::Decorator< float >(m_prefix+xAOD::Iso::toCString(t));
53  m_ptconeTypes.push_back(t);
54  }
55 
56  return StatusCode::SUCCESS;
57 }
58 
60 {
61  ATH_MSG_VERBOSE("finalize() ...");
62 
64  for(auto d: m_decorators) {if(d) delete d;}
65 
67 
68  return StatusCode::SUCCESS;
69 }
70 
72 {
73  // retrieve container
74  const xAOD::IParticleContainer* toDecorate = 0;
75  if(evtStore()->retrieve(toDecorate, m_containerName).isFailure()) {
76  ATH_MSG_FATAL( "Unable to retrieve " << m_containerName );
77  return StatusCode::FAILURE;
78  }
79 
81  for(auto particle : *toDecorate) {
82 
84  xAOD::TrackIsolation resultTrack;
85  if (m_trackIsolationTool->trackIsolation(resultTrack, *particle, m_ptconeTypes, m_trkCorrList)){
86  for(unsigned int i=0; i<m_ptcones.size(); i++){
87 // (*(m_decorators[static_cast<int>(m_ptcones[i])]))(*particle) = resultTrack.ptcones.at(i);
88  (*(m_decorators[m_ptcones[i]]))(*particle) = resultTrack.ptcones.at(i);
89  }
90  }else{
91  ATH_MSG_WARNING("Failed to apply the track isolation for a particle");
92  }
93 
94  }
95 
96  return StatusCode::SUCCESS;
97 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
DerivationFramework::trackIsolationDecorator::~trackIsolationDecorator
~trackIsolationDecorator()
Destructor.
Definition: trackIsolationDecorator.cxx:32
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:79
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
hist_file_dump.d
d
Definition: hist_file_dump.py:142
xAOD::Iso::coreTrackPtr
@ coreTrackPtr
tracks pointer
Definition: Event/xAOD/xAODPrimitives/xAODPrimitives/IsolationCorrection.h:66
DerivationFramework::trackIsolationDecorator::addBranches
virtual StatusCode addBranches() const
Definition: trackIsolationDecorator.cxx:71
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
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
DerivationFramework::trackIsolationDecorator::m_prefix
std::string m_prefix
Definition: trackIsolationDecorator.h:41
DerivationFramework::trackIsolationDecorator::trackIsolationDecorator
trackIsolationDecorator(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
Definition: trackIsolationDecorator.cxx:18
DerivationFramework::trackIsolationDecorator::m_ptcones
std::vector< int > m_ptcones
Definition: trackIsolationDecorator.h:47
trackIsolationDecorator.h
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
CP::Iso
@ Iso
Definition: MuonEfficiencyType.h:16
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:729
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::Iso::IsolationType
IsolationType
Overall enumeration for isolation types in xAOD files.
Definition: IsolationType.h:26
DerivationFramework::trackIsolationDecorator::finalize
StatusCode finalize()
Definition: trackIsolationDecorator.cxx:59
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
DerivationFramework::trackIsolationDecorator::initialize
StatusCode initialize()
Definition: trackIsolationDecorator.cxx:36
xAOD::TrackIsolation
Definition: IsolationCommon.h:33
errorcheck.h
Helpers for checking error return status codes and reporting errors.
DerivationFramework::trackIsolationDecorator::m_trackIsolationTool
ToolHandle< xAOD::ITrackIsolationTool > m_trackIsolationTool
Athena configured tools.
Definition: trackIsolationDecorator.h:44
xAOD::TrackIsolation::ptcones
std::vector< float > ptcones
Definition: IsolationCommon.h:36
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
DerivationFramework::trackIsolationDecorator::m_containerName
std::string m_containerName
Definition: trackIsolationDecorator.h:40
xAOD::Iso::numIsolationTypes
@ numIsolationTypes
Definition: IsolationType.h:118
python.compressB64.c
def c
Definition: compressB64.py:93
TrackingPrimitives.h
TrackParticleContainer.h