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 hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () 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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 19 of file GenVisTauProducer.cc.

Constructor & Destructor Documentation

◆ GenVisTauProducer()

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  pTComparator_() {
25  produces<reco::GenParticleCollection>();
26  }

◆ ~GenVisTauProducer()

GenVisTauProducer::~GenVisTauProducer ( )
inlineoverride

Definition at line 28 of file GenVisTauProducer.cc.

28 {}

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 91 of file GenVisTauProducer.cc.

91  {
93  desc.add<edm::InputTag>("src")->setComment("collection of visible gen taus (as reco::GenJetCollection)");
94  desc.add<edm::InputTag>("srcGenParticles")->setComment("collections of gen particles");
95  descriptions.add("genVisTaus", desc);
96  }

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

◆ produce()

void GenVisTauProducer::produce ( edm::StreamID  id,
edm::Event evt,
const edm::EventSetup es 
) const
inlineoverridevirtual

Implements edm::global::EDProducerBase.

Definition at line 30 of file GenVisTauProducer.cc.

30  {
32  evt.getByToken(src_, genTauJets);
33 
36  size_t numGenParticles = genParticles->size();
37 
38  auto genVisTaus = std::make_unique<reco::GenParticleCollection>();
39 
40  for (const auto& genTauJet : *genTauJets) {
41  std::string decayMode_string = JetMCTagUtils::genTauDecayMode(genTauJet);
42  // CV: store hadronic tau decays only
43  if (decayMode_string == "electron" || decayMode_string == "muon")
44  continue;
46  if (decayMode_string == "oneProng0Pi0")
48  else if (decayMode_string == "oneProng1Pi0")
50  else if (decayMode_string == "oneProng2Pi0")
52  else if (decayMode_string == "threeProng0Pi0")
54  else if (decayMode_string == "threeProng1Pi0")
56  else
58 
59  int pdgId = (genTauJet.charge() > 0) ? -15 : +15;
60 
61  // CV: store decayMode in status flag of GenParticle object
62  reco::GenParticle genVisTau(genTauJet.charge(), genTauJet.p4(), genTauJet.vertex(), pdgId, decayMode, true);
63 
64  // CV: find tau lepton "mother" particle
65  for (size_t idxGenParticle = 0; idxGenParticle < numGenParticles; ++idxGenParticle) {
66  const reco::GenParticle& genTau = (*genParticles)[idxGenParticle];
67  if (abs(genTau.pdgId()) == 15 && genTau.status() == 2) {
68  reco::Candidate::LorentzVector daughterVisP4;
69  for (const reco::GenParticleRef& daughter : genTau.daughterRefVector()) {
70  int abs_pdgId = abs(daughter->pdgId());
71  // CV: skip neutrinos
72  if (abs_pdgId == 12 || abs_pdgId == 14 || abs_pdgId == 16)
73  continue;
74  daughterVisP4 += daughter->p4();
75  }
76  double dR2 = deltaR2(daughterVisP4, genVisTau);
77  if (dR2 < 1.e-4) {
78  genVisTau.addMother(reco::GenParticleRef(genParticles, idxGenParticle));
79  break;
80  }
81  }
82  }
83 
84  genVisTaus->push_back(genVisTau);
85  }
86 
87  std::sort(genVisTaus->begin(), genVisTaus->end(), pTComparator_);
88  evt.put(std::move(genVisTaus));
89  }

References funct::abs(), reco::CompositeRefCandidateT< D >::daughterRefVector(), taus_cff::decayMode, HLTMuonOfflineAnalyzer_cfi::deltaR2, MillePedeFileConverter_cfg::e, genParticles2HepMC_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(), EgammaValidation_cff::pdgId, reco::LeafCandidate::pdgId(), pTComparator_, edm::Event::put(), src_, srcGenParticles_, reco::LeafCandidate::status(), and AlCaHLTBitMon_QueryRunRegistry::string.

Member Data Documentation

◆ pTComparator_

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

Definition at line 101 of file GenVisTauProducer.cc.

Referenced by produce().

◆ src_

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

Definition at line 99 of file GenVisTauProducer.cc.

Referenced by produce().

◆ srcGenParticles_

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

Definition at line 100 of file GenVisTauProducer.cc.

Referenced by produce().

reco::PFTau::kNull
Definition: PFTau.h:39
reco::PFTau::kOneProng1PiZero
Definition: PFTau.h:41
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
genParticles2HepMC_cfi.genParticles
genParticles
Definition: genParticles2HepMC_cfi.py:4
reco::LeafCandidate::status
int status() const final
status word
Definition: LeafCandidate.h:180
reco::GenParticle
Definition: GenParticle.h:21
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
reco::PFTau::kOneProng2PiZero
Definition: PFTau.h:42
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
reco::PFTau::kOneProng0PiZero
Definition: PFTau.h:40
reco::PFTau::kRareDecayMode
Definition: PFTau.h:55
edm::Handle< reco::GenJetCollection >
edm::Ref< GenParticleCollection >
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
GenVisTauProducer::srcGenParticles_
const edm::EDGetTokenT< reco::GenParticleCollection > srcGenParticles_
Definition: GenVisTauProducer.cc:100
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
taus_cff.decayMode
decayMode
Definition: taus_cff.py:60
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
reco::LeafCandidate::pdgId
int pdgId() const final
PDG identifier.
Definition: LeafCandidate.h:176
reco::PFTau::kThreeProng1PiZero
Definition: PFTau.h:51
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
EgammaValidation_cff.pdgId
pdgId
Definition: EgammaValidation_cff.py:118
eostools.move
def move(src, dest)
Definition: eostools.py:511
HLTMuonOfflineAnalyzer_cfi.deltaR2
deltaR2
Definition: HLTMuonOfflineAnalyzer_cfi.py:105
reco::PFTau::kThreeProng0PiZero
Definition: PFTau.h:50
reco::CompositeRefCandidateT::daughterRefVector
const daughters & daughterRefVector() const
references to daughtes
Definition: CompositeRefCandidateT.h:71
GenVisTauProducer::src_
const edm::EDGetTokenT< reco::GenJetCollection > src_
Definition: GenVisTauProducer.cc:99
GenVisTauProducer::pTComparator_
const GreaterByPt< reco::GenParticle > pTComparator_
Definition: GenVisTauProducer.cc:101
taus_cff.genVisTaus
genVisTaus
Definition: taus_cff.py:172
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
reco::Candidate::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
edm::InputTag
Definition: InputTag.h:15
JetMCTagUtils::genTauDecayMode
std::string genTauDecayMode(const reco::CompositePtrCandidate &c)
Definition: JetMCTag.cc:70
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37