CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BooleanFlagFilter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CommonTools/RecoAlgos
4 // Class: BooleanFlagFilter
5 //
13 //
14 // Original Author: Igor Volobouev
15 // Created: Fri, 20 Mar 2015 08:05:20 GMT
16 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
29 
31 
32 //
33 // class declaration
34 //
35 
37  public:
38  explicit BooleanFlagFilter(const edm::ParameterSet&);
40 
41  private:
42  virtual void beginJob() override;
43  virtual bool filter(edm::Event&, const edm::EventSetup&) override;
44  virtual void endJob() override;
45 
46  //virtual void beginRun(edm::Run const&, edm::EventSetup const&) override;
47  //virtual void endRun(edm::Run const&, edm::EventSetup const&) override;
48  //virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
49  //virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
50 
51  // ----------member data ---------------------------
53  bool reverse_;
54 };
55 
56 //
57 // constants, enums and typedefs
58 //
59 
60 //
61 // static data member definitions
62 //
63 
64 //
65 // constructors and destructor
66 //
68 {
69  //now do what ever initialization is needed
70  inputToken_ = consumes<bool>(iConfig.getParameter<edm::InputTag>("inputLabel"));
71  reverse_ = iConfig.getParameter<bool>("reverseDecision");
72 }
73 
74 
76 {
77 
78  // do anything here that needs to be done at desctruction time
79  // (e.g. close files, deallocate resources etc.)
80 
81 }
82 
83 
84 //
85 // member functions
86 //
87 
88 // ------------ method called on each new Event ------------
89 bool
91 {
92  using namespace edm;
93 
94  Handle<bool> pIn;
95  iEvent.getByToken(inputToken_, pIn);
96  if (!pIn.isValid())
97  {
98  throw edm::Exception(edm::errors::ProductNotFound) << " could not find requested flag\n";
99  return true;
100  }
101 
102  bool result = *pIn;
103  if (reverse_)
104  result = !result;
105 
106  return result;
107 }
108 
109 // ------------ method called once each job just before starting event loop ------------
110 void
112 {
113 }
114 
115 // ------------ method called once each job just after ending the event loop ------------
116 void
118 }
119 
120 // ------------ method called when starting to processes a run ------------
121 /*
122 void
123 BooleanFlagFilter::beginRun(edm::Run const&, edm::EventSetup const&)
124 {
125 }
126 */
127 
128 // ------------ method called when ending the processing of a run ------------
129 /*
130 void
131 BooleanFlagFilter::endRun(edm::Run const&, edm::EventSetup const&)
132 {
133 }
134 */
135 
136 // ------------ method called when starting to processes a luminosity block ------------
137 /*
138 void
139 BooleanFlagFilter::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
140 {
141 }
142 */
143 
144 // ------------ method called when ending the processing of a luminosity block ------------
145 /*
146 void
147 BooleanFlagFilter::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
148 {
149 }
150 */
151 
152 //define this as a plug-in
virtual void endJob() override
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
virtual bool filter(edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int iEvent
Definition: GenABIO.cc:230
tuple result
Definition: query.py:137
BooleanFlagFilter(const edm::ParameterSet &)
virtual void beginJob() override
edm::EDGetTokenT< bool > inputToken_