48 ATH_MSG_DEBUG(
"L1CaloL1TopoMonitorAlgorithm::fillHistograms");
54 typedef std::tuple<int,int,int,int,int,int> TobKey;
63 std::vector<int> errors;
64 std::vector<std::reference_wrapper<Monitored::IMonitoredVariable>> variables;
73 variables.push_back(
run);
74 variables.push_back(nJetTobs);
75 variables.push_back(nTauTobs);
76 variables.push_back(nEMTobs);
77 variables.push_back(nMuonTobs);
138 if (!l1TopoRawData.
isValid()) {
143 return StatusCode::SUCCESS;
145 if (l1TopoRawData->empty()) {
150 return StatusCode::SUCCESS;
155 std::vector<uint32_t> ctp_data=const_ctpRdo->getDataWords();
156 CTP_RDO ctpRdo(4,std::move(ctp_data));
162 ATH_MSG_DEBUG(
"CTP version number not set, skipping CTP test");
168 const uint32_t bx=ctp.getBunchCrossings().size();
174 ATH_MSG_DEBUG(
"CTP l1aPos, size : " << l1aPos <<
", " << bx );
175 if ( bx>=3 && l1aPos>0) {
176 for (
int bc=-dbx; bc<=dbx; ++bc) {
177 const CTP_BC& ctp_bc = ctp.getBunchCrossings().at(l1aPos+bc);
178 std::bitset<512> tip = ctp_bc.
getTIP();
180 const unsigned int topoTipStart(384);
181 const unsigned int nTopoCTPOutputs(128);
182 for (
unsigned int item=0; item<nTopoCTPOutputs;++item) {
184 if (tip.test(item+topoTipStart)) {
198 if (cmxCpTob->empty()) {
202 ATH_MSG_DEBUG(
"Found CMXCPTobCollection, looping on TOBs ..." );
205 for (
int clone=0;clone<4;++clone) {
207 cmxKeys[
TAU_TOB].insert(std::make_tuple(t->crate(),t->cpm(),
208 t->chip(),t->location(),
211 cmxKeys[
EM_TOB].insert(std::make_tuple(t->crate(),t->cpm(),
212 t->chip(),t->location(),
220 if (cmxJetTob->empty()) {
224 ATH_MSG_DEBUG(
"Found CMXJetTobCollection, looping on TOBs ..." );
226 for (
int clone=0;clone<4;++clone) {
227 if (t->energyLarge())
228 cmxKeys[
JETL_TOB].insert(std::make_tuple(t->crate(),t->jem(),
229 t->frame(),t->location(),
230 t->energyLarge(),clone));
231 if (t->energySmall())
232 cmxKeys[
JETS_TOB].insert(std::make_tuple(t->crate(),t->jem(),
233 t->frame(),t->location(),
234 t->energySmall(),clone));
248 if (rawdata->errorWord()) {
249 ATH_MSG_INFO(
"DAQ Converter errors reported: " << rawdata->errorWord());
252 if (rawdata->dataWords().empty()) {
257 std::vector<L1Topo::L1TopoTOB> daqTobs;
263 for (
auto word : rawdata->dataWords()) {
269 if (
header.payload_crc()!=0) {
272 i_fpga=(((rawdata->sourceID())>>3)&2)+
header.fpga();
284 <<
" fibre crc: " << status.crc() );
292 if (
header.bcn_offset()==0){
295 daqTobs.push_back(tob);
298 for (
unsigned int i=0; i<8; ++i){
299 if ((tob.trigger_bits() >>i)&1) {
302 if ((tob.overflow_bits()>>i)&1) {
312 if (
header.bcn_offset()==0) {
313 const int crate = (word >> 28) & 0x1;
314 const int jem = (word >> 24) & 0xF;
315 const int frame = (word >> 21) & 0x7;
316 const int location = (word >> 19) & 0x3;
317 const int energyS = (word >> 10) & 0x1FF;
318 const int energyL = (word & 0x3FF);
321 insert(std::make_tuple(crate,jem,frame,
322 location,energyL,i_fpga));
324 jetTobsEnergyL=energyL;
329 insert(std::make_tuple(crate,jem,frame,
330 location,energyS,i_fpga));
337 if (
header.bcn_offset()==0) {
339 const int crate = (word >> 26) & 0x3;
340 const int cpm = (word >> 20) & 0xF;
341 const int chip = (word >> 15) & 0xF;
342 const int location = (word >> 13) & 0x3;
343 const int energy = (word & 0xFF);
346 insert(std::make_tuple(crate,cpm,chip,
347 location,energy,i_fpga));
353 if (
header.bcn_offset()==0) {
355 const int crate = (word >> 26) & 0x3;
356 const int cpm = (word >> 20) & 0xF;
357 const int chip = (word >> 15) & 0xF;
358 const int location = (word >> 13) & 0x3;
359 const int energy = (word & 0xFF);
362 insert(std::make_tuple(crate,cpm,chip,
363 location,energy,i_fpga));
369 if (
header.bcn_offset()==0){
376 if (
header.bcn_offset()==0){
395 set_symmetric_difference(cmxKeys[t].begin(),cmxKeys[t].end(),
396 topoKeys[t].begin(),topoKeys[t].end(),
397 inserter(keyDiff[t],keyDiff[t].begin()));
398 if (keyDiff[t].size()>0) {
400 << keyDiff[t].size());
403 for (
auto& tob : keyDiff[t]) {
407 jem2Coord(std::get<0>(tob),std::get<1>(tob),
408 std::get<2>(tob),std::get<3>(tob),
x,
y,
eta,
phi);
410 xJetSTobs_mismatch=
x; yJetSTobs_mismatch=
y;
411 etaJetSTobs_mismatch=
eta; phiJetSTobs_mismatch=
phi;
413 etaJetSTobs_mismatch, phiJetSTobs_mismatch);
416 xJetLTobs_mismatch=
x; yJetLTobs_mismatch=
y;
417 etaJetLTobs_mismatch=
eta; phiJetLTobs_mismatch=
phi;
419 etaJetLTobs_mismatch, phiJetLTobs_mismatch);
423 cpm2Coord(std::get<0>(tob),std::get<1>(tob),
424 std::get<2>(tob),std::get<3>(tob),
x,
y,
eta,
phi);
426 xTauTobs_mismatch=
x; yTauTobs_mismatch=
y;
427 etaTauTobs_mismatch=
eta; phiTauTobs_mismatch=
phi;
429 etaTauTobs_mismatch, phiTauTobs_mismatch);
432 xEMTobs_mismatch=
x; yEMTobs_mismatch=
y;
433 etaEMTobs_mismatch=
eta; phiEMTobs_mismatch=
phi;
435 etaEMTobs_mismatch, phiEMTobs_mismatch);
441 topoKeys[t].begin(),topoKeys[t].end(),
442 inserter(keyIntersect[t],keyIntersect[t].begin()));
443 for (
auto& tob : keyIntersect[t]) {
447 jem2Coord(std::get<0>(tob),std::get<1>(tob),
448 std::get<2>(tob),std::get<3>(tob),
x,
y,
eta,
phi);
450 xJetSTobs_match=
x; yJetSTobs_match=
y;
451 etaJetSTobs_match=
eta; phiJetSTobs_match=
phi;
453 etaJetSTobs_match, phiJetSTobs_match);
456 xJetLTobs_match=
x; yJetLTobs_match=
y;
457 etaJetLTobs_match=
eta; phiJetLTobs_match=
phi;
459 etaJetLTobs_match, phiJetLTobs_match);
463 cpm2Coord(std::get<0>(tob),std::get<1>(tob),
464 std::get<2>(tob),std::get<3>(tob),
x,
y,
eta,
phi);
466 xTauTobs_match=
x; yTauTobs_match=
y;
467 etaTauTobs_match=
eta; phiTauTobs_match=
phi;
469 etaTauTobs_match, phiTauTobs_match);
472 xEMTobs_match=
x; yEMTobs_match=
y;
473 etaEMTobs_match=
eta; phiEMTobs_match=
phi;
475 etaEMTobs_match, phiEMTobs_match);
484 if (!errors.empty()) {
489 nJetTobs=std::min(daqJetTobs/NFPGA,
MAXTOBS-1);
490 nTauTobs=std::min(daqTauTobs/NFPGA,
MAXTOBS-1);
491 nEMTobs=std::min(daqEMTobs/NFPGA,
MAXTOBS-1);
492 nMuonTobs=std::min(daqMuonTobs/NFPGA,
MAXTOBS-1);
495 return StatusCode::SUCCESS;