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::EDConsumerBase 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 ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
 
int noAccepted
 
edm::EDGetTokenT
< edm::HepMCProduct
token_
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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(), edm::ParameterSet::getUntrackedParameter(), HLT_25ns14e33_v1_cff::InputTag, HLT_25ns14e33_v1_cff::jetType, and AlCaHLTBitMon_QueryRunRegistry::string.

10 {
11  token_ = consumes<edm::HepMCProduct>(edm::InputTag(iConfig.getUntrackedParameter("moduleLabel",std::string("generator")),"unsmeared"));
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
edm::EDGetTokenT< edm::HepMCProduct > token_
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 class-composition::child, alignCSCRings::ff, reco::flavour(), edm::Event::getByToken(), i, HLT_25ns14e33_v1_cff::jetType, AlCaHLTBitMon_ParallelJobs::p, and parents.

74 {
76  iEvent.getByToken(token_, 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:21
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
HepMC::GenParticle * findParticle(const GenPartVect &genPartVect, const int requested_id)
edm::EDGetTokenT< edm::HepMCProduct > token_
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 class-composition::child, gather_cfg::cout, end, AlCaHLTBitMon_ParallelJobs::p, and parents.

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 }
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
TPRegexp parents
Definition: eve_filter.cc:21
#define end
Definition: vmac.h:37
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.

int JetFlavourFilter::noAccepted
private

Definition at line 49 of file JetFlavourFilter.h.

edm::EDGetTokenT<edm::HepMCProduct> JetFlavourFilter::token_
private

Definition at line 48 of file JetFlavourFilter.h.