Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:26:34

0001 #ifndef RecoLuminosity_LumiProducer_RevisionDML_H
0002 #define RecoLuminosity_LumiProducer_RevisionDML_H
0003 #include <string>
0004 #include <vector>
0005 namespace coral {
0006   class ISchema;
0007 }
0008 namespace lumi {
0009   class RevisionDML {
0010   public:
0011     //class Revision{
0012     //public:
0013     //  Revision():revision_id(0),data_id(0){}
0014     //  unsigned long long revision_id;
0015     //  unsigned long long data_id;
0016     //};
0017     class DataID {
0018     public:
0019       DataID() : lumi_id(0), trg_id(0), hlt_id(0) {}
0020 
0021     public:
0022       unsigned long long lumi_id;
0023       unsigned long long trg_id;
0024       unsigned long long hlt_id;
0025     };
0026     class Entry {
0027     public:
0028       Entry() : revision_id(0), entry_id(0), data_id(0), entry_name("") {}
0029       unsigned long long revision_id;
0030       unsigned long long entry_id;
0031       unsigned long long data_id;
0032       std::string entry_name;
0033     };
0034     class LumiEntry : public Entry {
0035     public:
0036       LumiEntry() : source(""), runnumber(0), bgev(0.0) {}
0037       std::string source;
0038       unsigned int runnumber;
0039       float bgev;
0040       unsigned int ncollidingbunches;
0041     };
0042     class TrgEntry : public Entry {
0043     public:
0044       TrgEntry() : source(""), runnumber(0), bitzeroname("") {}
0045       std::string source;
0046       unsigned int runnumber;
0047       std::string bitzeroname;
0048       std::string bitnames;
0049     };
0050     class HltEntry : public Entry {
0051     public:
0052       HltEntry() : source(""), runnumber(0), npath(0) {}
0053       std::string source;
0054       unsigned int runnumber;
0055       unsigned int npath;
0056       std::string pathnames;
0057     };
0058 
0059     /**
0060        select revision_id from revisions where name=:branchName
0061     **/
0062     unsigned long long branchIdByName(coral::ISchema& schema, const std::string& branchName);
0063 
0064     /**
0065        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
0066     **/
0067     unsigned long long getEntryInBranchByName(coral::ISchema& schema,
0068                                               const std::string& datatableName,
0069                                               const std::string& entryname,
0070                                               const std::string& branchname);
0071     /**
0072        allocate new revision_id,entry_id,data_id
0073      **/
0074     void bookNewEntry(coral::ISchema& schema, const std::string& datatableName, Entry& entry);
0075     /**
0076        allocate new revision_id,data_id
0077     **/
0078     void bookNewRevision(coral::ISchema& schema, const std::string& datatableName, Entry& revision);
0079     /**
0080        1. allocate and insert a new revision in the revisions table
0081        2. allocate and insert a new entry into the entry table with the new revision
0082        3. insert into data_rev table new data_id,revision_id mapping
0083        insert into revisions(revision_id,branch_id,branch_name,comment,ctime) values()
0084        insert into datatablename_entries (entry_id,revision_id) values()
0085        insert into datatablename_rev(data_id,revision_id) values()
0086     **/
0087     void addEntry(coral::ISchema& schema,
0088                   const std::string& datatableName,
0089                   const Entry& entry,
0090                   unsigned long long branch_id,
0091                   const std::string& branchname);
0092     /**
0093        1.insert a new revision into the revisions table
0094        2.insert into data_id, revision_id pair to  datatable_revmap
0095        insert into revisions(revision_id,branch_id,branch_name,ctime) values()
0096        insert into datatable_rev(data_id,revision_id) values())
0097     **/
0098     void addRevision(coral::ISchema& schema,
0099                      const std::string& datatableName,
0100                      const Entry& revision,
0101                      unsigned long long branch_id,
0102                      std::string& branchname);
0103     void insertLumiRunData(coral::ISchema& schema, const LumiEntry& lumientry);
0104     void insertTrgRunData(coral::ISchema& schema, const TrgEntry& trgentry);
0105     void insertHltRunData(coral::ISchema& schema, const HltEntry& hltentry);
0106 
0107     unsigned long long currentHFDataTagId(coral::ISchema& schema);
0108     unsigned long long HFDataTagIdByName(coral::ISchema& schema, const std::string& datatagname);
0109     unsigned long long addRunToCurrentHFDataTag(coral::ISchema& schema,
0110                                                 unsigned int runnum,
0111                                                 unsigned long long lumiid,
0112                                                 unsigned long long trgid,
0113                                                 unsigned long long hltid,
0114                                                 const std::string& patchcomment);
0115     DataID dataIDForRun(coral::ISchema& schema, unsigned int runnum, unsigned long long tagid);
0116   };
0117 }  // namespace lumi
0118 #endif