CMS 3D CMS Logo

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::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
 TauGenJetProducer (const edm::ParameterSet &)
 
 ~TauGenJetProducer () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
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.

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

Definition at line 30 of file TauGenJetProducer.cc.

30 { }

Member Function Documentation

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

Definition at line 32 of file TauGenJetProducer.cc.

References funct::abs(), edm::RefVector< C, T, F >::begin(), ALCARECOTkAlJpsiMuMu_cff::charge, gather_cfg::cout, DEFINE_FWK_MODULE, edm::RefVector< C, T, F >::empty(), edm::RefVector< C, T, F >::end(), Exception, GenParticlesHelper::findDescendents(), GenParticlesHelper::findParticles(), runEdmFileComparison::found, GenHFHadronMatcher_cfi::genParticles, edm::Event::getByToken(), includeNeutrinos_, inputTagGenParticles_, metsig::jet, eostools::move(), edm::Event::put(), edm::refToPtr(), reco::LeafCandidate::setCharge(), tokenGenParticles_, and verbose_.

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

const bool TauGenJetProducer::includeNeutrinos_
private

if yes, neutrinos will be included, for debug purposes

Definition at line 41 of file TauGenJetProducer.h.

Referenced by produce().

const edm::InputTag TauGenJetProducer::inputTagGenParticles_
private

Input PFCandidates.

Definition at line 37 of file TauGenJetProducer.h.

Referenced by produce().

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

Definition at line 38 of file TauGenJetProducer.h.

Referenced by produce().

const bool TauGenJetProducer::verbose_
private

verbose ?

Definition at line 44 of file TauGenJetProducer.h.

Referenced by produce().