ATLAS Offline Software
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 
12 #include "InDetIdentifier/TRT_ID.h"
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 
43 {
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 
61 {
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 
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
90  TRT_RDO_Container::const_iterator it_coll = cont->begin();
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;
115  TRTRawCollection::const_iterator it_b = coll->begin();
116  TRTRawCollection::const_iterator it_e = coll->end();
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);
138  theEncoder.set_trt_cabling (m_trt_CablingSvc);
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 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
TRTRawContByteStreamTool::finalize
virtual StatusCode finalize() override
Definition: TRTRawContByteStreamTool.cxx:60
TRTRawContByteStreamTool::initialize
virtual StatusCode initialize() override
Definition: TRTRawContByteStreamTool.cxx:42
TRT_ID::layer_id
Identifier layer_id(int barrel_ec, int phi_module, int layer_or_wheel, int straw_layer) const
For an individual straw layer.
Definition: TRT_ID.h:500
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:50
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
TRTRawContByteStreamTool::m_trt_idHelper
const TRT_ID * m_trt_idHelper
Definition: TRTRawContByteStreamTool.h:63
TRT_RodEncoder::set_trt_cabling
void set_trt_cabling(ServiceHandle< ITRT_CablingSvc > trt_CablingSvc)
setCablingSvc
Definition: TRT_RodEncoder.h:42
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
FullEventAssembler< SrcIdMap >
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
initialize
void initialize()
Definition: run_EoverP.cxx:894
TRT_RodEncoder
This class provides conversion from TRT RDO to ROD format.
Definition: TRT_RodEncoder.h:24
InDetRawDataCollection::identify
virtual Identifier identify() const override final
TRT_ID.h
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
IdentifiableContainerMT::size
size_t size() const
Duplicate of fullSize for backwards compatability.
Definition: IdentifiableContainerMT.h:209
TRT_RodEncoder::fillROD
StatusCode fillROD(std::vector< uint32_t > &v)
conversion of ROD into ROD fragment
Definition: TRT_RodEncoder.cxx:36
TRT_RodEncoder::setRodMinorVersion
void setRodMinorVersion(unsigned short RodBlockVersion)
setRodMinorVersion
Definition: TRT_RodEncoder.h:48
TRT_RodEncoder::set_trt_IdHelper
void set_trt_IdHelper(const TRT_ID *trt_id)
setId Helper
Definition: TRT_RodEncoder.h:39
TRTRawContByteStreamTool::m_trt_CablingSvc
ServiceHandle< ITRT_CablingSvc > m_trt_CablingSvc
Definition: TRTRawContByteStreamTool.h:61
TRT_RodEncoder.h
InDetRawDataContainer
Definition: InDetRawDataContainer.h:27
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
TRT_RDORawData
Definition: TRT_RDORawData.h:24
SrcIdMap.h
TRTRawContByteStreamTool::~TRTRawContByteStreamTool
virtual ~TRTRawContByteStreamTool()
destructor
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
InDetRawDataCollection
Definition: InDetRawDataCollection.h:31
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IdentifiableContainerMT::end
const_iterator end() const
return const_iterator for end of container
Definition: IdentifiableContainerMT.h:242
IdentifiableContainerMT::const_iterator
Definition: IdentifiableContainerMT.h:82
IdentifiableContainerMT::begin
const_iterator begin() const
return const_iterator for first entry
Definition: IdentifiableContainerMT.h:236
FullEventAssembler.h
TRTRawContByteStreamTool::TRTRawContByteStreamTool
TRTRawContByteStreamTool(const std::string &type, const std::string &name, const IInterface *parent)
constructor
Definition: TRTRawContByteStreamTool.cxx:23
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TRT_RodEncoder::fillROD3
StatusCode fillROD3(std::vector< uint32_t > &v)
conversion of ROD into compressed ROD fragment
Definition: TRT_RodEncoder.cxx:77
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
FullEventAssembler::setRodMinorVersion
void setRodMinorVersion(uint16_t m)
change the ROD minor version
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TRTRawContByteStreamTool.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TRTRawContByteStreamTool::m_RodBlockVersion
unsigned short m_RodBlockVersion
Definition: TRTRawContByteStreamTool.h:64
TRTRawContByteStreamTool::m_byteStreamCnvSvc
ServiceHandle< IByteStreamCnvSvc > m_byteStreamCnvSvc
Definition: TRTRawContByteStreamTool.h:59
FullEventAssembler::getRodData
RODDATA * getRodData(uint32_t id)
get a block of ROD data
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
TRTRawContByteStreamTool::convert
virtual StatusCode convert(TRT_RDO_Container *cont) const override
New convert method which makes use of the encoder class (as done for other detectors)
Definition: TRTRawContByteStreamTool.cxx:71
Identifier
Definition: IdentifierFieldParser.cxx:14