CMS 3D CMS Logo

HLTDummy2DB.cc
Go to the documentation of this file.
1 #ifndef RecoLuminosity_LumiProducer_HLTDummy2DB_h
2 #define RecoLuminosity_LumiProducer_HLTDummy2DB_h
3 #include "RelationalAccess/ConnectionService.h"
4 #include "RelationalAccess/ISessionProxy.h"
5 #include "RelationalAccess/ITransaction.h"
6 #include "RelationalAccess/ISchema.h"
7 #include "RelationalAccess/ITable.h"
8 #include "RelationalAccess/ITableDataEditor.h"
9 #include "RelationalAccess/IBulkOperation.h"
10 #include "CoralBase/AttributeList.h"
11 #include "CoralBase/AttributeSpecification.h"
12 #include "CoralBase/Attribute.h"
13 #include "CoralBase/Exception.h"
19 #include <iostream>
20 #include <cstdio>
21 namespace lumi {
22  class HLTDummy2DB : public DataPipe {
23  public:
25  unsigned long long retrieveData(unsigned int) override;
26  const std::string dataType() const override;
27  const std::string sourceType() const override;
28  ~HLTDummy2DB() override;
29  }; //cl HLTDummy2DB
30  //
31  //implementation
32  //
34  unsigned long long HLTDummy2DB::retrieveData(unsigned int runnum) {
35  //
36  //generate dummy data of hlt for the given run and write data to LumiDB
37  //
38  coral::ConnectionService* svc = new coral::ConnectionService;
39  lumi::DBConfig dbconf(*svc);
40  if (!m_authpath.empty()) {
42  }
43  coral::ISessionProxy* session = svc->connect(m_dest, coral::Update);
44  try {
45  unsigned int totalcmsls = 32;
46  session->transaction().start(false);
47  coral::ISchema& schema = session->nominalSchema();
48  lumi::idDealer idg(schema);
49  coral::ITable& hlttable = schema.tableHandle(LumiNames::hltTableName());
50  coral::AttributeList hltData;
51  hltData.extend<unsigned long long>("HLT_ID");
52  hltData.extend<unsigned int>("RUNNUM");
53  hltData.extend<unsigned int>("CMSLSNUM");
54  hltData.extend<std::string>("PATHNAME");
55  hltData.extend<unsigned long long>("INPUTCOUNT");
56  hltData.extend<unsigned long long>("ACCEPTCOUNT");
57  hltData.extend<unsigned int>("PRESCALE");
58  coral::IBulkOperation* hltInserter = hlttable.dataEditor().bulkInsert(hltData, totalcmsls * 260);
59  //loop over lumi LS
60  unsigned long long& hlt_id = hltData["HLT_ID"].data<unsigned long long>();
61  unsigned int& hltrunnum = hltData["RUNNUM"].data<unsigned int>();
62  unsigned int& cmslsnum = hltData["CMSLSNUM"].data<unsigned int>();
63  std::string& pathname = hltData["PATHNAME"].data<std::string>();
64  unsigned long long& inputcount = hltData["INPUTCOUNT"].data<unsigned long long>();
65  unsigned long long& acceptcount = hltData["ACCEPTCOUNT"].data<unsigned long long>();
66  unsigned int& prescale = hltData["PRESCALE"].data<unsigned int>();
67 
68  for (unsigned int i = 1; i <= totalcmsls; ++i) {
69  for (unsigned int j = 1; j < 165; ++j) {
71  hltrunnum = runnum;
72  cmslsnum = i;
73  char c[10];
74  ::sprintf(c, "%d", j);
75  pathname = std::string("FakeHLTPath_") + std::string(c);
76  inputcount = 12345;
77  acceptcount = 10;
78  prescale = 1;
79  hltInserter->processNextIteration();
80  }
81  }
82  hltInserter->flush();
83  delete hltInserter;
84  } catch (const coral::Exception& er) {
85  std::cout << "database problem " << er.what() << std::endl;
86  session->transaction().rollback();
87  delete session;
88  delete svc;
89  throw er;
90  }
91  //delete detailInserter;
92  session->transaction().commit();
93  delete session;
94  delete svc;
95  return 0;
96  }
97  const std::string HLTDummy2DB::dataType() const { return "HLT"; }
98  const std::string HLTDummy2DB::sourceType() const { return "DUMMY"; }
100 } // namespace lumi
103 #endif
int runnum
HLTDummy2DB(const std::string &dest)
Definition: HLTDummy2DB.cc:33
~HLTDummy2DB() override
Definition: HLTDummy2DB.cc:99
std::string m_dest
Definition: DataPipe.h:29
unsigned long long retrieveData(unsigned int) override
Definition: HLTDummy2DB.cc:34
void setAuthentication(const std::string &authPath)
Definition: DBConfig.cc:15
const std::string dataType() const override
Definition: HLTDummy2DB.cc:97
static const std::string hltTableName()
Definition: LumiNames.cc:14
const std::string sourceType() const override
Definition: HLTDummy2DB.cc:98
unsigned long long generateNextIDForTable(const std::string &tableName, unsigned int interval=1)
Definition: idDealer.cc:33
std::string m_authpath
Definition: DataPipe.h:31
#define DEFINE_EDM_PLUGIN(factory, type, name)