ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
L1Topo
L1TopoAlgorithms
Root
DeltaPhiIncl2.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
* DeltaPhiIncl2.cpp
6
* Created by Joerg Stelzer on 11/16/12.
7
* Modified by V Sorin
8
*
9
* @brief algorithm calculates the phi-distance between two lists and applies delta-phi criteria
10
*
11
* @param NumberLeading
12
**********************************/
13
14
#include <cmath>
15
#include <string>
16
#include <iostream>
17
#include <sstream>
18
#include <vector>
19
20
#include "
L1TopoAlgorithms/DeltaPhiIncl2.h
"
21
#include "
L1TopoCommon/Exception.h
"
22
#include "
L1TopoInterfaces/Decision.h
"
23
#include "
L1TopoSimulationUtils/Helpers.h
"
24
25
REGISTER_ALG_TCS
(DeltaPhiIncl2)
26
27
using namespace
std
;
28
29
TCS::DeltaPhiIncl2::DeltaPhiIncl2
(
const
std::string &
name
) :
DecisionAlg
(
name
)
30
{
31
defineParameter
(
"InputWidth1"
, 8);
32
defineParameter
(
"InputWidth2"
, 8);
33
defineParameter
(
"MaxTob1"
, 0);
34
defineParameter
(
"MaxTob2"
, 0);
35
defineParameter
(
"NumResultBits"
, 2);
36
defineParameter
(
"Delay1"
, 0);
37
defineParameter
(
"Delay2"
, 0);
38
defineParameter
(
"MinET1"
,0,0);
39
defineParameter
(
"MinET2"
,0,0);
40
defineParameter
(
"MinDeltaPhi"
, 0, 0);
41
defineParameter
(
"MaxDeltaPhi"
, 31, 0);
42
defineParameter
(
"MinET1"
,0,1);
43
defineParameter
(
"MinET2"
,0,1);
44
defineParameter
(
"MinDeltaPhi"
, 0, 1);
45
defineParameter
(
"MaxDeltaPhi"
, 31, 1);
46
setNumberOutputBits
(2);
47
}
48
49
TCS::DeltaPhiIncl2::~DeltaPhiIncl2
(){}
50
51
52
TCS::StatusCode
53
TCS::DeltaPhiIncl2::initialize
() {
54
p_NumberLeading1
=
parameter
(
"InputWidth1"
).value();
55
p_NumberLeading2
=
parameter
(
"InputWidth2"
).value();
56
if
(
parameter
(
"MaxTob1"
).value() > 0)
p_NumberLeading1
=
parameter
(
"MaxTob1"
).value();
57
if
(
parameter
(
"MaxTob2"
).value() > 0)
p_NumberLeading2
=
parameter
(
"MaxTob2"
).value();
58
for
(
unsigned
int
i=0; i<
numberOutputBits
(); ++i) {
59
p_DeltaPhiMin
[i] =
parameter
(
"MinDeltaPhi"
, i).value();
60
p_DeltaPhiMax
[i] =
parameter
(
"MaxDeltaPhi"
, i).value();
61
p_MinET1
[i] =
parameter
(
"MinET1"
,i).value();
62
p_MinET2
[i] =
parameter
(
"MinET2"
,i).value();
63
64
TRG_MSG_INFO
(
"DeltaPhiMin : "
<<
p_DeltaPhiMin
[i]);
65
TRG_MSG_INFO
(
"DeltaPhiMax : "
<<
p_DeltaPhiMax
[i]);
66
TRG_MSG_INFO
(
"MinET1 : "
<<
p_MinET1
[i]);
67
TRG_MSG_INFO
(
"MinET2 : "
<<
p_MinET2
[i]);
68
69
}
70
71
TRG_MSG_INFO
(
"NumberLeading1 : "
<<
p_NumberLeading1
);
// note that the reading of generic parameters doesn't work yet
72
TRG_MSG_INFO
(
"NumberLeading2 : "
<<
p_NumberLeading2
);
73
TRG_MSG_INFO
(
"number output : "
<<
numberOutputBits
());
74
75
// book histograms
76
for
(
unsigned
int
i=0; i<
numberOutputBits
(); ++i) {
77
std::string hname_accept =
"hDeltaPhiIncl2_accept_bit"
+std::to_string((
int
)i);
78
std::string hname_reject =
"hDeltaPhiIncl2_reject_bit"
+std::to_string((
int
)i);
79
// mass
80
bookHist
(
m_histAccept
, hname_accept,
"DPHI"
, 100,
p_DeltaPhiMin
[i],
p_DeltaPhiMax
[i]);
81
bookHist
(
m_histReject
, hname_reject,
"DPHI"
, 100,
p_DeltaPhiMin
[i],
p_DeltaPhiMax
[i]);
82
}
83
84
85
return
StatusCode::SUCCESS
;
86
}
87
88
89
90
TCS::StatusCode
91
TCS::DeltaPhiIncl2::processBitCorrect
(
const
std::vector<TCS::TOBArray const *> & input,
92
const
std::vector<TCS::TOBArray *> & output,
93
Decision
& decision )
94
{
95
if
( input.size() == 2) {
96
std::vector<bool> iaccept (
numberOutputBits
());
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
for
(
TCS::TOBArray::const_iterator
tob2 = input[1]->begin();
102
tob2 != input[1]->end() && distance(input[1]->begin(), tob2) <
p_NumberLeading2
;
103
++tob2) {
104
// test DeltaPhiMin, DeltaPhiMax
105
unsigned
int
deltaPhi
=
calcDeltaPhiBW
( *tob1, *tob2 );
106
for
(
unsigned
int
i=0; i<
numberOutputBits
(); ++i) {
107
bool
accept =
false
;
108
if
(
parType_t
((*tob1)->Et()) <=
p_MinET1
[i])
continue
;
// ET cut
109
if
(
parType_t
((*tob2)->Et()) <=
p_MinET2
[i])
continue
;
// ET cut
110
accept =
deltaPhi
>=
p_DeltaPhiMin
[i] &&
deltaPhi
<=
p_DeltaPhiMax
[i];
111
const
bool
fillAccept =
fillHistos
() and (
fillHistosBasedOnHardware
() ?
getDecisionHardwareBit
(i) : accept);
112
const
bool
fillReject =
fillHistos
() and not fillAccept;
113
const
bool
alreadyFilled = decision.
bit
(i);
114
if
( accept ) {
115
decision.
setBit
(i,
true
);
116
output[i]->push_back(
TCS::CompositeTOB
(*tob1, *tob2));
117
}
118
if
(fillAccept and not alreadyFilled) {
119
fillHist1D
(
m_histAccept
[i],
deltaPhi
);
120
}
else
if
(fillReject) {
121
fillHist1D
(
m_histReject
[i],
deltaPhi
);
122
}
123
TRG_MSG_DEBUG
(
"DeltaPhiIncl2 = "
<<
deltaPhi
<<
" -> "
124
<< (accept?
"pass"
:
"fail"
));
125
}
126
}
127
}
128
for
(
unsigned
int
i=0; i <
numberOutputBits
(); ++i) {
129
bool
hasAmbiguousInputs =
TSU::isAmbiguousTruncation
(input[0],
p_NumberLeading1
,
p_MinET1
[i])
130
||
TSU::isAmbiguousTruncation
(input[1],
p_NumberLeading2
,
p_MinET2
[i]);
131
output[i]->setAmbiguityFlag(hasAmbiguousInputs);
132
}
133
}
else
{
134
TCS_EXCEPTION
(
"DeltaPhiIncl2 alg must have 2 inputs, but got "
<< input.size());
135
}
136
return
TCS::StatusCode::SUCCESS
;
137
}
138
139
140
TCS::StatusCode
141
TCS::DeltaPhiIncl2::process
(
const
std::vector<TCS::TOBArray const *> & input,
142
const
std::vector<TCS::TOBArray *> & output,
143
Decision
& decision )
144
{
145
if
( input.size() == 2) {
146
std::vector<bool> iaccept (
numberOutputBits
());
147
for
(
TOBArray::const_iterator
tob1 = input[0]->begin();
148
tob1 != input[0]->end() && distance(input[0]->begin(), tob1) <
p_NumberLeading1
;
149
++tob1)
150
{
151
for
(
TCS::TOBArray::const_iterator
tob2 = input[1]->begin();
152
tob2 != input[1]->end() && distance(input[1]->begin(), tob2) <
p_NumberLeading2
;
153
++tob2) {
154
// test DeltaPhiMin, DeltaPhiMax
155
unsigned
int
deltaPhi
=
calcDeltaPhi
( *tob1, *tob2 );
156
for
(
unsigned
int
i=0; i<
numberOutputBits
(); ++i) {
157
bool
accept =
false
;
158
if
(
parType_t
((*tob1)->Et()) <=
p_MinET1
[i])
continue
;
// ET cut
159
if
(
parType_t
((*tob2)->Et()) <=
p_MinET2
[i])
continue
;
// ET cut
160
accept =
deltaPhi
>=
p_DeltaPhiMin
[i] &&
deltaPhi
<=
p_DeltaPhiMax
[i];
161
const
bool
fillAccept =
fillHistos
() and (
fillHistosBasedOnHardware
() ?
getDecisionHardwareBit
(i) : accept);
162
const
bool
fillReject =
fillHistos
() and not fillAccept;
163
const
bool
alreadyFilled = decision.
bit
(i);
164
if
( accept ) {
165
decision.
setBit
(i,
true
);
166
output[i]->push_back(
TCS::CompositeTOB
(*tob1, *tob2));
167
}
168
if
(fillAccept and not alreadyFilled) {
169
fillHist1D
(
m_histAccept
[i],
deltaPhi
);
170
}
else
if
(fillReject) {
171
fillHist1D
(
m_histReject
[i],
deltaPhi
);
172
}
173
TRG_MSG_DEBUG
(
"DeltaPhiIncl2 = "
<<
deltaPhi
<<
" -> "
174
<< (accept?
"pass"
:
"fail"
));
175
}
176
}
177
}
178
}
else
{
179
TCS_EXCEPTION
(
"DeltaPhiIncl2 alg must have 2 inputs, but got "
<< input.size());
180
}
181
return
TCS::StatusCode::SUCCESS
;
182
}
REGISTER_ALG_TCS
#define REGISTER_ALG_TCS(CLASS)
Definition
AlgFactory.h:62
deltaPhi
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
Definition
AmgMatrixBasePlugin.h:112
Decision.h
DeltaPhiIncl2.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::calcDeltaPhiBW
unsigned int calcDeltaPhiBW(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
Definition
ConfigurableAlg.cxx:122
TCS::ConfigurableAlg::defineParameter
void defineParameter(std::string_view name, TCS::parType_t value)
Definition
ConfigurableAlg.cxx:203
TCS::ConfigurableAlg::calcDeltaPhi
unsigned int calcDeltaPhi(const TCS::GenericTOB *tob1, const TCS::GenericTOB *tob2)
Definition
ConfigurableAlg.cxx:167
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::DeltaPhiIncl2::p_NumberLeading2
parType_t p_NumberLeading2
Definition
DeltaPhiIncl2.h:36
TCS::DeltaPhiIncl2::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition
DeltaPhiIncl2.cxx:141
TCS::DeltaPhiIncl2::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition
DeltaPhiIncl2.cxx:91
TCS::DeltaPhiIncl2::initialize
virtual StatusCode initialize()
Definition
DeltaPhiIncl2.cxx:53
TCS::DeltaPhiIncl2::p_DeltaPhiMax
parType_t p_DeltaPhiMax[2]
Definition
DeltaPhiIncl2.h:38
TCS::DeltaPhiIncl2::p_MinET1
parType_t p_MinET1[2]
Definition
DeltaPhiIncl2.h:39
TCS::DeltaPhiIncl2::DeltaPhiIncl2
DeltaPhiIncl2(const std::string &name)
Definition
DeltaPhiIncl2.cxx:29
TCS::DeltaPhiIncl2::p_NumberLeading1
parType_t p_NumberLeading1
Definition
DeltaPhiIncl2.h:35
TCS::DeltaPhiIncl2::p_DeltaPhiMin
parType_t p_DeltaPhiMin[2]
Definition
DeltaPhiIncl2.h:37
TCS::DeltaPhiIncl2::p_MinET2
parType_t p_MinET2[2]
Definition
DeltaPhiIncl2.h:40
TCS::DeltaPhiIncl2::~DeltaPhiIncl2
virtual ~DeltaPhiIncl2()
Definition
DeltaPhiIncl2.cxx:49
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
std
STL namespace.
Generated on
for ATLAS Offline Software by
1.17.0