ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigConfiguration
TrigConfStorage
src
TriggerThresholdValueLoader.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
//
7
//NAME: TriggerThresholdValueLoader.cpp
8
//PACKAGE: TrigConfStorage
9
//
10
//AUTHOR: J.Haller (CERN) Johannes.Haller@cern.ch
11
//CREATED: 31. Oct. 2005
12
//
13
//PURPOSE:
14
//
15
//UPDATED: 8 Dec 2008 Paul Bell for sqlite access
16
// (use of defineOutput method to set data type)
17
//
19
20
#include "
./TriggerThresholdValueLoader.h
"
21
22
#include <CoralBase/Attribute.h>
23
#include <CoralBase/AttributeList.h>
24
25
#include "RelationalAccess/SchemaException.h"
26
#include "RelationalAccess/ITransaction.h"
27
#include "RelationalAccess/ITable.h"
28
#include "RelationalAccess/ISchema.h"
29
#include "RelationalAccess/ICursor.h"
30
#include "RelationalAccess/IQuery.h"
31
32
#include "
TrigConfL1Data/ClusterThresholdValue.h
"
33
#include "
TrigConfL1Data/JetThresholdValue.h
"
34
#include "
TrigConfL1Data/MuonThresholdValue.h
"
35
#include "
TrigConfL1Data/TriggerThresholdValue.h
"
36
#include "
TrigConfL1Data/L1DataDef.h
"
37
#include "
TrigConfL1Data/HelperFunctions.h
"
38
39
#include <iostream>
40
#include <stdexcept>
41
#include <typeinfo>
42
43
using namespace
std
;
44
45
bool
46
TrigConf::TriggerThresholdValueLoader::load
(
TriggerThresholdValue
& ttvTarget ) {
47
TRG_MSG_DEBUG
(
"TriggerThresholdValueLoader loading thresholdvalue with ID = "
<< ttvTarget.
id
());
48
L1DataDef
def;
49
50
string
name
=
""
;
51
string
type
=
""
;
52
int
version = 0;
53
float
ptcut = 0;
54
float
priority=0;
55
int
phimin = 0;
56
int
phimax = 0;
57
int
etamin = 0;
58
int
etamax = 0;
59
string
emisolation =
""
;
60
string
hadisolation =
""
;
61
string
hadveto =
""
;
62
int
window = 0;
63
64
try
{
65
//unsigned int schema = triggerDBSchemaVersion();
66
67
startSession
();
68
69
coral::ITable& table =
m_session
.nominalSchema().tableHandle(
"L1_TRIGGER_THRESHOLD_VALUE"
);
70
coral::IQuery*
query
= table.newQuery();
71
query
->setRowCacheSize( 5 );
72
73
//Bind list
74
coral::AttributeList bindList;
75
bindList.extend<
long
>(
"ttvId"
);
76
std::string cond=
"L1TTV_ID = :ttvId"
;
77
bindList[0].data<
long
>() = ttvTarget.
id
();
78
query
->setCondition( cond, bindList );
79
80
//Define the data types
81
coral::AttributeList attList;
82
attList.extend<std::string>(
"L1TTV_NAME"
);
83
attList.extend<
int
>(
"L1TTV_VERSION"
);
84
attList.extend<std::string>(
"L1TTV_TYPE"
);
85
attList.extend<std::string>(
"L1TTV_PT_CUT"
);
86
attList.extend<
int
>(
"L1TTV_ETA_MIN"
);
87
attList.extend<
int
>(
"L1TTV_ETA_MAX"
);
88
attList.extend<
int
>(
"L1TTV_PHI_MIN"
);
89
attList.extend<
int
>(
"L1TTV_PHI_MAX"
);
90
attList.extend<std::string>(
"L1TTV_EM_ISOLATION"
);
91
attList.extend<std::string>(
"L1TTV_HAD_ISOLATION"
);
92
attList.extend<std::string>(
"L1TTV_HAD_VETO"
);
93
attList.extend<
int
>(
"L1TTV_WINDOW"
);
94
attList.extend<std::string>(
"L1TTV_PRIORITY"
);
95
query
->defineOutput(attList);
96
query
->addToOutputList(
"L1TTV_NAME"
);
97
query
->addToOutputList(
"L1TTV_VERSION"
);
98
query
->addToOutputList(
"L1TTV_TYPE"
);
99
query
->addToOutputList(
"L1TTV_PT_CUT"
);
100
query
->addToOutputList(
"L1TTV_ETA_MIN"
);
101
query
->addToOutputList(
"L1TTV_ETA_MAX"
);
102
query
->addToOutputList(
"L1TTV_PHI_MIN"
);
103
query
->addToOutputList(
"L1TTV_PHI_MAX"
);
104
query
->addToOutputList(
"L1TTV_EM_ISOLATION"
);
105
query
->addToOutputList(
"L1TTV_HAD_ISOLATION"
);
106
query
->addToOutputList(
"L1TTV_HAD_VETO"
);
107
query
->addToOutputList(
"L1TTV_WINDOW"
);
108
query
->addToOutputList(
"L1TTV_PRIORITY"
);
109
110
coral::ICursor& cursor =
query
->execute();
111
if
( !cursor.next()) {
112
msg
() <<
"TriggerThresholdValueLoader >> No such TriggerThresholdValue exists "
113
<< ttvTarget.
id
() << std::endl;
114
delete
query
;
115
commitSession
();
116
throw
std::runtime_error(
"TriggerThresholdValueLoader >> TriggerThresholdValue not available"
);
117
}
118
119
const
coral::AttributeList& row = cursor.currentRow();
120
121
name
= row[
"L1TTV_NAME"
].data<std::string>();
122
version = row[
"L1TTV_VERSION"
].data<
int
>();
123
type
= row[
"L1TTV_TYPE"
].data<std::string>();
124
ptcut = std::stof(row[
"L1TTV_PT_CUT"
].data<std::string>());
125
etamin = row[
"L1TTV_ETA_MIN"
].data<
int
>();
126
etamax = row[
"L1TTV_ETA_MAX"
].data<
int
>();
127
phimin = row[
"L1TTV_PHI_MIN"
].data<
int
>();
128
phimax = row[
"L1TTV_PHI_MAX"
].data<
int
>();
129
window = row[
"L1TTV_WINDOW"
].data<
int
>();
130
priority = std::stof(row[
"L1TTV_PRIORITY"
].data<std::string>());
131
emisolation = row[
"L1TTV_EM_ISOLATION"
].data<std::string>();
132
hadisolation = row[
"L1TTV_HAD_ISOLATION"
].data<std::string>();
133
hadveto = row[
"L1TTV_HAD_VETO"
].data<std::string>();
134
135
136
if
(cursor.next()) {
137
msg
() <<
"TriggerThresholdValueLoader >> More than one TriggerThresholdValue exists "
138
<< ttvTarget.
id
() << std::endl;
139
delete
query
;
140
commitSession
();
141
throw
std::runtime_error(
"TriggerThresholdValueLoader >> TriggerThresholdValue not available"
);
142
}
143
144
// Fill the value common for all threshold_value
145
ttvTarget.
setName
(
name
);
146
ttvTarget.
setVersion
( version );
147
ttvTarget.
setType
(
type
);
148
ttvTarget.
setPtcut
( ptcut );
149
ttvTarget.
setPriority
(priority);
150
delete
query
;
151
commitSession
();
152
//msg() << name << std::endl;
153
154
}
155
catch
(
const
coral::Exception& e ) {
156
TRG_MSG_ERROR
(
"Caught coral exception: "
<< e.what() );
157
throw
;
158
}
159
catch
(
const
std::exception& e ) {
160
TRG_MSG_ERROR
(
"Caught standard exception: "
<< e.what() );
161
throw
;
162
}
163
164
try
{
165
ClusterThresholdValue
& ctvTarget =
dynamic_cast<
ClusterThresholdValue
&
>
(ttvTarget);
166
if
(
type
!= def.
typeAsString
(
L1DataDef::EM
) &&
type
!= def.
typeAsString
(
L1DataDef::TAU
) ) {
167
msg
() <<
"TriggerThresholdValueLoader >> No type match for ttv_id = "
168
<< ctvTarget.
id
() <<
" "
<<
type
<< std::endl;
169
throw
std::runtime_error(
"TriggerThresholdValueLoader >> ClusterThresholdValue not available"
);
170
}
171
172
cout <<
"ISO "
<< emisolation <<
" "
<< hadisolation <<
" "
<< hadveto << endl;
173
174
if
(hadveto==
"USEISOBITS"
|| std::stoi(hadveto)==99 ) {
175
ctvTarget.
setIsolationMask
(
TrigConf::bin2uint
(emisolation) );
176
ctvTarget.
setUseIsolationMask
();
177
}
else
{
178
ctvTarget.
setEmIsolation
( std::stof(emisolation) );
179
ctvTarget.
setHadIsolation
( std::stof(hadisolation) );
180
ctvTarget.
setHadVeto
( std::stof(hadveto) );
181
ctvTarget.
setUseIsolationMask
(
false
);
182
}
183
184
185
ctvTarget.
setPhiMin
( phimin);
186
ctvTarget.
setPhiMax
( phimax);
187
ctvTarget.
setEtaMin
( etamin );
188
ctvTarget.
setEtaMax
( etamax );
189
}
catch
(std::bad_cast& ex) { }
190
191
//is it a jet_threshold_value?
192
try
{
193
JetThresholdValue
& jtvTarget =
dynamic_cast<
JetThresholdValue
&
>
(ttvTarget);
194
195
if
(
type
!=def.
typeAsString
(
L1DataDef::JET
) &&
196
type
!=def.
typeAsString
(
L1DataDef::JB
) &&
197
type
!=def.
typeAsString
(
L1DataDef::JF
)) {
198
msg
() <<
"TriggerThresholdValueLoader >> No type match for ttv_id = "
199
<< jtvTarget.
id
() <<
type
<< std::endl;
200
throw
std::runtime_error(
"TriggerThresholdValueLoader >> TriggerThresholdValue not available"
);
201
}
202
jtvTarget.
setPhiMin
( phimin );
203
jtvTarget.
setPhiMax
( phimax );
204
jtvTarget.
setEtaMin
( etamin );
205
jtvTarget.
setEtaMax
( etamax );
206
jtvTarget.
setWindow
( window );
207
}
catch
(std::bad_cast& ex) {}
208
209
return
true
;
210
}
ClusterThresholdValue.h
JetThresholdValue.h
L1DataDef.h
MuonThresholdValue.h
TriggerThresholdValueLoader.h
TriggerThresholdValue.h
TRG_MSG_DEBUG
#define TRG_MSG_DEBUG(x)
Definition
Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:25
TRG_MSG_ERROR
#define TRG_MSG_ERROR(x)
Definition
Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:29
HelperFunctions.h
TrigConf::ClusterThresholdValue
Definition
ClusterThresholdValue.h:13
TrigConf::ClusterThresholdValue::setHadIsolation
void setHadIsolation(float v)
Definition
ClusterThresholdValue.h:39
TrigConf::ClusterThresholdValue::setHadVeto
void setHadVeto(float v)
Definition
ClusterThresholdValue.h:40
TrigConf::ClusterThresholdValue::setEmIsolation
void setEmIsolation(float v)
Definition
ClusterThresholdValue.h:38
TrigConf::ClusterThresholdValue::setUseIsolationMask
void setUseIsolationMask(bool use=true)
Definition
ClusterThresholdValue.h:43
TrigConf::ClusterThresholdValue::setIsolationMask
void setIsolationMask(uint16_t mask)
Definition
ClusterThresholdValue.h:46
TrigConf::DBLoader::commitSession
void commitSession()
commit session if not already done
Definition
DBLoader.cxx:45
TrigConf::DBLoader::m_session
coral::ISessionProxy & m_session
CORAL interface to database session.
Definition
DBLoader.h:67
TrigConf::DBLoader::startSession
void startSession()
start session if not already active
Definition
DBLoader.cxx:36
TrigConf::JetThresholdValue
Definition
JetThresholdValue.h:12
TrigConf::L1DataDef
Definition
L1DataDef.h:16
TrigConf::L1DataDef::JB
@ JB
Definition
L1DataDef.h:21
TrigConf::L1DataDef::JET
@ JET
Definition
L1DataDef.h:21
TrigConf::L1DataDef::JF
@ JF
Definition
L1DataDef.h:21
TrigConf::L1DataDef::TAU
@ TAU
Definition
L1DataDef.h:20
TrigConf::L1DataDef::EM
@ EM
Definition
L1DataDef.h:20
TrigConf::L1DataDef::typeAsString
static std::string & typeAsString(TriggerType tt)
Definition
L1DataDef.h:53
TrigConf::TrigConfData::id
unsigned int id() const
Definition
TrigConfData.h:21
TrigConf::TrigConfData::setName
void setName(const std::string &name)
Definition
TrigConfData.h:30
TrigConf::TrigConfData::setVersion
void setVersion(unsigned int version)
Definition
TrigConfData.h:31
TrigConf::TrigConfMessaging::msg
MsgStreamTC & msg() const
The standard message stream.
Definition
TrigConfMessaging.h:86
TrigConf::TriggerThresholdValueLoader::load
virtual bool load(TriggerThresholdValue &data) override
Definition
TriggerThresholdValueLoader.cxx:46
TrigConf::TriggerThresholdValue
Definition
TriggerThresholdValue.h:22
TrigConf::TriggerThresholdValue::setPtcut
void setPtcut(float pt)
Definition
TriggerThresholdValue.h:58
TrigConf::TriggerThresholdValue::setEtaMax
void setEtaMax(int value)
Definition
TriggerThresholdValue.h:64
TrigConf::TriggerThresholdValue::setWindow
void setWindow(int value)
Definition
TriggerThresholdValue.h:60
TrigConf::TriggerThresholdValue::setPriority
void setPriority(float prio)
Definition
TriggerThresholdValue.h:59
TrigConf::TriggerThresholdValue::setType
void setType(const std::string &type)
Definition
TriggerThresholdValue.h:57
TrigConf::TriggerThresholdValue::setPhiMin
void setPhiMin(int value)
Definition
TriggerThresholdValue.h:61
TrigConf::TriggerThresholdValue::setPhiMax
void setPhiMax(int value)
Definition
TriggerThresholdValue.h:62
TrigConf::TriggerThresholdValue::setEtaMin
void setEtaMin(int value)
Definition
TriggerThresholdValue.h:63
TrigConf::bin2uint
uint32_t bin2uint(const std::string &binary)
Definition
Trigger/TrigConfiguration/TrigConfL1Data/Root/HelperFunctions.cxx:314
query
Definition
query.py:1
std
STL namespace.
type
TrigConf::name
Definition
HLTChainList.h:35
Generated on
for ATLAS Offline Software by
1.17.0