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::stream::EDProducer<> edm::stream::EDProducerBase 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::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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

const bool linkToPackedPF_
 
const bool modifyMuon_
 
std::unique_ptr
< pat::ObjectModifier
< pat::Muon > > 
muonModifier_
 
const edm::EDGetTokenT
< edm::Association
< pat::PackedCandidateCollection > > 
pf2pc_
 
const edm::EDGetTokenT
< reco::PFCandidateCollection
pf_
 
const StringCutObjectSelector
< pat::Muon
saveTeVMuons_
 
const edm::EDGetTokenT
< pat::MuonCollection
src_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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  pf_(mayConsume<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("pfCandidates"))),
49  linkToPackedPF_(iConfig.getParameter<bool>("linkToPackedPFCandidates")),
50  saveTeVMuons_(iConfig.getParameter<std::string>("saveTeVMuons")),
51  modifyMuon_(iConfig.getParameter<bool>("modifyMuons"))
52 {
54  if( modifyMuon_ ) {
55  const edm::ParameterSet& mod_config = iConfig.getParameter<edm::ParameterSet>("modifierConfig");
56  muonModifier_.reset(new pat::ObjectModifier<pat::Muon>(mod_config) );
57  muonModifier_->setConsumes(sumes);
58  } else {
59  muonModifier_.reset(nullptr);
60  }
61  produces<std::vector<pat::Muon> >();
62 }
const edm::EDGetTokenT< pat::MuonCollection > src_
T getParameter(std::string const &) const
const bool linkToPackedPF_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
std::unique_ptr< pat::ObjectModifier< pat::Muon > > muonModifier_
const edm::EDGetTokenT< reco::PFCandidateCollection > pf_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
const StringCutObjectSelector< pat::Muon > saveTeVMuons_
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
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::stream::EDProducerBase.

Definition at line 65 of file PATMuonSlimmer.cc.

References modifyMuon_, and muonModifier_.

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

Implements edm::stream::EDProducerBase.

Definition at line 70 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_.

70  {
71  using namespace edm;
72  using namespace std;
73 
75  iEvent.getByToken(src_, src);
76 
77  auto_ptr<vector<pat::Muon> > out(new vector<pat::Muon>());
78  out->reserve(src->size());
79 
80  if( modifyMuon_ ) { muonModifier_->setEvent(iEvent); }
81 
82  std::map<reco::CandidatePtr,pat::PackedCandidateRef> mu2pc;
83  if (linkToPackedPF_) {
86  iEvent.getByToken(pf_, pf);
87  iEvent.getByToken(pf2pc_, pf2pc);
88  for (unsigned int i = 0, n = pf->size(); i < n; ++i) {
89  const reco::PFCandidate &p = (*pf)[i];
90  if (p.muonRef().isNonnull()) mu2pc[refToPtr(p.muonRef())] = (*pf2pc)[reco::PFCandidateRef(pf, i)];
91  }
92  }
93 
94  for (vector<pat::Muon>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
95  out->push_back(*it);
96  pat::Muon & mu = out->back();
97 
98  if( modifyMuon_ ) { muonModifier_->modify(mu); }
99 
100  if (saveTeVMuons_(mu)){mu.embedPickyMuon(); mu.embedTpfmsMuon(); mu.embedDytMuon();}
101  if (linkToPackedPF_) {
102  mu.refToOrig_ = refToPtr(mu2pc[mu.refToOrig_]);
103  }
104  }
105 
106  iEvent.put(out);
107 }
const edm::EDGetTokenT< pat::MuonCollection > src_
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:252
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
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
const bool linkToPackedPF_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
std::unique_ptr< pat::ObjectModifier< pat::Muon > > muonModifier_
const edm::EDGetTokenT< reco::PFCandidateCollection > pf_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
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
const StringCutObjectSelector< pat::Muon > saveTeVMuons_
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:421

Member Data Documentation

const bool pat::PATMuonSlimmer::linkToPackedPF_
private

Definition at line 37 of file PATMuonSlimmer.cc.

Referenced by produce().

const 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().

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

Definition at line 36 of file PATMuonSlimmer.cc.

Referenced by produce().

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

Definition at line 35 of file PATMuonSlimmer.cc.

Referenced by produce().

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

Definition at line 38 of file PATMuonSlimmer.cc.

Referenced by produce().

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

Definition at line 34 of file PATMuonSlimmer.cc.

Referenced by produce().