ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonCablings
MuonTGC_Cabling
src
TGCDatabaseInPP.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
#include "
MuonTGC_Cabling/TGCDatabaseInPP.h
"
6
7
#include <fstream>
8
#include <sstream>
9
10
namespace
MuonTGC_Cabling
{
11
12
TGCDatabaseInPP::TGCDatabaseInPP
(
const
std::string& filename,
13
const
std::string& blockname)
14
:
TGCDatabase
(
TGCDatabase
::
InPP
, filename, blockname),
m_NIndexDBIn
(0) {
15
for
(
int
iIndexIn = 0; iIndexIn <
NIndexIn
; iIndexIn++) {
16
m_maxIndexIn
[iIndexIn] = 0;
17
m_minIndexIn
[iIndexIn] = 9999;
18
}
19
20
// read out ascii file and fill database
21
TGCDatabaseInPP::readDB
();
22
}
23
24
TGCDatabaseInPP::TGCDatabaseInPP
(
const
TGCDatabaseInPP
& right)
25
:
TGCDatabase
(right) {
26
right.
getindexDBVectorIn
(
m_indexDBIn
);
27
right.
getNIndexDBIn
(
m_NIndexDBIn
);
28
right.
getmaxIndexIn
(
m_maxIndexIn
);
29
right.
getminIndexIn
(
m_minIndexIn
);
30
}
31
32
TGCDatabaseInPP::~TGCDatabaseInPP
() {}
33
34
bool
TGCDatabaseInPP::update
(
const
std::vector<int>& input) {
35
int
ip =
find
(input);
36
if
(ip < 0) {
37
return
false
;
38
}
39
40
const
unsigned
int
input_size = input.size();
41
42
const
unsigned
int
database_ip_size =
m_database
[ip].size();
43
for
(
unsigned
int
i = 3; i < database_ip_size; i++) {
44
if
(i < input.size()) {
45
m_database
[ip].at(i) = input.at(i);
46
}
else
{
47
m_database
[ip].at(i) = -1;
48
}
49
}
50
if
(database_ip_size < input_size) {
51
for
(
unsigned
int
i = database_ip_size; i < input_size; i++) {
52
m_database
[ip].push_back(input.at(i));
53
}
54
}
55
return
true
;
56
}
57
58
int
TGCDatabaseInPP::find
(
const
std::vector<int>& channel)
const
{
59
int
index
= -1;
60
const
unsigned
int
size
=
m_database
.size();
61
for
(
unsigned
int
i = 0; i <
size
; i++) {
62
if
(
m_database
[i].at(2) == channel.at(2) &&
63
m_database
[i].at(1) == channel.at(1) &&
64
m_database
[i].at(0) == channel.at(0)) {
65
index
= i;
66
break
;
67
}
68
}
69
return
index
;
70
}
71
72
int
TGCDatabaseInPP::getIndexDBIn
(
int
* indexIn)
const
{
73
if
(!indexIn) {
74
return
-1;
75
}
76
77
int
converted =
convertIndexDBIn
(indexIn);
78
if
(converted < 0 || converted >=
m_NIndexDBIn
) {
79
return
-1;
80
}
81
82
return
m_indexDBIn
.at(converted);
83
}
84
85
void
TGCDatabaseInPP::getindexDBVectorIn
(std::vector<int>& tmpindexDBIn)
const
{
86
tmpindexDBIn =
m_indexDBIn
;
87
}
88
89
void
TGCDatabaseInPP::getNIndexDBIn
(
int
& tmpNIndexDBIn)
const
{
90
tmpNIndexDBIn =
m_NIndexDBIn
;
91
}
92
93
void
TGCDatabaseInPP::getmaxIndexIn
(
int
* tmpmaxIndexIn)
const
{
94
for
(
int
iIndexIn = 0; iIndexIn <
NIndexIn
; iIndexIn++) {
95
tmpmaxIndexIn[iIndexIn] =
m_maxIndexIn
[iIndexIn];
96
}
97
}
98
99
void
TGCDatabaseInPP::getminIndexIn
(
int
* tmpminIndexIn)
const
{
100
for
(
int
iIndexIn = 0; iIndexIn <
NIndexIn
; iIndexIn++) {
101
tmpminIndexIn[iIndexIn] =
m_minIndexIn
[iIndexIn];
102
}
103
}
104
105
void
TGCDatabaseInPP::readDB
() {
106
std::ifstream
file
(
m_filename
.c_str());
107
std::string buf;
108
109
for
(
int
iIndexIn = 0; iIndexIn <
NIndexIn
; iIndexIn++) {
110
m_maxIndexIn
[iIndexIn] = 0;
111
m_minIndexIn
[iIndexIn] = 9999;
112
}
113
114
while
(getline(
file
, buf)) {
115
if
(buf.substr(0,
m_blockname
.size()) ==
m_blockname
) {
116
break
;
117
}
118
}
119
120
while
(getline(
file
, buf)) {
121
if
(buf.substr(0, 1) ==
"E"
|| buf.substr(0, 1) ==
"F"
) {
122
break
;
123
}
124
std::istringstream line(buf);
125
std::vector<int> entry;
126
for
(
int
i = 0; i < 6; i++) {
127
int
temp = -1;
128
line >> temp;
129
entry.push_back(temp);
130
131
if
(
IndexInMin
<= i && i <=
IndexInMax
) {
132
int
j = i -
IndexInMin
;
133
if
(
m_maxIndexIn
[j] < temp) {
134
m_maxIndexIn
[j] = temp;
135
}
136
if
(
m_minIndexIn
[j] > temp) {
137
m_minIndexIn
[j] = temp;
138
}
139
}
140
}
141
for
(
int
i = 0; i < 3; i++) {
142
int
temp = -1;
143
line >> temp;
144
if
(temp < 0) {
145
break
;
146
}
147
entry.push_back(temp);
148
}
149
m_database
.push_back(std::move(entry));
150
}
151
152
file
.close();
153
154
makeIndexDBIn
();
155
}
156
157
void
TGCDatabaseInPP::makeIndexDBIn
() {
158
m_NIndexDBIn
= 1;
159
for
(
int
iIndexIn = 0; iIndexIn <
NIndexIn
; iIndexIn++) {
160
m_NIndexDBIn
*= (
m_maxIndexIn
[iIndexIn] -
m_minIndexIn
[iIndexIn] + 1);
161
}
162
for
(
int
iIndexDBIn = 0; iIndexDBIn <
m_NIndexDBIn
; iIndexDBIn++) {
163
m_indexDBIn
.push_back(-1);
164
}
165
166
const
int
size
=
m_database
.size();
167
for
(
int
i = 0; i <
size
; i++) {
168
int
tmpValIndexIn[
NIndexIn
];
169
for
(
int
iIndexIn = 0; iIndexIn <
NIndexIn
; iIndexIn++) {
170
tmpValIndexIn[iIndexIn] =
171
m_database
.at(i).at(iIndexIn +
IndexInMin
);
172
}
173
m_indexDBIn
.at(
convertIndexDBIn
(tmpValIndexIn)) = i;
174
}
175
}
176
177
int
TGCDatabaseInPP::convertIndexDBIn
(
int
* indexIn)
const
{
178
int
converted = indexIn[0] -
m_minIndexIn
[0];
179
for
(
int
iIndexIn = 1; iIndexIn <
NIndexIn
; iIndexIn++) {
180
converted *= (
m_maxIndexIn
[iIndexIn] -
m_minIndexIn
[iIndexIn] + 1);
181
converted += indexIn[iIndexIn] -
m_minIndexIn
[iIndexIn];
182
}
183
return
converted;
184
}
185
186
}
// namespace MuonTGC_Cabling
size
size_t size() const
Number of registered mappings.
TGCDatabaseInPP.h
MuonTGC_Cabling::TGCDatabaseInPP::m_NIndexDBIn
int m_NIndexDBIn
Definition
TGCDatabaseInPP.h:65
MuonTGC_Cabling::TGCDatabaseInPP::readDB
virtual void readDB() override
Definition
TGCDatabaseInPP.cxx:105
MuonTGC_Cabling::TGCDatabaseInPP::getIndexDBIn
virtual int getIndexDBIn(int *indexIn) const override
Get IndexDBIn (position in the databse between 0 and database.size()-1) from indexIn which is NIndexI...
Definition
TGCDatabaseInPP.cxx:72
MuonTGC_Cabling::TGCDatabaseInPP::NIndexIn
@ NIndexIn
Definition
TGCDatabaseInPP.h:29
MuonTGC_Cabling::TGCDatabaseInPP::IndexInMax
@ IndexInMax
Definition
TGCDatabaseInPP.h:29
MuonTGC_Cabling::TGCDatabaseInPP::IndexInMin
@ IndexInMin
Definition
TGCDatabaseInPP.h:29
MuonTGC_Cabling::TGCDatabaseInPP::makeIndexDBIn
virtual void makeIndexDBIn()
Make the IndexDBIn table.
Definition
TGCDatabaseInPP.cxx:157
MuonTGC_Cabling::TGCDatabaseInPP::find
virtual int find(const std::vector< int > &) const override
Definition
TGCDatabaseInPP.cxx:58
MuonTGC_Cabling::TGCDatabaseInPP::TGCDatabaseInPP
TGCDatabaseInPP(const std::string &filename, const std::string &blockname)
Constructor.
Definition
TGCDatabaseInPP.cxx:12
MuonTGC_Cabling::TGCDatabaseInPP::m_maxIndexIn
int m_maxIndexIn[NIndexIn]
Definition
TGCDatabaseInPP.h:66
MuonTGC_Cabling::TGCDatabaseInPP::update
virtual bool update(const std::vector< int > &) override
Definition
TGCDatabaseInPP.cxx:34
MuonTGC_Cabling::TGCDatabaseInPP::getmaxIndexIn
virtual void getmaxIndexIn(int *tmpmaxIndexIn) const
Get the maximum values of indexIn with NIndexIn dimensions.
Definition
TGCDatabaseInPP.cxx:93
MuonTGC_Cabling::TGCDatabaseInPP::getminIndexIn
virtual void getminIndexIn(int *tmpminIndexIn) const
Get the minimum values of indexIn with NIndexIn dimensions.
Definition
TGCDatabaseInPP.cxx:99
MuonTGC_Cabling::TGCDatabaseInPP::getNIndexDBIn
virtual void getNIndexDBIn(int &tmpNIndexDBIn) const
Get the size of the IndexDBIn table.
Definition
TGCDatabaseInPP.cxx:89
MuonTGC_Cabling::TGCDatabaseInPP::TGCDatabaseInPP
TGCDatabaseInPP()
Definition
TGCDatabaseInPP.h:57
MuonTGC_Cabling::TGCDatabaseInPP::~TGCDatabaseInPP
virtual ~TGCDatabaseInPP()
Destructor.
Definition
TGCDatabaseInPP.cxx:32
MuonTGC_Cabling::TGCDatabaseInPP::convertIndexDBIn
virtual int convertIndexDBIn(int *indexIn) const
Get the internal number, which is between 0 and NIndexDBIn-1.
Definition
TGCDatabaseInPP.cxx:177
MuonTGC_Cabling::TGCDatabaseInPP::m_minIndexIn
int m_minIndexIn[NIndexIn]
Definition
TGCDatabaseInPP.h:67
MuonTGC_Cabling::TGCDatabaseInPP::m_indexDBIn
std::vector< int > m_indexDBIn
Definition
TGCDatabaseInPP.h:64
MuonTGC_Cabling::TGCDatabaseInPP::getindexDBVectorIn
virtual void getindexDBVectorIn(std::vector< int > &tmpindexDBIn) const
Get the IndexDBIn table.
Definition
TGCDatabaseInPP.cxx:85
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::InPP
@ InPP
Definition
TGCDatabase.h:18
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
file
TFile * file
Definition
tile_monitor.h:29
Generated on
for ATLAS Offline Software by
1.17.0