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 
9 // Default constructor
11 {
12  m_id = 9999;
13  clear();
14 }
15 
16 // Creates an empty container ready for writing
17 TgcRdo::TgcRdo(uint16_t id, IdentifierHash idHash) : DataVector<TgcRawData>(), m_id(id), m_idHash(idHash)
18 {
19  clear();
20 }
21 
22 // Full constructor
23 TgcRdo::TgcRdo(uint16_t subDetectorId,
24  uint16_t rodId,
25  uint16_t bcId,
26  uint16_t l1Id) : DataVector<TgcRawData>()
27 {
28  clear();
29  m_bcId = bcId;
30  m_l1Id = l1Id;
31 
33 }
34 
35 // set Online ID
36 void TgcRdo::setOnlineId(uint16_t subDetectorId, uint16_t rodId)
37 {
39  m_rodId = rodId;
40 
41  // set my ID
43 }
44 
45 // class method for RawData identification
47 {
48  return calculateOnlineId(rawData.subDetectorId(), rawData.rodId());
49 }
50 
51 // Returns offset, MAX_N_ROD
52 std::pair<int, int> TgcRdo::initOnlineId() {
53  static constexpr int offset = -1;
54  static constexpr int MAX_N_ROD = 12;
55  return std::make_pair (offset, MAX_N_ROD);
56 }
57 
58 // online ID calculator
60 {
61  int offset = -1;
62  int MAX_N_ROD = 12;
63  if ( rodId < 13 ){
64  static const std::pair<int, int> offset_max = initOnlineId();
65  offset = offset_max.first;
66  MAX_N_ROD = offset_max.second;
67  }else{
68  offset = 7; // 24-0x11
69  MAX_N_ROD = 3;
70  }
71  if (MAX_N_ROD < 0) {
72  return 9999;
73  }
74 
75  // A-side or C-side ?
76  uint16_t is = (subDetectorId == 0x67) ? 0 : 1;
77 
78  return is * MAX_N_ROD + rodId + offset; // 0-23 : ROD, 24-29 : SROD
79 }
80 
81 template <class stream>
82 stream& dump(stream& sl, const TgcRdo& coll)
83 {
84  sl << "TgcRdo: "
85  << " version=" << coll.version()
86  << ", id=" << std::hex << coll.identify() << std::dec
87  << ", rodId=" << coll.rodId()
88  << ", subDetectorId=" << std::hex << coll.subDetectorId() << std::dec
89  << ", triggerType=" << (int16_t)coll.triggerType()
90  << ", bcId=" << coll.bcId()
91  << ", l1Id=" << coll.l1Id()
92  << ", errors=" << std::hex << std::bit_cast<unsigned>(coll.errors())
93  << ", rodStatus=" << std::bit_cast<unsigned>(coll.rodStatus())
94  << ", localStatus=" << std::bit_cast<unsigned>(coll.localStatus()) << std::dec
95  << ", orbit=" << coll.orbit()
96  << std::endl << "TgcRawData: [" << std::endl;
97  int iRaw = 0;
98  for (const TgcRawData* rd : coll)
99  {
100  sl << ++iRaw
101  << ": " << *rd << std::endl;
102  }
103  sl << "]";
104  return sl;
105 }
106 
107 std::ostream& operator<<(std::ostream& sl, const TgcRdo& coll)
108 {
109  dump(sl, coll) << std::endl;
110  return sl;
111 }
112 
114 {
115  m_version = 300;
117  memset(&m_errors, 0, sizeof(Errors));
118  memset(&m_rodStatus, 0, sizeof(RodStatus));
119  memset(&m_localStatus, 0, sizeof(LocalStatus));
120  m_orbit = 0;
121 }
122 
TgcRdo::identify
uint16_t identify() const
Definition: TgcRdo.h:107
TgcRdo::identifyRawData
static uint16_t identifyRawData(const TgcRawData &rawData)
Definition: TgcRdo.cxx:46
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:107
TgcRdo::calculateOnlineId
static uint16_t calculateOnlineId(uint16_t subDetectorId, uint16_t rodId)
Definition: TgcRdo.cxx:59
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:113
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:52
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:82
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:36
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:10
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