CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
GenVisTauProducer Class Reference
Inheritance diagram for GenVisTauProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 GenVisTauProducer (const edm::ParameterSet &params)
 
void produce (edm::StreamID id, edm::Event &evt, const edm::EventSetup &es) const override
 
 ~GenVisTauProducer () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
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)
 
virtual ~ProducerBase () noexcept(false)
 
- 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)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

const edm::EDGetTokenT< reco::GenJetCollectionsrc_
 
const edm::EDGetTokenT< reco::GenParticleCollectionsrcGenParticles_
 

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
 
- 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 18 of file GenVisTauProducer.cc.

Constructor & Destructor Documentation

GenVisTauProducer::GenVisTauProducer ( const edm::ParameterSet params)
inline

Definition at line 21 of file GenVisTauProducer.cc.

22  : src_(consumes<reco::GenJetCollection>(params.getParameter<edm::InputTag>("src")))
23  , srcGenParticles_(consumes<reco::GenParticleCollection>(params.getParameter<edm::InputTag>("srcGenParticles")))
24  {
25  produces<reco::GenParticleCollection>();
26  }
T getParameter(std::string const &) const
const edm::EDGetTokenT< reco::GenParticleCollection > srcGenParticles_
const edm::EDGetTokenT< reco::GenJetCollection > src_
GenVisTauProducer::~GenVisTauProducer ( )
inlineoverride

Definition at line 28 of file GenVisTauProducer.cc.

28 {}

Member Function Documentation

static void GenVisTauProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 83 of file GenVisTauProducer.cc.

References edm::ConfigurationDescriptions::add(), and edm::ParameterSetDescription::add().

83  {
85  desc.add<edm::InputTag>("src")->setComment("collection of visible gen taus (as reco::GenJetCollection)");
86  desc.add<edm::InputTag>("srcGenParticles")->setComment("collections of gen particles");
87  descriptions.add("genVisTaus", desc);
88  }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void GenVisTauProducer::produce ( edm::StreamID  id,
edm::Event evt,
const edm::EventSetup es 
) const
inlineoverride

Definition at line 30 of file GenVisTauProducer.cc.

References funct::abs(), reco::CompositeRefCandidateT< D >::daughterRefVector(), taus_cff::decayMode, reco::deltaR2(), MillePedeFileConverter_cfg::e, GenHFHadronMatcher_cfi::genParticles, JetMCTagUtils::genTauDecayMode(), taus_cff::genVisTaus, edm::Event::getByToken(), reco::PFTau::kNull, reco::PFTau::kOneProng0PiZero, reco::PFTau::kOneProng1PiZero, reco::PFTau::kOneProng2PiZero, reco::PFTau::kRareDecayMode, reco::PFTau::kThreeProng0PiZero, reco::PFTau::kThreeProng1PiZero, eostools::move(), common_cff::pdgId, reco::LeafCandidate::pdgId(), edm::Event::put(), src_, srcGenParticles_, reco::LeafCandidate::status(), and AlCaHLTBitMon_QueryRunRegistry::string.

31  {
33  evt.getByToken(src_, genTauJets);
34 
36  evt.getByToken(srcGenParticles_, genParticles);
37  size_t numGenParticles = genParticles->size();
38 
39  auto genVisTaus = std::make_unique<reco::GenParticleCollection>();
40 
41  for (const auto & genTauJet : *genTauJets) {
42  std::string decayMode_string = JetMCTagUtils::genTauDecayMode(genTauJet);
43  // CV: store hadronic tau decays only
44  if ( decayMode_string == "electron" || decayMode_string == "muon" ) continue;
46  if ( decayMode_string == "oneProng0Pi0" ) decayMode = reco::PFTau::kOneProng0PiZero;
47  else if ( decayMode_string == "oneProng1Pi0" ) decayMode = reco::PFTau::kOneProng1PiZero;
48  else if ( decayMode_string == "oneProng2Pi0" ) decayMode = reco::PFTau::kOneProng2PiZero;
49  else if ( decayMode_string == "threeProng0Pi0" ) decayMode = reco::PFTau::kThreeProng0PiZero;
50  else if ( decayMode_string == "threeProng1Pi0" ) decayMode = reco::PFTau::kThreeProng1PiZero;
51  else decayMode = reco::PFTau::kRareDecayMode;
52 
53  int pdgId = ( genTauJet.charge() > 0 ) ? -15 : +15;
54 
55  // CV: store decayMode in status flag of GenParticle object
56  reco::GenParticle genVisTau(genTauJet.charge(), genTauJet.p4(), genTauJet.vertex(), pdgId, decayMode, true);
57 
58  // CV: find tau lepton "mother" particle
59  for ( size_t idxGenParticle = 0; idxGenParticle < numGenParticles; ++idxGenParticle ) {
60  const reco::GenParticle & genTau = (*genParticles)[idxGenParticle];
61  if ( abs(genTau.pdgId()) == 15 && genTau.status() == 2 ) {
62  reco::Candidate::LorentzVector daughterVisP4;
63  for (const reco::GenParticleRef & daughter : genTau.daughterRefVector()) {
64  int abs_pdgId = abs(daughter->pdgId());
65  // CV: skip neutrinos
66  if ( abs_pdgId == 12 || abs_pdgId == 14 || abs_pdgId == 16 ) continue;
67  daughterVisP4 += daughter->p4();
68  }
69  double dR2 = deltaR2(daughterVisP4, genVisTau);
70  if ( dR2 < 1.e-4 ) {
71  genVisTau.addMother(reco::GenParticleRef(genParticles, idxGenParticle));
72  break;
73  }
74  }
75  }
76 
77  genVisTaus->push_back(genVisTau);
78  }
79 
80  evt.put(std::move(genVisTaus));
81  }
int pdgId() const final
PDG identifier.
std::string genTauDecayMode(const reco::CompositePtrCandidate &c)
Definition: JetMCTag.cc:81
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
const daughters & daughterRefVector() const
references to daughtes
genVisTaus
Definition: taus_cff.py:79
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const edm::EDGetTokenT< reco::GenParticleCollection > srcGenParticles_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
int status() const final
status word
const edm::EDGetTokenT< reco::GenJetCollection > src_
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

const edm::EDGetTokenT<reco::GenJetCollection> GenVisTauProducer::src_
private

Definition at line 92 of file GenVisTauProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<reco::GenParticleCollection> GenVisTauProducer::srcGenParticles_
private

Definition at line 93 of file GenVisTauProducer.cc.

Referenced by produce().