ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
L1Topo
L1TopoAlgorithms
Root
DeltaRSqrIncl1.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
* DeltaRSqrIncl1.cpp
6
* Created by Joerg Stelzer / V Sorin on 9/16/14.
7
*
8
* @brief algorithm calculates the R2-distance between objects in one list and applies dR criteria
9
*
10
* @param NumberLeading
11
**********************************/
12
13
#include <cmath>
14
15
#include "
L1TopoAlgorithms/DeltaRSqrIncl1.h
"
16
#include "
L1TopoCommon/Exception.h
"
17
#include "
L1TopoInterfaces/Decision.h
"
18
#include "
L1TopoSimulationUtils/Helpers.h
"
19
20
REGISTER_ALG_TCS
(DeltaRSqrIncl1)
21
22
23
// not the best solution but we will move to athena where this comes for free
24
#define LOG std::cout << "TCS::DeltaRSqrIncl1: "
25
26
TCS::DeltaRSqrIncl1::DeltaRSqrIncl1
(
const
std::string &
name
) :
DecisionAlg
(
name
)
27
{
28
defineParameter
(
"InputWidth"
, 9);
29
defineParameter
(
"MaxTob"
, 0);
30
defineParameter
(
"NumResultBits"
, 3);
31
defineParameter
(
"RequireOneBarrel"
, 0);
32
defineParameter
(
"MinET1"
,1);
33
defineParameter
(
"MinET2"
,1);
34
defineParameter
(
"DeltaRMin"
, 0, 0);
35
defineParameter
(
"DeltaRMax"
, 0, 0);
36
defineParameter
(
"DeltaRMin"
, 0, 1);
37
defineParameter
(
"DeltaRMax"
, 0, 1);
38
defineParameter
(
"DeltaRMin"
, 0, 2);
39
defineParameter
(
"DeltaRMax"
, 0, 2);
40
setNumberOutputBits
(3);
41
}
42
43
TCS::DeltaRSqrIncl1::~DeltaRSqrIncl1
(){}
44
45
46
TCS::StatusCode
47
TCS::DeltaRSqrIncl1::initialize
() {
48
if
(
parameter
(
"MaxTob"
).value() > 0) {
49
p_NumberLeading1
=
parameter
(
"MaxTob"
).value();
50
p_NumberLeading2
=
parameter
(
"MaxTob"
).value();
51
}
else
{
52
p_NumberLeading1
=
parameter
(
"InputWidth"
).value();
53
p_NumberLeading2
=
parameter
(
"InputWidth"
).value();
54
}
55
p_OneBarrel
=
parameter
(
"RequireOneBarrel"
).value();
56
57
for
(
unsigned
int
i=0; i<
numberOutputBits
(); ++i) {
58
p_DeltaRMin
[i] =
parameter
(
"DeltaRMin"
, i).value();
59
p_DeltaRMax
[i] =
parameter
(
"DeltaRMax"
, i).value();
60
}
61
p_MinET1
=
parameter
(
"MinET1"
).value();
62
p_MinET2
=
parameter
(
"MinET2"
).value();
63
64
TRG_MSG_INFO
(
"NumberLeading1 : "
<<
p_NumberLeading1
);
65
TRG_MSG_INFO
(
"NumberLeading2 : "
<<
p_NumberLeading2
);
66
TRG_MSG_INFO
(
"RequireOneBarrel : "
<<
p_OneBarrel
);
67
68
for
(
unsigned
int
i=0; i<
numberOutputBits
(); ++i) {
69
TRG_MSG_INFO
(
"DeltaRMin : "
<<
p_DeltaRMin
[i]);
70
TRG_MSG_INFO
(
"DeltaRMax : "
<<
p_DeltaRMax
[i]);
71
}
72
TRG_MSG_INFO
(
"MinET1 : "
<<
p_MinET1
);
73
TRG_MSG_INFO
(
"MinET2 : "
<<
p_MinET2
);
74
75
TRG_MSG_INFO
(
"number output : "
<<
numberOutputBits
());
76
77
// book histograms
78
for
(
unsigned
int
i=0; i<
numberOutputBits
(); ++i) {
79
std::string hname_accept =
"hDeltaRSqrIncl1_accept_bit"
+std::to_string((
int
)i);
80
std::string hname_reject =
"hDeltaRSqrIncl1_reject_bit"
+std::to_string((
int
)i);
81
// dR
82
bookHist
(
m_histAccept
, hname_accept,
"DR"
, 100, sqrt(
p_DeltaRMin
[i]), sqrt(
p_DeltaRMax
[i]));
83
bookHist
(
m_histReject
, hname_reject,
"DR"
, 100, sqrt(
p_DeltaRMin
[i]), sqrt(
p_DeltaRMax
[i]));
84
}
85
86
return
StatusCode::SUCCESS
;
87
}
88
89
90
91
TCS::StatusCode
92
TCS::DeltaRSqrIncl1::processBitCorrect
(
const
std::vector<TCS::TOBArray const *> & input,
93
const
std::vector<TCS::TOBArray *> & output,
94
Decision
& decision )
95
{
96
if
(input.size() == 1) {
97
for
(
TOBArray::const_iterator
tob1 = input[0]->begin();
98
tob1 != input[0]->end() && distance( input[0]->begin(), tob1) <
p_NumberLeading1
;
99
++tob1)
100
{
101
if
(
parType_t
((*tob1)->Et()) <= std::min(
p_MinET1
,
p_MinET2
))
continue
;
// ET cut
102
TCS::TOBArray::const_iterator
tob2 = tob1; ++tob2;
103
for
( ;
104
tob2 != input[0]->end() && distance( input[0]->begin(), tob2) <
p_NumberLeading2
;
105
++tob2) {
106
if
(
parType_t
((*tob2)->Et()) <= std::min(
p_MinET1
,
p_MinET2
))
continue
;
// ET cut
107
if
( (
parType_t
((*tob1)->Et()) <= std::max(
p_MinET1
,
p_MinET2
)) && (
parType_t
((*tob2)->Et()) <= std::max(
p_MinET1
,
p_MinET2
)))
continue
;
108
// OneBarrel
109
if
(
p_OneBarrel
&&
parType_t
(abs((*tob1)->eta())) > 10 &&
parType_t
(abs((*tob2)->eta())) > 10 )
continue
;
110
// DeltaR2 cuts
111
unsigned
int
deltaR2 =
calcDeltaR2BW
( *tob1, *tob2 );
112
for
(
unsigned
int
i=0; i<
numberOutputBits
(); ++i) {
113
bool
accept =
false
;
114
accept = deltaR2 >=
p_DeltaRMin
[i] && deltaR2 <=
p_DeltaRMax
[i];
115
const
bool
fillAccept =
fillHistos
() and (
fillHistosBasedOnHardware
() ?
getDecisionHardwareBit
(i) : accept);
116
const
bool
fillReject =
fillHistos
() and not fillAccept;
117
const
bool
alreadyFilled = decision.
bit
(i);
118
if
( accept ) {
119
decision.
setBit
(i,
true
);
120
output[i]->push_back(
TCS::CompositeTOB
(*tob1, *tob2) );
121
}
122
if
(fillAccept and not alreadyFilled) {
123
fillHist1D
(
m_histAccept
[i],sqrt((
float
)deltaR2));
124
}
else
if
(fillReject) {
125
fillHist1D
(
m_histReject
[i],sqrt((
float
)deltaR2));
126
}
127
TRG_MSG_DEBUG
(
"Decision "
<< i <<
": "
<< (accept?
"pass"
:
"fail"
) <<
" deltaR2 = "
<< deltaR2);
128
}
129
}
130
}
131
bool
hasAmbiguousInputs =
TSU::isAmbiguousTruncation
(input[0],
p_NumberLeading1
,
p_MinET1
)
132
||
TSU::isAmbiguousTruncation
(input[0],
p_NumberLeading2
,
p_MinET2
);
133
for
(
unsigned
int
i=0; i <
numberOutputBits
(); ++i) {
134
output[i]->setAmbiguityFlag(hasAmbiguousInputs);
135
}
136
}
else
{
137
TCS_EXCEPTION
(
"DeltaRSqrIncl1 alg must have either 1 input, but got "
<< input.size());
138
}
139
return
TCS::StatusCode::SUCCESS
;
140
}
141
142
TCS::StatusCode
143
TCS::DeltaRSqrIncl1::process
(
const
std::vector<TCS::TOBArray const *> & input,
144
const
std::vector<TCS::TOBArray *> & output,
145
Decision
& decision )
146
{
147
if
(input.size() == 1) {
148
for
(
TOBArray::const_iterator
tob1 = input[0]->begin();
149
tob1 != input[0]->end() && distance( input[0]->begin(), tob1) <
p_NumberLeading1
;
150
++tob1)
151
{
152
if
(
parType_t
((*tob1)->Et()) <= std::min(
p_MinET1
,
p_MinET2
))
continue
;
// ET cut
153
TCS::TOBArray::const_iterator
tob2 = tob1; ++tob2;
154
for
( ;
155
tob2 != input[0]->end() && distance( input[0]->begin(), tob2) <
p_NumberLeading2
;
156
++tob2) {
157
if
(
parType_t
((*tob2)->Et()) <= std::min(
p_MinET1
,
p_MinET2
))
continue
;
// ET cut
158
if
( (
parType_t
((*tob1)->Et()) <= std::max(
p_MinET1
,
p_MinET2
)) && (
parType_t
((*tob2)->Et()) <= std::max(
p_MinET1
,
p_MinET2
)))
continue
;
159
// OneBarrel
160
if
(
p_OneBarrel
&&
parType_t
(abs((*tob1)->eta())) > 10 &&
parType_t
(abs((*tob2)->eta())) > 10 )
continue
;
161
// DeltaR2 cuts
162
unsigned
int
deltaR2 =
calcDeltaR2
( *tob1, *tob2 );
163
for
(
unsigned
int
i=0; i<
numberOutputBits
(); ++i) {
164
bool
accept =
false
;
165
accept = deltaR2 >=
p_DeltaRMin
[i] && deltaR2 <=
p_DeltaRMax
[i];
166
const
bool
fillAccept =
fillHistos
() and (
fillHistosBasedOnHardware
() ?
getDecisionHardwareBit
(i) : accept);
167
const
bool
fillReject =
fillHistos
() and not fillAccept;
168
const
bool
alreadyFilled = decision.
bit
(i);
169
if
( accept ) {
170
decision.
setBit
(i,
true
);
171
output[i]->push_back(
TCS::CompositeTOB
(*tob1, *tob2) );
172
}
173
if
(fillAccept and not alreadyFilled) {
174
fillHist1D
(
m_histAccept
[i],sqrt((
float
)deltaR2));
175
}
else
if
(fillReject) {
176
fillHist1D
(
m_histReject
[i],sqrt((
float
)deltaR2));
177
}
178
TRG_MSG_DEBUG
(
"Decision "
<< i <<
": "
<< (accept?
"pass"
:
"fail"
) <<
" deltaR2 = "
<< deltaR2);
179
}
180
}
181
}
182
}
else
{
183
TCS_EXCEPTION
(
"DeltaRSqrIncl1 alg must have either 1 input, but got "
<< input.size());
184
}
185
return
TCS::StatusCode::SUCCESS
;
186
}
REGISTER_ALG_TCS
#define REGISTER_ALG_TCS(CLASS)
Definition
AlgFactory.h:62
Decision.h
DeltaRSqrIncl1.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::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::fillHist1D
void fillHist1D(const std::string &histName, double x)
Definition
ConfigurableAlg.cxx:470
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::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::DeltaRSqrIncl1::p_NumberLeading1
parType_t p_NumberLeading1
Definition
DeltaRSqrIncl1.h:37
TCS::DeltaRSqrIncl1::initialize
virtual StatusCode initialize()
Definition
DeltaRSqrIncl1.cxx:47
TCS::DeltaRSqrIncl1::DeltaRSqrIncl1
DeltaRSqrIncl1(const std::string &name)
Definition
DeltaRSqrIncl1.cxx:26
TCS::DeltaRSqrIncl1::p_OneBarrel
parType_t p_OneBarrel
Definition
DeltaRSqrIncl1.h:43
TCS::DeltaRSqrIncl1::p_NumberLeading2
parType_t p_NumberLeading2
Definition
DeltaRSqrIncl1.h:38
TCS::DeltaRSqrIncl1::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition
DeltaRSqrIncl1.cxx:143
TCS::DeltaRSqrIncl1::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition
DeltaRSqrIncl1.cxx:92
TCS::DeltaRSqrIncl1::~DeltaRSqrIncl1
virtual ~DeltaRSqrIncl1()
Definition
DeltaRSqrIncl1.cxx:43
TCS::DeltaRSqrIncl1::p_DeltaRMin
parType_t p_DeltaRMin[3]
Definition
DeltaRSqrIncl1.h:39
TCS::DeltaRSqrIncl1::p_MinET2
parType_t p_MinET2
Definition
DeltaRSqrIncl1.h:42
TCS::DeltaRSqrIncl1::p_DeltaRMax
parType_t p_DeltaRMax[3]
Definition
DeltaRSqrIncl1.h:40
TCS::DeltaRSqrIncl1::p_MinET1
parType_t p_MinET1
Definition
DeltaRSqrIncl1.h:41
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
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