ATLAS Offline Software
HadronOriginDecorator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 
9 namespace DerivationFramework {
10 
11  HadronOriginDecorator::HadronOriginDecorator(const std::string& t, const std::string& n, const IInterface* p):
12  AthAlgTool(t,n,p),
13  m_Tool("")
14  {
15  declareInterface<DerivationFramework::IAugmentationTool>(this);
16 
17  declareProperty("ToolName",m_Tool);
18  declareProperty("TruthEventName",m_TruthEventName="TruthParticles");
19  }
20 
22 
24  ATH_MSG_INFO("Initialize " );
25 
26  if(m_Tool.retrieve().isFailure()){
27  ATH_MSG_ERROR("unable to retrieve the tool " <<m_Tool);
28  return StatusCode::FAILURE;
29  }
30 
31  return StatusCode::SUCCESS;
32  }
33 
35  return StatusCode::SUCCESS;
36  }
37 
39  const xAOD::TruthParticleContainer* xTruthParticleContainer = nullptr;
40  if (evtStore()->retrieve(xTruthParticleContainer,m_TruthEventName).isFailure()) {
41  ATH_MSG_WARNING("could not retrieve TruthParticleContainer " <<m_TruthEventName);
42  return StatusCode::FAILURE;
43  }
44 
45  std::map<const xAOD::TruthParticle*, DerivationFramework::HadronOriginClassifier::HF_id> hadronMap=m_Tool->GetOriginMap();
46 
47  for(xAOD::TruthParticleContainer::const_iterator PItr = xTruthParticleContainer->begin(); PItr!=xTruthParticleContainer->end(); ++PItr){
48  int flavortype=6;
49  if(hadronMap.find((*PItr))!=hadronMap.end()){
50  flavortype= static_cast<int>(hadronMap[(*PItr)]);
51  }
52  SG::AuxElement::Decorator< int > decoration("TopHadronOriginFlag");
53  decoration(**PItr) = flavortype;
54  }
55 
56  return StatusCode::SUCCESS;
57  }
58 
59 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
DerivationFramework::HadronOriginDecorator::~HadronOriginDecorator
~HadronOriginDecorator()
Definition: HadronOriginDecorator.cxx:21
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TruthParticleContainer.h
HadronOriginClassifier.h
DerivationFramework::HadronOriginDecorator::m_TruthEventName
std::string m_TruthEventName
Definition: HadronOriginDecorator.h:40
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
DerivationFramework::HadronOriginDecorator::m_Tool
ToolHandle< DerivationFramework::HadronOriginClassifier > m_Tool
Definition: HadronOriginDecorator.h:41
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DerivationFramework::HadronOriginDecorator::HadronOriginDecorator
HadronOriginDecorator(const std::string &t, const std::string &n, const IInterface *p)
Definition: HadronOriginDecorator.cxx:11
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DerivationFramework::HadronOriginDecorator::addBranches
virtual StatusCode addBranches() const
Pass the thinning service
Definition: HadronOriginDecorator.cxx:38
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
AthAlgTool
Definition: AthAlgTool.h:26
HadronOriginDecorator.h
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
DerivationFramework::HadronOriginDecorator::initialize
StatusCode initialize()
Definition: HadronOriginDecorator.cxx:23
DerivationFramework::HadronOriginDecorator::finalize
StatusCode finalize()
Definition: HadronOriginDecorator.cxx:34