CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTV32DB.cc
Go to the documentation of this file.
1 #ifndef RecoLuminosity_LumiProducer_HLTV32DB_H
2 #define RecoLuminosity_LumiProducer_HLTV32DB_H
3 #include "CoralBase/AttributeList.h"
4 #include "CoralBase/Attribute.h"
5 #include "CoralBase/AttributeSpecification.h"
6 #include "CoralBase/Blob.h"
7 #include "CoralBase/Exception.h"
8 #include "RelationalAccess/ConnectionService.h"
9 #include "RelationalAccess/ISessionProxy.h"
10 #include "RelationalAccess/ITransaction.h"
11 #include "RelationalAccess/ITypeConverter.h"
12 #include "RelationalAccess/IQuery.h"
13 #include "RelationalAccess/ICursor.h"
14 #include "RelationalAccess/ISchema.h"
15 #include "RelationalAccess/IView.h"
16 #include "RelationalAccess/ITable.h"
17 #include "RelationalAccess/ITableDataEditor.h"
18 #include "RelationalAccess/IBulkOperation.h"
19 
27 #include <iostream>
28 #include <map>
29 #include <vector>
30 #include <string>
31 #include <cstring>
33 namespace lumi{
34  class HLTV32DB : public DataPipe{
35 
36  public:
37  const static unsigned int COMMITINTERVAL=200; //commit interval in LS,totalrow=nls*(~200)
38  const static unsigned int COMMITLSINTERVAL=500; //commit interval in LS
39 
40  explicit HLTV32DB(const std::string& dest);
41  virtual void retrieveData( unsigned int );
42  virtual const std::string dataType() const;
43  virtual const std::string sourceType() const;
44  virtual ~HLTV32DB();
45  struct hltinfo{
46  unsigned int cmsluminr;
47  std::string pathname;
48  unsigned int hltinput;
49  unsigned int hltaccept;
50  unsigned int prescale;
51  };
52  typedef std::map< unsigned int, std::string , std::less<unsigned int> > HltPathMap; //order by hltpathid
53  typedef std::vector< std::map<unsigned int,HLTV32DB::hltinfo,std::less<unsigned int> > > HltResult;
54 
55  void writeHltData(coral::ISessionProxy* lumisession,
56  unsigned int irunnumber,
57  const std::string& source,
58  unsigned int npath,
59  HltResult::iterator hltBeg,
60  HltResult::iterator hltEnd,
61  unsigned int commitintv);
62  void writeHltDataToSchema2(coral::ISessionProxy* lumisession,
63  unsigned int irunnumber,
64  const std::string& source,
65  unsigned int npath,
66  HltResult::iterator hltBeg,
67  HltResult::iterator hltEnd,
68  HltPathMap& hltpathmap,
69  unsigned int commitintv);
70  };//cl HLTV32DB
71 
72  //
73  //implementation
74  //
75 
76  HLTV32DB::HLTV32DB(const std::string& dest):DataPipe(dest){}
77  void HLTV32DB::retrieveData( unsigned int runnumber){
78  std::string confdbschema("CMS_HLT");
79  std::string hltschema("CMS_RUNINFO");
80  std::string confdbpathtabname("PATHS");
81  std::string triggerpathtabname("HLT_SUPERVISOR_TRIGGERPATHS");
82  std::string lstabname("HLT_SUPERVISOR_LUMISECTIONS_V3");
83  std::string maptabname("HLT_SUPERVISOR_SCALAR_MAP_V2");
84 
85  coral::ConnectionService* svc=new coral::ConnectionService;
86  lumi::DBConfig dbconf(*svc);
87  if(!m_authpath.empty()){
89  }
90 
99  //std::cout<<"m_source "<<m_source<<std::endl;
100  //std::cout<<"m_source "<<m_source<<std::endl;
101  std::string::size_type cutpos=m_source.find(';');
102  std::string dbsource=m_source;
103  std::string csvsource("");
104  if(cutpos!=std::string::npos){
105  dbsource=m_source.substr(0,cutpos);
106  csvsource=m_source.substr(cutpos+1);
107  }
108  //std::cout<<"dbsource: "<<dbsource<<" , csvsource: "<<csvsource<<std::endl;
109  coral::ISessionProxy* srcsession=svc->connect(dbsource, coral::ReadOnly);
110  coral::ITypeConverter& tpc=srcsession->typeConverter();
111  tpc.setCppTypeForSqlType("unsigned int","NUMBER(11)");
112  srcsession->transaction().start(true);
113  coral::ISchema& hltSchemaHandle=srcsession->schema(hltschema);
114  coral::ISchema& confdbSchemaHandle=srcsession->schema(confdbschema);
115  if( !hltSchemaHandle.existsTable(triggerpathtabname) || !hltSchemaHandle.existsTable(lstabname) || !hltSchemaHandle.existsTable(maptabname) ){
116  throw lumi::Exception("missing hlt tables" ,"retrieveData","HLTV32DB");
117  }
118  HltPathMap hltpathmap;
119  coral::AttributeList bindVariableList;
120  bindVariableList.extend("runnumber",typeid(unsigned int));
121  bindVariableList["runnumber"].data<unsigned int>()=runnumber;
122  coral::IQuery* q1=hltSchemaHandle.tableHandle(triggerpathtabname).newQuery();
123  coral::AttributeList hltpathid;
124  hltpathid.extend("hltpathid",typeid(unsigned int));
125  q1->addToOutputList("distinct PATHID","hltpathid");
126  q1->setCondition("RUNNUMBER =:runnumber",bindVariableList);
127  q1->defineOutput(hltpathid);
128  coral::ICursor& c=q1->execute();
129  unsigned int npc=0;
130  while( c.next() ){
131  npc++;
132  unsigned int hid=c.currentRow()["hltpathid"].data<unsigned int>();
133  hltpathmap.insert(std::make_pair(hid,""));
134  }
135  delete q1;
136  HltPathMap::iterator mpit;
137  HltPathMap::iterator mpitBeg=hltpathmap.begin();
138  HltPathMap::iterator mpitEnd=hltpathmap.end();
139  for( mpit=mpitBeg;mpit!=mpitEnd;++mpit){
140  coral::IQuery* mq=confdbSchemaHandle.newQuery();
141  coral::AttributeList mqbindVariableList;
142  mqbindVariableList.extend("pathid",typeid(unsigned int));
143  mqbindVariableList["pathid"].data<unsigned int>()=mpit->first;
144  mq->addToTableList(confdbpathtabname);
145  mq->addToOutputList("NAME","hltpathname");
146  mq->setCondition("PATHID=:pathid",mqbindVariableList);
147  coral::ICursor& mqcursor=mq->execute();
148  while( mqcursor.next() ){
149  std::string pathname=mqcursor.currentRow()["hltpathname"].data<std::string>();
150  hltpathmap[mpit->first]=pathname;
151  }
152  delete mq;
153  }
154  //for( mpit=mpitBeg;mpit!=mpitEnd;++mpit){
155  // std::cout<<mpit->first<<" "<<mpit->second<<std::endl;
156  //}
157  unsigned int maxls=0;
158  unsigned int minls=0;
159  unsigned int nls=0;
160  coral::IQuery* nq=hltSchemaHandle.tableHandle(lstabname).newQuery();
161  coral::AttributeList nqbindVariableList;
162  coral::AttributeList nqout;
163  nqout.extend("minls",typeid(unsigned int));
164  nqout.extend("maxls",typeid(unsigned int));
165  nqbindVariableList.extend("runnumber",typeid(unsigned int));
166  nqbindVariableList["runnumber"].data<unsigned int>()=runnumber;
167  nq->addToOutputList("min(lsnumber)","minls");
168  nq->addToOutputList("max(lsnumber)","maxls");
169  nq->setCondition("RUNNUMBER =:runnumber",nqbindVariableList);
170  nq->defineOutput(nqout);
171  coral::ICursor& nqcursor=nq->execute();
172  while( nqcursor.next() ){
173  minls=nqcursor.currentRow()["minls"].data<unsigned int>();
174  maxls=nqcursor.currentRow()["maxls"].data<unsigned int>();
175  }
176  delete nq;
177  //std::cout<<"nls "<<nls<<std::endl;
178  HltResult hltresult;
179  nls=maxls-minls+1;
180  std::cout<<"nls "<<nls<<std::endl;
181  hltresult.reserve(nls);//
182  //fix all size
183  for(unsigned int i=minls;i<=maxls;++i){
184  if (i==0) continue; //skip ls=0
185  std::map<unsigned int, HLTV32DB::hltinfo> allpaths;
186  HltPathMap::iterator aIt;
187  HltPathMap::iterator aItBeg=hltpathmap.begin();
188  HltPathMap::iterator aItEnd=hltpathmap.end();
189  for(aIt=aItBeg;aIt!=aItEnd;++aIt){
191  ct.cmsluminr=i;
192  ct.pathname=aIt->second;
193  ct.hltinput=0;
194  ct.hltaccept=0;
195  ct.prescale=0;
196  allpaths.insert(std::make_pair(aIt->first,ct));
197  }
198  hltresult.push_back(allpaths);
199  }
200  //std::cout<<"book hltresult size "<<hltresult.size()<<std::endl;
201  coral::IQuery* jq=hltSchemaHandle.newQuery();
202  coral::AttributeList jqbindVariableList;
203  jqbindVariableList.extend("runnumber",typeid(unsigned int));
204  jqbindVariableList["runnumber"].data<unsigned int>()=runnumber;
205  coral::AttributeList jqoutput;
206  jqoutput.extend("lsnumber",typeid(unsigned int));
207  jqoutput.extend("pathid",typeid(unsigned int));
208  jqoutput.extend("l1pass",typeid(unsigned int));
209  jqoutput.extend("paccept",typeid(unsigned int));
210  jqoutput.extend("psvalue",typeid(unsigned int));
211  jq->addToTableList(triggerpathtabname,"tr");
212  jq->addToTableList(lstabname,"ls");
213  jq->addToTableList(maptabname,"sm");
214  jq->addToOutputList("tr.LSNUMBER","lsnumber");
215  jq->addToOutputList("tr.PATHID","pathid");
216  jq->addToOutputList("tr.L1PASS","l1pass");
217  jq->addToOutputList("tr.PACCEPT","paccept");
218  jq->addToOutputList("sm.PSVALUE","psvalue");
219  jq->setCondition("tr.RUNNUMBER=ls.RUNNUMBER AND tr.LSNUMBER=ls.LSNUMBER and sm.RUNNUMBER=tr.RUNNUMBER and sm.PATHID=tr.PATHID and sm.PSINDEX=ls.PSINDEX and tr.RUNNUMBER=:runnumber",jqbindVariableList);
220  jq->defineOutput(jqoutput);
221  jq->addToOrderList("tr.LSNUMBER");
222  jq->setRowCacheSize(10692);
223  coral::ICursor& jqcursor=jq->execute();
224  bool lscountfromzero=false;
225  while( jqcursor.next() ){
226  const coral::AttributeList& row=jqcursor.currentRow();
227  unsigned int currentLumiSection=row["lsnumber"].data<unsigned int>();
228  if (currentLumiSection==0){
229  lscountfromzero=true;
230  }else{
231  std::map<unsigned int,hltinfo>& allpathinfo=hltresult.at(currentLumiSection-1);
232  unsigned int pathid=row["pathid"].data<unsigned int>();
233  //std::cout<<"look for path id "<<pathid<<std::endl;
234  hltinfo& pathcontent=allpathinfo[pathid];
235  pathcontent.hltinput=row["l1pass"].data<unsigned int>();
236  pathcontent.hltaccept=row["paccept"].data<unsigned int>();
237  pathcontent.prescale=row["psvalue"].data<unsigned int>();
238  }
239  }
240  if(lscountfromzero) {
241  std::cout<<"hlt ls count from 0 , we skip/dodge/parry it!"<<std::endl;
242  }
243  delete jq;
244  srcsession->transaction().commit();
245  delete srcsession;
246  //
247  // Write into DB
248  //
249  unsigned int npath=hltpathmap.size();
250  coral::ISessionProxy* destsession=svc->connect(m_dest,coral::Update);
251  coral::ITypeConverter& lumitpc=destsession->typeConverter();
252  lumitpc.setCppTypeForSqlType("unsigned int","NUMBER(7)");
253  lumitpc.setCppTypeForSqlType("unsigned int","NUMBER(10)");
254  lumitpc.setCppTypeForSqlType("unsigned long long","NUMBER(20)");
255 
256  //for(hltIt=hltItBeg;hltIt!=hltItEnd;++hltIt){
257  // std::map<unsigned int,HLTV32DB::hltinfo>::iterator pathIt;
258  // std::map<unsigned int,HLTV32DB::hltinfo>::iterator pathItBeg=hltIt->begin();
259  // std::map<unsigned int,HLTV32DB::hltinfo>::iterator pathItEnd=hltIt->end();
260  // for(pathIt=pathItBeg;pathIt!=pathItEnd;++pathIt){
261  // std::cout<<"cmslsnr "<<pathIt->second.cmsluminr<<" "<<pathIt->second.pathname<<" "<<pathIt->second.hltinput<<" "<<pathIt->second.hltaccept<<" "<<pathIt->second.prescale<<std::endl;
262  // }
263  //}
264  unsigned int totalcmsls=hltresult.size();
265  std::cout<<"inserting totalhltls "<<totalcmsls<<" total path "<<npath<<std::endl;
266  //HltResult::iterator hltItBeg=hltresult.begin();
267  //HltResult::iterator hltItEnd=hltresult.end();
268  try{
269  if(m_mode=="loadoldschema"){
270  std::cout<<"writing hlt data to old hlt table"<<std::endl;
271  writeHltData(destsession,runnumber,dbsource,npath,hltresult.begin(),hltresult.end(),COMMITINTERVAL);
272  std::cout<<"done"<<std::endl;
273  }
274  std::cout<<"writing hlt data to new lshlt table"<<std::endl;
275  writeHltDataToSchema2(destsession,runnumber,dbsource,npath,hltresult.begin(),hltresult.end(), hltpathmap,COMMITLSINTERVAL);
276  std::cout<<"done"<<std::endl;
277  delete destsession;
278  delete svc;
279  }catch( const coral::Exception& er){
280  std::cout<<"database problem "<<er.what()<<std::endl;
281  destsession->transaction().rollback();
282  delete destsession;
283  delete svc;
284  throw er;
285  }
286  }
287  void
288  HLTV32DB::writeHltData(coral::ISessionProxy* lumisession,
289  unsigned int irunnumber,
290  const std::string& source,
291  unsigned int npath,
292  HltResult::iterator hltItBeg,
293  HltResult::iterator hltItEnd,
294  unsigned int commitintv){
295  std::map< unsigned long long, std::vector<unsigned long long> > idallocationtable;
296  unsigned int hltlscount=0;
297  unsigned int totalcmsls=std::distance(hltItBeg,hltItEnd);
298  std::cout<<"\t allocating total ids "<<totalcmsls*npath<<std::endl;
299  lumisession->transaction().start(false);
300  lumi::idDealer idg(lumisession->nominalSchema());
301  unsigned long long hltID = idg.generateNextIDForTable(LumiNames::hltTableName(),totalcmsls*npath)-totalcmsls*npath;
302  for(HltResult::iterator hltIt=hltItBeg;hltIt!=hltItEnd;++hltIt,++hltlscount){
303  std::vector<unsigned long long> pathvec;
304  pathvec.reserve(npath);
305  for(unsigned int i=0;i<npath;++i,++hltID){
306  pathvec.push_back(hltID);
307  }
308  idallocationtable.insert(std::make_pair(hltlscount,pathvec));
309  }
310  std::cout<<"\t all ids allocated"<<std::endl;
311 
312  coral::AttributeList hltData;
313  hltData.extend("HLT_ID",typeid(unsigned long long));
314  hltData.extend("RUNNUM",typeid(unsigned int));
315  hltData.extend("CMSLSNUM",typeid(unsigned int));
316  hltData.extend("PATHNAME",typeid(std::string));
317  hltData.extend("INPUTCOUNT",typeid(unsigned int));
318  hltData.extend("ACCEPTCOUNT",typeid(unsigned int));
319  hltData.extend("PRESCALE",typeid(unsigned int));
320 
321  //loop over lumi LS
322  unsigned long long& hlt_id=hltData["HLT_ID"].data<unsigned long long>();
323  unsigned int& hltrunnum=hltData["RUNNUM"].data<unsigned int>();
324  unsigned int& cmslsnum=hltData["CMSLSNUM"].data<unsigned int>();
325  std::string& pathname=hltData["PATHNAME"].data<std::string>();
326  unsigned int& inputcount=hltData["INPUTCOUNT"].data<unsigned int>();
327  unsigned int& acceptcount=hltData["ACCEPTCOUNT"].data<unsigned int>();
328  unsigned int& prescale=hltData["PRESCALE"].data<unsigned int>();
329  hltlscount=0;
330  coral::IBulkOperation* hltInserter=0;
331  unsigned int comittedls=0;
332  for(HltResult::iterator hltIt=hltItBeg;hltIt!=hltItEnd;++hltIt,++hltlscount){
333  std::map<unsigned int,HLTV32DB::hltinfo>::const_iterator pathIt;
334  std::map<unsigned int,HLTV32DB::hltinfo>::const_iterator pathBeg=hltIt->begin();
335  std::map<unsigned int,HLTV32DB::hltinfo>::const_iterator pathEnd=hltIt->end();
336  if(!lumisession->transaction().isActive()){
337  lumisession->transaction().start(false);
338  coral::ITable& hlttable=lumisession->nominalSchema().tableHandle(LumiNames::hltTableName());
339  hltInserter=hlttable.dataEditor().bulkInsert(hltData,npath);
340  }else{
341  if(hltIt==hltItBeg){
342  coral::ITable& hlttable=lumisession->nominalSchema().tableHandle(LumiNames::hltTableName());
343  hltInserter=hlttable.dataEditor().bulkInsert(hltData,npath);
344  }
345  }
346  unsigned int hltpathcount=0;
347  for(pathIt=pathBeg;pathIt!=pathEnd;++pathIt,++hltpathcount){
348  hlt_id = idallocationtable[hltlscount].at(hltpathcount);
349  hltrunnum = irunnumber;
350  cmslsnum = pathIt->second.cmsluminr;
351  pathname = pathIt->second.pathname;
352  inputcount = pathIt->second.hltinput;
353  acceptcount = pathIt->second.hltaccept;
354  prescale = pathIt->second.prescale;
355  hltInserter->processNextIteration();
356  }
357  hltInserter->flush();
358  ++comittedls;
359  if(comittedls==commitintv){
360  std::cout<<"\t committing in LS chunck "<<comittedls<<std::endl;
361  delete hltInserter; hltInserter=0;
362  lumisession->transaction().commit();
363  comittedls=0;
364  std::cout<<"\t committed "<<std::endl;
365  }else if( hltlscount==(totalcmsls-1) ){
366  std::cout<<"\t committing at the end"<<std::endl;
367  delete hltInserter; hltInserter=0;
368  lumisession->transaction().commit();
369  std::cout<<"\t done"<<std::endl;
370  }
371  }
372  }
373  void
374  HLTV32DB::writeHltDataToSchema2(coral::ISessionProxy* lumisession,
375  unsigned int irunnumber,
376  const std::string& source,
377  unsigned int npath,
378  HltResult::iterator hltItBeg,
379  HltResult::iterator hltItEnd,
380  HltPathMap& hltpathmap,
381  unsigned int commitintv){
382  HltResult::iterator hltIt;
383  unsigned int totalcmsls=std::distance(hltItBeg,hltItEnd);
384  std::cout<<"inserting totalcmsls "<<totalcmsls<<std::endl;
385  coral::AttributeList lshltData;
386  lshltData.extend("DATA_ID",typeid(unsigned long long));
387  lshltData.extend("RUNNUM",typeid(unsigned int));
388  lshltData.extend("CMSLSNUM",typeid(unsigned int));
389  lshltData.extend("PRESCALEBLOB",typeid(coral::Blob));
390  lshltData.extend("HLTCOUNTBLOB",typeid(coral::Blob));
391  lshltData.extend("HLTACCEPTBLOB",typeid(coral::Blob));
392  unsigned long long& data_id=lshltData["DATA_ID"].data<unsigned long long>();
393  unsigned int& hltrunnum=lshltData["RUNNUM"].data<unsigned int>();
394  unsigned int& cmslsnum=lshltData["CMSLSNUM"].data<unsigned int>();
395  coral::Blob& prescaleblob=lshltData["PRESCALEBLOB"].data<coral::Blob>();
396  coral::Blob& hltcountblob=lshltData["HLTCOUNTBLOB"].data<coral::Blob>();
397  coral::Blob& hltacceptblob=lshltData["HLTACCEPTBLOB"].data<coral::Blob>();
398 
399  unsigned long long branch_id=3;
400  std::string branch_name("DATA");
401  lumi::RevisionDML revisionDML;
403  std::stringstream op;
404  op<<irunnumber;
405  std::string runnumberStr=op.str();
406  lumisession->transaction().start(false);
407  hltrundata.entry_name=runnumberStr;
408  hltrundata.source=source;
409  hltrundata.runnumber=irunnumber;
410  hltrundata.npath=npath;
411  std::string pathnames;
412  HltPathMap::iterator hltpathmapIt;
413  HltPathMap::iterator hltpathmapItBeg=hltpathmap.begin();
414  HltPathMap::iterator hltpathmapItEnd=hltpathmap.end();
415  for(hltpathmapIt=hltpathmapItBeg;hltpathmapIt!=hltpathmapItEnd;++hltpathmapIt){
416  if(hltpathmapIt!=hltpathmapItBeg){
417  pathnames+=std::string(",");
418  }
419  pathnames+=hltpathmapIt->second;
420  }
421  std::cout<<"\tpathnames "<<pathnames<<std::endl;
422  hltrundata.pathnames=pathnames;
423  hltrundata.entry_id=revisionDML.getEntryInBranchByName(lumisession->nominalSchema(),lumi::LumiNames::hltdataTableName(),runnumberStr,branch_name);
424  if(hltrundata.entry_id==0){
425  revisionDML.bookNewEntry(lumisession->nominalSchema(),LumiNames::hltdataTableName(),hltrundata);
426  std::cout<<"hltrundata revision_id "<<hltrundata.revision_id<<" entry_id "<<hltrundata.entry_id<<" data_id "<<hltrundata.data_id<<std::endl;
427  revisionDML.addEntry(lumisession->nominalSchema(),LumiNames::hltdataTableName(),hltrundata,branch_id,branch_name);
428  }else{
429  revisionDML.bookNewRevision(lumisession->nominalSchema(),LumiNames::hltdataTableName(),hltrundata);
430  std::cout<<"hltrundata revision_id "<<hltrundata.revision_id<<" entry_id "<<hltrundata.entry_id<<" data_id "<<hltrundata.data_id<<std::endl;
431  revisionDML.addRevision(lumisession->nominalSchema(),LumiNames::hltdataTableName(),hltrundata,branch_id,branch_name);
432  }
433  std::cout<<"inserting hltrundata"<<std::endl;
434  revisionDML.insertHltRunData(lumisession->nominalSchema(),hltrundata);
435  std::cout<<"inserting lshlt data"<<std::endl;
436 
437  unsigned int hltlscount=0;
438  coral::IBulkOperation* hltInserter=0;
439  unsigned int comittedls=0;
440  for(HltResult::iterator hltIt=hltItBeg;hltIt!=hltItEnd;++hltIt,++hltlscount){
441  unsigned int cmslscount=hltlscount+1;
442  std::map<unsigned int,HLTV32DB::hltinfo,std::less<unsigned int> >::const_iterator pathIt;
443  std::map<unsigned int,HLTV32DB::hltinfo,std::less<unsigned int> >::const_iterator pathBeg=hltIt->begin();
444  std::map<unsigned int,HLTV32DB::hltinfo,std::less<unsigned int> >::const_iterator pathEnd=hltIt->end();
445  if(!lumisession->transaction().isActive()){
446  lumisession->transaction().start(false);
447  coral::ITable& hlttable=lumisession->nominalSchema().tableHandle(LumiNames::lshltTableName());
448  hltInserter=hlttable.dataEditor().bulkInsert(lshltData,npath);
449  }else{
450  if(hltIt==hltItBeg){
451  coral::ITable& hlttable=lumisession->nominalSchema().tableHandle(LumiNames::lshltTableName());
452  hltInserter=hlttable.dataEditor().bulkInsert(lshltData,npath);
453  }
454  }
455  data_id = hltrundata.data_id;
456  hltrunnum = irunnumber;
457  cmslsnum = cmslscount;
458  std::vector<unsigned int> prescales; prescales.reserve(npath);
459  std::vector<unsigned int> hltcounts; hltcounts.reserve(npath);
460  std::vector<unsigned int> hltaccepts; hltaccepts.reserve(npath);
461 
462  for(pathIt=pathBeg;pathIt!=pathEnd;++pathIt){
463  unsigned int hltcount=pathIt->second.hltinput;
464  //std::cout<<"hltcount "<<hltcount<<std::endl;
465  hltcounts.push_back(hltcount);
466  unsigned int hltaccept=pathIt->second.hltaccept;
467  //std::cout<<"hltaccept "<<hltaccept<<std::endl;
468  hltaccepts.push_back(hltaccept);
469  unsigned int prescale=pathIt->second.prescale;
470  //std::cout<<"prescale "<<prescale<<std::endl;
471  prescales.push_back(prescale);
472  }
473  prescaleblob.resize(sizeof(unsigned int)*npath);
474  void* prescaleblob_StartAddress = prescaleblob.startingAddress();
475  std::memmove(prescaleblob_StartAddress,&prescales[0],sizeof(unsigned int)*npath);
476  hltcountblob.resize(sizeof(unsigned int)*npath);
477  void* hltcountblob_StartAddress = hltcountblob.startingAddress();
478  std::memmove(hltcountblob_StartAddress,&hltcounts[0],sizeof(unsigned int)*npath);
479  hltacceptblob.resize(sizeof(unsigned int)*npath);
480  void* hltacceptblob_StartAddress = hltacceptblob.startingAddress();
481  std::memmove(hltacceptblob_StartAddress,&hltaccepts[0],sizeof(unsigned int)*npath);
482 
483  hltInserter->processNextIteration();
484  hltInserter->flush();
485  ++comittedls;
486  if(comittedls==commitintv){
487  std::cout<<"\t committing in LS chunck "<<comittedls<<std::endl;
488  delete hltInserter; hltInserter=0;
489  lumisession->transaction().commit();
490  comittedls=0;
491  std::cout<<"\t committed "<<std::endl;
492  }else if( hltlscount==(totalcmsls-1) ){
493  std::cout<<"\t committing at the end"<<std::endl;
494  delete hltInserter; hltInserter=0;
495  lumisession->transaction().commit();
496  std::cout<<"\t done"<<std::endl;
497  }
498  }
499  }
500  const std::string HLTV32DB::dataType() const{
501  return "HLTV3";
502  }
503  const std::string HLTV32DB::sourceType() const{
504  return "DB";
505  }
507 }//ns lumi
510 #endif
int i
Definition: DBlmapReader.cc:9
virtual void retrieveData(unsigned int)
Definition: HLTV32DB.cc:77
void addEntry(coral::ISchema &schema, const std::string &datatableName, const Entry &entry, unsigned long long branch_id, const std::string &branchname)
Definition: RevisionDML.cc:61
tuple lumi
Definition: fjr2json.py:35
list hltrundata
Definition: dataDML.py:2363
static const std::string lshltTableName()
Definition: LumiNames.cc:59
void 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:374
std::vector< std::map< unsigned int, HLTV32DB::hltinfo, std::less< unsigned int > > > HltResult
Definition: HLTV32DB.cc:53
uint16_t size_type
std::map< unsigned int, std::string, std::less< unsigned int > > HltPathMap
Definition: HLTV32DB.cc:52
static const std::string hltdataTableName()
Definition: LumiNames.cc:56
unsigned int cmsluminr
Definition: HLTV32DB.cc:46
std::string m_dest
Definition: DataPipe.h:27
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:288
unsigned long long data_id
Definition: RevisionDML.h:22
void setAuthentication(const std::string &authPath)
Definition: DBConfig.cc:15
unsigned long long getEntryInBranchByName(coral::ISchema &schema, const std::string &datatableName, const std::string &entryname, const std::string &branchname)
Definition: RevisionDML.cc:14
tuple pathnames
Definition: lumiPlot.py:411
unsigned long long revision_id
Definition: RevisionDML.h:20
virtual const std::string sourceType() const
Definition: HLTV32DB.cc:503
std::string pathname
Definition: HLTV32DB.cc:47
static const unsigned int COMMITINTERVAL
Definition: HLTV32DB.cc:37
unsigned long long entry_id
Definition: RevisionDML.h:21
std::string m_source
Definition: DataPipe.h:28
static const unsigned int COMMITLSINTERVAL
Definition: HLTV32DB.cc:38
void bookNewEntry(coral::ISchema &schema, const std::string &datatableName, Entry &entry)
Definition: RevisionDML.cc:43
virtual const std::string dataType() const
Definition: HLTV32DB.cc:500
void insertHltRunData(coral::ISchema &schema, const HltEntry &hltentry)
Definition: RevisionDML.cc:165
unsigned int hltaccept
Definition: HLTV32DB.cc:49
virtual ~HLTV32DB()
Definition: HLTV32DB.cc:506
double q1[4]
Definition: TauolaWrapper.h:87
static const std::string hltTableName()
Definition: LumiNames.cc:17
unsigned long long generateNextIDForTable(const std::string &tableName, unsigned int interval=1)
Definition: idDealer.cc:31
std::string m_authpath
Definition: DataPipe.h:29
std::string m_mode
Definition: DataPipe.h:30
tuple cout
Definition: gather_cfg.py:121
#define DEFINE_EDM_PLUGIN(factory, type, name)
void addRevision(coral::ISchema &schema, const std::string &datatableName, const Entry &revision, unsigned long long branch_id, std::string &branchname)
Definition: RevisionDML.cc:99
unsigned int prescale
Definition: HLTV32DB.cc:50
HLTV32DB(const std::string &dest)
Definition: HLTV32DB.cc:76
tuple destsession
Definition: DBCopy.py:270
void bookNewRevision(coral::ISchema &schema, const std::string &datatableName, Entry &revision)
Definition: RevisionDML.cc:53
unsigned int hltinput
Definition: HLTV32DB.cc:48