retrieve hlt info with 2 queries select count(distinct PATHNAME ) as npath from HLT_SUPERVISOR_LUMISECTIONS_V2 where runnr=110823 and lsnumber=1; select l.PATHNAME,l.LSNUMBER,l.L1PASS,l.PACCEPT,m.PSVALUE from hlt_supervisor_lumisections_v2 l, hlt_supervisor_scalar_map m where l.RUNNR=m.RUNNR and l.PSINDEX=m.PSINDEX and l.PATHNAME=m.PATHNAME and l.RUNNR=83037 order by l.LSNUMBER;
57 std::string hltschema(
"CMS_RUNINFO");
58 std::string tabname(
"HLT_SUPERVISOR_LUMISECTIONS_V2");
59 std::string maptabname(
"HLT_SUPERVISOR_SCALAR_MAP");
61 coral::ConnectionService*
svc=
new coral::ConnectionService;
72 coral::ISessionProxy* srcsession=svc->connect(
m_source, coral::ReadOnly);
73 coral::ITypeConverter& tpc=srcsession->typeConverter();
74 tpc.setCppTypeForSqlType(
"unsigned int",
"NUMBER(11)");
75 srcsession->transaction().start(
true);
76 coral::ISchema& hltSchemaHandle=srcsession->schema(hltschema);
77 if( !hltSchemaHandle.existsTable(tabname) || !hltSchemaHandle.existsTable(maptabname) ){
80 std::vector< std::vector<HLT2DB::hltinfo> > hltresult;
81 coral::AttributeList bindVariableList;
82 bindVariableList.extend(
"runnumber",
typeid(
unsigned int));
83 bindVariableList.extend(
"lsnumber",
typeid(
unsigned int));
84 bindVariableList[
"runnumber"].data<
unsigned int>()=
runnumber;
85 bindVariableList[
"lsnumber"].data<
unsigned int>()=1;
107 unsigned int npath=0;
108 coral::IQuery*
q2=srcsession->nominalSchema().newQuery();
109 coral::AttributeList q2bindVariableList;
110 q2bindVariableList.extend(
"runnumber",
typeid(
unsigned int));
111 q2bindVariableList[
"runnumber"].data<
unsigned int>()=
runnumber;
112 q2->addToTableList(tabname,
"l");
113 q2->addToTableList(maptabname,
"m");
114 q2->addToOutputList(
"l.LSNUMBER",
"lsnumber");
115 q2->addToOutputList(
"l.PATHNAME",
"pathname");
116 q2->addToOutputList(
"l.L1PASS",
"hltinput");
117 q2->addToOutputList(
"l.PACCEPT",
"hltratecounter");
118 q2->addToOutputList(
"m.PSVALUE",
"prescale");
119 q2->addToOutputList(
"m.HLTKEY",
"hltconfigid");
120 q2->setCondition(
"l.RUNNR=m.RUNNR and l.PSINDEX=m.PSINDEX and l.PATHNAME=m.PATHNAME and l.RUNNR =:runnumber",q2bindVariableList);
121 q2->addToOrderList(
"lsnumber");
122 q2->setRowCacheSize(10692);
123 coral::ICursor& cursor2=q2->execute();
125 unsigned int lastLumiSection=1;
126 unsigned int currentLumiSection=0;
128 std::vector<hltinfo> allpaths;
129 allpaths.reserve(200);
130 while( cursor2.next() ){
132 const coral::AttributeList& row=cursor2.currentRow();
133 currentLumiSection=row[
"lsnumber"].data<
unsigned int>();
134 pathcontent.cmsluminr=currentLumiSection;
135 pathcontent.hltinput=row[
"hltinput"].data<
unsigned int>();
136 pathcontent.hltaccept=row[
"hltratecounter"].data<
unsigned int>();
137 pathcontent.pathname=row[
"pathname"].data<std::string>();
138 pathcontent.prescale=row[
"prescale"].data<
unsigned int>();
139 pathcontent.hltconfigid=row[
"hltconfigid"].data<
unsigned int>();
140 if(currentLumiSection != lastLumiSection){
141 hltresult.push_back(allpaths);
145 lastLumiSection=currentLumiSection;
146 allpaths.push_back(pathcontent);
147 npath=allpaths.size();
149 hltresult.push_back(allpaths);
152 srcsession->transaction().commit();
158 unsigned int totalcmsls=hltresult.size();
159 std::cout<<
"inserting totalhltls "<<totalcmsls<<std::endl;
160 std::map< unsigned long long, std::vector<unsigned long long> > idallocationtable;
162 coral::ITypeConverter& lumitpc=destsession->typeConverter();
163 lumitpc.setCppTypeForSqlType(
"unsigned int",
"NUMBER(7)");
164 lumitpc.setCppTypeForSqlType(
"unsigned int",
"NUMBER(10)");
165 lumitpc.setCppTypeForSqlType(
"unsigned long long",
"NUMBER(20)");
167 std::vector< std::vector<HLT2DB::hltinfo> >::const_iterator hltIt;
168 std::vector< std::vector<HLT2DB::hltinfo> >::const_iterator hltBeg=hltresult.begin();
169 std::vector< std::vector<HLT2DB::hltinfo> >::const_iterator hltEnd=hltresult.end();
172 std::cout<<
"\t allocating total ids "<<totalcmsls*npath<<std::endl;
173 destsession->transaction().start(
false);
176 destsession->transaction().commit();
177 unsigned int hltlscount=0;
178 for(hltIt=hltBeg;hltIt!=hltEnd;++hltIt,++hltlscount){
179 std::vector<unsigned long long> pathvec;
180 pathvec.reserve(200);
181 std::vector<HLT2DB::hltinfo>::const_iterator pathIt;
182 std::vector<HLT2DB::hltinfo>::const_iterator pathBeg=hltIt->begin();
183 std::vector<HLT2DB::hltinfo>::const_iterator pathEnd=hltIt->end();
184 for(pathIt=pathBeg;pathIt!=pathEnd;++pathIt,++hltID){
185 pathvec.push_back(hltID);
187 idallocationtable.insert(std::make_pair(hltlscount,pathvec));
189 std::cout<<
"\t all ids allocated"<<std::endl;
191 coral::AttributeList hltData;
192 hltData.extend(
"HLT_ID",
typeid(
unsigned long long));
193 hltData.extend(
"RUNNUM",
typeid(
unsigned int));
194 hltData.extend(
"CMSLSNUM",
typeid(
unsigned int));
195 hltData.extend(
"PATHNAME",
typeid(std::string));
196 hltData.extend(
"INPUTCOUNT",
typeid(
unsigned int));
197 hltData.extend(
"ACCEPTCOUNT",
typeid(
unsigned int));
198 hltData.extend(
"PRESCALE",
typeid(
unsigned int));
201 unsigned long long& hlt_id=hltData[
"HLT_ID"].data<
unsigned long long>();
202 unsigned int& hltrunnum=hltData[
"RUNNUM"].data<
unsigned int>();
203 unsigned int& cmslsnum=hltData[
"CMSLSNUM"].data<
unsigned int>();
204 std::string& pathname=hltData[
"PATHNAME"].data<std::string>();
205 unsigned int& inputcount=hltData[
"INPUTCOUNT"].data<
unsigned int>();
206 unsigned int& acceptcount=hltData[
"ACCEPTCOUNT"].data<
unsigned int>();
207 unsigned int& prescale=hltData[
"PRESCALE"].data<
unsigned int>();
209 coral::IBulkOperation* hltInserter=0;
210 unsigned int comittedls=0;
211 for(hltIt=hltBeg;hltIt!=hltEnd;++hltIt,++hltlscount){
212 std::vector<HLT2DB::hltinfo>::const_iterator pathIt;
213 std::vector<HLT2DB::hltinfo>::const_iterator pathBeg=hltIt->begin();
214 std::vector<HLT2DB::hltinfo>::const_iterator pathEnd=hltIt->end();
215 if(!destsession->transaction().isActive()){
216 destsession->transaction().start(
false);
218 hltInserter=hlttable.dataEditor().bulkInsert(hltData,200);
220 unsigned int hltpathcount=0;
221 for(pathIt=pathBeg;pathIt!=pathEnd;++pathIt,++hltpathcount){
222 hlt_id = idallocationtable[hltlscount].at(hltpathcount);
224 cmslsnum = pathIt->cmsluminr;
225 pathname = pathIt->pathname;
226 inputcount = pathIt->hltinput;
227 acceptcount = pathIt->hltaccept;
228 prescale = pathIt->prescale;
229 hltInserter->processNextIteration();
231 hltInserter->flush();
234 std::cout<<
"\t committing in LS chunck "<<comittedls<<std::endl;
235 delete hltInserter; hltInserter=0;
236 destsession->transaction().commit();
239 }
else if( hltlscount==(totalcmsls-1) ){
240 std::cout<<
"\t committing at the end"<<std::endl;
241 delete hltInserter; hltInserter=0;
242 destsession->transaction().commit();
247 std::cout<<
"database problem "<<er.what()<<std::endl;
248 destsession->transaction().rollback();
static const std::string hltTableName()
unsigned long long generateNextIDForTable(const std::string &tableName, unsigned int interval=1)
static const unsigned int COMMITLSINTERVAL