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

virtual void beginLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) overridefinal
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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_
 
bool modifyMuon_
 
std::unique_ptr
< pat::ObjectModifier
< pat::Muon > > 
muonModifier_
 
edm::EDGetTokenT
< edm::Association
< pat::PackedCandidateCollection > > 
pf2pc_
 
edm::EDGetTokenT
< reco::PFCandidateCollection
pf_
 
StringCutObjectSelector
< pat::Muon
saveTeVMuons_
 
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 25 of file PATMuonSlimmer.cc.

Constructor & Destructor Documentation

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

Definition at line 45 of file PATMuonSlimmer.cc.

References edm::EDConsumerBase::consumesCollector(), and edm::ParameterSet::getParameter().

45  :
46  src_(consumes<pat::MuonCollection>(iConfig.getParameter<edm::InputTag>("src"))),
47  linkToPackedPF_(iConfig.getParameter<bool>("linkToPackedPFCandidates")),
48  saveTeVMuons_(iConfig.getParameter<std::string>("saveTeVMuons")),
49  modifyMuon_(iConfig.getParameter<bool>("modifyMuons"))
50 {
52  if( modifyMuon_ ) {
53  const edm::ParameterSet& mod_config = iConfig.getParameter<edm::ParameterSet>("modifierConfig");
54  muonModifier_.reset(new pat::ObjectModifier<pat::Muon>(mod_config) );
55  muonModifier_->setConsumes(sumes);
56  } else {
57  muonModifier_.reset(nullptr);
58  }
59  produces<std::vector<pat::Muon> >();
60  if (linkToPackedPF_) {
61  pf_ = consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("pfCandidates"));
62  pf2pc_ = consumes<edm::Association<pat::PackedCandidateCollection>>(iConfig.getParameter<edm::InputTag>("packedPFCandidates"));
63  }
64 }
T getParameter(std::string const &) const
edm::EDGetTokenT< pat::MuonCollection > src_
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
StringCutObjectSelector< pat::Muon > saveTeVMuons_
std::unique_ptr< pat::ObjectModifier< pat::Muon > > muonModifier_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::EDGetTokenT< reco::PFCandidateCollection > pf_
virtual pat::PATMuonSlimmer::~PATMuonSlimmer ( )
inlinevirtual

Definition at line 28 of file PATMuonSlimmer.cc.

28 { }

Member Function Documentation

void pat::PATMuonSlimmer::beginLuminosityBlock ( const edm::LuminosityBlock ,
const edm::EventSetup iSetup 
)
finaloverridevirtual

Reimplemented from edm::EDProducer.

Definition at line 67 of file PATMuonSlimmer.cc.

References modifyMuon_, and muonModifier_.

67  {
68  if( modifyMuon_ ) muonModifier_->setEventContent(iSetup);
69 }
std::unique_ptr< pat::ObjectModifier< pat::Muon > > muonModifier_
void pat::PATMuonSlimmer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 72 of file PATMuonSlimmer.cc.

References pat::Muon::embedDytMuon(), pat::Muon::embedPickyMuon(), pat::Muon::embedTpfmsMuon(), edm::Event::getByToken(), i, edm::Ref< C, T, F >::isNonnull(), linkToPackedPF_, modifyMuon_, RPCpg::mu, muonModifier_, reco::PFCandidate::muonRef(), gen::n, dbtoconf::out, AlCaHLTBitMon_ParallelJobs::p, pf2pc_, pf_, edm::Event::put(), pat::PATObject< ObjectType >::refToOrig_, edm::refToPtr(), saveTeVMuons_, alcazmumu_cfi::src, and src_.

72  {
73  using namespace edm;
74  using namespace std;
75 
77  iEvent.getByToken(src_, src);
78 
79  auto_ptr<vector<pat::Muon> > out(new vector<pat::Muon>());
80  out->reserve(src->size());
81 
82  if( modifyMuon_ ) { muonModifier_->setEvent(iEvent); }
83 
84  std::map<reco::CandidatePtr,pat::PackedCandidateRef> mu2pc;
85  if (linkToPackedPF_) {
88  iEvent.getByToken(pf_, pf);
89  iEvent.getByToken(pf2pc_, pf2pc);
90  for (unsigned int i = 0, n = pf->size(); i < n; ++i) {
91  const reco::PFCandidate &p = (*pf)[i];
92  if (p.muonRef().isNonnull()) mu2pc[refToPtr(p.muonRef())] = (*pf2pc)[reco::PFCandidateRef(pf, i)];
93  }
94  }
95 
96  for (vector<pat::Muon>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
97  out->push_back(*it);
98  pat::Muon & mu = out->back();
99 
100  if( modifyMuon_ ) { muonModifier_->modify(mu); }
101 
102  if (saveTeVMuons_(mu)){mu.embedPickyMuon(); mu.embedTpfmsMuon(); mu.embedDytMuon();}
103  if (linkToPackedPF_) {
104  mu.refToOrig_ = refToPtr(mu2pc[mu.refToOrig_]);
105  }
106  }
107 
108  iEvent.put(out);
109 }
int i
Definition: DBlmapReader.cc:9
void embedDytMuon()
embed reference to the above dyt Track
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
void embedTpfmsMuon()
embed reference to the above tpfms Track
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:449
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
StringCutObjectSelector< pat::Muon > saveTeVMuons_
std::unique_ptr< pat::ObjectModifier< pat::Muon > > muonModifier_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
const int mu
Definition: Constants.h:22
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:450
tuple out
Definition: dbtoconf.py:99
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
edm::EDGetTokenT< reco::PFCandidateCollection > pf_
void embedPickyMuon()
embed reference to the above picky Track
Analysis-level muon class.
Definition: Muon.h:49
edm::Ptr< reco::Candidate > refToOrig_
Definition: PATObject.h:407

Member Data Documentation

bool pat::PATMuonSlimmer::linkToPackedPF_
private

Definition at line 37 of file PATMuonSlimmer.cc.

Referenced by produce().

bool pat::PATMuonSlimmer::modifyMuon_
private

Definition at line 39 of file PATMuonSlimmer.cc.

Referenced by beginLuminosityBlock(), and produce().

std::unique_ptr<pat::ObjectModifier<pat::Muon> > pat::PATMuonSlimmer::muonModifier_
private

Definition at line 40 of file PATMuonSlimmer.cc.

Referenced by beginLuminosityBlock(), and produce().

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

Definition at line 36 of file PATMuonSlimmer.cc.

Referenced by produce().

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

Definition at line 35 of file PATMuonSlimmer.cc.

Referenced by produce().

StringCutObjectSelector<pat::Muon> pat::PATMuonSlimmer::saveTeVMuons_
private

Definition at line 38 of file PATMuonSlimmer.cc.

Referenced by produce().

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

Definition at line 34 of file PATMuonSlimmer.cc.

Referenced by produce().