ATLAS Offline Software
Loading...
Searching...
No Matches
CaloSinCosLoader.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: CaloSinCosLoader.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
18#include "./CaloSinCosLoader.h"
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
36bool
38 msg() << "CaloSinCosLoader started loading data via ID. ID = " << cscTarget.id() << std::endl;
39
40 try {
42 msg() << "Loading CaloSinCos " << cscTarget.id() << std::endl;
43
44 coral::ITable& table = m_session.nominalSchema().tableHandle( "L1_CALO_SIN_COS");
45 coral::IQuery* query = table.newQuery();
46 query->setRowCacheSize( 5 );
47
48 // the query condition
49 std::string condition = "L1CSC_ID = :l1cscid";
50
51 // binding
52 coral::AttributeList boundvars;
53 boundvars.extend<int>("l1cscid");
54 boundvars[0].data<int>() = (int)cscTarget.id();
55
56 query->setCondition( condition, boundvars );
57
58 //Output
59 coral::AttributeList attList;
60 attList.extend<int>( "L1CSC_VERSION" );
61 attList.extend<std::string>( "L1CSC_NAME" );
62 attList.extend<int>( "L1CSC_VAL1" );
63 attList.extend<int>( "L1CSC_VAL2" );
64 attList.extend<int>( "L1CSC_VAL3" );
65 attList.extend<int>( "L1CSC_VAL4" );
66 attList.extend<int>( "L1CSC_VAL5" );
67 attList.extend<int>( "L1CSC_VAL6" );
68 attList.extend<int>( "L1CSC_VAL7" );
69 attList.extend<int>( "L1CSC_VAL8" );
70 attList.extend<int>( "L1CSC_ETA_MIN" );
71 attList.extend<int>( "L1CSC_ETA_MAX" );
72 attList.extend<int>( "L1CSC_PHI_MIN" );
73 attList.extend<int>( "L1CSC_PHI_MAX" );
74 query->defineOutput(attList);
75
76 query->addToOutputList( "L1CSC_VERSION" );
77 query->addToOutputList( "L1CSC_NAME" );
78 query->addToOutputList( "L1CSC_VAL1" );
79 query->addToOutputList( "L1CSC_VAL2" );
80 query->addToOutputList( "L1CSC_VAL3" );
81 query->addToOutputList( "L1CSC_VAL4" );
82 query->addToOutputList( "L1CSC_VAL5" );
83 query->addToOutputList( "L1CSC_VAL6" );
84 query->addToOutputList( "L1CSC_VAL7" );
85 query->addToOutputList( "L1CSC_VAL8" );
86 query->addToOutputList( "L1CSC_ETA_MIN" );
87 query->addToOutputList( "L1CSC_ETA_MAX" );
88 query->addToOutputList( "L1CSC_PHI_MIN" );
89 query->addToOutputList( "L1CSC_PHI_MAX" );
90
91 query->addToOrderList( "L1CSC_ID" );
92
93 coral::ICursor& cursor = query->execute();
94
95 if ( ! cursor.next() ) {
96 msg() << "CaloSinCosLoader >> No such deadtime exists " << cscTarget.id() << std::endl;
97 delete query;
99 throw std::runtime_error( "CaloSinCosLoader >> CaloSinCos not available" );
100 }
101
102 const coral::AttributeList& row = cursor.currentRow();
103 std::string name = row["L1CSC_NAME"].data<std::string>();
104 int version = row["L1CSC_VERSION"].data<int>();
105 int val1 = row["L1CSC_VAL1"].data<int>();
106 int val2 = row["L1CSC_VAL2"].data<int>();
107 int val3 = row["L1CSC_VAL3"].data<int>();
108 int val4 = row["L1CSC_VAL4"].data<int>();
109 int val5 = row["L1CSC_VAL5"].data<int>();
110 int val6 = row["L1CSC_VAL6"].data<int>();
111 int val7 = row["L1CSC_VAL7"].data<int>();
112 int val8 = row["L1CSC_VAL8"].data<int>();
113 int eta_min = row["L1CSC_ETA_MIN"].data<int>();
114 int eta_max = row["L1CSC_ETA_MAX"].data<int>();
115 int phi_min = row["L1CSC_PHI_MIN"].data<int>();
116 int phi_max = row["L1CSC_PHI_MAX"].data<int>();
117
118 if ( cursor.next() ) {
119 msg() << "CaloSinCosLoader >> More than one CaloSinCos exists "
120 << cscTarget.id() << std::endl;
121 delete query;
123 throw std::runtime_error( "CaloSinCosLoader >> CaloSinCos not available" );
124 }
125
126 // fill the object with data
127 cscTarget.setName( name );
128 cscTarget.setVersion( version );
129 cscTarget.setVal1( val1 );
130 cscTarget.setVal2( val2 );
131 cscTarget.setVal3( val3 );
132 cscTarget.setVal4( val4 );
133 cscTarget.setVal5( val5 );
134 cscTarget.setVal6( val6 );
135 cscTarget.setVal7( val7 );
136 cscTarget.setVal8( val8 );
137 cscTarget.setEtaMin(eta_min);
138 cscTarget.setEtaMax(eta_max);
139 cscTarget.setPhiMin(phi_min);
140 cscTarget.setPhiMax(phi_max);
141
142 delete query;
144 return true;
145 } catch( const coral::SchemaException& e ) {
146 msg() << "CaloSinCosLoader >> SchemaException: "
147 << e.what() << std::endl;
148 m_session.transaction().rollback();
149 return false;
150 } catch( const std::exception& e ) {
151 msg() << "CaloSinCosLoader >> Standard C++ exception: " << e.what() << std::endl;
152 m_session.transaction().rollback();
153 return false;
154 } catch(...) {
155 msg() << "CaloSinCosLoader >> unknown C++ exception" << std::endl;
156 m_session.transaction().rollback();
157 return false;
158 }
159}
160
161
virtual bool load(CaloSinCos &data) override
void setVal2(int val)
Definition CaloSinCos.h:41
void setEtaMin(int val)
Definition CaloSinCos.h:48
void setVal3(int val)
Definition CaloSinCos.h:42
void setVal7(int val)
Definition CaloSinCos.h:46
void setEtaMax(int val)
Definition CaloSinCos.h:49
void setVal5(int val)
Definition CaloSinCos.h:44
void setVal1(int val)
Definition CaloSinCos.h:40
void setVal6(int val)
Definition CaloSinCos.h:45
void setPhiMax(int val)
Definition CaloSinCos.h:51
void setVal4(int val)
Definition CaloSinCos.h:43
void setPhiMin(int val)
Definition CaloSinCos.h:50
void setVal8(int val)
Definition CaloSinCos.h:47
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
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