ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_OnlineId.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 * SCT_OnlineId.cxx
6 * SCT_Cabling
7 *
8 * Created by sroe on 21/10/2008.
9 *
10 */
11
13#include <iostream>
14namespace{
16 template <unsigned int nibbleNumber, class T>
17 inline
18 unsigned int nibble(const T number){
19 return (number>>(4*nibbleNumber)) & 0xf;
20 }
21}
22
26
27//
28SCT_OnlineId::SCT_OnlineId(const std::uint32_t onlineId):m_onlineId(onlineId){
29 //nop
30}
31
32SCT_OnlineId::SCT_OnlineId(const std::uint32_t rodId, const std::uint32_t fibre){
33 //cursory checks on range only
34 if (not (fibreInRange(fibre) and rodIdInRange(rodId) )){
35 std::cout<<"SCT_OnlineId: Trying to create an invalid online Id from RodId 0x"<<std::hex<<rodId<<std::dec<<" and fibre: "<<fibre<<std::endl;
37 } else {
38 m_onlineId = rodId + (fibre<<24);
39 }
40}
41
44 m_onlineId+=(1<<24);
46 return *this;
47}
48
51 SCT_OnlineId temp=*this;
52 m_onlineId+=(1<<24);
54 return temp;
55}
56
57//
58std::uint32_t
60 return m_onlineId & 0xFFFFFF;
61}
62
63//
64std::uint32_t
66 return m_onlineId>>24;
67}
68
69//
70SCT_OnlineId::operator unsigned int() const{
71 return m_onlineId;
72}
73
74//
75bool
76SCT_OnlineId::is_valid(const bool usingDbCabling) const{
77 return ( fibreInRange(fibre()) and rodIdInRange(rod(), usingDbCabling) );
78}
79
80//
81bool
83 return ( fibreInRange(fibre()) and rodIdInRange(rod()) );
84}
85
86
87//
88bool SCT_OnlineId::fibreInRange(std::uint32_t f) {
89 return (f<NUM_FIBRES);
90}
91
92//
93bool SCT_OnlineId::rodIdInRange(std::uint32_t r){
94 const std::uint32_t lowestRodId(0x210000);
95 const std::uint32_t highestRodId=0x24010F;
96 return ((r >=lowestRodId) and (r<=highestRodId)) ;
97}
98
99//
100bool SCT_OnlineId::rodIdInRange(std::uint32_t r, const bool usingDbCabling) const{
101 const std::uint32_t lowestRodId(0x210000);
102 const std::uint32_t highestRodId=0x24010F;
103 //choose one unique Rod as a signature to check for either database or montecarlo.
104 //0x220010 is unique to the text file, 0x220105 is unique to the database
105 //as an alternative, more thorough (but slower) check, the SCT_OnlineIdType function should be used
106 const std::uint32_t uniqueToOppositeCase = usingDbCabling?0x220010:0x220105;
107 return ((r >=lowestRodId) and (r<=highestRodId) and (r!=uniqueToOppositeCase)) ;
108}
109
110//
111unsigned int
113 //number is of form 0xII2X0Y0Z, X=[1-4], Y=[0-2], Z=[0xO-0xf], II is 0 to 95
114 //so Z is nibble 0; Y is nibble 2; X is nibble 4
115 // BUT long ago...
116 //MC cabling was stored in a file with robs in different format, so the online Id will be in form
117 //0xII2X00YZ, X=[1-4], Y=[0-2], Z=[0xO-0xf], II is 0 to 95
118 unsigned int Z(nibble<0>(m_onlineId));
119 unsigned int Y(nibble<2>(m_onlineId));
127 const unsigned int X(nibble<4>(m_onlineId) - 1);
128 unsigned int result= ((X + (Y * 4)) * 16 + Z) * 96 + (fibre()); //should return an index in range 0-19872
129 if (result > MAX_INDEX){
130 std::cout<<"SCT_OnlineId: Invalid index for online Id "<<std::hex<<m_onlineId<<std::dec<<" X, Y, Z: "<<X<<", "<<Y<<", "<<Z<<std::endl;
132 }
133 return result;
134}
135
136
137
Header file for a utility class to hold the online id.
SCT_OnlineId is a class to hold an online id number and provide check on validity,...
std::uint32_t fibre() const
Return the fibre.
bool is_valid() const
Check whether the onlineId is valid, without knowing the data source; this is a rough check.
std::uint32_t m_onlineId
The underlying number.
std::uint32_t rod() const
Return the rod/rob Id.
SCT_OnlineId & operator++()
Implement pre-increment and post-increment for iterating over fibres in a rod.
static bool rodIdInRange(std::uint32_t r)
Is the rod in range?
static bool fibreInRange(std::uint32_t f)
Simple range check.
unsigned int index() const
Return an index in the range 0-9215, calculated from parts of the onlineId.
SCT_OnlineId()
Default constructor produces an invalid serial number.
int r
Definition globals.cxx:22
std::string number(const double &d, const std::string &s)
Definition utils.cxx:186