ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
L1Topo
L1TopoAlgorithms
Root
TeAsymmetry.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
/*********************************
5
* TeAsymmetry.cpp
6
* Created by Jack Harrison on 12/05/25.
7
*
8
* @brief Based on the JIRA ticket: https://its.cern.ch/jira/browse/ATR-31097
9
* Three conditions are implemented:
10
* abs(jTE_A - jTE_C) > deltaAbsMin
11
* abs(jTE_A - jTE_C) > asymFactor * (jTE + asymOffset)
12
* jTE_A * jTE_C < maxTeProduct
13
*
14
* @param deltaAbsMin, asymFactor, asymOffset, maxTeProduct
15
**********************************/
16
17
18
#include <cmath>
19
20
#include "
L1TopoAlgorithms/TeAsymmetry.h
"
21
#include "
L1TopoCommon/Exception.h
"
22
#include "
L1TopoInterfaces/Decision.h
"
23
#include "
L1TopoEvent/jTETOBArray.h
"
24
25
REGISTER_ALG_TCS
(TeAsymmetry)
26
27
28
TCS
::
TeAsymmetry
::
TeAsymmetry
(
const
std
::
string
&
name
) :
DecisionAlg
(
name
)
29
{
30
31
defineParameter
(
"InputWidth"
, 1);
32
defineParameter
(
"MaxTob"
, 0);
33
defineParameter
(
"NumResultBits"
, 4);
34
defineParameter
(
"Delay"
, 1);
35
setNumberOutputBits
(4);
36
37
for
(
unsigned
int
i=0;i<
numberOutputBits
();i++){
38
// Algo parameters
39
defineParameter
(
"deltaAbsMin"
, 0, i);
40
defineParameter
(
"asymFactor"
, 0, i);
41
defineParameter
(
"asymOffset"
, 0, i);
42
defineParameter
(
"maxTeProduct"
, 0, i);
43
}
44
45
// Histo monitoring parameters
46
defineParameter
(
"MinSidejTE"
,0);
47
defineParameter
(
"MaxSidejTE"
,999);
48
49
}
50
51
TCS::TeAsymmetry::~TeAsymmetry
(){}
52
53
54
TCS::StatusCode
55
TCS::TeAsymmetry::initialize
() {
56
57
//Algo parameters
58
for
(
unsigned
int
i=0;i<
numberOutputBits
();i++){
59
p_deltaAbsMin
[i] =
parameter
(
"deltaAbsMin"
, i).value();
60
p_asymFactor
[i] =
parameter
(
"asymFactor"
, i).value();
61
p_asymOffset
[i] =
parameter
(
"asymOffset"
, i).value();
62
p_maxTeProduct
[i] =
parameter
(
"maxTeProduct"
, i).value();
63
}
64
65
// Histo monitoring
66
p_MinSidejTE
=
parameter
(
"MinSidejTE"
).value();
67
p_MaxSidejTE
=
parameter
(
"MaxSidejTE"
).value();
68
69
TRG_MSG_INFO
(
"number output : "
<<
numberOutputBits
());
70
71
// book histograms
72
for
(
unsigned
int
i=0; i<
numberOutputBits
(); ++i) {
73
std::string hname_accept =
"hTeAsymmetry_accept_bit"
+std::to_string((
int
)i);
74
std::string hname_reject =
"hTeAsymmetry_reject_bit"
+std::to_string((
int
)i);
75
bookHist
(
m_histAccept
, hname_accept,
"jTE SideA vs jTE SideC"
, 100,
p_MinSidejTE
,
p_MaxSidejTE
, 100,
p_MinSidejTE
,
p_MaxSidejTE
);
76
bookHist
(
m_histReject
, hname_reject,
"jTE SideA vs jTE SideC"
, 100,
p_MinSidejTE
,
p_MaxSidejTE
, 100,
p_MinSidejTE
,
p_MaxSidejTE
);
77
}
78
79
return
StatusCode::SUCCESS
;
80
}
81
82
83
TCS::StatusCode
84
TCS::TeAsymmetry::processBitCorrect
(
const
std::vector<TCS::TOBArray const *> & input,
85
const
std::vector<TCS::TOBArray *> & output,
86
Decision
& decision )
87
{
88
if
(input.size() == 1) {
89
90
if
(input[0]->
size
()!=1) {
91
TCS_EXCEPTION
(
"TeAsymmetry alg needs input list with a single jTE TOB, got "
<< input[0]->
size
());
92
}
93
94
for
(
TOBArray::const_iterator
jte = input[0]->begin();
95
jte != input[0]->end();
96
++jte)
97
{
98
99
for
(
unsigned
int
i=0; i<
numberOutputBits
(); ++i) {
100
101
bool
accept =
false
;
102
103
// Cast to long to avoid overflow
104
long
long
jteSideA = (*jte)->sumEtSideA();
105
long
long
jteSideC = (*jte)->sumEtSideC();
106
107
//std::cout << "jTE SideA: " << jteSideA << ", jTE SideC: " << jteSideC << " , " << p_deltaAbsMin[i] << " , " << abs(jteSideA - jteSideC) << std::endl;
108
109
bool
condition_1 = std::abs(jteSideA - jteSideC) >
p_deltaAbsMin
[i];
110
111
//std::cout << "Condition 1: " << condition_1 << std::endl;
112
//attention: some of these values are to be interpreted as signed,
113
//but also need to explicitly cast unsigned quantities to have correct results
114
static
constexpr
unsigned
c2fractionalBits = 8;
// 8 fractional bits in p_asymFactor
115
int
offsetSumEt =
static_cast<
int
>
((*jte)->sumEt()) +
static_cast<
int
>
(
p_asymOffset
[i]);
116
bool
condition_2 = std::abs(jteSideA - jteSideC) > ((
static_cast<
long
long
>
(
p_asymFactor
[i]) * offsetSumEt ) >> c2fractionalBits);
117
//std::cout << "Condition 2: " << condition_2 << std::endl;
118
bool
condition_3 = jteSideA * jteSideC <
p_maxTeProduct
[i];
119
//std::cout << "Condition 3: " << condition_3 << std::endl;
120
121
//Write out to the output bit
122
accept = condition_1 && condition_2 && condition_3;
123
//std::cout << "Accept: " << accept << std::endl;
124
125
126
const
bool
fillAccept =
fillHistos
() and (
fillHistosBasedOnHardware
() ?
getDecisionHardwareBit
(i) : accept);
127
const
bool
fillReject =
fillHistos
() and not fillAccept;
128
const
bool
alreadyFilled = decision.
bit
(i);
129
130
TRG_MSG_DEBUG
(
"Decision "
<< i <<
": "
<< (accept?
"pass"
:
"fail"
) <<
" jTE_A = "
<< (*jte)->sumEtSideA() <<
" , jTE_C = "
<< (*jte)->sumEtSideC());
131
132
if
( accept ) {
133
decision.
setBit
(i,
true
);
134
output[i]->push_back(
TCS::CompositeTOB
(*jte) );
135
}
136
if
(fillAccept and not alreadyFilled) {
137
fillHist2D
(
m_histAccept
[i], jteSideA, jteSideC);
138
}
else
if
(fillReject) {
139
fillHist2D
(
m_histReject
[i], jteSideA, jteSideC);
140
}
141
}
142
}
143
return
TCS::StatusCode::SUCCESS
;
144
}
else
{
145
TCS_EXCEPTION
(
"TeAsymmetry alg must have 1 input, but got "
<< input.size());
146
}
147
}
148
149
TCS::StatusCode
150
TCS::TeAsymmetry::process
(
const
std::vector<TCS::TOBArray const *> & input,
151
const
std::vector<TCS::TOBArray *> & output,
152
Decision
& decision )
153
{
154
return
processBitCorrect
(input, output, decision);
155
}
REGISTER_ALG_TCS
#define REGISTER_ALG_TCS(CLASS)
Definition
AlgFactory.h:62
Decision.h
size
size_t size() const
Number of registered mappings.
TeAsymmetry.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
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::StatusCode
Definition
Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:15
TCS::StatusCode::SUCCESS
@ SUCCESS
Definition
Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/StatusCode.h:17
TCS::TeAsymmetry::p_asymFactor
parType_t p_asymFactor[4]
Definition
TeAsymmetry.h:41
TCS::TeAsymmetry::initialize
virtual StatusCode initialize()
Definition
TeAsymmetry.cxx:55
TCS::TeAsymmetry::processBitCorrect
virtual StatusCode processBitCorrect(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition
TeAsymmetry.cxx:84
TCS::TeAsymmetry::process
virtual StatusCode process(const std::vector< TCS::TOBArray const * > &input, const std::vector< TCS::TOBArray * > &output, Decision &decison)
Definition
TeAsymmetry.cxx:150
TCS::TeAsymmetry::p_MinSidejTE
parType_t p_MinSidejTE
Definition
TeAsymmetry.h:38
TCS::TeAsymmetry::p_MaxSidejTE
parType_t p_MaxSidejTE
Definition
TeAsymmetry.h:39
TCS::TeAsymmetry::~TeAsymmetry
virtual ~TeAsymmetry()
Definition
TeAsymmetry.cxx:51
TCS::TeAsymmetry::p_maxTeProduct
parType_t p_maxTeProduct[4]
Definition
TeAsymmetry.h:43
TCS::TeAsymmetry::p_deltaAbsMin
parType_t p_deltaAbsMin[4]
Definition
TeAsymmetry.h:40
TCS::TeAsymmetry::p_asymOffset
parType_t p_asymOffset[4]
Definition
TeAsymmetry.h:42
TCS::TeAsymmetry::TeAsymmetry
TeAsymmetry(const std::string &name)
Definition
TeAsymmetry.cxx:28
jTETOBArray.h
const
TCS
Definition
AnomalyDetectionBDT.h:18
std
STL namespace.
Generated on
for ATLAS Offline Software by
1.17.0