ATLAS Offline Software
TRTRawDataProviderTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 #include "GaudiKernel/IToolSvc.h"
10 #include "GaudiKernel/ServiceHandle.h"
12 #include "StoreGate/WriteHandle.h"
13 
14 
16 
17 
18 // -------------------------------------------------------
19 //
20 
21 
22 
23 // -------------------------------------------------------
24 // default contructor
25 
27 ( const std::string& type, const std::string& name,const IInterface* parent )
28  : base_class( type, name, parent ),
29  m_decoder ("TRT_RodDecoder",this)
30 {
31  declareProperty ("Decoder", m_decoder);
32 }
33 
34 // -------------------------------------------------------
35 // initialize
36 
38 {
39 
41 
42  ATH_CHECK( m_decoder.retrieve() );
43  ATH_MSG_INFO( "Retrieved tool " << m_decoder );
44 
45  //initialize write handles
48 
49  return StatusCode::SUCCESS;
50 }
51 
52 // -------------------------------------------------------
53 // convert method
54 
55 StatusCode TRTRawDataProviderTool::convert(const std::vector<const ROBFragment*>& vecRobs,
56  TRT_RDO_Container* rdoIdc,
58  DataPool<TRT_LoLumRawData>* dataItemsPool,
59  const EventContext& ctx) const
60 {
61 
62  static std::atomic_int DecodeErrCount = 0;
63 
64  if(vecRobs.empty())
65  return StatusCode::SUCCESS;
66 
67 
68  std::unique_ptr<InDetTimeCollection> LVL1Collection;
69  std::unique_ptr<InDetTimeCollection> BCCollection;
70  std::vector<const ROBFragment*>::const_iterator rob_it = vecRobs.begin();
71 
72 
73  if ( m_storeInDetTimeColls ) {
74  // Create Collections for per ROD vectors on L1ID and BCID
75  LVL1Collection = std::make_unique<InDetTimeCollection>();
76  LVL1Collection->reserve(vecRobs.size());
77 
78  BCCollection = std::make_unique<InDetTimeCollection>();
79  BCCollection->reserve(vecRobs.size());
80  }
81 
82  // loop over the ROB fragments
83  for(; rob_it!=vecRobs.end(); ++rob_it)
84  {
85 
86  uint32_t robid = (*rob_it)->rod_source_id();
87 
89  /*
90  * Add to vector containing pairs of (ROD ID, [L1ID,BCID])
91  */
92 
93  unsigned int lvl1id = (*rob_it)->rod_lvl1_id();
94  LVL1Collection->emplace_back(robid, lvl1id);
95 
96  unsigned int bcid = (*rob_it)->rod_bc_id();
97  BCCollection->emplace_back(robid, bcid);
98 
99 #ifdef TRT_BSC_DEBUG
100  ATH_MSG_DEBUG( "Stored LVL1ID " << lvl1id << " and BCID " << bcid << " in InDetTimeCollections" );
101 #endif
102  }
103  StatusCode sc = m_decoder->fillCollection( &**rob_it, rdoIdc, bserr, dataItemsPool);
104  if ( sc == StatusCode::FAILURE )
105  {
106  if (DecodeErrCount < 100) {
107  ATH_MSG_INFO("Problem with TRT ByteStream Decoding!");
108  DecodeErrCount++;
109  } else if (100 == DecodeErrCount) {
110  ATH_MSG_INFO(
111  "Too many Problem with TRT Decoding messages. Turning message "
112  "off.");
113  DecodeErrCount++;
114  }
115  // return sc; Don't return on single ROD failure
116  }
117  }
118 
119  /*
120  * record per ROD L1ID and BCID collections
121  */
122  if ( m_storeInDetTimeColls ) {
123 
125  ATH_CHECK(lvl1id.record(std::move(LVL1Collection)));
126 
128  ATH_CHECK(bcid.record(std::move(BCCollection)));
129  }
130 
131  return StatusCode::SUCCESS;
132 }
TRTRawDataProviderTool.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
initialize
void initialize()
Definition: run_EoverP.cxx:894
TRT_RDORawData.h
TRTRawDataProviderTool::TRTRawDataProviderTool
TRTRawDataProviderTool(const std::string &type, const std::string &name, const IInterface *parent)
constructor
Definition: TRTRawDataProviderTool.cxx:27
InDetRawDataContainer
Definition: InDetRawDataContainer.h:27
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
TRT_BSErrContainer
Definition: TRT_BSErrContainer.h:20
TRTRawDataProviderTool::m_decoder
ToolHandle< ITRT_RodDecoder > m_decoder
Definition: TRTRawDataProviderTool.h:47
WriteHandle.h
Handle class for recording to StoreGate.
TRTRawDataProviderTool::initialize
virtual StatusCode initialize() override
initialize
Definition: TRTRawDataProviderTool.cxx:37
TRTRawDataProviderTool::m_lvl1idkey
SG::WriteHandleKey< InDetTimeCollection > m_lvl1idkey
Definition: TRTRawDataProviderTool.h:49
RawEvent.h
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
test_pyathena.parent
parent
Definition: test_pyathena.py:15
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
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
xAOD::bcid
setEventNumber setTimeStamp bcid
Definition: EventInfo_v1.cxx:133
OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment
eformat::ROBFragment< PointerType > ROBFragment
Definition: RawEvent.h:27
StoreClearedIncident.h
Incident sent after a store is cleared.
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
plotBeamSpotVxVal.bserr
float bserr
Definition: plotBeamSpotVxVal.py:283
TRTRawDataProviderTool::m_bcidkey
SG::WriteHandleKey< InDetTimeCollection > m_bcidkey
Definition: TRTRawDataProviderTool.h:50
DataPool
a typed memory pool that saves time spent allocation small object. This is typically used by containe...
Definition: DataPool.h:47
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
TRTRawDataProviderTool::convert
virtual StatusCode convert(const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &vecRobs, TRT_RDO_Container *rdoIdc, TRT_BSErrContainer *bsErrCont, DataPool< TRT_LoLumRawData > *dataItemsPool, const EventContext &ctx) const override
this is the main decoding method
Definition: TRTRawDataProviderTool.cxx:55
TRTRawDataProviderTool::m_storeInDetTimeColls
Gaudi::Property< bool > m_storeInDetTimeColls
Definition: TRTRawDataProviderTool.h:51