Skip to content

Commit

Permalink
Merge pull request #30598 from JamminJones/fixRecoLocalMuonCSCRecHitD
Browse files Browse the repository at this point in the history
added esConsumes to modules in RecoLocalMuon/CSCRecHitD
  • Loading branch information
cmsbuild committed Jul 13, 2020
2 parents b2aff51 + 86792e2 commit 3368964
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 47 deletions.
28 changes: 26 additions & 2 deletions CalibMuon/CSCCalibration/interface/CSCConditions.h
@@ -1,15 +1,25 @@
#ifndef CSCCalibration_CSCConditions_h
#define CSCCalibration_CSCConditions_h

#include "CondFormats/DataRecord/interface/CSCChamberTimeCorrectionsRcd.h"
#include "CondFormats/DataRecord/interface/CSCDBChipSpeedCorrectionRcd.h"
#include "CondFormats/DataRecord/interface/CSCDBCrosstalkRcd.h"
#include "CondFormats/DataRecord/interface/CSCDBGasGainCorrectionRcd.h"
#include "CondFormats/DataRecord/interface/CSCDBNoiseMatrixRcd.h"
#include "CondFormats/DataRecord/interface/CSCDBPedestalsRcd.h"
#include "CondFormats/CSCObjects/interface/CSCDBNoiseMatrix.h"
#include "CondFormats/DataRecord/interface/CSCBadStripsRcd.h"
#include "CondFormats/DataRecord/interface/CSCBadWiresRcd.h"
#include "CondFormats/DataRecord/interface/CSCDBGainsRcd.h"
#include "CalibMuon/CSCCalibration/interface/CSCChannelMapperRecord.h"
#include "CalibMuon/CSCCalibration/interface/CSCIndexerRecord.h"
#include "CondFormats/DataRecord/interface/CSCBadChambersRcd.h"
#include "DataFormats/MuonDetId/interface/CSCDetId.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ESWatcher.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"

#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
#include <bitset>
#include <vector>

Expand Down Expand Up @@ -47,7 +57,7 @@ class CSCChannelMapperBase;

class CSCConditions {
public:
explicit CSCConditions(const edm::ParameterSet &ps);
explicit CSCConditions(const edm::ParameterSet &ps, edm::ConsumesCollector);
~CSCConditions();

/// fetch database content via EventSetup
Expand Down Expand Up @@ -156,6 +166,20 @@ class CSCConditions {
edm::ESHandle<CSCIndexerBase> indexer_;
edm::ESHandle<CSCChannelMapperBase> mapper_;

//EventSetup Tokens for Handles
edm::ESGetToken<CSCDBGains, CSCDBGainsRcd> gainsToken_;
edm::ESGetToken<CSCDBCrosstalk, CSCDBCrosstalkRcd> crosstalkToken_;
edm::ESGetToken<CSCDBPedestals, CSCDBPedestalsRcd> pedestalsToken_;
edm::ESGetToken<CSCDBNoiseMatrix, CSCDBNoiseMatrixRcd> noiseMatrixToken_;
edm::ESGetToken<CSCBadStrips, CSCBadStripsRcd> badStripsToken_;
edm::ESGetToken<CSCBadWires, CSCBadWiresRcd> badWiresToken_;
edm::ESGetToken<CSCBadChambers, CSCBadChambersRcd> badChambersToken_;
edm::ESGetToken<CSCDBChipSpeedCorrection, CSCDBChipSpeedCorrectionRcd> chipCorrectionsToken_;
edm::ESGetToken<CSCChamberTimeCorrections, CSCChamberTimeCorrectionsRcd> chamberTimingCorrectionsToken_;
edm::ESGetToken<CSCDBGasGainCorrection, CSCDBGasGainCorrectionRcd> gasGainCorrectionsToken_;
edm::ESGetToken<CSCIndexerBase, CSCIndexerRecord> indexerToken_;
edm::ESGetToken<CSCChannelMapperBase, CSCChannelMapperRecord> mapperToken_;

// logical flags controlling some conditions data usage

bool readBadChannels_; // flag whether or not to even attempt reading bad
Expand Down
58 changes: 33 additions & 25 deletions CalibMuon/CSCCalibration/src/CSCConditions.cc
@@ -1,9 +1,6 @@

#include "CalibMuon/CSCCalibration/interface/CSCConditions.h"

#include "CalibMuon/CSCCalibration/interface/CSCChannelMapperRecord.h"
#include "CalibMuon/CSCCalibration/interface/CSCIndexerRecord.h"

#include "CalibMuon/CSCCalibration/interface/CSCChannelMapperBase.h"
#include "CalibMuon/CSCCalibration/interface/CSCIndexerBase.h"

Expand All @@ -14,27 +11,18 @@
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "CondFormats/DataRecord/interface/CSCChamberTimeCorrectionsRcd.h"
#include "CondFormats/DataRecord/interface/CSCDBChipSpeedCorrectionRcd.h"
#include "CondFormats/DataRecord/interface/CSCDBCrosstalkRcd.h"
#include "CondFormats/DataRecord/interface/CSCDBGasGainCorrectionRcd.h"
#include "CondFormats/DataRecord/interface/CSCDBNoiseMatrixRcd.h"
#include "CondFormats/DataRecord/interface/CSCDBPedestalsRcd.h"

#include "CondFormats/CSCObjects/interface/CSCChamberTimeCorrections.h"
#include "CondFormats/CSCObjects/interface/CSCDBChipSpeedCorrection.h"
#include "CondFormats/CSCObjects/interface/CSCDBCrosstalk.h"
#include "CondFormats/CSCObjects/interface/CSCDBGains.h"
#include "CondFormats/CSCObjects/interface/CSCDBGasGainCorrection.h"
#include "CondFormats/CSCObjects/interface/CSCDBPedestals.h"

#include "CondFormats/DataRecord/interface/CSCBadChambersRcd.h"

#include "CondFormats/CSCObjects/interface/CSCBadChambers.h"
#include "CondFormats/CSCObjects/interface/CSCBadStrips.h"
#include "CondFormats/CSCObjects/interface/CSCBadWires.h"

CSCConditions::CSCConditions(const edm::ParameterSet &ps)
CSCConditions::CSCConditions(const edm::ParameterSet &ps, edm::ConsumesCollector cc)
: theGains(),
theCrosstalk(),
thePedestals(),
Expand All @@ -59,37 +47,57 @@ CSCConditions::CSCConditions(const edm::ParameterSet &ps)
readBadChambers_ = ps.getParameter<bool>("readBadChambers");
useTimingCorrections_ = ps.getParameter<bool>("CSCUseTimingCorrections");
useGasGainCorrections_ = ps.getParameter<bool>("CSCUseGasGainCorrections");
indexerToken_ = cc.esConsumes<CSCIndexerBase, CSCIndexerRecord>();
mapperToken_ = cc.esConsumes<CSCChannelMapperBase, CSCChannelMapperRecord>();
gainsToken_ = cc.esConsumes<CSCDBGains, CSCDBGainsRcd>();
crosstalkToken_ = cc.esConsumes<CSCDBCrosstalk, CSCDBCrosstalkRcd>();
pedestalsToken_ = cc.esConsumes<CSCDBPedestals, CSCDBPedestalsRcd>();
noiseMatrixToken_ = cc.esConsumes<CSCDBNoiseMatrix, CSCDBNoiseMatrixRcd>();
if (useTimingCorrections()) {
chipCorrectionsToken_ = cc.esConsumes<CSCDBChipSpeedCorrection, CSCDBChipSpeedCorrectionRcd>();
chamberTimingCorrectionsToken_ = cc.esConsumes<CSCChamberTimeCorrections, CSCChamberTimeCorrectionsRcd>();
}
if (readBadChannels()) {
badStripsToken_ = cc.esConsumes<CSCBadStrips, CSCBadStripsRcd>();
badWiresToken_ = cc.esConsumes<CSCBadWires, CSCBadWiresRcd>();
}
if (readBadChambers()) {
badChambersToken_ = cc.esConsumes<CSCBadChambers, CSCBadChambersRcd>();
}
if (useGasGainCorrections()) {
gasGainCorrectionsToken_ = cc.esConsumes<CSCDBGasGainCorrection, CSCDBGasGainCorrectionRcd>();
}
}

CSCConditions::~CSCConditions() {}

void CSCConditions::initializeEvent(const edm::EventSetup &es) {
// Algorithms
es.get<CSCIndexerRecord>().get(indexer_);
es.get<CSCChannelMapperRecord>().get(mapper_);
indexer_ = es.getHandle(indexerToken_);
mapper_ = es.getHandle(mapperToken_);

// Strip gains
es.get<CSCDBGainsRcd>().get(theGains);
theGains = es.getHandle(gainsToken_);
// Strip X-talk
es.get<CSCDBCrosstalkRcd>().get(theCrosstalk);
theCrosstalk = es.getHandle(crosstalkToken_);
// Strip pedestals
es.get<CSCDBPedestalsRcd>().get(thePedestals);
thePedestals = es.getHandle(pedestalsToken_);
// Strip autocorrelation noise matrix
es.get<CSCDBNoiseMatrixRcd>().get(theNoiseMatrix);
theNoiseMatrix = es.getHandle(noiseMatrixToken_);

if (useTimingCorrections()) {
// Buckeye chip speeds
es.get<CSCDBChipSpeedCorrectionRcd>().get(theChipCorrections);
theChipCorrections = es.getHandle(chipCorrectionsToken_);
// Cable lengths from chambers to peripheral crate and additional chamber
// level timing correction
es.get<CSCChamberTimeCorrectionsRcd>().get(theChamberTimingCorrections);
theChamberTimingCorrections = es.getHandle(chamberTimingCorrectionsToken_);
}

if (readBadChannels()) {
// Bad strip channels
es.get<CSCBadStripsRcd>().get(theBadStrips);
theBadStrips = es.getHandle(badStripsToken_);
// Bad wiregroup channels
es.get<CSCBadWiresRcd>().get(theBadWires);
theBadWires = es.getHandle(badWiresToken_);

//@@ if( badStripsWatcher_.check( es ) ) {
// fillBadStripWords();
Expand All @@ -106,11 +114,11 @@ void CSCConditions::initializeEvent(const edm::EventSetup &es) {

if (readBadChambers()) {
// Entire bad chambers
es.get<CSCBadChambersRcd>().get(theBadChambers);
theBadChambers = es.getHandle(badChambersToken_);
}

if (useGasGainCorrections()) {
es.get<CSCDBGasGainCorrectionRcd>().get(theGasGainCorrections);
theGasGainCorrections = es.getHandle(gasGainCorrectionsToken_);
}

// print();
Expand Down
10 changes: 4 additions & 6 deletions RecoLocalMuon/CSCRecHitD/src/CSCRecHitDProducer.cc
Expand Up @@ -12,8 +12,6 @@
#include <FWCore/Utilities/interface/Exception.h>
#include <FWCore/MessageLogger/interface/MessageLogger.h>

#include <Geometry/Records/interface/MuonGeometryRecord.h>

#include <DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h>

CSCRecHitDProducer::CSCRecHitDProducer(const edm::ParameterSet& ps)
Expand All @@ -26,9 +24,10 @@ CSCRecHitDProducer::CSCRecHitDProducer(const edm::ParameterSet& ps)
{
s_token = consumes<CSCStripDigiCollection>(ps.getParameter<edm::InputTag>("stripDigiTag"));
w_token = consumes<CSCWireDigiCollection>(ps.getParameter<edm::InputTag>("wireDigiTag"));
cscGeom_token = esConsumes<CSCGeometry, MuonGeometryRecord>();

recHitBuilder_ = new CSCRecHitDBuilder(ps); // pass on the parameter sets
recoConditions_ = new CSCRecoConditions(ps); // access to conditions data
recHitBuilder_ = new CSCRecHitDBuilder(ps); // pass on the parameter sets
recoConditions_ = new CSCRecoConditions(ps, consumesCollector()); // access to conditions data

recHitBuilder_->setConditions(recoConditions_); // pass down to who needs access

Expand All @@ -46,8 +45,7 @@ void CSCRecHitDProducer::produce(edm::Event& ev, const edm::EventSetup& setup) {
// LogTrace("CSCRecHitDProducer|CSCRecHit")<< "[CSCRecHitDProducer] starting event " << ev.id().event() << " of run " << ev.id().run();
LogTrace("CSCRecHit") << "[CSCRecHitDProducer] starting event " << ev.id().event() << " of run " << ev.id().run();
// find the geometry for this event & cache it in the builder
edm::ESHandle<CSCGeometry> h;
setup.get<MuonGeometryRecord>().get(h);
edm::ESHandle<CSCGeometry> h = setup.getHandle(cscGeom_token);
const CSCGeometry* pgeom = &*h;
recHitBuilder_->setGeometry(pgeom);

Expand Down
4 changes: 4 additions & 0 deletions RecoLocalMuon/CSCRecHitD/src/CSCRecHitDProducer.h
Expand Up @@ -20,9 +20,12 @@
#include <FWCore/Framework/interface/Event.h>
#include <FWCore/ParameterSet/interface/ParameterSet.h>
#include <FWCore/Utilities/interface/InputTag.h>
#include <FWCore/Utilities/interface/ESGetToken.h>

#include <DataFormats/CSCDigi/interface/CSCStripDigiCollection.h>
#include <DataFormats/CSCDigi/interface/CSCWireDigiCollection.h>
#include <Geometry/Records/interface/MuonGeometryRecord.h>
#include <Geometry/CSCGeometry/interface/CSCGeometry.h>

class CSCRecHitDBuilder;
class CSCRecoConditions;
Expand All @@ -49,6 +52,7 @@ class CSCRecHitDProducer : public edm::stream::EDProducer<> {

edm::EDGetTokenT<CSCStripDigiCollection> s_token;
edm::EDGetTokenT<CSCWireDigiCollection> w_token;
edm::ESGetToken<CSCGeometry, MuonGeometryRecord> cscGeom_token;
};

#endif
18 changes: 11 additions & 7 deletions RecoLocalMuon/CSCRecHitD/src/CSCRecoBadChannelsAnalyzer.cc
Expand Up @@ -12,6 +12,7 @@

#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/ESGetToken.h"

#include "CalibMuon/CSCCalibration/interface/CSCIndexerBase.h"
#include "CalibMuon/CSCCalibration/interface/CSCIndexerRecord.h"
Expand All @@ -33,7 +34,10 @@ class CSCRecoBadChannelsAnalyzer : public edm::EDAnalyzer {
dashedLine_(std::string(dashedLineWidth_, '-')),
myName_("CSCRecoBadChannelsAnalyzer"),
readBadChannels_(ps.getParameter<bool>("readBadChannels")),
recoConditions_(new CSCRecoConditions(ps)) {}
recoConditions_(new CSCRecoConditions(ps, consumesCollector())),
indexerToken_(esConsumes<CSCIndexerBase, CSCIndexerRecord>()),
mapperToken_(esConsumes<CSCChannelMapperBase, CSCChannelMapperRecord>()),
geometryToken_(esConsumes<CSCGeometry, MuonGeometryRecord>()) {}

~CSCRecoBadChannelsAnalyzer() override { delete recoConditions_; }
void analyze(const edm::Event& e, const edm::EventSetup& c) override;
Expand All @@ -49,6 +53,9 @@ class CSCRecoBadChannelsAnalyzer : public edm::EDAnalyzer {

bool readBadChannels_;
CSCRecoConditions* recoConditions_;
edm::ESGetToken<CSCIndexerBase, CSCIndexerRecord> indexerToken_;
edm::ESGetToken<CSCChannelMapperBase, CSCChannelMapperRecord> mapperToken_;
edm::ESGetToken<CSCGeometry, MuonGeometryRecord> geometryToken_;
};

void CSCRecoBadChannelsAnalyzer::analyze(const edm::Event& ev, const edm::EventSetup& evsetup) {
Expand All @@ -60,19 +67,16 @@ void CSCRecoBadChannelsAnalyzer::analyze(const edm::Event& ev, const edm::EventS
edm::LogVerbatim("CSCBadChannels") << "RUN# " << ev.id().run();
edm::LogVerbatim("CSCBadChannels") << "EVENT# " << ev.id().event();

edm::ESHandle<CSCIndexerBase> theIndexer;
evsetup.get<CSCIndexerRecord>().get(theIndexer);
edm::ESHandle<CSCIndexerBase> theIndexer = evsetup.getHandle(indexerToken_);

edm::LogVerbatim("CSCBadChannels") << myName() << "::analyze sees indexer " << theIndexer->name()
<< " in Event Setup";

edm::ESHandle<CSCChannelMapperBase> theMapper;
evsetup.get<CSCChannelMapperRecord>().get(theMapper);
edm::ESHandle<CSCChannelMapperBase> theMapper = evsetup.getHandle(mapperToken_);

edm::LogVerbatim("CSCBadChannels") << myName() << "::analyze sees mapper " << theMapper->name() << " in Event Setup";

edm::ESHandle<CSCGeometry> theGeometry;
evsetup.get<MuonGeometryRecord>().get(theGeometry);
edm::ESHandle<CSCGeometry> theGeometry = evsetup.getHandle(geometryToken_);

edm::LogVerbatim("CSCBadChannels") << " Geometry node for CSCGeom is " << &(*theGeometry);
edm::LogVerbatim("CSCBadChannels") << " There are " << theGeometry->dets().size() << " dets";
Expand Down
2 changes: 1 addition & 1 deletion RecoLocalMuon/CSCRecHitD/src/CSCRecoConditions.cc
Expand Up @@ -3,7 +3,7 @@
#include <FWCore/MessageLogger/interface/MessageLogger.h>
#include <iostream>

CSCRecoConditions::CSCRecoConditions(const edm::ParameterSet& ps) : theConditions(ps) {}
CSCRecoConditions::CSCRecoConditions(const edm::ParameterSet& ps, edm::ConsumesCollector cc) : theConditions(ps, cc) {}

CSCRecoConditions::~CSCRecoConditions() {}

Expand Down
3 changes: 2 additions & 1 deletion RecoLocalMuon/CSCRecHitD/src/CSCRecoConditions.h
Expand Up @@ -18,13 +18,14 @@

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "CalibMuon/CSCCalibration/interface/CSCConditions.h"
#include "DataFormats/MuonDetId/interface/CSCDetId.h"

class CSCRecoConditions {
public:
// Passed a PSet just in case we need to configure in some way
explicit CSCRecoConditions(const edm::ParameterSet& pset);
explicit CSCRecoConditions(const edm::ParameterSet& pset, edm::ConsumesCollector);
~CSCRecoConditions();

/// fetch the cond data from the database
Expand Down
4 changes: 2 additions & 2 deletions SimMuon/CSCDigitizer/src/CSCDbStripConditions.cc
Expand Up @@ -7,9 +7,9 @@
#include "FWCore/Utilities/interface/Exception.h"
#include "SimMuon/CSCDigitizer/src/CSCDbStripConditions.h"

CSCDbStripConditions::CSCDbStripConditions(const edm::ParameterSet &pset)
CSCDbStripConditions::CSCDbStripConditions(const edm::ParameterSet &pset, edm::ConsumesCollector cc)
: CSCStripConditions(),
theConditions(pset),
theConditions(pset, cc),
theCapacitiveCrosstalk(pset.getParameter<double>("capacativeCrosstalk")),
theResistiveCrosstalkScaling(pset.getParameter<double>("resistiveCrosstalkScaling")),
theGainsConstant(pset.getParameter<double>("gainsConstant")),
Expand Down
2 changes: 1 addition & 1 deletion SimMuon/CSCDigitizer/src/CSCDbStripConditions.h
Expand Up @@ -7,7 +7,7 @@

class CSCDbStripConditions : public CSCStripConditions {
public:
explicit CSCDbStripConditions(const edm::ParameterSet &pset);
explicit CSCDbStripConditions(const edm::ParameterSet &pset, edm::ConsumesCollector cc);
~CSCDbStripConditions() override;

/// fetch the maps from the database
Expand Down
2 changes: 1 addition & 1 deletion SimMuon/CSCDigitizer/src/CSCDigiProducer.cc
Expand Up @@ -33,7 +33,7 @@ CSCDigiProducer::CSCDigiProducer(const edm::ParameterSet &ps) : theDigitizer(ps)
if (stripConditions == "Configurable") {
theStripConditions = new CSCConfigurableStripConditions(stripPSet);
} else if (stripConditions == "Database") {
theStripConditions = new CSCDbStripConditions(stripPSet);
theStripConditions = new CSCDbStripConditions(stripPSet, consumesCollector());
} else {
throw cms::Exception("CSCDigiProducer") << "Bad option for strip conditions: " << stripConditions;
}
Expand Down
2 changes: 1 addition & 1 deletion SimMuon/CSCDigitizer/test/CSCNoiseMatrixTest.cc
Expand Up @@ -14,7 +14,7 @@

class CSCNoiseMatrixTest : public edm::EDAnalyzer {
public:
CSCNoiseMatrixTest(const edm::ParameterSet &pset) : theDbConditions(pset) {
CSCNoiseMatrixTest(const edm::ParameterSet &pset) : theDbConditions(pset, consumesCollector()) {
edm::Service<edm::RandomNumberGenerator> rng;
if (!rng.isAvailable()) {
throw cms::Exception("Configuration") << "CSCNoiseMatrixTest requires the RandomNumberGeneratorService\n"
Expand Down

0 comments on commit 3368964

Please sign in to comment.