#include <RecoLuminosity/LumiProducer/src/LumiProducer.cc>
Classes | |
struct | HLTData |
struct | L1Data |
struct | PerLSData |
struct | PerRunData |
Public Member Functions | |
LumiProducer (const edm::ParameterSet &) | |
~LumiProducer () | |
Private Member Functions | |
virtual void | beginLuminosityBlock (edm::LuminosityBlock &iLBlock, edm::EventSetup const &iSetup) |
virtual void | beginRun (edm::Run &, edm::EventSetup const &) |
virtual void | endLuminosityBlock (edm::LuminosityBlock &lumiBlock, edm::EventSetup const &c) |
virtual void | endRun (edm::Run &, edm::EventSetup const &) |
void | fillLSCache (unsigned int luminum) |
bool | fillLumi (edm::LuminosityBlock &iLBlock) |
void | fillRunCache (const coral::ISchema &schema, unsigned int runnumber) |
unsigned long long | getHltDataId (const coral::ISchema &schema, unsigned int runnumber) |
unsigned long long | getLumiDataId (const coral::ISchema &schema, unsigned int runnumber) |
unsigned long long | getTrgDataId (const coral::ISchema &schema, unsigned int runnumber) |
virtual void | produce (edm::Event &, const edm::EventSetup &) |
XMLCh * | s2x (const std::string &input) const |
const std::string | servletTranslation (const std::string &servlet) const |
std::string | toParentString (const xercesc::DOMNode &nodeToConvert) const |
void | writeProductsForEntry (edm::LuminosityBlock &iLBlock, unsigned int runnumber, unsigned int luminum) |
std::string | x2s (const XMLCh *input) const |
Private Attributes | |
unsigned long long | m_cachedhltdataid |
unsigned long long | m_cachedlumidataid |
unsigned int | m_cachedrun |
unsigned long long | m_cachedtrgdataid |
unsigned int | m_cachesize |
std::string | m_connectStr |
bool | m_isNullRun |
std::map< unsigned int, PerLSData > | m_lscache |
std::string | m_lumiversion |
PerRunData | m_runcache |
std::string | m_siteconfpath |
Description: This class would load the luminosity object into a Luminosity Block
Implementation: The are two main steps, the first one retrieve the record of the luminosity data from the DB and the second loads the Luminosity Obj into the Lumi Block. (Actually in the initial implementation it is retrieving from the ParameterSet from the configuration file, the DB is not implemented yet)
Definition at line 80 of file LumiProducer.cc.
LumiProducer::LumiProducer | ( | const edm::ParameterSet & | ) | [explicit] |
LumiProducer::~LumiProducer | ( | ) |
Definition at line 290 of file LumiProducer.cc.
{ }
void LumiProducer::beginLuminosityBlock | ( | edm::LuminosityBlock & | iLBlock, |
edm::EventSetup const & | iSetup | ||
) | [private, virtual] |
Reimplemented from edm::EDProducer.
Definition at line 411 of file LumiProducer.cc.
References fillLSCache(), edm::LuminosityBlockBase::luminosityBlock(), m_isNullRun, m_lscache, edm::LuminosityBlock::put(), edm::LuminosityBlockBase::run(), cond::runnumber, and writeProductsForEntry().
{ unsigned int runnumber=iLBlock.run(); unsigned int luminum=iLBlock.luminosityBlock(); //std::cout<<"beg of beginLuminosityBlock "<<luminum<<std::endl; //if is null run, fill empty values and return if(m_isNullRun){ std::auto_ptr<LumiSummary> pOut1; std::auto_ptr<LumiDetails> pOut2; LumiSummary* pIn1=new LumiSummary; LumiDetails* pIn2=new LumiDetails; pOut1.reset(pIn1); iLBlock.put(pOut1); pOut2.reset(pIn2); iLBlock.put(pOut2); return; } if(m_lscache.find(luminum)==m_lscache.end()){ //if runnumber is cached but LS is not, this is the first LS, fill LS cache to full capacity fillLSCache(luminum); } //here the presence of ls is guaranteed writeProductsForEntry(iLBlock,runnumber,luminum); }
void LumiProducer::beginRun | ( | edm::Run & | run, |
edm::EventSetup const & | iSetup | ||
) | [private, virtual] |
Reimplemented from edm::EDProducer.
Definition at line 379 of file LumiProducer.cc.
References Exception, fillRunCache(), getHltDataId(), getLumiDataId(), getTrgDataId(), edm::Service< T >::isAvailable(), m_cachedhltdataid, m_cachedlumidataid, m_cachedrun, m_cachedtrgdataid, m_connectStr, m_isNullRun, edm::RunBase::run(), cond::runnumber, and python::CommonUtils::session.
{ unsigned int runnumber=run.run(); if(m_cachedrun!=runnumber){ //queries once per run m_cachedrun=runnumber; edm::Service<lumi::service::DBService> mydbservice; if( !mydbservice.isAvailable() ){ throw cms::Exception("Non existing service lumi::service::DBService"); } coral::ISessionProxy* session=mydbservice->connectReadOnly(m_connectStr); try{ session->transaction().start(true); m_cachedlumidataid=getLumiDataId(session->nominalSchema(),runnumber); if(m_cachedlumidataid!=0){//if no lumi, do not bother other info m_cachedtrgdataid=getTrgDataId(session->nominalSchema(),runnumber); m_cachedhltdataid=getHltDataId(session->nominalSchema(),runnumber); fillRunCache(session->nominalSchema(),runnumber); }else{ m_isNullRun=true; } session->transaction().commit(); }catch(const coral::Exception& er){ session->transaction().rollback(); mydbservice->disconnect(session); throw cms::Exception("DatabaseError ")<<er.what(); } mydbservice->disconnect(session); } //std::cout<<"end of beginRun "<<runnumber<<std::endl; }
void LumiProducer::endLuminosityBlock | ( | edm::LuminosityBlock & | lumiBlock, |
edm::EventSetup const & | c | ||
) | [private, virtual] |
void LumiProducer::endRun | ( | edm::Run & | run, |
edm::EventSetup const & | iSetup | ||
) | [private, virtual] |
Reimplemented from edm::EDProducer.
Definition at line 440 of file LumiProducer.cc.
References LumiProducer::PerRunData::HLTPathNames, LumiProducer::PerRunData::HLTPathNameToIndex, m_runcache, edm::Run::put(), LumiProducer::PerRunData::TRGBitNames, and LumiProducer::PerRunData::TRGBitNameToIndex.
{ std::auto_ptr<LumiSummaryRunHeader> lsrh(new LumiSummaryRunHeader()); lsrh->swapL1Names(m_runcache.TRGBitNames); lsrh->swapHLTNames(m_runcache.HLTPathNames); run.put(lsrh); m_runcache.TRGBitNameToIndex.clear(); m_runcache.HLTPathNameToIndex.clear(); }
void LumiProducer::fillLSCache | ( | unsigned int | luminum | ) | [private] |
Definition at line 513 of file LumiProducer.cc.
References LumiProducer::HLTData::acceptcount, LumiProducer::PerLSData::beam1intensity, LumiProducer::PerLSData::beam2intensity, LumiProducer::L1Data::bitname, LumiProducer::PerLSData::bunchlumierror, LumiProducer::PerLSData::bunchlumiquality, LumiProducer::PerLSData::bunchlumivalue, estimatePileup2::cmslsnum, Exception, LumiProducer::PerLSData::hltdata, LumiProducer::PerRunData::HLTPathNames, i, UserOptions_cff::idx, edm::Service< T >::isAvailable(), prof2calltree::l, LumiProducer::PerLSData::l1data, LumiProducer::HLTData::l1passcount, lumi::LumiNames::lshltTableName(), lumi::LumiNames::lstrgTableName(), lumi::LumiNames::lumisummaryv2TableName(), m_cachedhltdataid, m_cachedlumidataid, m_cachedtrgdataid, m_cachesize, m_connectStr, m_isNullRun, m_lscache, m_runcache, n, LumiProducer::HLTData::pathname, LumiProducer::L1Data::prescale, LumiProducer::HLTData::prescale, makeHLTPrescaleTable::prescales, LumiProducer::L1Data::ratecount, python::IdGenerator::schema, python::CommonUtils::session, and LumiProducer::PerRunData::TRGBitNames.
Referenced by beginLuminosityBlock().
{ //initialize cache if(m_isNullRun) return; m_lscache.clear(); for(unsigned int n=luminum;n<luminum+m_cachesize;++n){ PerLSData l; l.hltdata.reserve(250); l.l1data.reserve(192); l.bunchlumivalue.reserve(5); l.bunchlumierror.reserve(5); l.bunchlumiquality.reserve(5); l.beam1intensity.resize(3564,0.0); l.beam2intensity.resize(3564,0.0); m_lscache.insert(std::make_pair(n,l)); } //queries once per cache refill // //select cmslsnum,instlumi,startorbit,numorbit,bxindex,beam1intensity,beam2intensity,bxlumivalue_occ1,bxlumivalue_occ2,bxlumivalue_et from lumisummaryv2 where cmslsnum>=:lsmin and cmslsnum<:lsmax and data_id=:lumidataid; // edm::Service<lumi::service::DBService> mydbservice; if( !mydbservice.isAvailable() ){ throw cms::Exception("Non existing service lumi::service::DBService"); } coral::ISessionProxy* session=mydbservice->connectReadOnly(m_connectStr); try{ session->transaction().start(true); coral::ISchema& schema=session->nominalSchema(); coral::AttributeList lumisummaryBindVariables; lumisummaryBindVariables.extend("lsmin",typeid(unsigned int)); lumisummaryBindVariables.extend("lsmax",typeid(unsigned int)); lumisummaryBindVariables.extend("lumidataid",typeid(unsigned long long)); lumisummaryBindVariables["lumidataid"].data<unsigned long long>()=m_cachedlumidataid; lumisummaryBindVariables["lsmin"].data<unsigned int>()=luminum; lumisummaryBindVariables["lsmax"].data<unsigned int>()=luminum+m_cachesize; coral::AttributeList lumisummaryOutput; lumisummaryOutput.extend("CMSLSNUM",typeid(unsigned int)); lumisummaryOutput.extend("INSTLUMI",typeid(float)); lumisummaryOutput.extend("STARTORBIT",typeid(unsigned int)); lumisummaryOutput.extend("NUMORBIT",typeid(unsigned int)); lumisummaryOutput.extend("CMSBXINDEXBLOB",typeid(coral::Blob)); lumisummaryOutput.extend("BEAMINTENSITYBLOB_1",typeid(coral::Blob)); lumisummaryOutput.extend("BEAMINTENSITYBLOB_2",typeid(coral::Blob)); lumisummaryOutput.extend("BXLUMIVALUE_OCC1",typeid(coral::Blob)); lumisummaryOutput.extend("BXLUMIVALUE_OCC2",typeid(coral::Blob)); lumisummaryOutput.extend("BXLUMIVALUE_ET",typeid(coral::Blob)); coral::IQuery* lumisummaryQuery=schema.newQuery(); lumisummaryQuery->addToTableList(lumi::LumiNames::lumisummaryv2TableName()); lumisummaryQuery->addToOutputList("CMSLSNUM"); lumisummaryQuery->addToOutputList("INSTLUMI"); lumisummaryQuery->addToOutputList("STARTORBIT"); lumisummaryQuery->addToOutputList("NUMORBIT"); lumisummaryQuery->addToOutputList("CMSBXINDEXBLOB"); lumisummaryQuery->addToOutputList("BEAMINTENSITYBLOB_1"); lumisummaryQuery->addToOutputList("BEAMINTENSITYBLOB_2"); lumisummaryQuery->addToOutputList("BXLUMIVALUE_OCC1"); lumisummaryQuery->addToOutputList("BXLUMIVALUE_OCC2"); lumisummaryQuery->addToOutputList("BXLUMIVALUE_ET"); lumisummaryQuery->setCondition("CMSLSNUM>=:lsmin AND CMSLSNUM<:lsmax AND DATA_ID=:lumidataid",lumisummaryBindVariables); lumisummaryQuery->defineOutput(lumisummaryOutput); coral::ICursor& lumisummarycursor=lumisummaryQuery->execute(); unsigned int rowcounter=0; while( lumisummarycursor.next() ){ const coral::AttributeList& row=lumisummarycursor.currentRow(); unsigned int cmslsnum=row["CMSLSNUM"].data<unsigned int>(); //std::cout<<"cmslsnum "<<cmslsnum<<std::endl; PerLSData& lsdata=m_lscache[cmslsnum]; lsdata.lumivalue=row["INSTLUMI"].data<float>(); lsdata.lumierror=0.0; lsdata.lumiquality=0; lsdata.startorbit=row["STARTORBIT"].data<unsigned int>(); lsdata.numorbit=row["NUMORBIT"].data<unsigned int>(); if(!row["CMSBXINDEXBLOB"].isNull() && !row["BXLUMIVALUE_OCC1"].isNull() ){ const coral::Blob& bxindexBlob=row["CMSBXINDEXBLOB"].data<coral::Blob>(); const void* bxindex_StartAddress=bxindexBlob.startingAddress(); short* bxindex=(short*)::malloc(bxindexBlob.size()); const coral::Blob& beam1intensityBlob=row["BEAMINTENSITYBLOB_1"].data<coral::Blob>(); const void* beam1intensityBlob_StartAddress=beam1intensityBlob.startingAddress(); float* beam1intensity=(float*)::malloc(beam1intensityBlob.size()); const coral::Blob& beam2intensityBlob=row["BEAMINTENSITYBLOB_2"].data<coral::Blob>(); const void* beam2intensityBlob_StartAddress=beam2intensityBlob.startingAddress(); float* beam2intensity=(float*)::malloc(beam2intensityBlob.size()); std::memmove(bxindex,bxindex_StartAddress,bxindexBlob.size()); std::memmove(beam1intensity,beam1intensityBlob_StartAddress,beam1intensityBlob.size()); std::memmove(beam2intensity,beam2intensityBlob_StartAddress,beam2intensityBlob.size()); for(unsigned int i=0;i<bxindexBlob.size()/sizeof(short);++i){ unsigned int idx=bxindex[i]; lsdata.beam1intensity.at(idx)=beam1intensity[i]; lsdata.beam2intensity.at(idx)=beam2intensity[i]; } ::free(bxindex); ::free(beam1intensity); ::free(beam2intensity); const coral::Blob& bxlumivalBlob_occ1=row["BXLUMIVALUE_OCC1"].data<coral::Blob>(); const void* bxlumival_occ1_StartAddress=bxlumivalBlob_occ1.startingAddress(); float* bxlumival_occ1=(float*)::malloc(bxlumivalBlob_occ1.size()); std::memmove(bxlumival_occ1,bxlumival_occ1_StartAddress,bxlumivalBlob_occ1.size()); std::vector<float> bxlumivalVec_occ1(bxlumival_occ1,bxlumival_occ1+bxlumivalBlob_occ1.size()/sizeof(float)); ::free(bxlumival_occ1); lsdata.bunchlumivalue.push_back(std::make_pair(std::string("OCC1"),bxlumivalVec_occ1)); lsdata.bunchlumierror.push_back(std::make_pair(std::string("OCC1"),std::vector<float>(3564))); lsdata.bunchlumiquality.push_back(std::make_pair(std::string("OCC1"),std::vector<short>(3564))); const coral::Blob& bxlumivalBlob_occ2=row["BXLUMIVALUE_OCC2"].data<coral::Blob>(); const void* bxlumival_occ2_StartAddress=bxlumivalBlob_occ2.startingAddress(); float* bxlumival_occ2=(float*)::malloc(bxlumivalBlob_occ2.size()); std::memmove(bxlumival_occ2,bxlumival_occ2_StartAddress,bxlumivalBlob_occ2.size()); std::vector<float> bxlumivalVec_occ2(bxlumival_occ2,bxlumival_occ2+bxlumivalBlob_occ1.size()/sizeof(float)); ::free(bxlumival_occ2); lsdata.bunchlumivalue.push_back(std::make_pair(std::string("OCC2"),bxlumivalVec_occ2)); lsdata.bunchlumierror.push_back(std::make_pair(std::string("OCC2"),std::vector<float>(3564))); lsdata.bunchlumiquality.push_back(std::make_pair(std::string("OCC2"),std::vector<short>(3564))); const coral::Blob& bxlumivalBlob_et=row["BXLUMIVALUE_ET"].data<coral::Blob>(); const void* bxlumival_et_StartAddress=bxlumivalBlob_et.startingAddress(); float* bxlumival_et=(float*)::malloc(bxlumivalBlob_et.size()); std::memmove(bxlumival_et,bxlumival_et_StartAddress,bxlumivalBlob_et.size()); std::vector<float> bxlumivalVec_et(bxlumival_et,bxlumival_et+bxlumivalBlob_et.size()/sizeof(float)); ::free(bxlumival_et); lsdata.bunchlumivalue.push_back(std::make_pair(std::string("ET"),bxlumivalVec_et)); lsdata.bunchlumierror.push_back(std::make_pair(std::string("ET"),std::vector<float>(3564))); lsdata.bunchlumiquality.push_back(std::make_pair(std::string("ET"),std::vector<short>(3564))); } ++rowcounter; } if (rowcounter==0){ m_isNullRun=true; return; } delete lumisummaryQuery; // //select cmslsnum,deadtimecount,bitzerocount,bitzeroprescale,prescaleblob,trgcountblob from lstrg where cmslsnum >=:luminum and cmslsnum<:luminum+cachesize AND data_id=:trgdataid; // coral::AttributeList trgBindVariables; trgBindVariables.extend("lsmin",typeid(unsigned int)); trgBindVariables.extend("lsmax",typeid(unsigned int)); trgBindVariables.extend("trgdataid",typeid(unsigned long long)); trgBindVariables["lsmin"].data<unsigned int>()=luminum; trgBindVariables["lsmax"].data<unsigned int>()=luminum+m_cachesize; trgBindVariables["trgdataid"].data<unsigned long long>()=m_cachedtrgdataid; coral::AttributeList trgOutput; trgOutput.extend("CMSLSNUM",typeid(unsigned int)); trgOutput.extend("DEADTIMECOUNT",typeid(unsigned long long)); trgOutput.extend("BITZEROCOUNT",typeid(unsigned int)); trgOutput.extend("BITZEROPRESCALE",typeid(unsigned int)); trgOutput.extend("PRESCALEBLOB",typeid(coral::Blob)); trgOutput.extend("TRGCOUNTBLOB",typeid(coral::Blob)); coral::IQuery* trgQuery=schema.newQuery(); trgQuery->addToTableList(lumi::LumiNames::lstrgTableName()); trgQuery->addToOutputList("CMSLSNUM"); trgQuery->addToOutputList("DEADTIMECOUNT"); trgQuery->addToOutputList("BITZEROCOUNT"); trgQuery->addToOutputList("BITZEROPRESCALE"); trgQuery->addToOutputList("PRESCALEBLOB"); trgQuery->addToOutputList("TRGCOUNTBLOB"); trgQuery->setCondition("CMSLSNUM>=:lsmin AND CMSLSNUM<:lsmax AND DATA_ID=:trgdataid",trgBindVariables); trgQuery->defineOutput(trgOutput); coral::ICursor& trgcursor=trgQuery->execute(); while( trgcursor.next() ){ const coral::AttributeList& row=trgcursor.currentRow(); unsigned int cmslsnum=row["CMSLSNUM"].data<unsigned int>(); PerLSData& lsdata=m_lscache[cmslsnum]; lsdata.deadcount=row["DEADTIMECOUNT"].data<unsigned long long>(); lsdata.bitzerocount=row["BITZEROCOUNT"].data<unsigned int>(); lsdata.bitzeroprescale=row["BITZEROPRESCALE"].data<unsigned int>(); if(!row["PRESCALEBLOB"].isNull()){ const coral::Blob& prescaleblob=row["PRESCALEBLOB"].data<coral::Blob>(); const void* prescaleblob_StartAddress=prescaleblob.startingAddress(); unsigned int* prescales=(unsigned int*)::malloc(prescaleblob.size()); std::memmove(prescales,prescaleblob_StartAddress,prescaleblob.size()); const coral::Blob& trgcountblob=row["TRGCOUNTBLOB"].data<coral::Blob>(); const void* trgcountblob_StartAddress=trgcountblob.startingAddress(); unsigned int* trgcounts=(unsigned int*)::malloc(trgcountblob.size()); std::memmove(trgcounts,trgcountblob_StartAddress,trgcountblob.size()); for(unsigned int i=0;i<sizeof(trgcounts)/sizeof(unsigned int);++i){ L1Data l1tmp; l1tmp.bitname=m_runcache.TRGBitNames[i]; l1tmp.prescale=prescales[i]; l1tmp.ratecount=trgcounts[i]; lsdata.l1data.push_back(l1tmp); } ::free(prescales); ::free(trgcounts); } } delete trgQuery; // //select cmslsnum,hltcountblob,hltacceptblob,prescaleblob from hlt where cmslsnum >=:luminum and cmslsnum<=:luminum+cachesize and data_id=:hltdataid // coral::AttributeList hltBindVariables; hltBindVariables.extend("lsmin",typeid(unsigned int)); hltBindVariables.extend("lsmax",typeid(unsigned int)); hltBindVariables.extend("hltdataid",typeid(unsigned long long)); hltBindVariables["lsmin"].data<unsigned int>()=luminum; hltBindVariables["lsmax"].data<unsigned int>()=luminum+m_cachesize; hltBindVariables["hltdataid"].data<unsigned long long>()=m_cachedhltdataid; coral::AttributeList hltOutput; hltOutput.extend("CMSLSNUM",typeid(unsigned int)); hltOutput.extend("HLTCOUNTBLOB",typeid(coral::Blob)); hltOutput.extend("HLTACCEPTBLOB",typeid(coral::Blob)); hltOutput.extend("PRESCALEBLOB",typeid(coral::Blob)); coral::IQuery* hltQuery=schema.newQuery(); hltQuery->addToTableList(lumi::LumiNames::lshltTableName()); hltQuery->addToOutputList("CMSLSNUM"); hltQuery->addToOutputList("HLTCOUNTBLOB"); hltQuery->addToOutputList("HLTACCEPTBLOB"); hltQuery->addToOutputList("PRESCALEBLOB"); hltQuery->setCondition("CMSLSNUM>=:lsmin AND CMSLSNUM<:lsmax AND DATA_ID=:hltdataid",hltBindVariables); hltQuery->defineOutput(hltOutput); coral::ICursor& hltcursor=hltQuery->execute(); while( hltcursor.next() ){ const coral::AttributeList& row=hltcursor.currentRow(); unsigned int cmslsnum=row["CMSLSNUM"].data<unsigned int>(); PerLSData& lsdata=m_lscache[cmslsnum]; if(!row["PRESCALEBLOB"].isNull()){ const coral::Blob& hltprescaleblob=row["PRESCALEBLOB"].data<coral::Blob>(); const void* hltprescaleblob_StartAddress=hltprescaleblob.startingAddress(); unsigned int* hltprescales=(unsigned int*)::malloc(hltprescaleblob.size()); std::memmove(hltprescales,hltprescaleblob_StartAddress,hltprescaleblob.size()); const coral::Blob& hltcountblob=row["HLTCOUNTBLOB"].data<coral::Blob>(); const void* hltcountblob_StartAddress=hltcountblob.startingAddress(); unsigned int* hltcounts=(unsigned int*)::malloc(hltcountblob.size()); std::memmove(hltcounts,hltcountblob_StartAddress,hltcountblob.size()); const coral::Blob& hltacceptblob=row["HLTACCEPTBLOB"].data<coral::Blob>(); const void* hltacceptblob_StartAddress=hltacceptblob.startingAddress(); unsigned int* hltaccepts=(unsigned int*)::malloc(hltacceptblob.size()); std::memmove(hltaccepts,hltacceptblob_StartAddress,hltacceptblob.size()); for(unsigned int i=0;i<sizeof(hltaccepts)/sizeof(unsigned int);++i){ HLTData hlttmp; hlttmp.pathname=m_runcache.HLTPathNames[i]; hlttmp.prescale=hltprescales[i]; hlttmp.l1passcount=hltcounts[i]; hlttmp.acceptcount=hltaccepts[i]; lsdata.hltdata.push_back(hlttmp); } ::free(hltprescales); ::free(hltcounts); ::free(hltaccepts); } } delete hltQuery; session->transaction().commit(); }catch(const coral::Exception& er){ session->transaction().rollback(); mydbservice->disconnect(session); throw cms::Exception("DatabaseError ")<<er.what(); } mydbservice->disconnect(session); }
bool LumiProducer::fillLumi | ( | edm::LuminosityBlock & | iLBlock | ) | [private] |
void LumiProducer::fillRunCache | ( | const coral::ISchema & | schema, |
unsigned int | runnumber | ||
) | [private] |
Definition at line 450 of file LumiProducer.cc.
References LumiProducer::PerRunData::bitzeroname, lumi::LumiNames::hltdataTableName(), LumiProducer::PerRunData::HLTPathNames, LumiProducer::PerRunData::HLTPathNameToIndex, i, m_cachedhltdataid, m_cachedtrgdataid, m_runcache, lumiPlot::pathnames, LumiProducer::PerRunData::TRGBitNames, LumiProducer::PerRunData::TRGBitNameToIndex, and lumi::LumiNames::trgdataTableName().
Referenced by beginRun().
{ if(m_cachedtrgdataid!=0){ coral::AttributeList trgBindVariables; trgBindVariables.extend("trgdataid",typeid(unsigned long long)); trgBindVariables["trgdataid"].data<unsigned long long>()=m_cachedtrgdataid; //std::cout<<"cached trgdataid "<<m_cachedtrgdataid<<std::endl; coral::AttributeList trgOutput; trgOutput.extend("bitzeroname",typeid(std::string)); trgOutput.extend("bitnameclob",typeid(std::string)); coral::IQuery* trgQuery=schema.newQuery(); trgQuery->addToTableList(lumi::LumiNames::trgdataTableName()); trgQuery->addToOutputList("BITZERONAME"); trgQuery->addToOutputList("BITNAMECLOB"); trgQuery->setCondition("DATA_ID=:trgdataid",trgBindVariables); trgQuery->defineOutput(trgOutput); coral::ICursor& trgcursor=trgQuery->execute(); while( trgcursor.next() ){ const coral::AttributeList& row=trgcursor.currentRow(); m_runcache.bitzeroname=row["bitzeroname"].data<std::string>(); //std::cout<<"bitzeroname "<<m_runcache.bitzeroname<<std::endl; std::string bitnames=row["bitnameclob"].data<std::string>(); boost::char_separator<char> sep(","); boost::tokenizer<boost::char_separator<char> > tokens(bitnames,sep); for(boost::tokenizer<boost::char_separator<char> >::iterator tok_it=tokens.begin();tok_it!=tokens.end();++tok_it){ m_runcache.TRGBitNames.push_back(*tok_it); } for(unsigned int i=0;i<m_runcache.TRGBitNames.size();++i){ m_runcache.TRGBitNameToIndex.insert(std::make_pair(m_runcache.TRGBitNames.at(i),i) ); } } delete trgQuery; } if(m_cachedhltdataid!=0){ // //select pathnameclob from hltdata where data_id=:hltdataid // coral::AttributeList hltBindVariables; hltBindVariables.extend("hltdataid",typeid(unsigned long long)); hltBindVariables["hltdataid"].data<unsigned long long>()=m_cachedhltdataid; coral::AttributeList hltOutput; hltOutput.extend("PATHNAMECLOB",typeid(std::string)); coral::IQuery* hltQuery=schema.newQuery(); hltQuery->addToTableList(lumi::LumiNames::hltdataTableName()); hltQuery->addToOutputList("PATHNAMECLOB"); hltQuery->setCondition("DATA_ID=:hltdataid",hltBindVariables); hltQuery->defineOutput(hltOutput); coral::ICursor& hltcursor=hltQuery->execute(); while( hltcursor.next() ){ const coral::AttributeList& row=hltcursor.currentRow(); std::string pathnames=row["PATHNAMECLOB"].data<std::string>(); boost::char_separator<char> sep(","); boost::tokenizer<boost::char_separator<char> > tokens(pathnames,sep); for(boost::tokenizer<boost::char_separator<char> >::iterator tok_it=tokens.begin();tok_it!=tokens.end();++tok_it){ m_runcache.HLTPathNames.push_back(*tok_it); } for(unsigned int i=0;i<m_runcache.HLTPathNames.size();++i){ m_runcache.HLTPathNameToIndex.insert(std::make_pair(m_runcache.HLTPathNames.at(i),i)); } } delete hltQuery; } }
unsigned long long LumiProducer::getHltDataId | ( | const coral::ISchema & | schema, |
unsigned int | runnumber | ||
) | [private] |
Definition at line 353 of file LumiProducer.cc.
References lumi::LumiNames::hltdataTableName().
Referenced by beginRun().
{ // //select max(data_id) from hltdata where runnum=:runnum // unsigned long long hltdataid=0; coral::AttributeList bindVariables; bindVariables.extend("runnum",typeid(unsigned int)); bindVariables["runnum"].data<unsigned int>()=runnumber; coral::AttributeList hltidOutput; hltidOutput.extend("hltdataid",typeid(unsigned long long)); coral::IQuery* hltQuery=schema.newQuery(); hltQuery->addToTableList(lumi::LumiNames::hltdataTableName()); hltQuery->addToOutputList("MAX(DATA_ID)","hltdataid"); hltQuery->setCondition("RUNNUM=:runnum",bindVariables); hltQuery->defineOutput(hltidOutput); coral::ICursor& hltcursor=hltQuery->execute(); while( hltcursor.next() ){ const coral::AttributeList& row=hltcursor.currentRow(); if(!row["hltdataid"].isNull()){ hltdataid=row["hltdataid"].data<unsigned long long>(); } } delete hltQuery; return hltdataid; }
unsigned long long LumiProducer::getLumiDataId | ( | const coral::ISchema & | schema, |
unsigned int | runnumber | ||
) | [private] |
Definition at line 300 of file LumiProducer.cc.
References lumi::LumiNames::lumidataTableName().
Referenced by beginRun().
{ // //select max(data_id) from lumidata where runnum=:runnum // //std::count<<"entering getLumiDataId "<<std::endl; unsigned long long lumidataid=0; coral::AttributeList bindVariables; bindVariables.extend("runnum",typeid(unsigned int)); bindVariables["runnum"].data<unsigned int>()=runnumber; coral::AttributeList lumiidOutput; lumiidOutput.extend("lumidataid",typeid(unsigned long long)); coral::IQuery* lumiQuery=schema.newQuery(); lumiQuery->addToTableList(lumi::LumiNames::lumidataTableName()); lumiQuery->addToOutputList("MAX(DATA_ID)","lumidataid"); lumiQuery->setCondition("RUNNUM=:runnum",bindVariables); lumiQuery->defineOutput(lumiidOutput); coral::ICursor& lumicursor=lumiQuery->execute(); while( lumicursor.next() ){ const coral::AttributeList& row=lumicursor.currentRow(); if(!row["lumidataid"].isNull()){ lumidataid=row["lumidataid"].data<unsigned long long>(); } } delete lumiQuery; return lumidataid; }
unsigned long long LumiProducer::getTrgDataId | ( | const coral::ISchema & | schema, |
unsigned int | runnumber | ||
) | [private] |
Definition at line 327 of file LumiProducer.cc.
References lumi::LumiNames::trgdataTableName().
Referenced by beginRun().
{ // //select max(data_id) from trgdata where runnum=:runnum // unsigned long long trgdataid=0; coral::AttributeList bindVariables; bindVariables.extend("runnum",typeid(unsigned int)); bindVariables["runnum"].data<unsigned int>()=runnumber; coral::AttributeList trgidOutput; trgidOutput.extend("trgdataid",typeid(unsigned long long)); coral::IQuery* trgQuery=schema.newQuery(); trgQuery->addToTableList(lumi::LumiNames::trgdataTableName()); trgQuery->addToOutputList("MAX(DATA_ID)","trgdataid"); trgQuery->setCondition("RUNNUM=:runnum",bindVariables); trgQuery->defineOutput(trgidOutput); coral::ICursor& trgcursor=trgQuery->execute(); while( trgcursor.next() ){ const coral::AttributeList& row=trgcursor.currentRow(); if(!row["trgdataid"].isNull()){ trgdataid=row["trgdataid"].data<unsigned long long>(); } } delete trgQuery; return trgdataid; }
void LumiProducer::produce | ( | edm::Event & | e, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
XMLCh * LumiProducer::s2x | ( | const std::string & | input | ) | const [private] |
Definition at line 173 of file LumiProducer.cc.
Referenced by servletTranslation().
{ XMLCh* buff = xercesc::XMLString::transcode(temp.c_str()); return buff; }
const std::string LumiProducer::servletTranslation | ( | const std::string & | servlet | ) | const [private] |
Definition at line 206 of file LumiProducer.cc.
References asciidump::doc, alignCSCRings::e, m_siteconfpath, geometryXMLtoCSV::parser, s2x(), and toParentString().
{ std::string frontierConnect; std::string realconnect; xercesc::XMLPlatformUtils::Initialize(); std::auto_ptr< xercesc::XercesDOMParser > parser(new xercesc::XercesDOMParser); try{ parser->setValidationScheme(xercesc::XercesDOMParser::Val_Auto); parser->setDoNamespaces(false); parser->parse(m_siteconfpath.c_str()); xercesc::DOMDocument* doc=parser->getDocument(); if(!doc){ return ""; } xercesc::DOMNodeList *frontierConnectList=doc->getElementsByTagName(s2x("frontier-connect")); if (frontierConnectList->getLength()>0){ xercesc::DOMElement *frontierConnectElement=static_cast < xercesc::DOMElement *> (frontierConnectList->item (0)); frontierConnect = toParentString(*frontierConnectElement); } // Replace the last component of every "serverurl=" piece (up to the // next close-paren) with the servlet std::string::size_type nextparen = 0; std::string::size_type serverurl, lastslash; std::string complexstr = ""; while ((serverurl=frontierConnect.find("(serverurl=", nextparen)) != std::string::npos){ realconnect.append(frontierConnect, nextparen, serverurl - nextparen); nextparen=frontierConnect.find(')', serverurl); lastslash=frontierConnect.rfind('/', nextparen); realconnect.append(frontierConnect,serverurl,lastslash-serverurl+1); realconnect.append(servlet); } realconnect.append(frontierConnect, nextparen,frontierConnect.length()-nextparen); }catch(xercesc::DOMException &e){ } return realconnect; }
std::string LumiProducer::toParentString | ( | const xercesc::DOMNode & | nodeToConvert | ) | const [private] |
Definition at line 179 of file LumiProducer.cc.
References asciidump::attributes, i, j, and x2s().
Referenced by servletTranslation().
{ std::ostringstream oss; xercesc::DOMNodeList *childList = nodeToConvert.getChildNodes(); unsigned int numNodes = childList->getLength (); for (unsigned int i = 0; i < numNodes; ++i){ xercesc::DOMNode *childNode = childList->item(i); if (childNode->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue; xercesc::DOMElement *child = static_cast < xercesc::DOMElement *> (childNode); xercesc::DOMNamedNodeMap *attributes = child->getAttributes(); unsigned int numAttributes = attributes->getLength (); for (unsigned int j = 0; j < numAttributes; ++j){ xercesc::DOMNode *attributeNode = attributes->item(j); if (attributeNode->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue; xercesc::DOMAttr *attribute = static_cast <xercesc::DOMAttr *> (attributeNode); oss << "(" << x2s(child->getTagName()) << x2s(attribute->getName()) << "=" << x2s(attribute->getValue()) << ")"; } } return oss.str(); }
void LumiProducer::writeProductsForEntry | ( | edm::LuminosityBlock & | iLBlock, |
unsigned int | runnumber, | ||
unsigned int | luminum | ||
) | [private] |
Definition at line 765 of file LumiProducer.cc.
References LumiProducer::PerLSData::beam1intensity, LumiProducer::PerLSData::beam2intensity, LumiProducer::PerLSData::bitzerocount, LumiProducer::PerLSData::bitzeroprescale, LumiProducer::PerLSData::bunchlumierror, LumiProducer::PerLSData::bunchlumiquality, LumiProducer::PerLSData::bunchlumivalue, LumiProducer::PerLSData::deadcount, LumiDetails::fill(), LumiDetails::fillBeamIntensities(), LumiProducer::PerLSData::hltdata, LumiProducer::PerRunData::HLTPathNameToIndex, i, LumiDetails::kET, LumiDetails::kOCC1, LumiDetails::kOCC2, LumiDetails::kPLT, LumiProducer::PerLSData::l1data, LumiProducer::PerLSData::lumierror, LumiProducer::PerLSData::lumiquality, LumiProducer::PerLSData::lumivalue, m_isNullRun, m_lscache, m_runcache, LumiProducer::PerLSData::numorbit, LumiSummary::HLT::pathnameidx, LumiSummary::L1::prescale, LumiSummary::HLT::prescale, edm::LuminosityBlock::put(), LumiSummary::setBitZeroCount(), LumiSummary::setDeadCount(), LumiSummary::setlsnumber(), LumiSummary::setLumiData(), LumiDetails::setLumiVersion(), LumiSummary::setLumiVersion(), LumiSummary::setOrbitData(), LumiProducer::PerLSData::startorbit, LumiSummary::swapHLTData(), LumiSummary::swapL1Data(), LumiProducer::PerRunData::TRGBitNameToIndex, and LumiSummary::L1::triggernameidx.
Referenced by beginLuminosityBlock().
{ //std::cout<<"writing runnumber,luminum "<<runnumber<<" "<<luminum<<std::endl; std::auto_ptr<LumiSummary> pOut1; std::auto_ptr<LumiDetails> pOut2; LumiSummary* pIn1=new LumiSummary; LumiDetails* pIn2=new LumiDetails; if(m_isNullRun){ pIn1->setLumiVersion("-1"); pIn2->setLumiVersion("-1"); pOut1.reset(pIn1); iLBlock.put(pOut1); pOut2.reset(pIn2); iLBlock.put(pOut2); return; } PerLSData& lsdata=m_lscache[luminum]; pIn1->setLumiData(lsdata.lumivalue,lsdata.lumierror,lsdata.lumiquality); pIn1->setDeadCount(lsdata.deadcount); if(!lsdata.l1data.empty()){ //std::cout<<"bitzerocount "<<lsdata.bitzerocount<<std::endl; //std::cout<<"bitzeroprescale "<<lsdata.bitzeroprescale<<std::endl; //std::cout<<"product "<<lsdata.bitzerocount*lsdata.bitzeroprescale<<std::endl; pIn1->setBitZeroCount(lsdata.bitzerocount*lsdata.bitzeroprescale); } pIn1->setlsnumber(luminum); pIn1->setOrbitData(lsdata.startorbit,lsdata.numorbit); std::vector<LumiSummary::L1> l1temp; for(std::vector< L1Data >::iterator it=lsdata.l1data.begin();it!=lsdata.l1data.end();++it){ LumiSummary::L1 trgtmp; trgtmp.triggernameidx=m_runcache.TRGBitNameToIndex[it->bitname]; trgtmp.prescale=it->prescale; l1temp.push_back(trgtmp); } std::vector<LumiSummary::HLT> hlttemp; for(std::vector< HLTData >::iterator it=lsdata.hltdata.begin();it!=lsdata.hltdata.end();++it){ LumiSummary::HLT hlttmp; hlttmp.pathnameidx=m_runcache.HLTPathNameToIndex[it->pathname];; hlttmp.prescale=it->prescale; hlttemp.push_back(hlttmp); } pIn1->swapL1Data(l1temp); pIn1->swapHLTData(hlttemp); pIn1->setLumiVersion(m_lumiversion); pIn2->fillBeamIntensities(lsdata.beam1intensity,lsdata.beam2intensity); for(unsigned int i=0;i<lsdata.bunchlumivalue.size();++i){ std::string algoname=lsdata.bunchlumivalue[i].first; if(algoname=="OCC1"){ pIn2->fill(LumiDetails::kOCC1,lsdata.bunchlumivalue[i].second,lsdata.bunchlumierror[i].second,lsdata.bunchlumiquality[i].second); }else if(algoname=="OCC2"){ pIn2->fill(LumiDetails::kOCC2,lsdata.bunchlumivalue[i].second,lsdata.bunchlumierror[i].second,lsdata.bunchlumiquality[i].second); }else if(algoname=="ET"){ pIn2->fill(LumiDetails::kET,lsdata.bunchlumivalue[i].second,lsdata.bunchlumierror[i].second,lsdata.bunchlumiquality[i].second); }else if(algoname=="PLT"){ pIn2->fill(LumiDetails::kPLT,lsdata.bunchlumivalue[i].second,lsdata.bunchlumierror[i].second,lsdata.bunchlumiquality[i].second); } } pIn2->setLumiVersion(m_lumiversion); pOut1.reset(pIn1); iLBlock.put(pOut1); pOut2.reset(pIn2); iLBlock.put(pOut2); }
std::string LumiProducer::x2s | ( | const XMLCh * | input | ) | const [private] |
unsigned long long LumiProducer::m_cachedhltdataid [private] |
Definition at line 155 of file LumiProducer.cc.
Referenced by beginRun(), fillLSCache(), and fillRunCache().
unsigned long long LumiProducer::m_cachedlumidataid [private] |
Definition at line 153 of file LumiProducer.cc.
Referenced by beginRun(), and fillLSCache().
unsigned int LumiProducer::m_cachedrun [private] |
Definition at line 152 of file LumiProducer.cc.
Referenced by beginRun().
unsigned long long LumiProducer::m_cachedtrgdataid [private] |
Definition at line 154 of file LumiProducer.cc.
Referenced by beginRun(), fillLSCache(), and fillRunCache().
unsigned int LumiProducer::m_cachesize [private] |
Definition at line 159 of file LumiProducer.cc.
Referenced by fillLSCache().
std::string LumiProducer::m_connectStr [private] |
Definition at line 149 of file LumiProducer.cc.
Referenced by beginRun(), and fillLSCache().
bool LumiProducer::m_isNullRun [private] |
Definition at line 158 of file LumiProducer.cc.
Referenced by beginLuminosityBlock(), beginRun(), fillLSCache(), and writeProductsForEntry().
std::map< unsigned int,PerLSData > LumiProducer::m_lscache [private] |
Definition at line 157 of file LumiProducer.cc.
Referenced by beginLuminosityBlock(), fillLSCache(), and writeProductsForEntry().
std::string LumiProducer::m_lumiversion [private] |
Definition at line 150 of file LumiProducer.cc.
PerRunData LumiProducer::m_runcache [private] |
Definition at line 156 of file LumiProducer.cc.
Referenced by endRun(), fillLSCache(), fillRunCache(), and writeProductsForEntry().
std::string LumiProducer::m_siteconfpath [private] |
Definition at line 151 of file LumiProducer.cc.
Referenced by servletTranslation().