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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
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)
 
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 ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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 24 of file TauGenJetProducer.h.

Constructor & Destructor Documentation

◆ TauGenJetProducer()

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

Definition at line 35 of file TauGenJetProducer.cc.

36  : tokenGenParticles_(consumes<GenParticleCollection>(iConfig.getParameter<InputTag>("GenParticles"))),
37  includeNeutrinos_(iConfig.getParameter<bool>("includeNeutrinos")),
38  verbose_(iConfig.getUntrackedParameter<bool>("verbose", false)) {
39  produces<GenJetCollection>();
40 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::EDGetTokenT< reco::GenParticleCollection > tokenGenParticles_
Input PFCandidates.
const bool verbose_
verbose ?
T getUntrackedParameter(std::string const &, T const &) const
const bool includeNeutrinos_
if yes, neutrinos will be included, for debug purposes

◆ ~TauGenJetProducer()

TauGenJetProducer::~TauGenJetProducer ( )
override

Definition at line 42 of file TauGenJetProducer.cc.

42 {}

Member Function Documentation

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 44 of file TauGenJetProducer.cc.

References funct::abs(), edm::RefVector< C, T, F >::begin(), ALCARECOTkAlJpsiMuMu_cff::charge, PixelTestBeamValidation_cfi::Charge, gather_cfg::cout, edm::RefVector< C, T, F >::empty(), edm::RefVector< C, T, F >::end(), GenParticlesHelper::findDescendents(), GenParticlesHelper::findParticles(), AJJGenJetFilter_cfi::genParticles, JetMCTagUtils::genTauDecayMode(), iEvent, includeNeutrinos_, metsig::jet, eostools::move(), edm::refToPtr(), cond::persistency::search(), timingPdfMaker::specific, tokenGenParticles_, verbose_, and bphysicsOniaDQM_cfi::vertex.

44  {
46 
47  auto pOutVisTaus = std::make_unique<GenJetCollection>();
48 
49  using namespace GenParticlesHelper;
50 
51  GenParticleRefVector allStatus2Taus;
52  findParticles(*genParticles, allStatus2Taus, 15, 2);
53 
54  for (IGR iTau = allStatus2Taus.begin(); iTau != allStatus2Taus.end(); ++iTau) {
55  // look for all status 1 (stable) descendents
56  GenParticleRefVector descendents;
57  findDescendents(*iTau, descendents, 1);
58  if (descendents.empty()) {
59  edm::LogWarning("NoTauDaughters") << "Tau p4: " << (*iTau)->p4() << " vtx: " << (*iTau)->vertex()
60  << " has no daughters";
61 
64  Jet::Constituents constituents;
65 
66  constituents.push_back(refToPtr(*iTau));
67  GenJet jet((*iTau)->p4(), vertex, specific, constituents);
68  jet.setCharge((*iTau)->charge());
69  jet.setStatus(decayModeStringToCodeMap.at("tau"));
70  pOutVisTaus->emplace_back(std::move(jet));
71  continue;
72  }
73  // CV: skip status 2 taus that radiate-off a photon
74  // --> have a status 2 tau lepton in the list of descendents
75  GenParticleRefVector status2TauDaughters;
76  findDescendents(*iTau, status2TauDaughters, 2, 15);
77  if (!status2TauDaughters.empty())
78  continue;
79 
80  // loop on descendents, and take all except neutrinos
81  math::XYZTLorentzVector sumVisMom;
83  Jet::Constituents constituents;
84 
85  if (verbose_)
86  cout << "tau " << (*iTau) << endl;
87 
88  for (IGR igr = descendents.begin(); igr != descendents.end(); ++igr) {
89  int absPdgId = abs((*igr)->pdgId());
90 
91  // neutrinos
92  if (!includeNeutrinos_) {
93  if (absPdgId == 12 || absPdgId == 14 || absPdgId == 16)
94  continue;
95  }
96 
97  if (verbose_)
98  cout << "\t" << (*igr) << endl;
99 
100  charge += (*igr)->charge();
101  sumVisMom += (*igr)->p4();
102 
103  // need to convert the vector of reference to the constituents
104  // to a vector of pointers to build the genjet
105  constituents.push_back(refToPtr(*igr));
106  }
107 
110 
111  GenJet jet(sumVisMom, vertex, specific, constituents);
112 
113  if (charge != (*iTau)->charge())
114  edm::LogError("TauGenJetProducer") << " charge of Tau: " << (*iTau)
115  << " not equal to charge of sum of charge of all descendents.\n"
116  << " Tau's charge: " << (*iTau)->charge() << " sum: " << charge
117  << " # descendents: " << constituents.size() << "\n";
118 
119  jet.setCharge(charge);
120  // determine tau decay mode and set it as jet status
121  if (auto search = decayModeStringToCodeMap.find(JetMCTagUtils::genTauDecayMode(jet));
122  search != decayModeStringToCodeMap.end())
123  jet.setStatus(search->second);
124  else
125  jet.setStatus(decayModeStringToCodeMap.at("null"));
126  pOutVisTaus->push_back(jet);
127  }
128  iEvent.put(std::move(pOutVisTaus));
129 }
std::string genTauDecayMode(const reco::CompositePtrCandidate &c)
Definition: JetMCTag.cc:70
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:99
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_
Input PFCandidates.
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
Definition: IOVProxy.cc:21
const bool verbose_
verbose ?
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
int iEvent
Definition: GenABIO.cc:224
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:23
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
Log< level::Warning, false > LogWarning
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223
def move(src, dest)
Definition: eostools.py:511
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

◆ includeNeutrinos_

const bool TauGenJetProducer::includeNeutrinos_
private

if yes, neutrinos will be included, for debug purposes

Definition at line 37 of file TauGenJetProducer.h.

Referenced by produce().

◆ tokenGenParticles_

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

Input PFCandidates.

Definition at line 34 of file TauGenJetProducer.h.

Referenced by produce().

◆ verbose_

const bool TauGenJetProducer::verbose_
private

verbose ?

Definition at line 40 of file TauGenJetProducer.h.

Referenced by produce().