CMS 3D CMS Logo

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&);
19  ~HSCParticleSelector() override;
20 
21  private:
22  void beginJob() override ;
23  bool filter(edm::Event&, const edm::EventSetup&) override;
24  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::unique_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->empty());
89 
90  iEvent.put(std::move(result));
91 
92  return filterResult;
93 }
94 
96 
97 
98 
99 
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void beginJob() override
std::vector< HSCParticle > HSCParticleCollection
Definition: HSCParticle.h:94
int iEvent
Definition: GenABIO.cc:230
HSCParticleSelector(const edm::ParameterSet &)
edm::EDGetTokenT< susybsm::HSCParticleCollection > sourceToken_
T const * product() const
Definition: Handle.h:81
std::vector< CandidateSelector * > Selectors
bool filter(edm::Event &, const edm::EventSetup &) override
def move(src, dest)
Definition: eostools.py:510