Skip to content

Commit

Permalink
Merge pull request #13415 from Martin-Grunewald/HLTPrescaler
Browse files Browse the repository at this point in the history
Make HLTPrescaler stage-2 aware
  • Loading branch information
cmsbuild committed Feb 22, 2016
2 parents f239fa8 + 5a139c4 commit 78c77d3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
9 changes: 8 additions & 1 deletion HLTrigger/HLTcore/interface/HLTPrescaler.h
Expand Up @@ -18,7 +18,13 @@
#include "FWCore/Framework/interface/stream/EDFilter.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/PrescaleService/interface/PrescaleService.h"

// legacy/stage-1 L1T:
#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"

// stage-2 L1T:
#include "DataFormats/L1TGlobal/interface/GlobalAlgBlk.h"

namespace edm {
class ConfigurationDescriptions;
}
Expand Down Expand Up @@ -86,7 +92,8 @@ class HLTPrescaler : public edm::stream::EDFilter<edm::GlobalCache<trigger::Effi

/// GT payload, to extract the prescale column index
edm::InputTag gtDigiTag_;
edm::EDGetTokenT<L1GlobalTriggerReadoutRecord> gtDigiToken_;
edm::EDGetTokenT<L1GlobalTriggerReadoutRecord> gtDigi1Token_;
edm::EDGetTokenT<GlobalAlgBlkBxCollection> gtDigi2Token_;

/// "seed" used to initialize the prescale counter
static const
Expand Down
36 changes: 24 additions & 12 deletions HLTrigger/HLTcore/plugins/HLTPrescaler.cc
Expand Up @@ -14,7 +14,6 @@
#include "FWCore/ServiceRegistry/interface/ModuleCallingContext.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
#include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
#include "HLTrigger/HLTcore/interface/HLTPrescaler.h"

Expand All @@ -39,7 +38,8 @@ HLTPrescaler::HLTPrescaler(edm::ParameterSet const& iConfig, const trigger::Effi
, prescaleService_(0)
, newLumi_(true)
, gtDigiTag_ (iConfig.getParameter<edm::InputTag>("L1GtReadoutRecordTag"))
, gtDigiToken_ (consumes<L1GlobalTriggerReadoutRecord>(gtDigiTag_))
, gtDigi1Token_ (consumes<L1GlobalTriggerReadoutRecord>(gtDigiTag_))
, gtDigi2Token_ (consumes<GlobalAlgBlkBxCollection>(gtDigiTag_))
{
if(edm::Service<edm::service::PrescaleService>().isAvailable())
prescaleService_ = edm::Service<edm::service::PrescaleService>().operator->();
Expand All @@ -60,7 +60,7 @@ HLTPrescaler::~HLTPrescaler()
void HLTPrescaler::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<unsigned int>("offset",0);
desc.add<edm::InputTag>("L1GtReadoutRecordTag",edm::InputTag("hltGtDigis"));
desc.add<edm::InputTag>("L1GtReadoutRecordTag",edm::InputTag("hltGtStage2Digis"));
descriptions.add("hltPrescaler", desc);
}

Expand All @@ -87,16 +87,28 @@ bool HLTPrescaler::filter(edm::Event& iEvent, const edm::EventSetup&)
const unsigned int oldSet(prescaleSet_);
const unsigned int oldPrescale(prescaleFactor_);

edm::Handle<L1GlobalTriggerReadoutRecord> handle;
iEvent.getByToken(gtDigiToken_,handle);
if (handle.isValid()) {
prescaleSet_ = handle->gtFdlWord().gtPrescaleFactorIndexAlgo();
// gtPrescaleFactorIndexTech() is also available
// by construction, they should always return the same index
prescaleFactor_ = prescaleService_->getPrescale(prescaleSet_, pathName);
edm::Handle<GlobalAlgBlkBxCollection> handle2;
iEvent.getByToken(gtDigi2Token_,handle2);
if (handle2.isValid()) {
if (handle2->begin(0)!=handle2->end(0)) {
prescaleSet_ = static_cast<unsigned int>(handle2->begin(0)->getPreScColumn());
prescaleFactor_ = prescaleService_->getPrescale(prescaleSet_, pathName);
} else {
edm::LogWarning("HLT") << "Cannot read prescale column index from GT2 data: using default as defined by configuration or DAQ";
prescaleFactor_ = prescaleService_->getPrescale(pathName);
}
} else {
edm::LogWarning("HLT") << "Cannot read prescale column index from GT data: using default as defined by configuration or DAQ";
prescaleFactor_ = prescaleService_->getPrescale(pathName);
edm::Handle<L1GlobalTriggerReadoutRecord> handle1;
iEvent.getByToken(gtDigi1Token_,handle1);
if (handle1.isValid()) {
prescaleSet_ = handle1->gtFdlWord().gtPrescaleFactorIndexAlgo();
// gtPrescaleFactorIndexTech() is also available
// by construction, they should always return the same index
prescaleFactor_ = prescaleService_->getPrescale(prescaleSet_, pathName);
} else {
edm::LogWarning("HLT") << "Cannot read prescale column index from GT1 data: using default as defined by configuration or DAQ";
prescaleFactor_ = prescaleService_->getPrescale(pathName);
}
}

if (prescaleSet_ != oldSet) {
Expand Down

0 comments on commit 78c77d3

Please sign in to comment.