ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
L1Topo
L1TopoAlgorithms
Root
RatioMatch.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
* RatioMatch.cpp
6
* Created by Joerg Stelzer on 11/16/12.
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/RatioMatch.h
"
16
#include "
L1TopoCommon/Exception.h
"
17
#include "
L1TopoInterfaces/Decision.h
"
18
#include "
L1TopoSimulationUtils/Helpers.h
"
19
20
REGISTER_ALG_TCS
(RatioMatch)
21
22
23
// not the best solution but we will move to athena where this comes for free
24
#define LOG std::cout << name() << ": "
25
26
/* NOT USED
27
namespace {
28
unsigned int
29
calcDeltaR2(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
30
double deta = ( tob1->etaDouble() - tob2->etaDouble() );
31
double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
32
if(dphi>M_PI)
33
dphi = 2*M_PI - dphi;
34
35
return round ( 100 * ((dphi)*(dphi) + (deta)*(deta) )) ;
36
37
}
38
}
39
*/
40
41
42
TCS::RatioMatch::RatioMatch
(
const
std::string &
name
) :
DecisionAlg
(
name
)
43
{
44
defineParameter
(
"InputWidth1"
, 9);
45
defineParameter
(
"InputWidth2"
, 9);
46
defineParameter
(
"MaxTob1"
, 0);
47
defineParameter
(
"MaxTob2"
, 0);
48
defineParameter
(
"NumResultBits"
, 2);
49
defineParameter
(
"MinET1"
,0);
50
defineParameter
(
"MinET2"
,0);
51
// FW version assumes clusters so no deltar, also no eta
52
//defineParameter("EtaMin",0);
53
//defineParameter("EtaMax",49);
54
//defineParameter("DeltaR",0);
55
defineParameter
(
"Ratio"
,0,0);
56
defineParameter
(
"Ratio"
,0,1);
57
setNumberOutputBits
(2);
58
}
59
60
TCS::RatioMatch::~RatioMatch
()
61
{}
62
63
64
TCS::StatusCode
65
TCS::RatioMatch::initialize
() {
66
p_NumberLeading1
=
parameter
(
"InputWidth1"
).value();
67
p_NumberLeading2
=
parameter
(
"InputWidth2"
).value();
68
if
(
parameter
(
"MaxTob1"
).value() > 0)
p_NumberLeading1
=
parameter
(
"MaxTob1"
).value();
69
if
(
parameter
(
"MaxTob2"
).value() > 0)
p_NumberLeading2
=
parameter
(
"MaxTob2"
).value();
70
71
p_MinET1
=
parameter
(
"MinET1"
).value();
72
p_MinET2
=
parameter
(
"MinET2"
).value();
73
// p_EtaMin = parameter("EtaMin").value();
74
// p_EtaMax = parameter("EtaMax").value();
75
// p_DeltaR = parameter("DeltaR").value();
76
77
78
TRG_MSG_INFO
(
"Maxtob 1 : "
<<
p_NumberLeading1
);
79
TRG_MSG_INFO
(
"Maxtob 2 : "
<<
p_NumberLeading2
);
80
TRG_MSG_INFO
(
"MinET1 : "
<<
p_MinET1
);
81
TRG_MSG_INFO
(
"MinET2 : "
<<
p_MinET2
);
82
// TRG_MSG_INFO("EtaMin : " << p_EtaMin);
83
// TRG_MSG_INFO("EtaMax : " << p_EtaMax);
84
// TRG_MSG_INFO("DeltaR : " << p_DeltaR);
85
86
for
(
unsigned
int
i=0; i<
numberOutputBits
(); ++i) {
87
p_Ratio
[i] =
parameter
(
"Ratio"
, i).value();
88
TRG_MSG_INFO
(
"Ratio "
<< i <<
" : "
<<
p_Ratio
[i]);
89
}
90
TRG_MSG_INFO
(
"number output : "
<<
numberOutputBits
());
91
return
StatusCode::SUCCESS
;
92
}
93
94
95
TCS::StatusCode
96
TCS::RatioMatch::processBitCorrect
(
const
std::vector<TCS::TOBArray const *> & input,
97
const
std::vector<TCS::TOBArray *> & output,
98
Decision
& decision )
99
100
{
101
return
process
(input,output,decision);
102
}
103
104
TCS::StatusCode
105
TCS::RatioMatch::process
(
const
std::vector<TCS::TOBArray const *> & input,
106
const
std::vector<TCS::TOBArray *> & output,
107
Decision
& decision )
108
{
109
110
if
(input.size()!=2) {
111
TCS_EXCEPTION
(
"RatioMatch alg must have exactly 2 input lists, but got "
<< input.size());
112
}
113
114
bool
hasAmbiguousTruncation =
TSU::isAmbiguousTruncation
(input[0],
p_NumberLeading1
,
p_MinET1
)
115
||
TSU::isAmbiguousTruncation
(input[1],
p_NumberLeading2
,
p_MinET2
);
116
for
(
unsigned
int
i=0; i<
numberOutputBits
(); ++i) {
117
// minEt values are global, not per-result bit.
118
output[i]->setAmbiguityFlag(hasAmbiguousTruncation);
119
}
120
121
unsigned
int
deltaR2 = 999;
122
123
for
(
TOBArray::const_iterator
tob1 = input[0]->begin();
124
tob1 != input[0]->end() && distance(input[0]->begin(), tob1) <
p_NumberLeading1
;
125
++tob1)
126
{
127
128
if
(
parType_t
((*tob1)->Et()) <=
p_MinET1
)
continue
;
// ET cut
129
deltaR2 = 999;
130
131
for
(
TCS::TOBArray::const_iterator
tob2 = input[1]->begin();
132
tob2 != input[1]->end() && distance(input[1]->begin(), tob2) <
p_NumberLeading2
;
133
++tob2) {
134
135
if
(
parType_t
((*tob2)->Et()) <=
p_MinET2
)
continue
;
// ET cut
136
// if( parType_t(fabs((*tob2)->eta())) > p_EtaMax ) continue; // Eta cut
137
// if( parType_t(fabs((*tob2)->eta())) < p_EtaMin ) continue; // Eta cut
138
139
// test DeltaR2Min, DeltaR2Max
140
//deltaR2 = calcDeltaR2( *tob1, *tob2 );
141
// test Deltaeta, Deltaphi
142
//
143
if
(((*tob1)->eta() != (*tob2)->eta()) || ((*tob1)->phi() != (*tob2)->phi()) )
continue
;
// EM does not matches TAU
144
//
145
//
146
for
(
unsigned
int
i=0; i<
numberOutputBits
(); ++i) {
147
bool
accept =
false
;
148
accept = 10*
parType_t
((*tob1)->Et()) >=
p_Ratio
[i]*
parType_t
((*tob2)->Et());
149
// accept = deltaR2 <= p_DeltaR && 10*parType_t((*tob1)->Et()) >= p_Ratio[i]*parType_t((*tob2)->Et());
150
if
( accept ) {
151
decision.
setBit
(i,
true
);
152
output[i]->push_back(
TCS::CompositeTOB
(*tob1, *tob2));
153
}
154
TRG_MSG_DEBUG
(
"Decision "
<< i <<
": "
<< (accept?
"pass"
:
"fail"
) <<
" deltaR2 = "
<< deltaR2 );
155
}
156
}
157
}
158
return
TCS::StatusCode::SUCCESS
;
159
}
REGISTER_ALG_TCS
#define REGISTER_ALG_TCS(CLASS)
Definition
AlgFactory.h:62
Decision.h
RatioMatch.h
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
Helpers.h
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::defineParameter
void defineParameter(std::string_view name, TCS::parType_t value)
Definition
ConfigurableAlg.cxx:203
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::RatioMatch::p_NumberLeading1
parType_t p_NumberLeading1
Definition
RatioMatch.h:33
TCS::RatioMatch::RatioMatch
RatioMatch(const std::string &name)
Definition
RatioMatch.cxx:42
TCS::RatioMatch::~RatioMatch
virtual ~RatioMatch()
Definition
RatioMatch.cxx:60
TCS::RatioMatch::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition
RatioMatch.cxx:105
TCS::RatioMatch::initialize
virtual StatusCode initialize()
Definition
RatioMatch.cxx:65
TCS::RatioMatch::p_Ratio
parType_t p_Ratio[2]
Definition
RatioMatch.h:40
TCS::RatioMatch::p_NumberLeading2
parType_t p_NumberLeading2
Definition
RatioMatch.h:34
TCS::RatioMatch::p_MinET2
parType_t p_MinET2
Definition
RatioMatch.h:36
TCS::RatioMatch::p_MinET1
parType_t p_MinET1
Definition
RatioMatch.h:35
TCS::RatioMatch::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition
RatioMatch.cxx:96
TCS::StatusCode
Definition
Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:15
TCS::StatusCode::SUCCESS
@ SUCCESS
Definition
Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:17
process
const std::string process
Definition
fbtTestBasics.cxx:76
TCS::parType_t
uint32_t parType_t
Definition
Parameter.h:23
TSU::isAmbiguousTruncation
bool isAmbiguousTruncation(TCS::TOBArray const *tobs, size_t pos, unsigned minEt=0)
Definition
Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Helpers.cxx:23
Generated on
for ATLAS Offline Software by
1.17.0