CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SimpleJetFilter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Utilities
4 // Class: SimpleJetFilter
5 //
13 //
14 // Original Author: Andrea Venturi
15 // Created: Tue Oct 21 20:55:22 CEST 2008
16 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 #include <string>
23 
24 // user include files
27 
32 
34 
36 
38 
41 
44 
45 //
46 // class declaration
47 //
48 
50  public:
51  explicit SimpleJetFilter(const edm::ParameterSet&);
53 
54  private:
55  virtual void beginJob() override ;
56  virtual bool filter(edm::Event&, const edm::EventSetup&) override;
57  virtual void endJob() override ;
58 
59  // ----------member data ---------------------------
60 
63  const double m_ptcut;
64  const double m_etamaxcut;
65  const double m_njetmin;
67 
68 };
69 
70 //
71 // constants, enums and typedefs
72 //
73 
74 //
75 // static data member definitions
76 //
77 
78 //
79 // constructors and destructor
80 //
82  m_jetCollection(iConfig.getParameter<edm::InputTag>("jetCollection")),
83  m_jetIDMap(iConfig.getParameter<edm::InputTag>("jetIDMap")),
84  m_ptcut(iConfig.getParameter<double>("ptCut")),
85  m_etamaxcut(iConfig.getParameter<double>("maxRapidityCut")),
86  m_njetmin(iConfig.getParameter<unsigned int>("nJetMin")),
88 {
89  //now do what ever initialization is needed
90 
91 
92 }
93 
95 {
96 
97  // do anything here that needs to be done at desctruction time
98  // (e.g. close files, deallocate resources etc.)
99 
100 }
101 
102 
103 //
104 // member functions
105 //
106 
107 // ------------ method called on each new Event ------------
108 bool
110 {
111  using namespace edm;
112 
113  bool selected = false;
114 
116  iEvent.getByLabel(m_jetCollection,jetcoll);
117 
119  iEvent.getByLabel(m_jetIDMap,jetIDmap);
120 
121  unsigned int goodjets = 0;
122 
123  for(unsigned int ijet=0;ijet<jetcoll->size();++ijet) {
124 
125  const reco::CaloJetRef jet(jetcoll,ijet);
126 
127  LogDebug("JetUnderTest") << "Jet with eta = " << jet->eta() << " and pt = " << jet->pt() << " under test";
128 
129  if( !(std::abs(jet->eta()) < m_etamaxcut && jet->pt() > m_ptcut )) continue;
130 
131  LogDebug("JetUnderTest") << "kincut passed";
132 
133  if(jetIDmap->contains(jet.id())) {
134 
135  const reco::JetID & jetid = (*jetIDmap)[jet];
137  ret.set(false);
138  bool goodjet = m_jetIDfunc((*jetcoll)[ijet],jetid,ret);
139  if(goodjet) {
140  ++goodjets;
141  LogDebug("JetUnderTest") << "JetID passed";
142  }
143  if(goodjets >= m_njetmin) return true;
144 
145  } else {
146  edm::LogWarning("JetIDNotFound") << "JetID not found ";
147 
148  }
149 
150  }
151 
152  return selected;
153 }
154 
155 // ------------ method called once each job just before starting event loop ------------
156 void
158 {
159 }
160 
161 // ------------ method called once each job just after ending the event loop ------------
162 void
164 }
165 
166 //define this as a plug-in
#define LogDebug(id)
const double m_etamaxcut
edm::InputTag m_jetIDMap
virtual void endJob() override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
Jet ID object.
Definition: JetID.h:16
ProductID id() const
Accessor for product ID.
Definition: Ref.h:258
int iEvent
Definition: GenABIO.cc:230
const double m_ptcut
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
JetIDSelectionFunctor m_jetIDfunc
SimpleJetFilter(const edm::ParameterSet &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:420
virtual void beginJob() override
Jet selector for pat::Jets and for CaloJets.
strbitset & set(bool val=true)
set method of all bits
Definition: strbitset.h:144
virtual bool filter(edm::Event &, const edm::EventSetup &) override
pat::strbitset getBitTemplate() const
Get an empty bitset with the proper names.
Definition: Selector.h:212
const double m_njetmin
edm::InputTag m_jetCollection