ATLAS Offline Software
UnassociatedHitsDecorator.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 // Author: Olivier Arnaez ( olivier.arnaez@cern.ch )
6 
10 
11 #include <vector>
12 #include <utility>
13 #include <string>
14 
15 namespace DerivationFramework {
16 
18  {
19 
20  if (m_sgName.empty()) {
21  ATH_MSG_WARNING("No decoration prefix name provided for the output of UnassociatedHitsDecorator!");
22  }
23 
24  if (m_eventInfoKey.empty()) {
25  ATH_MSG_ERROR("No EventInfo collection provided for UnassociatedHitsDecorator!");
26  return StatusCode::FAILURE;
27  }
29  // retrieve PRD association tool
31 
32  { // FIXME DecorHandleKeys should be properly configured in the python layer
33  std::vector<std::string> names;
34  names.resize(kNIntDecor);
35  names[knPixelUADecor] ="nPixelUA";
36  names[knBlayerUADecor] ="nBlayerUA";
37  names[knPixelBarrelUADecor] ="nPixelBarrelUA";
38  names[knPixelEndCapAUADecor] ="nPixelEndCapAUA";
39  names[knPixelEndCapCUADecor] ="nPixelEndCapCUA";
40  names[knSCTUADecor] ="nSCTUA";
41  names[knSCTBarrelUADecor] ="nSCTBarrelUA";
42  names[knSCTEndCapAUADecor] ="nSCTEndCapAUA";
43  names[knSCTEndCapCUADecor] ="nSCTEndCapCUA";
44  names[knTRTUADecor] ="nTRTUA";
45  names[knTRTBarrelUADecor] ="nTRTBarrelUA";
46  names[knTRTEndCapAUADecor] ="nTRTEndCapAUA";
47  names[knTRTEndCapCUADecor] ="nTRTEndCapCUA";
49  }
50  return StatusCode::SUCCESS;
51  }
52 
53 
54  StatusCode UnassociatedHitsDecorator::addBranches(const EventContext& ctx) const
55  {
56  ATH_MSG_DEBUG("Adding unassociated hits info to EventInfo");
57 
59  CHECK( eventInfo.isValid() ? StatusCode::SUCCESS : StatusCode::FAILURE );
60 
61  const MinBiasPRDAssociation* prdAssoc = m_UnassociatedHitsGetterTool->get();
62  std::vector<SG::WriteDecorHandle<xAOD::EventInfo,int> >
63  intDecorators = createDecorators<xAOD::EventInfo,int>(m_intDecorKeys,ctx);
64  if (prdAssoc) {
65  intDecorators[knPixelUADecor](*eventInfo) = prdAssoc->nPixelUA;
66  intDecorators[knBlayerUADecor](*eventInfo) = prdAssoc->nBlayerUA;
67  intDecorators[knPixelBarrelUADecor](*eventInfo) = prdAssoc->nPixelBarrelUA;
68  intDecorators[knPixelEndCapAUADecor](*eventInfo) = prdAssoc->nPixelEndCapAUA;
69  intDecorators[knPixelEndCapCUADecor](*eventInfo) = prdAssoc->nPixelEndCapCUA;
70  intDecorators[knSCTUADecor](*eventInfo) = prdAssoc->nSCTUA;
71  intDecorators[knSCTBarrelUADecor](*eventInfo) = prdAssoc->nSCTBarrelUA;
72  intDecorators[knSCTEndCapAUADecor](*eventInfo) = prdAssoc->nSCTEndCapAUA;
73  intDecorators[knSCTEndCapCUADecor](*eventInfo) = prdAssoc->nSCTEndCapCUA;
74  intDecorators[knTRTUADecor](*eventInfo) = prdAssoc->nTRTUA;
75  intDecorators[knTRTBarrelUADecor](*eventInfo) = prdAssoc->nTRTBarrelUA;
76  intDecorators[knTRTEndCapAUADecor](*eventInfo) = prdAssoc->nTRTEndCapAUA;
77  intDecorators[knTRTEndCapCUADecor](*eventInfo) = prdAssoc->nTRTEndCapCUA;
78 
79  ATH_MSG_DEBUG("Decorating unassociated hits with nPixelBarrelUA = ");
80  ATH_MSG_DEBUG(prdAssoc->nPixelBarrelUA);
81 
82  m_UnassociatedHitsGetterTool->releaseObject(prdAssoc);
83  }
84  else
85  ATH_MSG_WARNING("Could not retrieve Unassociated hits information");
86 
87  return StatusCode::SUCCESS;
88  }
89 
90 }
DecoratorUtils.h
DerivationFramework::createDecoratorKeys
void createDecoratorKeys(T_Parent &parent, const SG::ReadHandleKey< T_Cont > &container_key, const std::string &prefix, const std::vector< std::string > &decor_names, std::vector< SG::WriteDecorHandleKey< T_Cont > > &decor_out)
Definition: DecoratorUtils.h:20
AthMsgStreamMacros.h
MinBiasPRDAssociation::nPixelBarrelUA
int nPixelBarrelUA
Definition: MinBiasPRDAssociation.h:20
MinBiasPRDAssociation::nPixelUA
int nPixelUA
Definition: MinBiasPRDAssociation.h:18
MinBiasPRDAssociation::nPixelEndCapAUA
int nPixelEndCapAUA
Definition: MinBiasPRDAssociation.h:21
DerivationFramework::UnassociatedHitsDecorator::m_intDecorKeys
std::vector< SG::WriteDecorHandleKey< xAOD::EventInfo > > m_intDecorKeys
Definition: UnassociatedHitsDecorator.h:61
UnassociatedHitsDecorator.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
DerivationFramework::UnassociatedHitsDecorator::knPixelEndCapCUADecor
@ knPixelEndCapCUADecor
Definition: UnassociatedHitsDecorator.h:51
MinBiasPRDAssociation::nSCTEndCapCUA
int nSCTEndCapCUA
Definition: MinBiasPRDAssociation.h:27
DerivationFramework::UnassociatedHitsDecorator::knSCTEndCapCUADecor
@ knSCTEndCapCUADecor
Definition: UnassociatedHitsDecorator.h:55
DerivationFramework::UnassociatedHitsDecorator::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: UnassociatedHitsDecorator.h:42
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
DerivationFramework::UnassociatedHitsDecorator::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const override final
Definition: UnassociatedHitsDecorator.cxx:54
MinBiasPRDAssociation::nSCTUA
int nSCTUA
Definition: MinBiasPRDAssociation.h:24
DerivationFramework::UnassociatedHitsDecorator::knPixelUADecor
@ knPixelUADecor
Definition: UnassociatedHitsDecorator.h:47
DerivationFramework::UnassociatedHitsDecorator::kNIntDecor
@ kNIntDecor
Definition: UnassociatedHitsDecorator.h:60
MinBiasPRDAssociation::nTRTEndCapCUA
int nTRTEndCapCUA
Definition: MinBiasPRDAssociation.h:32
DerivationFramework::UnassociatedHitsDecorator::m_sgName
Gaudi::Property< std::string > m_sgName
Definition: UnassociatedHitsDecorator.h:39
MinBiasPRDAssociation::nTRTEndCapAUA
int nTRTEndCapAUA
Definition: MinBiasPRDAssociation.h:31
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
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
python.subdetectors.mmg.names
names
Definition: mmg.py:8
MinBiasPRDAssociation::nSCTBarrelUA
int nSCTBarrelUA
Definition: MinBiasPRDAssociation.h:25
DerivationFramework::UnassociatedHitsDecorator::knSCTBarrelUADecor
@ knSCTBarrelUADecor
Definition: UnassociatedHitsDecorator.h:53
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
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
MinBiasPRDAssociation::nSCTEndCapAUA
int nSCTEndCapAUA
Definition: MinBiasPRDAssociation.h:26
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
MinBiasPRDAssociation
Definition: MinBiasPRDAssociation.h:11
DerivationFramework::UnassociatedHitsDecorator::knBlayerUADecor
@ knBlayerUADecor
Definition: UnassociatedHitsDecorator.h:48
MinBiasPRDAssociation::nTRTBarrelUA
int nTRTBarrelUA
Definition: MinBiasPRDAssociation.h:30
DerivationFramework::UnassociatedHitsDecorator::knTRTBarrelUADecor
@ knTRTBarrelUADecor
Definition: UnassociatedHitsDecorator.h:57
DerivationFramework::UnassociatedHitsDecorator::knPixelEndCapAUADecor
@ knPixelEndCapAUADecor
Definition: UnassociatedHitsDecorator.h:50
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
DerivationFramework::UnassociatedHitsDecorator::knTRTEndCapCUADecor
@ knTRTEndCapCUADecor
Definition: UnassociatedHitsDecorator.h:59
DerivationFramework::UnassociatedHitsDecorator::knSCTUADecor
@ knSCTUADecor
Definition: UnassociatedHitsDecorator.h:52
MinBiasPRDAssociation::nPixelEndCapCUA
int nPixelEndCapCUA
Definition: MinBiasPRDAssociation.h:22
DerivationFramework::UnassociatedHitsDecorator::knTRTUADecor
@ knTRTUADecor
Definition: UnassociatedHitsDecorator.h:56
DerivationFramework::UnassociatedHitsDecorator::m_UnassociatedHitsGetterTool
ToolHandle< IUnassociatedHitsGetterTool > m_UnassociatedHitsGetterTool
Definition: UnassociatedHitsDecorator.h:45
DerivationFramework::UnassociatedHitsDecorator::knTRTEndCapAUADecor
@ knTRTEndCapAUADecor
Definition: UnassociatedHitsDecorator.h:58
MinBiasPRDAssociation::nBlayerUA
int nBlayerUA
Definition: MinBiasPRDAssociation.h:19
MinBiasPRDAssociation::nTRTUA
int nTRTUA
Definition: MinBiasPRDAssociation.h:29
DerivationFramework::UnassociatedHitsDecorator::knPixelBarrelUADecor
@ knPixelBarrelUADecor
Definition: UnassociatedHitsDecorator.h:49
DerivationFramework::UnassociatedHitsDecorator::knSCTEndCapAUADecor
@ knSCTEndCapAUADecor
Definition: UnassociatedHitsDecorator.h:54
DerivationFramework::UnassociatedHitsDecorator::initialize
virtual StatusCode initialize() override final
Definition: UnassociatedHitsDecorator.cxx:17