ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigConfiguration
TrigConfStorage
src
BunchGroupSetLoader.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 "
./BunchGroupSetLoader.h
"
6
#include "
./BunchGroupLoader.h
"
7
#include "
./DBHelper.h
"
8
#include "
TrigConfStorage/StorageMgr.h
"
9
#include "
TrigConfL1Data/BunchGroupSet.h
"
10
11
#include <iostream>
12
#include <stdexcept>
13
#include <typeinfo>
14
15
using namespace
std
;
16
17
bool
18
TrigConf::BunchGroupSetLoader::load
(
BunchGroupSet
& data ) {
19
20
TRG_MSG_INFO
(
"Loading BunchGroupSet with ID = "
<< data.id());
21
try
{
22
23
{
24
startSession
();
25
unique_ptr<coral::IQuery> q(
m_session
.nominalSchema().tableHandle(
"L1_BUNCH_GROUP_SET"
).newQuery());
26
q->setRowCacheSize( 5 );
27
28
//Bind list
29
coral::AttributeList bindList;
30
bindList.extend<
int
>(
"bgsId"
);
31
bindList[0].data<
int
>() = (
int
)data.id();
32
q->setCondition(
"L1BGS_ID = :bgsId"
, bindList );
33
34
//Output data and types
35
coral::AttributeList attList;
36
attList.extend<std::string>(
"L1BGS_NAME"
);
37
attList.extend<
int
>(
"L1BGS_VERSION"
);
38
attList.extend<std::string>(
"L1BGS_COMMENT"
);
39
fillQuery
(q.get(),attList);
40
41
coral::ICursor& cursor = q->execute();
42
43
if
( ! cursor.next() ) {
44
TRG_MSG_ERROR
(
"No such BGS exists "
<< data.id());
45
commitSession
();
46
throw
std::runtime_error(
"BunchGroupSetLoader >> BunchGroupSet not available"
);
47
}
48
49
const
coral::AttributeList& row = cursor.currentRow();
50
string
name
= row[
"L1BGS_NAME"
].data<std::string>();
51
int
version = row[
"L1BGS_VERSION"
].data<
int
>();
52
string
comment = row[
"L1BGS_COMMENT"
].data<std::string>();
53
54
if
( cursor.next() ) {
55
TRG_MSG_ERROR
(
"More than one BunchGroupSet exists "
<< data.id());
56
commitSession
();
57
throw
std::runtime_error(
"BunchGroupSetLoader >> BunchGroupSet not available"
);
58
}
59
60
// fill the object with data
61
data.setName(
name
);
62
data.setVersion( version );
63
data.setComment( comment );
64
}
65
66
// now touch the l1_bgs_to_bg table to get the bunch groups.
67
{
68
unique_ptr<coral::IQuery> q(
m_session
.nominalSchema().tableHandle(
"L1_BGS_TO_BG"
).newQuery() );
69
q->setRowCacheSize( 5 );
70
71
//binding
72
coral::AttributeList bindList;
73
bindList.extend<
int
>(
"bgsId"
);
74
bindList[0].data<
int
>() = (
int
)data.id();
75
q->setCondition(
"L1BGS2BG_BUNCH_GROUP_SET_ID = :bgsId "
, bindList );
76
77
//Output data and types
78
coral::AttributeList attList;
79
attList.extend<
long
>(
"L1BGS2BG_BUNCH_GROUP_ID"
);
80
attList.extend<
long
>(
"L1BGS2BG_INTERNAL_NUMBER"
);
81
if
(
isRun2
()) {
82
attList.extend<
string
>(
"L1BGS2BG_BUNCH_GROUP_NAME"
);
83
}
84
fillQuery
(q.get(),attList);
85
86
q->addToOrderList(
"L1BGS2BG_INTERNAL_NUMBER"
);
87
88
coral::ICursor& cursor = q->execute();
89
90
BunchGroupLoader
& bgldr =
dynamic_cast<
BunchGroupLoader
&
>
(
dynamic_cast<
StorageMgr
&
>
(
m_storageMgr
).
bunchGroupLoader
() );
91
while
( cursor.next() ) {
92
BunchGroup
bg;
93
const
coral::AttributeList& row = cursor.currentRow();
94
95
bg.setId(row[
"L1BGS2BG_BUNCH_GROUP_ID"
].data<long>());
96
bg.setInternalNumber( row[
"L1BGS2BG_INTERNAL_NUMBER"
].data<long>() );
97
if
(
isRun2
()) {
98
bg.setName( row[
"L1BGS2BG_BUNCH_GROUP_NAME"
].data<string>() );
99
}
100
if
( !bgldr.
load
( bg ) ) {
101
TRG_MSG_ERROR
(
"loading BunchGroup "
<< bg.id() );
102
commitSession
();
103
throw
std::runtime_error(
"BunchGroupSetLoader: Error loading BunchGroup"
);
104
}
105
106
data.addBunchGroup(bg);
107
}
108
commitSession
();
109
}
110
111
}
112
catch
(
const
coral::Exception& e ) {
113
TRG_MSG_ERROR
(
"Coral::Exception: "
<< e.what());
114
m_session
.transaction().rollback();
115
throw
;
116
}
117
118
return
true
;
119
}
120
BunchGroupLoader.h
BunchGroupSetLoader.h
BunchGroupSet.h
DBHelper.h
StorageMgr.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::BunchGroupLoader
Definition
BunchGroupLoader.h:13
TrigConf::BunchGroupLoader::load
virtual bool load(BunchGroup &data) override
Definition
BunchGroupLoader.cxx:16
TrigConf::BunchGroupSetLoader::load
virtual bool load(BunchGroupSet &data) override
Definition
BunchGroupSetLoader.cxx:18
TrigConf::BunchGroupSet
Definition
BunchGroupSet.h:19
TrigConf::BunchGroup
Definition
BunchGroup.h:17
TrigConf::DBLoader::m_storageMgr
StorageMgr & m_storageMgr
reference to the storage manager
Definition
DBLoader.h:66
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::isRun2
bool isRun2()
Definition
DBLoader.cxx:54
TrigConf::DBLoader::startSession
void startSession()
start session if not already active
Definition
DBLoader.cxx:36
TrigConf::StorageMgr
Database Storage Manager, controls the database session and the different loader classes for DB acces...
Definition
StorageMgr.h:23
TrigConf::StorageMgr::bunchGroupLoader
virtual IBunchGroupLoader & bunchGroupLoader() override
Definition
StorageMgr.cxx:198
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