ATLAS Offline Software
StreamSelectorTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 #include <algorithm>
9 
10 #include "GaudiKernel/ServiceHandle.h"
11 #include "StoreGate/StoreGateSvc.h"
12 
13 #include "StreamSelectorTool.h"
18 
19 #include "PoolSvc/IPoolSvc.h"
20 
21 //___________________________________________________________________________
22 StreamSelectorTool::StreamSelectorTool(const std::string& type, const std::string& name, const IInterface* parent) :
24 {
25  declareInterface<IAthenaSelectorTool>(this);
26 }
27 //___________________________________________________________________________
29 }
30 
31 //__________________________________________________________________________
33  ATH_MSG_INFO("StreamSelectorTool::postNext");
34 
35  // Use attribute list to filter on selected stream, if it exists
37  if (attrList.isValid()) {
38  if (attrList->specification().exists(m_streamName.value())) {
39  if (!(*attrList)[m_streamName.value()].data<bool>()) {
40  // Rejecting event
41  ATH_MSG_DEBUG("Rejecting event");
42  return(StatusCode::RECOVERABLE);
43  }
44  }
45  // Accepting event
46  ATH_MSG_DEBUG("Accepting event");
47  if (attrList->specification().exists("eventRef")) {
48  // Recording Extension DataHeader
49  const std::string tokenStr = (*attrList)["eventRef"].data<std::string>();
50  Token* token = new Token;
51  token->fromString(tokenStr);
52  token->setCont("POOLContainer_" + m_streamName.value() + "(DataHeader)");
53  IOpaqueAddress* iop = new TokenAddress(POOL_StorageType, ClassID_traits<DataHeader>::ID(), "", m_streamName.value(), IPoolSvc::kInputStream, token);
54  if (!evtStore()->recordAddress(iop).isSuccess()) {
55  ATH_MSG_ERROR("Failed to record AthenaAttribute, name = " << token->contID() << ", eventRef = " << tokenStr);
56  return(StatusCode::FAILURE);
57  }
58  }
59  } else {
60  ATH_MSG_ERROR("Could not find attribute list for " << m_attrListKey);
61  return(StatusCode::FAILURE);
62  }
63  return(StatusCode::SUCCESS);
64 }
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
Token
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition: Token.h:21
TokenAddress
This class provides a Generic Transient Address for POOL tokens.
Definition: TokenAddress.h:21
Token::fromString
Token & fromString(const std::string &from)
Build from the string representation of a token.
Definition: Token.cxx:133
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
IPoolSvc::kInputStream
@ kInputStream
Definition: IPoolSvc.h:39
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
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
test_pyathena.parent
parent
Definition: test_pyathena.py:15
DataHeader.h
This file contains the class definition for the DataHeader and DataHeaderElement classes.
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
IPoolSvc.h
This file contains the class definition for the IPoolSvc interface class.
AthenaAttributeList.h
An AttributeList represents a logical row of attributes in a metadata table. The name and type of eac...
StreamSelectorTool::m_attrListKey
StringProperty m_attrListKey
Definition: StreamSelectorTool.h:36
StreamSelectorTool::~StreamSelectorTool
virtual ~StreamSelectorTool()
Destructor.
Definition: StreamSelectorTool.cxx:28
StreamSelectorTool::m_streamName
StringProperty m_streamName
Definition: StreamSelectorTool.h:37
TokenAddress.h
This file contains the class definition for the TokenAddress class.
StreamSelectorTool.h
This file contains the class definition for the StreamSelectorTool class.
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
Token::setCont
Token & setCont(const std::string &cnt)
Set container name.
Definition: Token.h:69
StreamSelectorTool::postNext
virtual StatusCode postNext() const override
Called at the end of next.
Definition: StreamSelectorTool.cxx:32
AthAlgTool
Definition: AthAlgTool.h:26
Token.h
This file contains the class definition for the Token class (migrated from POOL).
StoreGateSvc.h
StreamSelectorTool::StreamSelectorTool
StreamSelectorTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Service Constructor.
Definition: StreamSelectorTool.cxx:22