ATLAS Offline Software
Loading...
Searching...
No Matches
PrescaledClockLoader.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: PrescaledClockLoader.cpp
8//PACKAGE: TrigConfStorage
9//
10//AUTHOR: J.Haller (CERN) Johannes.Haller@cern.ch
11//CREATED: 31. Oct. 2005
12//
13//PURPOSE:
14//
15//
17
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/ISchema.h"
27#include "RelationalAccess/ICursor.h"
28#include "RelationalAccess/IQuery.h"
29
31
32#include <iostream>
33#include <stdexcept>
34#include <typeinfo>
35
37
38 if(verbose())
39 msg() << "PrescaledClockLoader: Load PrescaledClock with ID = " << pcTarget.id() << std::endl;
40
41 try {
42
44 coral::ITable& table = m_session.nominalSchema().tableHandle( "L1_PRESCALED_CLOCK");
45 coral::IQuery* query = table.newQuery();
46 query->setRowCacheSize( 5 );
47
48 //Bind list
49 coral::AttributeList bindList;
50 bindList.extend<long>("pcId");
51 std::string cond = "L1PC_ID = :pcId";
52 bindList[0].data<long>() = pcTarget.id();
53 query->setCondition( cond, bindList);
54
55 //Output data and types
56 coral::AttributeList attList;
57 attList.extend<std::string>( "L1PC_NAME" );
58 attList.extend<int>( "L1PC_VERSION" );
59 attList.extend<int>( "L1PC_CLOCK1" );
60 attList.extend<int>( "L1PC_CLOCK2" );
61 attList.extend<long>( "L1PC_ID" );
62 query->defineOutput(attList);
63
64 query->addToOutputList( "L1PC_NAME" );
65 query->addToOutputList( "L1PC_VERSION" );
66 query->addToOutputList( "L1PC_CLOCK1" );
67 query->addToOutputList( "L1PC_CLOCK2" );
68 query->addToOutputList( "L1PC_ID" );
69 query->addToOrderList( "L1PC_ID" );
70
71 coral::ICursor& cursor = query->execute();
72
73 if ( ! cursor.next() ) {
74 msg() << "PrescaledClockLoader >> No such prescaled clock exists "
75 << pcTarget.id() << std::endl;
76 delete query;
78 throw std::runtime_error( "PrescaledClockLoader >> PrescaledClock not available" );
79 }
80
81 const coral::AttributeList& row = cursor.currentRow();
82 std::string name = row["L1PC_NAME"].data<std::string>();
83 int version = row["L1PC_VERSION"].data<int>();
84 int clock1 = row["L1PC_CLOCK1"].data<int>();
85 int clock2 = row["L1PC_CLOCK2"].data<int>();
86
87 if ( cursor.next() ) {
88 msg() << "PrescaledClockLoader >> More than one PrescaledClock exists "
89 << pcTarget.id() << std::endl;
90 delete query;
92 throw std::runtime_error( "PrescaledClockLoader >> PrescaledClock not available" );
93 }
94
95 // Fill the object with data
96 pcTarget.setName( name );
97 pcTarget.setVersion( version );
98 pcTarget.setClock1( clock1 );
99 pcTarget.setClock2( clock2 );
100
101 delete query;
103 return true;
104
105 } catch( const coral::SchemaException& e ) {
106 msg() << "PrescaledClockLoader >> SchemaException: "
107
108 << e.what() << std::endl;
109 m_session.transaction().rollback();
110 return false;
111
112 } catch( const std::exception& e ) {
113 msg() << "PrescaledClockLoader >> Standard C++ exception: " << e.what() << std::endl;
114
115 m_session.transaction().rollback();
116 return false;
117
118 } catch( ... ) {
119 msg() << "PrescaledClockLoader >> Uknown C++ exception" << std::endl;
120
121 m_session.transaction().rollback();
122 return false;
123 }
124}
125
virtual int verbose() const override
Definition DBLoader.h:57
void commitSession()
commit session if not already done
Definition DBLoader.cxx:45
coral::ISessionProxy & m_session
CORAL interface to database session.
Definition DBLoader.h:68
void startSession()
start session if not already active
Definition DBLoader.cxx:35
virtual bool load(PrescaledClock &data) override
void setClock2(int clock2)
void setClock1(int clock1)
unsigned int id() const
void setName(const std::string &name)
void setVersion(unsigned int version)
MsgStreamTC & msg() const
The standard message stream.
Definition query.py:1