-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
ECAL esConsumes migration of remaining file in RecoMET #35179
Merged
cmsbuild
merged 2 commits into
cms-sw:master
from
thomreis:ecal-esconsumes-migration-recomet
Sep 14, 2021
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,14 +24,15 @@ | |
#include "PhysicsTools/SelectorUtils/interface/strbitset.h" | ||
|
||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/EDFilter.h" | ||
#include "FWCore/Framework/interface/EDProducer.h" | ||
#include "FWCore/Framework/interface/stream/EDFilter.h" | ||
|
||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
|
||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
|
||
#include "FWCore/Utilities/interface/Exception.h" | ||
|
||
#include "DataFormats/EcalRecHit/interface/EcalRecHit.h" | ||
#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" | ||
#include "DataFormats/DetId/interface/DetId.h" | ||
|
@@ -81,30 +82,17 @@ | |
|
||
#include "DataFormats/Math/interface/deltaR.h" | ||
|
||
// HCAL | ||
#include "CondFormats/HcalObjects/interface/HcalChannelQuality.h" | ||
#include "CondFormats/DataRecord/interface/HcalChannelQualityRcd.h" | ||
#include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h" | ||
#include "DataFormats/HcalDetId/interface/HcalDetId.h" | ||
|
||
#include "DataFormats/Provenance/interface/RunLumiEventNumber.h" | ||
|
||
#include "TFile.h" | ||
#include "TTree.h" | ||
#include "TH1.h" | ||
|
||
class EcalDeadCellDeltaRFilter : public edm::EDFilter { | ||
class EcalDeadCellDeltaRFilter : public edm::stream::EDFilter<> { | ||
public: | ||
explicit EcalDeadCellDeltaRFilter(const edm::ParameterSet &); | ||
~EcalDeadCellDeltaRFilter() override; | ||
~EcalDeadCellDeltaRFilter() override = default; | ||
|
||
private: | ||
bool filter(edm::Event &, const edm::EventSetup &) override; | ||
void beginJob() override; | ||
void endJob() override; | ||
void beginRun(const edm::Run &, const edm::EventSetup &) override; | ||
void endRun(const edm::Run &, const edm::EventSetup &) override; | ||
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override; | ||
virtual void envSet(const edm::EventSetup &); | ||
|
||
// ----------member data --------------------------- | ||
|
@@ -133,11 +121,12 @@ class EcalDeadCellDeltaRFilter : public edm::EDFilter { | |
double calomet, calometPhi, tcmet, tcmetPhi, pfmet, pfmetPhi; | ||
|
||
// Channel status related | ||
edm::ESHandle<EcalChannelStatus> ecalStatus; // these come from EventSetup | ||
edm::ESHandle<HcalChannelQuality> hcalStatus; // these may come per LS | ||
edm::ESHandle<EcalChannelStatus> ecalStatus; // these come from EventSetup | ||
edm::ESHandle<CaloGeometry> geometry; | ||
|
||
edm::ESHandle<EcalTrigTowerConstituentsMap> ttMap_; | ||
const EcalTrigTowerConstituentsMap *ttMap_; | ||
const edm::ESGetToken<EcalChannelStatus, EcalChannelStatusRcd> ecalChannelStatusToken_; | ||
const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeometryToken_; | ||
const edm::ESGetToken<EcalTrigTowerConstituentsMap, IdealGeometryRecord> ecalTrigTowerConstituentsMapToken_; | ||
|
||
const int maskedEcalChannelStatusThreshold_; | ||
const int chnStatusToBeEvaluated_; | ||
|
@@ -157,11 +146,6 @@ class EcalDeadCellDeltaRFilter : public edm::EDFilter { | |
int evtProcessedCnt, totTPFilteredCnt; | ||
double wtdEvtProcessed, wtdTPFiltered; | ||
|
||
const bool makeProfileRoot_; | ||
const std::string profileRootName_; | ||
TFile *profFile; | ||
TH1F *h1_dummy; | ||
|
||
const bool isProd_; | ||
const int verbose_; | ||
|
||
|
@@ -221,71 +205,40 @@ void EcalDeadCellDeltaRFilter::loadJets(const edm::Event &iEvent, const edm::Eve | |
// | ||
EcalDeadCellDeltaRFilter::EcalDeadCellDeltaRFilter(const edm::ParameterSet &iConfig) | ||
: jetToken_(consumes<edm::View<reco::Jet> >(iConfig.getParameter<edm::InputTag>("jetInputTag"))), | ||
jetSelCuts_(iConfig.getParameter<std::vector<double> >("jetSelCuts")) | ||
|
||
, | ||
metToken_(consumes<edm::View<reco::MET> >(iConfig.getParameter<edm::InputTag>("metInputTag"))) | ||
|
||
, | ||
jetSelCuts_(iConfig.getParameter<std::vector<double> >("jetSelCuts")), | ||
metToken_(consumes<edm::View<reco::MET> >(iConfig.getParameter<edm::InputTag>("metInputTag"))), | ||
debug_(iConfig.getUntrackedParameter<bool>("debug", false)), | ||
printSkimInfo_(iConfig.getUntrackedParameter<bool>("printSkimInfo", false)) | ||
|
||
, | ||
printSkimInfo_(iConfig.getUntrackedParameter<bool>("printSkimInfo", false)), | ||
ecalChannelStatusToken_(esConsumes<edm::Transition::BeginRun>()), | ||
caloGeometryToken_(esConsumes<edm::Transition::BeginRun>()), | ||
ecalTrigTowerConstituentsMapToken_(esConsumes<edm::Transition::BeginRun>()), | ||
maskedEcalChannelStatusThreshold_(iConfig.getParameter<int>("maskedEcalChannelStatusThreshold")), | ||
chnStatusToBeEvaluated_(iConfig.getParameter<int>("chnStatusToBeEvaluated")) | ||
|
||
, | ||
makeProfileRoot_(iConfig.getUntrackedParameter<bool>("makeProfileRoot", true)), | ||
profileRootName_(iConfig.getUntrackedParameter<std::string>("profileRootName", "EcalDeadCellDeltaRFilter.root")) | ||
|
||
, | ||
chnStatusToBeEvaluated_(iConfig.getParameter<int>("chnStatusToBeEvaluated")), | ||
isProd_(iConfig.getUntrackedParameter<bool>("isProd")), | ||
verbose_(iConfig.getParameter<int>("verbose")) | ||
|
||
, | ||
verbose_(iConfig.getParameter<int>("verbose")), | ||
doCracks_(iConfig.getUntrackedParameter<bool>("doCracks")), | ||
cracksHBHEdef_(iConfig.getParameter<std::vector<double> >("cracksHBHEdef")), | ||
cracksHEHFdef_(iConfig.getParameter<std::vector<double> >("cracksHEHFdef")) | ||
|
||
, | ||
EcalDeadCellDeltaRFilterInput_(iConfig.getParameter<std::vector<double> >("EcalDeadCellDeltaRFilterInput")) | ||
|
||
, | ||
cracksHEHFdef_(iConfig.getParameter<std::vector<double> >("cracksHEHFdef")), | ||
EcalDeadCellDeltaRFilterInput_(iConfig.getParameter<std::vector<double> >("EcalDeadCellDeltaRFilterInput")), | ||
taggingMode_(iConfig.getParameter<bool>("taggingMode")) { | ||
produces<int>("deadCellStatus"); | ||
produces<int>("boundaryStatus"); | ||
produces<bool>(); | ||
|
||
if (makeProfileRoot_) { | ||
profFile = new TFile(profileRootName_.c_str(), "RECREATE"); | ||
h1_dummy = new TH1F("dummy", "dummy", 500, 0, 500); | ||
} | ||
} | ||
|
||
EcalDeadCellDeltaRFilter::~EcalDeadCellDeltaRFilter() { | ||
if (makeProfileRoot_) { | ||
profFile->cd(); | ||
|
||
h1_dummy->Write(); | ||
|
||
profFile->Close(); | ||
delete profFile; | ||
} | ||
} | ||
|
||
void EcalDeadCellDeltaRFilter::envSet(const edm::EventSetup &iSetup) { | ||
if (debug_) | ||
std::cout << "***envSet***" << std::endl; | ||
|
||
iSetup.get<IdealGeometryRecord>().get(ttMap_); | ||
ttMap_ = &iSetup.getData(ecalTrigTowerConstituentsMapToken_); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
iSetup.get<EcalChannelStatusRcd>().get(ecalStatus); | ||
iSetup.get<CaloGeometryRecord>().get(geometry); | ||
ecalStatus = iSetup.getHandle(ecalChannelStatusToken_); | ||
geometry = iSetup.getHandle(caloGeometryToken_); | ||
|
||
if (!ecalStatus.isValid()) | ||
throw "Failed to get ECAL channel status!"; | ||
throw cms::Exception("ESDataError") << "Failed to get ECAL channel status!"; | ||
if (!geometry.isValid()) | ||
throw "Failed to get the geometry!"; | ||
throw cms::Exception("ESDataError") << "Failed to get the geometry!"; | ||
} | ||
|
||
// ------------ method called on each new Event ------------ | ||
|
@@ -337,10 +290,6 @@ bool EcalDeadCellDeltaRFilter::filter(edm::Event &iEvent, const edm::EventSetup | |
dRtoDeadCell); | ||
} | ||
|
||
if (makeProfileRoot_) { | ||
// h1_dummy->Fill(xxx); | ||
} | ||
|
||
iEvent.put(std::make_unique<int>(deadCellStatus), "deadCellStatus"); | ||
iEvent.put(std::make_unique<int>(boundaryStatus), "boundaryStatus"); | ||
|
||
|
@@ -352,18 +301,6 @@ bool EcalDeadCellDeltaRFilter::filter(edm::Event &iEvent, const edm::EventSetup | |
return taggingMode_ || pass; | ||
} | ||
|
||
// ------------ method called once each job just before starting event loop ------------ | ||
void EcalDeadCellDeltaRFilter::beginJob() { | ||
if (debug_) | ||
std::cout << "beginJob" << std::endl; | ||
} | ||
|
||
// ------------ method called once each job just after ending the event loop ------------ | ||
void EcalDeadCellDeltaRFilter::endJob() { | ||
if (debug_) | ||
std::cout << "endJob" << std::endl; | ||
} | ||
|
||
// ------------ method called once each run just before starting event loop ------------ | ||
void EcalDeadCellDeltaRFilter::beginRun(const edm::Run &run, const edm::EventSetup &iSetup) { | ||
if (debug_) | ||
|
@@ -385,16 +322,6 @@ void EcalDeadCellDeltaRFilter::endRun(const edm::Run &run, const edm::EventSetup | |
return; | ||
} | ||
|
||
// ------------ method called at lumi block start | ||
void EcalDeadCellDeltaRFilter::beginLuminosityBlock(const edm::LuminosityBlock &iLSblock, | ||
const edm::EventSetup &iSetup) { | ||
// needs per-LS access, if used at all | ||
iSetup.get<HcalChannelQualityRcd>().get("withTopo", hcalStatus); | ||
if (!hcalStatus.isValid()) | ||
throw "Failed to get HCAL channel status!"; | ||
return; | ||
} | ||
|
||
int EcalDeadCellDeltaRFilter::etaToBoundary(const std::vector<reco::Jet> &jetTVec) { | ||
int isClose = 0; | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you confirm that it was tested to be thread-safe now after these changes? I see some TH1F was removed, which indicates that beforehand it may not have been safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TH1F was removed because it was actually never filled. With it gone, I think making the filter a stream module is possible but it was not tested. The module does not seem to be used in any configuration at the moment.