ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetDetDescr
SCT_Cabling
src
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
12
#include "
SCT_Cabling/SCT_OnlineId.h
"
13
#include <iostream>
14
namespace
{
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
23
SCT_OnlineId::SCT_OnlineId
():
m_onlineId
(
SCT_OnlineId
::
INVALID_ONLINE_ID
){
24
//nop
25
}
26
27
//
28
SCT_OnlineId::SCT_OnlineId
(
const
std::uint32_t onlineId):
m_onlineId
(onlineId){
29
//nop
30
}
31
32
SCT_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;
36
m_onlineId
=
INVALID_ONLINE_ID
;
37
}
else
{
38
m_onlineId
= rodId + (
fibre
<<24);
39
}
40
}
41
42
SCT_OnlineId
&
43
SCT_OnlineId::operator++
(){
44
m_onlineId
+=(1<<24);
45
if
(not
fibreInRange
(
fibre
()))
m_onlineId
=
INVALID_ONLINE_ID
;
46
return
*
this
;
47
}
48
49
SCT_OnlineId
50
SCT_OnlineId::operator++
(
int
){
51
SCT_OnlineId
temp=*
this
;
52
m_onlineId
+=(1<<24);
53
if
(not
fibreInRange
(
fibre
()))
m_onlineId
=
INVALID_ONLINE_ID
;
54
return
temp;
55
}
56
57
//
58
std::uint32_t
59
SCT_OnlineId::rod
()
const
{
60
return
m_onlineId
& 0xFFFFFF;
61
}
62
63
//
64
std::uint32_t
65
SCT_OnlineId::fibre
()
const
{
66
return
m_onlineId
>>24;
67
}
68
69
//
70
SCT_OnlineId::operator
unsigned
int()
const
{
71
return
m_onlineId
;
72
}
73
74
//
75
bool
76
SCT_OnlineId::is_valid
(
const
bool
usingDbCabling)
const
{
77
return
(
fibreInRange
(
fibre
()) and
rodIdInRange
(
rod
(), usingDbCabling) );
78
}
79
80
//
81
bool
82
SCT_OnlineId::is_valid
()
const
{
83
return
(
fibreInRange
(
fibre
()) and
rodIdInRange
(
rod
()) );
84
}
85
86
87
//
88
bool
SCT_OnlineId::fibreInRange
(std::uint32_t f) {
89
return
(f<
NUM_FIBRES
);
90
}
91
92
//
93
bool
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
//
100
bool
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
//
111
unsigned
int
112
SCT_OnlineId::index
()
const
{
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;
131
result=
INVALID_INDEX
;
132
}
133
return
result;
134
}
135
136
137
SCT_OnlineId.h
Header file for a utility class to hold the online id.
SCT_OnlineId
SCT_OnlineId is a class to hold an online id number and provide check on validity,...
Definition
SCT_OnlineId.h:22
SCT_OnlineId::fibre
std::uint32_t fibre() const
Return the fibre.
Definition
SCT_OnlineId.cxx:65
SCT_OnlineId::NUM_FIBRES
@ NUM_FIBRES
Definition
SCT_OnlineId.h:57
SCT_OnlineId::INVALID_INDEX
@ INVALID_INDEX
Definition
SCT_OnlineId.h:57
SCT_OnlineId::MAX_INDEX
@ MAX_INDEX
Definition
SCT_OnlineId.h:57
SCT_OnlineId::INVALID_ONLINE_ID
@ INVALID_ONLINE_ID
Definition
SCT_OnlineId.h:57
SCT_OnlineId::is_valid
bool is_valid() const
Check whether the onlineId is valid, without knowing the data source; this is a rough check.
Definition
SCT_OnlineId.cxx:82
SCT_OnlineId::m_onlineId
std::uint32_t m_onlineId
The underlying number.
Definition
SCT_OnlineId.h:66
SCT_OnlineId::rod
std::uint32_t rod() const
Return the rod/rob Id.
Definition
SCT_OnlineId.cxx:59
SCT_OnlineId::operator++
SCT_OnlineId & operator++()
Implement pre-increment and post-increment for iterating over fibres in a rod.
Definition
SCT_OnlineId.cxx:43
SCT_OnlineId::rodIdInRange
static bool rodIdInRange(std::uint32_t r)
Is the rod in range?
Definition
SCT_OnlineId.cxx:93
SCT_OnlineId::fibreInRange
static bool fibreInRange(std::uint32_t f)
Simple range check.
Definition
SCT_OnlineId.cxx:88
SCT_OnlineId::index
unsigned int index() const
Return an index in the range 0-9215, calculated from parts of the onlineId.
Definition
SCT_OnlineId.cxx:112
SCT_OnlineId::SCT_OnlineId
SCT_OnlineId()
Default constructor produces an invalid serial number.
Definition
SCT_OnlineId.cxx:23
r
int r
Definition
globals.cxx:22
number
std::string number(const double &d, const std::string &s)
Definition
utils.cxx:186
Generated on
for ATLAS Offline Software by
1.17.0