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

builds a GenJet from the visible daughters of each status 2 tau in the event. More...

#include <TauGenJetProducer.h>

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

Public Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &) override
 
 TauGenJetProducer (const edm::ParameterSet &)
 
 ~TauGenJetProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- 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 Attributes

bool includeNeutrinos_
 if yes, neutrinos will be included, for debug purposes More...
 
edm::InputTag inputTagGenParticles_
 Input PFCandidates. More...
 
edm::EDGetTokenT
< reco::GenParticleCollection
tokenGenParticles_
 
bool verbose_
 verbose ? More...
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer 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::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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

builds a GenJet from the visible daughters of each status 2 tau in the event.

Author
Colin Bernet
Date
february 2008

Definition at line 25 of file TauGenJetProducer.h.

Constructor & Destructor Documentation

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

Definition at line 19 of file TauGenJetProducer.cc.

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

20 {
22  = iConfig.getParameter<InputTag>("GenParticles");
24  = consumes<GenParticleCollection>(inputTagGenParticles_);
25 
27  = iConfig.getParameter<bool>("includeNeutrinos");
28 
29  verbose_ =
30  iConfig.getUntrackedParameter<bool>("verbose",false);
31 
32  produces<GenJetCollection>();
33 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool verbose_
verbose ?
edm::EDGetTokenT< reco::GenParticleCollection > tokenGenParticles_
bool includeNeutrinos_
if yes, neutrinos will be included, for debug purposes
edm::InputTag inputTagGenParticles_
Input PFCandidates.
TauGenJetProducer::~TauGenJetProducer ( )

Definition at line 35 of file TauGenJetProducer.cc.

35 { }

Member Function Documentation

void TauGenJetProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 37 of file TauGenJetProducer.cc.

References funct::abs(), edm::RefVector< C, T, F >::begin(), RecoTauCleanerPlugins::charge, gather_cfg::cout, edm::RefVector< C, T, F >::end(), edm::hlt::Exception, GenParticlesHelper::findDescendents(), GenParticlesHelper::findParticles(), newFWLiteAna::found, genParticleCandidates2GenParticles_cfi::genParticles, edm::Event::getByToken(), metsig::jet, edm::Event::put(), edm::refToPtr(), reco::LeafCandidate::setCharge(), edm::RefVector< C, T, F >::size(), and timingPdfMaker::specific.

38  {
39 
41 
42  bool found = iEvent.getByToken( tokenGenParticles_, genParticles);
43 
44  if ( !found ) {
45  std::ostringstream err;
46  err<<" cannot get collection: "
47  <<inputTagGenParticles_<<std::endl;
48  edm::LogError("TauGenJetProducer")<<err.str();
49  throw cms::Exception( "MissingProduct", err.str());
50  }
51 
52  std::auto_ptr<GenJetCollection>
53  pOutVisTaus(new GenJetCollection());
54 
55  using namespace GenParticlesHelper;
56 
57  GenParticleRefVector allStatus2Taus;
58  findParticles( *genParticles,
59  allStatus2Taus, 15, 2);
60 
61  for ( IGR iTau=allStatus2Taus.begin(); iTau!=allStatus2Taus.end(); ++iTau ) {
62 
63  // look for all status 1 (stable) descendents
64  GenParticleRefVector descendents;
65  findDescendents( *iTau, descendents, 1);
66 
67  // CV: skip status 2 taus that radiate-off a photon
68  // --> have a status 2 tau lepton in the list of descendents
69  GenParticleRefVector status2TauDaughters;
70  findDescendents( *iTau, status2TauDaughters, 2, 15 );
71  if ( status2TauDaughters.size() > 0 ) continue;
72 
73  // loop on descendents, and take all except neutrinos
74  math::XYZTLorentzVector sumVisMom;
75  Particle::Charge charge = 0;
76  Jet::Constituents constituents;
77 
78  if(verbose_)
79  cout<<"tau "<<(*iTau)<<endl;
80 
81  for(IGR igr = descendents.begin();
82  igr!= descendents.end(); ++igr ) {
83 
84  int absPdgId = abs((*igr)->pdgId());
85 
86  // neutrinos
87  if(!includeNeutrinos_ ) {
88  if( absPdgId == 12 ||
89  absPdgId == 14 ||
90  absPdgId == 16 )
91  continue;
92  }
93 
94  if(verbose_)
95  cout<<"\t"<<(*igr)<<endl;
96 
97  charge += (*igr)->charge();
98  sumVisMom += (*igr)->p4();
99 
100  // need to convert the vector of reference to the constituents
101  // to a vector of pointers to build the genjet
102  constituents.push_back( refToPtr( *igr) );
103  }
104 
105  math::XYZPoint vertex;
107 
108  GenJet jet( sumVisMom, vertex, specific, constituents);
109 
110  if (charge != (*iTau)->charge() )
111  std::cout<<" charge of Tau: " << (*iTau) << " not equal to charge of sum of charge of all descendents. " << std::cout;
112 
113  jet.setCharge(charge);
114  pOutVisTaus->push_back( jet );
115 
116  }
117  iEvent.put( pOutVisTaus );
118 }
dictionary specific
bool verbose_
verbose ?
edm::EDGetTokenT< reco::GenParticleCollection > tokenGenParticles_
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
void findParticles(const reco::GenParticleCollection &sourceParticles, reco::GenParticleRefVector &particleRefs, int pdgId, int status)
find all particles of a given pdgId and status
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
std::vector< GenJet > GenJetCollection
collection of GenJet objects
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:255
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:250
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Jets made from MC generator particles.
Definition: GenJet.h:24
bool includeNeutrinos_
if yes, neutrinos will be included, for debug purposes
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
edm::InputTag inputTagGenParticles_
Input PFCandidates.
size_type size() const
Size of the RefVector.
Definition: RefVector.h:99
tuple cout
Definition: gather_cfg.py:121
void findDescendents(const reco::GenParticleRef &base, reco::GenParticleRefVector &descendents, int status, int pdgId=0)
find all descendents of a given status and pdgId (recursive)

Member Data Documentation

bool TauGenJetProducer::includeNeutrinos_
private

if yes, neutrinos will be included, for debug purposes

Definition at line 41 of file TauGenJetProducer.h.

edm::InputTag TauGenJetProducer::inputTagGenParticles_
private

Input PFCandidates.

Definition at line 37 of file TauGenJetProducer.h.

edm::EDGetTokenT<reco::GenParticleCollection> TauGenJetProducer::tokenGenParticles_
private

Definition at line 38 of file TauGenJetProducer.h.

bool TauGenJetProducer::verbose_
private

verbose ?

Definition at line 44 of file TauGenJetProducer.h.