ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
L1Topo
L1TopoAlgorithms
Root
EtaPhiWindow.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
6
7
#include "
L1TopoAlgorithms/EtaPhiWindow.h
"
8
9
#include "
L1TopoCommon/Exception.h
"
10
#include "
L1TopoInterfaces/Decision.h
"
11
12
#include <cmath>
13
#include <iterator>
14
15
16
REGISTER_ALG_TCS
(EtaPhiWindow)
17
18
using
std::distance;
19
20
//----------------------------------------------------------
21
TCS::EtaPhiWindow::EtaPhiWindow
(
const
std::string &
name
) :
DecisionAlg
(
name
)
22
{
23
defineParameter
(
"InputWidth"
, 3);
24
defineParameter
(
"NumResultBits"
, 1);
25
defineParameter
(
"MaxTob"
, 0);
26
defineParameter
(
"MinET"
,1);
27
defineParameter
(
"EtaMin"
, 0);
28
defineParameter
(
"EtaMax"
, 5);
29
defineParameter
(
"PhiMin"
, 0);
30
defineParameter
(
"PhiMax"
, 63);
31
setNumberOutputBits
(1);
32
}
33
//----------------------------------------------------------
34
TCS::EtaPhiWindow::~EtaPhiWindow
()
35
{
36
}
37
//----------------------------------------------------------
38
TCS::StatusCode
39
TCS::EtaPhiWindow::initialize
()
40
{
41
parType_t
inputWidth =
parameter
(
"InputWidth"
).value();
42
p_MaxTob
=
parameter
(
"MaxTob"
).value();
43
if
(
p_MaxTob
>inputWidth) {
44
TRG_MSG_DEBUG
(
"MaxTob ("
<<
p_MaxTob
<<
")"
45
<<
" is larger than InputWidth ("
<<inputWidth<<
")"
46
<<
" : restricting to InputWidth"
);
47
p_MaxTob
= inputWidth;
48
}
49
p_MinET
=
parameter
(
"MinET"
).value();
50
p_EtaMin
=
parameter
(
"EtaMin"
).value();
51
p_EtaMax
=
parameter
(
"EtaMax"
).value();
52
p_PhiMin
=
parameter
(
"PhiMin"
).value();
53
p_PhiMax
=
parameter
(
"PhiMax"
).value();
54
55
TRG_MSG_INFO
(
"MaxTob : "
<<
p_MaxTob
);
56
TRG_MSG_INFO
(
"MinET : "
<<
p_MinET
);
57
TRG_MSG_INFO
(
"EtaMin : "
<<(
int
)
p_EtaMin
);
58
TRG_MSG_INFO
(
"EtaMax : "
<<(
int
)
p_EtaMax
);
59
TRG_MSG_INFO
(
"PhiMin : "
<<
p_PhiMin
);
60
TRG_MSG_INFO
(
"PhiMax : "
<<
p_PhiMax
);
61
TRG_MSG_INFO
(
"number of output bits : "
<<
numberOutputBits
());
62
63
// book histograms
64
for
(
unsigned
int
i=0; i<
numberOutputBits
(); ++i) {
65
std::string hname_accept =
"hEtaPhiWindow_accept_bit"
+std::to_string((
int
)i);
66
std::string hname_reject =
"hEtaPhiWindow_reject_bit"
+std::to_string((
int
)i);
67
// deta vs dphi
68
bookHist
(
m_histAccept
, hname_accept,
"ETA vs PHI"
, 100,
p_EtaMin
,
p_EtaMax
, 100,
p_PhiMin
,
p_PhiMax
);
69
bookHist
(
m_histReject
, hname_reject,
"ETA vs PHI"
, 100,
p_EtaMin
,
p_EtaMax
, 100,
p_PhiMin
,
p_PhiMax
);
70
}
71
72
return
StatusCode::SUCCESS
;
73
}
74
//----------------------------------------------------------
75
TCS::StatusCode
76
TCS::EtaPhiWindow::processBitCorrect
(
const
std::vector<TCS::TOBArray const *> &input,
77
const
std::vector<TCS::TOBArray *> &output,
78
Decision
&decision)
79
80
{
81
if
(input.size() == 1) {
82
TRG_MSG_DEBUG
(
"input size : "
<<input[0]->
size
());
83
const
unsigned
int
nLeading =
p_MaxTob
;
84
bool
accept{
false
};
85
for
(
TOBArray::const_iterator
tob1 = input[0]->begin();
86
tob1 != input[0]->end();
87
++tob1) {
88
const
std::ptrdiff_t iTob = distance( input[0]->begin(), tob1);
89
if
(nLeading!=0 and iTob>=nLeading)
continue
;
90
if
(
parType_t
((*tob1)->Et()) <=
p_MinET
)
continue
;
91
if
( (
int
)
parType_t
((*tob1)->eta()) < (
int
)
p_EtaMin
)
continue
;
92
if
( (
int
)
parType_t
((*tob1)->eta()) >= (
int
)
p_EtaMax
)
continue
;
93
if
( (
int
)
parType_t
((*tob1)->phi()) < (
int
)
p_PhiMin
)
continue
;
94
if
( (
int
)
parType_t
((*tob1)->phi()) >= (
int
)
p_PhiMax
)
continue
;
95
accept =
true
;
96
const
bool
fillAccept =
fillHistos
() and (
fillHistosBasedOnHardware
() ?
getDecisionHardwareBit
(0) : accept);
97
const
bool
fillReject =
fillHistos
() and not fillAccept;
98
const
bool
alreadyFilled = decision.
bit
(0);
99
output[0]->push_back(
TCS::CompositeTOB
(*tob1));
100
if
(fillAccept and not alreadyFilled) {
101
fillHist2D
(
m_histAccept
[0],(
float
)(*tob1)->eta(),(
float
)(*tob1)->phi());
102
}
else
if
(fillReject) {
103
fillHist2D
(
m_histReject
[0],(
float
)(*tob1)->eta(),(
float
)(*tob1)->phi());
104
}
105
TRG_MSG_DEBUG
(
"TOB "
<<iTob
106
<<
" ET = "
<<(*tob1)->Et()
107
<<
" Eta = "
<<(*tob1)->eta()
108
<<
" phi = "
<<(*tob1)->phi());
109
}
110
decision.
setBit
( 0, accept );
111
}
else
{
112
TCS_EXCEPTION
(
"EtaPhiWindow alg must have 1 input, but got "
<<input.size());
113
}
114
return
TCS::StatusCode::SUCCESS
;
115
}
116
//----------------------------------------------------------
117
TCS::StatusCode
118
TCS::EtaPhiWindow::process
(
const
std::vector<TCS::TOBArray const *> &input,
119
const
std::vector<TCS::TOBArray *> &output,
120
Decision
&decision)
121
{
122
if
(input.size() == 1) {
123
TRG_MSG_DEBUG
(
"input size : "
<<input[0]->
size
());
124
const
unsigned
int
nLeading =
p_MaxTob
;
125
bool
accept{
false
};
126
for
(
TOBArray::const_iterator
tob1 = input[0]->begin();
127
tob1 != input[0]->end();
128
++tob1) {
129
const
std::ptrdiff_t iTob = distance( input[0]->begin(), tob1);
130
if
(nLeading!=0 and iTob>=nLeading)
continue
;
131
if
(
parType_t
((*tob1)->Et()) <=
p_MinET
)
continue
;
132
if
( (
int
)
parType_t
((*tob1)->eta()) < (
int
)
p_EtaMin
)
continue
;
133
if
( (
int
)
parType_t
((*tob1)->eta()) >= (
int
)
p_EtaMax
)
continue
;
134
if
( (
int
)
parType_t
((*tob1)->phi()) < (
int
)
p_PhiMin
)
continue
;
135
if
( (
int
)
parType_t
((*tob1)->phi()) >= (
int
)
p_PhiMax
)
continue
;
136
accept =
true
;
137
const
bool
fillAccept =
fillHistos
() and (
fillHistosBasedOnHardware
() ?
getDecisionHardwareBit
(0) : accept);
138
const
bool
fillReject =
fillHistos
() and not fillAccept;
139
const
bool
alreadyFilled = decision.
bit
(0);
140
output[0]->push_back(
TCS::CompositeTOB
(*tob1));
141
if
(fillAccept and not alreadyFilled) {
142
fillHist2D
(
m_histAccept
[0],(
float
)(*tob1)->eta(),(
float
)(*tob1)->phi());
143
}
else
if
(fillReject) {
144
fillHist2D
(
m_histReject
[0],(
float
)(*tob1)->eta(),(
float
)(*tob1)->phi());
145
}
146
TRG_MSG_DEBUG
(
"TOB "
<<iTob
147
<<
" ET = "
<<(*tob1)->Et()
148
<<
" Eta = "
<<(*tob1)->eta()
149
<<
" phi = "
<<(*tob1)->phi());
150
}
151
decision.
setBit
( 0, accept );
152
}
else
{
153
TCS_EXCEPTION
(
"EtaPhiWindow alg must have 1 input, but got "
<<input.size());
154
}
155
return
TCS::StatusCode::SUCCESS
;
156
}
157
//----------------------------------------------------------
REGISTER_ALG_TCS
#define REGISTER_ALG_TCS(CLASS)
Definition
AlgFactory.h:62
Decision.h
EtaPhiWindow.h
size
size_t size() const
Number of registered mappings.
TRG_MSG_INFO
#define TRG_MSG_INFO(x)
Definition
Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:27
TRG_MSG_DEBUG
#define TRG_MSG_DEBUG(x)
Definition
Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:25
Exception.h
TCS_EXCEPTION
#define TCS_EXCEPTION(MSG)
Definition
Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/Exception.h:15
TCS::CompositeTOB
Definition
CompositeTOB.h:16
TCS::ConfigurableAlg::name
const std::string & name() const
Definition
ConfigurableAlg.h:49
TCS::ConfigurableAlg::bookHist
void bookHist(std::vector< std::string > ®Name, std::string_view name, std::string_view title, const int binx, const int xmin, const int xmax)
Definition
ConfigurableAlg.cxx:272
TCS::ConfigurableAlg::parameter
const Parameter & parameter(std::string_view parameterName) const
Definition
ConfigurableAlg.cxx:245
TCS::ConfigurableAlg::defineParameter
void defineParameter(std::string_view name, TCS::parType_t value)
Definition
ConfigurableAlg.cxx:203
TCS::ConfigurableAlg::fillHist2D
void fillHist2D(const std::string &histName, double x, double y)
Definition
ConfigurableAlg.cxx:474
TCS::DataArrayImpl< GenericTOB >::const_iterator
data_t::const_iterator const_iterator
Definition
DataArrayImpl.h:18
TCS::DecisionAlg::setNumberOutputBits
void setNumberOutputBits(unsigned int numberOutputBits)
Definition
DecisionAlg.h:39
TCS::DecisionAlg::DecisionAlg
DecisionAlg(const std::string &name)
Definition
DecisionAlg.h:24
TCS::DecisionAlg::fillHistosBasedOnHardware
bool fillHistosBasedOnHardware() const
! getter
Definition
DecisionAlg.cxx:84
TCS::DecisionAlg::fillHistos
bool fillHistos() const
whether the monitoring histograms should be filled
Definition
DecisionAlg.cxx:100
TCS::DecisionAlg::m_histAccept
std::vector< std::string > m_histAccept
Definition
DecisionAlg.h:72
TCS::DecisionAlg::m_histReject
std::vector< std::string > m_histReject
Definition
DecisionAlg.h:73
TCS::DecisionAlg::numberOutputBits
unsigned int numberOutputBits() const
Definition
DecisionAlg.h:38
TCS::DecisionAlg::getDecisionHardwareBit
bool getDecisionHardwareBit(const unsigned int &bitNumber) const
! get one hardware decision bit from this algo
Definition
DecisionAlg.cxx:52
TCS::Decision
Definition
Decision.h:19
TCS::Decision::bit
bool bit(unsigned int index) const
Definition
Decision.h:40
TCS::Decision::setBit
void setBit(unsigned int index, bool value)
Definition
Decision.cxx:12
TCS::EtaPhiWindow::p_EtaMax
parType_t p_EtaMax
Definition
EtaPhiWindow.h:45
TCS::EtaPhiWindow::p_MinET
parType_t p_MinET
Definition
EtaPhiWindow.h:43
TCS::EtaPhiWindow::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition
EtaPhiWindow.cxx:76
TCS::EtaPhiWindow::p_PhiMin
parType_t p_PhiMin
Definition
EtaPhiWindow.h:47
TCS::EtaPhiWindow::p_PhiMax
parType_t p_PhiMax
Definition
EtaPhiWindow.h:46
TCS::EtaPhiWindow::p_MaxTob
parType_t p_MaxTob
Definition
EtaPhiWindow.h:42
TCS::EtaPhiWindow::~EtaPhiWindow
virtual ~EtaPhiWindow()
Definition
EtaPhiWindow.cxx:34
TCS::EtaPhiWindow::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition
EtaPhiWindow.cxx:118
TCS::EtaPhiWindow::p_EtaMin
parType_t p_EtaMin
Definition
EtaPhiWindow.h:44
TCS::EtaPhiWindow::EtaPhiWindow
EtaPhiWindow(const std::string &name)
Definition
EtaPhiWindow.cxx:21
TCS::EtaPhiWindow::initialize
virtual StatusCode initialize()
Definition
EtaPhiWindow.cxx:39
TCS::StatusCode
Definition
Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:15
TCS::StatusCode::SUCCESS
@ SUCCESS
Definition
Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:17
TCS::parType_t
uint32_t parType_t
Definition
Parameter.h:23
Generated on
for ATLAS Offline Software by
1.17.0