ATLAS Offline Software
TRT_RodEncoder.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Implementation of TRT_RodEncoder class
6 
7 #include <deque>
8 
9 #include "TRT_RodEncoder.h"
10 
12 #include "InDetIdentifier/TRT_ID.h"
15 
16 #include "GaudiKernel/ISvcLocator.h"
17 #include "GaudiKernel/Bootstrap.h"
18 #include "GaudiKernel/MsgStream.h"
19 #include "GaudiKernel/IMessageSvc.h"
20 
24  :m_trt_id ( nullptr ),
25  m_CablingSvc ( "TRT_CablingSvc", "TRT_RodEncoder" ),
26  m_RodBlockVersion ( 0 )
27 {}
28 
32 
36 TRT_RodEncoder::fillROD( std::vector<uint32_t>& v32rod )
37 {
38  if ( ! m_CablingSvc )
39  return StatusCode::FAILURE;
40 
41  int TRT_MaxBufferSize = 120*16;
42  // Make sure vector is big enough, fill it with 0
43  v32rod.resize(TRT_MaxBufferSize,0 );
44 
45  VRDO::iterator rdo_it = m_RDOs.begin();
46  const VRDO::iterator rdo_it_end = m_RDOs.end();
47 
48  const RDO* rawdata;
49  uint32_t StrawWord;
50  Identifier StrawID;
51  uint32_t BufferOffset;
52 
53  while ( rdo_it != rdo_it_end )
54  {
55  rawdata = *rdo_it;
56 
57  StrawWord = rawdata->getWord();
58  StrawID = rawdata->identify();
59 
60  BufferOffset = m_CablingSvc->getBufferOffset( StrawID );
61 
62  // if ( 0 == BufferOffset )
63  // cout << m_trt_id->print_to_string( StrawID ) << " ->"
64  // << BufferOffset << "<- " << endl;
65 
66  v32rod[BufferOffset] = StrawWord;
67 
68  ++rdo_it;
69  }
70 
71  return StatusCode::SUCCESS;
72 } // end of fillROD(...)
73 
77 TRT_RodEncoder::fillROD3( std::vector<uint32_t>& v32rod )
78 {
79  if ( ! m_CablingSvc )
80  return StatusCode::FAILURE;
81 
82  const int TRT_MaxBufferSize = 120*16;
83  int tmp_data[TRT_MaxBufferSize] = {0}; // does init to 0 for all !
84 
85  std::deque<bool> bitstowrite;
86 
87  VRDO::iterator rdo_it = m_RDOs.begin();
88  const VRDO::iterator rdo_it_end = m_RDOs.end();
89 
90  const RDO* rawdata;
91  uint32_t StrawWord;
92  Identifier StrawID;
93  uint32_t BufferOffset;
94 
95  while ( rdo_it != rdo_it_end )
96  {
97  rawdata = *rdo_it;
98 
99  StrawWord = rawdata->getWord();
100  StrawID = rawdata->identify();
101 
102  BufferOffset = m_CablingSvc->getBufferOffset( StrawID );
103 
104  // if ( 0 == BufferOffset )
105  // cout << m_trt_id->print_to_string( StrawID ) << " ->"
106  // << BufferOffset << "<- " << endl;
107 
108  tmp_data[BufferOffset] = StrawWord;
109 
110  ++rdo_it;
111  }
112 
113  for ( int i=0; i<TRT_MaxBufferSize; i++ )
114  {
115  if ( tmp_data[i] )
116  {
117  /*
118  * Push escape code
119  */
120  bitstowrite.push_back( 0 );
121  bitstowrite.push_back( 0 );
122  bitstowrite.push_back( 0 );
123  bitstowrite.push_back( 0 );
124  bitstowrite.push_back( 0 );
125 
126  /*
127  * Push Straw Word
128  */
129 
130  //for ( int j=27-1; j>=0; j-- )
131  for ( int j=0; j<27; j++ )
132  bitstowrite.push_back( (tmp_data[i] >> j) & 1 );
133  }
134  else
135  bitstowrite.push_back( 1 );
136  }
137 
138 
139 
140  int bit_in_word = 0;
141  int out_word = 0;
142  while ( ! bitstowrite.empty() )
143  {
144  out_word = out_word | ( (bitstowrite.front()?1:0) << bit_in_word );
145  bitstowrite.pop_front();
146  bit_in_word++;
147 
148  if ( bit_in_word > 31 )
149  {
150  v32rod.push_back( out_word );
151  out_word = 0;
152  bit_in_word = 0;
153  }
154  }
155 
156  if ( 0 != bit_in_word )
157  v32rod.push_back( out_word );
158 
159  return StatusCode::SUCCESS;
160 } // end of fillROD(...)
161 
162 
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
TRT_RodEncoder::~TRT_RodEncoder
~TRT_RodEncoder()
destructor
TRT_ID.h
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
TRT_RodEncoder::fillROD
StatusCode fillROD(std::vector< uint32_t > &v)
conversion of ROD into ROD fragment
Definition: TRT_RodEncoder.cxx:36
TRT_RDORawData.h
TRT_RodEncoder.h
TRT_RDORawData
Definition: TRT_RDORawData.h:24
lumiFormat.i
int i
Definition: lumiFormat.py:92
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
RawEvent.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TRT_RodEncoder::TRT_RodEncoder
TRT_RodEncoder()
constructor
Definition: TRT_RodEncoder.cxx:23
ITRT_CablingSvc.h
TRT_RodEncoder::fillROD3
StatusCode fillROD3(std::vector< uint32_t > &v)
conversion of ROD into compressed ROD fragment
Definition: TRT_RodEncoder.cxx:77
InDetRawData::getWord
unsigned int getWord() const
Definition: InDetRawData.h:47
TRT_RodEncoder::m_RDOs
VRDO m_RDOs
Definition: TRT_RodEncoder.h:60
InDetRawData::identify
virtual Identifier identify() const override final
Definition: InDetRawData.h:41
TRT_RodEncoder::m_CablingSvc
ServiceHandle< ITRT_CablingSvc > m_CablingSvc
Definition: TRT_RodEncoder.h:58