CMS 3D CMS Logo

List of all members | Public Member Functions
lumi::TRGDummy2DB Class Reference
Inheritance diagram for lumi::TRGDummy2DB:
lumi::DataPipe

Public Member Functions

const std::string dataType () const override
 
unsigned long long retrieveData (unsigned int) override
 
const std::string sourceType () const override
 
 TRGDummy2DB (const std::string &dest)
 
 ~TRGDummy2DB () override
 
- Public Member Functions inherited from lumi::DataPipe
 DataPipe (const std::string &)
 
 DataPipe (const DataPipe &)=delete
 
std::string getAuthPath () const
 
std::string getMode () const
 
float getNorm () const
 
std::string getSource () const
 
const DataPipeoperator= (const DataPipe &)=delete
 
void setAuthPath (const std::string &authpath)
 
void setMode (const std::string &mode)
 
void setNoCheckingStableBeam ()
 
void setNorm (float norm)
 
void setNoValidate ()
 
void setSource (const std::string &source)
 
virtual ~DataPipe ()
 

Additional Inherited Members

- Protected Attributes inherited from lumi::DataPipe
std::string m_authpath
 
std::string m_dest
 
std::string m_mode
 
bool m_nocheckingstablebeam
 
float m_norm
 
bool m_novalidate
 
std::string m_source
 

Detailed Description

Definition at line 25 of file TRGDummy2DB.cc.

Constructor & Destructor Documentation

◆ TRGDummy2DB()

lumi::TRGDummy2DB::TRGDummy2DB ( const std::string &  dest)

Definition at line 36 of file TRGDummy2DB.cc.

36 : DataPipe(dest) {}
DataPipe(const std::string &)
Definition: DataPipe.cc:2

◆ ~TRGDummy2DB()

lumi::TRGDummy2DB::~TRGDummy2DB ( )
override

Definition at line 116 of file TRGDummy2DB.cc.

116 {}

Member Function Documentation

◆ dataType()

const std::string lumi::TRGDummy2DB::dataType ( ) const
overridevirtual

Implements lumi::DataPipe.

Definition at line 114 of file TRGDummy2DB.cc.

114 { return "TRG"; }

◆ retrieveData()

unsigned long long lumi::TRGDummy2DB::retrieveData ( unsigned int  runnum)
overridevirtual

Implements lumi::DataPipe.

Definition at line 37 of file TRGDummy2DB.cc.

References DummyCfis::c, submitPVResolutionJobs::count, gather_cfg::cout, Exception, lumi::idDealer::generateNextIDForTable(), mps_fire::i, dqmiolumiharvest::j, lumi::DataPipe::m_authpath, lumi::DataPipe::m_dest, lumi::N_TRGALGOBIT, lumi::N_TRGTECHBIT, runnum, lumi::DBConfig::setAuthentication(), AlCaHLTBitMon_QueryRunRegistry::string, and lumi::LumiNames::trgTableName().

37  {
38  //
39  //generate dummy data of trg for the given run and write data to LumiDB
40  //
41  coral::ConnectionService* svc = new coral::ConnectionService;
42  lumi::DBConfig dbconf(*svc);
43 
44  if (!m_authpath.empty()) {
45  dbconf.setAuthentication(m_authpath);
46  }
47  coral::ISessionProxy* session = svc->connect(m_dest, coral::Update);
48  coral::ITypeConverter& tpc = session->typeConverter();
49  tpc.setCppTypeForSqlType("unsigned int", "NUMBER(7)");
50  tpc.setCppTypeForSqlType("unsigned int", "NUMBER(10)");
51  tpc.setCppTypeForSqlType("unsigned long long", "NUMBER(20)");
52  try {
53  unsigned int totalcmsls = 32;
54  session->transaction().start(false);
55  coral::ISchema& schema = session->nominalSchema();
56  lumi::idDealer idg(schema);
57  coral::ITable& trgtable = schema.tableHandle(LumiNames::trgTableName());
58  coral::AttributeList trgData;
59  trgData.extend("TRG_ID", typeid(unsigned long long));
60  trgData.extend("RUNNUM", typeid(unsigned int));
61  trgData.extend("CMSLSNUM", typeid(unsigned int));
62  trgData.extend("BITNUM", typeid(unsigned int));
63  trgData.extend("BITNAME", typeid(std::string));
64  trgData.extend("TRGCOUNT", typeid(unsigned int));
65  trgData.extend("DEADTIME", typeid(unsigned long long));
66  trgData.extend("PRESCALE", typeid(unsigned int));
67  coral::IBulkOperation* trgInserter =
68  trgtable.dataEditor().bulkInsert(trgData, totalcmsls * (lumi::N_TRGALGOBIT + lumi::N_TRGTECHBIT));
69  //loop over lumi LS
70  unsigned long long& trg_id = trgData["TRG_ID"].data<unsigned long long>();
71  unsigned int& trgrunnum = trgData["RUNNUM"].data<unsigned int>();
72  unsigned int& cmslsnum = trgData["CMSLSNUM"].data<unsigned int>();
73  unsigned int& bitnum = trgData["BITNUM"].data<unsigned int>();
74  std::string& bitname = trgData["BITNAME"].data<std::string>();
75  unsigned int& count = trgData["TRGCOUNT"].data<unsigned int>();
76  unsigned long long& deadtime = trgData["DEADTIME"].data<unsigned long long>();
77  unsigned int& prescale = trgData["PRESCALE"].data<unsigned int>();
78 
79  for (unsigned int i = 1; i <= totalcmsls; ++i) {
80  for (unsigned int j = 0; j < (lumi::N_TRGALGOBIT + lumi::N_TRGTECHBIT); ++j) { //total n of trg bits
81  trg_id = idg.generateNextIDForTable(LumiNames::trgTableName());
82  trgrunnum = runnum;
83  cmslsnum = i;
84  bitnum = j;
85  char c[10];
86  if (j > (lumi::N_TRGALGOBIT - 1)) {
87  ::sprintf(c, "%d", j - (lumi::N_TRGALGOBIT - 1));
88  bitname = std::string(c);
89  } else {
90  ::sprintf(c, "%d", j);
91  bitname = std::string("FakeTRGBIT_") + std::string(c);
92  }
93  count = 12345;
94  deadtime = 6785;
95  prescale = 1;
96  trgInserter->processNextIteration();
97  }
98  }
99  trgInserter->flush();
100  delete trgInserter;
101  } catch (const coral::Exception& er) {
102  std::cout << "database problem " << er.what() << std::endl;
103  session->transaction().rollback();
104  delete session;
105  delete svc;
106  throw er;
107  }
108  //delete detailInserter;
109  session->transaction().commit();
110  delete session;
111  delete svc;
112  return 0;
113  }
static const std::string trgTableName()
Definition: LumiNames.cc:13
int runnum
std::string m_dest
Definition: DataPipe.h:29
const unsigned int N_TRGTECHBIT
Definition: ConstantDef.h:7
std::string m_authpath
Definition: DataPipe.h:31
const unsigned int N_TRGALGOBIT
Definition: ConstantDef.h:6

◆ sourceType()

const std::string lumi::TRGDummy2DB::sourceType ( ) const
overridevirtual

Implements lumi::DataPipe.

Definition at line 115 of file TRGDummy2DB.cc.

115 { return "DUMMY"; }