CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
pat::PATMuonSlimmer Class Reference

Slimmer of PAT Muons. More...

Inheritance diagram for pat::PATMuonSlimmer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PATMuonSlimmer (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
virtual ~PATMuonSlimmer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

bool linkToPackedPF_
 
edm::EDGetTokenT
< edm::Association
< pat::PackedCandidateCollection > > 
pf2pc_
 
edm::EDGetTokenT
< reco::PFCandidateCollection
pf_
 
edm::EDGetTokenT
< pat::MuonCollection
src_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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

Slimmer of PAT Muons.

Definition at line 23 of file PATMuonSlimmer.cc.

Constructor & Destructor Documentation

pat::PATMuonSlimmer::PATMuonSlimmer ( const edm::ParameterSet iConfig)
explicit

Definition at line 39 of file PATMuonSlimmer.cc.

References edm::ParameterSet::getParameter(), linkToPackedPF_, pf2pc_, and pf_.

39  :
40  src_(consumes<pat::MuonCollection>(iConfig.getParameter<edm::InputTag>("src"))),
41  linkToPackedPF_(iConfig.getParameter<bool>("linkToPackedPFCandidates"))
42 {
43  produces<std::vector<pat::Muon> >();
44  if (linkToPackedPF_) {
45  pf_ = consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("pfCandidates"));
46  pf2pc_ = consumes<edm::Association<pat::PackedCandidateCollection>>(iConfig.getParameter<edm::InputTag>("packedPFCandidates"));
47  }
48 }
T getParameter(std::string const &) const
edm::EDGetTokenT< pat::MuonCollection > src_
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
edm::EDGetTokenT< reco::PFCandidateCollection > pf_
virtual pat::PATMuonSlimmer::~PATMuonSlimmer ( )
inlinevirtual

Definition at line 26 of file PATMuonSlimmer.cc.

26 { }

Member Function Documentation

void pat::PATMuonSlimmer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 51 of file PATMuonSlimmer.cc.

References edm::Event::getByToken(), i, edm::Ref< C, T, F >::isNonnull(), RPCpg::mu, reco::PFCandidate::muonRef(), n, dbtoconf::out, AlCaHLTBitMon_ParallelJobs::p, edm::Event::put(), pat::PATObject< ObjectType >::refToOrig_, edm::refToPtr(), and alcazmumu_cfi::src.

51  {
52  using namespace edm;
53  using namespace std;
54 
56  iEvent.getByToken(src_, src);
57 
58  auto_ptr<vector<pat::Muon> > out(new vector<pat::Muon>());
59  out->reserve(src->size());
60 
61  std::map<reco::CandidatePtr,pat::PackedCandidateRef> mu2pc;
62  if (linkToPackedPF_) {
65  iEvent.getByToken(pf_, pf);
66  iEvent.getByToken(pf2pc_, pf2pc);
67  for (unsigned int i = 0, n = pf->size(); i < n; ++i) {
68  const reco::PFCandidate &p = (*pf)[i];
69  if (p.muonRef().isNonnull()) mu2pc[refToPtr(p.muonRef())] = (*pf2pc)[reco::PFCandidateRef(pf, i)];
70  }
71  }
72 
73  for (vector<pat::Muon>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
74  out->push_back(*it);
75  pat::Muon & mu = out->back();
76  if (linkToPackedPF_) {
77  mu.refToOrig_ = refToPtr(mu2pc[mu.refToOrig_]);
78  }
79  }
80 
81  iEvent.put(out);
82 }
int i
Definition: DBlmapReader.cc:9
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
edm::EDGetTokenT< pat::MuonCollection > src_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
const int mu
Definition: Constants.h:22
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:446
tuple out
Definition: dbtoconf.py:99
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:38
edm::EDGetTokenT< reco::PFCandidateCollection > pf_
Analysis-level muon class.
Definition: Muon.h:50
edm::Ptr< reco::Candidate > refToOrig_
Definition: PATObject.h:407

Member Data Documentation

bool pat::PATMuonSlimmer::linkToPackedPF_
private

Definition at line 34 of file PATMuonSlimmer.cc.

Referenced by PATMuonSlimmer().

edm::EDGetTokenT<edm::Association<pat::PackedCandidateCollection> > pat::PATMuonSlimmer::pf2pc_
private

Definition at line 33 of file PATMuonSlimmer.cc.

Referenced by PATMuonSlimmer().

edm::EDGetTokenT<reco::PFCandidateCollection> pat::PATMuonSlimmer::pf_
private

Definition at line 32 of file PATMuonSlimmer.cc.

Referenced by PATMuonSlimmer().

edm::EDGetTokenT<pat::MuonCollection> pat::PATMuonSlimmer::src_
private

Definition at line 31 of file PATMuonSlimmer.cc.