ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonDetDescr
MuonGeoModel
src
StationSelector.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
MuonGeoModel/StationSelector.h
"
6
7
#include "
AthenaKernel/getMessageSvc.h
"
8
#include "GaudiKernel/MsgStream.h"
9
#include "
MuonGeoModel/MYSQL.h
"
10
#include "
MuonGeoModel/Station.h
"
11
12
#include <fstream>
13
#include <sstream>
14
#include <utility>
15
16
namespace
MuonGM
{
17
18
std::atomic<int>
StationSelector::m_selectType
= 0;
19
20
StationSelector::StationSelector
(
const
MYSQL
& mysql,
const
std::string& filename) {
21
std::ifstream from;
22
from.open(filename.c_str());
23
char
buffer[200];
24
while
(from.getline(buffer, 200)) {
25
std::istringstream line(buffer);
26
std::string key;
27
line >> key;
28
m_selector
.push_back(key);
29
}
30
31
for
(
const
auto
& [name, station] : mysql.
stationMap
()) {
32
if
(
select
(name))
33
m_theMap
[name] = station.get();
34
}
35
}
36
37
StationSelector::StationSelector
(
const
MYSQL
& mysql, std::vector<std::string> s) :
m_selector
(
std
::move(s)) {
38
StationIterator
it;
39
for
(
const
auto
& [name, station] : mysql.
stationMap
()) {
40
if (select(name))
41
m_theMap[name] = station.get();
42
}
43
}
44
45
StationSelector::StationIterator
StationSelector::begin
() {
return
m_theMap
.begin(); }
46
StationSelector::StationIterator
StationSelector::end
() {
return
m_theMap
.end(); }
47
48
bool
StationSelector::select
(
const
std::string& name ) {
49
MsgStream log(
Athena::getMessageSvc
(),
"MuonGeoModel"
);
50
int
selFlag =
m_selectType
;
51
if
(
m_selector
[0] ==
"*"
) {
52
selFlag = 1;
// override JO choice for general configuration
53
}
54
55
if
(selFlag == 1) {
56
for
(
unsigned
int
k = 0; k <
m_selector
.size(); k++) {
57
std::string
sel
=
m_selector
[k];
58
59
if
(
sel
.size() <= name.size()) {
60
bool
myflag =
true
;
61
for
(
unsigned
int
i = 0; i <
sel
.size(); i++) {
62
if
(
sel
[i] ==
'*'
)
63
continue
;
64
if
(
sel
[i] != name[i]) {
65
myflag =
false
;
66
break
;
67
}
68
}
69
70
if
(myflag)
71
return
myflag;
72
}
73
}
74
return
false
;
75
}
else
if
(selFlag == 2) {
76
for
(
unsigned
int
k = 0; k <
m_selector
.size(); k++) {
77
std::string
sel
=
m_selector
[k];
78
79
if
(
sel
.size() != name.size())
80
continue
;
// require exact match
81
82
bool
myflag =
true
;
83
for
(
unsigned
int
i = 0; i <
sel
.size(); i++) {
84
if
(
sel
[i] ==
'*'
)
85
continue
;
86
if
(
sel
[i] != name[i]) {
87
myflag =
false
;
88
break
;
89
}
90
}
91
92
if
(myflag) {
93
log << MSG::INFO <<
" StationSelector: removing station "
<< name <<
endmsg
;
94
return
false
;
95
}
96
}
97
98
return
true
;
99
}
100
101
return
true
;
102
}
103
104
void
StationSelector::SetSelectionType
(
int
t) {
m_selectType
= t; }
105
106
}
// namespace MuonGM
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
MYSQL.h
sel
sel
Definition
SUSYToolsTester.cxx:92
StationSelector.h
Station.h
MuonGM::MYSQL
Definition
MYSQL.h:43
MuonGM::MYSQL::stationMap
const StationMap & stationMap() const
Definition
MYSQL.cxx:227
MuonGM::StationSelector::m_selectType
static std::atomic< int > m_selectType
Definition
StationSelector.h:31
MuonGM::StationSelector::end
StationIterator end()
Definition
StationSelector.cxx:46
MuonGM::StationSelector::m_selector
std::vector< std::string > m_selector
Definition
StationSelector.h:28
MuonGM::StationSelector::begin
StationIterator begin()
Definition
StationSelector.cxx:45
MuonGM::StationSelector::select
bool select(const std::string &name)
Definition
StationSelector.cxx:48
MuonGM::StationSelector::SetSelectionType
static void SetSelectionType(int t)
Definition
StationSelector.cxx:104
MuonGM::StationSelector::StationIterator
StationMap::const_iterator StationIterator
Definition
StationSelector.h:20
MuonGM::StationSelector::StationSelector
StationSelector(const MYSQL &mysql, const std::string &filename)
Definition
StationSelector.cxx:20
MuonGM::StationSelector::m_theMap
StationMap m_theMap
Definition
StationSelector.h:29
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition
getMessageSvc.cxx:20
MuonGM
Ensure that the Athena extensions are properly loaded.
Definition
GeoMuonHits.h:27
std
STL namespace.
Generated on
for ATLAS Offline Software by
1.17.0