ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigConfiguration
TrigConfStorage
src
MuctpiLoader.cxx
Go to the documentation of this file.
1
// Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
2
3
5
//
6
//NAME: MuctpiLoader.cpp
7
//PACKAGE: TrigConfStorage
8
//
9
//AUTHOR: J.Haller (CERN) Johannes.Haller@cern.ch
10
//CREATED: 31. Oct. 2005
11
//
12
//PURPOSE:
13
//UPDATED: 8 Dec 2008 Paul Bell for sqlite access
14
// (use of defineOutput method to set data types)
15
//
17
18
#include "
./MuctpiLoader.h
"
19
20
#include <CoralBase/Attribute.h>
21
#include <CoralBase/AttributeList.h>
22
23
#include "RelationalAccess/SchemaException.h"
24
#include "RelationalAccess/ITransaction.h"
25
#include "RelationalAccess/ITable.h"
26
#include "RelationalAccess/ICursor.h"
27
#include "RelationalAccess/IQuery.h"
28
#include "RelationalAccess/ISchema.h"
29
#include "RelationalAccess/ITableDescription.h"
30
31
#include "
TrigConfL1Data/Muctpi.h
"
32
33
#include <sstream>
34
#include <stdexcept>
35
#include <typeinfo>
36
37
bool
38
TrigConf::MuctpiLoader::load
(
Muctpi
& mTarget ) {
39
40
if
(
verbose
())
41
msg
() <<
"MuctpiLoader: Loading MuCTPi with ID = "
<< mTarget.
id
() <<
" and Lvl1 masterId = "
<< mTarget.
lvl1MasterTableId
() << std::endl;
42
try
{
43
startSession
();
44
if
( mTarget.
lvl1MasterTableId
() ) {
45
// get the muctpi id for this mastertable
46
long
muctpi_id = 0;
47
48
std::unique_ptr<coral::IQuery> query0(
m_session
.nominalSchema().tableHandle(
"L1_MASTER_TABLE"
).newQuery());
49
query0->setRowCacheSize( 5 );
50
51
//Bind list
52
coral::AttributeList bindList;
53
bindList.extend<
long
>(
"mtId"
);
54
std::string cond =
"L1MT_ID = :mtId"
;
55
bindList[0].data<
long
>() = mTarget.
lvl1MasterTableId
();
56
query0->setCondition( cond, bindList );
57
58
//Output data and types
59
coral::AttributeList attList;
60
attList.extend<
long
>(
"L1MT_MUCTPI_INFO_ID"
);
61
query0->defineOutput(attList);
62
query0->addToOutputList(
"L1MT_MUCTPI_INFO_ID"
);
63
64
coral::ICursor& cursor0 = query0->execute();
65
66
if
( ! cursor0.next() ) {
67
msg
() <<
"MuctpiLoader >> No such Master_Table exists "
<< mTarget.
lvl1MasterTableId
() << std::endl;
68
commitSession
();
69
throw
std::runtime_error(
"MuctpiLoader >> Muctpi_Info not available"
);
70
}
71
72
const
coral::AttributeList& row0 = cursor0.currentRow();
73
muctpi_id = row0[
"L1MT_MUCTPI_INFO_ID"
].data<
long
>();
74
75
if
( cursor0.next() ) {
76
msg
() <<
"MuctpiLoader >> More than one Muctpi_Info exists for this master_table id"
77
<< mTarget.
lvl1MasterTableId
() << std::endl;
78
commitSession
();
79
throw
std::runtime_error(
"MuctpiLoader >> Muctpi_Info not available"
);
80
}
81
mTarget.
setId
(muctpi_id);
82
}
83
84
std::unique_ptr<coral::IQuery>
query
(
m_session
.nominalSchema().tableHandle(
"L1_MUCTPI_INFO"
).newQuery());
85
query
->setRowCacheSize( 5 );
86
87
//Bind list
88
coral::AttributeList bindList2;
89
bindList2.extend<
long
>(
"miId"
);
90
std::string cond2 =
"L1MI_ID = :miId"
;
91
bindList2[0].data<
long
>() = mTarget.
id
();
92
query
->setCondition( cond2, bindList2 );
93
94
//Output data and types
95
coral::AttributeList attList;
96
attList.extend<
int
>(
"L1MI_VERSION"
);
97
attList.extend<std::string>(
"L1MI_NAME"
);
98
attList.extend<
int
>(
"L1MI_LOW_PT"
);
99
attList.extend<
int
>(
"L1MI_HIGH_PT"
);
100
attList.extend<
int
>(
"L1MI_MAX_CAND"
);
101
attList.extend<
long
>(
"L1MI_ID"
);
102
query
->defineOutput(attList);
103
104
query
->addToOutputList(
"L1MI_VERSION"
);
105
query
->addToOutputList(
"L1MI_NAME"
);
106
query
->addToOutputList(
"L1MI_LOW_PT"
);
107
query
->addToOutputList(
"L1MI_HIGH_PT"
);
108
query
->addToOutputList(
"L1MI_MAX_CAND"
);
109
query
->addToOutputList(
"L1MI_ID"
);
110
query
->addToOrderList(
"L1MI_ID"
);
111
112
coral::ICursor& cursor =
query
->execute();
113
if
( ! cursor.next() ) {
114
msg
() <<
"MuctpiLoader >> No such Muctpi_info exists "
<< mTarget.
id
() << std::endl;
115
commitSession
();
116
throw
std::runtime_error(
"MuctpiLoader >> Muctpi not available"
);
117
}
118
119
const
coral::AttributeList& row = cursor.currentRow();
120
std::string
name
= row[
"L1MI_NAME"
].data<std::string>();
121
int
version = row[
"L1MI_VERSION"
].data<
int
>();
122
int
low_pt = row[
"L1MI_LOW_PT"
].data<
int
>();
123
int
high_pt = row[
"L1MI_HIGH_PT"
].data<
int
>();
124
int
max_cand = row[
"L1MI_MAX_CAND"
].data<
int
>();
125
126
if
( cursor.next() ) {
127
msg
() <<
"MuctpiLoader >> More than one Muctpi exists "
<< mTarget.
id
() << std::endl;
128
commitSession
();
129
throw
std::runtime_error(
"MuctpiLoader >> Muctpi not available"
);
130
}
131
132
133
// Fill the object with data
134
mTarget.
setName
(
name
);
135
mTarget.
setVersion
( version );
136
mTarget.
setLowptThreshold
( low_pt );
137
mTarget.
setHighptThreshold
( high_pt );
138
mTarget.
setMaxCand
( max_cand );
139
commitSession
();
140
return
true
;
141
}
catch
(
const
coral::SchemaException& e ) {
142
msg
() <<
"MuctpiLoader >> SchemaException: "
<< e.what() << std::endl;
143
m_session
.transaction().rollback();
144
return
false
;
145
}
catch
(
const
std::exception& e ) {
146
msg
() <<
"MuctpiLoader >> Standard C++ exception: "
<< e.what() << std::endl;
147
m_session
.transaction().rollback();
148
return
false
;
149
150
}
catch
( ... ) {
151
msg
() <<
"MuctpiLoader >> unknown C++ exception"
<< std::endl;
152
m_session
.transaction().rollback();
153
return
false
;
154
}
155
}
MuctpiLoader.h
Muctpi.h
TrigConf::DBLoader::verbose
virtual int verbose() const override
Definition
DBLoader.h:56
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::L1DataBaseclass::lvl1MasterTableId
unsigned int lvl1MasterTableId() const
Definition
L1DataBaseclass.h:30
TrigConf::MuctpiLoader::load
virtual bool load(Muctpi &data) override
Definition
MuctpiLoader.cxx:38
TrigConf::Muctpi
Definition
Muctpi.h:12
TrigConf::Muctpi::setMaxCand
void setMaxCand(int m)
Definition
Muctpi.h:25
TrigConf::Muctpi::setLowptThreshold
void setLowptThreshold(int l)
Definition
Muctpi.h:23
TrigConf::Muctpi::setHighptThreshold
void setHighptThreshold(int h)
Definition
Muctpi.h:24
TrigConf::TrigConfData::id
unsigned int id() const
Definition
TrigConfData.h:21
TrigConf::TrigConfData::setId
void setId(unsigned int id)
Definition
TrigConfData.h:29
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
query
Definition
query.py:1
TrigConf::name
Definition
HLTChainList.h:35
Generated on
for ATLAS Offline Software by
1.17.0