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 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 () noexcept(false) 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)
 

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 GreaterByPt< reco::GenParticlepTComparator_
 
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 19 of file GenVisTauProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 22 of file GenVisTauProducer.cc.

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

Definition at line 30 of file GenVisTauProducer.cc.

30 {}

Member Function Documentation

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

Definition at line 86 of file GenVisTauProducer.cc.

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

86  {
88  desc.add<edm::InputTag>("src")->setComment("collection of visible gen taus (as reco::GenJetCollection)");
89  desc.add<edm::InputTag>("srcGenParticles")->setComment("collections of gen particles");
90  descriptions.add("genVisTaus", desc);
91  }
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 32 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(), pTComparator_, edm::Event::put(), src_, srcGenParticles_, reco::LeafCandidate::status(), and AlCaHLTBitMon_QueryRunRegistry::string.

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

Member Data Documentation

const GreaterByPt<reco::GenParticle> GenVisTauProducer::pTComparator_
private

Definition at line 97 of file GenVisTauProducer.cc.

Referenced by produce().

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

Definition at line 95 of file GenVisTauProducer.cc.

Referenced by produce().

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

Definition at line 96 of file GenVisTauProducer.cc.

Referenced by produce().