ATLAS Offline Software
Loading...
Searching...
No Matches
TRTRawContByteStreamTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
6
9
10#include "GaudiKernel/MsgStream.h"
11
13
14
15#include "TRT_RodEncoder.h"
16
17
18
19// ------------------------------------------------------------------------
20// default contructor
21
23( const std::string& type, const std::string& name,const IInterface* parent )
24 : base_class(type,name,parent),
25 m_trt_CablingSvc ("TRT_CablingSvc", name ),
26 m_trt_idHelper(nullptr)
27{
28 declareInterface< ITRTRawContByteStreamTool >( this );
29 declareProperty("RodBlockVersion",m_RodBlockVersion=3);
30}
31
32// ------------------------------------------------------------------------
33// destructor
34
36= default;
37
38// ------------------------------------------------------------------------
39// initialize the tool
40
41StatusCode
43{
44 ATH_CHECK( AlgTool::initialize() );
45
46 ATH_CHECK( m_trt_CablingSvc.retrieve() );
47 ATH_MSG_INFO( "Retrieved tool " << m_trt_CablingSvc );
48
49 ATH_CHECK( detStore()->retrieve(m_trt_idHelper, "TRT_ID") );
50
51 ATH_CHECK( m_byteStreamCnvSvc.retrieve() );
52
53 return StatusCode::SUCCESS;
54}
55
56// ------------------------------------------------------------------------
57// finalize the tool
58
59StatusCode
61{
62 ATH_CHECK( AlgTool::finalize() );
63 return StatusCode::SUCCESS;
64}
65
66// ------------------------------------------------------------------------
67// New convert method which makes use of the encoder class (as done for
68// other detectors)
69
70StatusCode
72{
73 StatusCode sc(StatusCode::SUCCESS);
74
75 FullEventAssembler<SrcIdMap>* fea = nullptr;
76 ATH_CHECK( m_byteStreamCnvSvc->getFullEventAssembler (fea,
77 "TRTRawCont") );
79
80 // set ROD Minor version
82 ATH_MSG_DEBUG( " Setting Minor Version Number to "<<m_RodBlockVersion );
83
84 // a map for ROD ID onto Encoder
85 std::map<uint32_t, TRT_RodEncoder> mapEncoder;
86
87 ATH_MSG_DEBUG( " number of collections "<< cont->size() );
88
89 //loop over the collections in the TRT RDO container
91 TRT_RDO_Container::const_iterator it_coll_end = cont->end();
92
93 for( ; it_coll!=it_coll_end;++it_coll)
94 {
95 const TRTRawCollection* coll = (*it_coll) ;
96
97 if ( nullptr != coll )
98 {
99 // Collection Id
100 Identifier id = coll->identify() ;
101
102 // Layer Id associated to the collection Id (Mapping)
103 Identifier IdLayer = m_trt_idHelper->layer_id(id);
104
105 std::vector<uint32_t> robids = m_trt_CablingSvc->getRobID(IdLayer);
106
107 eformat::helper::SourceIdentifier sid_rob(robids[0]);
108
109 // Building the rod ID
110 eformat::helper::SourceIdentifier sid_rod( sid_rob.subdetector_id(),
111 sid_rob.module_id() );
112 uint32_t rodId = sid_rod.code();
113
114 // loop over RDOs in the collection;
117
118 for(; it_b!=it_e; ++it_b) // loop over RDOs in the collection;
119 {
120 const RDO* theRdo = *it_b; // fill rdo vector VRDO in
121 mapEncoder[rodId].addRdo(theRdo); // RodEncoder with the collection
122 }
123 }
124
125 } // End loop over collections
126
127 // loop over Encoder map and fill all ROD Data Blocks
128 std::map<uint32_t,TRT_RodEncoder>::iterator it_map = mapEncoder.begin();
129 std::map<uint32_t,TRT_RodEncoder>::iterator it_map_end = mapEncoder.end();
130
131 for (; (it_map != it_map_end) && (sc == StatusCode::SUCCESS); ++it_map)
132 {
133
134 TRT_RodEncoder theEncoder = (*it_map).second;
135
136 // set the idhelper, mapping and minor version
137 theEncoder.set_trt_IdHelper (m_trt_idHelper);
140 // use encoder to get ROD fragment data
141 theROD = fea->getRodData((*it_map).first); // get ROD data address
142
143
144 if ( 1 == m_RodBlockVersion )
145 sc = theEncoder.fillROD( *theROD ) ; // fill ROD data
146 else if ( 3 == m_RodBlockVersion )
147 sc = theEncoder.fillROD3( *theROD ) ; // fill ROD data
148 else
149 {
150 ATH_MSG_WARNING( "Unsupported TRT Rod Block Version Number" );
151 sc = StatusCode::RECOVERABLE;
152 }
153 }
154
155 if ( sc == StatusCode::FAILURE )
156 ATH_MSG_ERROR( "TRT ROD Encoder Failed" );
157 else if ( sc == StatusCode::RECOVERABLE )
158 ATH_MSG_WARNING( "TRT ROD Encoder has RECOVERABLE error" );
159
160
161 return sc;
162}
163
164
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This is an Identifier helper class for the TRT subdetector.
InDetRawDataContainer< InDetRawDataCollection< TRT_RDORawData > > TRT_RDO_Container
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
const_iterator begin() const noexcept
Template class for assembling a full atlas raw event from subfragments.
void setRodMinorVersion(uint16_t m)
change the ROD minor version
std::vector< uint32_t > RODDATA
ROD data as a vector of unsigned int.
RODDATA * getRodData(uint32_t id)
get a block of ROD data
const_iterator end() const
return const_iterator for end of container
size_t size() const
Duplicate of fullSize for backwards compatability.
const_iterator begin() const
return const_iterator for first entry
virtual Identifier identify() const override final
ServiceHandle< ITRT_CablingSvc > m_trt_CablingSvc
ServiceHandle< IByteStreamCnvSvc > m_byteStreamCnvSvc
virtual StatusCode initialize() override
TRTRawContByteStreamTool(const std::string &type, const std::string &name, const IInterface *parent)
constructor
virtual StatusCode finalize() override
virtual StatusCode convert(TRT_RDO_Container *cont) const override
New convert method which makes use of the encoder class (as done for other detectors)
virtual ~TRTRawContByteStreamTool()
destructor
InDetRawDataCollection< RDO > TRTRawCollection
This class provides conversion from TRT RDO to ROD format.
void set_trt_IdHelper(const TRT_ID *trt_id)
setId Helper
void setRodMinorVersion(unsigned short RodBlockVersion)
setRodMinorVersion
void set_trt_cabling(const ServiceHandle< ITRT_CablingSvc > &trt_CablingSvc)
setCablingSvc
StatusCode fillROD3(std::vector< uint32_t > &v)
conversion of ROD into compressed ROD fragment
StatusCode fillROD(std::vector< uint32_t > &v)
conversion of ROD into ROD fragment