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;
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; } }
78 std::string triggerpathtabname(
"HLT_SUPERVISOR_TRIGGERPATHS");
79 std::string maptabname(
"HLT_SUPERVISOR_SCALAR_MAP_V2");
81 coral::ConnectionService* svc =
new coral::ConnectionService;
93 if (cutpos != std::string::npos) {
94 dbsource =
m_source.substr(0, cutpos);
95 csvsource =
m_source.substr(cutpos + 1);
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");
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) {
132 if (pslsnum <
lsmin) {
135 psindexmap.push_back(std::make_pair(pslsnum, psindx));
139 if (psindexmap.empty()) {
140 srcsession->transaction().commit();
142 throw lumi::Exception(
"no psindex data found",
"retrieveData",
"HLTV32DB");
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();
159 unsigned int hid =
c.currentRow()[
"hltpathid"].data<
unsigned int>();
160 hltpathmap.insert(std::make_pair(hid,
""));
165 HltPathMap::iterator mpit;
166 HltPathMap::iterator mpitBeg = hltpathmap.begin();
167 HltPathMap::iterator mpitEnd = hltpathmap.end();
168 for (mpit = mpitBeg; mpit != mpitEnd; ++mpit) {
169 coral::IQuery* mq = confdbSchemaHandle.newQuery();
170 coral::AttributeList mqbindVariableList;
171 mqbindVariableList.extend(
"pathid",
typeid(
unsigned int));
172 mqbindVariableList[
"pathid"].data<
unsigned int>() = mpit->first;
173 mq->addToTableList(confdbpathtabname);
174 mq->addToOutputList(
"NAME",
"hltpathname");
175 mq->setCondition(
"PATHID=:pathid", mqbindVariableList);
176 coral::ICursor& mqcursor = mq->execute();
177 while (mqcursor.next()) {
188 hltresult.reserve(nls);
193 std::map<unsigned int, HLTV32DB::hltinfo> allpaths;
194 HltPathMap::iterator aIt;
195 HltPathMap::iterator aItBeg = hltpathmap.begin();
196 HltPathMap::iterator aItEnd = hltpathmap.end();
197 for (aIt = aItBeg; aIt != aItEnd; ++aIt) {
198 HLTV32DB::hltinfo ct;
200 ct.pathname = aIt->second;
204 allpaths.insert(std::make_pair(aIt->first, ct));
206 hltresult.push_back(allpaths);
209 bool lscountfromzero =
false;
212 for (
std::vector<std::pair<unsigned int, unsigned int> >::iterator it = psindexmap.begin(); it != psindexmap.end();
215 unsigned int lsnum = it->first;
216 unsigned int psindex = it->second;
217 coral::AttributeList hltdataVariableList;
218 hltdataVariableList.extend(
"runnumber",
typeid(
unsigned int));
219 hltdataVariableList.extend(
"lsnum",
typeid(
unsigned int));
220 hltdataVariableList.extend(
"psindex",
typeid(
unsigned int));
221 hltdataVariableList[
"runnumber"].data<
unsigned int>() =
runnumber;
222 hltdataVariableList[
"lsnum"].data<
unsigned int>() = lsnum;
223 hltdataVariableList[
"psindex"].data<
unsigned int>() = psindex;
224 coral::IQuery* qHltData = hltSchemaHandle.newQuery();
225 qHltData->addToTableList(triggerpathtabname,
"t");
226 qHltData->addToTableList(maptabname,
"m");
227 coral::AttributeList hltdataOutput;
228 hltdataOutput.extend(
"L1PASS",
typeid(
unsigned int));
229 hltdataOutput.extend(
"PACCEPT",
typeid(
unsigned int));
230 hltdataOutput.extend(
"PATHID",
typeid(
unsigned int));
231 hltdataOutput.extend(
"PSVALUE",
typeid(
unsigned int));
233 qHltData->addToOutputList(
"t.L1PASS",
"l1pass");
234 qHltData->addToOutputList(
"t.PACCEPT",
"paccept");
235 qHltData->addToOutputList(
"t.PATHID",
"pathid");
236 qHltData->addToOutputList(
"m.PSVALUE",
"psvalue");
237 qHltData->setCondition(
238 "m.PATHID=t.PATHID and m.RUNNUMBER=t.RUNNUMBER and m.RUNNUMBER=:runnumber AND m.PSINDEX=:psindex AND " 240 hltdataVariableList);
241 qHltData->defineOutput(hltdataOutput);
242 coral::ICursor& hltdataCursor = qHltData->execute();
243 while (hltdataCursor.next()) {
244 const coral::AttributeList& row = hltdataCursor.currentRow();
246 lscountfromzero =
true;
247 if (lscountfromzero) {
248 std::cout <<
"hlt ls count from 0 , we skip/dodge/parry it!" << std::endl;
251 unsigned int pathid = row[
"PATHID"].data<
unsigned int>();
252 std::map<unsigned int, hltinfo>& allpathinfo = hltresult.at(lsnum - 1);
253 hltinfo& pathcontent = allpathinfo[pathid];
254 pathcontent.hltinput = row[
"L1PASS"].data<
unsigned int>();
255 pathcontent.hltaccept = row[
"PACCEPT"].data<
unsigned int>();
256 pathcontent.prescale = row[
"PSVALUE"].data<
unsigned int>();
261 srcsession->transaction().commit();
266 unsigned int npath = hltpathmap.size();
267 coral::ISessionProxy* destsession = svc->connect(
m_dest, coral::Update);
268 coral::ITypeConverter& lumitpc = destsession->typeConverter();
269 lumitpc.setCppTypeForSqlType(
"unsigned int",
"NUMBER(7)");
270 lumitpc.setCppTypeForSqlType(
"unsigned int",
"NUMBER(10)");
271 lumitpc.setCppTypeForSqlType(
"unsigned long long",
"NUMBER(20)");
281 unsigned int totalcmsls = hltresult.size();
282 std::cout <<
"inserting totalhltls " << totalcmsls <<
" total path " << npath << std::endl;
285 unsigned long long hltdataid = 0;
287 if (
m_mode ==
"loadoldschema") {
288 std::cout <<
"writing hlt data to old hlt table" << std::endl;
292 std::cout <<
"writing hlt data to new lshlt table" << std::endl;
314 std::cout <<
"database problem " << er.what() << std::endl;
315 destsession->transaction().rollback();
std::map< unsigned int, std::string, std::less< unsigned int > > HltPathMap
void writeHltData(coral::ISessionProxy *lumisession, unsigned int irunnumber, const std::string &source, unsigned int npath, HltResult::iterator hltBeg, HltResult::iterator hltEnd, unsigned int commitintv)
static const unsigned int COMMITINTERVAL
std::vector< std::map< unsigned int, HLTV32DB::hltinfo, std::less< unsigned int > > > HltResult
static const unsigned int COMMITLSINTERVAL
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)