ATLAS Offline Software
ByteStreamCnvSvc.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef BYTESTREAMCNVSVC_BYTESTREAMCNVSVC_H
6 #define BYTESTREAMCNVSVC_BYTESTREAMCNVSVC_H
7 
10 #include "StoreGate/StoreGateSvc.h"
12 #include "GaudiKernel/ThreadLocalContext.h"
13 #include "GaudiKernel/ServiceHandle.h"
14 
15 #include <map>
16 
19 
34 class ByteStreamCnvSvc : public ByteStreamCnvSvcBase/*, virtual public IService*/ {
35 
36 public:
38  ByteStreamCnvSvc(const std::string& name, ISvcLocator* svc);
39 
41  virtual ~ByteStreamCnvSvc();
42 
44  virtual StatusCode initialize() override;
45  virtual StatusCode finalize() override;
46 
48  virtual StatusCode connectOutput(const std::string& t, const std::string& mode) override;
49  virtual StatusCode connectOutput(const std::string& t) override;
50 
52  virtual StatusCode commitOutput(const std::string& outputConnection, bool b) override;
53 
55  virtual RawEventWrite* getRawEvent() override
56  {
57  return m_slots->m_rawEventWrite.get();
58  }
59 
61  template <class T> StatusCode getFullEventAssembler(T*&t, const std::string& nm);
62 
63  virtual StatusCode queryInterface( const InterfaceID& riid, void** ppvInterface ) override;
65  static const InterfaceID& interfaceID();
67 
68 protected:
69  RawEventWrite* setRawEvent (std::unique_ptr<RawEventWrite> rawEventWrite);
70 
71 private:
73  std::string m_ioSvcName;
74 
76  Gaudi::Property<std::vector<std::string>> m_ioSvcNameList{ this, "ByteStreamOutputSvcList", {}, "", "OrderedSet<T>"};
77 
79  Gaudi::Property<bool> m_fillTriggerBits{this, "FillTriggerBits", true, "Read in xTrigDecision and use it to fill Trigger bits in event header"};
80 
82  std::map<std::string, ByteStreamOutputSvc*> m_ioSvcMap;
83 
86 
88  std::string m_userType;
89 
91  using FEAPtr_t = std::unique_ptr<FullEventAssemblerBase>;
92  using FEAMap_t = std::map<std::string, FEAPtr_t>;
93 
95  struct SlotData
96  {
97  std::unique_ptr<RawEventWrite> m_rawEventWrite;
99  std::vector<uint32_t> m_tagBuff;
100  std::vector<uint32_t> m_l1Buff;
101  std::vector<uint32_t> m_l2Buff;
102  std::vector<uint32_t> m_efBuff;
103 
104  void clear()
105  {
106  m_rawEventWrite.reset();
107  m_feaMap.clear();
108  m_tagBuff.clear();
109  m_l1Buff.clear();
110  m_l2Buff.clear();
111  m_efBuff.clear();
112  }
113  };
115 
117  void writeFEA (SlotData& slot);
118 };
119 
120 // Implementation of template method:
121 template <class T> StatusCode ByteStreamCnvSvc::getFullEventAssembler(T*& t, const std::string& nm)
122 {
123  const EventContext& ctx = Gaudi::Hive::currentContext();
124  FEAMap_t& feaMap = m_slots.get (ctx)->m_feaMap;
125  FEAPtr_t& fea = feaMap[nm];
126  if (fea) {
127  T* p = dynamic_cast<T*>(fea.get());
128  if (p == 0) {
129  ATH_MSG_WARNING(" Key = " << nm << " exists, but of different type");
130  return(StatusCode::FAILURE);
131  }
132  t = p;
133  return(StatusCode::SUCCESS);
134  }
135 
136  // reach here if key does not exist
137  auto ptr = std::make_unique<T>();
138  t = ptr.get();
139  fea = std::move (ptr);
140  return(StatusCode::SUCCESS);
141 }
142 
143 #endif
ByteStreamCnvSvc::commitOutput
virtual StatusCode commitOutput(const std::string &outputConnection, bool b) override
Implements ConversionSvc's commitOutput.
Definition: ByteStreamCnvSvc.cxx:190
ByteStreamCnvSvc::SlotData
Slot-specific state.
Definition: ByteStreamCnvSvc.h:96
RawEventWrite
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::FullEventFragment RawEventWrite
data type for writing raw event
Definition: RawEvent.h:39
ByteStreamCnvSvc::SlotData::m_efBuff
std::vector< uint32_t > m_efBuff
Definition: ByteStreamCnvSvc.h:102
ByteStreamCnvSvc::SlotData::clear
void clear()
Definition: ByteStreamCnvSvc.h:104
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ByteStreamCnvSvc::~ByteStreamCnvSvc
virtual ~ByteStreamCnvSvc()
Standard Destructor.
Definition: ByteStreamCnvSvc.cxx:44
ByteStreamCnvSvc::m_ioSvcMap
std::map< std::string, ByteStreamOutputSvc * > m_ioSvcMap
Services for writing output.
Definition: ByteStreamCnvSvc.h:82
ByteStreamCnvSvc::m_evtStore
ServiceHandle< StoreGateSvc > m_evtStore
Event store.
Definition: ByteStreamCnvSvc.h:85
ByteStreamCnvSvc::getRawEvent
virtual RawEventWrite * getRawEvent() override
Implementation of IByteStreamEventAccess: Get RawEvent.
Definition: ByteStreamCnvSvc.h:55
ByteStreamCnvSvc::m_slots
SG::SlotSpecificObj< SlotData > m_slots
Definition: ByteStreamCnvSvc.h:114
ByteStreamCnvSvc::ByteStreamCnvSvc
ByteStreamCnvSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
Definition: ByteStreamCnvSvc.cxx:34
ByteStreamCnvSvc::FEAPtr_t
std::unique_ptr< FullEventAssemblerBase > FEAPtr_t
common FEA, indexed by string key
Definition: ByteStreamCnvSvc.h:91
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ByteStreamCnvSvc::SlotData::m_l1Buff
std::vector< uint32_t > m_l1Buff
Definition: ByteStreamCnvSvc.h:100
ByteStreamCnvSvc::m_ioSvcName
std::string m_ioSvcName
name of the service
Definition: ByteStreamCnvSvc.h:73
ByteStreamCnvSvc::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface) override
Required of all Gaudi services: see Gaudi documentation for details.
Definition: ByteStreamCnvSvc.cxx:251
ByteStreamCnvSvc::FEAMap_t
std::map< std::string, FEAPtr_t > FEAMap_t
Definition: ByteStreamCnvSvc.h:92
FullEventAssemblerBase
base class for assembling a full atlas raw event from subfragments
Definition: FullEventAssembler.h:23
SG::SlotSpecificObj
Maintain a set of objects, one per slot.
Definition: AthenaKernel/AthenaKernel/SlotSpecificObj.h:70
ByteStreamCnvSvc
Gaudi Conversion Service class for ByteStream Persistency.
Definition: ByteStreamCnvSvc.h:34
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ByteStreamCnvSvc::SlotData::m_feaMap
FEAMap_t m_feaMap
Definition: ByteStreamCnvSvc.h:98
ByteStreamCnvSvc::SlotData::m_l2Buff
std::vector< uint32_t > m_l2Buff
Definition: ByteStreamCnvSvc.h:101
ByteStreamCnvSvc::SlotData::m_rawEventWrite
std::unique_ptr< RawEventWrite > m_rawEventWrite
Definition: ByteStreamCnvSvc.h:97
ByteStreamCnvSvc::m_userType
std::string m_userType
user type
Definition: ByteStreamCnvSvc.h:88
Preparation.mode
mode
Definition: Preparation.py:95
ByteStreamCnvSvc::interfaceID
static const InterfaceID & interfaceID()
Should rather be in IByteStreamSvc.h if we had one.
Definition: ByteStreamCnvSvc.cxx:266
ByteStreamCnvSvc::initialize
virtual StatusCode initialize() override
Gaudi Service Interface method implementations:
Definition: ByteStreamCnvSvc.cxx:48
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
FullEventAssembler.h
ByteStreamCnvSvc::finalize
virtual StatusCode finalize() override
Definition: ByteStreamCnvSvc.cxx:96
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
CalibCoolCompareRT.nm
nm
Definition: CalibCoolCompareRT.py:110
ByteStreamCnvSvcBase
The base class for offline and HLT ByteStream conversion services.
Definition: ByteStreamCnvSvcBase.h:19
ByteStreamCnvSvc::writeFEA
void writeFEA(SlotData &slot)
Write the FEA to RawEvent.
Definition: ByteStreamCnvSvc.cxx:239
ByteStreamCnvSvc::m_fillTriggerBits
Gaudi::Property< bool > m_fillTriggerBits
fill trigger bits
Definition: ByteStreamCnvSvc.h:79
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ByteStreamCnvSvc::SlotData::m_tagBuff
std::vector< uint32_t > m_tagBuff
Definition: ByteStreamCnvSvc.h:99
SlotSpecificObj.h
Maintain a set of objects, one per slot.
ByteStreamCnvSvcBase.h
ByteStreamOutputSvc
This class provides the base class to services to write bytestream data. The concrete class can provi...
Definition: ByteStreamOutputSvc.h:25
ByteStreamCnvSvc::getFullEventAssembler
StatusCode getFullEventAssembler(T *&t, const std::string &nm)
Access to FullEventAssembler.
Definition: ByteStreamCnvSvc.h:121
ByteStreamCnvSvc::setRawEvent
RawEventWrite * setRawEvent(std::unique_ptr< RawEventWrite > rawEventWrite)
Definition: ByteStreamCnvSvc.cxx:273
ByteStreamCnvSvc::connectOutput
virtual StatusCode connectOutput(const std::string &t, const std::string &mode) override
Implements ConversionSvc's connectOutput.
Definition: ByteStreamCnvSvc.cxx:100
ByteStreamCnvSvc::m_ioSvcNameList
Gaudi::Property< std::vector< std::string > > m_ioSvcNameList
list of service names
Definition: ByteStreamCnvSvc.h:76
StoreGateSvc.h
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
ServiceHandle< StoreGateSvc >