ATLAS Offline Software
Loading...
Searching...
No Matches
eFexByteStreamTool Class Reference

#include <eFexByteStreamTool.h>

Inheritance diagram for eFexByteStreamTool:
Collaboration diagram for eFexByteStreamTool:

Classes

class  MonitoredLogging
 Create a class to override logging interface in underlying decoder tool. More...

Public Member Functions

 eFexByteStreamTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~eFexByteStreamTool () override=default
virtual StatusCode initialize () override
virtual StatusCode convertFromBS (const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &vrobf, const EventContext &eventContext) const override
 BS->xAOD conversion.
virtual StatusCode convertToBS (std::vector< OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment * > &vrobf, const EventContext &eventContext) override
 xAOD->BS conversion
virtual const std::vector< uint32_t > & robIds () const override
 Declare ROB IDs for conversion.

Private Attributes

ToolHandle< GenericMonitoringToolm_monTool {this,"MonTool","","Monitoring tool"}
Gaudi::Property< std::vector< uint32_t > > m_robIds {this, "ROBIDs", {}, "List of ROB IDs required for conversion to/from xAOD RoI"}
SG::WriteHandleKey< xAOD::eFexEMRoIContainerm_eEMWriteKey
SG::WriteHandleKey< xAOD::eFexTauRoIContainerm_eTAUWriteKey
SG::WriteHandleKey< xAOD::eFexEMRoIContainerm_eEMxWriteKey
SG::WriteHandleKey< xAOD::eFexTauRoIContainerm_eTAUxWriteKey
SG::WriteHandleKey< xAOD::eFexEMRoIContainerm_eEMSliceWriteKey
SG::WriteHandleKey< xAOD::eFexTauRoIContainerm_eTAUSliceWriteKey
SG::WriteHandleKey< xAOD::eFexTowerContainerm_eTowerWriteKey
SG::ReadHandleKey< xAOD::eFexEMRoIContainerm_eEMReadKey
SG::ReadHandleKey< xAOD::eFexTauRoIContainerm_eTAUReadKey
std::unique_ptr< L1CaloBsDecoderRun3m_decoder

Detailed Description

Definition at line 40 of file eFexByteStreamTool.h.

Constructor & Destructor Documentation

◆ eFexByteStreamTool()

eFexByteStreamTool::eFexByteStreamTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 45 of file eFexByteStreamTool.cxx.

48 : base_class(type, name, parent) {}

◆ ~eFexByteStreamTool()

virtual eFexByteStreamTool::~eFexByteStreamTool ( )
overridevirtualdefault

Member Function Documentation

◆ convertFromBS()

StatusCode eFexByteStreamTool::convertFromBS ( const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > & vrobf,
const EventContext & eventContext ) const
overridevirtual

BS->xAOD conversion.

Definition at line 97 of file eFexByteStreamTool.cxx.

97 {
98
99 // indices are source (tob or xtob) and bool for in/out of time
100 std::map<std::pair<L1CaloRdoFexTob::TobSource,bool>,SG::WriteHandle<xAOD::eFexEMRoIContainer>> eContainers;
101 std::map<std::pair<L1CaloRdoFexTob::TobSource,bool>,SG::WriteHandle<xAOD::eFexTauRoIContainer>> tContainers;
102
103 bool multislice=false;
104
105 if (!m_eEMWriteKey.empty()) {
106 ATH_CHECK(StatusCode(addContainer<xAOD::eFexEMRoIContainer, xAOD::eFexEMRoIAuxContainer>(
107 eContainers, L1CaloRdoFexTob::TobSource::EfexTob, false, m_eEMWriteKey, ctx)));
108 }
109 if (!m_eTAUWriteKey.empty()) {
110 ATH_CHECK(StatusCode(addContainer<xAOD::eFexTauRoIContainer, xAOD::eFexTauRoIAuxContainer>(
111 tContainers, L1CaloRdoFexTob::TobSource::EfexTob, false, m_eTAUWriteKey, ctx)));
112 }
113 if (!m_eEMxWriteKey.empty()) {
114 ATH_CHECK( StatusCode(addContainer<xAOD::eFexEMRoIContainer,xAOD::eFexEMRoIAuxContainer>(
116 }
117 if (!m_eTAUxWriteKey.empty()) {
118 ATH_CHECK( StatusCode(addContainer<xAOD::eFexTauRoIContainer,xAOD::eFexTauRoIAuxContainer>(
120 }
121 if (!m_eEMSliceWriteKey.empty()) {
122 ATH_CHECK( StatusCode(addContainer<xAOD::eFexEMRoIContainer,xAOD::eFexEMRoIAuxContainer>(
124 multislice=true;
125 }
126 if (!m_eTAUSliceWriteKey.empty()) {
127 ATH_CHECK( StatusCode(addContainer<xAOD::eFexTauRoIContainer,xAOD::eFexTauRoIAuxContainer>(
129 multislice=true;
130 }
131
132
133 SG::WriteHandle<xAOD::eFexTowerContainer> eTowers;
134 if(!m_eTowerWriteKey.empty()) {
135 eTowers = SG::WriteHandle<xAOD::eFexTowerContainer>(m_eTowerWriteKey,ctx);
136 ATH_CHECK( eTowers.record(std::make_unique<xAOD::eFexTowerContainer>(),std::make_unique<xAOD::eFexTowerAuxContainer>()) );
137 }
138
139 std::list<L1CaloRdoRodInfo> rodInfos;
140 std::list<L1CaloRdoEfexTob> efexTobs;
141 std::list<L1CaloRdoEfexTower> efexTowers;
142 L1CaloBsDecoderRun3& decoder = *m_decoder;
143 std::map<std::tuple<int,int,int,int,int>,size_t> towerMap; // maps {crate,module,fpga,eta,phi} onto index in vector
144 for (const ROBF* rob : vrobf) {
145 // Iterate over ROD words and decode
146 ATH_MSG_DEBUG("Decoding " << rob->rod_ndata() << " ROD words from ROB 0x" << std::hex << rob->rob_source_id() << std::dec);
147 L1CaloBsDecoderUtil::decodeRodInfo( rob, rodInfos );
148
149 if(rob->rod_ndata()==0) continue;
150
151 CxxUtils::span data{rob->rod_data(), rob->rod_ndata()};
152 auto lastRod = rodInfos.end(); lastRod--;
153
154 if ( (rob->rob_source_id() >> 16) == eformat::TDAQ_CALO_FEAT_EXTRACT_DAQ && !m_eTowerWriteKey.empty() ) {
155 // decoding raw input data
156 // tower et counts should be in order: PS, L1, L2, L3, Had
157 // towers with all et counts 0 will still be zero-suppressed
158 efexTowers.clear();
159 decoder.decodeEfexData(data.begin(), data.end(), efexTowers, lastRod );
160 for(auto& t : efexTowers) {
161 if (t.getLayer() != 0) continue; // do hadronic in next loop
162 towerMap[std::make_tuple(t.getCrate(),t.getModule(),t.getFpgaNumber(),t.getRegion().getEtaIndex(),t.getRegion().getPhiIndex())] = eTowers->size();
163 eTowers->push_back( std::make_unique<xAOD::eFexTower>() );
164 // in bytestream cell orders are L2,PS,L1,L3 so reorder to usual PS,L1,L2,L3 order
165 std::vector<uint16_t> counts(11,xAOD::eFexTower::c_missingCountCode);
166 counts[0] = t.getSupercells().at(4);
167 for(size_t idx = 0;idx<4;idx++) {
168 counts[idx+1] = t.getSupercells().at(idx+5); // L1
169 counts[idx+5] = t.getSupercells().at(idx); // L2
170 }
171 counts[9] = t.getSupercells().at(9);
172
173 eTowers->back()->initialize(t.getRegion().getEtaIndex()*0.1 + 0.05,2.*ROOT::Math::Pi()*(0.5 + t.getRegion().getPhiIndex() - 64*(t.getRegion().getPhiIndex()>=32))/64,
174 counts,
175 t.getModule() + t.getCrate()*12,
176 t.getFpgaNumber(),
177 t.getFlag(),0 /* hadronic status flag */);
178 }
179
180 for(auto& t : efexTowers) {
181 if (t.getLayer() == 0) continue; // do hadronic towers now ... add to existing towers
182 size_t idx = eTowers->size();
183 if(auto itr = towerMap.find({t.getCrate(), t.getModule(), t.getFpgaNumber(),t.getRegion().getEtaIndex(),t.getRegion().getPhiIndex()}); itr != towerMap.end()) {
184 idx = itr->second;
185 } else {
186 // possible that ecal tower was zero-suppressed but hcal has energy, so create such a tower
187 towerMap[std::make_tuple(t.getCrate(),t.getModule(),t.getFpgaNumber(),t.getRegion().getEtaIndex(),t.getRegion().getPhiIndex())] = eTowers->size();
188 eTowers->push_back( std::make_unique<xAOD::eFexTower>() );
189 eTowers->back()->initialize(t.getRegion().getEtaIndex()*0.1 + 0.05,2.*ROOT::Math::Pi()*(0.5 + t.getRegion().getPhiIndex() - 64*(t.getRegion().getPhiIndex()>=32))/64,
190 std::vector<uint16_t>(11,xAOD::eFexTower::c_missingCountCode),
191 t.getModule() + t.getCrate()*12,t.getFpgaNumber(),0,t.getFlag());
192 }
193 auto tower = eTowers->at(idx);
194 tower->setHad_status(t.getFlag());
195 auto et_count = tower->et_count();
196 et_count.at(10) = t.getValue();
197 tower->setEt_count(et_count);
198 }
199
200
201
202 } else if ( (rob->rob_source_id() >> 16) == eformat::TDAQ_CALO_FEAT_EXTRACT_ROI ) {
203 // decoding tobs
204 efexTobs.clear();
205 decoder.decodeEfexTobs(data.begin(), data.end(), efexTobs, lastRod);
206
207 for (const L1CaloRdoEfexTob &tob: efexTobs) {
208 // loop over slices ... create separate tobs for each, where there's a word defined
209 for (size_t slice = 0; slice < tob.numSlices(); slice++) {
210 if (!multislice && int(slice) != tob.getL1aPos())
211 continue; // ignore out-of-time slices if multiSlice option = false
212 if (tob.getWord0(slice) == 0) continue; // this tob isn't in this slice
213 if (tob.getTobType() == L1CaloRdoFexTob::TobType::EM) {
214 auto cont = eContainers.find({tob.getTobSource(), int(slice) != tob.getL1aPos()});
215 if (cont == eContainers.end()) continue; // not writing this tob collection
216 cont->second->push_back(std::make_unique<xAOD::eFexEMRoI>());
217 if (tob.getTobSource() == L1CaloRdoFexTob::TobSource::EfexTob) {
218 cont->second->back()->initialize(tob.getModule(), tob.getCrate(), tob.getWord0(slice));
219 } else {
220 cont->second->back()->initialize(tob.getWord0(slice), tob.getWord1(slice));
221 }
222 } else if (tob.getTobType() == L1CaloRdoFexTob::TobType::Tau) {
223 auto cont = tContainers.find({tob.getTobSource(), int(slice) != tob.getL1aPos()});
224 if (cont == tContainers.end()) continue; // not writing this tob collection
225 cont->second->push_back(std::make_unique<xAOD::eFexTauRoI>());
226 if (tob.getTobSource() == L1CaloRdoFexTob::TobSource::EfexTob) {
227 cont->second->back()->initialize(tob.getModule(), tob.getCrate(), tob.getWord0(slice));
228 } else {
229 cont->second->back()->initialize(tob.getWord0(slice), tob.getWord1(slice));
230 }
231 }
232 } // timeslice loop
233 } // tob loop
234 } // tob data if block
235 } // fragment loop
236
237 if(msgLevel(MSG::DEBUG)) {
238 std::stringstream msg;
239 for (auto&[k, v]: eContainers) {
240 msg << v->size() << " " << (k.second ? "out-of-time " : "in-time ") << "eg" <<
241 (k.first == L1CaloRdoFexTob::TobSource::EfexTob ? "" : "x") << "TOB, ";
242 }
243 for (auto&[k, v]: tContainers) {
244 msg << v->size() << " " << (k.second ? "out-of-time " : "in-time ") << "tau" <<
245 (k.first == L1CaloRdoFexTob::TobSource::EfexTob ? "" : "x") << "TOB, ";
246 }
247 ATH_MSG_DEBUG("Decoded: " << msg.str());
248 if (!m_eTowerWriteKey.empty()) {
249 ATH_MSG_DEBUG("Decoded: " << eTowers->size() << " eTowers");
250 }
251 }
252 // this is how to print the in-time em xTOBs:
253// for(const auto& tob : *(eContainers[{L1CaloRdoFexTob::TobSource::EfexXtob,false}])) {
254// std::cout << tob->eFexNumber() << "." << tob->fpga() << ": " << tob->fpgaEta() << " " << tob->fpgaPhi() << " " << tob->et() << " " << tob->etXTOB() << " " << tob->etTOB() << " " << std::endl;
255// }
256
257 return StatusCode::SUCCESS;
258}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment ROBF
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static void decodeRodInfo(const eformat::ROBFragment< const uint32_t * > *rod, std::list< L1CaloRdoRodInfo > &dat)
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SG::WriteHandleKey< xAOD::eFexTowerContainer > m_eTowerWriteKey
SG::WriteHandleKey< xAOD::eFexTauRoIContainer > m_eTAUxWriteKey
SG::WriteHandleKey< xAOD::eFexTauRoIContainer > m_eTAUWriteKey
std::unique_ptr< L1CaloBsDecoderRun3 > m_decoder
SG::WriteHandleKey< xAOD::eFexEMRoIContainer > m_eEMxWriteKey
SG::WriteHandleKey< xAOD::eFexEMRoIContainer > m_eEMSliceWriteKey
SG::WriteHandleKey< xAOD::eFexTauRoIContainer > m_eTAUSliceWriteKey
SG::WriteHandleKey< xAOD::eFexEMRoIContainer > m_eEMWriteKey
static const int c_missingCountCode
span(T *ptr, std::size_t sz) -> span< T >
A couple needed deduction guides.
::StatusCode StatusCode
StatusCode definition for legacy code.
MsgStream & msg
Definition testRead.cxx:32

◆ convertToBS()

StatusCode eFexByteStreamTool::convertToBS ( std::vector< OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment * > & vrobf,
const EventContext & eventContext )
overridevirtual

xAOD->BS conversion

Definition at line 260 of file eFexByteStreamTool.cxx.

260 {
261 // not supported yet
262 return StatusCode::FAILURE;
263}

◆ initialize()

StatusCode eFexByteStreamTool::initialize ( )
overridevirtual

Definition at line 50 of file eFexByteStreamTool.cxx.

50 {
51
52 // Initialise eEM data handle keys
53 ATH_CHECK(m_eEMReadKey.initialize(!m_eEMReadKey.empty()));
54 ATH_CHECK(m_eEMWriteKey.initialize(!m_eEMWriteKey.empty()));
55
56 // Initialise eTAU data handle keys
57 ATH_CHECK(m_eTAUReadKey.initialize(!m_eTAUReadKey.empty()));
58 ATH_CHECK(m_eTAUWriteKey.initialize(!m_eTAUWriteKey.empty()));
59
60 // write keys for xTOBs
61 ATH_CHECK(m_eEMxWriteKey.initialize(!m_eEMxWriteKey.empty()));
62 ATH_CHECK(m_eTAUxWriteKey.initialize(!m_eTAUxWriteKey.empty()));
63
64 // multislice TOBs
67
68 // Initialize eTower handle key
69 ATH_CHECK(m_eTowerWriteKey.initialize(!m_eTowerWriteKey.empty()));
70
71 m_decoder = std::make_unique<L1CaloBsDecoderRun3>();
72
73 // Initialize monitoring tool if not empty
74 if (!m_monTool.empty()) {
75 ATH_CHECK(m_monTool.retrieve());
76 m_decoder->setLogger( std::make_unique<MonitoredLogging>(m_monTool) );
77 ATH_MSG_INFO("Logging errors to " << m_monTool.name() << " monitoring tool");
78 }
79
80
81 return StatusCode::SUCCESS;
82}
#define ATH_MSG_INFO(x)
SG::ReadHandleKey< xAOD::eFexTauRoIContainer > m_eTAUReadKey
SG::ReadHandleKey< xAOD::eFexEMRoIContainer > m_eEMReadKey
ToolHandle< GenericMonitoringTool > m_monTool

◆ robIds()

virtual const std::vector< uint32_t > & eFexByteStreamTool::robIds ( ) const
inlineoverridevirtual

Declare ROB IDs for conversion.

Definition at line 56 of file eFexByteStreamTool.h.

56 {
57 return m_robIds.value();
58 }
Gaudi::Property< std::vector< uint32_t > > m_robIds

Member Data Documentation

◆ m_decoder

std::unique_ptr<L1CaloBsDecoderRun3> eFexByteStreamTool::m_decoder
private

Definition at line 107 of file eFexByteStreamTool.h.

◆ m_eEMReadKey

SG::ReadHandleKey<xAOD::eFexEMRoIContainer> eFexByteStreamTool::m_eEMReadKey
private
Initial value:
{
this, "eEMContainerReadKey", "", "Read handle key to eEM (x)TOB container for conversion to ByteStream"}

Definition at line 98 of file eFexByteStreamTool.h.

98 {
99 this, "eEMContainerReadKey", "", "Read handle key to eEM (x)TOB container for conversion to ByteStream"};

◆ m_eEMSliceWriteKey

SG::WriteHandleKey<xAOD::eFexEMRoIContainer> eFexByteStreamTool::m_eEMSliceWriteKey
private
Initial value:
{
this, "eEMSliceContainerWriteKey", "", "Write handle key to eEM TOB out-of-time container for conversion from ByteStream"}

Definition at line 89 of file eFexByteStreamTool.h.

89 {
90 this, "eEMSliceContainerWriteKey", "", "Write handle key to eEM TOB out-of-time container for conversion from ByteStream"};

◆ m_eEMWriteKey

SG::WriteHandleKey<xAOD::eFexEMRoIContainer> eFexByteStreamTool::m_eEMWriteKey
private
Initial value:
{
this, "eEMContainerWriteKey", "", "Write handle key to eEM TOB container for conversion from ByteStream"}

Definition at line 79 of file eFexByteStreamTool.h.

79 {
80 this, "eEMContainerWriteKey", "", "Write handle key to eEM TOB container for conversion from ByteStream"};

◆ m_eEMxWriteKey

SG::WriteHandleKey<xAOD::eFexEMRoIContainer> eFexByteStreamTool::m_eEMxWriteKey
private
Initial value:
{
this, "eEMxContainerWriteKey", "", "Write handle key to eEM xTOB container for conversion from ByteStream"}

Definition at line 83 of file eFexByteStreamTool.h.

83 {
84 this, "eEMxContainerWriteKey", "", "Write handle key to eEM xTOB container for conversion from ByteStream"};

◆ m_eTAUReadKey

SG::ReadHandleKey<xAOD::eFexTauRoIContainer> eFexByteStreamTool::m_eTAUReadKey
private
Initial value:
{
this, "eTAUContainerReadKey", "", "Read handle key to eTAU (x)TOB container for conversion to ByteStream"}

Definition at line 100 of file eFexByteStreamTool.h.

100 {
101 this, "eTAUContainerReadKey", "", "Read handle key to eTAU (x)TOB container for conversion to ByteStream"};

◆ m_eTAUSliceWriteKey

SG::WriteHandleKey<xAOD::eFexTauRoIContainer> eFexByteStreamTool::m_eTAUSliceWriteKey
private
Initial value:
{
this, "eTAUSliceContainerWriteKey", "", "Write handle key to eTAU TOB out-of-time container for conversion from ByteStream"}

Definition at line 91 of file eFexByteStreamTool.h.

91 {
92 this, "eTAUSliceContainerWriteKey", "", "Write handle key to eTAU TOB out-of-time container for conversion from ByteStream"};

◆ m_eTAUWriteKey

SG::WriteHandleKey<xAOD::eFexTauRoIContainer> eFexByteStreamTool::m_eTAUWriteKey
private
Initial value:
{
this, "eTAUContainerWriteKey", "", "Write handle key to eTAU TOB container for conversion from ByteStream"}

Definition at line 81 of file eFexByteStreamTool.h.

81 {
82 this, "eTAUContainerWriteKey", "", "Write handle key to eTAU TOB container for conversion from ByteStream"};

◆ m_eTAUxWriteKey

SG::WriteHandleKey<xAOD::eFexTauRoIContainer> eFexByteStreamTool::m_eTAUxWriteKey
private
Initial value:
{
this, "eTAUxContainerWriteKey", "", "Write handle key to eTAU xTOB container for conversion from ByteStream"}

Definition at line 85 of file eFexByteStreamTool.h.

85 {
86 this, "eTAUxContainerWriteKey", "", "Write handle key to eTAU xTOB container for conversion from ByteStream"};

◆ m_eTowerWriteKey

SG::WriteHandleKey<xAOD::eFexTowerContainer> eFexByteStreamTool::m_eTowerWriteKey
private
Initial value:
{
this, "eTowerContainerWriteKey", "", "Write handle key to ETower container for conversion from ByteStream"}

Definition at line 94 of file eFexByteStreamTool.h.

94 {
95 this, "eTowerContainerWriteKey", "", "Write handle key to ETower container for conversion from ByteStream"};

◆ m_monTool

ToolHandle<GenericMonitoringTool> eFexByteStreamTool::m_monTool {this,"MonTool","","Monitoring tool"}
private

Definition at line 61 of file eFexByteStreamTool.h.

61{this,"MonTool","","Monitoring tool"};

◆ m_robIds

Gaudi::Property<std::vector<uint32_t> > eFexByteStreamTool::m_robIds {this, "ROBIDs", {}, "List of ROB IDs required for conversion to/from xAOD RoI"}
private

Definition at line 74 of file eFexByteStreamTool.h.

74{this, "ROBIDs", {}, "List of ROB IDs required for conversion to/from xAOD RoI"};

The documentation for this class was generated from the following files: