ATLAS Offline Software
Loading...
Searching...
No Matches
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"
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
40 ATH_CHECK( AlgTool::initialize() );
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
55StatusCode TRTRawDataProviderTool::convert(const std::vector<const ROBFragment*>& vecRobs,
56 TRT_RDO_Container* rdoIdc,
57 TRT_BSErrContainer* bserr,
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
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, ctx);
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) {
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Incident sent after a store is cleared.
Handle class for recording to StoreGate.
InDetRawDataContainer< InDetRawDataCollection< TRT_RDORawData > > TRT_RDO_Container
a typed memory pool that saves time spent allocation small object.
Definition DataPool.h:63
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ToolHandle< ITRT_RodDecoder > m_decoder
TRTRawDataProviderTool(const std::string &type, const std::string &name, const IInterface *parent)
constructor
virtual StatusCode initialize() override
initialize
SG::WriteHandleKey< InDetTimeCollection > m_lvl1idkey
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
SG::WriteHandleKey< InDetTimeCollection > m_bcidkey
Gaudi::Property< bool > m_storeInDetTimeColls
eformat::ROBFragment< PointerType > ROBFragment
Definition RawEvent.h:27