CMS 3D CMS Logo

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

Public Member Functions

const std::string dataType () const override
 
 LumiDummy2DB (const std::string &dest)
 
unsigned long long retrieveData (unsigned int) override
 
const std::string sourceType () const override
 
 ~LumiDummy2DB () 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 27 of file LumiDummy2DB.cc.

Constructor & Destructor Documentation

◆ LumiDummy2DB()

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

Definition at line 38 of file LumiDummy2DB.cc.

38  : DataPipe(dest) {
39  //check the format of dest
40  }
DataPipe(const std::string &)
Definition: DataPipe.cc:2

◆ ~LumiDummy2DB()

lumi::LumiDummy2DB::~LumiDummy2DB ( )
override

Definition at line 187 of file LumiDummy2DB.cc.

187 {}

Member Function Documentation

◆ dataType()

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

Implements lumi::DataPipe.

Definition at line 185 of file LumiDummy2DB.cc.

185 { return "LUMI"; }

◆ retrieveData()

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

Implements lumi::DataPipe.

Definition at line 41 of file LumiDummy2DB.cc.

References Exception, lumi::idDealer::generateNextIDForTable(), mps_fire::i, dqmiolumiharvest::j, isotrackApplyRegressor::k, lumi::LumiNames::lumidetailTableName(), lumi::LumiNames::lumisummaryTableName(), FastTimerService_cff::lumiversion, lumi::DataPipe::m_authpath, lumi::DataPipe::m_dest, lumi::N_BX, lumi::N_LUMIALGO, runnum, run_AlCaRecoTriggerBitsUpdateWorkflow::session, lumi::DBConfig::setAuthentication(), and AlCaHLTBitMon_QueryRunRegistry::string.

41  {
42  //
43  //generate dummy data for lumi summary and detail for the given run and write data to LumiDB
44  //
45  coral::ConnectionService* svc = new coral::ConnectionService;
46  lumi::DBConfig dbconf(*svc);
47  if (!m_authpath.empty()) {
48  dbconf.setAuthentication(m_authpath);
49  }
50  coral::ISessionProxy* session = svc->connect(m_dest, coral::Update);
51  coral::ITypeConverter& tpc = session->typeConverter();
52  tpc.setCppTypeForSqlType("unsigned int", "NUMBER(10)");
53  try {
54  unsigned int totallumils = 35;
55  unsigned int totalcmsls = 32;
56  session->transaction().start(false);
57  coral::ISchema& schema = session->nominalSchema();
58  lumi::idDealer idg(schema);
59  coral::ITable& summarytable = schema.tableHandle(LumiNames::lumisummaryTableName());
60  coral::ITable& detailtable = schema.tableHandle(LumiNames::lumidetailTableName());
61  coral::AttributeList summaryData;
62  summaryData.extend("LUMISUMMARY_ID", typeid(unsigned long long));
63  summaryData.extend("RUNNUM", typeid(unsigned int));
64  summaryData.extend("CMSLSNUM", typeid(unsigned int));
65  summaryData.extend("LUMILSNUM", typeid(unsigned int));
66  summaryData.extend("LUMIVERSION", typeid(std::string));
67  summaryData.extend("DTNORM", typeid(float));
68  summaryData.extend("LHCNORM", typeid(float));
69  summaryData.extend("INSTLUMI", typeid(float));
70  summaryData.extend("INSTLUMIERROR", typeid(float));
71  summaryData.extend("INSTLUMIQUALITY", typeid(short));
72  summaryData.extend("LUMISECTIONQUALITY", typeid(short));
73  summaryData.extend("CMSALIVE", typeid(short));
74  summaryData.extend("STARTORBIT", typeid(unsigned int));
75  summaryData.extend("NUMORBIT", typeid(unsigned int));
76  summaryData.extend("BEAMENERGY", typeid(float));
77  summaryData.extend("BEAMSTATUS", typeid(std::string));
78 
79  coral::IBulkOperation* summaryInserter = summarytable.dataEditor().bulkInsert(summaryData, totallumils);
80  coral::AttributeList detailData;
81  detailData.extend("LUMIDETAIL_ID", typeid(unsigned long long));
82  detailData.extend("LUMISUMMARY_ID", typeid(unsigned long long));
83  detailData.extend("BXLUMIVALUE", typeid(coral::Blob));
84  detailData.extend("BXLUMIERROR", typeid(coral::Blob));
85  detailData.extend("BXLUMIQUALITY", typeid(coral::Blob));
86  detailData.extend("ALGONAME", typeid(std::string));
87  coral::IBulkOperation* detailInserter = detailtable.dataEditor().bulkInsert(detailData, totallumils * N_LUMIALGO);
88  //loop over lumi LS
89  unsigned long long& lumisummary_id = summaryData["LUMISUMMARY_ID"].data<unsigned long long>();
90  unsigned int& lumirunnum = summaryData["RUNNUM"].data<unsigned int>();
91  unsigned int& cmslsnum = summaryData["CMSLSNUM"].data<unsigned int>();
92  unsigned int& lumilsnum = summaryData["LUMILSNUM"].data<unsigned int>();
93  std::string& lumiversion = summaryData["LUMIVERSION"].data<std::string>();
94  float& dtnorm = summaryData["DTNORM"].data<float>();
95  float& lhcnorm = summaryData["LHCNORM"].data<float>();
96  float& instlumi = summaryData["INSTLUMI"].data<float>();
97  float& instlumierror = summaryData["INSTLUMIERROR"].data<float>();
98  short& instlumiquality = summaryData["INSTLUMIQUALITY"].data<short>();
99  short& lumisectionquality = summaryData["LUMISECTIONQUALITY"].data<short>();
100  short& cmsalive = summaryData["CMSALIVE"].data<short>();
101  unsigned int& startorbit = summaryData["STARTORBIT"].data<unsigned int>();
102  unsigned int& numorbit = summaryData["NUMORBIT"].data<unsigned int>();
103  float& beamenergy = summaryData["BEAMENERGY"].data<float>();
104  std::string& beamstatus = summaryData["BEAMSTATUS"].data<std::string>();
105 
106  unsigned long long& lumidetail_id = detailData["LUMIDETAIL_ID"].data<unsigned long long>();
107  unsigned long long& d2lumisummary_id = detailData["LUMISUMMARY_ID"].data<unsigned long long>();
108  coral::Blob& bxlumivalue = detailData["BXLUMIVALUE"].data<coral::Blob>();
109  coral::Blob& bxlumierror = detailData["BXLUMIERROR"].data<coral::Blob>();
110  coral::Blob& bxlumiquality = detailData["BXLUMIQUALITY"].data<coral::Blob>();
111  std::string& algoname = detailData["ALGONAME"].data<std::string>();
112  for (unsigned int i = 1; i <= totallumils; ++i) {
113  lumisummary_id = idg.generateNextIDForTable(LumiNames::lumisummaryTableName());
114  lumilsnum = i;
115  lumirunnum = runnum;
116  lumiversion = "0";
117  dtnorm = 1.05;
118  lhcnorm = 1.2;
119  instlumi = 0.9;
120  instlumierror = 0.01;
121  instlumiquality = 8;
122  lumisectionquality = 16;
123  // unsigned int cmslsnum = 0;
124  short iscmsalive = 0;
125  if (i <= totalcmsls) {
126  iscmsalive = 1;
127  cmslsnum = i;
128  }
129  cmsalive = iscmsalive;
130  startorbit = 2837495;
131  numorbit = 34566;
132  beamenergy = 362;
133  beamstatus = "stable";
134  //fetch a new id value
135  //insert the new row
136  summaryInserter->processNextIteration();
137  summaryInserter->flush();
138  d2lumisummary_id = i;
139  for (unsigned int j = 0; j < N_LUMIALGO; ++j) {
140  lumidetail_id = idg.generateNextIDForTable(LumiNames::lumidetailTableName());
141  if (j == 0)
142  algoname = std::string("ET");
143  if (j == 1)
144  algoname = std::string("OCC1");
145  if (j == 2)
146  algoname = std::string("OCC2");
147  float lumivalue[N_BX];
148  std::memset((void*)&lumivalue, 0, sizeof(float) * N_BX);
149  float lumierror[N_BX];
150  std::memset((void*)&lumierror, 0, sizeof(float) * N_BX);
151  short lumiquality[N_BX];
152  std::memset((void*)&lumiquality, 0, sizeof(short) * N_BX);
153  bxlumivalue.resize(sizeof(float) * N_BX);
154  bxlumierror.resize(sizeof(float) * N_BX);
155  bxlumiquality.resize(sizeof(short) * N_BX);
156  void* bxlumivalueStartAddress = bxlumivalue.startingAddress();
157  void* bxlumierrorStartAddress = bxlumierror.startingAddress();
158  void* bxlumiqualityStartAddress = bxlumiquality.startingAddress();
159  for (unsigned int k = 0; k < N_BX; ++k) {
160  lumivalue[k] = 1.5;
161  lumierror[k] = 0.1;
162  lumiquality[k] = 1;
163  }
164  std::memmove(bxlumivalueStartAddress, lumivalue, sizeof(float) * N_BX);
165  std::memmove(bxlumierrorStartAddress, lumierror, sizeof(float) * N_BX);
166  std::memmove(bxlumiqualityStartAddress, lumiquality, sizeof(short) * N_BX);
167  detailInserter->processNextIteration();
168  }
169  }
170  detailInserter->flush();
171  delete summaryInserter;
172  delete detailInserter;
173  } catch (const coral::Exception& er) {
174  session->transaction().rollback();
175  delete session;
176  delete svc;
177  throw er;
178  }
179  //delete detailInserter;
180  session->transaction().commit();
181  delete session;
182  delete svc;
183  return 0;
184  }
int runnum
const unsigned int N_LUMIALGO
Definition: ConstantDef.h:4
std::string m_dest
Definition: DataPipe.h:29
static const std::string lumisummaryTableName()
Definition: LumiNames.cc:5
const unsigned int N_BX
Definition: ConstantDef.h:5
static const std::string lumidetailTableName()
Definition: LumiNames.cc:7
std::string m_authpath
Definition: DataPipe.h:31

◆ sourceType()

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

Implements lumi::DataPipe.

Definition at line 186 of file LumiDummy2DB.cc.

186 { return "DUMMY"; }