Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:59:47

0001 #include "FWCore/Framework/interface/Event.h"
0002 #include "FWCore/Framework/interface/EventSetup.h"
0003 #include "FWCore/Framework/interface/stream/EDFilter.h"
0004 #include "FWCore/Framework/interface/ESHandle.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "FWCore/Utilities/interface/ESGetToken.h"
0007 #include "CondFormats/RunInfo/interface/RunInfo.h"
0008 #include "CondFormats/DataRecord/interface/RunSummaryRcd.h"
0009 
0010 //
0011 // -- Class Deleration
0012 //
0013 
0014 class SiStripBFieldFilter : public edm::stream::EDFilter<> {
0015 public:
0016   SiStripBFieldFilter(const edm::ParameterSet&);
0017   ~SiStripBFieldFilter() override;
0018 
0019 private:
0020   const edm::ESGetToken<RunInfo, RunInfoRcd> runInfoToken_;
0021   double MagFieldCurrentTh_; /*!<  Threshold for the Magnet current. */
0022   bool HIpassFilter_;        /*!<  Swith for HI/Low filter. */
0023 
0024   bool filter(edm::Event&, edm::EventSetup const&) override;
0025 };
0026 
0027 //
0028 // -- Constructor
0029 //
0030 SiStripBFieldFilter::SiStripBFieldFilter(const edm::ParameterSet& pset)
0031     : runInfoToken_(esConsumes<RunInfo, RunInfoRcd>()) {
0032   MagFieldCurrentTh_ = pset.getUntrackedParameter<double>("MagFieldCurrentTh", 2000.);
0033   HIpassFilter_ = pset.getUntrackedParameter<bool>("HIpassFilter", true);
0034 }
0035 
0036 //
0037 // -- Destructor
0038 //
0039 SiStripBFieldFilter::~SiStripBFieldFilter() {}
0040 
0041 bool SiStripBFieldFilter::filter(edm::Event& evt, edm::EventSetup const& es) {
0042   edm::ESHandle<RunInfo> runInfo = es.getHandle(runInfoToken_);
0043   double average_current = runInfo.product()->m_avg_current;
0044 
0045   return ((HIpassFilter_) ? average_current > MagFieldCurrentTh_ : average_current < MagFieldCurrentTh_);
0046 }
0047 
0048 #include "FWCore/Framework/interface/MakerMacros.h"
0049 DEFINE_FWK_MODULE(SiStripBFieldFilter);