Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
OnCalDBodbc.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file OnCalDBodbc.cc
1
#include "
OnCalDBodbc.h
"
2
3
#include <
odbc++/connection.h
>
4
#include <
odbc++/drivermanager.h
>
5
#include <
odbc++/statement.h
>
// for Statement
6
#include <
odbc++/types.h
>
// for SQLException
7
8
#pragma GCC diagnostic push
9
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
10
#include <
odbc++/resultset.h
>
11
#pragma GCC diagnostic pop
12
13
#include <iostream>
// for operator<<, basic_ostream, endl, cout
14
#include <sstream>
15
16
//#define VERBOSE
17
18
void
OnCalDBodbc::identify
()
const
19
{
20
std::cout <<
"DB Name: "
<<
dbname
<< std::endl;
21
std::cout <<
"DB Owner: "
<<
dbowner
<< std::endl;
22
std::cout <<
"DB Pwd: "
<<
dbpasswd
<< std::endl;
23
return
;
24
}
25
26
int
OnCalDBodbc::GetLastCalibratedRun
(
const
int
runno)
const
27
{
28
odbc::Connection
*
con
=
nullptr
;
29
odbc::Statement
* query =
nullptr
;
30
std::ostringstream
cmd
;
31
int
closestgoodrun = 329640;
32
try
33
{
34
con =
odbc::DriverManager::getConnection
(
dbname
.c_str(),
dbowner
.c_str(),
dbpasswd
.c_str());
35
}
36
catch
(
odbc::SQLException
&
e
)
37
{
38
std::cout << __PRETTY_FUNCTION__
39
<<
" Exception caught during DriverManager::getConnection"
<< std::endl;
40
std::cout <<
"Message: "
<< e.
getMessage
() << std::endl;
41
return
closestgoodrun;
42
}
43
44
query = con->
createStatement
();
45
cmd <<
"SELECT runnumber FROM OnCal_status WHERE RUNNUMBER <= "
<< runno
46
<<
" and dchcal > 0 and padcal > 0 and pbscgainscal > 0 and pbglqa>0 and pbglcal > 0"
47
<<
" order by runnumber desc limit 1"
;
48
if
(
verbosity
> 0)
49
{
50
std::cout <<
"command: "
<< cmd.str() << std::endl;
51
}
52
odbc::ResultSet
* rs =
nullptr
;
53
try
54
{
55
rs = query->
executeQuery
(cmd.str());
56
}
57
catch
(
odbc::SQLException
& e)
58
{
59
std::cout <<
"Exception caught"
<< std::endl;
60
std::cout <<
"Message: "
<< e.
getMessage
() << std::endl;
61
}
62
if
(rs && rs->
next
())
63
{
64
closestgoodrun = rs->
getInt
(
"runnumber"
);
65
}
66
delete
con
;
67
return
closestgoodrun;
68
}
OnlMon
blob
main
onlmondatabase
OnCalDBodbc.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:28
using
1.8.2 with
sPHENIX GitHub integration