CMS 3D CMS Logo

Classes | Public Member Functions

lumi::RevisionDML Class Reference

#include <RevisionDML.h>

List of all members.

Classes

class  DataID
class  Entry
class  HltEntry
class  LumiEntry
class  TrgEntry

Public Member Functions

void addEntry (coral::ISchema &schema, const std::string &datatableName, const Entry &entry, unsigned long long branch_id, const std::string &branchname)
void addRevision (coral::ISchema &schema, const std::string &datatableName, const Entry &revision, unsigned long long branch_id, std::string &branchname)
unsigned long long addRunToCurrentHFDataTag (coral::ISchema &schema, unsigned int runnum, unsigned long long lumiid, unsigned long long trgid, unsigned long long hltid, const std::string &patchcomment)
void bookNewEntry (coral::ISchema &schema, const std::string &datatableName, Entry &entry)
void bookNewRevision (coral::ISchema &schema, const std::string &datatableName, Entry &revision)
unsigned long long branchIdByName (coral::ISchema &schema, const std::string &branchName)
unsigned long long currentHFDataTagId (coral::ISchema &schema)
DataID dataIDForRun (coral::ISchema &schema, unsigned int runnum, unsigned long long tagid)
unsigned long long getEntryInBranchByName (coral::ISchema &schema, const std::string &datatableName, const std::string &entryname, const std::string &branchname)
unsigned long long HFDataTagIdByName (coral::ISchema &schema, const std::string &datatagname)
void insertHltRunData (coral::ISchema &schema, const HltEntry &hltentry)
void insertLumiRunData (coral::ISchema &schema, const LumiEntry &lumientry)
void insertTrgRunData (coral::ISchema &schema, const TrgEntry &trgentry)

Detailed Description

Definition at line 9 of file RevisionDML.h.


Member Function Documentation

void lumi::RevisionDML::addEntry ( coral::ISchema &  schema,
const std::string &  datatableName,
const Entry entry,
unsigned long long  branch_id,
const std::string &  branchname 
)

1. allocate and insert a new revision in the revisions table 2. allocate and insert a new entry into the entry table with the new revision 3. insert into data_rev table new data_id,revision_id mapping insert into revisions(revision_id,branch_id,branch_name,comment,ctime) values() insert into datatablename_entries (entry_id,revision_id) values() insert into datatablename_rev(data_id,revision_id) values()

Definition at line 64 of file RevisionDML.cc.

References lumi::RevisionDML::Entry::data_id, lumi::RevisionDML::Entry::entry_id, lumi::RevisionDML::Entry::entry_name, nameDealer::entryTableName(), lumi::LumiNames::entryTableName(), cmsPerfSuiteHarvest::now, lumi::RevisionDML::Entry::revision_id, nameDealer::revisionTableName(), nameDealer::revmapTableName(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by lumi::Lumi2DB::writeAllLumiDataToSchema2(), lumi::HLTV32DB::writeHltDataToSchema2(), and lumi::TRGScalers2DB::writeTrgDataToSchema2().

                                                         {
  coral::AttributeList revdata;
  revdata.extend("REVISION_ID",typeid(unsigned long long));
  revdata.extend("BRANCH_ID",typeid(unsigned long long));
  revdata.extend("BRANCH_NAME",typeid(std::string));
  revdata.extend("CTIME",typeid(coral::TimeStamp));
  revdata["REVISION_ID"].data<unsigned long long>()=entry.revision_id;
  revdata["BRANCH_ID"].data<unsigned long long>()=branchid;
  revdata["BRANCH_NAME"].data<std::string>()=branchname;
  revdata["CTIME"].data<coral::TimeStamp>()=coral::TimeStamp::now();
  const std::string revTableName=lumi::LumiNames::revisionTableName();
  schema.tableHandle(revTableName).dataEditor().insertRow(revdata);

  coral::AttributeList entrydata;
  entrydata.extend("REVISION_ID",typeid(unsigned long long));
  entrydata.extend("ENTRY_ID",typeid(unsigned long long));
  entrydata.extend("NAME",typeid(std::string));
  entrydata["REVISION_ID"].data<unsigned long long>()=entry.revision_id;
  entrydata["ENTRY_ID"].data<unsigned long long>()=entry.entry_id;
  entrydata["NAME"].data<std::string>()=entry.entry_name;
  const std::string entryTableName=lumi::LumiNames::entryTableName(datatableName);
  schema.tableHandle(entryTableName).dataEditor().insertRow(entrydata);
  
  coral::AttributeList revmapdata;
  revmapdata.extend("REVISION_ID",typeid(unsigned long long));
  revmapdata.extend("DATA_ID",typeid(unsigned long long));

  revmapdata["REVISION_ID"].data<unsigned long long>()=entry.revision_id;
  revmapdata["DATA_ID"].data<unsigned long long>()=entry.data_id;

  const std::string revmapTableName=lumi::LumiNames::revmapTableName(datatableName);
  schema.tableHandle(revmapTableName).dataEditor().insertRow(revmapdata);
}
void lumi::RevisionDML::addRevision ( coral::ISchema &  schema,
const std::string &  datatableName,
const Entry revision,
unsigned long long  branch_id,
std::string &  branchname 
)

1.insert a new revision into the revisions table 2.insert into data_id, revision_id pair to datatable_revmap insert into revisions(revision_id,branch_id,branch_name,ctime) values() insert into datatable_rev(data_id,revision_id) values())

Definition at line 102 of file RevisionDML.cc.

References lumi::RevisionDML::Entry::data_id, cmsPerfSuiteHarvest::now, lumi::RevisionDML::Entry::revision_id, lumi::LumiNames::revisionTableName(), nameDealer::revmapTableName(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by lumi::Lumi2DB::writeAllLumiDataToSchema2(), lumi::HLTV32DB::writeHltDataToSchema2(), and lumi::TRGScalers2DB::writeTrgDataToSchema2().

                                                      {
  coral::AttributeList revdata;
  revdata.extend("REVISION_ID",typeid(unsigned long long));
  revdata.extend("BRANCH_ID",typeid(unsigned long long));
  revdata.extend("BRANCH_NAME",typeid(std::string));
  revdata.extend("CTIME",typeid(coral::TimeStamp));
  revdata["REVISION_ID"].data<unsigned long long>()=revision.revision_id;
  revdata["BRANCH_ID"].data<unsigned long long>()=branchid;
  revdata["BRANCH_NAME"].data<std::string>()=branchname;
  revdata["CTIME"].data<coral::TimeStamp>()=coral::TimeStamp::now();
  schema.tableHandle(lumi::LumiNames::revisionTableName()).dataEditor().insertRow(revdata);
  coral::AttributeList revmapdata;
  revmapdata.extend("REVISION_ID",typeid(unsigned long long));
  revmapdata.extend("DATA_ID",typeid(unsigned long long));
  revmapdata["REVISION_ID"].data<unsigned long long>()=revision.revision_id;
  revmapdata["DATA_ID"].data<unsigned long long>()=revision.data_id;
  const std::string revmapTableName=lumi::LumiNames::revmapTableName(datatableName);
  schema.tableHandle(revmapTableName).dataEditor().insertRow(revmapdata);
}
unsigned long long lumi::RevisionDML::addRunToCurrentHFDataTag ( coral::ISchema &  schema,
unsigned int  runnum,
unsigned long long  lumiid,
unsigned long long  trgid,
unsigned long long  hltid,
const std::string &  patchcomment 
)

Definition at line 239 of file RevisionDML.cc.

References cmsPerfSuiteHarvest::now, AlCaHLTBitMon_QueryRunRegistry::string, lumi::LumiNames::tagRunsTableName(), and nameDealer::tagRunsTableName().

{
  unsigned long long currenttagid=currentHFDataTagId(schema);  
  coral::AttributeList tagrundata;
  tagrundata.extend("TAGID",typeid(unsigned long long));
  tagrundata.extend("RUNNUM",typeid(unsigned int));
  tagrundata.extend("LUMIDATAID",typeid(unsigned long long));
  tagrundata.extend("TRGDATAID",typeid(unsigned long long));
  tagrundata.extend("HLTDATAID",typeid(unsigned long long));
  tagrundata.extend("CREATIONTIME",typeid(coral::TimeStamp));
  tagrundata.extend("COMMENT",typeid(std::string));
  tagrundata["TAGID"].data<unsigned long long>()=currenttagid;
  tagrundata["RUNNUM"].data<unsigned int>()=runnum;
  tagrundata["LUMIDATAID"].data<unsigned long long>()=lumiid;
  tagrundata["TRGDATAID"].data<unsigned long long>()=trgid;
  tagrundata["HLTDATAID"].data<unsigned long long>()=hltid;
  tagrundata["CREATIONTIME"].data<coral::TimeStamp>()=coral::TimeStamp::now();
  tagrundata["COMMENT"].data<std::string>()=patchcomment;
  const std::string tagrunTableName=lumi::LumiNames::tagRunsTableName();
  try{
    schema.tableHandle(lumi::LumiNames::tagRunsTableName()).dataEditor().insertRow(tagrundata);
  }catch(const coral::DuplicateEntryInUniqueKeyException& er){
    throw lumi::duplicateRunInDataTagException("","addRunToCurrentHFDataTag","RevisionDML");
  }
  return currenttagid;
}
void lumi::RevisionDML::bookNewEntry ( coral::ISchema &  schema,
const std::string &  datatableName,
Entry entry 
)

allocate new revision_id,entry_id,data_id

Definition at line 46 of file RevisionDML.cc.

References lumi::RevisionDML::Entry::data_id, lumi::RevisionDML::Entry::entry_id, nameDealer::entryTableName(), lumi::idDealer::generateNextIDForTable(), lumi::RevisionDML::Entry::revision_id, lumi::LumiNames::revisionTableName(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by lumi::Lumi2DB::writeAllLumiDataToSchema2(), lumi::HLTV32DB::writeHltDataToSchema2(), and lumi::TRGScalers2DB::writeTrgDataToSchema2().

                                                            {
  lumi::idDealer idg(schema);
  const std::string entrytableName=lumi::LumiNames::entryTableName(datatableName);
  entry.revision_id=idg.generateNextIDForTable(lumi::LumiNames::revisionTableName());
  entry.data_id=idg.generateNextIDForTable(datatableName);
  entry.entry_id=idg.generateNextIDForTable(entrytableName);
}
void lumi::RevisionDML::bookNewRevision ( coral::ISchema &  schema,
const std::string &  datatableName,
Entry revision 
)

allocate new revision_id,data_id

Definition at line 56 of file RevisionDML.cc.

References lumi::RevisionDML::Entry::data_id, lumi::idDealer::generateNextIDForTable(), lumi::RevisionDML::Entry::revision_id, and lumi::LumiNames::revisionTableName().

Referenced by lumi::Lumi2DB::writeAllLumiDataToSchema2(), lumi::HLTV32DB::writeHltDataToSchema2(), and lumi::TRGScalers2DB::writeTrgDataToSchema2().

                                                                  {
  lumi::idDealer idg(schema);
  revision.revision_id=idg.generateNextIDForTable(lumi::LumiNames::revisionTableName());
  revision.data_id=idg.generateNextIDForTable(datatableName);
}
unsigned long long lumi::RevisionDML::branchIdByName ( coral::ISchema &  schema,
const std::string &  branchName 
)

select revision_id from revisions where name=:branchName

unsigned long long lumi::RevisionDML::currentHFDataTagId ( coral::ISchema &  schema)

Definition at line 190 of file RevisionDML.cc.

References lumi::LumiNames::tagsTableName().

Referenced by LumiCorrectionSource::fillparamcache().

                                                       {
  unsigned long long currentdatatagid=0;
  std::vector<unsigned long long> alltagids;
  coral::IQuery* qHandle=schema.newQuery();
  qHandle->addToTableList( lumi::LumiNames::tagsTableName());
  qHandle->addToOutputList("TAGID");
  coral::AttributeList qResult;
  qResult.extend("TAGID",typeid(unsigned long long));
  qHandle->defineOutput(qResult);
  coral::ICursor& cursor=qHandle->execute();
  while(cursor.next()){
    if(!cursor.currentRow()["TAGID"].isNull()){
      alltagids.push_back(cursor.currentRow()["TAGID"].data<unsigned long long>());
    }
  }
  delete qHandle;
  if(alltagids.size()>0){
    std::vector<unsigned long long>::iterator currentdatatagidIt=std::max_element(alltagids.begin(),alltagids.end());
    currentdatatagid=*currentdatatagidIt;
  }
  return currentdatatagid;
}
lumi::RevisionDML::DataID lumi::RevisionDML::dataIDForRun ( coral::ISchema &  schema,
unsigned int  runnum,
unsigned long long  tagid 
)

Definition at line 272 of file RevisionDML.cc.

References lumi::RevisionDML::DataID::hlt_id, lumi::RevisionDML::DataID::lumi_id, cond::lumiid, query::result, AlCaHLTBitMon_QueryRunRegistry::string, lumi::LumiNames::tagRunsTableName(), and lumi::RevisionDML::DataID::trg_id.

Referenced by LumiCorrectionSource::fillparamcache().

                                                   {
  lumi::RevisionDML::DataID result;
  coral::IQuery* qHandle=schema.newQuery();
  qHandle->addToTableList( lumi::LumiNames::tagRunsTableName());
  qHandle->addToOutputList("LUMIDATAID");
  qHandle->addToOutputList("TRGDATAID");
  qHandle->addToOutputList("HLTDATAID");
  coral::AttributeList qResult;
  qResult.extend("LUMIDATAID",typeid(unsigned long long));
  qResult.extend("TRGDATAID",typeid(unsigned long long));
  qResult.extend("HLTDATAID",typeid(unsigned long long));
  qHandle->defineOutput(qResult);
  coral::AttributeList qCondition;
  qCondition.extend("tagid",typeid(unsigned long long));
  qCondition.extend("runnum",typeid(unsigned int));
  qCondition["tagid"].data<unsigned long long>()=tagid;
  qCondition["runnum"].data<unsigned int>()=runnum;
  std::string qConditionStr("TAGID<=:tagid AND RUNNUM=:runnum");
  qHandle->setCondition(qConditionStr,qCondition);
  coral::ICursor& cursor=qHandle->execute();
  unsigned long long minlumid=0;
  unsigned long long mintrgid=0;
  unsigned long long minhltid=0;
  while(cursor.next()){
    if(!cursor.currentRow()["LUMIDATAID"].isNull()){
      unsigned long long lumiid=cursor.currentRow()["LUMIDATAID"].data<unsigned long long>();      
      if(lumiid>minlumid){
        result.lumi_id=lumiid;
      }
      
    }
    if(!cursor.currentRow()["TRGDATAID"].isNull()){
      unsigned long long trgid=cursor.currentRow()["TRGDATAID"].data<unsigned long long>();      
      if(trgid>mintrgid){
        result.trg_id=trgid;
      }
    }
    if(!cursor.currentRow()["HLTDATAID"].isNull()){
      unsigned long long hltid=cursor.currentRow()["HLTDATAID"].data<unsigned long long>();  
      if(hltid>minhltid){
        result.hlt_id=hltid;
      }
    }
  }
  delete qHandle;
  return result;
}
unsigned long long lumi::RevisionDML::getEntryInBranchByName ( coral::ISchema &  schema,
const std::string &  datatableName,
const std::string &  entryname,
const std::string &  branchname 
)

select e.entry_id from entrytabl e,revisiontable r where r.revision_id=e.revision_id and e.name=:entryname and r.branch_name=:branchname

Definition at line 17 of file RevisionDML.cc.

References lumi::LumiNames::entryTableName(), lumi::LumiNames::revisionTableName(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by lumi::Lumi2DB::writeAllLumiDataToSchema2(), lumi::HLTV32DB::writeHltDataToSchema2(), and lumi::TRGScalers2DB::writeTrgDataToSchema2().

                                                                      {
  unsigned long long entry_id=0;
  coral::IQuery* qHandle=schema.newQuery();
  qHandle->addToTableList( lumi::LumiNames::entryTableName(datatableName),"e");
  qHandle->addToTableList( lumi::LumiNames::revisionTableName(),"r");
  qHandle->addToOutputList("e.ENTRY_ID","entry_id");

  coral::AttributeList qCondition;
  qCondition.extend("entryname",typeid(std::string));
  qCondition.extend("branchname",typeid(std::string));
  qCondition["entryname"].data<std::string>()=entryname;
  qCondition["branchname"].data<std::string>()=branchname;
  std::string qConditionStr("r.REVISION_ID=e.REVISION_ID and e.NAME=:entryname AND r.BRANCH_NAME=:branchname");

  coral::AttributeList qResult;
  qResult.extend("entry_id",typeid(unsigned long long));
  qHandle->defineOutput(qResult);
  qHandle->setCondition(qConditionStr,qCondition);
  coral::ICursor& cursor=qHandle->execute();
  while(cursor.next()){
    entry_id=cursor.currentRow()["entry_id"].data<unsigned long long>();
  }
  delete qHandle;
  return entry_id;
}
unsigned long long lumi::RevisionDML::HFDataTagIdByName ( coral::ISchema &  schema,
const std::string &  datatagname 
)

Definition at line 214 of file RevisionDML.cc.

References lumiCalc2::datatagid, AlCaHLTBitMon_QueryRunRegistry::string, and lumi::LumiNames::tagsTableName().

Referenced by LumiCorrectionSource::fillparamcache().

                                                                  {
  unsigned long long datatagid=0;
  coral::IQuery* qHandle=schema.newQuery();
  qHandle->addToTableList( lumi::LumiNames::tagsTableName());
  const std::string conditionStr("TAGNAME=:tagname");
  coral::AttributeList condition;
  condition.extend("tagname",typeid(std::string));
  condition["tagname"].data<std::string>()=datatagname;
  qHandle->addToOutputList("TAGID");
  coral::AttributeList qResult;
  qResult.extend("TAGID",typeid(unsigned long long));
  qHandle->setCondition(conditionStr,condition);
  qHandle->defineOutput(qResult);
  coral::ICursor& cursor=qHandle->execute();
  while(cursor.next()){
    if(!cursor.currentRow()["TAGID"].isNull()){
      datatagid=cursor.currentRow()["TAGID"].data<unsigned long long>();
    }
  }
  delete qHandle;
  return datatagid;
}
void lumi::RevisionDML::insertHltRunData ( coral::ISchema &  schema,
const HltEntry hltentry 
)

Definition at line 168 of file RevisionDML.cc.

References lumi::RevisionDML::Entry::data_id, lumi::RevisionDML::Entry::entry_id, lumi::RevisionDML::Entry::entry_name, lumi::LumiNames::hltdataTableName(), nameDealer::hltdataTableName(), dataDML::hltrundata, lumi::RevisionDML::HltEntry::npath, lumi::RevisionDML::HltEntry::pathnames, lumi::RevisionDML::HltEntry::runnumber, lumi::RevisionDML::HltEntry::source, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by lumi::HLTV32DB::writeHltDataToSchema2().

                                                                            {
  coral::AttributeList hltrundata;
  hltrundata.extend("DATA_ID",typeid(unsigned long long));
  hltrundata.extend("ENTRY_ID",typeid(unsigned long long));
  hltrundata.extend("ENTRY_NAME",typeid(std::string));
  hltrundata.extend("RUNNUM",typeid(unsigned int));
  hltrundata.extend("SOURCE",typeid(std::string));
  hltrundata.extend("NPATH",typeid(unsigned int));
  hltrundata.extend("PATHNAMECLOB",typeid(std::string));
  hltrundata["DATA_ID"].data<unsigned long long>()=hltentry.data_id;
  hltrundata["ENTRY_ID"].data<unsigned long long>()=hltentry.entry_id;
  hltrundata["ENTRY_NAME"].data<std::string>()=hltentry.entry_name;
  hltrundata["RUNNUM"].data<unsigned int>()=hltentry.runnumber;
  hltrundata["SOURCE"].data<std::string>()=hltentry.source;
  hltrundata["NPATH"].data<unsigned int>()=hltentry.npath;
  hltrundata["PATHNAMECLOB"].data<std::string>()=hltentry.pathnames;
  const std::string hltdataTableName=lumi::LumiNames::hltdataTableName();
  schema.tableHandle(hltdataTableName).dataEditor().insertRow(hltrundata);
}
void lumi::RevisionDML::insertLumiRunData ( coral::ISchema &  schema,
const LumiEntry lumientry 
)

Definition at line 126 of file RevisionDML.cc.

References lumi::RevisionDML::LumiEntry::bgev, lumi::RevisionDML::Entry::data_id, lumi::RevisionDML::Entry::entry_id, lumi::RevisionDML::Entry::entry_name, lumi::LumiNames::lumidataTableName(), nameDealer::lumidataTableName(), dataDML::lumirundata, lumi::RevisionDML::LumiEntry::ncollidingbunches, lumi::RevisionDML::LumiEntry::runnumber, lumi::RevisionDML::LumiEntry::source, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by lumi::Lumi2DB::writeAllLumiDataToSchema2().

                                                                               {
  coral::AttributeList lumirundata;
  lumirundata.extend("DATA_ID",typeid(unsigned long long));
  lumirundata.extend("ENTRY_ID",typeid(unsigned long long));
  lumirundata.extend("ENTRY_NAME",typeid(std::string));
  lumirundata.extend("RUNNUM",typeid(unsigned int));
  lumirundata.extend("SOURCE",typeid(std::string));
  lumirundata.extend("NOMINALEGEV",typeid(float));
  lumirundata.extend("NCOLLIDINGBUNCHES",typeid(unsigned int));
  lumirundata["DATA_ID"].data<unsigned long long>()=lumientry.data_id;
  lumirundata["ENTRY_ID"].data<unsigned long long>()=lumientry.entry_id;
  lumirundata["ENTRY_NAME"].data<std::string>()=lumientry.entry_name;
  lumirundata["RUNNUM"].data<unsigned int>()=lumientry.runnumber;
  lumirundata["SOURCE"].data<std::string>()=lumientry.source;
  lumirundata["NOMINALEGEV"].data<float>()=lumientry.bgev;
  lumirundata["NCOLLIDINGBUNCHES"].data<unsigned int>()=lumientry.ncollidingbunches;
  const std::string lumidataTableName=lumi::LumiNames::lumidataTableName();
  schema.tableHandle(lumidataTableName).dataEditor().insertRow(lumirundata);
}
void lumi::RevisionDML::insertTrgRunData ( coral::ISchema &  schema,
const TrgEntry trgentry 
)

Definition at line 147 of file RevisionDML.cc.

References lumi::RevisionDML::TrgEntry::bitnames, lumi::RevisionDML::TrgEntry::bitzeroname, lumi::RevisionDML::Entry::data_id, lumi::RevisionDML::Entry::entry_id, lumi::RevisionDML::Entry::entry_name, lumi::RevisionDML::TrgEntry::runnumber, lumi::RevisionDML::TrgEntry::source, AlCaHLTBitMon_QueryRunRegistry::string, nameDealer::trgdataTableName(), lumi::LumiNames::trgdataTableName(), and dataDML::trgrundata.

Referenced by lumi::TRGScalers2DB::writeTrgDataToSchema2().

                                                                            {
  coral::AttributeList trgrundata;
  trgrundata.extend("DATA_ID",typeid(unsigned long long));
  trgrundata.extend("ENTRY_ID",typeid(unsigned long long));
  trgrundata.extend("ENTRY_NAME",typeid(std::string));
  trgrundata.extend("RUNNUM",typeid(unsigned int));
  trgrundata.extend("SOURCE",typeid(std::string));
  trgrundata.extend("BITZERONAME",typeid(std::string));
  trgrundata.extend("BITNAMECLOB",typeid(std::string));
  trgrundata["DATA_ID"].data<unsigned long long>()=trgentry.data_id;
  trgrundata["ENTRY_ID"].data<unsigned long long>()=trgentry.entry_id;
  trgrundata["ENTRY_NAME"].data<std::string>()=trgentry.entry_name;
  trgrundata["RUNNUM"].data<unsigned int>()=trgentry.runnumber;
  trgrundata["SOURCE"].data<std::string>()=trgentry.source;
  trgrundata["BITZERONAME"].data<std::string>()=trgentry.bitzeroname;
  trgrundata["BITNAMECLOB"].data<std::string>()=trgentry.bitnames;
  const std::string trgdataTableName=lumi::LumiNames::trgdataTableName();
  schema.tableHandle(trgdataTableName).dataEditor().insertRow(trgrundata);
}