49 {
50
51 using std::string;
52
53 TRG_MSG_INFO(
"Started loading data with HLT PSK: " << hltpss.id());
54
55
56 try {
57
59
61
62 unique_ptr< coral::IQuery >
q(
m_session.nominalSchema().newQuery() );
63
64
65 q->addToTableList (
"HLT_PRESCALE_SET",
"PS" );
66 q->addToTableList (
"HLT_PRESCALE",
"PR" );
67
68
69
70
71 coral::AttributeList bindList;
72 bindList.extend<int>("psid");
73 bindList[0].data<int>() = (int)hltpss.id();
74
75
76 string theCondition = " PS.HPS_ID = :psid";
77 theCondition += " AND PS.HPS_ID = PR.HPR_PRESCALE_SET_ID";
78 q->setCondition( theCondition, bindList );
79
80
81 coral::AttributeList attList;
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" );
88 } else {
89 attList.extend<float> ( "PR.HPR_VALUE" );
90 attList.extend<string> ( "PR.HPR_TYPE" );
91 attList.extend<string> ( "PR.HPR_CONDITION" );
92 }
93 attList.extend<int> ( "PR.HPR_CHAIN_COUNTER" );
94
96
97
98 string theOrder = "";
100 theOrder = " PR.HPR_L2_OR_EF DESC, PR.HPR_CHAIN_COUNTER ASC";
101 } else {
102 theOrder += "PR.HPR_CHAIN_COUNTER ASC";
103 }
104 q->addToOrderList( theOrder );
105
106
107 q->setRowCacheSize(1000);
109
110
111 coral::ICursor&
cursor =
q->execute();
112
113 bool pssnameset = false;
114
115
116
118
119 const coral::AttributeList&
row =
cursor.currentRow();
120
121 if(!pssnameset) {
122 string pssname = CheckTilda(row[
"PS.HPS_NAME"].
data<string>());
123 int pssversion =
row[
"PS.HPS_VERSION"].data<
int>();
124 hltpss.setName(pssname);
125 hltpss.setVersion(pssversion);
126 pssnameset=true;
127 }
128
129 string level =
isRun1() ?
row[
"PR.HPR_L2_OR_EF"].data<
string>() :
"HLT";
130 int counter =
row[
"PR.HPR_CHAIN_COUNTER"].data<
int>();
131
132
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");
140 }
141
142 std::string passThroughStr =
row[
"PR.HPR_PASS_THROUGH_RATE"].data<
string>();
143 if (!
convert(passThroughStr, pt)) {
144 TRG_MSG_WARNING(
"Could not convert passthrough string '" << passThroughStr <<
"' of chain " << counter <<
" to float");
145 }
146
147 if(level=="L2" || level=="l2" || level=="EF" || level=="ef" || level=="hlt" || level=="HLT" || level=="") {
148 hltpss.thePrescale( counter,
str2lvl(level) )
149 .setPrescale(ps)
150 .setPassThrough(pt);
151 } else {
152 std::string streamnametype(std::move(level));
153
154 if(streamnametype.rfind(':')==std::string::npos)
155 streamnametype += ":" + streamnametype;
156 }
157 } else {
158
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>();
162
163 TRG_MSG_DEBUG(
"Loaded prescales:"<< setw(4) << right << counter <<
" : " << pstype <<
" (" << pscondition <<
") => " << value );
164
165 auto& thePS = hltpss.thePrescale( counter,
str2lvl(
"HLT") );
166
167 if(pstype=="Prescale") {
168 thePS.setPrescale(value);
169 } else if (pstype=="Pass_Through") {
170 thePS.setPassThrough(value);
171 } else if (pstype=="ReRun") {
172 if(pscondition=="0") pscondition="";
173 thePS.setRerunPrescale(pscondition,value);
174 } else if (pstype=="Stream") {
175
176 thePS.setStreamPrescale(pscondition,value);
177 } else {
178 TRG_MSG_WARNING(
"Could not interpret this entry in the prescale set table: counter " << counter <<
" : " << pstype <<
" (" << pscondition <<
") => " << value);
179 }
180 }
181 }
182
184 TRG_MSG_INFO(
"Loaded " << hltpss.size(
L2) <<
" L2 prescales and " << hltpss.size(
EF) <<
" EF prescales.");
185 } else {
186 TRG_MSG_INFO(
"Loaded " << hltpss.size() <<
" HLT prescales");
187 }
189 }
190 catch (const coral::SchemaException& e) {
191 TRG_MSG_ERROR(
"HLTPrescaleSetLoader >> IRelationalException: " <<
e.what());
193 return false;
194 }
195 catch (const std::exception& e) {
196 TRG_MSG_ERROR(
"HLTPrescaleSetLoader >> Standard C++ exception: " <<
e.what());
198 return false;
199 }
200 catch (...) {
201 TRG_MSG_ERROR(
"HLTPrescaleSetLoader >> unknown C++ exception");
203 return false;
204 }
205
206 return true;
207
208}
char data[hepevt_bytes_allocation_ATLAS]
#define TRG_MSG_WARNING(x)
void commitSession()
commit session if not already done
unsigned int triggerDBSchemaVersion()
void startSession()
start session if not already active
row
Appending html table to final .html summary file.
std::unique_ptr< MVAUtils::BDT > convert(TMVA::MethodBDT *bdt, bool isRegression=true, bool useYesNoLeaf=false)
HLTLevel str2lvl(const std::string &level)
void fillQuery(coral::IQuery *q, coral::AttributeList &attList)