14 #include "eformat/SourceIdentifier.h"
15 #include "eformat/Status.h"
31 template<
typename T,
typename W>
35 const EventContext &ctx) {
36 if (!handle.
empty()) {
37 return map.emplace(std::make_pair(
source, inTime),
39 std::make_unique<T>(), std::make_unique<W>());
41 return StatusCode::SUCCESS;
46 const std::string&
name,
71 m_decoder = std::make_unique<L1CaloBsDecoderRun3>();
81 return StatusCode::SUCCESS;
87 Monitored::Scalar(
"efexDecoderErrorLocation",std::string(
"lb=") +
std::to_string(Gaudi::Hive::currentContext().eventID().lumi_block()) +
"," + (location.empty() ? std::string(
"UNKNOWN") : location)),
92 Monitored::Scalar(
"decoderError",(
title.empty() ? std::string(
"UNKNOWN") :
title) +
":" + (location.empty() ? std::string(
"UNKNOWN") : location))
103 bool multislice=
false;
107 eContainers, L1CaloRdoFexTob::TobSource::EfexTob,
false,
m_eEMWriteKey, ctx)));
110 ATH_CHECK(
StatusCode(addContainer<xAOD::eFexTauRoIContainer, xAOD::eFexTauRoIAuxContainer>(
111 tContainers, L1CaloRdoFexTob::TobSource::EfexTob,
false,
m_eTAUWriteKey, ctx)));
115 eContainers,L1CaloRdoFexTob::TobSource::EfexXtob,
false,
m_eEMxWriteKey,ctx)) );
118 ATH_CHECK(
StatusCode(addContainer<xAOD::eFexTauRoIContainer,xAOD::eFexTauRoIAuxContainer>(
119 tContainers,L1CaloRdoFexTob::TobSource::EfexXtob,
false,
m_eTAUxWriteKey,ctx)) );
127 ATH_CHECK(
StatusCode(addContainer<xAOD::eFexTauRoIContainer,xAOD::eFexTauRoIAuxContainer>(
136 ATH_CHECK( eTowers.
record(std::make_unique<xAOD::eFexTowerContainer>(),std::make_unique<xAOD::eFexTowerAuxContainer>()) );
139 std::list<L1CaloRdoRodInfo> rodInfos;
140 std::list<L1CaloRdoEfexTob> efexTobs;
141 std::list<L1CaloRdoEfexTower> efexTowers;
143 std::map<std::tuple<int,int,int,int,int>,
size_t> towerMap;
144 for (
const ROBF* rob : vrobf) {
146 ATH_MSG_DEBUG(
"Decoding " << rob->rod_ndata() <<
" ROD words from ROB 0x" << std::hex << rob->rob_source_id() << std::dec);
149 if(rob->rod_ndata()==0)
continue;
152 auto lastRod = rodInfos.end(); lastRod--;
154 if ( (rob->rob_source_id() >> 16) == eformat::TDAQ_CALO_FEAT_EXTRACT_DAQ && !
m_eTowerWriteKey.empty() ) {
159 decoder.decodeEfexData(
data.begin(),
data.end(), efexTowers, lastRod );
160 for(
auto&
t : efexTowers) {
161 if (
t.getLayer() != 0)
continue;
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>() );
165 std::vector<uint16_t> counts(11,0);
166 counts[0] =
t.getSupercells().at(4);
168 counts[
idx+1] =
t.getSupercells().at(
idx+5);
169 counts[
idx+5] =
t.getSupercells().at(
idx);
171 counts[9] =
t.getSupercells().at(9);
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,
175 t.getModule() +
t.getCrate()*12,
180 for(
auto&
t : efexTowers) {
181 if (
t.getLayer() == 0)
continue;
183 if(
auto itr = towerMap.find({t.getCrate(), t.getModule(), t.getFpgaNumber(),t.getRegion().getEtaIndex(),t.getRegion().getPhiIndex()}); itr != towerMap.end()) {
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,1025),
191 t.getModule() +
t.getCrate()*12,
t.getFpgaNumber(),0,
t.getFlag());
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);
202 }
else if ( (rob->rob_source_id() >> 16) == eformat::TDAQ_CALO_FEAT_EXTRACT_ROI ) {
210 if (!multislice &&
int(
slice) != tob.getL1aPos())
212 if (tob.getWord0(
slice) == 0)
continue;
214 auto cont = eContainers.find({tob.getTobSource(),
int(
slice) != tob.getL1aPos()});
215 if (cont == eContainers.end())
continue;
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));
220 cont->second->back()->initialize(tob.getWord0(
slice), tob.getWord1(
slice));
223 auto cont = tContainers.find({tob.getTobSource(),
int(
slice) != tob.getL1aPos()});
224 if (cont == tContainers.end())
continue;
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));
229 cont->second->back()->initialize(tob.getWord0(
slice), tob.getWord1(
slice));
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, ";
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, ";
257 return StatusCode::SUCCESS;
262 return StatusCode::FAILURE;