CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
JetFlavourFilter Class Reference

#include <JetFlavourFilter.h>

Inheritance diagram for JetFlavourFilter:
edm::EDFilter edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

virtual bool filter (edm::Event &, const edm::EventSetup &)
 
 JetFlavourFilter (const edm::ParameterSet &)
 
 ~JetFlavourFilter ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Types

typedef std::vector
< HepMC::GenParticle * > 
GenPartVect
 
typedef std::vector
< HepMC::GenParticle * >
::const_iterator 
GenPartVectIt
 

Private Member Functions

HepMC::GenParticle * findParticle (const GenPartVect genPartVect, const int requested_id)
 
void printHisto (const HepMC::GenEvent::particle_iterator start, const HepMC::GenEvent::particle_iterator end)
 

Private Attributes

int jetType
 
std::string label_
 
int noAccepted
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
typedef WorkerT< EDFilterWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDFilter
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 25 of file JetFlavourFilter.h.

Member Typedef Documentation

typedef std::vector< HepMC::GenParticle * > JetFlavourFilter::GenPartVect
private

Definition at line 37 of file JetFlavourFilter.h.

typedef std::vector< HepMC::GenParticle * >::const_iterator JetFlavourFilter::GenPartVectIt
private

Definition at line 38 of file JetFlavourFilter.h.

Constructor & Destructor Documentation

JetFlavourFilter::JetFlavourFilter ( const edm::ParameterSet iConfig)
explicit

Definition at line 9 of file JetFlavourFilter.cc.

References edm::ParameterSet::getParameter(), and edm::ParameterSet::getUntrackedParameter().

10 {
11  label_ = iConfig.getUntrackedParameter("moduleLabel",std::string("generator"));
12  jetType = iConfig.getParameter< int >("jetType");
13  if ((jetType>=1)&&(jetType<=3)) jetType=1;
14 
15  noAccepted = 0;
16 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::string label_
JetFlavourFilter::~JetFlavourFilter ( )

Definition at line 19 of file JetFlavourFilter.cc.

References gather_cfg::cout.

20 {
21  std::cout << "Total number of accepted events = " << noAccepted << std::endl;
22 }
tuple cout
Definition: gather_cfg.py:121

Member Function Documentation

bool JetFlavourFilter::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDFilter.

Definition at line 73 of file JetFlavourFilter.cc.

References alignCSCRings::ff, reco::flavour(), edm::Event::getByLabel(), i, AlCaHLTBitMon_ParallelJobs::p, parents, and detailsBasic3DVector::z.

74 {
76  iEvent.getByLabel(label_, evt);
77 
78  const HepMC::GenEvent * generated_event = evt->GetEvent();
79 
80  bool event_passed = false;
81 
82  vector<int> foundQ;
83  HepMC::GenEvent::particle_const_iterator p;
84  for (p = generated_event->particles_begin(); p != generated_event->particles_end(); p++) {
85  if (((*p)->pdg_id() < 1) && ((*p)->pdg_id() > -10)) { // We have an anti-quark
86 // cout << "antiQ "<< (*p)->pdg_id();
87  //vector< GenParticle * > parents = (*p)->listParents();
88  vector< GenParticle * > parents;
89  HepMC::GenVertex* inVertex = (*p)->production_vertex();
90  for(GenVertex::particles_in_const_iterator iter = inVertex->particles_in_const_begin();
91  iter != inVertex->particles_in_const_end();iter++)
92  parents.push_back(*iter);
93 
94  for (GenPartVectIt z = parents.begin(); z != parents.end(); z++){
95 
96  vector< GenParticle * > child;
97  HepMC::GenVertex* outVertex = (*z)->end_vertex();
98  for(GenVertex::particles_in_const_iterator iter = outVertex->particles_in_const_begin();
99  iter != outVertex->particles_in_const_end();iter++)
100  child.push_back(*iter);
101 
102  if (findParticle(child, -(*p)->pdg_id())) foundQ.push_back(-(*p)->pdg_id());
103  }
104 // cout << " "<< foundQ.size()<<endl;
105 
106  }
107 
108  }
109 
110  int flavour = 0;
111  int ff[6];
112  ff[0]=0; ff[1]=0; ff[2]=0; ff[3]=0; ff[4]=0; ff[5]=0;
113  for (vector<int>::iterator i = foundQ.begin(); i != foundQ.end(); i++){
114  ++ff[(*i)-1];
115  if ((*i)>flavour) flavour = (*i);
116  }
117  // Is it light quark jet?
118  if ((flavour>=0)&&(flavour<=3)) flavour=1;
119  // Do we have more than one heavy flavour ?
120  if ( (ff[3] && ff[4]) || (ff[3] && ff[5]) || (ff[4] && ff[5]) ) flavour =0;
121 
122  if (jetType==flavour) event_passed =true;
123 
124 // cout <<"Final flavour: " << ff[0]<<" "<<ff[1]<<" "<<ff[2]<<" "<<ff[3]<<" "<<ff[4]<<" "<<ff[5];
125 // if (ff[0]||ff[1]||ff[2]) cout << " light";
126 // if (ff[3]) cout << " charm";
127 // if (ff[4]) cout << " bottom";
128 // if (ff[5]) cout << " top";
129 // if ((ff[0]||ff[1]||ff[2])&&((ff[3] + ff[4]+ff[5]))) {cout << " LH";};
130 // if ( (ff[3] && ff[4]) || (ff[3] && ff[5]) || (ff[4] && ff[5]) ) {cout <<" notDef";}//printHisto(start,end);//}
131 
132 // cout<<" "<<flavour<<event_passed<<endl;
133 
134  if (event_passed) noAccepted++;
135 
136  delete generated_event;
137 
138  return event_passed;
139 }
int i
Definition: DBlmapReader.cc:9
TPRegexp parents
Definition: eve_filter.cc:24
double double double z
std::string label_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
HepMC::GenParticle * findParticle(const GenPartVect genPartVect, const int requested_id)
std::vector< HepMC::GenParticle * >::const_iterator GenPartVectIt
int flavour(const Candidate &part)
Definition: pdgIdUtils.h:31
HepMC::GenParticle * JetFlavourFilter::findParticle ( const GenPartVect  genPartVect,
const int  requested_id 
)
private

Definition at line 25 of file JetFlavourFilter.cc.

References AlCaHLTBitMon_ParallelJobs::p.

27 {
28  for (GenPartVectIt p = genPartVect.begin(); p != genPartVect.end(); p++)
29  {
30  if (requested_id == (*p)->pdg_id()) return *p;
31  }
32  return 0;
33 }
std::vector< HepMC::GenParticle * >::const_iterator GenPartVectIt
void JetFlavourFilter::printHisto ( const HepMC::GenEvent::particle_iterator  start,
const HepMC::GenEvent::particle_iterator  end 
)
private

Definition at line 38 of file JetFlavourFilter.cc.

References gather_cfg::cout, end, AlCaHLTBitMon_ParallelJobs::p, parents, and detailsBasic3DVector::z.

40 {
41  HepMC::GenEvent::particle_iterator p;
42  for (p = start; p != end; p++)
43  {
44  //vector< GenParticle * > parents = (*p)->listParents();
45  vector< GenParticle * > parents;
46  HepMC::GenVertex* inVertex = (*p)->production_vertex();
47  for(std::vector<GenParticle*>::const_iterator iter = inVertex->particles_in_const_begin();
48  // for(GenVertex::particles_in_const_iterator iter = inVertex->particles_in_const_begin();
49  iter != inVertex->particles_in_const_end();iter++)
50  parents.push_back(*iter);
51 
52  cout << "isC "<<(*p)->pdg_id()<<" status "<<(*p)->status()<<" Parents: "<<parents.size()<<" - ";
53  for (GenPartVectIt z = parents.begin(); z != parents.end(); z++){
54  cout << (*z)->pdg_id()<<" ";
55  }
56 
57  //vector< GenParticle * > child = (*p)->listChildren();
58  vector< GenParticle * > child;
59  HepMC::GenVertex* outVertex = (*p)->end_vertex();
60  for(GenVertex::particles_in_const_iterator iter = outVertex->particles_in_const_begin();
61  iter != outVertex->particles_in_const_end();iter++)
62  child.push_back(*iter);
63 
64  cout << " - Child: "<<child.size()<<" - ";
65  for (GenPartVectIt z = child.begin(); z != child.end(); z++){
66  cout << (*z)->pdg_id()<<" ";
67  }
68  cout<<"\n";
69  }
70 }
TPRegexp parents
Definition: eve_filter.cc:24
double double double z
#define end
Definition: vmac.h:38
std::vector< HepMC::GenParticle * >::const_iterator GenPartVectIt
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

int JetFlavourFilter::jetType
private

Definition at line 46 of file JetFlavourFilter.h.

std::string JetFlavourFilter::label_
private
int JetFlavourFilter::noAccepted
private

Definition at line 49 of file JetFlavourFilter.h.