File indexing completed on 2021-02-14 14:25:20
0001 #ifndef RecoLuminosity_LumiProducer_HLTV32DB_H
0002 #define RecoLuminosity_LumiProducer_HLTV32DB_H
0003 #include "CoralBase/AttributeList.h"
0004 #include "CoralBase/Attribute.h"
0005 #include "CoralBase/AttributeSpecification.h"
0006 #include "CoralBase/Blob.h"
0007 #include "CoralBase/Exception.h"
0008 #include "RelationalAccess/ConnectionService.h"
0009 #include "RelationalAccess/ISessionProxy.h"
0010 #include "RelationalAccess/ITransaction.h"
0011 #include "RelationalAccess/ITypeConverter.h"
0012 #include "RelationalAccess/IQuery.h"
0013 #include "RelationalAccess/ICursor.h"
0014 #include "RelationalAccess/ISchema.h"
0015 #include "RelationalAccess/IView.h"
0016 #include "RelationalAccess/ITable.h"
0017 #include "RelationalAccess/ITableDataEditor.h"
0018 #include "RelationalAccess/IBulkOperation.h"
0019
0020 #include "RecoLuminosity/LumiProducer/interface/DataPipe.h"
0021 #include "RecoLuminosity/LumiProducer/interface/LumiNames.h"
0022 #include "RecoLuminosity/LumiProducer/interface/idDealer.h"
0023 #include "RecoLuminosity/LumiProducer/interface/Exception.h"
0024 #include "RecoLuminosity/LumiProducer/interface/DBConfig.h"
0025 #include "RecoLuminosity/LumiProducer/interface/ConstantDef.h"
0026 #include "RecoLuminosity/LumiProducer/interface/RevisionDML.h"
0027 #include <iostream>
0028 #include <map>
0029 #include <vector>
0030 #include <string>
0031 #include <cstring>
0032 #include "RecoLuminosity/LumiProducer/interface/DataPipe.h"
0033 namespace lumi {
0034 class HLTV32DB : public DataPipe {
0035 public:
0036 const static unsigned int COMMITINTERVAL = 200;
0037 const static unsigned int COMMITLSINTERVAL = 500;
0038
0039 explicit HLTV32DB(const std::string& dest);
0040 unsigned long long retrieveData(unsigned int) override;
0041 const std::string dataType() const override;
0042 const std::string sourceType() const override;
0043 ~HLTV32DB() override;
0044 struct hltinfo {
0045 unsigned int cmsluminr;
0046 std::string pathname;
0047 unsigned int hltinput;
0048 unsigned int hltaccept;
0049 unsigned int prescale;
0050 };
0051 typedef std::map<unsigned int, std::string, std::less<unsigned int> > HltPathMap;
0052 typedef std::vector<std::map<unsigned int, HLTV32DB::hltinfo, std::less<unsigned int> > > HltResult;
0053 void writeHltData(coral::ISessionProxy* lumisession,
0054 unsigned int irunnumber,
0055 const std::string& source,
0056 unsigned int npath,
0057 HltResult::iterator hltBeg,
0058 HltResult::iterator hltEnd,
0059 unsigned int commitintv);
0060 unsigned long long writeHltDataToSchema2(coral::ISessionProxy* lumisession,
0061 unsigned int irunnumber,
0062 const std::string& source,
0063 unsigned int npath,
0064 HltResult::iterator hltBeg,
0065 HltResult::iterator hltEnd,
0066 HltPathMap& hltpathmap,
0067 unsigned int commitintv);
0068 };
0069
0070
0071
0072 HLTV32DB::HLTV32DB(const std::string& dest) : DataPipe(dest) {}
0073 unsigned long long HLTV32DB::retrieveData(unsigned int runnumber) {
0074 std::string confdbschema("CMS_HLT");
0075 std::string hltschema("CMS_RUNINFO");
0076 std::string gtschema("CMS_GT_MON");
0077 std::string confdbpathtabname("PATHS");
0078 std::string triggerpathtabname("HLT_SUPERVISOR_TRIGGERPATHS");
0079 std::string maptabname("HLT_SUPERVISOR_SCALAR_MAP_V2");
0080 std::string gttabname("LUMI_SECTIONS");
0081 coral::ConnectionService* svc = new coral::ConnectionService;
0082 lumi::DBConfig dbconf(*svc);
0083 if (!m_authpath.empty()) {
0084 dbconf.setAuthentication(m_authpath);
0085 }
0086
0087
0088
0089
0090 std::string::size_type cutpos = m_source.find(';');
0091 std::string dbsource = m_source;
0092 std::string csvsource("");
0093 if (cutpos != std::string::npos) {
0094 dbsource = m_source.substr(0, cutpos);
0095 csvsource = m_source.substr(cutpos + 1);
0096 }
0097
0098 coral::ISessionProxy* srcsession = svc->connect(dbsource, coral::ReadOnly);
0099 coral::ITypeConverter& tpc = srcsession->typeConverter();
0100 tpc.setCppTypeForSqlType("unsigned int", "NUMBER(11)");
0101 srcsession->transaction().start(true);
0102 coral::ISchema& gtSchemaHandle = srcsession->schema(gtschema);
0103 coral::ISchema& hltSchemaHandle = srcsession->schema(hltschema);
0104 coral::ISchema& confdbSchemaHandle = srcsession->schema(confdbschema);
0105 if (!hltSchemaHandle.existsTable(triggerpathtabname) || !hltSchemaHandle.existsTable(maptabname)) {
0106 throw lumi::Exception("missing hlt tables", "retrieveData", "HLTV32DB");
0107 }
0108
0109
0110 std::vector<std::pair<unsigned int, unsigned int> > psindexmap;
0111 coral::AttributeList psindexVariableList;
0112 psindexVariableList.extend("runnumber", typeid(unsigned int));
0113 psindexVariableList["runnumber"].data<unsigned int>() = runnumber;
0114 coral::IQuery* qPsindex = gtSchemaHandle.tableHandle(gttabname).newQuery();
0115 coral::AttributeList psindexOutput;
0116 psindexOutput.extend("PRESCALE_INDEX", typeid(unsigned int));
0117 psindexOutput.extend("LUMI_SECTION", typeid(unsigned int));
0118 qPsindex->addToOutputList("PRESCALE_INDEX");
0119 qPsindex->addToOutputList("LUMI_SECTION");
0120 qPsindex->setCondition("RUN_NUMBER=:runnumber", psindexVariableList);
0121 qPsindex->defineOutput(psindexOutput);
0122 coral::ICursor& psindexCursor = qPsindex->execute();
0123 unsigned int lsmin = 4294967295;
0124 unsigned int lsmax = 0;
0125 while (psindexCursor.next()) {
0126 if (!psindexCursor.currentRow()["PRESCALE_INDEX"].isNull()) {
0127 unsigned int psindx = psindexCursor.currentRow()["PRESCALE_INDEX"].data<unsigned int>();
0128 unsigned int pslsnum = psindexCursor.currentRow()["LUMI_SECTION"].data<unsigned int>();
0129 if (pslsnum > lsmax) {
0130 lsmax = pslsnum;
0131 }
0132 if (pslsnum < lsmin) {
0133 lsmin = pslsnum;
0134 }
0135 psindexmap.push_back(std::make_pair(pslsnum, psindx));
0136 }
0137 }
0138 delete qPsindex;
0139 if (psindexmap.empty()) {
0140 srcsession->transaction().commit();
0141 delete srcsession;
0142 throw lumi::Exception("no psindex data found", "retrieveData", "HLTV32DB");
0143 }
0144
0145
0146
0147 HltPathMap hltpathmap;
0148 coral::AttributeList bindVariableList;
0149 bindVariableList.extend("runnumber", typeid(unsigned int));
0150 bindVariableList["runnumber"].data<unsigned int>() = runnumber;
0151 coral::IQuery* q1 = hltSchemaHandle.tableHandle(triggerpathtabname).newQuery();
0152 coral::AttributeList hltpathid;
0153 hltpathid.extend("hltpathid", typeid(unsigned int));
0154 q1->addToOutputList("distinct(PATHID)", "hltpathid");
0155 q1->setCondition("RUNNUMBER=:runnumber", bindVariableList);
0156 q1->defineOutput(hltpathid);
0157 coral::ICursor& c = q1->execute();
0158 unsigned int npc = 0;
0159 while (c.next()) {
0160 npc++;
0161 unsigned int hid = c.currentRow()["hltpathid"].data<unsigned int>();
0162 hltpathmap.insert(std::make_pair(hid, ""));
0163 }
0164 delete q1;
0165
0166
0167 HltPathMap::iterator mpit;
0168 HltPathMap::iterator mpitBeg = hltpathmap.begin();
0169 HltPathMap::iterator mpitEnd = hltpathmap.end();
0170 for (mpit = mpitBeg; mpit != mpitEnd; ++mpit) {
0171 coral::IQuery* mq = confdbSchemaHandle.newQuery();
0172 coral::AttributeList mqbindVariableList;
0173 mqbindVariableList.extend("pathid", typeid(unsigned int));
0174 mqbindVariableList["pathid"].data<unsigned int>() = mpit->first;
0175 mq->addToTableList(confdbpathtabname);
0176 mq->addToOutputList("NAME", "hltpathname");
0177 mq->setCondition("PATHID=:pathid", mqbindVariableList);
0178 coral::ICursor& mqcursor = mq->execute();
0179 while (mqcursor.next()) {
0180 std::string pathname = mqcursor.currentRow()["hltpathname"].data<std::string>();
0181 hltpathmap[mpit->first] = pathname;
0182 }
0183 delete mq;
0184 }
0185
0186
0187 HltResult hltresult;
0188 unsigned int nls = lsmax - lsmin + 1;
0189
0190 hltresult.reserve(nls);
0191
0192 for (unsigned int i = lsmin; i <= lsmax; ++i) {
0193 if (i == 0)
0194 continue;
0195 std::map<unsigned int, HLTV32DB::hltinfo> allpaths;
0196 HltPathMap::iterator aIt;
0197 HltPathMap::iterator aItBeg = hltpathmap.begin();
0198 HltPathMap::iterator aItEnd = hltpathmap.end();
0199 for (aIt = aItBeg; aIt != aItEnd; ++aIt) {
0200 HLTV32DB::hltinfo ct;
0201 ct.cmsluminr = i;
0202 ct.pathname = aIt->second;
0203 ct.hltinput = 0;
0204 ct.hltaccept = 0;
0205 ct.prescale = 0;
0206 allpaths.insert(std::make_pair(aIt->first, ct));
0207 }
0208 hltresult.push_back(allpaths);
0209 }
0210
0211 bool lscountfromzero = false;
0212
0213
0214 for (std::vector<std::pair<unsigned int, unsigned int> >::iterator it = psindexmap.begin(); it != psindexmap.end();
0215 ++it) {
0216
0217 unsigned int lsnum = it->first;
0218 unsigned int psindex = it->second;
0219 coral::AttributeList hltdataVariableList;
0220 hltdataVariableList.extend("runnumber", typeid(unsigned int));
0221 hltdataVariableList.extend("lsnum", typeid(unsigned int));
0222 hltdataVariableList.extend("psindex", typeid(unsigned int));
0223 hltdataVariableList["runnumber"].data<unsigned int>() = runnumber;
0224 hltdataVariableList["lsnum"].data<unsigned int>() = lsnum;
0225 hltdataVariableList["psindex"].data<unsigned int>() = psindex;
0226 coral::IQuery* qHltData = hltSchemaHandle.newQuery();
0227 qHltData->addToTableList(triggerpathtabname, "t");
0228 qHltData->addToTableList(maptabname, "m");
0229 coral::AttributeList hltdataOutput;
0230 hltdataOutput.extend("L1PASS", typeid(unsigned int));
0231 hltdataOutput.extend("PACCEPT", typeid(unsigned int));
0232 hltdataOutput.extend("PATHID", typeid(unsigned int));
0233 hltdataOutput.extend("PSVALUE", typeid(unsigned int));
0234
0235 qHltData->addToOutputList("t.L1PASS", "l1pass");
0236 qHltData->addToOutputList("t.PACCEPT", "paccept");
0237 qHltData->addToOutputList("t.PATHID", "pathid");
0238 qHltData->addToOutputList("m.PSVALUE", "psvalue");
0239 qHltData->setCondition(
0240 "m.PATHID=t.PATHID and m.RUNNUMBER=t.RUNNUMBER and m.RUNNUMBER=:runnumber AND m.PSINDEX=:psindex AND "
0241 "t.LSNUMBER=:lsnum",
0242 hltdataVariableList);
0243 qHltData->defineOutput(hltdataOutput);
0244 coral::ICursor& hltdataCursor = qHltData->execute();
0245 while (hltdataCursor.next()) {
0246 const coral::AttributeList& row = hltdataCursor.currentRow();
0247 if (lsnum == 0) {
0248 lscountfromzero = true;
0249 if (lscountfromzero) {
0250 std::cout << "hlt ls count from 0 , we skip/dodge/parry it!" << std::endl;
0251 }
0252 } else {
0253 unsigned int pathid = row["PATHID"].data<unsigned int>();
0254 std::map<unsigned int, hltinfo>& allpathinfo = hltresult.at(lsnum - 1);
0255 hltinfo& pathcontent = allpathinfo[pathid];
0256 pathcontent.hltinput = row["L1PASS"].data<unsigned int>();
0257 pathcontent.hltaccept = row["PACCEPT"].data<unsigned int>();
0258 pathcontent.prescale = row["PSVALUE"].data<unsigned int>();
0259 }
0260 }
0261 delete qHltData;
0262 }
0263 srcsession->transaction().commit();
0264 delete srcsession;
0265
0266
0267
0268 unsigned int npath = hltpathmap.size();
0269 coral::ISessionProxy* destsession = svc->connect(m_dest, coral::Update);
0270 coral::ITypeConverter& lumitpc = destsession->typeConverter();
0271 lumitpc.setCppTypeForSqlType("unsigned int", "NUMBER(7)");
0272 lumitpc.setCppTypeForSqlType("unsigned int", "NUMBER(10)");
0273 lumitpc.setCppTypeForSqlType("unsigned long long", "NUMBER(20)");
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283 unsigned int totalcmsls = hltresult.size();
0284 std::cout << "inserting totalhltls " << totalcmsls << " total path " << npath << std::endl;
0285
0286
0287 unsigned long long hltdataid = 0;
0288 try {
0289 if (m_mode == "loadoldschema") {
0290 std::cout << "writing hlt data to old hlt table" << std::endl;
0291 writeHltData(destsession, runnumber, dbsource, npath, hltresult.begin(), hltresult.end(), COMMITINTERVAL);
0292 std::cout << "done" << std::endl;
0293 }
0294 std::cout << "writing hlt data to new lshlt table" << std::endl;
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310 hltdataid = writeHltDataToSchema2(
0311 destsession, runnumber, dbsource, npath, hltresult.begin(), hltresult.end(), hltpathmap, COMMITLSINTERVAL);
0312 std::cout << "done" << std::endl;
0313 delete destsession;
0314 delete svc;
0315 } catch (const coral::Exception& er) {
0316 std::cout << "database problem " << er.what() << std::endl;
0317 destsession->transaction().rollback();
0318 delete destsession;
0319 delete svc;
0320 throw er;
0321 }
0322 return hltdataid;
0323 }
0324 void HLTV32DB::writeHltData(coral::ISessionProxy* lumisession,
0325 unsigned int irunnumber,
0326 const std::string& source,
0327 unsigned int npath,
0328 HltResult::iterator hltItBeg,
0329 HltResult::iterator hltItEnd,
0330 unsigned int commitintv) {
0331 std::map<unsigned long long, std::vector<unsigned long long> > idallocationtable;
0332 unsigned int hltlscount = 0;
0333 unsigned int totalcmsls = std::distance(hltItBeg, hltItEnd);
0334 std::cout << "\t allocating total ids " << totalcmsls * npath << std::endl;
0335 lumisession->transaction().start(false);
0336 lumi::idDealer idg(lumisession->nominalSchema());
0337 unsigned long long hltID =
0338 idg.generateNextIDForTable(LumiNames::hltTableName(), totalcmsls * npath) - totalcmsls * npath;
0339 for (HltResult::iterator hltIt = hltItBeg; hltIt != hltItEnd; ++hltIt, ++hltlscount) {
0340 std::vector<unsigned long long> pathvec;
0341 pathvec.reserve(npath);
0342 for (unsigned int i = 0; i < npath; ++i, ++hltID) {
0343 pathvec.push_back(hltID);
0344 }
0345 idallocationtable.insert(std::make_pair(hltlscount, pathvec));
0346 }
0347 std::cout << "\t all ids allocated" << std::endl;
0348
0349 coral::AttributeList hltData;
0350 hltData.extend("HLT_ID", typeid(unsigned long long));
0351 hltData.extend("RUNNUM", typeid(unsigned int));
0352 hltData.extend("CMSLSNUM", typeid(unsigned int));
0353 hltData.extend("PATHNAME", typeid(std::string));
0354 hltData.extend("INPUTCOUNT", typeid(unsigned int));
0355 hltData.extend("ACCEPTCOUNT", typeid(unsigned int));
0356 hltData.extend("PRESCALE", typeid(unsigned int));
0357
0358
0359 unsigned long long& hlt_id = hltData["HLT_ID"].data<unsigned long long>();
0360 unsigned int& hltrunnum = hltData["RUNNUM"].data<unsigned int>();
0361 unsigned int& cmslsnum = hltData["CMSLSNUM"].data<unsigned int>();
0362 std::string& pathname = hltData["PATHNAME"].data<std::string>();
0363 unsigned int& inputcount = hltData["INPUTCOUNT"].data<unsigned int>();
0364 unsigned int& acceptcount = hltData["ACCEPTCOUNT"].data<unsigned int>();
0365 unsigned int& prescale = hltData["PRESCALE"].data<unsigned int>();
0366 hltlscount = 0;
0367 coral::IBulkOperation* hltInserter = nullptr;
0368 unsigned int comittedls = 0;
0369 for (HltResult::iterator hltIt = hltItBeg; hltIt != hltItEnd; ++hltIt, ++hltlscount) {
0370 std::map<unsigned int, HLTV32DB::hltinfo>::const_iterator pathIt;
0371 std::map<unsigned int, HLTV32DB::hltinfo>::const_iterator pathBeg = hltIt->begin();
0372 std::map<unsigned int, HLTV32DB::hltinfo>::const_iterator pathEnd = hltIt->end();
0373 if (!lumisession->transaction().isActive()) {
0374 lumisession->transaction().start(false);
0375 coral::ITable& hlttable = lumisession->nominalSchema().tableHandle(LumiNames::hltTableName());
0376 hltInserter = hlttable.dataEditor().bulkInsert(hltData, npath);
0377 } else {
0378 if (hltIt == hltItBeg) {
0379 coral::ITable& hlttable = lumisession->nominalSchema().tableHandle(LumiNames::hltTableName());
0380 hltInserter = hlttable.dataEditor().bulkInsert(hltData, npath);
0381 }
0382 }
0383 unsigned int hltpathcount = 0;
0384 for (pathIt = pathBeg; pathIt != pathEnd; ++pathIt, ++hltpathcount) {
0385 hlt_id = idallocationtable[hltlscount].at(hltpathcount);
0386 hltrunnum = irunnumber;
0387 cmslsnum = pathIt->second.cmsluminr;
0388 pathname = pathIt->second.pathname;
0389 inputcount = pathIt->second.hltinput;
0390 acceptcount = pathIt->second.hltaccept;
0391 prescale = pathIt->second.prescale;
0392 hltInserter->processNextIteration();
0393 }
0394 hltInserter->flush();
0395 ++comittedls;
0396 if (comittedls == commitintv) {
0397 std::cout << "\t committing in LS chunck " << comittedls << std::endl;
0398 delete hltInserter;
0399 hltInserter = nullptr;
0400 lumisession->transaction().commit();
0401 comittedls = 0;
0402 std::cout << "\t committed " << std::endl;
0403 } else if (hltlscount == (totalcmsls - 1)) {
0404 std::cout << "\t committing at the end" << std::endl;
0405 delete hltInserter;
0406 hltInserter = nullptr;
0407 lumisession->transaction().commit();
0408 std::cout << "\t done" << std::endl;
0409 }
0410 }
0411 }
0412 unsigned long long HLTV32DB::writeHltDataToSchema2(coral::ISessionProxy* lumisession,
0413 unsigned int irunnumber,
0414 const std::string& source,
0415 unsigned int npath,
0416 HltResult::iterator hltItBeg,
0417 HltResult::iterator hltItEnd,
0418 HltPathMap& hltpathmap,
0419 unsigned int commitintv) {
0420 unsigned int totalcmsls = std::distance(hltItBeg, hltItEnd);
0421 std::cout << "inserting totalcmsls " << totalcmsls << std::endl;
0422 coral::AttributeList lshltData;
0423 lshltData.extend("DATA_ID", typeid(unsigned long long));
0424 lshltData.extend("RUNNUM", typeid(unsigned int));
0425 lshltData.extend("CMSLSNUM", typeid(unsigned int));
0426 lshltData.extend("PRESCALEBLOB", typeid(coral::Blob));
0427 lshltData.extend("HLTCOUNTBLOB", typeid(coral::Blob));
0428 lshltData.extend("HLTACCEPTBLOB", typeid(coral::Blob));
0429 unsigned long long& data_id = lshltData["DATA_ID"].data<unsigned long long>();
0430 unsigned int& hltrunnum = lshltData["RUNNUM"].data<unsigned int>();
0431 unsigned int& cmslsnum = lshltData["CMSLSNUM"].data<unsigned int>();
0432 coral::Blob& prescaleblob = lshltData["PRESCALEBLOB"].data<coral::Blob>();
0433 coral::Blob& hltcountblob = lshltData["HLTCOUNTBLOB"].data<coral::Blob>();
0434 coral::Blob& hltacceptblob = lshltData["HLTACCEPTBLOB"].data<coral::Blob>();
0435
0436 unsigned long long branch_id = 3;
0437 std::string branch_name("DATA");
0438 lumi::RevisionDML revisionDML;
0439 lumi::RevisionDML::HltEntry hltrundata;
0440 std::stringstream op;
0441 op << irunnumber;
0442 std::string runnumberStr = op.str();
0443 lumisession->transaction().start(false);
0444 hltrundata.entry_name = runnumberStr;
0445 hltrundata.source = source;
0446 hltrundata.runnumber = irunnumber;
0447 hltrundata.npath = npath;
0448 std::string pathnames;
0449 HltPathMap::iterator hltpathmapIt;
0450 HltPathMap::iterator hltpathmapItBeg = hltpathmap.begin();
0451 HltPathMap::iterator hltpathmapItEnd = hltpathmap.end();
0452 for (hltpathmapIt = hltpathmapItBeg; hltpathmapIt != hltpathmapItEnd; ++hltpathmapIt) {
0453 if (hltpathmapIt != hltpathmapItBeg) {
0454 pathnames += std::string(",");
0455 }
0456 pathnames += hltpathmapIt->second;
0457 }
0458 std::cout << "\tpathnames " << pathnames << std::endl;
0459 hltrundata.pathnames = pathnames;
0460 hltrundata.entry_id = revisionDML.getEntryInBranchByName(
0461 lumisession->nominalSchema(), lumi::LumiNames::hltdataTableName(), runnumberStr, branch_name);
0462 if (hltrundata.entry_id == 0) {
0463 revisionDML.bookNewEntry(lumisession->nominalSchema(), LumiNames::hltdataTableName(), hltrundata);
0464 std::cout << "hltrundata revision_id " << hltrundata.revision_id << " entry_id " << hltrundata.entry_id
0465 << " data_id " << hltrundata.data_id << std::endl;
0466 revisionDML.addEntry(
0467 lumisession->nominalSchema(), LumiNames::hltdataTableName(), hltrundata, branch_id, branch_name);
0468 } else {
0469 revisionDML.bookNewRevision(lumisession->nominalSchema(), LumiNames::hltdataTableName(), hltrundata);
0470 std::cout << "hltrundata revision_id " << hltrundata.revision_id << " entry_id " << hltrundata.entry_id
0471 << " data_id " << hltrundata.data_id << std::endl;
0472 revisionDML.addRevision(
0473 lumisession->nominalSchema(), LumiNames::hltdataTableName(), hltrundata, branch_id, branch_name);
0474 }
0475 std::cout << "inserting hltrundata" << std::endl;
0476 revisionDML.insertHltRunData(lumisession->nominalSchema(), hltrundata);
0477 std::cout << "inserting lshlt data" << std::endl;
0478
0479 unsigned int hltlscount = 0;
0480 coral::IBulkOperation* hltInserter = nullptr;
0481 unsigned int comittedls = 0;
0482 for (HltResult::iterator hltIt = hltItBeg; hltIt != hltItEnd; ++hltIt, ++hltlscount) {
0483 unsigned int cmslscount = hltlscount + 1;
0484 std::map<unsigned int, HLTV32DB::hltinfo, std::less<unsigned int> >::const_iterator pathIt;
0485 std::map<unsigned int, HLTV32DB::hltinfo, std::less<unsigned int> >::const_iterator pathBeg = hltIt->begin();
0486 std::map<unsigned int, HLTV32DB::hltinfo, std::less<unsigned int> >::const_iterator pathEnd = hltIt->end();
0487 if (!lumisession->transaction().isActive()) {
0488 lumisession->transaction().start(false);
0489 coral::ITable& hlttable = lumisession->nominalSchema().tableHandle(LumiNames::lshltTableName());
0490 hltInserter = hlttable.dataEditor().bulkInsert(lshltData, npath);
0491 } else {
0492 if (hltIt == hltItBeg) {
0493 coral::ITable& hlttable = lumisession->nominalSchema().tableHandle(LumiNames::lshltTableName());
0494 hltInserter = hlttable.dataEditor().bulkInsert(lshltData, npath);
0495 }
0496 }
0497 data_id = hltrundata.data_id;
0498 hltrunnum = irunnumber;
0499 cmslsnum = cmslscount;
0500 std::vector<unsigned int> prescales;
0501 prescales.reserve(npath);
0502 std::vector<unsigned int> hltcounts;
0503 hltcounts.reserve(npath);
0504 std::vector<unsigned int> hltaccepts;
0505 hltaccepts.reserve(npath);
0506
0507 for (pathIt = pathBeg; pathIt != pathEnd; ++pathIt) {
0508 unsigned int hltcount = pathIt->second.hltinput;
0509
0510 hltcounts.push_back(hltcount);
0511 unsigned int hltaccept = pathIt->second.hltaccept;
0512
0513 hltaccepts.push_back(hltaccept);
0514 unsigned int prescale = pathIt->second.prescale;
0515
0516 prescales.push_back(prescale);
0517 }
0518 prescaleblob.resize(sizeof(unsigned int) * npath);
0519 void* prescaleblob_StartAddress = prescaleblob.startingAddress();
0520 std::memmove(prescaleblob_StartAddress, &prescales[0], sizeof(unsigned int) * npath);
0521 hltcountblob.resize(sizeof(unsigned int) * npath);
0522 void* hltcountblob_StartAddress = hltcountblob.startingAddress();
0523 std::memmove(hltcountblob_StartAddress, &hltcounts[0], sizeof(unsigned int) * npath);
0524 hltacceptblob.resize(sizeof(unsigned int) * npath);
0525 void* hltacceptblob_StartAddress = hltacceptblob.startingAddress();
0526 std::memmove(hltacceptblob_StartAddress, &hltaccepts[0], sizeof(unsigned int) * npath);
0527
0528 hltInserter->processNextIteration();
0529 hltInserter->flush();
0530 ++comittedls;
0531 if (comittedls == commitintv) {
0532 std::cout << "\t committing in LS chunck " << comittedls << std::endl;
0533 delete hltInserter;
0534 hltInserter = nullptr;
0535 lumisession->transaction().commit();
0536 comittedls = 0;
0537 std::cout << "\t committed " << std::endl;
0538 } else if (hltlscount == (totalcmsls - 1)) {
0539 std::cout << "\t committing at the end" << std::endl;
0540 delete hltInserter;
0541 hltInserter = nullptr;
0542 lumisession->transaction().commit();
0543 std::cout << "\t done" << std::endl;
0544 }
0545 }
0546 return hltrundata.data_id;
0547 }
0548 const std::string HLTV32DB::dataType() const { return "HLTV3"; }
0549 const std::string HLTV32DB::sourceType() const { return "DB"; }
0550 HLTV32DB::~HLTV32DB() {}
0551 }
0552 #include "RecoLuminosity/LumiProducer/interface/DataPipeFactory.h"
0553 DEFINE_EDM_PLUGIN(lumi::DataPipeFactory, lumi::HLTV32DB, "HLTV32DB");
0554 #endif