ATLAS Offline Software
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
18 TgcRdo::TgcRdo(uint16_t id, IdentifierHash idHash) : DataVector<TgcRawData>(), m_id(id), m_idHash(idHash)
19 {
20  clear();
21 }
22 
23 // Full constructor
24 TgcRdo::TgcRdo(uint16_t subDetectorId,
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
37 void 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
48 {
49  return calculateOnlineId(rawData.subDetectorId(), rawData.rodId());
50 }
51 
52 // Returns offset, MAX_N_ROD
53 std::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
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 
82 template <class stream>
83 stream& 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 
108 std::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 
TgcRdo::identify
uint16_t identify() const
Definition: TgcRdo.h:107
TgcRdo::identifyRawData
static uint16_t identifyRawData(const TgcRawData &rawData)
Definition: TgcRdo.cxx:47
TgcRdo::m_subDetectorId
uint16_t m_subDetectorId
Definition: TgcRdo.h:246
operator<<
std::ostream & operator<<(std::ostream &sl, const TgcRdo &coll)
Overload of << operator for std::ostream for debug output.
Definition: TgcRdo.cxx:108
TgcRdo::calculateOnlineId
static uint16_t calculateOnlineId(uint16_t subDetectorId, uint16_t rodId)
Definition: TgcRdo.cxx:60
TgcRdo::m_id
uint16_t m_id
ID of this instance.
Definition: TgcRdo.h:240
TgcRdo::localStatus
const LocalStatus & localStatus() const
Definition: TgcRdo.h:190
TgcRdo::m_version
uint16_t m_version
Definition: TgcRdo.h:237
TgcRdo::m_triggerType
uint16_t m_triggerType
Definition: TgcRdo.h:250
TgcRdo::rodStatus
const RodStatus & rodStatus() const
Definition: TgcRdo.h:174
TgcRawData::subDetectorId
uint16_t subDetectorId() const
Definition: TgcRawData.h:264
TgcRdo::triggerType
uint16_t triggerType() const
Definition: TgcRdo.h:142
xAOD::int16_t
setScaleOne setStatusOne setSaturated int16_t
Definition: gFexGlobalRoI_v1.cxx:55
TgcRdo::l1Id
uint16_t l1Id() const
Definition: TgcRdo.h:150
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
TgcRdo::m_orbit
uint32_t m_orbit
Definition: TgcRdo.h:259
TgcRdo::clear
void clear()
Definition: TgcRdo.cxx:114
TgcRdo::LocalStatus
Definition: TgcRdo.h:77
TgcRawData::rodId
uint16_t rodId() const
Definition: TgcRawData.h:268
TgcRdo::orbit
uint32_t orbit() const
Definition: TgcRdo.h:206
TgcRdo::m_bcId
uint16_t m_bcId
Definition: TgcRdo.h:253
TgcRdo::m_rodId
uint16_t m_rodId
Definition: TgcRdo.h:247
TgcRdo::subDetectorId
uint16_t subDetectorId() const
Definition: TgcRdo.h:134
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
TgcRdo.h
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
TgcRdo::m_errors
Definition: TgcRdo.h:256
TgcRdo::bcId
uint16_t bcId() const
Definition: TgcRdo.h:146
TgcRdo::initOnlineId
static std::pair< int, int > initOnlineId()
Definition: TgcRdo.cxx:53
bcId
uint16_t bcId(uint32_t data)
Definition: TgcByteStreamData.h:326
TgcRdo::RodStatus
Definition: TgcRdo.h:45
dump
stream & dump(stream &sl, const TgcRdo &coll)
Definition: TgcRdo.cxx:83
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:239
TgcRdo::errors
const Errors & errors() const
Definition: TgcRdo.h:158
errorcheck.h
Helpers for checking error return status codes and reporting errors.
TgcRdo::m_localStatus
Definition: TgcRdo.h:258
TgcRdo::setOnlineId
void setOnlineId(uint16_t subDetectorId, uint16_t rodId)
Definition: TgcRdo.cxx:37
TgcRdo::m_l1Id
uint16_t m_l1Id
Definition: TgcRdo.h:254
TgcRdo::version
uint16_t version() const
Definition: TgcRdo.h:215
TgcRdo::TgcRdo
TgcRdo()
Default constructor.
Definition: TgcRdo.cxx:11
TgcRawData
An unit object of TGC ROD output.
Definition: TgcRawData.h:23
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
TgcRdo
Definition: TgcRdo.h:22
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
TgcRdo::rodId
uint16_t rodId() const
Definition: TgcRdo.h:138
TgcRdo::m_rodStatus
Definition: TgcRdo.h:257
TgcRdo::Errors
Definition: TgcRdo.h:36