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

Migrate GEM/CSC validation to esConsumes #31102

Merged
merged 4 commits into from
Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "L1Trigger/CSCTriggerPrimitives/interface/CSCTriggerPrimitivesBuilder.h"

#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "DataFormats/CSCDigi/interface/CSCALCTDigiCollection.h"
Expand Down Expand Up @@ -89,8 +88,7 @@ CSCTriggerPrimitivesProducer::~CSCTriggerPrimitivesProducer() {}

void CSCTriggerPrimitivesProducer::produce(edm::Event& ev, const edm::EventSetup& setup) {
// get the csc geometry
edm::ESHandle<CSCGeometry> h = setup.getHandle(cscToken_);
builder_->setCSCGeometry(&*h);
builder_->setCSCGeometry(&setup.getData(cscToken_));

// get the gem geometry if it's there
edm::ESHandle<GEMGeometry> h_gem = setup.getHandle(gemToken_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@
#include "DataFormats/GEMDigi/interface/GEMPadDigiCollection.h"
#include "DataFormats/GEMDigi/interface/GEMPadDigiClusterCollection.h"
#include "L1Trigger/CSCTriggerPrimitives/interface/CSCTriggerPrimitivesBuilder.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"
#include "CondFormats/DataRecord/interface/CSCBadChambersRcd.h"
#include "Geometry/GEMGeometry/interface/GEMGeometry.h"
#include "CondFormats/DataRecord/interface/CSCDBL1TPParametersRcd.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"
#include "Geometry/GEMGeometry/interface/GEMGeometry.h"
#include "Geometry/CSCGeometry/interface/CSCGeometry.h"

// temporarily switch to a "one" module with a CSCTriggerPrimitivesBuilder data member
class CSCTriggerPrimitivesProducer : public edm::one::EDProducer<> {
Expand Down
13 changes: 7 additions & 6 deletions RecoLocalMuon/CSCEfficiency/src/CSCEfficiency.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Routine to calculate CSC efficiencies
* Routine to calculate CSC efficiencies
* Comments about the program logic are denoted by //----
*
*
* Stoyan Stoynev, Northwestern University.
*/

Expand Down Expand Up @@ -74,8 +74,7 @@ bool CSCEfficiency::filter(edm::Event &event, const edm::EventSetup &eventSetup)
//---- Get the CSC Geometry :
if (printalot)
printf("\tget the CSC geometry.\n");
edm::ESHandle<CSCGeometry> cscGeom;
eventSetup.get<MuonGeometryRecord>().get(cscGeom);
edm::ESHandle<CSCGeometry> cscGeom = eventSetup.getHandle(geomToken_);

// use theTrackingGeometry instead of cscGeom?
edm::ESHandle<GlobalTrackingGeometry> theTrackingGeometry;
Expand Down Expand Up @@ -1685,6 +1684,8 @@ CSCEfficiency::CSCEfficiency(const edm::ParameterSet &pset) {
tk_token = consumes<edm::View<reco::Track> >(pset.getParameter<edm::InputTag>("tracksTag"));
sh_token = consumes<edm::PSimHitContainer>(pset.getParameter<edm::InputTag>("simHitTag"));

geomToken_ = esConsumes<CSCGeometry, MuonGeometryRecord>();

edm::ParameterSet serviceParameters = pset.getParameter<edm::ParameterSet>("ServiceParameters");
// maybe use the service for getting magnetic field, propagators, etc. ...
theService = new MuonServiceProxy(serviceParameters, consumesCollector());
Expand Down Expand Up @@ -1942,11 +1943,11 @@ CSCEfficiency::CSCEfficiency(const edm::ParameterSet &pset) {
//
/*
sprintf(SpecName,"Sim_Rechits_each_Ch%d",iChamber);
ChHist[ec][st][rg][iChamber-FirstCh].SimRechits_each =
ChHist[ec][st][rg][iChamber-FirstCh].SimRechits_each =
new TH1F(SpecName,"Existing RecHit (Sim), each;layers (1-6);entries",nLayer_bins,Layer_min,Layer_max);
//
sprintf(SpecName,"Sim_Simhits_each_Ch%d",iChamber);
ChHist[ec][st][rg][iChamber-FirstCh].SimSimhits_each =
ChHist[ec][st][rg][iChamber-FirstCh].SimSimhits_each =
new TH1F(SpecName,"Existing SimHit (Sim), each;layers (1-6);entries",nLayer_bins,Layer_min,Layer_max);
*/
theFile->cd();
Expand Down
41 changes: 12 additions & 29 deletions RecoLocalMuon/CSCEfficiency/src/CSCEfficiency.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,40 @@

/** \class CSCEfficiency
*
* Efficiency calculations
* Efficiency calculations
* Stoyan Stoynev, Northwestern University
*/

// how many of the headers below are not needed?...
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDFilter.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include <FWCore/Utilities/interface/InputTag.h>
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"

#include "DataFormats/CSCDigi/interface/CSCALCTDigi.h"
#include "DataFormats/CSCDigi/interface/CSCALCTDigiCollection.h"
#include "DataFormats/CSCDigi/interface/CSCCLCTDigi.h"
#include "DataFormats/CSCDigi/interface/CSCCLCTDigiCollection.h"
#include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h"
#include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h"
#include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h"
#include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h"
#include "DataFormats/CSCDigi/interface/CSCComparatorDigiCollection.h"

#include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h"
#include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"

#include "DataFormats/MuonDetId/interface/CSCDetId.h"
#include <DataFormats/CSCRecHit/interface/CSCSegmentCollection.h>

#include "Geometry/CSCGeometry/interface/CSCGeometry.h"
#include <Geometry/CSCGeometry/interface/CSCChamber.h>
#include <Geometry/CSCGeometry/interface/CSCLayer.h>
#include <Geometry/CSCGeometry/interface/CSCLayerGeometry.h>
#include <Geometry/Records/interface/MuonGeometryRecord.h>
#include "Geometry/Records/interface/MuonGeometryRecord.h"

#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
#include "DataFormats/GeometryVector/interface/GlobalVector.h"
#include "DataFormats/GeometryVector/interface/LocalPoint.h"
#include "DataFormats/GeometryVector/interface/LocalVector.h"

#include "DataFormats/CSCDigi/interface/CSCWireDigi.h"
#include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h"
#include "DataFormats/CSCDigi/interface/CSCStripDigi.h"
#include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h"

#include "DataFormats/CSCDigi/interface/CSCComparatorDigi.h"
#include "DataFormats/CSCDigi/interface/CSCComparatorDigiCollection.h"

#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"

#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
Expand All @@ -68,7 +49,7 @@
#include "TrackingTools/DetLayers/interface/NavigationDirection.h"
#include "TrackingTools/GeomPropagators/interface/Propagator.h"

#include <RecoMuon/TrackingTools/interface/MuonServiceProxy.h>
#include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
#include "RecoMuon/TrackingTools/interface/MuonPatternRecoDumper.h"

#include "DataFormats/Common/interface/TriggerResults.h"
Expand Down Expand Up @@ -145,6 +126,8 @@ class CSCEfficiency : public edm::EDFilter {

edm::EDGetTokenT<edm::TriggerResults> ht_token;

edm::ESGetToken<CSCGeometry, MuonGeometryRecord> geomToken_;

//
unsigned int printout_NEvents;
bool isData;
Expand Down
5 changes: 3 additions & 2 deletions RecoLocalMuon/CSCValidation/src/CSCValidation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ CSCValidation::CSCValidation(const ParameterSet& pset) {
// setup trees to hold global position data for rechits and segments
if (writeTreeToFile)
histos->setupTrees();

geomToken_ = esConsumes<CSCGeometry, MuonGeometryRecord>();
}

//////////////////
Expand Down Expand Up @@ -195,8 +197,7 @@ void CSCValidation::analyze(const Event& event, const EventSetup& eventSetup) {
}

// Get the CSC Geometry :
edm::ESHandle<CSCGeometry> cscGeom;
eventSetup.get<MuonGeometryRecord>().get(cscGeom);
edm::ESHandle<CSCGeometry> cscGeom = eventSetup.getHandle(geomToken_);

// Get the RecHits collection :
edm::Handle<CSCRecHit2DCollection> recHits;
Expand Down
17 changes: 3 additions & 14 deletions RecoLocalMuon/CSCValidation/src/CSCValidation.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,18 @@
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/EDFilter.h"
#include "FWCore/Framework/interface/Event.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/ESGetToken.h"

#include "DataFormats/CSCDigi/interface/CSCWireDigi.h"
#include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h"
#include "DataFormats/CSCDigi/interface/CSCStripDigi.h"
#include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h"
#include "DataFormats/CSCDigi/interface/CSCComparatorDigi.h"
#include "DataFormats/CSCDigi/interface/CSCComparatorDigiCollection.h"
#include "DataFormats/CSCDigi/interface/CSCALCTDigi.h"
#include "DataFormats/CSCDigi/interface/CSCALCTDigiCollection.h"
#include "DataFormats/CSCDigi/interface/CSCCLCTDigi.h"
#include "DataFormats/CSCDigi/interface/CSCCLCTDigiCollection.h"
#include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h"
#include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h"

#include "EventFilter/CSCRawToDigi/interface/CSCDCCEventData.h"
Expand All @@ -64,9 +57,7 @@
#include "DataFormats/FEDRawData/interface/FEDNumbering.h"
#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"

#include "DataFormats/MuonDetId/interface/CSCDetId.h"
#include <DataFormats/CSCRecHit/interface/CSCRecHit2D.h>
#include <DataFormats/CSCRecHit/interface/CSCSegmentCollection.h>
#include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
#include "DataFormats/MuonDetId/interface/RPCDetId.h"

#include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutRecord.h"
Expand All @@ -75,9 +66,6 @@
#include "FWCore/Common/interface/TriggerNames.h"

#include "Geometry/CSCGeometry/interface/CSCGeometry.h"
#include "Geometry/CSCGeometry/interface/CSCChamber.h"
#include "Geometry/CSCGeometry/interface/CSCLayer.h"
#include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"

#include "DataFormats/TrackReco/interface/Track.h"
Expand Down Expand Up @@ -258,6 +246,7 @@ class CSCValidation : public edm::EDAnalyzer {
edm::EDGetTokenT<edm::TriggerResults> tr_token;
edm::EDGetTokenT<reco::TrackCollection> sa_token;
edm::EDGetTokenT<edm::PSimHitContainer> sh_token;
edm::ESGetToken<CSCGeometry, MuonGeometryRecord> geomToken_;

// module on/off switches
bool makeOccupancyPlots;
Expand Down
10 changes: 3 additions & 7 deletions Validation/CSCRecHits/src/CSCRecHitValidation.cc
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
#include "DQMServices/Core/interface/DQMStore.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "Geometry/CSCGeometry/interface/CSCGeometry.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"
#include "Validation/CSCRecHits/src/CSCRecHitValidation.h"
#include <DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h>
#include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h"

CSCRecHitValidation::CSCRecHitValidation(const edm::ParameterSet &ps)
: theSimHitMap(ps.getParameter<edm::InputTag>("simHitsTag"), consumesCollector()),
theCSCGeometry(nullptr),
the2DValidation(nullptr),
theSegmentValidation(nullptr) {
the2DValidation = new CSCRecHit2DValidation(ps.getParameter<edm::InputTag>("recHitLabel"), consumesCollector());
theSegmentValidation = new CSCSegmentValidation(ps.getParameter<edm::InputTag>("segmentLabel"), consumesCollector());
geomToken_ = esConsumes<CSCGeometry, MuonGeometryRecord>();
}

CSCRecHitValidation::~CSCRecHitValidation() {
Expand All @@ -31,9 +29,7 @@ void CSCRecHitValidation::analyze(const edm::Event &e, const edm::EventSetup &ev
theSimHitMap.fill(e);

// find the geometry & conditions for this event
edm::ESHandle<CSCGeometry> hGeom;
eventSetup.get<MuonGeometryRecord>().get(hGeom);
theCSCGeometry = &*hGeom;
const CSCGeometry *theCSCGeometry = &eventSetup.getData(geomToken_);

the2DValidation->setGeometry(theCSCGeometry);
the2DValidation->setSimHitMap(&theSimHitMap);
Expand Down
11 changes: 6 additions & 5 deletions Validation/CSCRecHits/src/CSCRecHitValidation.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

// user include files

#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Utilities/interface/EDGetToken.h"

#include <DQMServices/Core/interface/DQMEDAnalyzer.h>
#include <DQMServices/Core/interface/DQMStore.h>
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "DQMServices/Core/interface/DQMStore.h"

#include "Geometry/CSCGeometry/interface/CSCGeometry.h"
#include "Geometry/GEMGeometry/interface/GEMGeometry.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"
#include "SimMuon/MCTruth/interface/PSimHitMap.h"
#include "Validation/CSCRecHits/src/CSCRecHit2DValidation.h"
#include "Validation/CSCRecHits/src/CSCSegmentValidation.h"
Expand All @@ -24,7 +25,7 @@ class CSCRecHitValidation : public DQMEDAnalyzer {

private:
PSimHitMap theSimHitMap;
const CSCGeometry *theCSCGeometry;
edm::ESGetToken<CSCGeometry, MuonGeometryRecord> geomToken_;

CSCRecHit2DValidation *the2DValidation;
CSCSegmentValidation *theSegmentValidation;
Expand Down
1 change: 0 additions & 1 deletion Validation/MuonCSCDigis/interface/CSCBaseValidation.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// user include files

#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Utilities/interface/InputTag.h"

Expand Down
2 changes: 1 addition & 1 deletion Validation/MuonCSCDigis/interface/CSCStubMatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class CSCStubMatcher {
std::shared_ptr<CSCDigiMatcher> cscDigiMatcher_;
std::shared_ptr<GEMDigiMatcher> gemDigiMatcher_;

edm::ESHandle<CSCGeometry> csc_geom_;
edm::ESGetToken<CSCGeometry, MuonGeometryRecord> geomToken_;
const CSCGeometry* cscGeometry_;

// all stubs (not necessarily matching) in crossed chambers with digis
Expand Down
7 changes: 2 additions & 5 deletions Validation/MuonCSCDigis/plugins/CSCDigiValidation.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "Validation/MuonCSCDigis/plugins/CSCDigiValidation.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "Geometry/CSCGeometry/interface/CSCGeometry.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"
#include "Validation/MuonCSCDigis/interface/CSCALCTDigiValidation.h"
#include "Validation/MuonCSCDigis/interface/CSCCLCTDigiValidation.h"
#include "Validation/MuonCSCDigis/interface/CSCComparatorDigiValidation.h"
Expand Down Expand Up @@ -37,6 +35,7 @@ CSCDigiValidation::CSCDigiValidation(const edm::ParameterSet &ps)
theWireDigiValidation->setSimHitMap(&theSimHitMap);
theComparatorDigiValidation->setSimHitMap(&theSimHitMap);
}
geomToken_ = esConsumes<CSCGeometry, MuonGeometryRecord>();
}

CSCDigiValidation::~CSCDigiValidation() {}
Expand All @@ -56,9 +55,7 @@ void CSCDigiValidation::analyze(const edm::Event &e, const edm::EventSetup &even
theSimHitMap.fill(e);

// find the geometry & conditions for this event
edm::ESHandle<CSCGeometry> hGeom;
eventSetup.get<MuonGeometryRecord>().get(hGeom);
const CSCGeometry *pGeom = &*hGeom;
const CSCGeometry *pGeom = &eventSetup.getData(geomToken_);

theStripDigiValidation->setGeometry(pGeom);
theWireDigiValidation->setGeometry(pGeom);
Expand Down
5 changes: 4 additions & 1 deletion Validation/MuonCSCDigis/plugins/CSCDigiValidation.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

// user include files

#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Utilities/interface/ESGetToken.h"

#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "DQMServices/Core/interface/DQMStore.h"

#include "Geometry/CSCGeometry/interface/CSCGeometry.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"
#include "SimMuon/MCTruth/interface/PSimHitMap.h"

class CSCStripDigiValidation;
Expand All @@ -35,6 +36,8 @@ class CSCDigiValidation : public DQMEDAnalyzer {
std::unique_ptr<CSCComparatorDigiValidation> theComparatorDigiValidation;
std::unique_ptr<CSCALCTDigiValidation> theALCTDigiValidation;
std::unique_ptr<CSCCLCTDigiValidation> theCLCTDigiValidation;

edm::ESGetToken<CSCGeometry, MuonGeometryRecord> geomToken_;
};

#endif
9 changes: 3 additions & 6 deletions Validation/MuonCSCDigis/src/CSCStubMatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ CSCStubMatcher::CSCStubMatcher(const edm::ParameterSet& pSet, edm::ConsumesColle
alctToken_ = iC.consumes<CSCALCTDigiCollection>(cscALCT.getParameter<edm::InputTag>("inputTag"));
lctToken_ = iC.consumes<CSCCorrelatedLCTDigiCollection>(cscLCT.getParameter<edm::InputTag>("inputTag"));
mplctToken_ = iC.consumes<CSCCorrelatedLCTDigiCollection>(cscMPLCT.getParameter<edm::InputTag>("inputTag"));

geomToken_ = iC.esConsumes<CSCGeometry, MuonGeometryRecord>();
}

void CSCStubMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
Expand All @@ -48,12 +50,7 @@ void CSCStubMatcher::init(const edm::Event& iEvent, const edm::EventSetup& iSetu
iEvent.getByToken(lctToken_, lctsH_);
iEvent.getByToken(mplctToken_, mplctsH_);

iSetup.get<MuonGeometryRecord>().get(csc_geom_);
if (csc_geom_.isValid()) {
cscGeometry_ = &*csc_geom_;
} else {
edm::LogError("CSCStubMatcher") << "+++ Info: CSC geometry is unavailable.";
}
cscGeometry_ = &iSetup.getData(geomToken_);
}

// do the matching
Expand Down
2 changes: 1 addition & 1 deletion Validation/MuonGEMDigis/interface/GEMDigiMatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class GEMDigiMatcher {

std::shared_ptr<GEMSimHitMatcher> muonSimHitMatcher_;

edm::ESHandle<GEMGeometry> gem_geom_;
edm::ESGetToken<GEMGeometry, MuonGeometryRecord> geomToken_;
const GEMGeometry* gemGeometry_;

template <class T>
Expand Down
Loading