diff --git a/CondTools/RunInfo/plugins/BuildFile.xml b/CondTools/RunInfo/plugins/BuildFile.xml index c651c33b38cfd..f1ed6cfc4fc16 100644 --- a/CondTools/RunInfo/plugins/BuildFile.xml +++ b/CondTools/RunInfo/plugins/BuildFile.xml @@ -42,3 +42,7 @@ + + + + diff --git a/CondTools/RunInfo/plugins/XangleBetaStarFilter.cc b/CondTools/RunInfo/plugins/XangleBetaStarFilter.cc new file mode 100644 index 0000000000000..f2b6717dc6d51 --- /dev/null +++ b/CondTools/RunInfo/plugins/XangleBetaStarFilter.cc @@ -0,0 +1,78 @@ +/**************************************************************************** + * Authors: + * Jan Kašpar + ****************************************************************************/ + +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Utilities/interface/Exception.h" +#include "FWCore/Framework/interface/EDFilter.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Framework/interface/EventSetup.h" + +#include "CondFormats/RunInfo/interface/LHCInfo.h" +#include "CondFormats/DataRecord/interface/LHCInfoRcd.h" + +//---------------------------------------------------------------------------------------------------- + +class XangleBetaStarFilter : public edm::EDFilter +{ + public: + explicit XangleBetaStarFilter(const edm::ParameterSet&); + + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); + + private: + edm::ESGetToken lhcInfoToken_; + + double xangle_min_; + double xangle_max_; + + double beta_star_min_; + double beta_star_max_; + + virtual bool filter(edm::Event &, const edm::EventSetup &) override; +}; + +//---------------------------------------------------------------------------------------------------- + +XangleBetaStarFilter::XangleBetaStarFilter(const edm::ParameterSet& iConfig) : + lhcInfoToken_(esConsumes(edm::ESInputTag{"", iConfig.getParameter("lhcInfoLabel")})), + + xangle_min_(iConfig.getParameter("xangle_min")), + xangle_max_(iConfig.getParameter("xangle_max")), + beta_star_min_(iConfig.getParameter("beta_star_min")), + beta_star_max_(iConfig.getParameter("beta_star_max")) +{ +} + +//---------------------------------------------------------------------------------------------------- + +void XangleBetaStarFilter::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { + edm::ParameterSetDescription desc; + + desc.add("lhcInfoLabel", "")->setComment("label of the LHCInfo record"); + + desc.add("xangle_min", 0.); + desc.add("xangle_max", 1000.); + + desc.add("beta_star_min", 0.); + desc.add("beta_star_max", 1000.); + + descriptions.add("xangleBetaStarFilter", desc); +} + +//---------------------------------------------------------------------------------------------------- + +bool XangleBetaStarFilter::filter(edm::Event& /*iEvent*/, const edm::EventSetup& iSetup) +{ + const auto &lhcInfo = iSetup.getData(lhcInfoToken_); + + return (xangle_min_ <= lhcInfo.crossingAngle() && lhcInfo.crossingAngle() < xangle_max_) + && (beta_star_min_ <= lhcInfo.betaStar() && lhcInfo.betaStar() < beta_star_max_); +} + +//---------------------------------------------------------------------------------------------------- + +DEFINE_FWK_MODULE(XangleBetaStarFilter); diff --git a/CondTools/RunInfo/test/xangleBetaStarFilter_test_cfg.py b/CondTools/RunInfo/test/xangleBetaStarFilter_test_cfg.py new file mode 100644 index 0000000000000..887c04906e177 --- /dev/null +++ b/CondTools/RunInfo/test/xangleBetaStarFilter_test_cfg.py @@ -0,0 +1,49 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("TEST") + +# define global tag +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, '106X_dataRun2_v28', '') + +# minimum of logs +process.MessageLogger = cms.Service("MessageLogger", + statistics = cms.untracked.vstring(), + destinations = cms.untracked.vstring('cout'), + cout = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ) +) + +# data source +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring("/store/data/Run2018D/EGamma/MINIAOD/12Nov2019_UL2018-v4/280000/FF9D0498-30CA-7241-A85C-6F4F272A7A16.root") +) + +#process.maxEvents = cms.untracked.PSet( +# input = cms.untracked.int32(1000) +#) + +# filter +process.load("CondTools.RunInfo.xangleBetaStarFilter_cfi") +process.xangleBetaStarFilter.xangle_min = 150 +process.xangleBetaStarFilter.xangle_max = 170 + +# plotters +process.plotterBefore = cms.EDAnalyzer("CTPPSLHCInfoPlotter", + lhcInfoLabel = cms.string(""), + outputFile = cms.string("output_before_filter.root") +) + +process.plotterAfter = cms.EDAnalyzer("CTPPSLHCInfoPlotter", + lhcInfoLabel = cms.string(""), + outputFile = cms.string("output_after_filter.root") +) + +# path +process.p = cms.Path( + process.plotterBefore + * process.xangleBetaStarFilter + * process.plotterAfter +)