Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consumes migration for L1GtUtils #9055

Merged
merged 9 commits into from May 22, 2015
10 changes: 6 additions & 4 deletions Calibration/HcalCalibAlgos/src/GammaJetAnalysis.cc
Expand Up @@ -68,7 +68,9 @@ unsigned int helper_findTrigger(const std::vector<std::string>& list,

// -------------------------------------------------

GammaJetAnalysis::GammaJetAnalysis(const edm::ParameterSet& iConfig) {
GammaJetAnalysis::GammaJetAnalysis(const edm::ParameterSet& iConfig) :
hltPrescaleProvider_(iConfig, consumesCollector(), *this) {

// set parameters
debug_ = iConfig.getUntrackedParameter<int>("debug", 0);
debugHLTTrigNames = iConfig.getUntrackedParameter<int>("debugHLTTrigNames",1);
Expand Down Expand Up @@ -353,7 +355,7 @@ void GammaJetAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup&
if (!writeTriggerPrescale_) photonTrigPrescale_.push_back(-1);
else {
// for triggers with two L1 seeds this fails
std::pair<int,int> prescaleVals= hltConfig_.prescaleValues(iEvent,evSetup, evTrigNames.triggerName(id));
std::pair<int,int> prescaleVals= hltPrescaleProvider_.prescaleValues(iEvent,evSetup, evTrigNames.triggerName(id));
photonTrigPrescale_.push_back(prescaleVals.first * prescaleVals.second);
}
}
Expand All @@ -368,7 +370,7 @@ void GammaJetAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup&
int fired= triggerResults->accept(id);
if (fired) jetTrigFlag=true;
jetTrigFired_.push_back(fired);
std::pair<int,int> prescaleVals= hltConfig_.prescaleValues(iEvent,evSetup,evTrigNames.triggerName(id));
std::pair<int,int> prescaleVals = hltPrescaleProvider_.prescaleValues(iEvent,evSetup,evTrigNames.triggerName(id));
jetTrigPrescale_.push_back(prescaleVals.first * prescaleVals.second);
}
}
Expand Down Expand Up @@ -1594,7 +1596,7 @@ void GammaJetAnalysis::beginRun(const edm::Run &iRun,
if (debug_>0) edm::LogInfo("GammaJetAnalysis") << "Initializing trigger information for individual run";
bool changed(true);
std::string processName="HLT";
if (hltConfig_.init(iRun,setup,processName,changed)) {
if (hltPrescaleProvider_.init(iRun,setup,processName,changed)) {
// if init returns TRUE, initialisation has succeeded!
if (changed) {
// The HLT config has actually changed wrt the previous Run, hence rebook your
Expand Down
4 changes: 2 additions & 2 deletions Calibration/HcalCalibAlgos/src/GammaJetAnalysis.h
Expand Up @@ -49,7 +49,7 @@
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"

#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
#include "HLTrigger/HLTcore/interface/HLTPrescaleProvider.h"

// forward declarations
class TH1D;
Expand Down Expand Up @@ -200,7 +200,7 @@ class GammaJetAnalysis : public edm::EDAnalyzer {
TTree* pf_tree_;

// trigger info
HLTConfigProvider hltConfig_; // variable for the access
HLTPrescaleProvider hltPrescaleProvider_;
std::vector<int> photonTrigFired_;
std::vector<int> photonTrigPrescale_;
std::vector<int> jetTrigFired_;
Expand Down
19 changes: 12 additions & 7 deletions Calibration/IsolatedParticles/plugins/IsoTrackCalib.cc
Expand Up @@ -2,9 +2,12 @@
#include "DataFormats/Math/interface/deltaR.h"
#include "DataFormats/Math/interface/deltaPhi.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"

IsoTrackCalib::IsoTrackCalib(const edm::ParameterSet& iConfig) :
changed(false), nRun(0), t_trackP(0), t_trackPx(0), t_trackPy(0),
changed(false),
hltPrescaleProvider_(iConfig, consumesCollector(), *this),
nRun(0), t_trackP(0), t_trackPx(0), t_trackPy(0),
t_trackPz(0), t_trackEta(0), t_trackPhi(0), t_trackPt(0), t_neu_iso(0),
t_charge_iso(0), t_emip(0), t_ehcal(0), t_trkL3mindr(0), t_ieta(0),
t_disthotcell(0), t_ietahotcell(0), t_eventweight(0), t_l1pt(0), t_l1eta(0),
Expand Down Expand Up @@ -132,6 +135,8 @@ void IsoTrackCalib::analyze(const edm::Event& iEvent, const edm::EventSetup& iSe
<< " Bunch " << iEvent.bunchCrossing() << " start";
clearTreeVectors();

HLTConfigProvider const& hltConfig = hltPrescaleProvider_.hltConfigProvider();

//Get magnetic field and ECAL channel status
edm::ESHandle<MagneticField> bFieldH;
iSetup.get<IdealMagneticFieldRecord>().get(bFieldH);
Expand Down Expand Up @@ -214,8 +219,8 @@ void IsoTrackCalib::analyze(const edm::Event& iEvent, const edm::EventSetup& iSe
const std::vector<std::string> & triggerNames_ = triggerNames.triggerNames();
for (unsigned int iHLT=0; iHLT<triggerResults->size(); iHLT++) {
bool ok(false);
unsigned int triggerindx = hltConfig_.triggerIndex(triggerNames_[iHLT]);
const std::vector<std::string>& moduleLabels(hltConfig_.moduleLabels(triggerindx));
unsigned int triggerindx = hltConfig.triggerIndex(triggerNames_[iHLT]);
const std::vector<std::string>& moduleLabels(hltConfig.moduleLabels(triggerindx));
edm::LogInfo("IsoTrack") << iHLT << " " <<triggerNames_[iHLT];
int ipos = -1;
for (unsigned int i=0; i<HLTNames.size(); ++i) {
Expand Down Expand Up @@ -249,7 +254,7 @@ void IsoTrackCalib::analyze(const edm::Event& iEvent, const edm::EventSetup& iSe
edm::LogInfo("IsoTrack") << "Trigger fired? : " << ok;
if (ok) {
std::vector<math::XYZTLorentzVector> vec[3];
const std::pair<int,int> prescales(hltConfig_.prescaleValues(iEvent,iSetup,triggerNames_[iHLT]));
const std::pair<int,int> prescales(hltPrescaleProvider_.prescaleValues(iEvent,iSetup,triggerNames_[iHLT]));
int preL1 = prescales.first;
int preHLT = prescales.second;
int prescale = preL1*preHLT;
Expand Down Expand Up @@ -471,9 +476,9 @@ void IsoTrackCalib::analyze(const edm::Event& iEvent, const edm::EventSetup& iSe
changed = false;
if ((verbosity/10)%10 > 1) {
edm::LogInfo("IsoTrack") <<"New trigger menu found !!!";
const unsigned int n(hltConfig_.size());
const unsigned int n(hltConfig.size());
for (unsigned itrig=0; itrig<triggerNames_.size(); itrig++) {
unsigned int triggerindx = hltConfig_.triggerIndex(triggerNames_[itrig]);
unsigned int triggerindx = hltConfig.triggerIndex(triggerNames_[itrig]);
if (triggerindx >= n)
edm::LogInfo("IsoTrack") << triggerNames_[itrig] << " "
<< triggerindx << " does not exist";
Expand Down Expand Up @@ -573,7 +578,7 @@ void IsoTrackCalib::endJob() {
// ------------ method called when starting to processes a run ------------
void IsoTrackCalib::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
edm::LogInfo("IsoTrack") << "Run[" << nRun <<"] " << iRun.run()
<< " hltconfig.init " << hltConfig_.init(iRun,iSetup,"HLT",changed);
<< " hltconfig.init " << hltPrescaleProvider_.init(iRun,iSetup,"HLT",changed);
char hname[100], htit[100];
sprintf(hname, "h_HLTAccepts_%i", iRun.run());
sprintf(htit, "HLT Accepts for Run No %i", iRun.run());
Expand Down
4 changes: 2 additions & 2 deletions Calibration/IsolatedParticles/plugins/IsoTrackCalib.h
Expand Up @@ -41,7 +41,7 @@
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Common/interface/TriggerNames.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
#include "HLTrigger/HLTcore/interface/HLTPrescaleProvider.h"

#include "Calibration/IsolatedParticles/interface/CaloPropagateTrack.h"
#include "Calibration/IsolatedParticles/interface/ChargeIsolation.h"
Expand Down Expand Up @@ -95,7 +95,7 @@ class IsoTrackCalib : public edm::EDAnalyzer {

bool changed;
edm::Service<TFileService> fs;
HLTConfigProvider hltConfig_;
HLTPrescaleProvider hltPrescaleProvider_;
std::vector<std::string> trigNames, HLTNames;
int verbosity;
spr::trackSelectionParameters selectionParameters;
Expand Down
18 changes: 11 additions & 7 deletions Calibration/IsolatedParticles/plugins/IsoTrig.cc
Expand Up @@ -24,8 +24,10 @@
#include "Calibration/IsolatedParticles/interface/eCone.h"
#include "Calibration/IsolatedParticles/interface/eECALMatrix.h"
#include "HLTrigger/Timer/interface/FastTimerService.h"
#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"

IsoTrig::IsoTrig(const edm::ParameterSet& iConfig) :
IsoTrig::IsoTrig(const edm::ParameterSet& iConfig) :
hltPrescaleProvider_(iConfig, consumesCollector(), *this),
changed(false), t_timeL2Prod(0), t_nPixCand(0), t_nPixSeed(0), t_nGoodTk(0),
t_TrkhCone(0), t_TrkP(0), t_TrkselTkFlag(0), t_TrkqltyFlag(0),
t_TrkMissFlag(0), t_TrkPVFlag(0), t_TrkNuIsolFlag(0),
Expand Down Expand Up @@ -214,6 +216,8 @@ void IsoTrig::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
#endif
int RunNo = iEvent.id().run();

HLTConfigProvider const& hltConfig = hltPrescaleProvider_.hltConfigProvider();

iSetup.get<IdealMagneticFieldRecord>().get(bFieldH);
iSetup.get<CaloGeometryRecord>().get(pG);
const MagneticField *bField = bFieldH.product();
Expand Down Expand Up @@ -309,8 +313,8 @@ void IsoTrig::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
#endif
int hlt(-1), preL1(-1), preHLT(-1), prescale(-1);
for (unsigned int i=0; i<triggerResults->size(); i++) {
unsigned int triggerindx = hltConfig_.triggerIndex(triggerNames_[i]);
const std::vector<std::string>& moduleLabels(hltConfig_.moduleLabels(triggerindx));
unsigned int triggerindx = hltConfig.triggerIndex(triggerNames_[i]);
const std::vector<std::string>& moduleLabels(hltConfig.moduleLabels(triggerindx));

for (unsigned int in=0; in<trigNames.size(); ++in) {
// if (triggerNames_[i].find(trigNames[in].c_str())!=std::string::npos || triggerNames_[i]==" ") {
Expand All @@ -327,7 +331,7 @@ void IsoTrig::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
edm::Handle<trigger::TriggerFilterObjectWithRefs> L1cands;
iEvent.getByToken(tok_l1cand_, L1cands);

const std::pair<int,int> prescales(hltConfig_.prescaleValues(iEvent,iSetup,triggerNames_[i]));
const std::pair<int,int> prescales(hltPrescaleProvider_.prescaleValues(iEvent,iSetup,triggerNames_[i]));
preL1 = prescales.first;
preHLT = prescales.second;
prescale = preL1*preHLT;
Expand Down Expand Up @@ -421,9 +425,9 @@ void IsoTrig::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
#ifdef DebugLog
if ((verbosity/10)%10 > 1) {
std::cout << "New trigger menu found !!!" << std::endl;
const unsigned int n(hltConfig_.size());
const unsigned int n(hltConfig.size());
for (unsigned itrig=0; itrig<triggerNames_.size(); itrig++) {
unsigned int triggerindx = hltConfig_.triggerIndex(triggerNames_[itrig]);
unsigned int triggerindx = hltConfig.triggerIndex(triggerNames_[itrig]);
std::cout << triggerNames_[itrig] << " " << triggerindx << " ";
if (triggerindx >= n)
std::cout << "does not exist in the current menu" << std::endl;
Expand Down Expand Up @@ -812,7 +816,7 @@ void IsoTrig::endJob() {
// ------------ method called when starting to processes a run ------------
void IsoTrig::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
edm::LogWarning ("IsoTrack") << "Run " << iRun.run() << " hltconfig.init "
<< hltConfig_.init(iRun,iSetup,processName,changed);
<< hltPrescaleProvider_.init(iRun,iSetup,processName,changed);
}

// ------------ method called when ending the processing of a run ------------
Expand Down
4 changes: 2 additions & 2 deletions Calibration/IsolatedParticles/plugins/IsoTrig.h
Expand Up @@ -30,7 +30,7 @@
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
#include "HLTrigger/HLTcore/interface/HLTPrescaleProvider.h"
#include "DataFormats/Math/interface/LorentzVector.h"
#include "Calibration/IsolatedParticles/interface/TrackSelection.h"
#include "DataFormats/TrackReco/interface/Track.h"
Expand Down Expand Up @@ -120,7 +120,7 @@ class IsoTrig : public edm::EDAnalyzer {
double getDistInCM(double eta1,double phi1, double eta2,double phi2);

// ----------member data ---------------------------
HLTConfigProvider hltConfig_;
HLTPrescaleProvider hltPrescaleProvider_;
std::vector<std::string> trigNames;
edm::InputTag PixcandTag_, L1candTag_, L2candTag_;
std::vector<edm::InputTag> pixelTracksSources_;
Expand Down
9 changes: 5 additions & 4 deletions Calibration/IsolatedParticles/plugins/IsolatedTracksNxN.cc
Expand Up @@ -32,8 +32,12 @@
#include "CondFormats/DataRecord/interface/L1GtTriggerMaskAlgoTrigRcd.h"
#include "CondFormats/DataRecord/interface/L1GtTriggerMaskTechTrigRcd.h"

static const bool useL1EventSetup(true);
static const bool useL1GtTriggerMenuLite(true);

IsolatedTracksNxN::IsolatedTracksNxN(const edm::ParameterSet& iConfig) :
trackerHitAssociatorConfig_(consumesCollector()) {
m_l1GtUtils(iConfig, consumesCollector(), useL1GtTriggerMenuLite, *this),
trackerHitAssociatorConfig_(consumesCollector()) {

//now do what ever initialization is needed
doMC = iConfig.getUntrackedParameter<bool> ("DoMC", false);
Expand Down Expand Up @@ -138,9 +142,6 @@ void IsolatedTracksNxN::analyze(const edm::Event& iEvent, const edm::EventSetup&
//===================== save L1 Trigger information =======================
if( L1TriggerAlgoInfo_ ) {

bool useL1EventSetup = true;
bool useL1GtTriggerMenuLite = true;

m_l1GtUtils.getL1GtRunCache(iEvent, iSetup, useL1EventSetup, useL1GtTriggerMenuLite);

int iErrorCode = -1;
Expand Down
Expand Up @@ -13,7 +13,7 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
#include "HLTrigger/HLTcore/interface/HLTPrescaleProvider.h"
#include "DataFormats/Common/interface/TriggerResults.h"
#include "DataFormats/HLTReco/interface/TriggerEvent.h"

Expand Down Expand Up @@ -42,7 +42,6 @@ class CandidateTriggerObjectProducer : public edm::EDProducer {
/// additional class data memebers
edm::Handle<edm::TriggerResults> triggerResultsHandle_;
edm::Handle<trigger::TriggerEvent> triggerEventHandle_;
HLTConfigProvider hltConfig_;

HLTPrescaleProvider hltPrescaleProvider_;
};
#endif
25 changes: 21 additions & 4 deletions CommonTools/TriggerUtils/interface/GenericTriggerEventFlag.h
Expand Up @@ -33,14 +33,15 @@
#include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtUtils.h"
#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"

#include <memory>
#include <string>


class GenericTriggerEventFlag {

// Utility classes
edm::ESWatcher< AlCaRecoTriggerBitsRcd > * watchDB_;
L1GtUtils l1Gt_;
std::unique_ptr<L1GtUtils> l1Gt_;
HLTConfigProvider hltConfig_;
bool hltConfigInit_;
// Configuration parameters
Expand Down Expand Up @@ -85,9 +86,13 @@ class GenericTriggerEventFlag {

public:

// Constructors and destructor
GenericTriggerEventFlag( const edm::ParameterSet & config, edm::ConsumesCollector && iC ) : GenericTriggerEventFlag( config, iC ) {}; // To be called from the ED module's c'tor
GenericTriggerEventFlag( const edm::ParameterSet & config, edm::ConsumesCollector & iC ); // To be called from the ED module's c'tor
// Constructors must be called from the ED module's c'tor
template <typename T>
GenericTriggerEventFlag( const edm::ParameterSet & config, edm::ConsumesCollector && iC, T& module );

template <typename T>
GenericTriggerEventFlag( const edm::ParameterSet & config, edm::ConsumesCollector & iC, T& module );

~GenericTriggerEventFlag();

// Public methods
Expand All @@ -100,6 +105,8 @@ class GenericTriggerEventFlag {

// Private methods

GenericTriggerEventFlag( const edm::ParameterSet & config, edm::ConsumesCollector & iC );

// DCS
bool acceptDcs( const edm::Event & event );
bool acceptDcsPartition( const edm::Handle< DcsStatusCollection > & dcsStatus, int dcsPartition ) const;
Expand Down Expand Up @@ -132,5 +139,15 @@ class GenericTriggerEventFlag {

};

template <typename T>
GenericTriggerEventFlag::GenericTriggerEventFlag( const edm::ParameterSet & config, edm::ConsumesCollector && iC, T& module ) :
GenericTriggerEventFlag(config, iC, module) {
}

template <typename T>
GenericTriggerEventFlag::GenericTriggerEventFlag( const edm::ParameterSet & config, edm::ConsumesCollector & iC, T& module ) :
GenericTriggerEventFlag(config, iC) {
l1Gt_.reset(new L1GtUtils(config, iC, false, module));
}

#endif
43 changes: 37 additions & 6 deletions CommonTools/TriggerUtils/interface/PrescaleWeightProvider.h
Expand Up @@ -20,23 +20,38 @@
*/


#include <vector>
#include <memory>
#include <string>
#include <vector>

#include "DataFormats/Common/interface/Handle.h"

#include "FWCore/Framework/interface/Run.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "FWCore/Utilities/interface/InputTag.h"

#include "HLTrigger/HLTcore/interface/HLTPrescaleProvider.h"

#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
#include "DataFormats/L1GlobalTrigger/interface/L1GtTriggerMenuLite.h"

class L1GtTriggerMenuLite;

namespace edm {
class ConsumesCollector;
class Event;
class EventSetup;
class ParameterSet;
class Run;
class TriggerResults;
}

class PrescaleWeightProvider {

bool configured_;
bool init_;
HLTConfigProvider hltConfig_;
std::unique_ptr<HLTPrescaleProvider> hltPrescaleProvider_;
edm::Handle< L1GtTriggerMenuLite > triggerMenuLite_;

std::vector< std::string > l1SeedPaths_;
Expand All @@ -51,18 +66,34 @@ class PrescaleWeightProvider {

public:

PrescaleWeightProvider( const edm::ParameterSet & config, edm::ConsumesCollector && iC ) : PrescaleWeightProvider( config, iC ) {}; // to be called from the ED module's c'tor
PrescaleWeightProvider( const edm::ParameterSet & config, edm::ConsumesCollector & iC ); // to be called from the ED module's c'tor
// The constructor must be called from the ED module's c'tor
template <typename T>
PrescaleWeightProvider( const edm::ParameterSet & config, edm::ConsumesCollector && iC, T& module );

template <typename T>
PrescaleWeightProvider( const edm::ParameterSet & config, edm::ConsumesCollector & iC, T& module );

~PrescaleWeightProvider() {}

void initRun( const edm::Run & run, const edm::EventSetup & setup ); // to be called from the ED module's beginRun() method
int prescaleWeight ( const edm::Event & event, const edm::EventSetup & setup ); // to be called from the ED module's event loop method

private:

PrescaleWeightProvider( const edm::ParameterSet & config, edm::ConsumesCollector & iC );

void parseL1Seeds( const std::string & l1Seeds );

};

template <typename T>
PrescaleWeightProvider::PrescaleWeightProvider( const edm::ParameterSet & config, edm::ConsumesCollector && iC, T& module ) :
PrescaleWeightProvider( config, iC, module ) {
}

template <typename T>
PrescaleWeightProvider::PrescaleWeightProvider( const edm::ParameterSet & config, edm::ConsumesCollector & iC, T& module ) :
PrescaleWeightProvider( config, iC ) {
hltPrescaleProvider_.reset(new HLTPrescaleProvider(config, iC, module));
}
#endif