-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35595 from bsunanda/Run3-alca206X
Run3-alca206X Make use of the HBHE calibration object in HEMuonFilter to reduce disk space requirement
- Loading branch information
Showing
7 changed files
with
239 additions
and
2 deletions.
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
141 changes: 141 additions & 0 deletions
141
Calibration/HcalAlCaRecoProducers/plugins/AlCaHcalHEMuonFilter.cc
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 |
---|---|---|
@@ -0,0 +1,141 @@ | ||
// system include files | ||
#include <atomic> | ||
#include <memory> | ||
#include <cmath> | ||
|
||
// user include files | ||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/global/EDFilter.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/EventSetup.h" | ||
#include "FWCore/Framework/interface/Run.h" | ||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" | ||
|
||
#include "DataFormats/Common/interface/Handle.h" | ||
#include "DataFormats/Common/interface/Ref.h" | ||
#include "DataFormats/HcalCalibObjects/interface/HcalHBHEMuonVariables.h" | ||
|
||
//#define EDM_ML_DEBUG | ||
// | ||
// class declaration | ||
// | ||
|
||
namespace alcaHcalHBHEMuon { | ||
struct Counters { | ||
Counters() : nAll_(0), nGood_(0), nFinal_(0) {} | ||
mutable std::atomic<unsigned int> nAll_, nGood_, nFinal_; | ||
}; | ||
} // namespace alcaHcalHBHEMuon | ||
|
||
class AlCaHcalHEMuonFilter : public edm::global::EDFilter<edm::RunCache<alcaHcalHBHEMuon::Counters> > { | ||
public: | ||
AlCaHcalHEMuonFilter(edm::ParameterSet const&); | ||
~AlCaHcalHEMuonFilter() override = default; | ||
|
||
std::shared_ptr<alcaHcalHBHEMuon::Counters> globalBeginRun(edm::Run const&, edm::EventSetup const&) const override; | ||
|
||
bool filter(edm::StreamID, edm::Event&, edm::EventSetup const&) const override; | ||
void globalEndRun(edm::Run const& iRun, edm::EventSetup const&) const override; | ||
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); | ||
|
||
private: | ||
// ----------member data --------------------------- | ||
const int prescale_; | ||
const double muonptCut_, muonetaCut_; | ||
const edm::InputTag labelHBHEMuonVar_; | ||
const edm::EDGetTokenT<HcalHBHEMuonVariablesCollection> tokHBHEMuonVar_; | ||
}; | ||
|
||
// | ||
// constructors and destructor | ||
// | ||
AlCaHcalHEMuonFilter::AlCaHcalHEMuonFilter(edm::ParameterSet const& iConfig) | ||
: prescale_(iConfig.getParameter<int>("prescale")), | ||
muonptCut_(iConfig.getParameter<double>("muonPtCut")), | ||
muonetaCut_(iConfig.getParameter<double>("muonEtaCut")), | ||
labelHBHEMuonVar_(iConfig.getParameter<edm::InputTag>("hbheMuonLabel")), | ||
tokHBHEMuonVar_(consumes<HcalHBHEMuonVariablesCollection>(labelHBHEMuonVar_)) { | ||
edm::LogVerbatim("HBHEMuon") << "Parameters read from config file \n\t prescale_ " << prescale_ << "\n\t Labels " | ||
<< labelHBHEMuonVar_; | ||
} // AlCaHcalHEMuonFilter::AlCaHcalHEMuonFilter constructor | ||
|
||
// | ||
// member functions | ||
// | ||
|
||
// ------------ method called on each new Event ------------ | ||
bool AlCaHcalHEMuonFilter::filter(edm::StreamID, edm::Event& iEvent, edm::EventSetup const&) const { | ||
bool accept(false); | ||
++(runCache(iEvent.getRun().index())->nAll_); | ||
#ifdef EDM_ML_DEBUG | ||
edm::LogVerbatim("HBHEMuon") << "AlCaHcalHEMuonFilter::Run " << iEvent.id().run() << " Event " << iEvent.id().event() | ||
<< " Luminosity " << iEvent.luminosityBlock() << " Bunch " << iEvent.bunchCrossing(); | ||
#endif | ||
|
||
auto const& hbheMuonColl = iEvent.getHandle(tokHBHEMuonVar_); | ||
if (hbheMuonColl.isValid()) { | ||
auto hbheMuon = hbheMuonColl.product(); | ||
if (!hbheMuon->empty()) { | ||
bool ok(false); | ||
for (auto const& muon : *hbheMuon) | ||
if ((muon.ptGlob_ >= muonptCut_) && (std::abs(muon.etaGlob_) > muonetaCut_)) | ||
ok = true; | ||
#ifdef EDM_ML_DEBUG | ||
edm::LogVerbatim("HBHEMuon") << "AlCaHcalHEMuonFilter::Flag for finding a muon with pt > " << muonptCut_ | ||
<< " and |eta| > " << muonetaCut_ << " is " << ok; | ||
#endif | ||
if (ok) { | ||
++(runCache(iEvent.getRun().index())->nGood_); | ||
if (prescale_ <= 1) | ||
accept = true; | ||
else if (runCache(iEvent.getRun().index())->nGood_ % prescale_ == 1) | ||
accept = true; | ||
} | ||
} | ||
} else { | ||
edm::LogVerbatim("HBHEMuon") << "AlCaHcalHEMuonFilter::Cannot find the collection for HcalHBHEMuonVariables"; | ||
} | ||
|
||
// Return the acceptance flag | ||
if (accept) | ||
++(runCache(iEvent.getRun().index())->nFinal_); | ||
#ifdef EDM_ML_DEBUG | ||
edm::LogVerbatim("HBHEMuon") << "AlCaHcalHEMuonFilter::Accept flag " << accept << " All " | ||
<< runCache(iEvent.getRun().index())->nAll_ << " Good " | ||
<< runCache(iEvent.getRun().index())->nGood_ << " Final " | ||
<< runCache(iEvent.getRun().index())->nFinal_; | ||
#endif | ||
return accept; | ||
|
||
} // AlCaHcalHEMuonFilter::filter | ||
|
||
// ------------ method called when starting to processes a run ------------ | ||
std::shared_ptr<alcaHcalHBHEMuon::Counters> AlCaHcalHEMuonFilter::globalBeginRun(edm::Run const& iRun, | ||
edm::EventSetup const&) const { | ||
edm::LogVerbatim("HBHEMuon") << "Start the Run " << iRun.run(); | ||
return std::make_shared<alcaHcalHBHEMuon::Counters>(); | ||
} | ||
|
||
// ------------ method called when ending the processing of a run ------------ | ||
void AlCaHcalHEMuonFilter::globalEndRun(edm::Run const& iRun, edm::EventSetup const&) const { | ||
edm::LogVerbatim("HBHEMuon") << "Select " << runCache(iRun.index())->nFinal_ << " out of " | ||
<< runCache(iRun.index())->nGood_ << " good and " << runCache(iRun.index())->nAll_ | ||
<< " total events"; | ||
} | ||
|
||
// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ | ||
void AlCaHcalHEMuonFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { | ||
edm::ParameterSetDescription desc; | ||
desc.add<int>("prescale", 1); | ||
desc.add<double>("muonPtCut", 20.0); | ||
desc.add<double>("muonEtaCut", 1.305); | ||
desc.add<edm::InputTag>("hbheMuonLabel", edm::InputTag("alcaHcalHBHEMuonProducer", "hbheMuon")); | ||
descriptions.add("alcaHcalHEMuonFilter", desc); | ||
} | ||
|
||
//define this as a plug-in | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
|
||
DEFINE_FWK_MODULE(AlCaHcalHEMuonFilter); |
19 changes: 19 additions & 0 deletions
19
Calibration/HcalAlCaRecoProducers/python/ALCARECOHcalCalHEMuonProducerFilter_Output_cff.py
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
# output block for alcastream HCAL HEMuon | ||
# output module | ||
# module alcastreamHcalHEMuonOutput = PoolOutputModule | ||
OutALCARECOHcalCalHEMuonProducerFilter_noDrop = cms.PSet( | ||
# use this in case of filter available | ||
SelectEvents = cms.untracked.PSet( | ||
SelectEvents = cms.vstring('pathALCARECOHcalCalHEMuonProducerFilter') | ||
), | ||
outputCommands = cms.untracked.vstring( | ||
'keep *_alcaHcalHBHEMuonProducer_hbheMuon_*', | ||
) | ||
) | ||
|
||
|
||
import copy | ||
OutALCARECOHcalCalHEMuonProducerFilter=copy.deepcopy(OutALCARECOHcalCalHEMuonProducerFilter_noDrop) | ||
OutALCARECOHcalCalHEMuonProducerFilter.outputCommands.insert(0, "drop *") |
14 changes: 14 additions & 0 deletions
14
Calibration/HcalAlCaRecoProducers/python/ALCARECOHcalCalHEMuonProducerFilter_cff.py
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
#------------------------------------------------ | ||
#AlCaReco filtering for HCAL isotrk: | ||
#------------------------------------------------ | ||
|
||
from Calibration.HcalAlCaRecoProducers.alcaHcalHBHEMuonProducer_cfi import * | ||
from Calibration.HcalAlCaRecoProducers.alcaHcalHEMuonFilter_cfi import * | ||
|
||
seqALCARECOHcalCalHEMuonProducerFilter = cms.Sequence(alcaHcalHBHEMuonProducer * alcaHcalHEMuonFilter) | ||
|
||
|
||
|
||
|
52 changes: 52 additions & 0 deletions
52
Calibration/HcalAlCaRecoProducers/test/AlCaHEMuonProducerFilter_cfg.py
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from Configuration.Eras.Era_Run2_2018_cff import Run2_2018 | ||
process = cms.Process("AlCaHEMuon",Run2_2018) | ||
|
||
process.load('Configuration.StandardSequences.Services_cff') | ||
process.load('FWCore.MessageService.MessageLogger_cfi') | ||
process.load("Configuration.StandardSequences.GeometryRecoDB_cff") | ||
process.load("Configuration.StandardSequences.MagneticField_cff") | ||
process.load('Configuration.StandardSequences.AlCaRecoStreams_cff') | ||
process.load('Configuration.StandardSequences.EndOfProcess_cff') | ||
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') | ||
from Configuration.AlCa.autoCond import autoCond | ||
process.GlobalTag.globaltag=autoCond['run2_data'] | ||
|
||
process.load("RecoLocalCalo.EcalRecAlgos.EcalSeverityLevelESProducer_cfi") | ||
|
||
if hasattr(process,'MessageLogger'): | ||
process.MessageLogger.HBHEMuon=dict() | ||
|
||
process.maxEvents = cms.untracked.PSet( | ||
input = cms.untracked.int32(-1) | ||
) | ||
|
||
process.source = cms.Source("PoolSource", | ||
fileNames = cms.untracked.vstring( | ||
'file:/eos/cms/store/group/dpg_hcal/comm_hcal/AmanKaur/HLTPhysics/RawtoReco_HLTPhysics/210910_053130/0000/RECO_RAW2DIGI_L1Reco_RECO_ALCA_1.root', | ||
'file:/eos/cms/store/group/dpg_hcal/comm_hcal/AmanKaur/HLTPhysics/RawtoReco_HLTPhysics/210910_053130/0000/RECO_RAW2DIGI_L1Reco_RECO_ALCA_2.root', | ||
) | ||
) | ||
|
||
process.ALCARECOStreamHcalCalHEMuon = cms.OutputModule("PoolOutputModule", | ||
SelectEvents = cms.untracked.PSet( | ||
SelectEvents = cms.vstring('pathALCARECOHcalCalHEMuonProducerFilter') | ||
), | ||
dataset = cms.untracked.PSet( | ||
dataTier = cms.untracked.string('ALCARECO'), | ||
filterName = cms.untracked.string('ALCARECOHcalCalHEMuonProducerFilter') | ||
), | ||
eventAutoFlushCompressedSize = cms.untracked.int32(5242880), | ||
outputCommands = process.OutALCARECOHcalCalHEMuonProducerFilter.outputCommands, | ||
fileName = cms.untracked.string('OutputHEMuonProducerFilter.root'), | ||
) | ||
|
||
process.alcaHcalHBHEMuonProducer.triggers = [] | ||
|
||
# Path and EndPath definitions | ||
process.endjob_step = cms.EndPath(process.endOfProcess) | ||
process.ALCARECOStreamHcalCalHEMuonProducerFilterOutPath = cms.EndPath(process.ALCARECOStreamHcalCalHEMuon) | ||
|
||
# Schedule definition | ||
process.schedule = cms.Schedule(process.pathALCARECOHcalCalHEMuonProducerFilter,process.endjob_step,process.ALCARECOStreamHcalCalHEMuonProducerFilterOutPath) |
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
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