CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RevisionDML.cc
Go to the documentation of this file.
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 "CoralBase/AttributeList.h"
8 #include "CoralBase/Attribute.h"
9 #include "CoralBase/AttributeSpecification.h"
10 #include "CoralBase/TimeStamp.h"
13 unsigned long long
15  const std::string& datatableName,
16  const std::string& entryname,
17  const std::string& branchname){
18  unsigned long long entry_id=0;
19  coral::IQuery* qHandle=schema.newQuery();
20  qHandle->addToTableList( lumi::LumiNames::entryTableName(datatableName),"e");
21  qHandle->addToTableList( lumi::LumiNames::revisionTableName(),"r");
22  qHandle->addToOutputList("e.ENTRY_ID","entry_id");
23 
24  coral::AttributeList qCondition;
25  qCondition.extend("entryname",typeid(std::string));
26  qCondition.extend("branchname",typeid(std::string));
27  qCondition["entryname"].data<std::string>()=entryname;
28  qCondition["branchname"].data<std::string>()=branchname;
29  std::string qConditionStr("r.REVISION_ID=e.REVISION_ID and e.NAME=:entryname AND r.BRANCH_NAME=:branchname");
30 
31  coral::AttributeList qResult;
32  qResult.extend("entry_id",typeid(unsigned long long));
33  qHandle->defineOutput(qResult);
34  qHandle->setCondition(qConditionStr,qCondition);
35  coral::ICursor& cursor=qHandle->execute();
36  while(cursor.next()){
37  entry_id=cursor.currentRow()["entry_id"].data<unsigned long long>();
38  }
39  delete qHandle;
40  return entry_id;
41 }
42 void
44  const std::string& datatableName,
46  lumi::idDealer idg(schema);
47  const std::string entrytableName=lumi::LumiNames::entryTableName(datatableName);
49  entry.data_id=idg.generateNextIDForTable(datatableName);
50  entry.entry_id=idg.generateNextIDForTable(entrytableName);
51 }
52 void
54  const std::string& datatableName,
55  lumi::RevisionDML::Entry& revision){
56  lumi::idDealer idg(schema);
58  revision.data_id=idg.generateNextIDForTable(datatableName);
59 }
60 void
62  const std::string& datatableName,
64  unsigned long long branchid,
65  const std::string& branchname ){
66  coral::AttributeList revdata;
67  revdata.extend("REVISION_ID",typeid(unsigned long long));
68  revdata.extend("BRANCH_ID",typeid(unsigned long long));
69  revdata.extend("BRANCH_NAME",typeid(std::string));
70  revdata.extend("CTIME",typeid(coral::TimeStamp));
71  revdata["REVISION_ID"].data<unsigned long long>()=entry.revision_id;
72  revdata["BRANCH_ID"].data<unsigned long long>()=branchid;
73  revdata["BRANCH_NAME"].data<std::string>()=branchname;
74  revdata["CTIME"].data<coral::TimeStamp>()=coral::TimeStamp::now();
75  const std::string revTableName=lumi::LumiNames::revisionTableName();
76  schema.tableHandle(revTableName).dataEditor().insertRow(revdata);
77 
78  coral::AttributeList entrydata;
79  entrydata.extend("REVISION_ID",typeid(unsigned long long));
80  entrydata.extend("ENTRY_ID",typeid(unsigned long long));
81  entrydata.extend("NAME",typeid(std::string));
82  entrydata["REVISION_ID"].data<unsigned long long>()=entry.revision_id;
83  entrydata["ENTRY_ID"].data<unsigned long long>()=entry.entry_id;
84  entrydata["NAME"].data<std::string>()=entry.entry_name;
85  const std::string entryTableName=lumi::LumiNames::entryTableName(datatableName);
86  schema.tableHandle(entryTableName).dataEditor().insertRow(entrydata);
87 
88  coral::AttributeList revmapdata;
89  revmapdata.extend("REVISION_ID",typeid(unsigned long long));
90  revmapdata.extend("DATA_ID",typeid(unsigned long long));
91 
92  revmapdata["REVISION_ID"].data<unsigned long long>()=entry.revision_id;
93  revmapdata["DATA_ID"].data<unsigned long long>()=entry.data_id;
94 
95  const std::string revmapTableName=lumi::LumiNames::revmapTableName(datatableName);
96  schema.tableHandle(revmapTableName).dataEditor().insertRow(revmapdata);
97 }
98 void
100  const std::string& datatableName,
101  const lumi::RevisionDML::Entry& revision,
102  unsigned long long branchid,
103  std::string& branchname ){
104  coral::AttributeList revdata;
105  revdata.extend("REVISION_ID",typeid(unsigned long long));
106  revdata.extend("BRANCH_ID",typeid(unsigned long long));
107  revdata.extend("BRANCH_NAME",typeid(std::string));
108  revdata.extend("CTIME",typeid(coral::TimeStamp));
109  revdata["REVISION_ID"].data<unsigned long long>()=revision.revision_id;
110  revdata["BRANCH_ID"].data<unsigned long long>()=branchid;
111  revdata["BRANCH_NAME"].data<std::string>()=branchname;
112  revdata["CTIME"].data<coral::TimeStamp>()=coral::TimeStamp::now();
113  schema.tableHandle(lumi::LumiNames::revisionTableName()).dataEditor().insertRow(revdata);
114  coral::AttributeList revmapdata;
115  revmapdata.extend("REVISION_ID",typeid(unsigned long long));
116  revmapdata.extend("DATA_ID",typeid(unsigned long long));
117  revmapdata["REVISION_ID"].data<unsigned long long>()=revision.revision_id;
118  revmapdata["DATA_ID"].data<unsigned long long>()=revision.data_id;
119  const std::string revmapTableName=lumi::LumiNames::revmapTableName(datatableName);
120  schema.tableHandle(revmapTableName).dataEditor().insertRow(revmapdata);
121 }
122 void
124  const lumi::RevisionDML::LumiEntry& lumientry){
125  coral::AttributeList lumirundata;
126  lumirundata.extend("DATA_ID",typeid(unsigned long long));
127  lumirundata.extend("ENTRY_ID",typeid(unsigned long long));
128  lumirundata.extend("ENTRY_NAME",typeid(std::string));
129  lumirundata.extend("RUNNUM",typeid(unsigned int));
130  lumirundata.extend("SOURCE",typeid(std::string));
131  lumirundata.extend("NOMINALEGEV",typeid(float));
132  lumirundata.extend("NCOLLIDINGBUNCHES",typeid(unsigned int));
133  lumirundata["DATA_ID"].data<unsigned long long>()=lumientry.data_id;
134  lumirundata["ENTRY_ID"].data<unsigned long long>()=lumientry.entry_id;
135  lumirundata["ENTRY_NAME"].data<std::string>()=lumientry.entry_name;
136  lumirundata["RUNNUM"].data<unsigned int>()=lumientry.runnumber;
137  lumirundata["SOURCE"].data<std::string>()=lumientry.source;
138  lumirundata["NOMINALEGEV"].data<float>()=lumientry.bgev;
139  lumirundata["NCOLLIDINGBUNCHES"].data<unsigned int>()=lumientry.ncollidingbunches;
141  schema.tableHandle(lumidataTableName).dataEditor().insertRow(lumirundata);
142 }
143 void
145  const lumi::RevisionDML::TrgEntry& trgentry){
146  coral::AttributeList trgrundata;
147  trgrundata.extend("DATA_ID",typeid(unsigned long long));
148  trgrundata.extend("ENTRY_ID",typeid(unsigned long long));
149  trgrundata.extend("ENTRY_NAME",typeid(std::string));
150  trgrundata.extend("RUNNUM",typeid(unsigned int));
151  trgrundata.extend("SOURCE",typeid(std::string));
152  trgrundata.extend("BITZERONAME",typeid(std::string));
153  trgrundata.extend("BITNAMECLOB",typeid(std::string));
154  trgrundata["DATA_ID"].data<unsigned long long>()=trgentry.data_id;
155  trgrundata["ENTRY_ID"].data<unsigned long long>()=trgentry.entry_id;
156  trgrundata["ENTRY_NAME"].data<std::string>()=trgentry.entry_name;
157  trgrundata["RUNNUM"].data<unsigned int>()=trgentry.runnumber;
158  trgrundata["SOURCE"].data<std::string>()=trgentry.source;
159  trgrundata["BITZERONAME"].data<std::string>()=trgentry.bitzeroname;
160  trgrundata["BITNAMECLOB"].data<std::string>()=trgentry.bitnames;
162  schema.tableHandle(trgdataTableName).dataEditor().insertRow(trgrundata);
163 }
164 void
166  const lumi::RevisionDML::HltEntry& hltentry){
167  coral::AttributeList hltrundata;
168  hltrundata.extend("DATA_ID",typeid(unsigned long long));
169  hltrundata.extend("ENTRY_ID",typeid(unsigned long long));
170  hltrundata.extend("ENTRY_NAME",typeid(std::string));
171  hltrundata.extend("RUNNUM",typeid(unsigned int));
172  hltrundata.extend("SOURCE",typeid(std::string));
173  hltrundata.extend("NPATH",typeid(unsigned int));
174  hltrundata.extend("PATHNAMECLOB",typeid(std::string));
175  hltrundata["DATA_ID"].data<unsigned long long>()=hltentry.data_id;
176  hltrundata["ENTRY_ID"].data<unsigned long long>()=hltentry.entry_id;
177  hltrundata["ENTRY_NAME"].data<std::string>()=hltentry.entry_name;
178  hltrundata["RUNNUM"].data<unsigned int>()=hltentry.runnumber;
179  hltrundata["SOURCE"].data<std::string>()=hltentry.source;
180  hltrundata["NPATH"].data<unsigned int>()=hltentry.npath;
181  hltrundata["PATHNAMECLOB"].data<std::string>()=hltentry.pathnames;
183  schema.tableHandle(hltdataTableName).dataEditor().insertRow(hltrundata);
184 }
static const std::string trgdataTableName()
Definition: LumiNames.cc:50
list lumirundata
Definition: dataDML.py:2353
void addEntry(coral::ISchema &schema, const std::string &datatableName, const Entry &entry, unsigned long long branch_id, const std::string &branchname)
Definition: RevisionDML.cc:61
list hltrundata
Definition: dataDML.py:2363
def revmapTableName
Definition: nameDealer.py:100
static const std::string hltdataTableName()
Definition: LumiNames.cc:56
def trgdataTableName
Definition: nameDealer.py:46
void insertLumiRunData(coral::ISchema &schema, const LumiEntry &lumientry)
Definition: RevisionDML.cc:123
def hltdataTableName
Definition: nameDealer.py:58
unsigned long long data_id
Definition: RevisionDML.h:22
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
static const std::string revmapTableName(const std::string &datatablename)
Definition: LumiNames.cc:62
unsigned long long getEntryInBranchByName(coral::ISchema &schema, const std::string &datatableName, const std::string &entryname, const std::string &branchname)
Definition: RevisionDML.cc:14
static const std::string entryTableName(const std::string &datatablename)
Definition: LumiNames.cc:65
def entryTableName
Definition: nameDealer.py:103
list trgrundata
Definition: dataDML.py:2358
unsigned long long revision_id
Definition: RevisionDML.h:20
def lumidataTableName
Definition: nameDealer.py:19
void insertTrgRunData(coral::ISchema &schema, const TrgEntry &trgentry)
Definition: RevisionDML.cc:144
static const std::string lumidataTableName()
Definition: LumiNames.cc:41
unsigned long long entry_id
Definition: RevisionDML.h:21
void bookNewEntry(coral::ISchema &schema, const std::string &datatableName, Entry &entry)
Definition: RevisionDML.cc:43
void insertHltRunData(coral::ISchema &schema, const HltEntry &hltentry)
Definition: RevisionDML.cc:165
unsigned int ncollidingbunches
Definition: RevisionDML.h:31
unsigned long long generateNextIDForTable(const std::string &tableName, unsigned int interval=1)
Definition: idDealer.cc:31
void addRevision(coral::ISchema &schema, const std::string &datatableName, const Entry &revision, unsigned long long branch_id, std::string &branchname)
Definition: RevisionDML.cc:99
static const std::string revisionTableName()
Definition: LumiNames.cc:38
void bookNewRevision(coral::ISchema &schema, const std::string &datatableName, Entry &revision)
Definition: RevisionDML.cc:53