test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HSCParticleSelector.cc
Go to the documentation of this file.
1 #include <memory>
5 
9 
12 
13 //
14 // class declaration
15 //
17  public:
18  explicit HSCParticleSelector(const edm::ParameterSet&);
20 
21  private:
22  virtual void beginJob() override ;
23  virtual bool filter(edm::Event&, const edm::EventSetup&) override;
24  virtual void endJob() override ;
25 
27 
28  bool Filter_;
29  std::vector<CandidateSelector*> Selectors;
30 };
31 
32 
35 {
36  // What is being produced
37  produces<susybsm::HSCParticleCollection >();
38 
39  // Input products
40  sourceToken_ = consumes<susybsm::HSCParticleCollection>(iConfig.getParameter<edm::InputTag> ("source"));
41  Filter_ = iConfig.getParameter<bool> ("filter");
42 
43  // Load all the selections
44  std::vector<edm::ParameterSet> SelectionParameters = iConfig.getParameter<std::vector<edm::ParameterSet> >("SelectionParameters");
45  for(unsigned int i=0;i<SelectionParameters.size();i++){
46  Selectors.push_back(new CandidateSelector(SelectionParameters[i]) );
47  }
48 }
49 
52 }
53 
56 }
57 
60 }
61 
64 {
65  // Source Collection
67  if (!iEvent.getByToken(sourceToken_, SourceHandle)) {
68  edm::LogError("") << ">>> HSCParticleCollection does not exist !!!";
69  return false;
70  }
72 
73 
74  // Output Collection
76  std::auto_ptr<susybsm::HSCParticleCollection> result(output);
77 
78  // cleanup the collection based on the input selection
79  for(susybsm::HSCParticleCollection::iterator hscpcandidate = Source.begin(); hscpcandidate < Source.end(); ++hscpcandidate){
80  bool decision = false;
81  for(unsigned int i=0;i<Selectors.size();i++){decision |= Selectors[i]->isSelected(*hscpcandidate);}
82  if(decision){
83  susybsm::HSCParticle* newhscp = new susybsm::HSCParticle(*hscpcandidate);
84  output->push_back(*newhscp);
85  }
86  }
87 
88  bool filterResult = !Filter_ || (Filter_ && output->size()>=1);
89 
90  iEvent.put(result);
91 
92  return filterResult;
93 }
94 
96 
97 
98 
99 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void beginJob() override
tuple result
Definition: mps_fire.py:84
std::vector< HSCParticle > HSCParticleCollection
Definition: HSCParticle.h:94
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
HSCParticleSelector(const edm::ParameterSet &)
edm::EDGetTokenT< susybsm::HSCParticleCollection > sourceToken_
T const * product() const
Definition: Handle.h:81
std::vector< CandidateSelector * > Selectors
virtual void endJob() override
virtual bool filter(edm::Event &, const edm::EventSetup &) override