ATLAS Offline Software
Loading...
Searching...
No Matches
TgcRdo.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#include "MuonRDO/TgcRdo.h"
7#include <bit>
8#include <cstring> // memset
9
10// Default constructor
12{
13 m_id = 9999;
14 clear();
15}
16
17// Creates an empty container ready for writing
18TgcRdo::TgcRdo(uint16_t id, IdentifierHash idHash) : DataVector<TgcRawData>(), m_id(id), m_idHash(idHash)
19{
20 clear();
21}
22
23// Full constructor
25 uint16_t rodId,
26 uint16_t bcId,
27 uint16_t l1Id) : DataVector<TgcRawData>()
28{
29 clear();
30 m_bcId = bcId;
31 m_l1Id = l1Id;
32
34}
35
36// set Online ID
37void TgcRdo::setOnlineId(uint16_t subDetectorId, uint16_t rodId)
38{
40 m_rodId = rodId;
41
42 // set my ID
44}
45
46// class method for RawData identification
47uint16_t TgcRdo::identifyRawData(const TgcRawData &rawData)
48{
49 return calculateOnlineId(rawData.subDetectorId(), rawData.rodId());
50}
51
52// Returns offset, MAX_N_ROD
53std::pair<int, int> TgcRdo::initOnlineId() {
54 static constexpr int offset = -1;
55 static constexpr int MAX_N_ROD = 12;
56 return std::make_pair (offset, MAX_N_ROD);
57}
58
59// online ID calculator
60uint16_t TgcRdo::calculateOnlineId (uint16_t subDetectorId, uint16_t rodId)
61{
62 int offset = -1;
63 int MAX_N_ROD = 12;
64 if ( rodId < 13 ){
65 static const std::pair<int, int> offset_max = initOnlineId();
66 offset = offset_max.first;
67 MAX_N_ROD = offset_max.second;
68 }else{
69 offset = 7; // 24-0x11
70 MAX_N_ROD = 3;
71 }
72 if (MAX_N_ROD < 0) {
73 return 9999;
74 }
75
76 // A-side or C-side ?
77 uint16_t is = (subDetectorId == 0x67) ? 0 : 1;
78
79 return is * MAX_N_ROD + rodId + offset; // 0-23 : ROD, 24-29 : SROD
80}
81
82template <class stream>
83stream& dump(stream& sl, const TgcRdo& coll)
84{
85 sl << "TgcRdo: "
86 << " version=" << coll.version()
87 << ", id=" << std::hex << coll.identify() << std::dec
88 << ", rodId=" << coll.rodId()
89 << ", subDetectorId=" << std::hex << coll.subDetectorId() << std::dec
90 << ", triggerType=" << (int16_t)coll.triggerType()
91 << ", bcId=" << coll.bcId()
92 << ", l1Id=" << coll.l1Id()
93 << ", errors=" << std::hex << std::bit_cast<unsigned>(coll.errors())
94 << ", rodStatus=" << std::bit_cast<unsigned>(coll.rodStatus())
95 << ", localStatus=" << std::bit_cast<unsigned>(coll.localStatus()) << std::dec
96 << ", orbit=" << coll.orbit()
97 << std::endl << "TgcRawData: [" << std::endl;
98 int iRaw = 0;
99 for (const TgcRawData* rd : coll)
100 {
101 sl << ++iRaw
102 << ": " << *rd << std::endl;
103 }
104 sl << "]";
105 return sl;
106}
107
108std::ostream& operator<<(std::ostream& sl, const TgcRdo& coll)
109{
110 dump(sl, coll) << std::endl;
111 return sl;
112}
113
115{
116 m_version = 300;
118 memset(&m_errors, 0, sizeof(Errors));
119 memset(&m_rodStatus, 0, sizeof(RodStatus));
120 memset(&m_localStatus, 0, sizeof(LocalStatus));
121 m_orbit = 0;
122}
123
Helpers for checking error return status codes and reporting errors.
std::ostream & operator<<(std::ostream &sl, const TgcRdo &coll)
Overload of << operator for std::ostream for debug output.
Definition TgcRdo.cxx:108
DataVector(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES)
This is a "hash" representation of an Identifier.
An unit object of TGC ROD output.
Definition TgcRawData.h:23
uint16_t subDetectorId() const
Definition TgcRawData.h:264
uint16_t rodId() const
Definition TgcRawData.h:268
uint16_t m_version
Definition TgcRdo.h:237
const RodStatus & rodStatus() const
Definition TgcRdo.h:174
uint16_t version() const
Definition TgcRdo.h:215
void clear()
Definition TgcRdo.cxx:114
uint16_t triggerType() const
Definition TgcRdo.h:142
uint16_t m_bcId
Definition TgcRdo.h:253
uint16_t rodId() const
Definition TgcRdo.h:138
uint16_t m_rodId
Definition TgcRdo.h:247
uint16_t l1Id() const
Definition TgcRdo.h:150
uint16_t m_l1Id
Definition TgcRdo.h:254
uint16_t m_id
ID of this instance.
Definition TgcRdo.h:240
static uint16_t identifyRawData(const TgcRawData &rawData)
Definition TgcRdo.cxx:47
uint32_t m_orbit
Definition TgcRdo.h:259
IdentifierHash m_idHash
OFFLINE hash of this collection.
Definition TgcRdo.h:243
void setOnlineId(uint16_t subDetectorId, uint16_t rodId)
Definition TgcRdo.cxx:37
uint16_t m_subDetectorId
Definition TgcRdo.h:246
static std::pair< int, int > initOnlineId()
Definition TgcRdo.cxx:53
uint32_t orbit() const
Definition TgcRdo.h:206
uint16_t subDetectorId() const
Definition TgcRdo.h:134
const Errors & errors() const
Definition TgcRdo.h:158
static uint16_t calculateOnlineId(uint16_t subDetectorId, uint16_t rodId)
Definition TgcRdo.cxx:60
uint16_t m_triggerType
Definition TgcRdo.h:250
const LocalStatus & localStatus() const
Definition TgcRdo.h:190
uint16_t identify() const
Definition TgcRdo.h:107
uint16_t bcId() const
Definition TgcRdo.h:146
TgcRdo()
Default constructor.
Definition TgcRdo.cxx:11
-event-from-file