ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonCablings
MuonTGC_Cabling
src
TGCDatabasePPToSL.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
MuonTGC_Cabling/TGCDatabasePPToSL.h
"
6
7
#include <fstream>
8
#include <sstream>
9
10
namespace
MuonTGC_Cabling
{
11
12
TGCDatabasePPToSL::TGCDatabasePPToSL
(
const
std::string& filename,
13
const
std::string& blockname)
14
:
TGCDatabase
(
TGCDatabase
::
PPToSL
, filename, blockname) {
15
// read out ascii file and fill database
16
TGCDatabasePPToSL::readDB
();
17
}
18
19
TGCDatabasePPToSL::TGCDatabasePPToSL
(
const
TGCDatabasePPToSL
& right)
20
:
TGCDatabase
(right) {}
21
22
void
TGCDatabasePPToSL::readDB
() {
23
std::ifstream
file
(
m_filename
.c_str());
24
std::string buf;
25
26
unsigned
int
space =
m_blockname
.find(
' '
);
27
std::string_view module = std::string_view(
m_blockname
).substr(0, space);
28
std::string_view region =
29
std::string_view(
m_blockname
).substr(space + 1, 1);
30
std::string_view
type
= std::string_view(
m_blockname
).substr(space + 2);
31
32
int
offset = -1;
33
if
(
type
==
"WT"
) {
34
offset = 1;
35
}
36
if
(
type
==
"WD"
) {
37
offset = 2;
38
}
39
if
(
type
==
"ST"
) {
40
offset = 3;
41
}
42
if
(
type
==
"SD"
) {
43
offset = 4;
44
}
45
if
(
type
==
"WI"
) {
46
offset = 5;
47
}
48
if
(
type
==
"SI"
) {
49
offset = 6;
50
}
51
if
(
type
==
"W"
) {
52
offset = 1;
53
}
54
if
(
type
==
"S"
) {
55
offset = 2;
56
}
57
58
while
(getline(
file
, buf)) {
59
if
(buf.compare(0, 1, region) == 0) {
60
break
;
61
}
62
}
63
64
while
(getline(
file
, buf)) {
65
if
(buf.compare(1, module.size(), module) == 0) {
66
break
;
67
}
68
}
69
70
while
(getline(
file
, buf)) {
71
if
(buf.compare(0, 2,
" "
) != 0) {
72
break
;
73
}
74
if
(buf.compare(2, 1,
"0"
) == 0) {
75
offset--;
76
}
77
if
(offset == 0) {
78
std::istringstream line(buf);
79
std::vector<int> entry;
80
for
(
int
i = 0; i < 3; i++) {
81
int
temp = -1;
82
line >> temp;
83
entry.push_back(temp);
84
}
85
m_database
.emplace_back(std::move(entry));
86
}
87
}
88
89
file
.close();
90
}
91
92
TGCDatabasePPToSL::~TGCDatabasePPToSL
() {}
93
94
bool
TGCDatabasePPToSL::update
(
const
std::vector<int>& input) {
95
int
ip =
find
(input);
96
if
(ip < 0) {
97
return
false
;
98
}
99
100
const
unsigned
int
input_size = input.size();
101
102
const
unsigned
int
database_size =
m_database
[ip].size();
103
for
(
unsigned
int
i = 1; i < database_size; i++) {
104
if
(i < input_size) {
105
m_database
[ip].at(i) = input.at(i);
106
}
else
{
107
m_database
[ip].at(i) = -1;
108
}
109
}
110
111
return
true
;
112
}
113
114
int
TGCDatabasePPToSL::find
(
const
std::vector<int>& channel)
const
{
115
int
index
= -1;
116
const
unsigned
int
size
=
m_database
.size();
117
for
(
unsigned
int
i = 0; i <
size
; i++) {
118
if
(
m_database
[i].at(0) == channel.at(0)) {
119
index
= i;
120
break
;
121
}
122
}
123
return
index
;
124
}
125
126
}
// namespace MuonTGC_Cabling
size
size_t size() const
Number of registered mappings.
TGCDatabasePPToSL.h
MuonTGC_Cabling::TGCDatabasePPToSL::TGCDatabasePPToSL
TGCDatabasePPToSL()
Definition
TGCDatabasePPToSL.h:28
MuonTGC_Cabling::TGCDatabasePPToSL::TGCDatabasePPToSL
TGCDatabasePPToSL(const std::string &filename, const std::string &blockname)
Definition
TGCDatabasePPToSL.cxx:12
MuonTGC_Cabling::TGCDatabasePPToSL::update
virtual bool update(const std::vector< int > &)
Definition
TGCDatabasePPToSL.cxx:94
MuonTGC_Cabling::TGCDatabasePPToSL::find
virtual int find(const std::vector< int > &) const
Definition
TGCDatabasePPToSL.cxx:114
MuonTGC_Cabling::TGCDatabasePPToSL::readDB
virtual void readDB()
Definition
TGCDatabasePPToSL.cxx:22
MuonTGC_Cabling::TGCDatabasePPToSL::~TGCDatabasePPToSL
virtual ~TGCDatabasePPToSL()
Definition
TGCDatabasePPToSL.cxx:92
MuonTGC_Cabling::TGCDatabase::m_filename
std::string m_filename
Definition
TGCDatabase.h:54
MuonTGC_Cabling::TGCDatabase::m_blockname
std::string m_blockname
Definition
TGCDatabase.h:55
MuonTGC_Cabling::TGCDatabase::TGCDatabase
TGCDatabase(DatabaseType type=NoDatabaseType)
Definition
TGCDatabase.cxx:9
MuonTGC_Cabling::TGCDatabase::PPToSL
@ PPToSL
Definition
TGCDatabase.h:19
MuonTGC_Cabling::TGCDatabase::m_database
std::vector< std::vector< int > > m_database
Definition
TGCDatabase.h:56
MuonTGC_Cabling
Definition
TGCCable.h:12
index
Definition
index.py:1
type
file
TFile * file
Definition
tile_monitor.h:29
Generated on
for ATLAS Offline Software by
1.17.0