Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-07 04:53:56

0001 /****************************************************************************
0002  * Authors:
0003  *   Jan Kašpar
0004  ****************************************************************************/
0005 
0006 #include "FWCore/Framework/interface/ESHandle.h"
0007 #include "FWCore/Framework/interface/MakerMacros.h"
0008 #include "FWCore/Utilities/interface/Exception.h"
0009 #include "FWCore/Framework/interface/stream/EDFilter.h"
0010 #include "FWCore/Framework/interface/Event.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "FWCore/Framework/interface/EventSetup.h"
0013 #include "CondFormats/RunInfo/interface/LHCInfo.h"
0014 #include "CondFormats/DataRecord/interface/LHCInfoRcd.h"
0015 
0016 //----------------------------------------------------------------------------------------------------
0017 
0018 class XangleBetaStarFilter : public edm::stream::EDFilter<> {
0019 public:
0020   explicit XangleBetaStarFilter(const edm::ParameterSet &);
0021 
0022   static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
0023 
0024 private:
0025   edm::ESGetToken<LHCInfo, LHCInfoRcd> lhcInfoToken_;
0026 
0027   double xangle_min_;
0028   double xangle_max_;
0029 
0030   double beta_star_min_;
0031   double beta_star_max_;
0032 
0033   bool filter(edm::Event &, const edm::EventSetup &) override;
0034 };
0035 
0036 //----------------------------------------------------------------------------------------------------
0037 
0038 XangleBetaStarFilter::XangleBetaStarFilter(const edm::ParameterSet &iConfig)
0039     : lhcInfoToken_(
0040           esConsumes<LHCInfo, LHCInfoRcd>(edm::ESInputTag{"", iConfig.getParameter<std::string>("lhcInfoLabel")})),
0041 
0042       xangle_min_(iConfig.getParameter<double>("xangle_min")),
0043       xangle_max_(iConfig.getParameter<double>("xangle_max")),
0044       beta_star_min_(iConfig.getParameter<double>("beta_star_min")),
0045       beta_star_max_(iConfig.getParameter<double>("beta_star_max")) {}
0046 
0047 //----------------------------------------------------------------------------------------------------
0048 
0049 void XangleBetaStarFilter::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
0050   edm::ParameterSetDescription desc;
0051 
0052   desc.add<std::string>("lhcInfoLabel", "")->setComment("label of the LHCInfo record");
0053 
0054   desc.add<double>("xangle_min", 0.);
0055   desc.add<double>("xangle_max", 1000.);
0056 
0057   desc.add<double>("beta_star_min", 0.);
0058   desc.add<double>("beta_star_max", 1000.);
0059 
0060   descriptions.add("xangleBetaStarFilter", desc);
0061 }
0062 
0063 //----------------------------------------------------------------------------------------------------
0064 
0065 bool XangleBetaStarFilter::filter(edm::Event & /*iEvent*/, const edm::EventSetup &iSetup) {
0066   const auto &lhcInfo = iSetup.getData(lhcInfoToken_);
0067 
0068   return (xangle_min_ <= lhcInfo.crossingAngle() && lhcInfo.crossingAngle() < xangle_max_) &&
0069          (beta_star_min_ <= lhcInfo.betaStar() && lhcInfo.betaStar() < beta_star_max_);
0070 }
0071 
0072 //----------------------------------------------------------------------------------------------------
0073 
0074 DEFINE_FWK_MODULE(XangleBetaStarFilter);