CMS 3D CMS Logo

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 &) override final
 
 PATMuonSlimmer (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
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)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
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, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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::MuonsaveTeVMuons_
 
const edm::EDGetTokenT< pat::MuonCollectionsrc_
 

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, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
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::getParameter(), linkToPackedPF_, modifyMuon_, muonModifier_, packedPFCandidateRefMixer_cfi::pf, pf2pc_, pf_, 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.getParameter<std::vector<edm::InputTag>>("pfCandidates");
53  const std::vector<edm::InputTag> & pf2pc = iConfig.getParameter<std::vector<edm::InputTag>>("packedPFCandidates");
54  if (pf.size() != pf2pc.size()) throw cms::Exception("Configuration") << "Mismatching pfCandidates and packedPFCandidates\n";
55  for (const edm::InputTag &tag : pf) pf_.push_back(consumes<reco::PFCandidateCollection>(tag));
57  }
58 
60  if( modifyMuon_ ) {
61  const edm::ParameterSet& mod_config = iConfig.getParameter<edm::ParameterSet>("modifierConfig");
62  muonModifier_.reset(new pat::ObjectModifier<pat::Muon>(mod_config) );
63  muonModifier_->setConsumes(sumes);
64  } else {
65  muonModifier_.reset(nullptr);
66  }
67  produces<std::vector<pat::Muon> >();
68 }
const edm::EDGetTokenT< pat::MuonCollection > src_
T getParameter(std::string const &) const
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.

References beginLuminosityBlock(), iEvent, and produce().

28 { }

Member Function Documentation

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

Definition at line 71 of file PATMuonSlimmer.cc.

References modifyMuon_, and muonModifier_.

Referenced by ~PATMuonSlimmer().

71  {
72  if( modifyMuon_ ) muonModifier_->setEventContent(iSetup);
73 }
std::unique_ptr< pat::ObjectModifier< pat::Muon > > muonModifier_
void pat::PATMuonSlimmer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Definition at line 76 of file PATMuonSlimmer.cc.

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

Referenced by ~PATMuonSlimmer().

76  {
77  using namespace edm;
78  using namespace std;
79 
81  iEvent.getByToken(src_, src);
82 
83  auto out = std::make_unique<std::vector<pat::Muon>>();
84  out->reserve(src->size());
85 
86  if( modifyMuon_ ) { muonModifier_->setEvent(iEvent); }
87 
88  std::map<reco::CandidatePtr,pat::PackedCandidateRef> mu2pc;
89  if (linkToPackedPF_) {
92  for (unsigned int ipfh = 0, npfh = pf_.size(); ipfh < npfh; ++ipfh) {
93  iEvent.getByToken(pf_[ipfh], pf);
94  iEvent.getByToken(pf2pc_[ipfh], pf2pc);
95  const auto & pfcoll = (*pf);
96  const auto & pfmap = (*pf2pc);
97  for (unsigned int i = 0, n = pf->size(); i < n; ++i) {
98  const reco::PFCandidate &p = pfcoll[i];
99  if (p.muonRef().isNonnull()) mu2pc[refToPtr(p.muonRef())] = pfmap[reco::PFCandidateRef(pf, i)];
100  }
101  }
102  }
103 
104  for (vector<pat::Muon>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
105  out->push_back(*it);
106  pat::Muon & mu = out->back();
107 
108  if( modifyMuon_ ) { muonModifier_->modify(mu); }
109 
110  if (saveTeVMuons_(mu)){mu.embedPickyMuon(); mu.embedTpfmsMuon(); mu.embedDytMuon();}
111  if (linkToPackedPF_) {
112  mu.refToOrig_ = refToPtr(mu2pc[mu.refToOrig_]);
113  }
114  }
115 
116  iEvent.put(std::move(out));
117 }
const edm::EDGetTokenT< pat::MuonCollection > src_
void embedDytMuon()
embed reference to the above dyt Track
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
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:460
const bool linkToPackedPF_
std::vector< edm::EDGetTokenT< reco::PFCandidateCollection > > pf_
std::unique_ptr< pat::ObjectModifier< pat::Muon > > muonModifier_
const int mu
Definition: Constants.h:22
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:455
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
HLT enums.
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
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

const bool pat::PATMuonSlimmer::linkToPackedPF_
private

Definition at line 37 of file PATMuonSlimmer.cc.

Referenced by PATMuonSlimmer(), and produce().

const bool pat::PATMuonSlimmer::modifyMuon_
private

Definition at line 39 of file PATMuonSlimmer.cc.

Referenced by beginLuminosityBlock(), PATMuonSlimmer(), and produce().

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

Definition at line 40 of file PATMuonSlimmer.cc.

Referenced by beginLuminosityBlock(), PATMuonSlimmer(), and produce().

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

Definition at line 36 of file PATMuonSlimmer.cc.

Referenced by PATMuonSlimmer(), and produce().

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

Definition at line 35 of file PATMuonSlimmer.cc.

Referenced by PATMuonSlimmer(), and 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().