Skip to content

Commit

Permalink
Merge pull request #28926 from wddgit/esConsumesGEMAndL1T
Browse files Browse the repository at this point in the history
EventSetup consumes migration 1 GEM module and 1 L1T module
  • Loading branch information
cmsbuild committed Feb 26, 2020
2 parents e618dce + b68094f commit d4b8008
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 93 deletions.
12 changes: 6 additions & 6 deletions EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.cc
Expand Up @@ -4,12 +4,10 @@
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Run.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Utilities/interface/Transition.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
#include "DataFormats/FEDRawData/interface/FEDNumbering.h"

#include "EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.h"
Expand All @@ -20,6 +18,9 @@ GEMRawToDigiModule::GEMRawToDigiModule(const edm::ParameterSet& pset)
: fed_token(consumes<FEDRawDataCollection>(pset.getParameter<edm::InputTag>("InputLabel"))),
useDBEMap_(pset.getParameter<bool>("useDBEMap")),
unPackStatusDigis_(pset.getParameter<bool>("unPackStatusDigis")) {
if (useDBEMap_) {
gemEMapToken_ = esConsumes<GEMeMap, GEMeMapRcd, edm::Transition::BeginRun>();
}
produces<GEMDigiCollection>();
if (unPackStatusDigis_) {
produces<GEMVfatStatusDigiCollection>("vfatStatus");
Expand All @@ -40,9 +41,8 @@ void GEMRawToDigiModule::fillDescriptions(edm::ConfigurationDescriptions& descri
std::shared_ptr<GEMROMapping> GEMRawToDigiModule::globalBeginRun(edm::Run const&, edm::EventSetup const& iSetup) const {
auto gemROmap = std::make_shared<GEMROMapping>();
if (useDBEMap_) {
edm::ESHandle<GEMeMap> gemEMapRcd;
iSetup.get<GEMeMapRcd>().get(gemEMapRcd);
auto gemEMap = std::make_unique<GEMeMap>(*(gemEMapRcd.product()));
GEMeMap const& eMap = iSetup.getData(gemEMapToken_);
auto gemEMap = std::make_unique<GEMeMap>(eMap);
gemEMap->convert(*gemROmap);
gemEMap.reset();
} else {
Expand Down
8 changes: 2 additions & 6 deletions EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.h
Expand Up @@ -6,10 +6,9 @@
* \author J. Lee - UoS
*/

#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Framework/interface/global/EDProducer.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"

Expand All @@ -26,10 +25,6 @@
#include "EventFilter/GEMRawToDigi/interface/AMC13Event.h"
#include "EventFilter/GEMRawToDigi/interface/VFATdata.h"

namespace edm {
class ConfigurationDescriptions;
}

class GEMRawToDigiModule : public edm::global::EDProducer<edm::RunCache<GEMROMapping> > {
public:
/// Constructor
Expand All @@ -45,6 +40,7 @@ class GEMRawToDigiModule : public edm::global::EDProducer<edm::RunCache<GEMROMap

private:
edm::EDGetTokenT<FEDRawDataCollection> fed_token;
edm::ESGetToken<GEMeMap, GEMeMapRcd> gemEMapToken_;
bool useDBEMap_;
bool unPackStatusDigis_;
};
Expand Down
27 changes: 15 additions & 12 deletions L1Trigger/L1TMuonOverlap/interface/AngleConverter.h
@@ -1,21 +1,20 @@
#ifndef ANGLECONVERTER_H
#define ANGLECONVERTER_H

#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/FrameworkfwdMostUsed.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"

#include "DataFormats/L1TMuon/interface/RegionalMuonCandFwd.h"

#include <memory>
#include "Geometry/CSCGeometry/interface/CSCGeometry.h"
#include "Geometry/DTGeometry/interface/DTGeometry.h"
#include "Geometry/RPCGeometry/interface/RPCGeometry.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"

namespace edm {
class EventSetup;
}
#include <memory>

class RPCGeometry;
class CSCGeometry;
class CSCLayer;
class DTGeometry;

class L1MuDTChambPhDigi;
class L1MuDTChambThContainer;
Expand All @@ -26,7 +25,7 @@ class RPCDetId;

class AngleConverter {
public:
AngleConverter();
AngleConverter(edm::ConsumesCollector &, bool getDuringEvent = true);
~AngleConverter();

///Update the Geometry with current Event Setup
Expand Down Expand Up @@ -62,11 +61,15 @@ class AngleConverter {
///Find BTI group
const int findBTIgroup(const L1MuDTChambPhDigi &aDigi, const L1MuDTChambThContainer *dtThDigis);

edm::ESGetToken<RPCGeometry, MuonGeometryRecord> rpcGeometryToken_;
edm::ESGetToken<CSCGeometry, MuonGeometryRecord> cscGeometryToken_;
edm::ESGetToken<DTGeometry, MuonGeometryRecord> dtGeometryToken_;

// pointers to the current geometry records
unsigned long long _geom_cache_id;
edm::ESHandle<RPCGeometry> _georpc;
edm::ESHandle<CSCGeometry> _geocsc;
edm::ESHandle<DTGeometry> _geodt;
RPCGeometry const *_georpc;
CSCGeometry const *_geocsc;
DTGeometry const *_geodt;

///Number of phi bins along 2Pi.
unsigned int nPhiBins;
Expand Down
19 changes: 10 additions & 9 deletions L1Trigger/L1TMuonOverlap/interface/OMTFReconstruction.h
Expand Up @@ -3,14 +3,16 @@

#include "xercesc/util/XercesDefs.hpp"

#include "CondFormats/DataRecord/interface/L1TMuonOverlapParamsRcd.h"
#include "CondFormats/L1TObjects/interface/L1TMuonOverlapParams.h"

#include "DataFormats/L1TMuon/interface/RegionalMuonCand.h"
#include "DataFormats/L1TMuon/interface/RegionalMuonCandFwd.h"

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/FrameworkfwdMostUsed.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "DataFormats/Common/interface/Handle.h"

#include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhContainer.h"
#include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambThContainer.h"
Expand All @@ -21,7 +23,6 @@
#include "L1Trigger/L1TMuonOverlap/interface/OMTFSorter.h"
#include "L1Trigger/L1TMuonOverlap/interface/GhostBuster.h"

class L1TMuonOverlapParams;
class OMTFProcessor;
class OMTFConfiguration;
class OMTFConfigMaker;
Expand All @@ -35,17 +36,15 @@ namespace XERCES_CPP_NAMESPACE {

class OMTFReconstruction {
public:
OMTFReconstruction();

OMTFReconstruction(const edm::ParameterSet &);
OMTFReconstruction(const edm::ParameterSet &, edm::ConsumesCollector &&);

~OMTFReconstruction();

void beginJob();

void endJob();

void beginRun(edm::Run const &run, edm::EventSetup const &iSetup);
void beginRun(edm::Run const &, edm::EventSetup const &);

std::unique_ptr<l1t::RegionalMuonCandBxCollection> reconstruct(const edm::Event &, const edm::EventSetup &);

Expand All @@ -57,6 +56,8 @@ class OMTFReconstruction {
edm::Handle<CSCCorrelatedLCTDigiCollection> cscDigis;
edm::Handle<RPCDigiCollection> rpcDigis;

edm::ESGetToken<L1TMuonOverlapParams, L1TMuonOverlapParamsRcd> l1TMuonOverlapParamsToken_;

void loadAndFilterDigis(const edm::Event &);

void getProcessorCandidates(unsigned int iProcessor,
Expand Down
14 changes: 6 additions & 8 deletions L1Trigger/L1TMuonOverlap/interface/OMTFinputMaker.h
Expand Up @@ -7,24 +7,22 @@

#include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhContainer.h"
#include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambThContainer.h"
#include "DataFormats/L1TMuon/interface/RegionalMuonCandFwd.h"
#include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h"
#include "DataFormats/RPCDigi/interface/RPCDigiCollection.h"
#include "L1Trigger/L1TMuonOverlap/interface/AngleConverter.h"
#include "FWCore/Framework/interface/FrameworkfwdMostUsed.h"
#include "L1Trigger/L1TMuonOverlap/interface/OMTFinput.h"

class AngleConverter;
class OMTFConfiguration;

namespace edm {
class EventSetup;
}

class OMTFinputMaker {
public:
OMTFinputMaker();
OMTFinputMaker(edm::ConsumesCollector &, bool getDuringEvent = true);

~OMTFinputMaker();

void initialize(const edm::EventSetup &es, const OMTFConfiguration *);
void initialize(const edm::EventSetup &, const OMTFConfiguration *);

///Method translating trigger digis into input matrix with global phi coordinates
OMTFinput buildInputForProcessor(const L1MuDTChambPhContainer *dtPhDigis,
Expand Down Expand Up @@ -70,7 +68,7 @@ class OMTFinputMaker {
///Result is modulo allowed number of hits per chamber
unsigned int getInputNumber(unsigned int rawId, unsigned int iProcessor, l1t::tftype type);

AngleConverter myAngleConverter;
std::unique_ptr<AngleConverter> myAngleConverter;

const OMTFConfiguration *myOmtfConfig;

Expand Down
14 changes: 6 additions & 8 deletions L1Trigger/L1TMuonOverlap/plugins/L1TMuonOverlapTrackProducer.cc
Expand Up @@ -2,11 +2,9 @@
#include <strstream>
#include <vector>

#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "DataFormats/L1TMuon/interface/RegionalMuonCand.h"
#include "DataFormats/L1TMuon/interface/RegionalMuonCandFwd.h"

#include "CondFormats/DataRecord/interface/L1TMuonOverlapParamsRcd.h"
#include "CondFormats/L1TObjects/interface/L1TMuonOverlapParams.h"

Expand All @@ -19,13 +17,13 @@
#include "L1Trigger/RPCTrigger/interface/RPCConst.h"

L1TMuonOverlapTrackProducer::L1TMuonOverlapTrackProducer(const edm::ParameterSet& cfg)
: theConfig(cfg), m_Reconstruction(cfg) {
: m_Reconstruction(cfg, consumesCollector()) {
produces<l1t::RegionalMuonCandBxCollection>("OMTF");

inputTokenDTPh = consumes<L1MuDTChambPhContainer>(theConfig.getParameter<edm::InputTag>("srcDTPh"));
inputTokenDTTh = consumes<L1MuDTChambThContainer>(theConfig.getParameter<edm::InputTag>("srcDTTh"));
inputTokenCSC = consumes<CSCCorrelatedLCTDigiCollection>(theConfig.getParameter<edm::InputTag>("srcCSC"));
inputTokenRPC = consumes<RPCDigiCollection>(theConfig.getParameter<edm::InputTag>("srcRPC"));
inputTokenDTPh = consumes<L1MuDTChambPhContainer>(cfg.getParameter<edm::InputTag>("srcDTPh"));
inputTokenDTTh = consumes<L1MuDTChambThContainer>(cfg.getParameter<edm::InputTag>("srcDTTh"));
inputTokenCSC = consumes<CSCCorrelatedLCTDigiCollection>(cfg.getParameter<edm::InputTag>("srcCSC"));
inputTokenRPC = consumes<RPCDigiCollection>(cfg.getParameter<edm::InputTag>("srcRPC"));
}
/////////////////////////////////////////////////////
/////////////////////////////////////////////////////
Expand Down
11 changes: 4 additions & 7 deletions L1Trigger/L1TMuonOverlap/plugins/L1TMuonOverlapTrackProducer.h
Expand Up @@ -6,11 +6,10 @@
#include "DataFormats/L1TMuon/interface/RegionalMuonCand.h"
#include "DataFormats/L1TMuon/interface/RegionalMuonCandFwd.h"

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/one/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/FrameworkfwdMostUsed.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/one/EDProducer.h"

#include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhContainer.h"
#include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambThContainer.h"
Expand Down Expand Up @@ -43,14 +42,12 @@ class L1TMuonOverlapTrackProducer : public edm::one::EDProducer<edm::one::WatchR

void endJob() override;

void beginRun(edm::Run const& run, edm::EventSetup const& iSetup) override;
void beginRun(edm::Run const&, edm::EventSetup const&) override;
void endRun(edm::Run const&, edm::EventSetup const&) override {}

void produce(edm::Event&, const edm::EventSetup&) override;
void produce(edm::Event&, edm::EventSetup const&) override;

private:
edm::ParameterSet theConfig;

edm::EDGetTokenT<L1MuDTChambPhContainer> inputTokenDTPh;
edm::EDGetTokenT<L1MuDTChambThContainer> inputTokenDTTh;
edm::EDGetTokenT<CSCCorrelatedLCTDigiCollection> inputTokenCSC;
Expand Down
4 changes: 3 additions & 1 deletion L1Trigger/L1TMuonOverlap/plugins/OMTFPatternMaker.cc
@@ -1,5 +1,6 @@
#include <iostream>

#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "CondFormats/DataRecord/interface/L1TMuonOverlapParamsRcd.h"
Expand Down Expand Up @@ -27,7 +28,8 @@ OMTFPatternMaker::OMTFPatternMaker(const edm::ParameterSet& cfg)
inputTokenRPC = consumes<RPCDigiCollection>(theConfig.getParameter<edm::InputTag>("srcRPC"));
inputTokenSimHit = consumes<edm::SimTrackContainer>(theConfig.getParameter<edm::InputTag>("g4SimTrackSrc"));

myInputMaker = new OMTFinputMaker();
edm::ConsumesCollector consumesColl(consumesCollector());
myInputMaker = new OMTFinputMaker(consumesColl);

makeGoldenPatterns = theConfig.getParameter<bool>("makeGoldenPatterns");
makeConnectionsMaps = theConfig.getParameter<bool>("makeConnectionsMaps");
Expand Down
24 changes: 16 additions & 8 deletions L1Trigger/L1TMuonOverlap/src/AngleConverter.cc
@@ -1,16 +1,14 @@
#include "L1Trigger/L1TMuonOverlap/interface/AngleConverter.h"
#include "L1Trigger/L1TMuonOverlap/interface/OMTFConfiguration.h"

#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"
#include "FWCore/Utilities/interface/Transition.h"

#include "Geometry/CSCGeometry/interface/CSCGeometry.h"
#include "L1Trigger/CSCCommonTrigger/interface/CSCConstants.h"
#include "L1Trigger/CSCCommonTrigger/interface/CSCPatternLUT.h"

#include "Geometry/DTGeometry/interface/DTGeometry.h"
#include "L1Trigger/DTUtilities/interface/DTTrigGeom.h"
#include "Geometry/RPCGeometry/interface/RPCGeometry.h"

#include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h"
#include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhDigi.h"
Expand Down Expand Up @@ -150,7 +148,17 @@ namespace {

} // namespace

AngleConverter::AngleConverter() : _geom_cache_id(0ULL) {}
AngleConverter::AngleConverter(edm::ConsumesCollector &iC, bool getDuringEvent) : _geom_cache_id(0ULL) {
if (getDuringEvent) {
rpcGeometryToken_ = iC.esConsumes<RPCGeometry, MuonGeometryRecord>();
cscGeometryToken_ = iC.esConsumes<CSCGeometry, MuonGeometryRecord>();
dtGeometryToken_ = iC.esConsumes<DTGeometry, MuonGeometryRecord>();
} else {
rpcGeometryToken_ = iC.esConsumes<RPCGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
cscGeometryToken_ = iC.esConsumes<CSCGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
dtGeometryToken_ = iC.esConsumes<DTGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
}
}
///////////////////////////////////////
///////////////////////////////////////
AngleConverter::~AngleConverter() {}
Expand All @@ -160,9 +168,9 @@ void AngleConverter::checkAndUpdateGeometry(const edm::EventSetup &es, unsigned
const MuonGeometryRecord &geom = es.get<MuonGeometryRecord>();
unsigned long long geomid = geom.cacheIdentifier();
if (_geom_cache_id != geomid) {
geom.get(_georpc);
geom.get(_geocsc);
geom.get(_geodt);
_georpc = &geom.get(rpcGeometryToken_);
_geocsc = &geom.get(cscGeometryToken_);
_geodt = &geom.get(dtGeometryToken_);
_geom_cache_id = geomid;
}

Expand Down

0 comments on commit d4b8008

Please sign in to comment.