ATLAS Offline Software
Loading...
Searching...
No Matches
MuonGM::StationSelector Class Reference

#include <StationSelector.h>

Collaboration diagram for MuonGM::StationSelector:

Public Types

using StationMap = std::map<std::string, Station*, std::less<std::string>>
using StationIterator = StationMap::const_iterator

Public Member Functions

 StationSelector (const MYSQL &mysql, const std::string &filename)
 StationSelector (const MYSQL &mysql, std::vector< std::string > s)
StationIterator begin ()
StationIterator end ()

Static Public Member Functions

static void SetSelectionType (int t)

Private Member Functions

bool select (const std::string &name)

Private Attributes

std::vector< std::string > m_selector {}
StationMap m_theMap {}

Static Private Attributes

static std::atomic< int > m_selectType = 0

Detailed Description

Definition at line 17 of file StationSelector.h.

Member Typedef Documentation

◆ StationIterator

using MuonGM::StationSelector::StationIterator = StationMap::const_iterator

Definition at line 20 of file StationSelector.h.

◆ StationMap

using MuonGM::StationSelector::StationMap = std::map<std::string, Station*, std::less<std::string>>

Definition at line 19 of file StationSelector.h.

Constructor & Destructor Documentation

◆ StationSelector() [1/2]

MuonGM::StationSelector::StationSelector ( const MYSQL & mysql,
const std::string & filename )

Definition at line 20 of file StationSelector.cxx.

20 {
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 }
const StationMap & stationMap() const
Definition MYSQL.cxx:227
std::vector< std::string > m_selector
bool select(const std::string &name)

◆ StationSelector() [2/2]

MuonGM::StationSelector::StationSelector ( const MYSQL & mysql,
std::vector< std::string > s )

Definition at line 37 of file StationSelector.cxx.

37 : m_selector(std::move(s)) {
39 for (const auto& [name, station] : mysql.stationMap()) {
40 if (select(name))
41 m_theMap[name] = station.get();
42 }
43 }
StationMap::const_iterator StationIterator

Member Function Documentation

◆ begin()

StationSelector::StationIterator MuonGM::StationSelector::begin ( )

Definition at line 45 of file StationSelector.cxx.

45{ return m_theMap.begin(); }

◆ end()

StationSelector::StationIterator MuonGM::StationSelector::end ( )

Definition at line 46 of file StationSelector.cxx.

46{ return m_theMap.end(); }

◆ select()

bool MuonGM::StationSelector::select ( const std::string & name)
private

Definition at line 48 of file StationSelector.cxx.

48 {
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 }
#define endmsg
static std::atomic< int > m_selectType
IMessageSvc * getMessageSvc(bool quiet=false)

◆ SetSelectionType()

void MuonGM::StationSelector::SetSelectionType ( int t)
static

Definition at line 104 of file StationSelector.cxx.

Member Data Documentation

◆ m_selector

std::vector<std::string> MuonGM::StationSelector::m_selector {}
private

Definition at line 28 of file StationSelector.h.

28{};

◆ m_selectType

std::atomic< int > MuonGM::StationSelector::m_selectType = 0
staticprivate

Definition at line 31 of file StationSelector.h.

◆ m_theMap

StationMap MuonGM::StationSelector::m_theMap {}
private

Definition at line 29 of file StationSelector.h.

29{};

The documentation for this class was generated from the following files: