CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HFFilter.cc
Go to the documentation of this file.
3 
5 
6 using namespace std;
7 
8 //
9 // constructors and destructor
10 //
12 {
13  genJetsCollToken_ = consumes<vector<reco::GenJet>>(iConfig.getParameter<edm::InputTag>("genJetsCollName"));
14  ptMin_ = iConfig.getParameter<double>("ptMin");
15  etaMax_ = iConfig.getParameter<double>("etaMax");
16 }
17 
18 
20 {
21 }
22 
23 
24 //
25 // member functions
26 //
27 
28 // Filter event based on whether there are heavy flavor GenJets in it that satisfy
29 // pt and eta cuts
30 bool
32 {
33 
34  // Get the GenJetCollection
35  using namespace edm;
36  using namespace reco;
37  Handle<std::vector<GenJet> > hGenJets;
38  iEvent.getByToken(genJetsCollToken_,hGenJets);
39 
40  // Loop over the GenJetCollection
41  vector<GenJet>::const_iterator ijet = hGenJets->begin();
42  vector<GenJet>::const_iterator end = hGenJets->end();
43  for ( ; ijet != end; ++ijet ) {
44 
45  // Check to make sure the GenJet satisfies kinematic cuts. Ignore those that don't.
46  if ( ijet->pt() < ptMin_ || fabs(ijet->eta()) > etaMax_ ) continue;
47 
48  // Get the constituent particles
49  vector<const GenParticle*> particles = ijet->getGenConstituents ();
50 
51  // Loop over the constituent particles
52  vector<const GenParticle*>::const_iterator genit = particles.begin();
53  vector<const GenParticle*>::const_iterator genend = particles.end();
54  for ( ; genit != genend; ++genit ) {
55 
56  // See if any of them come from B or C hadrons
57  const GenParticle & genitref = **genit;
58  if ( JetMCTagUtils::decayFromBHadron( genitref ) ||
59  JetMCTagUtils::decayFromCHadron( genitref ) ) {
60  return true;
61  }
62  }// end loop over constituents
63  }// end loop over jets
64 
65 
66  return false;
67 }
68 
69 // ------------ method called once each job just after ending the event loop ------------
70 void
72 }
73 
74 //define this as a plug-in
T getParameter(std::string const &) const
virtual void endJob()
Definition: HFFilter.cc:71
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
~HFFilter()
Definition: HFFilter.cc:19
int iEvent
Definition: GenABIO.cc:230
#define end
Definition: vmac.h:37
bool decayFromCHadron(const reco::Candidate &c)
Definition: JetMCTag.cc:61
bool decayFromBHadron(const reco::Candidate &c)
Definition: JetMCTag.cc:40
HFFilter(const edm::ParameterSet &)
Definition: HFFilter.cc:11
virtual bool filter(edm::Event &, const edm::EventSetup &) override
Definition: HFFilter.cc:31