ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigConfiguration
TrigConfStorage
src
BunchGroupLoader.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 "
./BunchGroupLoader.h
"
6
#include "
./DBHelper.h
"
7
8
#include "
TrigConfL1Data/BunchGroup.h
"
9
10
#include <iostream>
11
#include <stdexcept>
12
#include <typeinfo>
13
14
using namespace
std
;
15
16
bool
TrigConf::BunchGroupLoader::load
(
BunchGroup
& bgTarget) {
17
18
TRG_MSG_DEBUG
(
"Loading BunchGroup with ID = "
<< bgTarget.
id
());
19
20
try
{
21
startSession
();
22
if
(
isRun1
()) {
23
unique_ptr<coral::IQuery>
query
(
m_session
.nominalSchema().tableHandle(
"L1_BUNCH_GROUP"
).newQuery() );
24
query
->setRowCacheSize( 5 );
25
26
//Bind list
27
coral::AttributeList bindList;
28
bindList.extend<
long
>(
"bgId"
);
29
std::string cond =
"L1BG_ID = :bgId"
;
30
bindList[0].data<
long
>() = bgTarget.
id
();
31
query
->setCondition( cond, bindList );
32
33
//Output data and types
34
coral::AttributeList attList;
35
attList.extend<std::string>(
"L1BG_NAME"
);
36
attList.extend<
int
>(
"L1BG_VERSION"
);
37
fillQuery
(
query
.get(),attList);
38
39
coral::ICursor& cursor =
query
->execute();
40
41
if
( ! cursor.next() ) {
42
TRG_MSG_ERROR
(
"No bunchgroup exists with ID "
<< bgTarget.
id
());
43
commitSession
();
44
throw
std::runtime_error(
"BunchGroupLoader >> BunchGroup not available"
);
45
}
46
47
const
coral::AttributeList& row = cursor.currentRow();
48
std::string
name
= row[
"L1BG_NAME"
].data<std::string>();
49
int
version = row[
"L1BG_VERSION"
].data<
int
>();
50
51
// fill the object with data
52
bgTarget.
setName
(
name
);
53
bgTarget.
setVersion
( version );
54
}
55
56
57
{
58
// now touch the l1_bg_to_b table to get the bunches.
59
unique_ptr<coral::IQuery> q(
m_session
.nominalSchema().tableHandle(
"L1_BG_TO_B"
).newQuery() );
60
q->setRowCacheSize( 5 );
61
62
//binding
63
coral::AttributeList bindList;
64
bindList.extend<
long
>(
"bgId"
);
65
bindList[0].data<
long
>() = bgTarget.
id
();
66
q->setCondition(
"L1BG2B_BUNCH_GROUP_ID = :bgId"
, bindList );
67
68
//Output data and types
69
coral::AttributeList attList;
70
attList.extend<
int
>(
"L1BG2B_BUNCH_NUMBER"
);
71
fillQuery
(q.get(),attList);
72
73
coral::ICursor& cursor = q->execute();
74
75
while
( cursor.next() ) {
76
const
coral::AttributeList& row = cursor.currentRow();
77
bgTarget.
addBunch
( row[
"L1BG2B_BUNCH_NUMBER"
].data<int>() );
78
}
79
80
}
81
commitSession
();
82
}
83
catch
(
const
coral::Exception& e ) {
84
TRG_MSG_ERROR
(
"Coral::Exception: "
<< e.what());
85
m_session
.transaction().rollback();
86
throw
;
87
}
88
89
return
true
;
90
91
}
92
93
94
BunchGroupLoader.h
BunchGroup.h
DBHelper.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
TrigConf::BunchGroupLoader::load
virtual bool load(BunchGroup &data) override
Definition
BunchGroupLoader.cxx:16
TrigConf::BunchGroup
Definition
BunchGroup.h:17
TrigConf::BunchGroup::addBunch
void addBunch(int)
Definition
BunchGroup.cxx:17
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::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
query
Definition
query.py:1
std
STL namespace.
TrigConf::name
Definition
HLTChainList.h:35
Generated on
for ATLAS Offline Software by
1.17.0