ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
L1Topo
L1TopoAlgorithms
Root
NotMatch.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
* NotMatch.cpp
6
* Created by Joerg Stelzer / V Sorin on 9/16/14.
7
*
8
* @brief algorithm calculates the phi-distance between one or two lists and applies delta-phi criteria
9
*
10
* @param NumberLeading
11
**********************************/
12
13
#include <cmath>
14
15
#include "
L1TopoAlgorithms/NotMatch.h
"
16
#include "
L1TopoCommon/Exception.h
"
17
#include "
L1TopoInterfaces/Decision.h
"
18
19
REGISTER_ALG_TCS
(NotMatch)
20
21
22
// not the best solution but we will move to athena where this comes for free
23
#define LOG cout << "TCS::NotMatch: "
24
25
26
TCS::NotMatch::NotMatch
(
const
std::string &
name
) :
DecisionAlg
(
name
)
27
{
28
defineParameter
(
"InputWidth1"
, 9);
29
defineParameter
(
"InputWidth2"
, 9);
30
defineParameter
(
"MaxTob1"
, 0);
31
defineParameter
(
"MaxTob2"
, 0);
32
defineParameter
(
"NumResultBits"
, 2);
33
defineParameter
(
"MinET1"
,1,0);
34
defineParameter
(
"MinET2"
,1,0);
35
defineParameter
(
"EtaMin1"
,0,0);
36
defineParameter
(
"EtaMax1"
,49,0);
37
defineParameter
(
"EtaMin2"
,0,0);
38
defineParameter
(
"EtaMax2"
,49,0);
39
defineParameter
(
"DRCut"
,0,0);
40
defineParameter
(
"MinET1"
,1,1);
41
defineParameter
(
"MinET2"
,1,1);
42
defineParameter
(
"EtaMin1"
,0,1);
43
defineParameter
(
"EtaMax1"
,49,1);
44
defineParameter
(
"EtaMin2"
,0,1);
45
defineParameter
(
"EtaMax2"
,49,1);
46
defineParameter
(
"DRCut"
,0,1);
47
setNumberOutputBits
(2);
48
}
49
50
TCS::NotMatch::~NotMatch
(){}
51
52
53
TCS::StatusCode
54
TCS::NotMatch::initialize
() {
55
p_NumberLeading1
=
parameter
(
"InputWidth1"
).value();
56
p_NumberLeading2
=
parameter
(
"InputWidth2"
).value();
57
if
(
parameter
(
"MaxTob1"
).value() > 0)
p_NumberLeading1
=
parameter
(
"MaxTob1"
).value();
58
if
(
parameter
(
"MaxTob2"
).value() > 0)
p_NumberLeading2
=
parameter
(
"MaxTob2"
).value();
59
for
(
unsigned
int
i=0; i<
numberOutputBits
(); ++i) {
60
p_MinET1
[i] =
parameter
(
"MinET1"
,i).value();
61
p_MinET2
[i] =
parameter
(
"MinET2"
,i).value();
62
TRG_MSG_INFO
(
"MinET1 : "
<<
p_MinET1
[i]);
63
TRG_MSG_INFO
(
"MinET2 : "
<<
p_MinET2
[i]);
64
65
p_EtaMin1
[i] =
parameter
(
"EtaMin1"
,i).value();
66
p_EtaMin2
[i] =
parameter
(
"EtaMin2"
,i).value();
67
TRG_MSG_INFO
(
"MinEta1 : "
<<
p_EtaMin1
[i]);
68
TRG_MSG_INFO
(
"MinEta2 : "
<<
p_EtaMin2
[i]);
69
70
p_EtaMax1
[i] =
parameter
(
"EtaMax1"
,i).value();
71
p_EtaMax2
[i] =
parameter
(
"EtaMax2"
,i).value();
72
TRG_MSG_INFO
(
"MinEta1 : "
<<
p_EtaMax1
[i]);
73
TRG_MSG_INFO
(
"MinEta2 : "
<<
p_EtaMax2
[i]);
74
75
p_DRCut
[i] =
parameter
(
"DRCut"
,i).value();
76
TRG_MSG_INFO
(
"DRCut : "
<<
p_DRCut
[i]);
77
}
78
TRG_MSG_INFO
(
"Maxtob 1 : "
<<
p_NumberLeading1
);
79
TRG_MSG_INFO
(
"Maxtob 2 : "
<<
p_NumberLeading2
);
80
TRG_MSG_INFO
(
"number output : "
<<
numberOutputBits
());
81
return
StatusCode::SUCCESS
;
82
}
83
84
TCS::StatusCode
85
TCS::NotMatch::processBitCorrect
(
const
std::vector<TCS::TOBArray const *> & input,
86
const
std::vector<TCS::TOBArray *> & output,
87
Decision
& decision )
88
{
89
if
( input.size() == 2) {
90
bool
matched =
false
;
91
unsigned
int
deltaR2= 999;
92
for
(
unsigned
int
i=0; i<
numberOutputBits
(); ++i) {
93
bool
all_unmatched =
true
;
94
std::vector<GenericTOB*> unmatched_tobs;
95
for
(
TOBArray::const_iterator
tob1 = input[0]->begin();
96
tob1 != input[0]->end() && distance(input[0]->begin(), tob1) <
p_NumberLeading1
;
97
++tob1)
98
{
99
if
(
p_NumberLeading1
< input[0]->
size
()) {
100
TCS::TOBArray::const_iterator
tob1_plus1 = tob1; ++tob1_plus1;
101
if
((*tob1)->Et() == (*tob1_plus1)->Et() && distance(input[0]->begin(), tob1) ==
p_NumberLeading1
- 1) {
102
for
(
unsigned
int
i=0; i<
numberOutputBits
(); ++i) {
103
output[i]->setAmbiguityFlag(
true
);
104
}
105
}
106
}
107
if
(
parType_t
((*tob1)->Et()) <=
p_MinET1
[i])
continue
;
// ET cut
108
if
(
parType_t
(std::abs((*tob1)->eta())) >
p_EtaMax1
[i] )
continue
;
// Eta cut
109
if
(
parType_t
(std::abs((*tob1)->eta())) <
p_EtaMin1
[i] )
continue
;
// Eta cut
110
matched =
false
;
111
deltaR2 = 999;
112
for
(
TCS::TOBArray::const_iterator
tob2 = input[1]->begin();
113
tob2 != input[1]->end() && distance(input[1]->begin(), tob2) <
p_NumberLeading2
&& matched !=
true
;
114
++tob2) {
115
if
(
parType_t
((*tob2)->Et()) <=
p_MinET2
[i])
continue
;
// ET cut
116
if
(
parType_t
(std::abs((*tob2)->eta())) >
p_EtaMax2
[i] )
continue
;
// Eta cut
117
if
(
parType_t
(std::abs((*tob2)->eta())) <
p_EtaMin2
[i] )
continue
;
// Eta cut
118
// test DeltaR2Min, DeltaR2Max
119
deltaR2 =
calcDeltaR2BW
( *tob1, *tob2 );
120
if
(deltaR2 <=
p_DRCut
[i]) matched =
true
;
121
}
// for(tob2)
122
// protection against no jets
123
if
(deltaR2 == 999) matched =
true
;
124
if
(not matched) unmatched_tobs.push_back(*tob1);
125
all_unmatched = all_unmatched and not matched;
126
}
// for(tob1)
127
const
bool
accept = all_unmatched and unmatched_tobs.size()>0;
128
if
(accept){
129
decision.
setBit
(i,
true
);
130
for
(
const
auto
tob : unmatched_tobs)
131
output[i]->push_back(
TCS::CompositeTOB
(tob));
132
}
133
TRG_MSG_DEBUG
(
"Decision "
<< i <<
": "
<< (accept?
"pass"
:
"fail"
));
134
}
// for(i)
135
}
else
{
136
TCS_EXCEPTION
(
"NotMatch alg must have 2 inputs, but got "
<< input.size());
137
}
138
return
TCS::StatusCode::SUCCESS
;
139
140
}
141
142
TCS::StatusCode
143
TCS::NotMatch::process
(
const
std::vector<TCS::TOBArray const *> & input,
144
const
std::vector<TCS::TOBArray *> & output,
145
Decision
& decision )
146
{
147
if
( input.size() == 2) {
148
bool
matched =
false
;
149
unsigned
int
deltaR2= 999;
150
for
(
unsigned
int
i=0; i<
numberOutputBits
(); ++i) {
151
bool
all_unmatched =
true
;
152
std::vector<GenericTOB*> unmatched_tobs;
153
for
(
TOBArray::const_iterator
tob1 = input[0]->begin();
154
tob1 != input[0]->end() && distance(input[0]->begin(), tob1) <
p_NumberLeading1
;
155
++tob1)
156
{
157
if
(
parType_t
((*tob1)->Et()) <=
p_MinET1
[i])
continue
;
// ET cut
158
if
(
parType_t
(std::abs((*tob1)->eta())) >
p_EtaMax1
[i] )
continue
;
// Eta cut
159
if
(
parType_t
(std::abs((*tob1)->eta())) <
p_EtaMin1
[i] )
continue
;
// Eta cut
160
matched =
false
;
161
deltaR2 = 999;
162
for
(
TCS::TOBArray::const_iterator
tob2 = input[1]->begin();
163
tob2 != input[1]->end() && distance(input[1]->begin(), tob2) <
p_NumberLeading2
&& matched !=
true
;
164
++tob2) {
165
if
(
parType_t
((*tob2)->Et()) <=
p_MinET2
[i])
continue
;
// ET cut
166
if
(
parType_t
(std::abs((*tob2)->eta())) >
p_EtaMax2
[i] )
continue
;
// Eta cut
167
if
(
parType_t
(std::abs((*tob2)->eta())) <
p_EtaMin2
[i] )
continue
;
// Eta cut
168
// test DeltaR2Min, DeltaR2Max
169
deltaR2 =
calcDeltaR2
( *tob1, *tob2 );
170
if
(deltaR2 <=
p_DRCut
[i]) matched =
true
;
171
}
// for(tob2)
172
// protection against no jets
173
if
(deltaR2 == 999) matched =
true
;
174
if
(not matched) unmatched_tobs.push_back(*tob1);
175
all_unmatched = all_unmatched and not matched;
176
}
// for(tob1)
177
const
bool
accept = all_unmatched and unmatched_tobs.size()>0;
178
if
(accept){
179
decision.
setBit
(i,
true
);
180
for
(
const
auto
tob : unmatched_tobs)
181
output[i]->push_back(
TCS::CompositeTOB
(tob));
182
}
183
TRG_MSG_DEBUG
(
"Decision "
<< i <<
": "
<< (accept?
"pass"
:
"fail"
));
184
}
// for(i)
185
}
else
{
186
TCS_EXCEPTION
(
"NotMatch alg must have 2 inputs, but got "
<< input.size());
187
}
188
return
TCS::StatusCode::SUCCESS
;
189
}
REGISTER_ALG_TCS
#define REGISTER_ALG_TCS(CLASS)
Definition
AlgFactory.h:62
Decision.h
NotMatch.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::parameter
const Parameter & parameter(std::string_view parameterName) const
Definition
ConfigurableAlg.cxx:245
TCS::ConfigurableAlg::calcDeltaR2BW
unsigned int calcDeltaR2BW(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
Definition
ConfigurableAlg.cxx:154
TCS::ConfigurableAlg::defineParameter
void defineParameter(std::string_view name, TCS::parType_t value)
Definition
ConfigurableAlg.cxx:203
TCS::ConfigurableAlg::calcDeltaR2
unsigned int calcDeltaR2(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
Definition
ConfigurableAlg.cxx:193
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::numberOutputBits
unsigned int numberOutputBits() const
Definition
DecisionAlg.h:38
TCS::Decision
Definition
Decision.h:19
TCS::Decision::setBit
void setBit(unsigned int index, bool value)
Definition
Decision.cxx:12
TCS::NotMatch::NotMatch
NotMatch(const std::string &name)
Definition
NotMatch.cxx:26
TCS::NotMatch::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition
NotMatch.cxx:143
TCS::NotMatch::p_NumberLeading1
parType_t p_NumberLeading1
Definition
NotMatch.h:33
TCS::NotMatch::~NotMatch
virtual ~NotMatch()
Definition
NotMatch.cxx:50
TCS::NotMatch::p_DRCut
parType_t p_DRCut[2]
Definition
NotMatch.h:41
TCS::NotMatch::p_MinET2
parType_t p_MinET2[2]
Definition
NotMatch.h:38
TCS::NotMatch::p_EtaMin2
parType_t p_EtaMin2[2]
Definition
NotMatch.h:39
TCS::NotMatch::p_EtaMin1
parType_t p_EtaMin1[2]
Definition
NotMatch.h:36
TCS::NotMatch::p_MinET1
parType_t p_MinET1[2]
Definition
NotMatch.h:35
TCS::NotMatch::p_NumberLeading2
parType_t p_NumberLeading2
Definition
NotMatch.h:34
TCS::NotMatch::p_EtaMax1
parType_t p_EtaMax1[2]
Definition
NotMatch.h:37
TCS::NotMatch::p_EtaMax2
parType_t p_EtaMax2[2]
Definition
NotMatch.h:40
TCS::NotMatch::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition
NotMatch.cxx:85
TCS::NotMatch::initialize
virtual StatusCode initialize()
Definition
NotMatch.cxx:54
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