ATLAS Offline Software
Loading...
Searching...
No Matches
NSWMMTP_ROD_Decoder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5
7#include "Identifier/Identifier.h"
8#include "eformat/Issue.h"
9#include "eformat/SourceIdentifier.h"
10
15
16
17Muon::NSWMMTP_ROD_Decoder::NSWMMTP_ROD_Decoder( const std::string& type, const std::string& name,const IInterface* parent )
18: AthAlgTool(type, name, parent)
19{
20 declareInterface<INSWMMTP_ROD_Decoder>( this );
21}
22
23
25 ATH_CHECK(m_idHelperSvc.retrieve());
26 return StatusCode::SUCCESS;
27}
28
30{
31
32 try {
33 fragment.check();
34 } catch (eformat::Issue &ex) {
35 ATH_MSG_WARNING(ex.what());
36 return StatusCode::SUCCESS;
37 }
38
39
40 const Muon::nsw::NSWTriggerCommonDecoder decoder{fragment, "MML1A"};
41
42 if (decoder.has_error()) {
43 ATH_MSG_DEBUG("NSW MMTP Common Decoder found exceptions while reading this MML1A fragment from " + std::to_string(fragment.rob_source_id()) + ". Skipping. Error id: "+std::to_string(decoder.error_id()));
44 return StatusCode::SUCCESS;
45 }
46
47 if (decoder.get_elinks().size()!=3 && decoder.get_elinks().size()!=5) {
48 // this is a severe requirement: a single elink missing would imply the whole event is problematic
49 ATH_MSG_DEBUG("NSW MMTP Common Decoder didn't give 3 or 5 elinks in output: something off with this fragment. Skipping.");
50 return StatusCode::SUCCESS;
51 }
52
53 //for all the 3/5 elinks expected, the MMTP header parameters should be the same by design
54 //checking consistency of a fraction of the header
55 bool consistent = true;
56 const auto l0 = static_cast<const Muon::nsw::NSWTriggerMML1AElink*>(decoder.get_elinks()[0].get());
57 for(const auto& baseLink: decoder.get_elinks()) {
58 const auto l = static_cast<const Muon::nsw::NSWTriggerMML1AElink*>(baseLink.get());
59 if (l0->head_sectID() != l->head_sectID()) {consistent = false; break;}
60 if (l0->L1ID() != l->L1ID()) {consistent = false; break;}
61 if (l0->l1a_versionID() != l->l1a_versionID()) {consistent = false; break;}
62 if (l0->l1a_req_BCID() != l->l1a_req_BCID()) {consistent = false; break;}
63 }
64 if (!consistent) {
65 ATH_MSG_DEBUG("NSW MMTP Common Decoder found inconsistent header parameters in the elinks: something off with this fragment. Skipping.");
66 return StatusCode::SUCCESS;
67 }
68
69 //TODO add checks: engines, timeouts, constants and elinks ID vs stream IDs
70
72 rdoContainer.push_back(rdo);
73
74 //this info is redundant with elinkID in the decoded packet! Wanna add a check in the future?
75 uint32_t sid = fragment.rob_source_id ();
76 eformat::helper::SourceIdentifier source_id (sid);
77 //eformat::SubDetector s = source_id.subdetector_id ();
78 uint16_t m = source_id.module_id ();
79
80 //ROD info
81 rdo->set_sourceID(sid);
82 rdo->set_moduleID(m);
83 rdo->set_ROD_L1ID(fragment.rod_lvl1_id ());
84 rdo->set_ROD_BCID(fragment.rod_bc_id ());
85
86 //TP head
87 rdo->set_EC(l0->head_EC());
88 rdo->set_sectID(l0->head_sectID());
89 rdo->set_L1ID(l0->L1ID());
90 rdo->set_BCID(l0->head_BCID());
91
92 //TP L1A head
93 rdo->set_l1a_request_BCID(l0->l1a_local_req_BCID());
94 rdo->set_l1a_release_BCID(l0->l1a_local_rel_BCID());
95 rdo->set_l1a_window_open(l0->l1a_open_BCID());
96 rdo->set_l1a_window_center(l0->l1a_req_BCID());
97 rdo->set_l1a_window_close(l0->l1a_close_BCID());
98 rdo->set_l1a_window_open_offset(l0->l1a_open_BCID_offset());
99 rdo->set_l1a_window_center_offset(l0->l1a_req_BCID_offset());
100 rdo->set_l1a_window_close_offset(l0->l1a_close_BCID_offset());
101
102 //L1A data quality
103 rdo->set_l1a_timeout(l0->l1a_timeout());
104 rdo->set_l1a_engines(l0->l1a_engine_snapshot());
105
106 for(const auto& baseLink: decoder.get_elinks()){
107 const auto l = dynamic_cast<const Muon::nsw::NSWTriggerMML1AElink*>(baseLink.get());
108
109 if (l->l1a_timeout()==0) {ATH_MSG_DEBUG("NSW MMTP Common Decoder reporting timeout condition: unclear if current event can be trusted");}
110
111 for (const auto& a: l->art_packets()) {
112 for (const auto& c: a->channels()) {
113 rdo->art_BCID().push_back(a->art_BCID());
114 rdo->art_layer().push_back(c.first);
115 rdo->art_channel().push_back(c.second);
116 }
117 }
118 for (const auto& t: l->trig_packets()) {
119 rdo->trig_globalX().push_back(t->trig_globalX());
120 rdo->trig_globalU().push_back(t->trig_globalU());
121 rdo->trig_BCID().push_back(t->trig_BCID());
122 rdo->trig_dTheta().push_back(t->trig_dTheta());
123 rdo->trig_ROI_rID().push_back(t->trig_rBin());
124 rdo->trig_ROI_phiID().push_back(t->trig_phiBin());
125 }
126
127 }
128
129
130 return StatusCode::SUCCESS;
131}
132
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t a
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
StatusCode fillCollection(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &fragment, xAOD::NSWMMTPRDOContainer &rdoContainer) const override
NSWMMTP_ROD_Decoder(const std::string &type, const std::string &name, const IInterface *parent)
StatusCode initialize() override
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130
eformat::ROBFragment< PointerType > ROBFragment
Definition RawEvent.h:27
NSWMMTPRDOContainer_v1 NSWMMTPRDOContainer
Define the version of the NSW MM RDO container.
NSWMMTPRDO_v1 NSWMMTPRDO
Define the version of the NSW MM RDO class.
Definition NSWMMTPRDO.h:13