CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
DimuonMCMatcher Class Reference
Inheritance diagram for DimuonMCMatcher:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 DimuonMCMatcher (const edm::ParameterSet &cfg)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () 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::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)
 

Private Attributes

edm::EDGetTokenT< reco::CandidateViewsrcToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer 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::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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

Definition at line 7 of file DimuonMCMatcher.cc.

Constructor & Destructor Documentation

◆ DimuonMCMatcher()

DimuonMCMatcher::DimuonMCMatcher ( const edm::ParameterSet cfg)

Definition at line 27 of file DimuonMCMatcher.cc.

28  : srcToken_(consumes<CandidateView>(cfg.getParameter<InputTag>("src"))) {
29  produces<vector<GenParticleRef> >();
30 }

Member Function Documentation

◆ produce()

void DimuonMCMatcher::produce ( edm::Event evt,
const edm::EventSetup  
)
overridevirtual

Implements edm::EDProducer.

Definition at line 32 of file DimuonMCMatcher.cc.

32  {
34  evt.getByToken(srcToken_, src);
35  unique_ptr<vector<GenParticleRef> > matched(new vector<GenParticleRef>);
36  matched->reserve(src->size());
37  int j = 0;
38  for (CandidateView::const_iterator i = src->begin(); i != src->end(); ++i) {
39  j++;
40  const Candidate* dau1 = i->daughter(0);
41  const Candidate* dau2 = i->daughter(1);
42  if (dau1 == nullptr || dau2 == nullptr)
43  throw Exception(errors::InvalidReference) << "one of the two daughter does not exist\n";
44  const Candidate* c1 = dau1->masterClone().get();
45  GenParticleRef mc1;
46  const pat::Muon* mu1 = dynamic_cast<const pat::Muon*>(c1);
47  if (mu1 != nullptr) {
48  mc1 = mu1->genParticleRef();
49  // if (mc1.isNonnull()) cout << "DimuonMCMatcher> genParticleRef1 " << mc1->pdgId() << endl;
50  } else {
51  const pat::GenericParticle* gp1 = dynamic_cast<const pat::GenericParticle*>(c1);
52  if (gp1 == nullptr)
54  << "first of two daughter is neither a pat::Muon not pat::GenericParticle\n";
55  mc1 = gp1->genParticleRef();
56  }
57  const Candidate* c2 = dau2->masterClone().get();
58  GenParticleRef mc2;
59  const pat::Muon* mu2 = dynamic_cast<const pat::Muon*>(c2);
60  if (mu2 != nullptr) {
61  mc2 = mu2->genParticleRef();
62  // if (mc2.isNonnull()) cout << "DimuonMCMatcher> genParticleRef2 " << mc2->pdgId() << endl;
63  } else {
64  const pat::GenericParticle* gp2 = dynamic_cast<const pat::GenericParticle*>(c2);
65  if (gp2 == nullptr)
67  << "first of two daughter is neither a pat::Muon not pat::GenericParticle\n";
68  mc2 = gp2->genParticleRef();
69  }
70  GenParticleRef dimuonMatch;
71  // cout << "DimuonMatcher> mc1 " << mc1.isNonnull() << " mc2 " << mc2.isNonnull() << endl;
72  if (mc1.isNonnull() && mc2.isNonnull()) {
73  int k = 0;
74  do {
75  k++;
76  mc1 = mc1->numberOfMothers() > 0 ? mc1->motherRef() : GenParticleRef();
77  mc2 = mc2->numberOfMothers() > 0 ? mc2->motherRef() : GenParticleRef();
78  // cout << "DimuonMCMatcher> do loop: " << k << " id1 " << mc1->pdgId() << " id2 " << mc2->pdgId() << endl;
79  } while (mc1 != mc2 && mc1.isNonnull() && mc2.isNonnull());
80  if (mc1.isNonnull() && mc2.isNonnull() && mc1->pdgId() == 23) {
81  dimuonMatch = mc1;
82  }
83  }
84  // cout << "DimuonMatcher> dimuonMatch " << dimuonMatch.isNonnull() << endl;
85  matched->push_back(dimuonMatch);
86  }
87 
88  evt.put(std::move(matched));
89 }

References alignmentValidation::c1, Exception, pat::PATObject< ObjectType >::genParticleRef(), edm::RefToBase< T >::get(), edm::Event::getByToken(), mps_fire::i, edm::errors::InvalidReference, edm::Ref< C, T, F >::isNonnull(), dqmiolumiharvest::j, dqmdumpme::k, reco::Candidate::masterClone(), muonTagProbeFilters_cff::matched, eostools::move(), edm::Event::put(), TrackRefitter_38T_cff::src, and srcToken_.

Member Data Documentation

◆ srcToken_

edm::EDGetTokenT<reco::CandidateView> DimuonMCMatcher::srcToken_
private

Definition at line 13 of file DimuonMCMatcher.cc.

Referenced by produce().

muonTagProbeFilters_cff.matched
matched
Definition: muonTagProbeFilters_cff.py:62
mps_fire.i
i
Definition: mps_fire.py:428
edm::errors::InvalidReference
Definition: EDMException.h:39
GenParticleRef
edm::Ref< edm::HepMCProduct, HepMC::GenParticle > GenParticleRef
Definition: MultiTrackValidator.cc:43
pat::Muon
Analysis-level muon class.
Definition: Muon.h:51
edm::Handle
Definition: AssociativeIterator.h:50
edm::Ref< GenParticleCollection >
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
dqmdumpme.k
k
Definition: dqmdumpme.py:60
edm::RefToBase::get
value_type const * get() const
Definition: RefToBase.h:209
pat::GenericParticle
Analysis-level Generic Particle class (e.g. for hadron or muon not fully reconstructed)
Definition: GenericParticle.h:38
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
alignmentValidation.c1
c1
do drawing
Definition: alignmentValidation.py:1025
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
DimuonMCMatcher::srcToken_
edm::EDGetTokenT< reco::CandidateView > srcToken_
Definition: DimuonMCMatcher.cc:13
looper.cfg
cfg
Definition: looper.py:297
reco::Candidate
Definition: Candidate.h:27
eostools.move
def move(src, dest)
Definition: eostools.py:511
Exception
Definition: hltDiff.cc:246
reco::Candidate::masterClone
virtual const CandidateBaseRef & masterClone() const =0
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::InputTag
Definition: InputTag.h:15
pat::PATObject::genParticleRef
reco::GenParticleRef genParticleRef(size_t idx=0) const
Definition: PATObject.h:267