CMS 3D CMS Logo

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 override
 
 HLTV32DB (const std::string &dest)
 
virtual unsigned long long retrieveData (unsigned int) override
 
virtual const std::string sourceType () const override
 
void writeHltData (coral::ISessionProxy *lumisession, unsigned int irunnumber, const std::string &source, unsigned int npath, HltResult::iterator hltBeg, HltResult::iterator hltEnd, unsigned int commitintv)
 
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)
 
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 73 of file HLTV32DB.cc.

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

Definition at line 539 of file HLTV32DB.cc.

References DEFINE_EDM_PLUGIN.

539 {}

Member Function Documentation

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

Implements lumi::DataPipe.

Definition at line 533 of file HLTV32DB.cc.

533  {
534  return "HLTV3";
535  }
unsigned long long lumi::HLTV32DB::retrieveData ( unsigned int  runnumber)
overridevirtual

retrieve hlt info with 3 queries from runinfo

  1. select prescale_index,lumi_section from cms_gt_mon.lumi_sections where run_number=:runnum; => map{ls:psindex}
  2. select name from cms_hlt.paths where pathid=:pathid

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;

initialize hltpathmap

select name from cms_hlt.paths where pathid=:pathid

fill up hltpathmap

initialize hltresult

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; } }

Implements lumi::DataPipe.

Definition at line 74 of file HLTV32DB.cc.

References EnergyCorrector::c, lumi::HLTV32DB::hltinfo::cmsluminr, COMMITINTERVAL, COMMITLSINTERVAL, gather_cfg::cout, Exception, lumi::HLTV32DB::hltinfo::hltaccept, dataDML::hltdataid, 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, lumi::HLTV32DB::hltinfo::prescale, q1, lumi::DBConfig::setAuthentication(), AlCaHLTBitMon_QueryRunRegistry::string, dataDML::svc, writeHltData(), and writeHltDataToSchema2().

74  {
75  std::string confdbschema("CMS_HLT");
76  std::string hltschema("CMS_RUNINFO");
77  std::string gtschema("CMS_GT_MON");
78  std::string confdbpathtabname("PATHS");
79  std::string triggerpathtabname("HLT_SUPERVISOR_TRIGGERPATHS");
80  std::string maptabname("HLT_SUPERVISOR_SCALAR_MAP_V2");
81  std::string gttabname("LUMI_SECTIONS");
82  coral::ConnectionService* svc=new coral::ConnectionService;
83  lumi::DBConfig dbconf(*svc);
84  if(!m_authpath.empty()){
85  dbconf.setAuthentication(m_authpath);
86  }
91  std::string::size_type cutpos=m_source.find(';');
92  std::string dbsource=m_source;
93  std::string csvsource("");
94  if(cutpos!=std::string::npos){
95  dbsource=m_source.substr(0,cutpos);
96  csvsource=m_source.substr(cutpos+1);
97  }
98  //std::cout<<"dbsource: "<<dbsource<<" , csvsource: "<<csvsource<<std::endl;
99  coral::ISessionProxy* srcsession=svc->connect(dbsource, coral::ReadOnly);
100  coral::ITypeConverter& tpc=srcsession->typeConverter();
101  tpc.setCppTypeForSqlType("unsigned int","NUMBER(11)");
102  srcsession->transaction().start(true);
103  coral::ISchema& gtSchemaHandle=srcsession->schema(gtschema);
104  coral::ISchema& hltSchemaHandle=srcsession->schema(hltschema);
105  coral::ISchema& confdbSchemaHandle=srcsession->schema(confdbschema);
106  if( !hltSchemaHandle.existsTable(triggerpathtabname) || !hltSchemaHandle.existsTable(maptabname) ){
107  throw lumi::Exception("missing hlt tables" ,"retrieveData","HLTV32DB");
108  }
110  //this is trg lumi section number
111  std::vector< std::pair<unsigned int,unsigned int> > psindexmap;
112  coral::AttributeList psindexVariableList;
113  psindexVariableList.extend("runnumber",typeid(unsigned int));
114  psindexVariableList["runnumber"].data<unsigned int>()=runnumber;
115  coral::IQuery* qPsindex=gtSchemaHandle.tableHandle(gttabname).newQuery();
116  coral::AttributeList psindexOutput;
117  psindexOutput.extend("PRESCALE_INDEX",typeid(unsigned int));
118  psindexOutput.extend("LUMI_SECTION",typeid(unsigned int));
119  qPsindex->addToOutputList("PRESCALE_INDEX");
120  qPsindex->addToOutputList("LUMI_SECTION");
121  qPsindex->setCondition("RUN_NUMBER=:runnumber",psindexVariableList);
122  qPsindex->defineOutput(psindexOutput);
123  coral::ICursor& psindexCursor=qPsindex->execute();
124  unsigned int lsmin=4294967295;
125  unsigned int lsmax=0;
126  while( psindexCursor.next() ){
127  if( !psindexCursor.currentRow()["PRESCALE_INDEX"].isNull() ){
128  unsigned int psindx=psindexCursor.currentRow()["PRESCALE_INDEX"].data<unsigned int>();
129  unsigned int pslsnum=psindexCursor.currentRow()["LUMI_SECTION"].data<unsigned int>();
130  if(pslsnum>lsmax){
131  lsmax=pslsnum;
132  }
133  if(pslsnum<lsmin){
134  lsmin=pslsnum;
135  }
136  psindexmap.push_back(std::make_pair(pslsnum,psindx));
137  }
138  }
139  delete qPsindex;
140  if(psindexmap.size()==0){
141  srcsession->transaction().commit();
142  delete srcsession;
143  throw lumi::Exception("no psindex data found","retrieveData","HLTV32DB");
144  }
145 
148  HltPathMap hltpathmap;
149  coral::AttributeList bindVariableList;
150  bindVariableList.extend("runnumber",typeid(unsigned int));
151  bindVariableList["runnumber"].data<unsigned int>()=runnumber;
152  coral::IQuery* q1=hltSchemaHandle.tableHandle(triggerpathtabname).newQuery();
153  coral::AttributeList hltpathid;
154  hltpathid.extend("hltpathid",typeid(unsigned int));
155  q1->addToOutputList("distinct(PATHID)","hltpathid");
156  q1->setCondition("RUNNUMBER=:runnumber",bindVariableList);
157  q1->defineOutput(hltpathid);
158  coral::ICursor& c=q1->execute();
159  unsigned int npc=0;
160  while( c.next() ){
161  npc++;
162  unsigned int hid=c.currentRow()["hltpathid"].data<unsigned int>();
163  hltpathmap.insert(std::make_pair(hid,""));
164  }
165  delete q1;
168  HltPathMap::iterator mpit;
169  HltPathMap::iterator mpitBeg=hltpathmap.begin();
170  HltPathMap::iterator mpitEnd=hltpathmap.end();
171  for( mpit=mpitBeg;mpit!=mpitEnd;++mpit){//loop over paths
172  coral::IQuery* mq=confdbSchemaHandle.newQuery();
173  coral::AttributeList mqbindVariableList;
174  mqbindVariableList.extend("pathid",typeid(unsigned int));
175  mqbindVariableList["pathid"].data<unsigned int>()=mpit->first;
176  mq->addToTableList(confdbpathtabname);
177  mq->addToOutputList("NAME","hltpathname");
178  mq->setCondition("PATHID=:pathid",mqbindVariableList);
179  coral::ICursor& mqcursor=mq->execute();
180  while( mqcursor.next() ){
181  std::string pathname=mqcursor.currentRow()["hltpathname"].data<std::string>();
182  hltpathmap[mpit->first]=pathname;
183  }
184  delete mq;
185  }
186 
188  HltResult hltresult;
189  unsigned int nls=lsmax-lsmin+1;
190  //std::cout<<"nls "<<nls<<std::endl;
191  hltresult.reserve(nls);//
192  //fix all size
193  for(unsigned int i=lsmin;i<=lsmax;++i){
194  if (i==0) continue; //skip ls=0
195  std::map<unsigned int, HLTV32DB::hltinfo> allpaths;
196  HltPathMap::iterator aIt;
197  HltPathMap::iterator aItBeg=hltpathmap.begin();
198  HltPathMap::iterator aItEnd=hltpathmap.end();
199  for(aIt=aItBeg;aIt!=aItEnd;++aIt){
200  HLTV32DB::hltinfo ct;
201  ct.cmsluminr=i;
202  ct.pathname=aIt->second;
203  ct.hltinput=0;
204  ct.hltaccept=0;
205  ct.prescale=0;
206  allpaths.insert(std::make_pair(aIt->first,ct));
207  }
208  hltresult.push_back(allpaths);
209  }
210 
211  bool lscountfromzero=false;
212 
214  for( std::vector< std::pair<unsigned int,unsigned int> >::iterator it=psindexmap.begin();it!=psindexmap.end();++it ){
215  //loop over ls
216  unsigned int lsnum=it->first;
217  unsigned int psindex=it->second;
218  coral::AttributeList hltdataVariableList;
219  hltdataVariableList.extend("runnumber",typeid(unsigned int));
220  hltdataVariableList.extend("lsnum",typeid(unsigned int));
221  hltdataVariableList.extend("psindex",typeid(unsigned int));
222  hltdataVariableList["runnumber"].data<unsigned int>()=runnumber;
223  hltdataVariableList["lsnum"].data<unsigned int>()=lsnum;
224  hltdataVariableList["psindex"].data<unsigned int>()=psindex;
225  coral::IQuery* qHltData=hltSchemaHandle.newQuery();
226  qHltData->addToTableList(triggerpathtabname,"t");
227  qHltData->addToTableList(maptabname,"m");
228  coral::AttributeList hltdataOutput;
229  hltdataOutput.extend("L1PASS",typeid(unsigned int));
230  hltdataOutput.extend("PACCEPT",typeid(unsigned int));
231  hltdataOutput.extend("PATHID",typeid(unsigned int));
232  hltdataOutput.extend("PSVALUE",typeid(unsigned int));
233 
234  qHltData->addToOutputList("t.L1PASS","l1pass");
235  qHltData->addToOutputList("t.PACCEPT","paccept");
236  qHltData->addToOutputList("t.PATHID","pathid");
237  qHltData->addToOutputList("m.PSVALUE","psvalue");
238  qHltData->setCondition("m.PATHID=t.PATHID and m.RUNNUMBER=t.RUNNUMBER and m.RUNNUMBER=:runnumber AND m.PSINDEX=:psindex AND t.LSNUMBER=:lsnum",hltdataVariableList);
239  qHltData->defineOutput(hltdataOutput);
240  coral::ICursor& hltdataCursor=qHltData->execute();
241  while( hltdataCursor.next() ){
242  const coral::AttributeList& row=hltdataCursor.currentRow();
243  if (lsnum==0){
244  lscountfromzero=true;
245  if(lscountfromzero) {
246  std::cout<<"hlt ls count from 0 , we skip/dodge/parry it!"<<std::endl;
247  }
248  }else{
249  unsigned int pathid=row["PATHID"].data<unsigned int>();
250  std::map<unsigned int,hltinfo>& allpathinfo=hltresult.at(lsnum-1);
251  hltinfo& pathcontent=allpathinfo[pathid];
252  pathcontent.hltinput=row["L1PASS"].data<unsigned int>();
253  pathcontent.hltaccept=row["PACCEPT"].data<unsigned int>();
254  pathcontent.prescale=row["PSVALUE"].data<unsigned int>();
255  }
256  }
257  delete qHltData;
258  }
259  srcsession->transaction().commit();
260  delete srcsession;
261  //
262  // Write into DB
263  //
264  unsigned int npath=hltpathmap.size();
265  coral::ISessionProxy* destsession=svc->connect(m_dest,coral::Update);
266  coral::ITypeConverter& lumitpc=destsession->typeConverter();
267  lumitpc.setCppTypeForSqlType("unsigned int","NUMBER(7)");
268  lumitpc.setCppTypeForSqlType("unsigned int","NUMBER(10)");
269  lumitpc.setCppTypeForSqlType("unsigned long long","NUMBER(20)");
270 
271  //for(hltIt=hltItBeg;hltIt!=hltItEnd;++hltIt){
272  // std::map<unsigned int,HLTV32DB::hltinfo>::iterator pathIt;
273  // std::map<unsigned int,HLTV32DB::hltinfo>::iterator pathItBeg=hltIt->begin();
274  // std::map<unsigned int,HLTV32DB::hltinfo>::iterator pathItEnd=hltIt->end();
275  // for(pathIt=pathItBeg;pathIt!=pathItEnd;++pathIt){
276  // std::cout<<"cmslsnr "<<pathIt->second.cmsluminr<<" "<<pathIt->second.pathname<<" "<<pathIt->second.hltinput<<" "<<pathIt->second.hltaccept<<" "<<pathIt->second.prescale<<std::endl;
277  // }
278  //}
279  unsigned int totalcmsls=hltresult.size();
280  std::cout<<"inserting totalhltls "<<totalcmsls<<" total path "<<npath<<std::endl;
281  //HltResult::iterator hltItBeg=hltresult.begin();
282  //HltResult::iterator hltItEnd=hltresult.end();
283  unsigned long long hltdataid=0;
284  try{
285  if(m_mode=="loadoldschema"){
286  std::cout<<"writing hlt data to old hlt table"<<std::endl;
287  writeHltData(destsession,runnumber,dbsource,npath,hltresult.begin(),hltresult.end(),COMMITINTERVAL);
288  std::cout<<"done"<<std::endl;
289  }
290  std::cout<<"writing hlt data to new lshlt table"<<std::endl;
291  //std::cout<<"npath "<<npath<<std::endl;
306  hltdataid=writeHltDataToSchema2(destsession,runnumber,dbsource,npath,hltresult.begin(),hltresult.end(), hltpathmap,COMMITLSINTERVAL);
307  std::cout<<"done"<<std::endl;
308  delete destsession;
309  delete svc;
310  }catch( const coral::Exception& er){
311  std::cout<<"database problem "<<er.what()<<std::endl;
312  destsession->transaction().rollback();
313  delete destsession;
314  delete svc;
315  throw er;
316  }
317  return hltdataid;
318  }
int i
Definition: DBlmapReader.cc:9
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:320
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
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)
Definition: HLTV32DB.cc:406
const std::string lumi::HLTV32DB::sourceType ( ) const
overridevirtual

Implements lumi::DataPipe.

Definition at line 536 of file HLTV32DB.cc.

536  {
537  return "DB";
538  }
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 320 of file HLTV32DB.cc.

References estimatePileup2::cmslsnum, gather_cfg::cout, SoftLeptonByDistance_cfi::distance, lumi::idDealer::generateNextIDForTable(), lumi::LumiNames::hltTableName(), i, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by retrieveData().

326  {
327  std::map< unsigned long long, std::vector<unsigned long long> > idallocationtable;
328  unsigned int hltlscount=0;
329  unsigned int totalcmsls=std::distance(hltItBeg,hltItEnd);
330  std::cout<<"\t allocating total ids "<<totalcmsls*npath<<std::endl;
331  lumisession->transaction().start(false);
332  lumi::idDealer idg(lumisession->nominalSchema());
333  unsigned long long hltID = idg.generateNextIDForTable(LumiNames::hltTableName(),totalcmsls*npath)-totalcmsls*npath;
334  for(HltResult::iterator hltIt=hltItBeg;hltIt!=hltItEnd;++hltIt,++hltlscount){
335  std::vector<unsigned long long> pathvec;
336  pathvec.reserve(npath);
337  for(unsigned int i=0;i<npath;++i,++hltID){
338  pathvec.push_back(hltID);
339  }
340  idallocationtable.insert(std::make_pair(hltlscount,pathvec));
341  }
342  std::cout<<"\t all ids allocated"<<std::endl;
343 
344  coral::AttributeList hltData;
345  hltData.extend("HLT_ID",typeid(unsigned long long));
346  hltData.extend("RUNNUM",typeid(unsigned int));
347  hltData.extend("CMSLSNUM",typeid(unsigned int));
348  hltData.extend("PATHNAME",typeid(std::string));
349  hltData.extend("INPUTCOUNT",typeid(unsigned int));
350  hltData.extend("ACCEPTCOUNT",typeid(unsigned int));
351  hltData.extend("PRESCALE",typeid(unsigned int));
352 
353  //loop over lumi LS
354  unsigned long long& hlt_id=hltData["HLT_ID"].data<unsigned long long>();
355  unsigned int& hltrunnum=hltData["RUNNUM"].data<unsigned int>();
356  unsigned int& cmslsnum=hltData["CMSLSNUM"].data<unsigned int>();
357  std::string& pathname=hltData["PATHNAME"].data<std::string>();
358  unsigned int& inputcount=hltData["INPUTCOUNT"].data<unsigned int>();
359  unsigned int& acceptcount=hltData["ACCEPTCOUNT"].data<unsigned int>();
360  unsigned int& prescale=hltData["PRESCALE"].data<unsigned int>();
361  hltlscount=0;
362  coral::IBulkOperation* hltInserter=0;
363  unsigned int comittedls=0;
364  for(HltResult::iterator hltIt=hltItBeg;hltIt!=hltItEnd;++hltIt,++hltlscount){
365  std::map<unsigned int,HLTV32DB::hltinfo>::const_iterator pathIt;
366  std::map<unsigned int,HLTV32DB::hltinfo>::const_iterator pathBeg=hltIt->begin();
367  std::map<unsigned int,HLTV32DB::hltinfo>::const_iterator pathEnd=hltIt->end();
368  if(!lumisession->transaction().isActive()){
369  lumisession->transaction().start(false);
370  coral::ITable& hlttable=lumisession->nominalSchema().tableHandle(LumiNames::hltTableName());
371  hltInserter=hlttable.dataEditor().bulkInsert(hltData,npath);
372  }else{
373  if(hltIt==hltItBeg){
374  coral::ITable& hlttable=lumisession->nominalSchema().tableHandle(LumiNames::hltTableName());
375  hltInserter=hlttable.dataEditor().bulkInsert(hltData,npath);
376  }
377  }
378  unsigned int hltpathcount=0;
379  for(pathIt=pathBeg;pathIt!=pathEnd;++pathIt,++hltpathcount){
380  hlt_id = idallocationtable[hltlscount].at(hltpathcount);
381  hltrunnum = irunnumber;
382  cmslsnum = pathIt->second.cmsluminr;
383  pathname = pathIt->second.pathname;
384  inputcount = pathIt->second.hltinput;
385  acceptcount = pathIt->second.hltaccept;
386  prescale = pathIt->second.prescale;
387  hltInserter->processNextIteration();
388  }
389  hltInserter->flush();
390  ++comittedls;
391  if(comittedls==commitintv){
392  std::cout<<"\t committing in LS chunck "<<comittedls<<std::endl;
393  delete hltInserter; hltInserter=0;
394  lumisession->transaction().commit();
395  comittedls=0;
396  std::cout<<"\t committed "<<std::endl;
397  }else if( hltlscount==(totalcmsls-1) ){
398  std::cout<<"\t committing at the end"<<std::endl;
399  delete hltInserter; hltInserter=0;
400  lumisession->transaction().commit();
401  std::cout<<"\t done"<<std::endl;
402  }
403  }
404  }
int i
Definition: DBlmapReader.cc:9
static const std::string hltTableName()
Definition: LumiNames.cc:38
unsigned long long generateNextIDForTable(const std::string &tableName, unsigned int interval=1)
Definition: idDealer.cc:31
unsigned long long 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 406 of file HLTV32DB.cc.

References lumi::RevisionDML::addEntry(), lumi::RevisionDML::addRevision(), lumi::RevisionDML::bookNewEntry(), lumi::RevisionDML::bookNewRevision(), lumiNorm::branch_id, estimatePileup2::cmslsnum, gather_cfg::cout, lumi::RevisionDML::Entry::data_id, revisionDML::data_id, SoftLeptonByDistance_cfi::distance, 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, lumi::RevisionDML::Entry::revision_id, lumi::RevisionDML::HltEntry::runnumber, source, lumi::RevisionDML::HltEntry::source, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by retrieveData().

413  {
414  HltResult::iterator hltIt;
415  unsigned int totalcmsls=std::distance(hltItBeg,hltItEnd);
416  std::cout<<"inserting totalcmsls "<<totalcmsls<<std::endl;
417  coral::AttributeList lshltData;
418  lshltData.extend("DATA_ID",typeid(unsigned long long));
419  lshltData.extend("RUNNUM",typeid(unsigned int));
420  lshltData.extend("CMSLSNUM",typeid(unsigned int));
421  lshltData.extend("PRESCALEBLOB",typeid(coral::Blob));
422  lshltData.extend("HLTCOUNTBLOB",typeid(coral::Blob));
423  lshltData.extend("HLTACCEPTBLOB",typeid(coral::Blob));
424  unsigned long long& data_id=lshltData["DATA_ID"].data<unsigned long long>();
425  unsigned int& hltrunnum=lshltData["RUNNUM"].data<unsigned int>();
426  unsigned int& cmslsnum=lshltData["CMSLSNUM"].data<unsigned int>();
427  coral::Blob& prescaleblob=lshltData["PRESCALEBLOB"].data<coral::Blob>();
428  coral::Blob& hltcountblob=lshltData["HLTCOUNTBLOB"].data<coral::Blob>();
429  coral::Blob& hltacceptblob=lshltData["HLTACCEPTBLOB"].data<coral::Blob>();
430 
431  unsigned long long branch_id=3;
432  std::string branch_name("DATA");
435  std::stringstream op;
436  op<<irunnumber;
437  std::string runnumberStr=op.str();
438  lumisession->transaction().start(false);
439  hltrundata.entry_name=runnumberStr;
440  hltrundata.source=source;
441  hltrundata.runnumber=irunnumber;
442  hltrundata.npath=npath;
444  HltPathMap::iterator hltpathmapIt;
445  HltPathMap::iterator hltpathmapItBeg=hltpathmap.begin();
446  HltPathMap::iterator hltpathmapItEnd=hltpathmap.end();
447  for(hltpathmapIt=hltpathmapItBeg;hltpathmapIt!=hltpathmapItEnd;++hltpathmapIt){
448  if(hltpathmapIt!=hltpathmapItBeg){
449  pathnames+=std::string(",");
450  }
451  pathnames+=hltpathmapIt->second;
452  }
453  std::cout<<"\tpathnames "<<pathnames<<std::endl;
454  hltrundata.pathnames=pathnames;
455  hltrundata.entry_id=revisionDML.getEntryInBranchByName(lumisession->nominalSchema(),lumi::LumiNames::hltdataTableName(),runnumberStr,branch_name);
456  if(hltrundata.entry_id==0){
457  revisionDML.bookNewEntry(lumisession->nominalSchema(),LumiNames::hltdataTableName(),hltrundata);
458  std::cout<<"hltrundata revision_id "<<hltrundata.revision_id<<" entry_id "<<hltrundata.entry_id<<" data_id "<<hltrundata.data_id<<std::endl;
459  revisionDML.addEntry(lumisession->nominalSchema(),LumiNames::hltdataTableName(),hltrundata,branch_id,branch_name);
460  }else{
461  revisionDML.bookNewRevision(lumisession->nominalSchema(),LumiNames::hltdataTableName(),hltrundata);
462  std::cout<<"hltrundata revision_id "<<hltrundata.revision_id<<" entry_id "<<hltrundata.entry_id<<" data_id "<<hltrundata.data_id<<std::endl;
463  revisionDML.addRevision(lumisession->nominalSchema(),LumiNames::hltdataTableName(),hltrundata,branch_id,branch_name);
464  }
465  std::cout<<"inserting hltrundata"<<std::endl;
466  revisionDML.insertHltRunData(lumisession->nominalSchema(),hltrundata);
467  std::cout<<"inserting lshlt data"<<std::endl;
468 
469  unsigned int hltlscount=0;
470  coral::IBulkOperation* hltInserter=0;
471  unsigned int comittedls=0;
472  for(HltResult::iterator hltIt=hltItBeg;hltIt!=hltItEnd;++hltIt,++hltlscount){
473  unsigned int cmslscount=hltlscount+1;
474  std::map<unsigned int,HLTV32DB::hltinfo,std::less<unsigned int> >::const_iterator pathIt;
475  std::map<unsigned int,HLTV32DB::hltinfo,std::less<unsigned int> >::const_iterator pathBeg=hltIt->begin();
476  std::map<unsigned int,HLTV32DB::hltinfo,std::less<unsigned int> >::const_iterator pathEnd=hltIt->end();
477  if(!lumisession->transaction().isActive()){
478  lumisession->transaction().start(false);
479  coral::ITable& hlttable=lumisession->nominalSchema().tableHandle(LumiNames::lshltTableName());
480  hltInserter=hlttable.dataEditor().bulkInsert(lshltData,npath);
481  }else{
482  if(hltIt==hltItBeg){
483  coral::ITable& hlttable=lumisession->nominalSchema().tableHandle(LumiNames::lshltTableName());
484  hltInserter=hlttable.dataEditor().bulkInsert(lshltData,npath);
485  }
486  }
487  data_id = hltrundata.data_id;
488  hltrunnum = irunnumber;
489  cmslsnum = cmslscount;
490  std::vector<unsigned int> prescales; prescales.reserve(npath);
491  std::vector<unsigned int> hltcounts; hltcounts.reserve(npath);
492  std::vector<unsigned int> hltaccepts; hltaccepts.reserve(npath);
493 
494  for(pathIt=pathBeg;pathIt!=pathEnd;++pathIt){
495  unsigned int hltcount=pathIt->second.hltinput;
496  //std::cout<<"hltcount "<<hltcount<<std::endl;
497  hltcounts.push_back(hltcount);
498  unsigned int hltaccept=pathIt->second.hltaccept;
499  //std::cout<<"hltaccept "<<hltaccept<<std::endl;
500  hltaccepts.push_back(hltaccept);
501  unsigned int prescale=pathIt->second.prescale;
502  //std::cout<<"prescale "<<prescale<<std::endl;
503  prescales.push_back(prescale);
504  }
505  prescaleblob.resize(sizeof(unsigned int)*npath);
506  void* prescaleblob_StartAddress = prescaleblob.startingAddress();
507  std::memmove(prescaleblob_StartAddress,&prescales[0],sizeof(unsigned int)*npath);
508  hltcountblob.resize(sizeof(unsigned int)*npath);
509  void* hltcountblob_StartAddress = hltcountblob.startingAddress();
510  std::memmove(hltcountblob_StartAddress,&hltcounts[0],sizeof(unsigned int)*npath);
511  hltacceptblob.resize(sizeof(unsigned int)*npath);
512  void* hltacceptblob_StartAddress = hltacceptblob.startingAddress();
513  std::memmove(hltacceptblob_StartAddress,&hltaccepts[0],sizeof(unsigned int)*npath);
514 
515  hltInserter->processNextIteration();
516  hltInserter->flush();
517  ++comittedls;
518  if(comittedls==commitintv){
519  std::cout<<"\t committing in LS chunck "<<comittedls<<std::endl;
520  delete hltInserter; hltInserter=0;
521  lumisession->transaction().commit();
522  comittedls=0;
523  std::cout<<"\t committed "<<std::endl;
524  }else if( hltlscount==(totalcmsls-1) ){
525  std::cout<<"\t committing at the end"<<std::endl;
526  delete hltInserter; hltInserter=0;
527  lumisession->transaction().commit();
528  std::cout<<"\t done"<<std::endl;
529  }
530  }
531  return hltrundata.data_id;
532  }
void addEntry(coral::ISchema &schema, const std::string &datatableName, const Entry &entry, unsigned long long branch_id, const std::string &branchname)
Definition: RevisionDML.cc:64
static const std::string lshltTableName()
Definition: LumiNames.cc:44
static const std::string hltdataTableName()
Definition: LumiNames.cc:41
hltrundata
Definition: dataDML.py:2372
unsigned long long data_id
Definition: RevisionDML.h:30
unsigned long long getEntryInBranchByName(coral::ISchema &schema, const std::string &datatableName, const std::string &entryname, const std::string &branchname)
Definition: RevisionDML.cc:17
unsigned long long revision_id
Definition: RevisionDML.h:28
unsigned long long entry_id
Definition: RevisionDML.h:29
void bookNewEntry(coral::ISchema &schema, const std::string &datatableName, Entry &entry)
Definition: RevisionDML.cc:46
void insertHltRunData(coral::ISchema &schema, const HltEntry &hltentry)
Definition: RevisionDML.cc:168
void addRevision(coral::ISchema &schema, const std::string &datatableName, const Entry &revision, unsigned long long branch_id, std::string &branchname)
Definition: RevisionDML.cc:102
static std::string const source
Definition: EdmProvDump.cc:43
void bookNewRevision(coral::ISchema &schema, const std::string &datatableName, Entry &revision)
Definition: RevisionDML.cc:56

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().