2 #include "RelationalAccess/ISchema.h"
3 #include "RelationalAccess/ITable.h"
4 #include "RelationalAccess/ITableDataEditor.h"
5 #include "RelationalAccess/IQuery.h"
6 #include "RelationalAccess/ICursor.h"
7 #include "RelationalAccess/SchemaException.h"
8 #include "CoralBase/AttributeList.h"
9 #include "CoralBase/Attribute.h"
10 #include "CoralBase/AttributeSpecification.h"
11 #include "CoralBase/TimeStamp.h"
20 unsigned long long entry_id = 0;
21 coral::IQuery* qHandle = schema.newQuery();
24 qHandle->addToOutputList(
"e.ENTRY_ID",
"entry_id");
26 coral::AttributeList qCondition;
27 qCondition.extend(
"entryname",
typeid(
std::string));
28 qCondition.extend(
"branchname",
typeid(
std::string));
29 qCondition[
"entryname"].data<
std::string>() = entryname;
30 qCondition[
"branchname"].data<
std::string>() = branchname;
31 std::string qConditionStr(
"r.REVISION_ID=e.REVISION_ID and e.NAME=:entryname AND r.BRANCH_NAME=:branchname");
33 coral::AttributeList qResult;
34 qResult.extend(
"entry_id",
typeid(
unsigned long long));
35 qHandle->defineOutput(qResult);
36 qHandle->setCondition(qConditionStr, qCondition);
37 coral::ICursor& cursor = qHandle->execute();
38 while (cursor.next()) {
39 entry_id = cursor.currentRow()[
"entry_id"].data<
unsigned long long>();
63 unsigned long long branchid,
65 coral::AttributeList revdata;
66 revdata.extend(
"REVISION_ID",
typeid(
unsigned long long));
67 revdata.extend(
"BRANCH_ID",
typeid(
unsigned long long));
69 revdata.extend(
"CTIME",
typeid(coral::TimeStamp));
70 revdata[
"REVISION_ID"].data<
unsigned long long>() =
entry.revision_id;
71 revdata[
"BRANCH_ID"].data<
unsigned long long>() = branchid;
72 revdata[
"BRANCH_NAME"].data<
std::string>() = branchname;
75 schema.tableHandle(revTableName).dataEditor().insertRow(revdata);
77 coral::AttributeList entrydata;
78 entrydata.extend(
"REVISION_ID",
typeid(
unsigned long long));
79 entrydata.extend(
"ENTRY_ID",
typeid(
unsigned long long));
81 entrydata[
"REVISION_ID"].data<
unsigned long long>() =
entry.revision_id;
82 entrydata[
"ENTRY_ID"].data<
unsigned long long>() =
entry.entry_id;
85 schema.tableHandle(entryTableName).dataEditor().insertRow(entrydata);
87 coral::AttributeList revmapdata;
88 revmapdata.extend(
"REVISION_ID",
typeid(
unsigned long long));
89 revmapdata.extend(
"DATA_ID",
typeid(
unsigned long long));
91 revmapdata[
"REVISION_ID"].data<
unsigned long long>() =
entry.revision_id;
92 revmapdata[
"DATA_ID"].data<
unsigned long long>() =
entry.data_id;
95 schema.tableHandle(revmapTableName).dataEditor().insertRow(revmapdata);
100 unsigned long long branchid,
102 coral::AttributeList revdata;
103 revdata.extend(
"REVISION_ID",
typeid(
unsigned long long));
104 revdata.extend(
"BRANCH_ID",
typeid(
unsigned long long));
105 revdata.extend(
"BRANCH_NAME",
typeid(
std::string));
106 revdata.extend(
"CTIME",
typeid(coral::TimeStamp));
107 revdata[
"REVISION_ID"].data<
unsigned long long>() = revision.
revision_id;
108 revdata[
"BRANCH_ID"].data<
unsigned long long>() = branchid;
109 revdata[
"BRANCH_NAME"].data<
std::string>() = branchname;
112 coral::AttributeList revmapdata;
113 revmapdata.extend(
"REVISION_ID",
typeid(
unsigned long long));
114 revmapdata.extend(
"DATA_ID",
typeid(
unsigned long long));
115 revmapdata[
"REVISION_ID"].data<
unsigned long long>() = revision.
revision_id;
116 revmapdata[
"DATA_ID"].data<
unsigned long long>() = revision.
data_id;
118 schema.tableHandle(revmapTableName).dataEditor().insertRow(revmapdata);
121 coral::AttributeList lumirundata;
122 lumirundata.extend(
"DATA_ID",
typeid(
unsigned long long));
123 lumirundata.extend(
"ENTRY_ID",
typeid(
unsigned long long));
124 lumirundata.extend(
"ENTRY_NAME",
typeid(
std::string));
125 lumirundata.extend(
"RUNNUM",
typeid(
unsigned int));
127 lumirundata.extend(
"NOMINALEGEV",
typeid(
float));
128 lumirundata.extend(
"NCOLLIDINGBUNCHES",
typeid(
unsigned int));
129 lumirundata[
"DATA_ID"].data<
unsigned long long>() = lumientry.
data_id;
130 lumirundata[
"ENTRY_ID"].data<
unsigned long long>() = lumientry.
entry_id;
132 lumirundata[
"RUNNUM"].data<
unsigned int>() = lumientry.
runnumber;
134 lumirundata[
"NOMINALEGEV"].data<
float>() = lumientry.
bgev;
135 lumirundata[
"NCOLLIDINGBUNCHES"].data<
unsigned int>() = lumientry.
ncollidingbunches;
137 schema.tableHandle(lumidataTableName).dataEditor().insertRow(lumirundata);
140 coral::AttributeList trgrundata;
141 trgrundata.extend(
"DATA_ID",
typeid(
unsigned long long));
142 trgrundata.extend(
"ENTRY_ID",
typeid(
unsigned long long));
143 trgrundata.extend(
"ENTRY_NAME",
typeid(
std::string));
144 trgrundata.extend(
"RUNNUM",
typeid(
unsigned int));
146 trgrundata.extend(
"BITZERONAME",
typeid(
std::string));
147 trgrundata.extend(
"BITNAMECLOB",
typeid(
std::string));
148 trgrundata[
"DATA_ID"].data<
unsigned long long>() = trgentry.
data_id;
149 trgrundata[
"ENTRY_ID"].data<
unsigned long long>() = trgentry.
entry_id;
151 trgrundata[
"RUNNUM"].data<
unsigned int>() = trgentry.
runnumber;
156 schema.tableHandle(trgdataTableName).dataEditor().insertRow(trgrundata);
159 coral::AttributeList hltrundata;
160 hltrundata.extend(
"DATA_ID",
typeid(
unsigned long long));
161 hltrundata.extend(
"ENTRY_ID",
typeid(
unsigned long long));
162 hltrundata.extend(
"ENTRY_NAME",
typeid(
std::string));
163 hltrundata.extend(
"RUNNUM",
typeid(
unsigned int));
165 hltrundata.extend(
"NPATH",
typeid(
unsigned int));
166 hltrundata.extend(
"PATHNAMECLOB",
typeid(
std::string));
167 hltrundata[
"DATA_ID"].data<
unsigned long long>() = hltentry.
data_id;
168 hltrundata[
"ENTRY_ID"].data<
unsigned long long>() = hltentry.
entry_id;
170 hltrundata[
"RUNNUM"].data<
unsigned int>() = hltentry.
runnumber;
172 hltrundata[
"NPATH"].data<
unsigned int>() = hltentry.
npath;
175 schema.tableHandle(hltdataTableName).dataEditor().insertRow(hltrundata);
179 unsigned long long currentdatatagid = 0;
180 std::vector<unsigned long long> alltagids;
181 coral::IQuery* qHandle = schema.newQuery();
183 qHandle->addToOutputList(
"TAGID");
184 coral::AttributeList qResult;
185 qResult.extend(
"TAGID",
typeid(
unsigned long long));
186 qHandle->defineOutput(qResult);
187 coral::ICursor& cursor = qHandle->execute();
188 while (cursor.next()) {
189 if (!cursor.currentRow()[
"TAGID"].isNull()) {
190 alltagids.push_back(cursor.currentRow()[
"TAGID"].data<
unsigned long long>());
194 if (!alltagids.empty()) {
195 std::vector<unsigned long long>::iterator currentdatatagidIt = std::max_element(alltagids.begin(), alltagids.end());
196 currentdatatagid = *currentdatatagidIt;
198 return currentdatatagid;
202 unsigned long long datatagid = 0;
203 coral::IQuery* qHandle = schema.newQuery();
205 const std::string conditionStr(
"TAGNAME=:tagname");
209 qHandle->addToOutputList(
"TAGID");
210 coral::AttributeList qResult;
211 qResult.extend(
"TAGID",
typeid(
unsigned long long));
212 qHandle->setCondition(conditionStr,
condition);
213 qHandle->defineOutput(qResult);
214 coral::ICursor& cursor = qHandle->execute();
215 while (cursor.next()) {
216 if (!cursor.currentRow()[
"TAGID"].isNull()) {
217 datatagid = cursor.currentRow()[
"TAGID"].data<
unsigned long long>();
226 unsigned long long lumiid,
227 unsigned long long trgid,
228 unsigned long long hltid,
230 unsigned long long currenttagid = currentHFDataTagId(schema);
231 coral::AttributeList tagrundata;
232 tagrundata.extend(
"TAGID",
typeid(
unsigned long long));
233 tagrundata.extend(
"RUNNUM",
typeid(
unsigned int));
234 tagrundata.extend(
"LUMIDATAID",
typeid(
unsigned long long));
235 tagrundata.extend(
"TRGDATAID",
typeid(
unsigned long long));
236 tagrundata.extend(
"HLTDATAID",
typeid(
unsigned long long));
237 tagrundata.extend(
"CREATIONTIME",
typeid(coral::TimeStamp));
239 tagrundata[
"TAGID"].data<
unsigned long long>() = currenttagid;
240 tagrundata[
"RUNNUM"].data<
unsigned int>() = runnum;
241 tagrundata[
"LUMIDATAID"].data<
unsigned long long>() =
lumiid;
242 tagrundata[
"TRGDATAID"].data<
unsigned long long>() = trgid;
243 tagrundata[
"HLTDATAID"].data<
unsigned long long>() = hltid;
245 tagrundata[
"COMMENT"].data<
std::string>() = patchcomment;
249 }
catch (
const coral::DuplicateEntryInUniqueKeyException& er) {
257 unsigned long long tagid) {
259 coral::IQuery* qHandle = schema.newQuery();
261 qHandle->addToOutputList(
"LUMIDATAID");
262 qHandle->addToOutputList(
"TRGDATAID");
263 qHandle->addToOutputList(
"HLTDATAID");
264 coral::AttributeList qResult;
265 qResult.extend(
"LUMIDATAID",
typeid(
unsigned long long));
266 qResult.extend(
"TRGDATAID",
typeid(
unsigned long long));
267 qResult.extend(
"HLTDATAID",
typeid(
unsigned long long));
268 qHandle->defineOutput(qResult);
269 coral::AttributeList qCondition;
270 qCondition.extend(
"tagid",
typeid(
unsigned long long));
271 qCondition.extend(
"runnum",
typeid(
unsigned int));
272 qCondition[
"tagid"].data<
unsigned long long>() = tagid;
273 qCondition[
"runnum"].data<
unsigned int>() = runnum;
274 std::string qConditionStr(
"TAGID<=:tagid AND RUNNUM=:runnum");
275 qHandle->setCondition(qConditionStr, qCondition);
276 coral::ICursor& cursor = qHandle->execute();
277 unsigned long long minlumid = 0;
278 unsigned long long mintrgid = 0;
279 unsigned long long minhltid = 0;
280 while (cursor.next()) {
281 if (!cursor.currentRow()[
"LUMIDATAID"].isNull()) {
282 unsigned long long lumiid = cursor.currentRow()[
"LUMIDATAID"].data<
unsigned long long>();
287 if (!cursor.currentRow()[
"TRGDATAID"].isNull()) {
288 unsigned long long trgid = cursor.currentRow()[
"TRGDATAID"].data<
unsigned long long>();
289 if (trgid > mintrgid) {
293 if (!cursor.currentRow()[
"HLTDATAID"].isNull()) {
294 unsigned long long hltid = cursor.currentRow()[
"HLTDATAID"].data<
unsigned long long>();
295 if (hltid > minhltid) {