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 (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &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_
 
std::vector< edm::EDGetTokenT
< edm::Association
< pat::PackedCandidateCollection > > > 
pf2pc_
 
std::vector< 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::consumes(), edm::EDConsumerBase::consumesCollector(), edm::ParameterSet::existsAs(), edm::ParameterSet::getParameter(), and GlobalPosition_Frontier_DevDB_cff::tag.

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 {
51  if (linkToPackedPF_) {
52  const std::vector<edm::InputTag> & pf = (iConfig.existsAs<std::vector<edm::InputTag>>("pfCandidates") ?
53  iConfig.getParameter<std::vector<edm::InputTag>>("pfCandidates") :
54  std::vector<edm::InputTag>(1,iConfig.getParameter<edm::InputTag>("pfCandidates")));
55  const std::vector<edm::InputTag> & pf2pc = (iConfig.existsAs<std::vector<edm::InputTag>>("packedPFCandidates") ?
56  iConfig.getParameter<std::vector<edm::InputTag>>("packedPFCandidates") :
57  std::vector<edm::InputTag>(1,iConfig.getParameter<edm::InputTag>("packedPFCandidates")));
58  if (pf.size() != pf2pc.size()) throw cms::Exception("Configuration") << "Mismatching pfCandidates and packedPFCandidates\n";
59  for (const edm::InputTag &tag : pf) pf_.push_back(consumes<reco::PFCandidateCollection>(tag));
61  }
62 
64  if( modifyMuon_ ) {
65  const edm::ParameterSet& mod_config = iConfig.getParameter<edm::ParameterSet>("modifierConfig");
66  muonModifier_.reset(new pat::ObjectModifier<pat::Muon>(mod_config) );
67  muonModifier_->setConsumes(sumes);
68  } else {
69  muonModifier_.reset(nullptr);
70  }
71  produces<std::vector<pat::Muon> >();
72 }
const edm::EDGetTokenT< pat::MuonCollection > src_
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
const bool linkToPackedPF_
std::vector< edm::EDGetTokenT< reco::PFCandidateCollection > > pf_
std::unique_ptr< pat::ObjectModifier< pat::Muon > > muonModifier_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
std::vector< edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > > pf2pc_
const StringCutObjectSelector< pat::Muon > saveTeVMuons_
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 75 of file PATMuonSlimmer.cc.

References modifyMuon_, and muonModifier_.

75  {
76  if( modifyMuon_ ) muonModifier_->setEventContent(iSetup);
77 }
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 80 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, GenerateHcalLaserBadRunList::out, AlCaHLTBitMon_ParallelJobs::p, pf2pc_, pf_, edm::Event::put(), pat::PATObject< ObjectType >::refToOrig_, edm::refToPtr(), saveTeVMuons_, alcazmumu_cfi::src, and src_.

80  {
81  using namespace edm;
82  using namespace std;
83 
85  iEvent.getByToken(src_, src);
86 
87  auto_ptr<vector<pat::Muon> > out(new vector<pat::Muon>());
88  out->reserve(src->size());
89 
90  if( modifyMuon_ ) { muonModifier_->setEvent(iEvent); }
91 
92  std::map<reco::CandidatePtr,pat::PackedCandidateRef> mu2pc;
93  if (linkToPackedPF_) {
96  for (unsigned int ipfh = 0, npfh = pf_.size(); ipfh < npfh; ++ipfh) {
97  iEvent.getByToken(pf_[ipfh], pf);
98  iEvent.getByToken(pf2pc_[ipfh], pf2pc);
99  const auto & pfcoll = (*pf);
100  const auto & pfmap = (*pf2pc);
101  for (unsigned int i = 0, n = pf->size(); i < n; ++i) {
102  const reco::PFCandidate &p = pfcoll[i];
103  if (p.muonRef().isNonnull()) mu2pc[refToPtr(p.muonRef())] = pfmap[reco::PFCandidateRef(pf, i)];
104  }
105  }
106  }
107 
108  for (vector<pat::Muon>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
109  out->push_back(*it);
110  pat::Muon & mu = out->back();
111 
112  if( modifyMuon_ ) { muonModifier_->modify(mu); }
113 
114  if (saveTeVMuons_(mu)){mu.embedPickyMuon(); mu.embedTpfmsMuon(); mu.embedDytMuon();}
115  if (linkToPackedPF_) {
116  mu.refToOrig_ = refToPtr(mu2pc[mu.refToOrig_]);
117  }
118  }
119 
120  iEvent.put(out);
121 }
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:462
const bool linkToPackedPF_
std::vector< edm::EDGetTokenT< reco::PFCandidateCollection > > pf_
std::unique_ptr< pat::ObjectModifier< pat::Muon > > muonModifier_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
const int mu
Definition: Constants.h:22
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:450
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
std::vector< edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > > pf2pc_
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().

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

Definition at line 36 of file PATMuonSlimmer.cc.

Referenced by produce().

std::vector<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().