11 #include <CoralBase/Attribute.h>
12 #include <CoralBase/AttributeList.h>
14 #include "RelationalAccess/SchemaException.h"
15 #include "RelationalAccess/ITransaction.h"
16 #include "RelationalAccess/ITable.h"
17 #include "RelationalAccess/ISchema.h"
18 #include "RelationalAccess/ICursor.h"
19 #include "RelationalAccess/IQuery.h"
34 bool from_string(
T&
t,
const std::string&
s,std::ios_base& (*
f)(std::ios_base&))
36 std::istringstream iss(
s);
37 return !(iss >>
f >>
t).
fail();
39 bool convert(
const string & prescale_s,
float& prescale_f){
40 return from_string<float>(prescale_f, std::string(prescale_s), std::dec);
42 std::string CheckTilda(
const std::string&
input){
53 TRG_MSG_INFO(
"Started loading data with HLT PSK: " << hltpss.
id());
58 triggerDBSchemaVersion();
62 unique_ptr< coral::IQuery >
q( m_session.nominalSchema().newQuery() );
65 q->addToTableList (
"HLT_PRESCALE_SET",
"PS" );
66 q->addToTableList (
"HLT_PRESCALE",
"PR" );
72 bindList.extend<
int>(
"psid");
73 bindList[0].data<
int>() = (
int)hltpss.
id();
76 string theCondition =
" PS.HPS_ID = :psid";
77 theCondition +=
" AND PS.HPS_ID = PR.HPR_PRESCALE_SET_ID";
78 q->setCondition( theCondition, bindList );
82 attList.extend<
string>(
"PS.HPS_NAME" );
83 attList.extend<
int> (
"PS.HPS_VERSION" );
85 attList.extend<
string>(
"PR.HPR_L2_OR_EF" );
86 attList.extend<
string>(
"PR.HPR_PASS_THROUGH_RATE" );
87 attList.extend<
string>(
"PR.HPR_PRESCALE" );
89 attList.extend<
float> (
"PR.HPR_VALUE" );
90 attList.extend<
string> (
"PR.HPR_TYPE" );
91 attList.extend<
string> (
"PR.HPR_CONDITION" );
93 attList.extend<
int> (
"PR.HPR_CHAIN_COUNTER" );
100 theOrder =
" PR.HPR_L2_OR_EF DESC, PR.HPR_CHAIN_COUNTER ASC";
102 theOrder +=
"PR.HPR_CHAIN_COUNTER ASC";
104 q->addToOrderList( theOrder );
107 q->setRowCacheSize(1000);
111 coral::ICursor&
cursor =
q->execute();
113 bool pssnameset =
false;
122 string pssname = CheckTilda(
row[
"PS.HPS_NAME"].data<string>());
123 int pssversion =
row[
"PS.HPS_VERSION"].data<
int>();
129 string level = isRun1() ?
row[
"PR.HPR_L2_OR_EF"].data<
string>() :
"HLT";
130 int counter =
row[
"PR.HPR_CHAIN_COUNTER"].data<
int>();
136 std::string prescaleStr =
row[
"PR.HPR_PRESCALE"].data<
string>();
137 if(prescaleStr==
"-0" || prescaleStr==
"na" ) prescaleStr =
"-1";
138 if (!
convert(prescaleStr, ps)) {
139 TRG_MSG_WARNING(
"Could not convert prescale string '" << prescaleStr <<
"' of chain " <<
counter <<
" to float");
142 std::string passThroughStr =
row[
"PR.HPR_PASS_THROUGH_RATE"].data<
string>();
144 TRG_MSG_WARNING(
"Could not convert passthrough string '" << passThroughStr <<
"' of chain " <<
counter <<
" to float");
152 std::string streamnametype(
level);
154 if(streamnametype.rfind(
':')==std::string::npos)
155 streamnametype +=
":" + streamnametype;
159 float value =
row[
"PR.HPR_VALUE"].data<
float>();
160 string pstype =
row[
"PR.HPR_TYPE"].data<
string>();
161 string pscondition =
row[
"PR.HPR_CONDITION"].data<
string>();
163 TRG_MSG_DEBUG(
"Loaded prescales:"<< setw(4) << right <<
counter <<
" : " << pstype <<
" (" << pscondition <<
") => " <<
value );
167 if(pstype==
"Prescale") {
169 }
else if (pstype==
"Pass_Through") {
171 }
else if (pstype==
"ReRun") {
172 if(pscondition==
"0") pscondition=
"";
174 }
else if (pstype==
"Stream") {
178 TRG_MSG_WARNING(
"Could not interpret this entry in the prescale set table: counter " <<
counter <<
" : " << pstype <<
" (" << pscondition <<
") => " <<
value);
190 catch (
const coral::SchemaException&
e) {
191 TRG_MSG_ERROR(
"HLTPrescaleSetLoader >> IRelationalException: " <<
e.what());
192 m_session.transaction().rollback();
196 TRG_MSG_ERROR(
"HLTPrescaleSetLoader >> Standard C++ exception: " <<
e.what());
197 m_session.transaction().rollback();
201 TRG_MSG_ERROR(
"HLTPrescaleSetLoader >> unknown C++ exception");
202 m_session.transaction().rollback();