ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigConfiguration
TrigConfStorage
src
RandomLoader.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
./RandomLoader.h
"
6
#include "
./DBHelper.h
"
7
#include "
TrigConfL1Data/Random.h
"
8
9
#include <iostream>
10
#include <stdexcept>
11
#include <typeinfo>
12
13
using namespace
std
;
14
15
bool
TrigConf::RandomLoader::load
(
Random
& rdTarget ) {
16
17
TRG_MSG_INFO
(
"Start loading data with ID = "
<< rdTarget.
id
());
18
19
try
{
20
startSession
();
21
22
unique_ptr<coral::IQuery> q(
m_session
.nominalSchema().tableHandle(
"L1_RANDOM"
).newQuery());
23
q->setRowCacheSize( 5 );
24
25
coral::AttributeList bindList;
26
bindList.extend<
long
>(
"rdId"
);
27
bindList[0].data<
long
>() = rdTarget.
id
();
28
29
q->setCondition(
"L1R_ID = :rdId"
, bindList );
30
31
//Output data and types
32
coral::AttributeList attList;
33
if
(
isRun1
()) {
34
attList.extend<std::string>(
"L1R_NAME"
);
35
attList.extend<
int
>(
"L1R_VERSION"
);
36
attList.extend<
long
>(
"L1R_RATE1"
);
37
attList.extend<
long
>(
"L1R_RATE2"
);
38
}
else
{
39
attList.extend<
string
>(
"L1R_CUT0"
);
40
attList.extend<
string
>(
"L1R_CUT1"
);
41
attList.extend<
string
>(
"L1R_CUT2"
);
42
attList.extend<
string
>(
"L1R_CUT3"
);
43
}
44
fillQuery
(q.get(), attList);
45
46
coral::ICursor& cursor = q->execute();
47
48
if
( ! cursor.next() ) {
49
TRG_MSG_ERROR
(
"No such random exists "
<< rdTarget.
id
());
50
commitSession
();
51
throw
std::runtime_error(
"RandomLoader >> Random not available"
);
52
}
53
54
const
coral::AttributeList& row = cursor.currentRow();
55
if
(
isRun1
()) {
56
std::string
name
= row[
"L1R_NAME"
].data<std::string>();
57
int
version = row[
"L1R_VERSION"
].data<
int
>();
58
long
rate1 = row[
"L1R_RATE1"
].data<
long
>();
59
long
rate2 = row[
"L1R_RATE2"
].data<
long
>();
60
// Fill the object with data
61
rdTarget.
setName
(
name
);
62
rdTarget.
setVersion
( version );
63
rdTarget.
setRate1
( rate1 );
64
rdTarget.
setRate2
( rate2 );
65
}
else
{
66
string
cut0 = row[
"L1R_CUT0"
].data<
string
>();
67
string
cut1 = row[
"L1R_CUT1"
].data<
string
>();
68
string
cut2 = row[
"L1R_CUT2"
].data<
string
>();
69
string
cut3 = row[
"L1R_CUT3"
].data<
string
>();
70
// Fill the object with data
71
rdTarget.
setCut
(0,
static_cast<
uint32_t
>
(std::stoul(cut0)));
72
rdTarget.
setCut
(1,
static_cast<
uint32_t
>
(std::stoul(cut1)));
73
rdTarget.
setCut
(2,
static_cast<
uint32_t
>
(std::stoul(cut2)));
74
rdTarget.
setCut
(3,
static_cast<
uint32_t
>
(std::stoul(cut3)));
75
}
76
77
if
( cursor.next() ) {
78
TRG_MSG_ERROR
(
"More than one Random exists "
<< rdTarget.
id
());
79
commitSession
();
80
throw
std::runtime_error(
"RandomLoader >> Random not available"
);
81
}
82
83
commitSession
();
84
return
true
;
85
}
86
catch
(
const
coral::Exception& e ) {
87
TRG_MSG_ERROR
(
"Coral::Exception: "
<< e.what());
88
m_session
.transaction().rollback();
89
throw
;
90
}
91
}
DBHelper.h
RandomLoader.h
Random.h
TRG_MSG_INFO
#define TRG_MSG_INFO(x)
Definition
Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:27
TRG_MSG_ERROR
#define TRG_MSG_ERROR(x)
Definition
Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:29
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::isRun1
bool isRun1()
Definition
DBLoader.h:59
TrigConf::DBLoader::startSession
void startSession()
start session if not already active
Definition
DBLoader.cxx:36
TrigConf::RandomLoader::load
virtual bool load(Random &data) override
Definition
RandomLoader.cxx:15
TrigConf::Random
Definition
TrigConfiguration/TrigConfL1Data/TrigConfL1Data/Random.h:16
TrigConf::Random::setRate1
void setRate1(int rate)
Definition
TrigConfiguration/TrigConfL1Data/TrigConfL1Data/Random.h:31
TrigConf::Random::setCut
void setCut(uint32_t idx, uint32_t cut)
Definition
TrigConfiguration/TrigConfL1Data/TrigConfL1Data/Random.h:30
TrigConf::Random::setRate2
void setRate2(int rate)
Definition
TrigConfiguration/TrigConfL1Data/TrigConfL1Data/Random.h:32
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::fillQuery
void fillQuery(coral::IQuery *q, coral::AttributeList &attList)
Definition
DBHelper.cxx:13
std
STL namespace.
TrigConf::name
Definition
HLTChainList.h:35
Generated on
for ATLAS Offline Software by
1.17.0