ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigConfiguration
TrigConfStorage
src
DeadTimeLoader.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
//
7
//NAME: DeadTimeLoader.cpp
8
//PACKAGE: TTrigConfStorage
9
//
10
//AUTHOR: J.Haller (CERN) Johannes.Haller@cern.ch
11
//CREATED: 31. Oct. 2005
12
//
13
//PURPOSE:
14
//UPDATED: 8 Dec 2008 Paul Bell for sqlite access
15
// (use of defineOutput method to set data type)
16
//
18
19
#include "
./DeadTimeLoader.h
"
20
21
#include <CoralBase/Attribute.h>
22
#include <CoralBase/AttributeList.h>
23
24
#include "RelationalAccess/SchemaException.h"
25
#include "RelationalAccess/ITransaction.h"
26
#include "RelationalAccess/ITable.h"
27
#include "RelationalAccess/ISchema.h"
28
#include "RelationalAccess/ICursor.h"
29
#include "RelationalAccess/IQuery.h"
30
31
#include "
TrigConfL1Data/DeadTime.h
"
32
33
#include <iostream>
34
#include <stdexcept>
35
#include <typeinfo>
36
37
using
std::string;
38
39
bool
TrigConf::DeadTimeLoader::load
(
DeadTime
& dtTarget) {
40
if
(
verbose
())
41
msg
() <<
"DeadTimeLoader: Start loading data via ID. ID="
<< dtTarget.
id
() << std::endl;
42
43
try
{
44
startSession
();
45
46
coral::ITable& table =
m_session
.nominalSchema().tableHandle(
"L1_DEAD_TIME"
);
47
coral::IQuery*
query
= table.newQuery();
48
query
->setRowCacheSize( 5 );
49
50
//Bind list
51
coral::AttributeList bindList;
52
bindList.extend<
long
>(
"dtId"
);
53
std::string cond =
"L1DT_ID = :dtId"
;
54
bindList[0].data<
long
>() = dtTarget.
id
();
55
query
->setCondition( cond, bindList );
56
57
//Output data and types
58
coral::AttributeList attList;
59
attList.extend<
int
>(
"L1DT_VERSION"
);
60
attList.extend<
string
>(
"L1DT_NAME"
);
61
attList.extend<
int
>(
"L1DT_SIMPLE"
);
62
attList.extend<
int
>(
"L1DT_COMPLEX1_LEVEL"
);
63
attList.extend<
int
>(
"L1DT_COMPLEX1_RATE"
);
64
attList.extend<
int
>(
"L1DT_COMPLEX2_LEVEL"
);
65
attList.extend<
int
>(
"L1DT_COMPLEX2_RATE"
);
66
attList.extend<
long
>(
"L1DT_ID"
);
67
query
->defineOutput(attList);
68
69
query
->addToOutputList(
"L1DT_VERSION"
);
70
query
->addToOutputList(
"L1DT_NAME"
);
71
query
->addToOutputList(
"L1DT_SIMPLE"
);
72
query
->addToOutputList(
"L1DT_COMPLEX1_LEVEL"
);
73
query
->addToOutputList(
"L1DT_COMPLEX1_RATE"
);
74
query
->addToOutputList(
"L1DT_COMPLEX2_LEVEL"
);
75
query
->addToOutputList(
"L1DT_COMPLEX2_RATE"
);
76
query
->addToOutputList(
"L1DT_ID"
);
77
query
->addToOrderList(
"L1DT_ID"
);
78
79
coral::ICursor& cursor =
query
->execute();
80
81
if
( ! cursor.next() ) {
82
msg
() <<
"DeadTimeLoader >> No such deadtime exists "
<< dtTarget.
id
() << std::endl;
83
delete
query
;
84
commitSession
();
85
throw
std::runtime_error(
"DeadTimeLoader >> DeadTime not available"
);
86
}
87
88
const
coral::AttributeList& row = cursor.currentRow();
89
std::string
name
= row[
"L1DT_NAME"
].data<std::string>();
90
int
version = row[
"L1DT_VERSION"
].data<
int
>();
91
int
simple = row[
"L1DT_SIMPLE"
].data<
int
>();
92
int
complex1_level = row[
"L1DT_COMPLEX1_LEVEL"
].data<
int
>();
93
int
complex1_rate = row[
"L1DT_COMPLEX1_RATE"
].data<
int
>();
94
int
complex2_level = row[
"L1DT_COMPLEX2_LEVEL"
].data<
int
>();
95
int
complex2_rate = row[
"L1DT_COMPLEX2_RATE"
].data<
int
>();
96
97
if
( cursor.next() ) {
98
msg
() <<
"DeadTimeLoader >> More than one DeadTime exists "
99
<< dtTarget.
id
() << std::endl;
100
commitSession
();
101
throw
std::runtime_error(
"DeadTimeLoader >> DeadTime not available"
);
102
}
103
104
// fill the object with data
105
dtTarget.
setName
(
name
);
106
dtTarget.
setVersion
( version );
107
dtTarget.
setSimple
( simple );
108
dtTarget.
setComplex1Level
( complex1_level );
109
dtTarget.
setComplex1Rate
( complex1_rate );
110
dtTarget.
setComplex2Level
( complex2_level );
111
dtTarget.
setComplex2Rate
( complex2_rate );
112
113
delete
query
;
114
commitSession
();
115
return
true
;
116
}
catch
(
const
coral::SchemaException& e ) {
117
msg
() <<
"DeadTimeLoader >> SchemaException: "
118
<< e.what() << std::endl;
119
m_session
.transaction().rollback();
120
return
false
;
121
}
catch
(
const
std::exception& e ) {
122
msg
() <<
"DeadTimeLoader >> Standard C++ exception: "
<< e.what() << std::endl;
123
m_session
.transaction().rollback();
124
return
false
;
125
}
catch
( ... ) {
126
msg
() <<
"DeadTimeLoader >> Unknown C++ exception"
<< std::endl;
127
m_session
.transaction().rollback();
128
return
false
;
129
}
130
131
}
132
DeadTimeLoader.h
DeadTime.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::DeadTimeLoader::load
virtual bool load(DeadTime &data) override
Definition
DeadTimeLoader.cxx:39
TrigConf::DeadTime
Definition
DeadTime.h:13
TrigConf::DeadTime::setComplex1Rate
void setComplex1Rate(int i)
Definition
DeadTime.h:28
TrigConf::DeadTime::setComplex2Rate
void setComplex2Rate(int i)
Definition
DeadTime.h:30
TrigConf::DeadTime::setComplex2Level
void setComplex2Level(int i)
Definition
DeadTime.h:29
TrigConf::DeadTime::setComplex1Level
void setComplex1Level(int i)
Definition
DeadTime.h:27
TrigConf::DeadTime::setSimple
void setSimple(int i)
Definition
DeadTime.h:26
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
query
Definition
query.py:1
TrigConf::name
Definition
HLTChainList.h:35
Generated on
for ATLAS Offline Software by
1.17.0