ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
TrigT1TGC
src
TGCNSWCoincidenceMap.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
#include <iostream>
7
#include <fstream>
8
#include <sstream>
9
#include <iomanip>
10
#include <stdexcept>
11
12
#include "
TrigT1TGC/TGCNSWCoincidenceMap.h
"
13
#include "
TrigT1TGC/NSWTrigOut.h
"
14
#include "
TrigT1TGC/TGCDatabaseManager.h
"
15
#include "
PathResolver/PathResolver.h
"
16
17
#include "
TrigT1TGC/TGCArguments.h
"
18
19
namespace
LVL1TGCTrigger
{
20
21
22
TGCNSWCoincidenceMap::TGCNSWCoincidenceMap
(
TGCArguments
* tgcargs,
const
std::string& version,
int
side,
int
oct,
int
mod)
23
:
AthMessaging
(
"TGCNSWCoincidenceMap"
),
24
m_verName
(version),
25
m_side
(side),
26
m_octant
(oct),
27
m_module
(mod),
28
m_tgcArgs
(tgcargs)
29
{
30
31
setLevel
(
tgcArgs
()->MSGLEVEL());
32
33
if
(!
tgcArgs
()->USE_NSW()){
return
;}
34
35
std::string moduleName = std::to_string(mod);
36
if
(
isForward
(mod)){
37
m_region
=
TGCRegionType::FORWARD
;
38
m_sector
=
m_module
/3;
39
m_sector
+= 3*
m_octant
;
40
}
41
else
{
42
m_region
=
TGCRegionType::ENDCAP
;
43
m_sector
=
m_module
%3 + 2*(
m_module
/3);
44
m_sector
+= 6*
m_octant
;
45
}
46
47
48
m_Offset_Eta
.resize(
m_NumberOfRoI
[
m_region
]);
49
m_Offset_Phi
.resize(
m_NumberOfRoI
[
m_region
]);
50
51
for
(
int
dr=0;dr!=
N_dEta
;dr++){
52
for
(
int
dphi=0;dphi!=
N_dPhi
;dphi++){
53
m_EtaPhi_CW
[dr][dphi].resize(
m_NumberOfRoI
[
m_region
]);
54
std::fill(
m_EtaPhi_CW
[dr][dphi].begin(),
m_EtaPhi_CW
[dr][dphi].end(),0);
55
}
56
for
(
int
dTheta=0;dTheta!=
N_Dtheta
;dTheta++){
57
m_EtaDtheta_CW
[dr][dTheta].resize(
m_NumberOfRoI
[
m_region
]);
58
std::fill(
m_EtaDtheta_CW
[dr][dTheta].begin(),
m_EtaDtheta_CW
[dr][dTheta].end(),0);
59
}
60
}
61
62
if
( ( oct%2==0 && mod==5 ) || (oct%2==1 && (mod==2 || mod==8)) ){moduleName+=
"b"
;}
63
else
{moduleName+=
"a"
;}
64
65
66
//---------Read out CW data---------
67
if
(!this->
readMap
( moduleName,
ReadCW_Type::EtaPhi_CW
) ||
68
!this->
readMap
( moduleName,
ReadCW_Type::EtaDtheta_CW
)
69
){
70
// NSW trigger flag is set to false when the map reading failed.
71
tgcArgs
()->
set_USE_NSW
(
false
);
72
}
73
74
//---------Fill Shift data---------
75
if
(!this->
readShift
()){
76
// NSW trigger flag is set to false when the map reading failed.
77
tgcArgs
()->
set_USE_NSW
(
false
);
78
}
79
80
}
81
82
83
bool
TGCNSWCoincidenceMap::isForward
(
int
mod ){
84
return
( mod==2 || mod==5 || mod==8 );
85
}
86
87
//TGC-NSW Eta-Phi Coincidence
88
int
TGCNSWCoincidenceMap::TGCNSW_pTcalcu_EtaPhi
(
const
LVL1TGC::NSWTrigOut
*nswOut,
int
roi)
const
89
{
90
std::vector<uint8_t> nswEta_vec=nswOut->
getNSWeta
();
91
std::vector<uint8_t> nswPhi_vec=nswOut->
getNSWphi
();
92
int
highest_pT=0;
93
94
for
(
unsigned
int
nswTrk_id=0;nswTrk_id!=nswEta_vec.size();nswTrk_id++){
95
int
eta_decode=
m_Offset_Eta
[roi]-nswEta_vec[nswTrk_id];
96
int
phi_decode=
m_Offset_Phi
[roi]-nswPhi_vec[nswTrk_id];
97
if
(eta_decode<0 || eta_decode>=
N_dEta
){
continue
;}
98
if
(phi_decode<0 || phi_decode>=
N_dPhi
){
continue
;}
99
100
if
(highest_pT<
m_EtaPhi_CW
[eta_decode][phi_decode][roi]){
101
highest_pT=
m_EtaPhi_CW
[eta_decode][phi_decode][roi];
102
}
103
}
104
105
return
1;
106
}
107
108
109
//TGC-NSW Eta-DeltaTheta Coincidence
110
int
TGCNSWCoincidenceMap::TGCNSW_pTcalcu_EtaDtheta
(
const
LVL1TGC::NSWTrigOut
*nswOut,
int
roi)
const
111
{
112
std::vector<uint8_t> nswEta_vec=nswOut->
getNSWeta
();
113
std::vector<uint8_t> nswDtheta_vec=nswOut->
getNSWDtheta
();
114
int
highest_pT=0;
115
116
for
(
unsigned
int
nswTrk_id=0;nswTrk_id!=nswEta_vec.size();nswTrk_id++){
117
int
eta_decode=
m_Offset_Eta
[roi]-nswEta_vec[nswTrk_id];
118
int
dTheta_decode=nswDtheta_vec[nswTrk_id];
119
if
(eta_decode<0 || eta_decode>=
N_dEta
){
continue
;}
120
if
(highest_pT<
m_EtaDtheta_CW
[eta_decode][dTheta_decode][roi]){
121
highest_pT=
m_EtaDtheta_CW
[eta_decode][dTheta_decode][roi];
122
}
123
}
124
125
return
1;
126
}
127
128
129
bool
TGCNSWCoincidenceMap::readMap
(
const
std::string& moduleName,
ReadCW_Type
cw_type)
130
{
131
std::string kSide[2] = {
"a"
,
"c"
};
132
std::string kCWtype[2] = {
"EtaPhi"
,
"EtaDtheta"
};
133
134
std::string dbname=
""
;
135
136
dbname =
"/NSW/cm_"
+ kSide[
m_side
] + moduleName +kCWtype[cw_type]+
"_Octant_"
+
m_verName
+
".db"
;
137
std::string fullName =
PathResolver::FindCalibDirectory
(
"dev"
)+
"/TrigT1TGC"
+dbname;
138
139
std::ifstream data(fullName);
140
if
(!data.is_open()){
141
ATH_MSG_WARNING
(
"Cannot open file dev/TrigT1TGC"
<< dbname);
142
return
false
;
143
}
144
char
delimiter
=
'\n'
;
145
std::string field;
146
std::string tag;
147
148
while
(std::getline(data, field,
delimiter
)) {
149
int
roi=-1;
150
unsigned
int
n_Etabit=0;
151
unsigned
int
n_Phibit=0;
152
std::istringstream
header
(field);
153
header
>> tag;
154
if
(tag==
"#"
){
// read header part.
155
header
>> roi >> n_Etabit >> n_Phibit;
156
}
157
// get trigger word
158
std::string word;
159
unsigned
int
pT=0;
160
162
for
(
size_t
posR=0; posR<
N_dEta
; posR++){
163
std::getline(data, field,
delimiter
);
164
std::istringstream cont(field);
165
//----Read EtaPhi CW---------
166
if
(cw_type==
ReadCW_Type::EtaPhi_CW
){
167
for
(
size_t
posPHI=0; posPHI<
N_dPhi
; posPHI++){
168
cont >> word;
169
std::istringstream(word) >> std::hex >> pT;
170
//values should be checked against sensible limits; do minimal check here:
171
if
(roi<0)
continue
;
172
//coverity[TAINTED_SCALAR]
173
m_EtaPhi_CW
[posR][posPHI][roi]=pT;
174
}
175
}
176
//-----Read EtaDtheta CW-----
177
if
(cw_type==
ReadCW_Type::EtaDtheta_CW
){
178
for
(
size_t
posDTHETA=0; posDTHETA<
N_Dtheta
; posDTHETA++){
179
cont >> word;
180
std::istringstream(word) >> std::hex >> pT;
181
auto
& roiIndexedVector =
m_EtaDtheta_CW
[posR][posDTHETA];
182
if
((roi<0) or (
static_cast<
size_t
>
(roi)>=roiIndexedVector.size())){
183
throw
std::out_of_range(
"roi outside of vector limits in TGCNSWCoincidenceMap::readMap"
);
184
}
185
roiIndexedVector[roi]=pT;
186
}
187
}
188
}
189
}
190
data.close();
191
192
193
return
true
;
194
}
195
196
197
bool
TGCNSWCoincidenceMap::readShift
(){
198
199
char
delimiter
=
'\n'
;
200
std::string field;
201
std::string tag;
202
int
side;
203
int
triggerSector;
204
205
//------- Read Endcap Shift
206
std::string dbname=
"/NSW/"
;
207
208
if
(
m_region
==
TGCRegionType::ENDCAP
){dbname +=
"RoIpos_Endcap.db"
;}
209
if
(
m_region
==
TGCRegionType::FORWARD
){dbname +=
"RoIpos_Forward.db"
;}
210
std::string fullName =
PathResolver::FindCalibDirectory
(
"dev"
)+
"/TrigT1TGC"
+dbname;
211
212
std::ifstream data(fullName);
213
if
(!data.is_open()){
return
false
;}
214
while
(std::getline(data, field,
delimiter
)) {
215
std::istringstream
header
(field);
216
header
>> tag;
217
if
(tag==
"#"
){
// read header part.
218
header
>> side >> triggerSector ;
219
}
220
221
// get trigger word
222
std::getline(data, field,
delimiter
);
223
std::istringstream cont(field);
224
std::string word;
225
int
shift=0;
226
std::array<int, 4> phi_shift {};
227
std::array<int, 37> eta_shift {};
228
229
if
(side!=
m_side
|| triggerSector!=
m_sector
){
continue
; }
230
for
(
int
phiN=0; phiN!=4; phiN++){
231
cont >> word;
232
std::istringstream(word) >> shift;
233
phi_shift[phiN]=shift;
234
}
235
for
(
int
etaN=0; etaN!=
m_NumberOfEtaRaw
[
m_region
]; etaN++){
236
cont >> word;
237
std::istringstream(word) >> shift;
238
eta_shift[etaN]=shift;
239
}
240
for
(
int
roi=0;roi!=
m_NumberOfRoI
[
m_region
];roi++){
241
m_Offset_Eta
[roi]=eta_shift[roi/4]+
N_dEta
/2;
242
m_Offset_Phi
[roi]=phi_shift[roi%4]+
N_dPhi
/2;
243
}
244
245
break
;
246
}
247
data.close();
248
249
return
true
;
250
}
251
252
}
//end of namespace bracket
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
NSWTrigOut.h
PathResolver.h
TGCArguments.h
TGCDatabaseManager.h
TGCNSWCoincidenceMap.h
AthMessaging::setLevel
void setLevel(MSG::Level lvl)
Change the current logging level.
Definition
AthMessaging.cxx:28
AthMessaging::AthMessaging
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Definition
AthMessaging.cxx:13
LVL1TGCTrigger::TGCArguments
Definition
TGCArguments.h:12
LVL1TGCTrigger::TGCArguments::set_USE_NSW
void set_USE_NSW(bool v)
Definition
TGCArguments.cxx:35
LVL1TGCTrigger::TGCNSWCoincidenceMap::m_EtaDtheta_CW
std::vector< short int > m_EtaDtheta_CW[N_dEta][N_Dtheta]
Definition
TGCNSWCoincidenceMap.h:56
LVL1TGCTrigger::TGCNSWCoincidenceMap::m_side
int m_side
Definition
TGCNSWCoincidenceMap.h:61
LVL1TGCTrigger::TGCNSWCoincidenceMap::TGCNSW_pTcalcu_EtaPhi
int TGCNSW_pTcalcu_EtaPhi(const LVL1TGC::NSWTrigOut *nswOut, int RoI) const
Definition
TGCNSWCoincidenceMap.cxx:88
LVL1TGCTrigger::TGCNSWCoincidenceMap::m_region
TGCRegionType m_region
Definition
TGCNSWCoincidenceMap.h:65
LVL1TGCTrigger::TGCNSWCoincidenceMap::N_dPhi
@ N_dPhi
Definition
TGCNSWCoincidenceMap.h:28
LVL1TGCTrigger::TGCNSWCoincidenceMap::N_Dtheta
@ N_Dtheta
Definition
TGCNSWCoincidenceMap.h:28
LVL1TGCTrigger::TGCNSWCoincidenceMap::N_dEta
@ N_dEta
Definition
TGCNSWCoincidenceMap.h:28
LVL1TGCTrigger::TGCNSWCoincidenceMap::isForward
bool isForward(int module)
Definition
TGCNSWCoincidenceMap.cxx:83
LVL1TGCTrigger::TGCNSWCoincidenceMap::TGCNSWCoincidenceMap
TGCNSWCoincidenceMap()=delete
LVL1TGCTrigger::TGCNSWCoincidenceMap::ReadCW_Type
ReadCW_Type
Definition
TGCNSWCoincidenceMap.h:29
LVL1TGCTrigger::TGCNSWCoincidenceMap::EtaPhi_CW
@ EtaPhi_CW
Definition
TGCNSWCoincidenceMap.h:29
LVL1TGCTrigger::TGCNSWCoincidenceMap::EtaDtheta_CW
@ EtaDtheta_CW
Definition
TGCNSWCoincidenceMap.h:29
LVL1TGCTrigger::TGCNSWCoincidenceMap::tgcArgs
TGCArguments * tgcArgs()
Definition
TGCNSWCoincidenceMap.h:51
LVL1TGCTrigger::TGCNSWCoincidenceMap::m_verName
std::string m_verName
Definition
TGCNSWCoincidenceMap.h:60
LVL1TGCTrigger::TGCNSWCoincidenceMap::m_module
int m_module
Definition
TGCNSWCoincidenceMap.h:63
LVL1TGCTrigger::TGCNSWCoincidenceMap::m_NumberOfRoI
std::map< TGCRegionType, int > m_NumberOfRoI
Definition
TGCNSWCoincidenceMap.h:31
LVL1TGCTrigger::TGCNSWCoincidenceMap::m_tgcArgs
TGCArguments * m_tgcArgs
Definition
TGCNSWCoincidenceMap.h:67
LVL1TGCTrigger::TGCNSWCoincidenceMap::readShift
bool readShift()
Definition
TGCNSWCoincidenceMap.cxx:197
LVL1TGCTrigger::TGCNSWCoincidenceMap::m_sector
int m_sector
Definition
TGCNSWCoincidenceMap.h:64
LVL1TGCTrigger::TGCNSWCoincidenceMap::m_octant
int m_octant
Definition
TGCNSWCoincidenceMap.h:62
LVL1TGCTrigger::TGCNSWCoincidenceMap::m_Offset_Phi
std::vector< short int > m_Offset_Phi
Definition
TGCNSWCoincidenceMap.h:58
LVL1TGCTrigger::TGCNSWCoincidenceMap::readMap
bool readMap(const std::string &moduleName, ReadCW_Type cw_type)
Definition
TGCNSWCoincidenceMap.cxx:129
LVL1TGCTrigger::TGCNSWCoincidenceMap::m_Offset_Eta
std::vector< short int > m_Offset_Eta
Definition
TGCNSWCoincidenceMap.h:57
LVL1TGCTrigger::TGCNSWCoincidenceMap::TGCNSW_pTcalcu_EtaDtheta
int TGCNSW_pTcalcu_EtaDtheta(const LVL1TGC::NSWTrigOut *nswOut, int RoI) const
Definition
TGCNSWCoincidenceMap.cxx:110
LVL1TGCTrigger::TGCNSWCoincidenceMap::m_EtaPhi_CW
std::vector< short int > m_EtaPhi_CW[N_dEta][N_dPhi]
Definition
TGCNSWCoincidenceMap.h:55
LVL1TGCTrigger::TGCNSWCoincidenceMap::m_NumberOfEtaRaw
std::map< TGCRegionType, int > m_NumberOfEtaRaw
Definition
TGCNSWCoincidenceMap.h:30
LVL1TGC::NSWTrigOut
Definition
NSWTrigOut.h:16
LVL1TGC::NSWTrigOut::getNSWphi
const std::vector< uint8_t > & getNSWphi() const
Definition
NSWTrigOut.h:67
LVL1TGC::NSWTrigOut::getNSWDtheta
const std::vector< uint8_t > & getNSWDtheta() const
Definition
NSWTrigOut.h:68
LVL1TGC::NSWTrigOut::getNSWeta
const std::vector< uint8_t > & getNSWeta() const
Definition
NSWTrigOut.h:66
PathResolver::FindCalibDirectory
static std::string FindCalibDirectory(const std::string &logical_file_name)
Definition
PathResolver.h:64
header
Definition
hcg.cxx:529
delimiter
static const std::string delimiter("/")
LVL1TGCTrigger
Definition
LVL1TGCTrigger.cxx:48
LVL1TGCTrigger::TGCRegionType::FORWARD
@ FORWARD
Definition
TGCNumbering.h:49
LVL1TGCTrigger::TGCRegionType::ENDCAP
@ ENDCAP
Definition
TGCNumbering.h:49
Generated on
for ATLAS Offline Software by
1.17.0