ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonCalib
MuonCalibStandAlone
MuonCalibStandAloneBase
src
RegionElement.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
MuonCalibStandAloneBase/RegionElement.h
"
6
7
#include <cstdlib>
8
9
#include "
AthenaKernel/getMessageSvc.h
"
10
#include "GaudiKernel/MsgStream.h"
11
#include "
MuonCalibIdentifier/MuonFixedId.h
"
12
#include "sstream"
13
14
namespace
MuonCalib
{
15
16
bool
RegionElement::Initialize
(
const
std::string ®ion) {
17
m_region
= region;
18
std::string inner_region(region, 1, region.size() - 2);
19
// clear all - empty means all chambers
20
m_stations
.clear();
21
m_eta_start
.clear();
22
m_eta_end
.clear();
23
m_phi_start
.clear();
24
m_phi_end
.clear();
25
m_ml
= 0;
26
// loop on the four elements of a region element
27
std::istringstream region_stream(inner_region);
28
std::string item;
29
for
(
int
i = 0; i < 4; i++) {
30
getline(region_stream, item,
','
);
31
if
(region_stream.fail())
break
;
32
// split in subelements
33
std::string item2;
34
std::istringstream item_stream(item);
35
while
(!item_stream.eof()) {
36
item_stream >> item2;
37
if
(item2.size() == 0)
continue
;
38
switch
(i) {
39
case
0:
40
if
(!
process_station_name
(item2))
return
false
;
41
break
;
42
case
1:
43
if
(!
process_int_range
(item2,
m_phi_start
,
m_phi_end
))
return
false
;
44
break
;
45
case
2:
46
if
(!
process_int_range
(item2,
m_eta_start
,
m_eta_end
))
return
false
;
47
break
;
48
case
3: {
49
m_ml
= atoi(item2.c_str());
50
if
(
m_ml < 0 || m_ml >
2)
return
false
;
51
break
;
52
}
53
}
54
}
55
}
56
return
true
;
57
}
58
59
void
RegionElement::Print
(std::ostream &os)
const
{ os <<
m_region
; }
60
61
bool
RegionElement::Result
(
const
MuonFixedId
&
id
)
const
{
62
// check for station
63
if
(
m_stations
.size() != 0 &&
m_stations
.find(
id
.stationName()) ==
m_stations
.end())
return
false
;
64
// check for eta
65
if
(
m_eta_start
.size() > 0) {
66
bool
match
(
false
);
67
for
(
unsigned
int
i = 0; i <
m_eta_start
.size(); i++) {
68
if
(
m_eta_start
[i] <=
id
.
eta
() &&
id
.
eta
() <=
m_eta_end
[i]) {
69
match
=
true
;
70
break
;
71
}
72
}
73
if
(!
match
)
return
false
;
74
}
75
// check for phi
76
if
(
m_phi_start
.size() > 0) {
77
bool
match
(
false
);
78
for
(
unsigned
int
i = 0; i <
m_phi_start
.size(); i++) {
79
if
(
m_phi_start
[i] <=
id
.
phi
() &&
id
.
phi
() <=
m_phi_end
[i]) {
80
match
=
true
;
81
break
;
82
}
83
}
84
if
(!
match
)
return
false
;
85
}
86
// check for multilayer
87
if
(
m_ml
> 0) {
88
if
(
id
.mdtMultilayer() !=
m_ml
)
return
false
;
89
}
90
return
true
;
91
}
92
93
bool
RegionElement::process_station_name
(std::string &substr) {
94
if
(substr.size() > 3) {
95
MsgStream log(
Athena::getMessageSvc
(),
"RegionElement"
);
96
log << MSG::WARNING <<
"Syntax Error '"
<< substr <<
"'"
<<
endmsg
;
97
return
false
;
98
}
99
std::string name_template(
"???"
);
100
for
(
unsigned
int
i = 0; i < substr.size(); i++) { name_template[i] = substr[i]; }
101
// get matching stations
102
MuonFixedId
id;
103
std::string station_name;
104
for
(
int
i = 1;
true
; i++) {
105
station_name =
id
.stationNumberToFixedStationString(i);
106
if
(station_name ==
"XXX"
)
break
;
107
bool
match
(
true
);
108
for
(
int
j = 0; j < 3; j++) {
109
if
(name_template[j] ==
'?'
)
continue
;
110
if
(name_template[j] == station_name[j])
continue
;
111
match
=
false
;
112
}
113
if
(
match
) {
m_stations
.insert(i); }
114
}
115
return
true
;
116
}
117
118
bool
RegionElement::process_int_range
(std::string &substr, std::vector<int> &target_start, std::vector<int> &target_end) {
119
// check for - in substring
120
std::string begin_range[2];
121
int
n_substrings(0);
122
bool
begin_number(
true
);
123
for
(
unsigned
int
i = 0; i < substr.size(); i++) {
124
switch
(substr[i]) {
125
case
'0'
:
126
case
'1'
:
127
case
'2'
:
128
case
'3'
:
129
case
'4'
:
130
case
'5'
:
131
case
'6'
:
132
case
'7'
:
133
case
'8'
:
134
case
'9'
:
135
begin_range[n_substrings] += substr[i];
136
begin_number =
false
;
137
break
;
138
case
'-'
:
139
if
(begin_number) {
140
begin_range[n_substrings] += substr[i];
141
begin_number =
false
;
142
break
;
143
}
144
if
(n_substrings > 0) {
145
MsgStream log(
Athena::getMessageSvc
(),
"RegionElement"
);
146
log << MSG::WARNING <<
"Surplus '-' in "
<< substr <<
endmsg
;
147
return
false
;
148
}
149
begin_number =
true
;
150
n_substrings = 1;
151
break
;
152
default
:
153
MsgStream log(
Athena::getMessageSvc
(),
"RegionElement"
);
154
log << MSG::WARNING <<
"Syntax error in "
<< substr <<
endmsg
;
155
return
false
;
156
}
157
}
158
if
(begin_range[0].
size
() == 0) {
return
true
; }
159
target_start.push_back(atoi(begin_range[0].c_str()));
160
if
(n_substrings == 0)
161
target_end.push_back(atoi(begin_range[0].c_str()));
162
else
163
target_end.push_back(atoi(begin_range[1].c_str()));
164
return
true
;
165
}
166
}
// namespace MuonCalib
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
MuonFixedId.h
RegionElement.h
size
size_t size() const
Number of registered mappings.
MuonCalib::MuonFixedId
Implements fixed identifiers not dependent upon Athena Identifier for internal use in the calibration...
Definition
MuonFixedId.h:50
MuonCalib::RegionElement::m_eta_end
std::vector< int > m_eta_end
Definition
RegionElement.h:37
MuonCalib::RegionElement::m_ml
int m_ml
Definition
RegionElement.h:40
MuonCalib::RegionElement::m_phi_end
std::vector< int > m_phi_end
Definition
RegionElement.h:39
MuonCalib::RegionElement::Result
bool Result(const MuonFixedId ®ion) const
return true if in region
Definition
RegionElement.cxx:61
MuonCalib::RegionElement::process_station_name
bool process_station_name(std::string &name)
process a astation name string
Definition
RegionElement.cxx:93
MuonCalib::RegionElement::m_stations
std::set< int > m_stations
regions
Definition
RegionElement.h:35
MuonCalib::RegionElement::Print
void Print(std::ostream &os) const
print region
Definition
RegionElement.cxx:59
MuonCalib::RegionElement::m_phi_start
std::vector< int > m_phi_start
Definition
RegionElement.h:38
MuonCalib::RegionElement::m_region
std::string m_region
Definition
RegionElement.h:33
MuonCalib::RegionElement::Initialize
bool Initialize(const std::string ®ion)
Initialize functions.
Definition
RegionElement.cxx:16
MuonCalib::RegionElement::process_int_range
bool process_int_range(std::string &range, std::vector< int > &target_start, std::vector< int > &target_end)
process a numerical id
Definition
RegionElement.cxx:118
MuonCalib::RegionElement::m_eta_start
std::vector< int > m_eta_start
Definition
RegionElement.h:36
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
match
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition
hcg.cxx:359
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition
getMessageSvc.cxx:20
MuonCalib
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
Definition
CscCalcPed.cxx:21
Generated on
for ATLAS Offline Software by
1.17.0