CMS 3D CMS Logo

Public Member Functions | Private Attributes

HLTPrescaleRecorder Class Reference

#include <HLTPrescaleRecorder.h>

Inheritance diagram for HLTPrescaleRecorder:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

virtual void beginLuminosityBlock (edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup)
virtual void beginRun (edm::Run &iRun, const edm::EventSetup &iSetup)
virtual void endLuminosityBlock (edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup)
virtual void endRun (edm::Run &iRun, const edm::EventSetup &iSetup)
 HLTPrescaleRecorder (const edm::ParameterSet &)
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 ~HLTPrescaleRecorder ()

Private Attributes

bool condDB_
cond::service::PoolDBOutputServicedb_
 Pool DB service.
bool event_
trigger::HLTPrescaleTable hlt_
 payload HLT object
std::string hltDBTag_
 Tag of DB entry (HLT Key Name) (src=4)
edm::ESHandle
< trigger::HLTPrescaleTableCond
hltESHandle_
edm::Handle
< trigger::HLTPrescaleTable
hltHandle_
 Handle and ESHandle for existing HLT object.
edm::InputTag hltInputTag_
 InputTag of HLTPrescaleTable product (src=1,2,3)
bool lumi_
edm::service::PrescaleServiceps_
 Prescale service.
std::string psetName_
bool run_
 (Multiple) Destinations
int src_

Detailed Description

This class is an EDProducer making the HLTPrescaleTable object

Date:
2010/03/08 17:12:09
Revision:
1.4
Author:
Martin Grunewald

See header file for documentation

Date:
2012/02/29 14:39:34
Revision:
1.6
Author:
Martin Grunewald

Definition at line 41 of file HLTPrescaleRecorder.h.


Constructor & Destructor Documentation

HLTPrescaleRecorder::HLTPrescaleRecorder ( const edm::ParameterSet ps) [explicit]

Definition at line 37 of file HLTPrescaleRecorder.cc.

References condDB_, db_, edm::InputTag::encode(), event_, hltDBTag_, hltInputTag_, lumi_, cmsCodeRules::cppFunctionSkipper::operator, ps_, psetName_, run_, and src_.

                                                                  : 
  src_(ps.getParameter<int>("src")),
  run_(ps.getParameter<bool>("run")),
  lumi_(ps.getParameter<bool>("lumi")),
  event_(ps.getParameter<bool>("event")),
  condDB_(ps.getParameter<bool>("condDB")),
  psetName_(ps.getParameter<string>("psetName")),
  hltInputTag_(ps.getParameter<InputTag>("hltInputTag")),
  hltDBTag_(ps.getParameter<string>("hltDBTag")),
  ps_(0),
  db_(0),
  hltHandle_(),
  hltESHandle_(),
  hlt_()
{

  LogInfo("HLTPrescaleRecorder")
    << "src:run-lumi-event-condDB+psetName+tags: "
    << src_ << ":" << run_ << "-" << lumi_ << "-" << event_ << "-"
    << condDB_ << "+" << psetName_ << "+"
    << hltInputTag_.encode() << "+" << hltDBTag_;

  if(edm::Service<edm::service::PrescaleService>().isAvailable()) {
    ps_ = edm::Service<edm::service::PrescaleService>().operator->();
  } else if (src_==0) {
    LogError("HLTPrescaleRecorder")<<"PrescaleService requested as source but unavailable!";
  }

  if (edm::Service<cond::service::PoolDBOutputService>().isAvailable()) {
    db_ = edm::Service<cond::service::PoolDBOutputService>().operator->();
  } else if (condDB_) {
    LogError("HLTPrescaleRecorder")<<"PoolDBOutputService requested as destination but unavailable!";
  }

  if (run_)   produces<HLTPrescaleTable,edm::InRun>("Run");
  if (lumi_)  produces<HLTPrescaleTable,edm::InLumi>("Lumi");
  if (event_) produces<HLTPrescaleTable,edm::InEvent>("Event");

}
HLTPrescaleRecorder::~HLTPrescaleRecorder ( )

Definition at line 77 of file HLTPrescaleRecorder.cc.

{
}

Member Function Documentation

void HLTPrescaleRecorder::beginLuminosityBlock ( edm::LuminosityBlock iLumi,
const edm::EventSetup iSetup 
) [virtual]

From PrescaleService default index updated at lumi block boundaries

From Lumi Block

Reimplemented from edm::EDProducer.

Definition at line 138 of file HLTPrescaleRecorder.cc.

References edm::LuminosityBlock::getByLabel(), edm::service::PrescaleService::getLvl1IndexDefault(), edm::service::PrescaleService::getLvl1Labels(), edm::service::PrescaleService::getPrescaleTable(), hlt_, hltHandle_, hltInputTag_, ps_, and src_.

                                                                                                     {

  if (src_==0) {
    if (ps_!=0) {
      hlt_=HLTPrescaleTable(ps_->getLvl1IndexDefault(), ps_->getLvl1Labels(), ps_->getPrescaleTable());
    } else {
      hlt_=HLTPrescaleTable();
      LogError("HLTPrescaleRecorder")<<"PrescaleService not found!";
    }
  } else if (src_==2) {
    if (iLumi.getByLabel(hltInputTag_,hltHandle_)) {
      hlt_=*hltHandle_;
    } else {
      hlt_=HLTPrescaleTable();
      LogError("HLTPrescaleRecorder")<<"HLTPrescaleTable not found in LumiBlock!";
    }
  }

  return;
}
void HLTPrescaleRecorder::beginRun ( edm::Run iRun,
const edm::EventSetup iSetup 
) [virtual]

From PrescaleTable tracked PSet

From PrescaleService default index updated at lumi block boundaries

From Run Block

From CondDB (needs ESProducer module as well)

Reimplemented from edm::EDProducer.

Definition at line 85 of file HLTPrescaleRecorder.cc.

References edm::EventSetup::get(), edm::eventsetup::EventSetupRecord::get(), edm::Run::getByLabel(), edm::service::PrescaleService::getLvl1IndexDefault(), edm::service::PrescaleService::getLvl1Labels(), edm::ParameterSet::getParameter(), edm::service::PrescaleService::getPrescaleTable(), edm::getProcessParameterSet(), hlt_, hltDBTag_, hltESHandle_, hltHandle_, hltInputTag_, i, reco_calib_source_client_cfg::labels, m, n, ps_, psetName_, src_, and asciidump::table.

                                                                            {

  hlt_=HLTPrescaleTable();

  if (src_==-1) {
    ParameterSet pPSet(getProcessParameterSet());
    ParameterSet iPS(pPSet.getParameter<ParameterSet>(psetName_));

    string defaultLabel(iPS.getParameter<std::string>("lvl1DefaultLabel"));
    vector<string> labels(iPS.getParameter<std::vector<std::string> >("lvl1Labels"));
    vector<ParameterSet> vpTable(iPS.getParameter<std::vector<ParameterSet> >("prescaleTable"));

    unsigned int set(0);
    const unsigned int n(labels.size());
    for (unsigned int i=0; i!=n; ++i) {
      if (labels[i]==defaultLabel) set=i;
    }

    map<string,vector<unsigned int> > table;
    const unsigned int m (vpTable.size());
    for (unsigned int i=0; i!=m; ++i) {
      table[vpTable[i].getParameter<std::string>("pathName")] = 
        vpTable[i].getParameter<std::vector<unsigned int> >("prescales");
    }
    hlt_=HLTPrescaleTable(set,labels,table);

  } else  if (src_==0) {
    if (ps_!=0) {
      hlt_=HLTPrescaleTable(ps_->getLvl1IndexDefault(), ps_->getLvl1Labels(), ps_->getPrescaleTable());
    } else {
      hlt_=HLTPrescaleTable();
      LogError("HLTPrescaleRecorder")<<"PrescaleService not found!";
    }
  } else if (src_==1) {
    if (iRun.getByLabel(hltInputTag_,hltHandle_)) {
      hlt_=*hltHandle_;
    } else {
      LogError("HLTPrescaleRecorder")<<"HLTPrescaleTable not found in Run!";
    }
  } else if (src_==4) {
    const HLTPrescaleTableRcd& hltRecord(iSetup.get<HLTPrescaleTableRcd>());
    hltRecord.get(hltDBTag_,hltESHandle_);
    hlt_=hltESHandle_->hltPrescaleTable();
  }

  return;
}
void HLTPrescaleRecorder::endLuminosityBlock ( edm::LuminosityBlock iLumi,
const edm::EventSetup iSetup 
) [virtual]

Writing to Lumi Block

Reimplemented from edm::EDProducer.

Definition at line 183 of file HLTPrescaleRecorder.cc.

References hlt_, lumi_, and edm::LuminosityBlock::put().

                                                                                                   {

  if (lumi_) {
    auto_ptr<HLTPrescaleTable> product (new HLTPrescaleTable(hlt_));
    iLumi.put(product,"Lumi");
  }

  return;
}
void HLTPrescaleRecorder::endRun ( edm::Run iRun,
const edm::EventSetup iSetup 
) [virtual]

Dump to logfile

Writing to Run Block

Writing to CondDB (needs PoolDBOutputService)

Reimplemented from edm::EDProducer.

Definition at line 194 of file HLTPrescaleRecorder.cc.

References cond::service::PoolDBOutputService::appendSinceTime(), cond::service::PoolDBOutputService::beginOfTime(), condDB_, cond::service::PoolDBOutputService::createNewIOV(), db_, cond::service::PoolDBOutputService::endOfTime(), hlt_, i, cond::service::PoolDBOutputService::isNewTagRequest(), reco_calib_source_client_cfg::labels, trigger::HLTPrescaleTable::labels(), n, edm::Run::put(), run_, trigger::HLTPrescaleTable::size(), asciidump::table, trigger::HLTPrescaleTable::table(), and edm::Timestamp::value().

                                                                          {

  ostringstream oss;
  const unsigned int n(hlt_.size());
  oss << "PrescaleTable: # of labels = " << n << endl;
  const vector<string>& labels(hlt_.labels());
  for (unsigned int i=0; i!=n; ++i) {
    oss << " " << i << "/'" << labels.at(i) << "'";
  }
  oss << endl;
  const map<string,vector<unsigned int> >& table(hlt_.table());
  oss << "PrescaleTable: # of paths = " << table.size() << endl;
  const map<string,vector<unsigned int> >::const_iterator tb(table.begin());
  const map<string,vector<unsigned int> >::const_iterator te(table.end());
  for (map<string,vector<unsigned int> >::const_iterator ti=tb; ti!=te; ++ti) {
    for (unsigned int i=0; i!=n; ++i) {
      oss << " " << ti->second.at(i);
    }
    oss << " " << ti->first << endl;
  }
  LogVerbatim("HLTPrescaleRecorder") << oss.str();

  if (run_) {
    auto_ptr<HLTPrescaleTable> product (new HLTPrescaleTable(hlt_));
    iRun.put(product,"Run");
  }

  if (condDB_) {
    if (db_!=0) {
      HLTPrescaleTableCond* product (new HLTPrescaleTableCond(hlt_));
      const string rcdName("HLTPrescaleTableRcd");
      if ( db_->isNewTagRequest(rcdName) ) {
        db_->createNewIOV<HLTPrescaleTableCond>(product,
              db_->beginOfTime(),db_->endOfTime(),rcdName);
      } else {
        ::timeval tv;
        gettimeofday(&tv,0);
        edm::Timestamp tstamp((unsigned long long)tv.tv_sec);
        db_->appendSinceTime<HLTPrescaleTableCond>(product,
//            db_->currentTime()
              tstamp.value()
                ,rcdName);
      }
    } else {
      LogError("HLTPrescaleRecorder") << "PoolDBOutputService not available!";
    }
  }

  return;
}
void HLTPrescaleRecorder::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

From Event Block

Writing to Event

Implements edm::EDProducer.

Definition at line 162 of file HLTPrescaleRecorder.cc.

References event_, edm::Event::getByLabel(), hlt_, hltHandle_, hltInputTag_, edm::Event::put(), and src_.

                                                                               {

  if (src_==3) {
    if (iEvent.getByLabel(hltInputTag_,hltHandle_)) {
      hlt_=*hltHandle_;
    } else {
      hlt_=HLTPrescaleTable();
      LogError("HLTPrescaleRecorder")<<"HLTPrescaleTable not found in Event!";
    }
  }

  if (event_) {
    auto_ptr<HLTPrescaleTable> product (new HLTPrescaleTable(hlt_));
    iEvent.put(product,"Event");
  }

  return;
}

Member Data Documentation

Definition at line 62 of file HLTPrescaleRecorder.h.

Referenced by endRun(), and HLTPrescaleRecorder().

Pool DB service.

Definition at line 75 of file HLTPrescaleRecorder.h.

Referenced by endRun(), and HLTPrescaleRecorder().

Definition at line 61 of file HLTPrescaleRecorder.h.

Referenced by HLTPrescaleRecorder(), and produce().

payload HLT object

Definition at line 82 of file HLTPrescaleRecorder.h.

Referenced by beginLuminosityBlock(), beginRun(), endLuminosityBlock(), endRun(), and produce().

std::string HLTPrescaleRecorder::hltDBTag_ [private]

Tag of DB entry (HLT Key Name) (src=4)

Definition at line 70 of file HLTPrescaleRecorder.h.

Referenced by beginRun(), and HLTPrescaleRecorder().

Definition at line 79 of file HLTPrescaleRecorder.h.

Referenced by beginRun().

Handle and ESHandle for existing HLT object.

Definition at line 78 of file HLTPrescaleRecorder.h.

Referenced by beginLuminosityBlock(), beginRun(), and produce().

InputTag of HLTPrescaleTable product (src=1,2,3)

Definition at line 68 of file HLTPrescaleRecorder.h.

Referenced by beginLuminosityBlock(), beginRun(), HLTPrescaleRecorder(), and produce().

Definition at line 60 of file HLTPrescaleRecorder.h.

Referenced by endLuminosityBlock(), and HLTPrescaleRecorder().

Prescale service.

Definition at line 73 of file HLTPrescaleRecorder.h.

Referenced by beginLuminosityBlock(), beginRun(), and HLTPrescaleRecorder().

std::string HLTPrescaleRecorder::psetName_ [private]

Source configs name of PrescaleServicePSet (src=-1)

Definition at line 66 of file HLTPrescaleRecorder.h.

Referenced by beginRun(), and HLTPrescaleRecorder().

bool HLTPrescaleRecorder::run_ [private]

(Multiple) Destinations

Definition at line 59 of file HLTPrescaleRecorder.h.

Referenced by endRun(), and HLTPrescaleRecorder().

(Single) source: -1:PrescaleServicePSet 0:PrescaleService, 1:Run, 2:Lumi, 3:Event, 4:CondDB

Definition at line 56 of file HLTPrescaleRecorder.h.

Referenced by beginLuminosityBlock(), beginRun(), HLTPrescaleRecorder(), and produce().