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 Attributes
GenParticlesFromZsSelectorForMCEmbedding Class Reference

#include <GenParticlesFromZsSelectorForMCEmbedding.h>

Inheritance diagram for GenParticlesFromZsSelectorForMCEmbedding:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 GenParticlesFromZsSelectorForMCEmbedding (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &)
 
 ~GenParticlesFromZsSelectorForMCEmbedding ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 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
 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
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

enum  { kBeforeFSR, kAfterFSR }
 
typedef std::vector< int > vint
 

Private Attributes

int before_or_afterFSR_
 
int maxDaughters_
 
int minDaughters_
 
vint pdgIdsDaughters_
 
vint pdgIdsMothers_
 
edm::InputTag src_
 
int verbosity_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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

Select tau leptons, muons and electrons produced in Z/gamma* –> l+ l- processes

NOTE: Can handle case that virtual Z/gamma is missing in GenEVT record

CV: This class is a copy of the copy of the code in TauAnalysis/GenSimTools/plugins/GenParticlesFromZsSelector.h TauAnalysis/GenSimTools/plugins/GenParticlesFromZsSelector.cc The copy was created to avoid package dependencies (of either TauAnalysis/MCEmbeddingTools on TauAnalysis/GenSimTools or of TauAnalysis/GenSimTools on TauAnalysis/MCEmbeddingTools... I know this is not nice)

Author
Christian Veelken, LLR
Version
Revision:
1.2
Id:
GenParticlesFromZsSelectorForMCEmbedding.h,v 1.2 2013/01/31 09:07:18 veelken Exp

Definition at line 33 of file GenParticlesFromZsSelectorForMCEmbedding.h.

Member Typedef Documentation

typedef std::vector<int> GenParticlesFromZsSelectorForMCEmbedding::vint
private

Definition at line 47 of file GenParticlesFromZsSelectorForMCEmbedding.h.

Member Enumeration Documentation

anonymous enum
private

Constructor & Destructor Documentation

GenParticlesFromZsSelectorForMCEmbedding::GenParticlesFromZsSelectorForMCEmbedding ( const edm::ParameterSet cfg)
explicit

Definition at line 13 of file GenParticlesFromZsSelectorForMCEmbedding.cc.

References before_or_afterFSR_, edm::hlt::Exception, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), kAfterFSR, kBeforeFSR, maxDaughters_, minDaughters_, pdgIdsDaughters_, pdgIdsMothers_, src_, AlCaHLTBitMon_QueryRunRegistry::string, and verbosity_.

14 {
15  src_ = cfg.getParameter<edm::InputTag>("src");
16 
17  pdgIdsMothers_ = cfg.getParameter<vint>("pdgIdsMothers");
18  pdgIdsDaughters_ = cfg.getParameter<vint>("pdgIdsDaughters");
19 
20  maxDaughters_ = cfg.getParameter<int>("maxDaughters");
21  minDaughters_ = cfg.getParameter<int>("minDaughters");
22 
23  std::string before_or_afterFSR_string = cfg.getParameter<std::string>("before_or_afterFSR");
24  if ( before_or_afterFSR_string == "beforeFSR" ) before_or_afterFSR_ = kBeforeFSR;
25  else if ( before_or_afterFSR_string == "afterFSR" ) before_or_afterFSR_ = kAfterFSR;
26  else throw cms::Exception("Configuration")
27  << " Invalid Configuration Parameter 'before_or_afterFSR' = " << before_or_afterFSR_string << " !!\n";
28 
29  verbosity_ = ( cfg.exists("verbosity") ) ?
30  cfg.getParameter<int>("verbosity") : 0;
31 
32  produces<reco::GenParticleCollection>("");
33 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
GenParticlesFromZsSelectorForMCEmbedding::~GenParticlesFromZsSelectorForMCEmbedding ( )

Definition at line 35 of file GenParticlesFromZsSelectorForMCEmbedding.cc.

36 {
37 // nothing to be done yet...
38 }

Member Function Documentation

void GenParticlesFromZsSelectorForMCEmbedding::produce ( edm::Event evt,
const edm::EventSetup es 
)
virtual

Implements edm::EDProducer.

Definition at line 98 of file GenParticlesFromZsSelectorForMCEmbedding.cc.

References before_or_afterFSR_, reco::CompositeRefCandidateT< D >::begin(), gather_cfg::cout, reco::CompositeRefCandidateT< D >::end(), reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), genParticleCandidates2GenParticles_cfi::genParticles, edm::Event::getByLabel(), customizeTrackingMonitorSeedNumber::idx, kAfterFSR, kBeforeFSR, maxDaughters_, minDaughters_, pdgIdsDaughters_, pdgIdsMothers_, reco::LeafCandidate::phi(), reco::LeafCandidate::pt(), edm::Event::put(), src_, and verbosity_.

99 {
100  if ( verbosity_ ) {
101  std::cout << "<GenParticlesFromZsSelectorForMCEmbedding::produce>:" << std::endl;
102  std::cout << " src = " << src_ << std::endl;
103  }
104 
106  evt.getByLabel(src_, genParticles);
107 
108  std::vector<const reco::GenParticle*> genParticlesFromZs_tmp;
109 
110 //--- check if HepEVT record contains any Z/gamma* --> l+ l- entries
111 //
112 // NOTE: iteration over mothers in the outer loop
113 // gives Z --> l+ l- decays priority over gamma --> e+ e-
114 //
115  for ( vint::const_iterator pdgIdMother = pdgIdsMothers_.begin();
116  pdgIdMother != pdgIdsMothers_.end(); ++pdgIdMother ) {
117  for ( vint::const_iterator pdgIdDaughter = pdgIdsDaughters_.begin();
118  pdgIdDaughter != pdgIdsDaughters_.end(); ++pdgIdDaughter ) {
119  if ( (int)genParticlesFromZs_tmp.size() < maxDaughters_ || maxDaughters_ == -1 )
120  findGenParticles(*genParticles, *pdgIdMother, *pdgIdDaughter, genParticlesFromZs_tmp);
121  }
122  }
123 
124 //--- check if HepEVT record contains l+ l- entries without Z/gamma* parent
125 //
126 // NOTE: in order to avoid ambiguities, give preference to l+ l- pairs
127 // which are subsequent in HepEVT record
128 //
129  if ( !((int)genParticlesFromZs_tmp.size() >= minDaughters_) ) {
130  for ( vint::const_iterator pdgIdDaughter = pdgIdsDaughters_.begin();
131  pdgIdDaughter != pdgIdsDaughters_.end(); ++pdgIdDaughter ) {
132  findGenParticles(*genParticles, *pdgIdDaughter, minDaughters_, true, genParticlesFromZs_tmp);
133  }
134  }
135  if ( !((int)genParticlesFromZs_tmp.size() >= minDaughters_) ) {
136  for ( vint::const_iterator pdgIdDaughter = pdgIdsDaughters_.begin();
137  pdgIdDaughter != pdgIdsDaughters_.end(); ++pdgIdDaughter ) {
138  findGenParticles(*genParticles, *pdgIdDaughter, minDaughters_, false, genParticlesFromZs_tmp);
139  }
140  }
141 
142  std::auto_ptr<reco::GenParticleCollection> genParticlesFromZs(new reco::GenParticleCollection());
143 
144  int idx = 0;
145  for ( std::vector<const reco::GenParticle*>::const_iterator genParticleFromZ_beforeFSR = genParticlesFromZs_tmp.begin();
146  genParticleFromZ_beforeFSR != genParticlesFromZs_tmp.end(); ++genParticleFromZ_beforeFSR ) {
147  if ( before_or_afterFSR_ == kBeforeFSR ) {
148  genParticlesFromZs->push_back(**genParticleFromZ_beforeFSR);
149  } else if ( before_or_afterFSR_ == kAfterFSR ) {
150  std::vector<const reco::GenParticle*> daughters;
151  findDaughters(*genParticleFromZ_beforeFSR, daughters, -1);
152  const reco::GenParticle* genParticleFromZ_afterFSR = (*genParticleFromZ_beforeFSR);
153  for ( std::vector<const reco::GenParticle*>::const_iterator daughter = daughters.begin();
154  daughter != daughters.end(); ++daughter ) {
155  if ( (*daughter)->pdgId() == (*genParticleFromZ_beforeFSR)->pdgId() &&
156  (*daughter)->energy() < genParticleFromZ_afterFSR->energy() ) genParticleFromZ_afterFSR = (*daughter);
157  }
158  if ( verbosity_ ) {
159  std::cout << "genParticleFromZ #" << idx << " (beforeFSR): Pt = " << (*genParticleFromZ_beforeFSR)->pt() << ","
160  << " eta = " << (*genParticleFromZ_beforeFSR)->eta() << ", phi = " << (*genParticleFromZ_beforeFSR)->phi() << std::endl;
161  std::cout << "genParticleFromZ #" << idx << " (afterFSR): Pt = " << genParticleFromZ_afterFSR->pt() << ","
162  << " eta = " << genParticleFromZ_afterFSR->eta() << ", phi = " << genParticleFromZ_afterFSR->phi() << std::endl;
163  }
164  genParticlesFromZs->push_back(*genParticleFromZ_afterFSR);
165  } else assert(0);
166  ++idx;
167  }
168 
169  evt.put(genParticlesFromZs);
170 }
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
virtual float pt() const
transverse momentum
virtual float phi() const
momentum azimuthal angle
virtual double energy() const
energy
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
virtual float eta() const
momentum pseudorapidity
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:402
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

int GenParticlesFromZsSelectorForMCEmbedding::before_or_afterFSR_
private
int GenParticlesFromZsSelectorForMCEmbedding::maxDaughters_
private
int GenParticlesFromZsSelectorForMCEmbedding::minDaughters_
private
vint GenParticlesFromZsSelectorForMCEmbedding::pdgIdsDaughters_
private
vint GenParticlesFromZsSelectorForMCEmbedding::pdgIdsMothers_
private
edm::InputTag GenParticlesFromZsSelectorForMCEmbedding::src_
private
int GenParticlesFromZsSelectorForMCEmbedding::verbosity_
private