CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

virtual const std::string dataType () const
 
 HLTV32DB (const std::string &dest)
 
virtual void retrieveData (unsigned int)
 
virtual const std::string sourceType () const
 
void writeHltData (coral::ISessionProxy *lumisession, unsigned int irunnumber, const std::string &source, unsigned int npath, HltResult::iterator hltBeg, HltResult::iterator hltEnd, unsigned int commitintv)
 
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)
 
virtual ~HLTV32DB ()
 
- Public Member Functions inherited from lumi::DataPipe
 DataPipe (const std::string &)
 
std::string getAuthPath () const
 
std::string getMode () const
 
float getNorm () const
 
std::string getSource () const
 
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

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

Definition at line 52 of file HLTV32DB.cc.

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

Definition at line 53 of file HLTV32DB.cc.

Constructor & Destructor Documentation

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

Definition at line 76 of file HLTV32DB.cc.

76 :DataPipe(dest){}
DataPipe(const std::string &)
Definition: DataPipe.cc:2
lumi::HLTV32DB::~HLTV32DB ( )
virtual

Definition at line 506 of file HLTV32DB.cc.

506 {}

Member Function Documentation

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

Implements lumi::DataPipe.

Definition at line 500 of file HLTV32DB.cc.

500  {
501  return "HLTV3";
502  }
void lumi::HLTV32DB::retrieveData ( unsigned int  runnumber)
virtual

retrieve hlt info with 3 queries from runinfo

  1. select distinct ( PATHID ) from HLT_SUPERVISOR_TRIGGERPATHS where runnumber=158878;
  2. retrieve hltpath map with n query from cms_hlt (n=number of pathids) select name from cms_hlt.paths where pathid=:pathid
  3. select min(lsnumber),max(lsnumber) from HLT_SUPERVISOR_LUMISECTIONS_V3 where runnumber=158878;
  4. select tr.lsnumber,tr.pathid,tr.l1pass,tr.paccept,ls.psindex,sm.psvalue from hlt_supervisor_triggerpaths tr,hlt_supervisor_lumisections_v3 ls,hlt_supervisor_scalar_map_v2 sm where 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=157805 order by tr.lsnumber;

Implements lumi::DataPipe.

Definition at line 77 of file HLTV32DB.cc.

References trackerHits::c, lumi::HLTV32DB::hltinfo::cmsluminr, COMMITINTERVAL, COMMITLSINTERVAL, gather_cfg::cout, python.DBCopy::destsession, edm::hlt::Exception, lumi::HLTV32DB::hltinfo::hltaccept, lumi::HLTV32DB::hltinfo::hltinput, i, lumi::DataPipe::m_authpath, lumi::DataPipe::m_dest, lumi::DataPipe::m_mode, lumi::DataPipe::m_source, lumi::HLTV32DB::hltinfo::pathname, timingPdfMaker::pathname, lumi::HLTV32DB::hltinfo::prescale, q1, lumi::DBConfig::setAuthentication(), python.CommonUtils::svc, writeHltData(), and writeHltDataToSchema2().

77  {
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()){
88  dbconf.setAuthentication(m_authpath);
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){
190  HLTV32DB::hltinfo ct;
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  }
int i
Definition: DBlmapReader.cc:9
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
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
static const unsigned int COMMITINTERVAL
Definition: HLTV32DB.cc:37
std::string m_source
Definition: DataPipe.h:28
static const unsigned int COMMITLSINTERVAL
Definition: HLTV32DB.cc:38
double q1[4]
Definition: TauolaWrapper.h:87
std::string m_authpath
Definition: DataPipe.h:29
std::string m_mode
Definition: DataPipe.h:30
tuple cout
Definition: gather_cfg.py:121
tuple destsession
Definition: DBCopy.py:270
const std::string lumi::HLTV32DB::sourceType ( ) const
virtual

Implements lumi::DataPipe.

Definition at line 503 of file HLTV32DB.cc.

503  {
504  return "DB";
505  }
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 288 of file HLTV32DB.cc.

References estimatePileup2::cmslsnum, gather_cfg::cout, lumi::idDealer::generateNextIDForTable(), lumi::LumiNames::hltTableName(), i, and timingPdfMaker::pathname.

Referenced by retrieveData().

294  {
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  }
int i
Definition: DBlmapReader.cc:9
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
tuple cout
Definition: gather_cfg.py:121
void 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 374 of file HLTV32DB.cc.

References lumi::RevisionDML::addEntry(), lumi::RevisionDML::addRevision(), lumi::RevisionDML::bookNewEntry(), lumi::RevisionDML::bookNewRevision(), estimatePileup2::cmslsnum, gather_cfg::cout, lumi::RevisionDML::Entry::data_id, lumi::RevisionDML::Entry::entry_id, lumi::RevisionDML::Entry::entry_name, lumi::RevisionDML::getEntryInBranchByName(), lumi::LumiNames::hltdataTableName(), dataDML::hltrundata, lumi::RevisionDML::insertHltRunData(), lumi::LumiNames::lshltTableName(), lumi::RevisionDML::HltEntry::npath, lumi::RevisionDML::HltEntry::pathnames, lumiPlot::pathnames, makeHLTPrescaleTable::prescales, lumi::RevisionDML::Entry::revision_id, lumi::RevisionDML::HltEntry::runnumber, LaserTracksInput_cfi::source, and lumi::RevisionDML::HltEntry::source.

Referenced by retrieveData().

381  {
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  }
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
list hltrundata
Definition: dataDML.py:2363
static const std::string lshltTableName()
Definition: LumiNames.cc:59
static const std::string hltdataTableName()
Definition: LumiNames.cc:56
unsigned long long data_id
Definition: RevisionDML.h:22
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
unsigned long long entry_id
Definition: RevisionDML.h:21
void bookNewEntry(coral::ISchema &schema, const std::string &datatableName, Entry &entry)
Definition: RevisionDML.cc:43
void insertHltRunData(coral::ISchema &schema, const HltEntry &hltentry)
Definition: RevisionDML.cc:165
tuple cout
Definition: gather_cfg.py:121
void addRevision(coral::ISchema &schema, const std::string &datatableName, const Entry &revision, unsigned long long branch_id, std::string &branchname)
Definition: RevisionDML.cc:99
void bookNewRevision(coral::ISchema &schema, const std::string &datatableName, Entry &revision)
Definition: RevisionDML.cc:53

Member Data Documentation

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

Definition at line 37 of file HLTV32DB.cc.

Referenced by retrieveData().

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

Definition at line 38 of file HLTV32DB.cc.

Referenced by retrieveData().