CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Static Public Attributes
lumi::HLTV32DB Class Reference
Inheritance diagram for lumi::HLTV32DB:
lumi::DataPipe

Classes

struct  hltinfo
 

Public Types

typedef std::map< unsigned int, std::string, std::less< unsigned int > > HltPathMap
 
typedef std::vector< std::map< unsigned int, HLTV32DB::hltinfo, std::less< unsigned int > > > HltResult
 

Public Member Functions

const std::string dataType () const override
 
 HLTV32DB (const std::string &dest)
 
unsigned long long retrieveData (unsigned int) override
 
const std::string sourceType () const override
 
void writeHltData (coral::ISessionProxy *lumisession, unsigned int irunnumber, const std::string &source, unsigned int npath, HltResult::iterator hltBeg, HltResult::iterator hltEnd, unsigned int commitintv)
 
unsigned long long writeHltDataToSchema2 (coral::ISessionProxy *lumisession, unsigned int irunnumber, const std::string &source, unsigned int npath, HltResult::iterator hltBeg, HltResult::iterator hltEnd, HltPathMap &hltpathmap, unsigned int commitintv)
 
 ~HLTV32DB () 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 ()
 

Static Public Attributes

static const unsigned int COMMITINTERVAL = 200
 
static const unsigned int COMMITLSINTERVAL = 500
 

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 34 of file HLTV32DB.cc.

Member Typedef Documentation

◆ HltPathMap

typedef std::map<unsigned int, std::string, std::less<unsigned int> > lumi::HLTV32DB::HltPathMap

Definition at line 51 of file HLTV32DB.cc.

◆ HltResult

typedef std::vector<std::map<unsigned int, HLTV32DB::hltinfo, std::less<unsigned int> > > lumi::HLTV32DB::HltResult

Definition at line 52 of file HLTV32DB.cc.

Constructor & Destructor Documentation

◆ HLTV32DB()

lumi::HLTV32DB::HLTV32DB ( const std::string &  dest)
explicit

Definition at line 72 of file HLTV32DB.cc.

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

◆ ~HLTV32DB()

lumi::HLTV32DB::~HLTV32DB ( )
override

Definition at line 550 of file HLTV32DB.cc.

550 {}

Member Function Documentation

◆ dataType()

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

Implements lumi::DataPipe.

Definition at line 548 of file HLTV32DB.cc.

548 { return "HLTV3"; }

◆ retrieveData()

unsigned long long lumi::HLTV32DB::retrieveData ( unsigned int  runnumber)
overridevirtual

retrieve hlt info with 3 queries from runinfo

  1. select prescale_index,lumi_section from cms_gt_mon.lumi_sections where run_number=:runnum; => map{ls:psindex}
  2. select name from cms_hlt.paths where pathid=:pathid

select prescale_index,lumi_section from cms_gt_mon.lumi_sections where run_number=:runnum;






select distinct ( PATHID ) from HLT_SUPERVISOR_TRIGGERPATHS where runnumber=:runnumber;

initialize hltpathmap




select name from cms_hlt.paths where pathid=:pathid



fill up hltpathmap


initialize hltresult

select t.l1pass,t.paccept,t.pathid,m.psvalue from cms_runinfo.hlt_supervisor_triggerpaths t, cms_runinfo.hlt_supervisor_scalar_map_v2 m where m.pathid=t.pathid and m.runnumber=t.runnumber and m.runnumber=:runnum and m.psindex=:0 and t.lsnumber=:ls
for(HltResult::iterator hltIt=hltresult.begin();hltIt!=hltresult.end();++hltIt){ std::map<unsigned int,HLTV32DB::hltinfo>::const_iterator pathIt; std::map<unsigned int,HLTV32DB::hltinfo>::const_iterator pathBeg=hltIt->begin(); std::map<unsigned int,HLTV32DB::hltinfo>::const_iterator pathEnd=hltIt->end(); for(pathIt=pathBeg;pathIt!=pathEnd;++pathIt){ unsigned int cmslsnum = pathIt->second.cmsluminr; std::string pathname = pathIt->second.pathname; unsigned int inputcount = pathIt->second.hltinput; unsigned int acceptcount = pathIt->second.hltaccept; unsigned int prescale = pathIt->second.prescale; std::cout<<"cmslsnum "<<cmslsnum<<" pathname "<<pathname<<" inputcount "<<inputcount<<" acceptcount "<<acceptcount<<" prescale "<<prescale<<std::endl; } }

Implements lumi::DataPipe.

Definition at line 73 of file HLTV32DB.cc.

References HltBtagPostValidation_cff::c, lumi::HLTV32DB::hltinfo::cmsluminr, COMMITINTERVAL, COMMITLSINTERVAL, gather_cfg::cout, Exception, lumi::HLTV32DB::hltinfo::hltaccept, lumi::HLTV32DB::hltinfo::hltinput, mps_fire::i, remoteMonitoring_LASER_era2018_cfg::lsmax, remoteMonitoring_LASER_era2018_cfg::lsmin, lumi::DataPipe::m_authpath, lumi::DataPipe::m_dest, lumi::DataPipe::m_mode, lumi::DataPipe::m_source, BTVHLTOfflineSource_cfi::pathname, lumi::HLTV32DB::hltinfo::pathname, lumi::HLTV32DB::hltinfo::prescale, cond::runnumber, lumi::DBConfig::setAuthentication(), AlCaHLTBitMon_QueryRunRegistry::string, trackerHitRTTI::vector, writeHltData(), and writeHltDataToSchema2().

73  {
74  std::string confdbschema("CMS_HLT");
75  std::string hltschema("CMS_RUNINFO");
76  std::string gtschema("CMS_GT_MON");
77  std::string confdbpathtabname("PATHS");
78  std::string triggerpathtabname("HLT_SUPERVISOR_TRIGGERPATHS");
79  std::string maptabname("HLT_SUPERVISOR_SCALAR_MAP_V2");
80  std::string gttabname("LUMI_SECTIONS");
81  coral::ConnectionService* svc = new coral::ConnectionService;
82  lumi::DBConfig dbconf(*svc);
83  if (!m_authpath.empty()) {
84  dbconf.setAuthentication(m_authpath);
85  }
90  std::string::size_type cutpos = m_source.find(';');
91  std::string dbsource = m_source;
92  std::string csvsource("");
93  if (cutpos != std::string::npos) {
94  dbsource = m_source.substr(0, cutpos);
95  csvsource = m_source.substr(cutpos + 1);
96  }
97  //std::cout<<"dbsource: "<<dbsource<<" , csvsource: "<<csvsource<<std::endl;
98  coral::ISessionProxy* srcsession = svc->connect(dbsource, coral::ReadOnly);
99  coral::ITypeConverter& tpc = srcsession->typeConverter();
100  tpc.setCppTypeForSqlType("unsigned int", "NUMBER(11)");
101  srcsession->transaction().start(true);
102  coral::ISchema& gtSchemaHandle = srcsession->schema(gtschema);
103  coral::ISchema& hltSchemaHandle = srcsession->schema(hltschema);
104  coral::ISchema& confdbSchemaHandle = srcsession->schema(confdbschema);
105  if (!hltSchemaHandle.existsTable(triggerpathtabname) || !hltSchemaHandle.existsTable(maptabname)) {
106  throw lumi::Exception("missing hlt tables", "retrieveData", "HLTV32DB");
107  }
109  //this is trg lumi section number
110  std::vector<std::pair<unsigned int, unsigned int> > psindexmap;
111  coral::AttributeList psindexVariableList;
112  psindexVariableList.extend("runnumber", typeid(unsigned int));
113  psindexVariableList["runnumber"].data<unsigned int>() = runnumber;
114  coral::IQuery* qPsindex = gtSchemaHandle.tableHandle(gttabname).newQuery();
115  coral::AttributeList psindexOutput;
116  psindexOutput.extend("PRESCALE_INDEX", typeid(unsigned int));
117  psindexOutput.extend("LUMI_SECTION", typeid(unsigned int));
118  qPsindex->addToOutputList("PRESCALE_INDEX");
119  qPsindex->addToOutputList("LUMI_SECTION");
120  qPsindex->setCondition("RUN_NUMBER=:runnumber", psindexVariableList);
121  qPsindex->defineOutput(psindexOutput);
122  coral::ICursor& psindexCursor = qPsindex->execute();
123  unsigned int lsmin = 4294967295;
124  unsigned int lsmax = 0;
125  while (psindexCursor.next()) {
126  if (!psindexCursor.currentRow()["PRESCALE_INDEX"].isNull()) {
127  unsigned int psindx = psindexCursor.currentRow()["PRESCALE_INDEX"].data<unsigned int>();
128  unsigned int pslsnum = psindexCursor.currentRow()["LUMI_SECTION"].data<unsigned int>();
129  if (pslsnum > lsmax) {
130  lsmax = pslsnum;
131  }
132  if (pslsnum < lsmin) {
133  lsmin = pslsnum;
134  }
135  psindexmap.push_back(std::make_pair(pslsnum, psindx));
136  }
137  }
138  delete qPsindex;
139  if (psindexmap.empty()) {
140  srcsession->transaction().commit();
141  delete srcsession;
142  throw lumi::Exception("no psindex data found", "retrieveData", "HLTV32DB");
143  }
144 
147  HltPathMap hltpathmap;
148  coral::AttributeList bindVariableList;
149  bindVariableList.extend("runnumber", typeid(unsigned int));
150  bindVariableList["runnumber"].data<unsigned int>() = runnumber;
151  coral::IQuery* q1 = hltSchemaHandle.tableHandle(triggerpathtabname).newQuery();
152  coral::AttributeList hltpathid;
153  hltpathid.extend("hltpathid", typeid(unsigned int));
154  q1->addToOutputList("distinct(PATHID)", "hltpathid");
155  q1->setCondition("RUNNUMBER=:runnumber", bindVariableList);
156  q1->defineOutput(hltpathid);
157  coral::ICursor& c = q1->execute();
158  unsigned int npc = 0;
159  while (c.next()) {
160  npc++;
161  unsigned int hid = c.currentRow()["hltpathid"].data<unsigned int>();
162  hltpathmap.insert(std::make_pair(hid, ""));
163  }
164  delete q1;
167  HltPathMap::iterator mpit;
168  HltPathMap::iterator mpitBeg = hltpathmap.begin();
169  HltPathMap::iterator mpitEnd = hltpathmap.end();
170  for (mpit = mpitBeg; mpit != mpitEnd; ++mpit) { //loop over paths
171  coral::IQuery* mq = confdbSchemaHandle.newQuery();
172  coral::AttributeList mqbindVariableList;
173  mqbindVariableList.extend("pathid", typeid(unsigned int));
174  mqbindVariableList["pathid"].data<unsigned int>() = mpit->first;
175  mq->addToTableList(confdbpathtabname);
176  mq->addToOutputList("NAME", "hltpathname");
177  mq->setCondition("PATHID=:pathid", mqbindVariableList);
178  coral::ICursor& mqcursor = mq->execute();
179  while (mqcursor.next()) {
180  std::string pathname = mqcursor.currentRow()["hltpathname"].data<std::string>();
181  hltpathmap[mpit->first] = pathname;
182  }
183  delete mq;
184  }
185 
187  HltResult hltresult;
188  unsigned int nls = lsmax - lsmin + 1;
189  //std::cout<<"nls "<<nls<<std::endl;
190  hltresult.reserve(nls); //
191  //fix all size
192  for (unsigned int i = lsmin; i <= lsmax; ++i) {
193  if (i == 0)
194  continue; //skip ls=0
195  std::map<unsigned int, HLTV32DB::hltinfo> allpaths;
196  HltPathMap::iterator aIt;
197  HltPathMap::iterator aItBeg = hltpathmap.begin();
198  HltPathMap::iterator aItEnd = hltpathmap.end();
199  for (aIt = aItBeg; aIt != aItEnd; ++aIt) {
200  HLTV32DB::hltinfo ct;
201  ct.cmsluminr = i;
202  ct.pathname = aIt->second;
203  ct.hltinput = 0;
204  ct.hltaccept = 0;
205  ct.prescale = 0;
206  allpaths.insert(std::make_pair(aIt->first, ct));
207  }
208  hltresult.push_back(allpaths);
209  }
210 
211  bool lscountfromzero = false;
212 
214  for (std::vector<std::pair<unsigned int, unsigned int> >::iterator it = psindexmap.begin(); it != psindexmap.end();
215  ++it) {
216  //loop over ls
217  unsigned int lsnum = it->first;
218  unsigned int psindex = it->second;
219  coral::AttributeList hltdataVariableList;
220  hltdataVariableList.extend("runnumber", typeid(unsigned int));
221  hltdataVariableList.extend("lsnum", typeid(unsigned int));
222  hltdataVariableList.extend("psindex", typeid(unsigned int));
223  hltdataVariableList["runnumber"].data<unsigned int>() = runnumber;
224  hltdataVariableList["lsnum"].data<unsigned int>() = lsnum;
225  hltdataVariableList["psindex"].data<unsigned int>() = psindex;
226  coral::IQuery* qHltData = hltSchemaHandle.newQuery();
227  qHltData->addToTableList(triggerpathtabname, "t");
228  qHltData->addToTableList(maptabname, "m");
229  coral::AttributeList hltdataOutput;
230  hltdataOutput.extend("L1PASS", typeid(unsigned int));
231  hltdataOutput.extend("PACCEPT", typeid(unsigned int));
232  hltdataOutput.extend("PATHID", typeid(unsigned int));
233  hltdataOutput.extend("PSVALUE", typeid(unsigned int));
234 
235  qHltData->addToOutputList("t.L1PASS", "l1pass");
236  qHltData->addToOutputList("t.PACCEPT", "paccept");
237  qHltData->addToOutputList("t.PATHID", "pathid");
238  qHltData->addToOutputList("m.PSVALUE", "psvalue");
239  qHltData->setCondition(
240  "m.PATHID=t.PATHID and m.RUNNUMBER=t.RUNNUMBER and m.RUNNUMBER=:runnumber AND m.PSINDEX=:psindex AND "
241  "t.LSNUMBER=:lsnum",
242  hltdataVariableList);
243  qHltData->defineOutput(hltdataOutput);
244  coral::ICursor& hltdataCursor = qHltData->execute();
245  while (hltdataCursor.next()) {
246  const coral::AttributeList& row = hltdataCursor.currentRow();
247  if (lsnum == 0) {
248  lscountfromzero = true;
249  if (lscountfromzero) {
250  std::cout << "hlt ls count from 0 , we skip/dodge/parry it!" << std::endl;
251  }
252  } else {
253  unsigned int pathid = row["PATHID"].data<unsigned int>();
254  std::map<unsigned int, hltinfo>& allpathinfo = hltresult.at(lsnum - 1);
255  hltinfo& pathcontent = allpathinfo[pathid];
256  pathcontent.hltinput = row["L1PASS"].data<unsigned int>();
257  pathcontent.hltaccept = row["PACCEPT"].data<unsigned int>();
258  pathcontent.prescale = row["PSVALUE"].data<unsigned int>();
259  }
260  }
261  delete qHltData;
262  }
263  srcsession->transaction().commit();
264  delete srcsession;
265  //
266  // Write into DB
267  //
268  unsigned int npath = hltpathmap.size();
269  coral::ISessionProxy* destsession = svc->connect(m_dest, coral::Update);
270  coral::ITypeConverter& lumitpc = destsession->typeConverter();
271  lumitpc.setCppTypeForSqlType("unsigned int", "NUMBER(7)");
272  lumitpc.setCppTypeForSqlType("unsigned int", "NUMBER(10)");
273  lumitpc.setCppTypeForSqlType("unsigned long long", "NUMBER(20)");
274 
275  //for(hltIt=hltItBeg;hltIt!=hltItEnd;++hltIt){
276  // std::map<unsigned int,HLTV32DB::hltinfo>::iterator pathIt;
277  // std::map<unsigned int,HLTV32DB::hltinfo>::iterator pathItBeg=hltIt->begin();
278  // std::map<unsigned int,HLTV32DB::hltinfo>::iterator pathItEnd=hltIt->end();
279  // for(pathIt=pathItBeg;pathIt!=pathItEnd;++pathIt){
280  // std::cout<<"cmslsnr "<<pathIt->second.cmsluminr<<" "<<pathIt->second.pathname<<" "<<pathIt->second.hltinput<<" "<<pathIt->second.hltaccept<<" "<<pathIt->second.prescale<<std::endl;
281  // }
282  //}
283  unsigned int totalcmsls = hltresult.size();
284  std::cout << "inserting totalhltls " << totalcmsls << " total path " << npath << std::endl;
285  //HltResult::iterator hltItBeg=hltresult.begin();
286  //HltResult::iterator hltItEnd=hltresult.end();
287  unsigned long long hltdataid = 0;
288  try {
289  if (m_mode == "loadoldschema") {
290  std::cout << "writing hlt data to old hlt table" << std::endl;
291  writeHltData(destsession, runnumber, dbsource, npath, hltresult.begin(), hltresult.end(), COMMITINTERVAL);
292  std::cout << "done" << std::endl;
293  }
294  std::cout << "writing hlt data to new lshlt table" << std::endl;
295  //std::cout<<"npath "<<npath<<std::endl;
310  hltdataid = writeHltDataToSchema2(
311  destsession, runnumber, dbsource, npath, hltresult.begin(), hltresult.end(), hltpathmap, COMMITLSINTERVAL);
312  std::cout << "done" << std::endl;
313  delete destsession;
314  delete svc;
315  } catch (const coral::Exception& er) {
316  std::cout << "database problem " << er.what() << std::endl;
317  destsession->transaction().rollback();
318  delete destsession;
319  delete svc;
320  throw er;
321  }
322  return hltdataid;
323  }
uint16_t size_type
std::string m_dest
Definition: DataPipe.h:29
std::map< unsigned int, std::string, std::less< unsigned int > > HltPathMap
Definition: HLTV32DB.cc:51
void writeHltData(coral::ISessionProxy *lumisession, unsigned int irunnumber, const std::string &source, unsigned int npath, HltResult::iterator hltBeg, HltResult::iterator hltEnd, unsigned int commitintv)
Definition: HLTV32DB.cc:324
static const unsigned int COMMITINTERVAL
Definition: HLTV32DB.cc:36
std::vector< std::map< unsigned int, HLTV32DB::hltinfo, std::less< unsigned int > > > HltResult
Definition: HLTV32DB.cc:52
std::string m_source
Definition: DataPipe.h:30
static const unsigned int COMMITLSINTERVAL
Definition: HLTV32DB.cc:37
std::string m_authpath
Definition: DataPipe.h:31
std::string m_mode
Definition: DataPipe.h:32
unsigned long long writeHltDataToSchema2(coral::ISessionProxy *lumisession, unsigned int irunnumber, const std::string &source, unsigned int npath, HltResult::iterator hltBeg, HltResult::iterator hltEnd, HltPathMap &hltpathmap, unsigned int commitintv)
Definition: HLTV32DB.cc:412

◆ sourceType()

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

Implements lumi::DataPipe.

Definition at line 549 of file HLTV32DB.cc.

549 { return "DB"; }

◆ writeHltData()

void lumi::HLTV32DB::writeHltData ( coral::ISessionProxy *  lumisession,
unsigned int  irunnumber,
const std::string &  source,
unsigned int  npath,
HltResult::iterator  hltBeg,
HltResult::iterator  hltEnd,
unsigned int  commitintv 
)

Definition at line 324 of file HLTV32DB.cc.

References gather_cfg::cout, HLT_2023v12_cff::distance, lumi::idDealer::generateNextIDForTable(), lumi::LumiNames::hltTableName(), mps_fire::i, BTVHLTOfflineSource_cfi::pathname, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by retrieveData().

330  {
331  std::map<unsigned long long, std::vector<unsigned long long> > idallocationtable;
332  unsigned int hltlscount = 0;
333  unsigned int totalcmsls = std::distance(hltItBeg, hltItEnd);
334  std::cout << "\t allocating total ids " << totalcmsls * npath << std::endl;
335  lumisession->transaction().start(false);
336  lumi::idDealer idg(lumisession->nominalSchema());
337  unsigned long long hltID =
338  idg.generateNextIDForTable(LumiNames::hltTableName(), totalcmsls * npath) - totalcmsls * npath;
339  for (HltResult::iterator hltIt = hltItBeg; hltIt != hltItEnd; ++hltIt, ++hltlscount) {
340  std::vector<unsigned long long> pathvec;
341  pathvec.reserve(npath);
342  for (unsigned int i = 0; i < npath; ++i, ++hltID) {
343  pathvec.push_back(hltID);
344  }
345  idallocationtable.insert(std::make_pair(hltlscount, pathvec));
346  }
347  std::cout << "\t all ids allocated" << std::endl;
348 
349  coral::AttributeList hltData;
350  hltData.extend("HLT_ID", typeid(unsigned long long));
351  hltData.extend("RUNNUM", typeid(unsigned int));
352  hltData.extend("CMSLSNUM", typeid(unsigned int));
353  hltData.extend("PATHNAME", typeid(std::string));
354  hltData.extend("INPUTCOUNT", typeid(unsigned int));
355  hltData.extend("ACCEPTCOUNT", typeid(unsigned int));
356  hltData.extend("PRESCALE", typeid(unsigned int));
357 
358  //loop over lumi LS
359  unsigned long long& hlt_id = hltData["HLT_ID"].data<unsigned long long>();
360  unsigned int& hltrunnum = hltData["RUNNUM"].data<unsigned int>();
361  unsigned int& cmslsnum = hltData["CMSLSNUM"].data<unsigned int>();
362  std::string& pathname = hltData["PATHNAME"].data<std::string>();
363  unsigned int& inputcount = hltData["INPUTCOUNT"].data<unsigned int>();
364  unsigned int& acceptcount = hltData["ACCEPTCOUNT"].data<unsigned int>();
365  unsigned int& prescale = hltData["PRESCALE"].data<unsigned int>();
366  hltlscount = 0;
367  coral::IBulkOperation* hltInserter = nullptr;
368  unsigned int comittedls = 0;
369  for (HltResult::iterator hltIt = hltItBeg; hltIt != hltItEnd; ++hltIt, ++hltlscount) {
370  std::map<unsigned int, HLTV32DB::hltinfo>::const_iterator pathIt;
371  std::map<unsigned int, HLTV32DB::hltinfo>::const_iterator pathBeg = hltIt->begin();
372  std::map<unsigned int, HLTV32DB::hltinfo>::const_iterator pathEnd = hltIt->end();
373  if (!lumisession->transaction().isActive()) {
374  lumisession->transaction().start(false);
375  coral::ITable& hlttable = lumisession->nominalSchema().tableHandle(LumiNames::hltTableName());
376  hltInserter = hlttable.dataEditor().bulkInsert(hltData, npath);
377  } else {
378  if (hltIt == hltItBeg) {
379  coral::ITable& hlttable = lumisession->nominalSchema().tableHandle(LumiNames::hltTableName());
380  hltInserter = hlttable.dataEditor().bulkInsert(hltData, npath);
381  }
382  }
383  unsigned int hltpathcount = 0;
384  for (pathIt = pathBeg; pathIt != pathEnd; ++pathIt, ++hltpathcount) {
385  hlt_id = idallocationtable[hltlscount].at(hltpathcount);
386  hltrunnum = irunnumber;
387  cmslsnum = pathIt->second.cmsluminr;
388  pathname = pathIt->second.pathname;
389  inputcount = pathIt->second.hltinput;
390  acceptcount = pathIt->second.hltaccept;
391  prescale = pathIt->second.prescale;
392  hltInserter->processNextIteration();
393  }
394  hltInserter->flush();
395  ++comittedls;
396  if (comittedls == commitintv) {
397  std::cout << "\t committing in LS chunck " << comittedls << std::endl;
398  delete hltInserter;
399  hltInserter = nullptr;
400  lumisession->transaction().commit();
401  comittedls = 0;
402  std::cout << "\t committed " << std::endl;
403  } else if (hltlscount == (totalcmsls - 1)) {
404  std::cout << "\t committing at the end" << std::endl;
405  delete hltInserter;
406  hltInserter = nullptr;
407  lumisession->transaction().commit();
408  std::cout << "\t done" << std::endl;
409  }
410  }
411  }
static const std::string hltTableName()
Definition: LumiNames.cc:14
unsigned long long generateNextIDForTable(const std::string &tableName, unsigned int interval=1)
Definition: idDealer.cc:33

◆ writeHltDataToSchema2()

unsigned long long lumi::HLTV32DB::writeHltDataToSchema2 ( coral::ISessionProxy *  lumisession,
unsigned int  irunnumber,
const std::string &  source,
unsigned int  npath,
HltResult::iterator  hltBeg,
HltResult::iterator  hltEnd,
HltPathMap hltpathmap,
unsigned int  commitintv 
)

Definition at line 412 of file HLTV32DB.cc.

References lumi::RevisionDML::addEntry(), lumi::RevisionDML::addRevision(), lumi::RevisionDML::bookNewEntry(), lumi::RevisionDML::bookNewRevision(), gather_cfg::cout, lumi::RevisionDML::Entry::data_id, HLT_2023v12_cff::distance, lumi::RevisionDML::Entry::entry_id, lumi::RevisionDML::Entry::entry_name, lumi::RevisionDML::getEntryInBranchByName(), lumi::LumiNames::hltdataTableName(), lumi::RevisionDML::insertHltRunData(), lumi::LumiNames::lshltTableName(), lumi::RevisionDML::HltEntry::npath, lumi::RevisionDML::HltEntry::pathnames, hltrates_dqm_sourceclient-live_cfg::prescales, lumi::RevisionDML::Entry::revision_id, lumi::RevisionDML::HltEntry::runnumber, source, lumi::RevisionDML::HltEntry::source, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by retrieveData().

419  {
420  unsigned int totalcmsls = std::distance(hltItBeg, hltItEnd);
421  std::cout << "inserting totalcmsls " << totalcmsls << std::endl;
422  coral::AttributeList lshltData;
423  lshltData.extend("DATA_ID", typeid(unsigned long long));
424  lshltData.extend("RUNNUM", typeid(unsigned int));
425  lshltData.extend("CMSLSNUM", typeid(unsigned int));
426  lshltData.extend("PRESCALEBLOB", typeid(coral::Blob));
427  lshltData.extend("HLTCOUNTBLOB", typeid(coral::Blob));
428  lshltData.extend("HLTACCEPTBLOB", typeid(coral::Blob));
429  unsigned long long& data_id = lshltData["DATA_ID"].data<unsigned long long>();
430  unsigned int& hltrunnum = lshltData["RUNNUM"].data<unsigned int>();
431  unsigned int& cmslsnum = lshltData["CMSLSNUM"].data<unsigned int>();
432  coral::Blob& prescaleblob = lshltData["PRESCALEBLOB"].data<coral::Blob>();
433  coral::Blob& hltcountblob = lshltData["HLTCOUNTBLOB"].data<coral::Blob>();
434  coral::Blob& hltacceptblob = lshltData["HLTACCEPTBLOB"].data<coral::Blob>();
435 
436  unsigned long long branch_id = 3;
437  std::string branch_name("DATA");
438  lumi::RevisionDML revisionDML;
439  lumi::RevisionDML::HltEntry hltrundata;
440  std::stringstream op;
441  op << irunnumber;
442  std::string runnumberStr = op.str();
443  lumisession->transaction().start(false);
444  hltrundata.entry_name = runnumberStr;
445  hltrundata.source = source;
446  hltrundata.runnumber = irunnumber;
447  hltrundata.npath = npath;
448  std::string pathnames;
449  HltPathMap::iterator hltpathmapIt;
450  HltPathMap::iterator hltpathmapItBeg = hltpathmap.begin();
451  HltPathMap::iterator hltpathmapItEnd = hltpathmap.end();
452  for (hltpathmapIt = hltpathmapItBeg; hltpathmapIt != hltpathmapItEnd; ++hltpathmapIt) {
453  if (hltpathmapIt != hltpathmapItBeg) {
454  pathnames += std::string(",");
455  }
456  pathnames += hltpathmapIt->second;
457  }
458  std::cout << "\tpathnames " << pathnames << std::endl;
459  hltrundata.pathnames = pathnames;
460  hltrundata.entry_id = revisionDML.getEntryInBranchByName(
461  lumisession->nominalSchema(), lumi::LumiNames::hltdataTableName(), runnumberStr, branch_name);
462  if (hltrundata.entry_id == 0) {
463  revisionDML.bookNewEntry(lumisession->nominalSchema(), LumiNames::hltdataTableName(), hltrundata);
464  std::cout << "hltrundata revision_id " << hltrundata.revision_id << " entry_id " << hltrundata.entry_id
465  << " data_id " << hltrundata.data_id << std::endl;
466  revisionDML.addEntry(
467  lumisession->nominalSchema(), LumiNames::hltdataTableName(), hltrundata, branch_id, branch_name);
468  } else {
469  revisionDML.bookNewRevision(lumisession->nominalSchema(), LumiNames::hltdataTableName(), hltrundata);
470  std::cout << "hltrundata revision_id " << hltrundata.revision_id << " entry_id " << hltrundata.entry_id
471  << " data_id " << hltrundata.data_id << std::endl;
472  revisionDML.addRevision(
473  lumisession->nominalSchema(), LumiNames::hltdataTableName(), hltrundata, branch_id, branch_name);
474  }
475  std::cout << "inserting hltrundata" << std::endl;
476  revisionDML.insertHltRunData(lumisession->nominalSchema(), hltrundata);
477  std::cout << "inserting lshlt data" << std::endl;
478 
479  unsigned int hltlscount = 0;
480  coral::IBulkOperation* hltInserter = nullptr;
481  unsigned int comittedls = 0;
482  for (HltResult::iterator hltIt = hltItBeg; hltIt != hltItEnd; ++hltIt, ++hltlscount) {
483  unsigned int cmslscount = hltlscount + 1;
484  std::map<unsigned int, HLTV32DB::hltinfo, std::less<unsigned int> >::const_iterator pathIt;
485  std::map<unsigned int, HLTV32DB::hltinfo, std::less<unsigned int> >::const_iterator pathBeg = hltIt->begin();
486  std::map<unsigned int, HLTV32DB::hltinfo, std::less<unsigned int> >::const_iterator pathEnd = hltIt->end();
487  if (!lumisession->transaction().isActive()) {
488  lumisession->transaction().start(false);
489  coral::ITable& hlttable = lumisession->nominalSchema().tableHandle(LumiNames::lshltTableName());
490  hltInserter = hlttable.dataEditor().bulkInsert(lshltData, npath);
491  } else {
492  if (hltIt == hltItBeg) {
493  coral::ITable& hlttable = lumisession->nominalSchema().tableHandle(LumiNames::lshltTableName());
494  hltInserter = hlttable.dataEditor().bulkInsert(lshltData, npath);
495  }
496  }
497  data_id = hltrundata.data_id;
498  hltrunnum = irunnumber;
499  cmslsnum = cmslscount;
500  std::vector<unsigned int> prescales;
501  prescales.reserve(npath);
502  std::vector<unsigned int> hltcounts;
503  hltcounts.reserve(npath);
504  std::vector<unsigned int> hltaccepts;
505  hltaccepts.reserve(npath);
506 
507  for (pathIt = pathBeg; pathIt != pathEnd; ++pathIt) {
508  unsigned int hltcount = pathIt->second.hltinput;
509  //std::cout<<"hltcount "<<hltcount<<std::endl;
510  hltcounts.push_back(hltcount);
511  unsigned int hltaccept = pathIt->second.hltaccept;
512  //std::cout<<"hltaccept "<<hltaccept<<std::endl;
513  hltaccepts.push_back(hltaccept);
514  unsigned int prescale = pathIt->second.prescale;
515  //std::cout<<"prescale "<<prescale<<std::endl;
516  prescales.push_back(prescale);
517  }
518  prescaleblob.resize(sizeof(unsigned int) * npath);
519  void* prescaleblob_StartAddress = prescaleblob.startingAddress();
520  std::memmove(prescaleblob_StartAddress, &prescales[0], sizeof(unsigned int) * npath);
521  hltcountblob.resize(sizeof(unsigned int) * npath);
522  void* hltcountblob_StartAddress = hltcountblob.startingAddress();
523  std::memmove(hltcountblob_StartAddress, &hltcounts[0], sizeof(unsigned int) * npath);
524  hltacceptblob.resize(sizeof(unsigned int) * npath);
525  void* hltacceptblob_StartAddress = hltacceptblob.startingAddress();
526  std::memmove(hltacceptblob_StartAddress, &hltaccepts[0], sizeof(unsigned int) * npath);
527 
528  hltInserter->processNextIteration();
529  hltInserter->flush();
530  ++comittedls;
531  if (comittedls == commitintv) {
532  std::cout << "\t committing in LS chunck " << comittedls << std::endl;
533  delete hltInserter;
534  hltInserter = nullptr;
535  lumisession->transaction().commit();
536  comittedls = 0;
537  std::cout << "\t committed " << std::endl;
538  } else if (hltlscount == (totalcmsls - 1)) {
539  std::cout << "\t committing at the end" << std::endl;
540  delete hltInserter;
541  hltInserter = nullptr;
542  lumisession->transaction().commit();
543  std::cout << "\t done" << std::endl;
544  }
545  }
546  return hltrundata.data_id;
547  }
void addEntry(coral::ISchema &schema, const std::string &datatableName, const Entry &entry, unsigned long long branch_id, const std::string &branchname)
Definition: RevisionDML.cc:60
static const std::string lshltTableName()
Definition: LumiNames.cc:16
static const std::string hltdataTableName()
Definition: LumiNames.cc:15
unsigned long long data_id
Definition: RevisionDML.h:31
unsigned long long getEntryInBranchByName(coral::ISchema &schema, const std::string &datatableName, const std::string &entryname, const std::string &branchname)
Definition: RevisionDML.cc:16
unsigned long long revision_id
Definition: RevisionDML.h:29
unsigned long long entry_id
Definition: RevisionDML.h:30
void bookNewEntry(coral::ISchema &schema, const std::string &datatableName, Entry &entry)
Definition: RevisionDML.cc:44
void insertHltRunData(coral::ISchema &schema, const HltEntry &hltentry)
Definition: RevisionDML.cc:158
void addRevision(coral::ISchema &schema, const std::string &datatableName, const Entry &revision, unsigned long long branch_id, std::string &branchname)
Definition: RevisionDML.cc:97
static std::string const source
Definition: EdmProvDump.cc:49
void bookNewRevision(coral::ISchema &schema, const std::string &datatableName, Entry &revision)
Definition: RevisionDML.cc:53

Member Data Documentation

◆ COMMITINTERVAL

const unsigned int lumi::HLTV32DB::COMMITINTERVAL = 200
static

Definition at line 36 of file HLTV32DB.cc.

Referenced by retrieveData().

◆ COMMITLSINTERVAL

const unsigned int lumi::HLTV32DB::COMMITLSINTERVAL = 500
static

Definition at line 37 of file HLTV32DB.cc.

Referenced by retrieveData().