Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:08:59

0001 // -*- C++ -*-
0002 //
0003 // Package:    SiStripTools
0004 // Class:      ByMultiplicityEventFilter
0005 //
0006 /**\class ByMultiplicityEventFilter ByMultiplicityEventFilter.cc DPGAnalysis/SiStripTools/ByMultiplicityEventFilter.cc
0007 
0008  Description: templated EDFilter to select events with large number of SiStripDigi or SiStripCluster
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Andrea Venturi
0015 //         Created:  Tue Oct 21 20:55:22 CEST 2008
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 #include <string>
0022 
0023 // user include files
0024 #include "FWCore/Framework/interface/Frameworkfwd.h"
0025 #include "FWCore/Framework/interface/stream/EDFilter.h"
0026 
0027 #include "FWCore/Framework/interface/Event.h"
0028 #include "FWCore/Framework/interface/MakerMacros.h"
0029 
0030 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0031 
0032 #include "FWCore/Utilities/interface/InputTag.h"
0033 
0034 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
0035 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
0036 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
0037 
0038 #include "CommonTools/Utils/interface/StringCutObjectSelector.h"
0039 
0040 #include "DPGAnalysis/SiStripTools/interface/Multiplicities.h"
0041 
0042 //
0043 // class declaration
0044 //
0045 
0046 template <class T>
0047 class ByMultiplicityEventFilter : public edm::stream::EDFilter<> {
0048 public:
0049   explicit ByMultiplicityEventFilter(const edm::ParameterSet&);
0050   ~ByMultiplicityEventFilter() override;
0051 
0052 private:
0053   bool filter(edm::Event&, const edm::EventSetup&) override;
0054 
0055   // ----------member data ---------------------------
0056 
0057   T m_multiplicities;
0058   StringCutObjectSelector<T> m_selector;
0059   bool m_taggedMode, m_forcedValue;
0060 };
0061 
0062 //
0063 // constants, enums and typedefs
0064 //
0065 
0066 //
0067 // static data member definitions
0068 //
0069 
0070 //
0071 // constructors and destructor
0072 //
0073 template <class T>
0074 ByMultiplicityEventFilter<T>::ByMultiplicityEventFilter(const edm::ParameterSet& iConfig)
0075     : m_multiplicities(iConfig.getParameter<edm::ParameterSet>("multiplicityConfig"), consumesCollector()),
0076       m_selector(iConfig.getParameter<std::string>("cut")),
0077       m_taggedMode(iConfig.getUntrackedParameter<bool>("taggedMode", false)),
0078       m_forcedValue(iConfig.getUntrackedParameter<bool>("forcedValue", true))
0079 
0080 {
0081   //now do what ever initialization is needed
0082   produces<bool>();
0083 }
0084 
0085 template <class T>
0086 ByMultiplicityEventFilter<T>::~ByMultiplicityEventFilter() {
0087   // do anything here that needs to be done at desctruction time
0088   // (e.g. close files, deallocate resources etc.)
0089 }
0090 
0091 //
0092 // member functions
0093 //
0094 
0095 // ------------ method called on each new Event  ------------
0096 template <class T>
0097 bool ByMultiplicityEventFilter<T>::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0098   using namespace edm;
0099 
0100   m_multiplicities.getEvent(iEvent, iSetup);
0101 
0102   bool value = m_selector(m_multiplicities);
0103   iEvent.put(std::make_unique<bool>(value));
0104 
0105   if (m_taggedMode)
0106     return m_forcedValue;
0107   return value;
0108 }
0109 
0110 //define this as a plug-in
0111 /*
0112 typedef ByMultiplicityEventFilter<SingleMultiplicity<edm::DetSetVector<SiStripDigi> > > BySiStripDigiMultiplicityEventFilter;
0113 typedef ByMultiplicityEventFilter<SingleMultiplicity<edmNew::DetSetVector<SiStripCluster> > > BySiStripClusterMultiplicityEventFilter;
0114 typedef ByMultiplicityEventFilter<SingleMultiplicity<edmNew::DetSetVector<SiPixelCluster> > > BySiPixelClusterMultiplicityEventFilter;
0115 typedef ByMultiplicityEventFilter<MultiplicityPair<edmNew::DetSetVector<SiPixelCluster>,edmNew::DetSetVector<SiStripCluster> > > BySiPixelClusterVsSiStripClusterMultiplicityEventFilter;
0116 */
0117 typedef ByMultiplicityEventFilter<SingleSiStripDigiMultiplicity> BySiStripDigiMultiplicityEventFilter;
0118 typedef ByMultiplicityEventFilter<SingleSiStripClusterMultiplicity> BySiStripClusterMultiplicityEventFilter;
0119 typedef ByMultiplicityEventFilter<SingleSiPixelClusterMultiplicity> BySiPixelClusterMultiplicityEventFilter;
0120 typedef ByMultiplicityEventFilter<SiPixelClusterSiStripClusterMultiplicityPair>
0121     BySiPixelClusterVsSiStripClusterMultiplicityEventFilter;
0122 typedef ByMultiplicityEventFilter<ClusterSummarySingleMultiplicity> ByClusterSummarySingleMultiplicityEventFilter;
0123 typedef ByMultiplicityEventFilter<ClusterSummaryMultiplicityPair> ByClusterSummaryMultiplicityPairEventFilter;
0124 
0125 DEFINE_FWK_MODULE(BySiStripDigiMultiplicityEventFilter);
0126 DEFINE_FWK_MODULE(BySiStripClusterMultiplicityEventFilter);
0127 DEFINE_FWK_MODULE(BySiPixelClusterMultiplicityEventFilter);
0128 DEFINE_FWK_MODULE(BySiPixelClusterVsSiStripClusterMultiplicityEventFilter);
0129 DEFINE_FWK_MODULE(ByClusterSummarySingleMultiplicityEventFilter);
0130 DEFINE_FWK_MODULE(ByClusterSummaryMultiplicityPairEventFilter);