ATLAS Offline Software
EventInfoTagBuilder.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 #include "EventInfoTagBuilder.h"
6 
7 #include <StoreGate/ReadHandle.h>
9 
11 {
12  ATH_MSG_DEBUG( "Initializing " << name() );
13 
14  if (m_attributeListName.empty()) {
15  ATH_MSG_ERROR("Output attribute list name should not be empty.");
16  return StatusCode::FAILURE;
17  }
18 
19  ATH_CHECK( m_tool.retrieve() );
20 
24 
25  return StatusCode::SUCCESS;
26 }
27 
28 
30 {
31  ATH_MSG_DEBUG( "Executing " << name() );
32 
34  if (!h_evt.isValid()) {
35  ATH_MSG_ERROR("Did not find xAOD::EventInfo");
36  return StatusCode::FAILURE;
37  }
38 
40  std::unique_ptr<AthenaAttributeList> attribList =
41  m_tool->getAttributeListPtr( *h_evt );
42 
43  // Check whether to propagate
44  if (m_propInput) {
46  // Check if there is an input to propagate
47  if (h_att.isValid()) {
48  for (auto it = h_att->specification().begin();
49  it!= h_att->specification().end(); ++it) {
50  // Only propagate bool properties
51  if (it->typeName()=="bool"&&!attribList->exists(it->name())) {
52  // Check if there is filtering on the name
53  if (m_filter != "") {
54  if (it->name().find(m_filter)!=std::string::npos) {
55  // Add those bools to the output attribute list
56  (*attribList).extend(it->name(),it->type());
57  (*attribList)[it->name()].data<bool>() = (*h_att)[it->name()].data<bool>();
58  }
59  }
60  } // take only bools
61  } // loop
62  } else { // valid input
63  ATH_MSG_INFO("No input attribute list");
64  }
65  } // propagate
66 
69  ATH_CHECK( wh.record(std::move(attribList)) );
70 
71  ATH_MSG_DEBUG( "Finished " << name() );
72 
73  return StatusCode::SUCCESS;
74 }
EventInfoTagBuilder::m_evtKey
SG::ReadHandleKey< xAOD::EventInfo > m_evtKey
Definition: EventInfoTagBuilder.h:56
EventInfoTagBuilder::m_propInput
Gaudi::Property< bool > m_propInput
Definition: EventInfoTagBuilder.h:60
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
skel.it
it
Definition: skel.GENtoEVGEN.py:423
EventInfoTagBuilder::m_attributeListName
SG::WriteHandleKey< AthenaAttributeList > m_attributeListName
Definition: EventInfoTagBuilder.h:58
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
WriteHandle.h
Handle class for recording to StoreGate.
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
parseDir.wh
wh
Definition: parseDir.py:46
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
EventInfoTagBuilder::m_filter
Gaudi::Property< std::string > m_filter
Definition: EventInfoTagBuilder.h:61
EventInfoTagBuilder::m_inputAttList
SG::ReadHandleKey< AthenaAttributeList > m_inputAttList
Definition: EventInfoTagBuilder.h:57
EventInfoTagBuilder::m_tool
ToolHandle< EventInfoAttListTool > m_tool
Global Event Tag Tool.
Definition: EventInfoTagBuilder.h:54
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
EventInfoTagBuilder::initialize
virtual StatusCode initialize() override
Definition: EventInfoTagBuilder.cxx:10
EventInfoTagBuilder::execute
virtual StatusCode execute() override
Definition: EventInfoTagBuilder.cxx:29
ReadHandle.h
Handle class for reading from StoreGate.
EventInfoTagBuilder.h