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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
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)
 

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::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 = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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

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 19 of file TauGenJetProducer.cc.

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  produces<GenJetCollection>();
25 }

◆ ~TauGenJetProducer()

TauGenJetProducer::~TauGenJetProducer ( )
override

Definition at line 27 of file TauGenJetProducer.cc.

27 {}

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 29 of file TauGenJetProducer.cc.

29  {
31 
32  bool found = iEvent.getByToken(tokenGenParticles_, genParticles);
33 
34  if (!found) {
35  std::ostringstream err;
36  err << " cannot get collection: " << inputTagGenParticles_ << std::endl;
37  edm::LogError("TauGenJetProducer") << err.str();
38  throw cms::Exception("MissingProduct", err.str());
39  }
40 
41  auto pOutVisTaus = std::make_unique<GenJetCollection>();
42 
43  using namespace GenParticlesHelper;
44 
45  GenParticleRefVector allStatus2Taus;
46  findParticles(*genParticles, allStatus2Taus, 15, 2);
47 
48  for (IGR iTau = allStatus2Taus.begin(); iTau != allStatus2Taus.end(); ++iTau) {
49  // look for all status 1 (stable) descendents
50  GenParticleRefVector descendents;
51  findDescendents(*iTau, descendents, 1);
52 
53  // CV: skip status 2 taus that radiate-off a photon
54  // --> have a status 2 tau lepton in the list of descendents
55  GenParticleRefVector status2TauDaughters;
56  findDescendents(*iTau, status2TauDaughters, 2, 15);
57  if (!status2TauDaughters.empty())
58  continue;
59 
60  // loop on descendents, and take all except neutrinos
61  math::XYZTLorentzVector sumVisMom;
63  Jet::Constituents constituents;
64 
65  if (verbose_)
66  cout << "tau " << (*iTau) << endl;
67 
68  for (IGR igr = descendents.begin(); igr != descendents.end(); ++igr) {
69  int absPdgId = abs((*igr)->pdgId());
70 
71  // neutrinos
72  if (!includeNeutrinos_) {
73  if (absPdgId == 12 || absPdgId == 14 || absPdgId == 16)
74  continue;
75  }
76 
77  if (verbose_)
78  cout << "\t" << (*igr) << endl;
79 
80  charge += (*igr)->charge();
81  sumVisMom += (*igr)->p4();
82 
83  // need to convert the vector of reference to the constituents
84  // to a vector of pointers to build the genjet
85  constituents.push_back(refToPtr(*igr));
86  }
87 
90 
91  GenJet jet(sumVisMom, vertex, specific, constituents);
92 
93  if (charge != (*iTau)->charge())
94  std::cout << " charge of Tau: " << (*iTau) << " not equal to charge of sum of charge of all descendents. "
95  << std::endl;
96 
97  jet.setCharge(charge);
98  pOutVisTaus->push_back(jet);
99  }
100  iEvent.put(std::move(pOutVisTaus));
101 }

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(), submitPVResolutionJobs::err, Exception, GenParticlesHelper::findDescendents(), GenParticlesHelper::findParticles(), newFWLiteAna::found, genParticles2HepMC_cfi::genParticles, iEvent, includeNeutrinos_, inputTagGenParticles_, metsig::jet, eostools::move(), edm::refToPtr(), timingPdfMaker::specific, tokenGenParticles_, verbose_, and bphysicsOniaDQM_cfi::vertex.

Member Data Documentation

◆ includeNeutrinos_

const bool TauGenJetProducer::includeNeutrinos_
private

if yes, neutrinos will be included, for debug purposes

Definition at line 38 of file TauGenJetProducer.h.

Referenced by produce().

◆ inputTagGenParticles_

const edm::InputTag TauGenJetProducer::inputTagGenParticles_
private

Input PFCandidates.

Definition at line 34 of file TauGenJetProducer.h.

Referenced by produce().

◆ tokenGenParticles_

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

Definition at line 35 of file TauGenJetProducer.h.

Referenced by produce().

◆ verbose_

const bool TauGenJetProducer::verbose_
private

verbose ?

Definition at line 41 of file TauGenJetProducer.h.

Referenced by produce().

GenParticlesHelper::findParticles
void findParticles(const reco::GenParticleCollection &sourceParticles, reco::GenParticleRefVector &particleRefs, int pdgId, int status)
find all particles of a given pdgId and status
Definition: GenParticlesHelper.cc:8
reco::GenJet
Jets made from MC generator particles.
Definition: GenJet.h:23
genParticles2HepMC_cfi.genParticles
genParticles
Definition: genParticles2HepMC_cfi.py:4
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::RefVector::begin
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223
TauGenJetProducer::inputTagGenParticles_
const edm::InputTag inputTagGenParticles_
Input PFCandidates.
Definition: TauGenJetProducer.h:34
GenParticlesHelper
Definition: GenParticlesHelper.h:8
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::RefVector< GenParticleCollection >
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::Handle
Definition: AssociativeIterator.h:50
TauGenJetProducer::tokenGenParticles_
const edm::EDGetTokenT< reco::GenParticleCollection > tokenGenParticles_
Definition: TauGenJetProducer.h:35
edm::refToPtr
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
reco::GenJet::Specific
Definition: GenJet.h:25
edm::RefVector::end
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
edm::RefVector::empty
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:99
TauGenJetProducer::verbose_
const bool verbose_
verbose ?
Definition: TauGenJetProducer.h:41
timingPdfMaker.specific
specific
Definition: timingPdfMaker.py:78
TauGenJetProducer::includeNeutrinos_
const bool includeNeutrinos_
if yes, neutrinos will be included, for debug purposes
Definition: TauGenJetProducer.h:38
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
submitPVResolutionJobs.err
err
Definition: submitPVResolutionJobs.py:85
eostools.move
def move(src, dest)
Definition: eostools.py:511
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
metsig::jet
Definition: SignAlgoResolutions.h:47
Exception
Definition: hltDiff.cc:245
edm::RefVectorIterator
Definition: EDProductfwd.h:33
PixelTestBeamValidation_cfi.Charge
Charge
Definition: PixelTestBeamValidation_cfi.py:91
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
GenParticlesHelper::findDescendents
void findDescendents(const reco::GenParticleRef &base, reco::GenParticleRefVector &descendents, int status, int pdgId=0)
find all descendents of a given status and pdgId (recursive)
Definition: GenParticlesHelper.cc:28
edm::InputTag
Definition: InputTag.h:15