CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
PATObjectCrossLinker Class Reference

#include <PhysicsTools/PATObjectCrossLinker/plugins/PATObjectCrossLinker.cc>

Inheritance diagram for PATObjectCrossLinker:
edm::stream::EDProducer<>

Public Member Functions

 PATObjectCrossLinker (const edm::ParameterSet &)
 
 ~PATObjectCrossLinker () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void beginStream (edm::StreamID) override
 
void endStream () override
 
template<class C1 , class C2 , class C3 , class C4 >
void matchElectronToPhoton (const C1 &refProdOne, C2 &itemsOne, const std::string &nameOne, const C3 &refProdMany, C4 &itemsMany, const std::string &nameMany)
 
template<class C1 , class C2 , class C3 , class C4 >
void matchOneToMany (const C1 &refProdOne, C2 &itemsOne, const std::string &nameOne, const C3 &refProdMany, C4 &itemsMany, const std::string &nameMany)
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

const edm::EDGetTokenT< edm::View< pat::Electron > > electrons_
 
const edm::EDGetTokenT< edm::View< pat::Jet > > jets_
 
const edm::EDGetTokenT< edm::View< pat::Muon > > muons_
 
const edm::EDGetTokenT< edm::View< pat::Photon > > photons_
 
const edm::EDGetTokenT< edm::View< pat::Tau > > taus_
 

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
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 45 of file PATObjectCrossLinker.cc.

Constructor & Destructor Documentation

◆ PATObjectCrossLinker()

PATObjectCrossLinker::PATObjectCrossLinker ( const edm::ParameterSet params)
explicit

Definition at line 89 of file PATObjectCrossLinker.cc.

90  : jets_(consumes<edm::View<pat::Jet>>(params.getParameter<edm::InputTag>("jets"))),
91  muons_(consumes<edm::View<pat::Muon>>(params.getParameter<edm::InputTag>("muons"))),
92  electrons_(consumes<edm::View<pat::Electron>>(params.getParameter<edm::InputTag>("electrons"))),
93  taus_(consumes<edm::View<pat::Tau>>(params.getParameter<edm::InputTag>("taus"))),
94  photons_(consumes<edm::View<pat::Photon>>(params.getParameter<edm::InputTag>("photons")))
95 
96 {
97  produces<std::vector<pat::Jet>>("jets");
98  produces<std::vector<pat::Muon>>("muons");
99  produces<std::vector<pat::Electron>>("electrons");
100  produces<std::vector<pat::Tau>>("taus");
101  produces<std::vector<pat::Photon>>("photons");
102 }

◆ ~PATObjectCrossLinker()

PATObjectCrossLinker::~PATObjectCrossLinker ( )
override

Definition at line 104 of file PATObjectCrossLinker.cc.

104  {
105  // do anything here that needs to be done at destruction time
106  // (e.g. close files, deallocate resources etc.)
107 }

Member Function Documentation

◆ beginStream()

void PATObjectCrossLinker::beginStream ( edm::StreamID  )
overrideprivate

Definition at line 214 of file PATObjectCrossLinker.cc.

214 {}

◆ endStream()

void PATObjectCrossLinker::endStream ( )
overrideprivate

Definition at line 217 of file PATObjectCrossLinker.cc.

217 {}

◆ fillDescriptions()

void PATObjectCrossLinker::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 220 of file PATObjectCrossLinker.cc.

220  {
221  //The following says we do not know what parameters are allowed so do no validation
222  // Please change this to state exactly what you do use, even if it is no parameters
224  desc.setUnknown();
225  descriptions.addDefault(desc);
226 }

References edm::ConfigurationDescriptions::addDefault(), and submitPVResolutionJobs::desc.

◆ matchElectronToPhoton()

template<class C1 , class C2 , class C3 , class C4 >
void PATObjectCrossLinker::matchElectronToPhoton ( const C1 &  refProdOne,
C2 &  itemsOne,
const std::string &  nameOne,
const C3 &  refProdMany,
C4 &  itemsMany,
const std::string &  nameMany 
)
private

Definition at line 140 of file PATObjectCrossLinker.cc.

145  {
146  size_t ji = 0;
147  for (auto& j : itemsOne) {
148  edm::PtrVector<reco::Candidate> overlaps(refProdMany.id());
149  size_t mi = 0;
150  for (auto& m : itemsMany) {
151  if (matchByCommonParentSuperClusterRef(j, m) && (!m.hasUserCand(nameOne))) {
152  m.addUserCand(nameOne, reco::CandidatePtr(refProdOne.id(), ji, refProdOne.productGetter()));
153  overlaps.push_back(reco::CandidatePtr(refProdMany.id(), mi, refProdMany.productGetter()));
154  }
155  mi++;
156  }
157  j.setOverlaps(nameMany, overlaps);
158  ji++;
159  }
160 }

References dqmiolumiharvest::j, visualization-live-secondInstance_cfg::m, matchByCommonParentSuperClusterRef(), analyzePatCleaning_cfg::overlaps, and edm::PtrVectorBase::productGetter().

Referenced by produce().

◆ matchOneToMany()

template<class C1 , class C2 , class C3 , class C4 >
void PATObjectCrossLinker::matchOneToMany ( const C1 &  refProdOne,
C2 &  itemsOne,
const std::string &  nameOne,
const C3 &  refProdMany,
C4 &  itemsMany,
const std::string &  nameMany 
)
private

Definition at line 117 of file PATObjectCrossLinker.cc.

122  {
123  size_t ji = 0;
124  for (auto& j : itemsOne) {
125  edm::PtrVector<reco::Candidate> overlaps(refProdMany.id());
126  size_t mi = 0;
127  for (auto& m : itemsMany) {
128  if (matchByCommonSourceCandidatePtr(j, m) && (!m.hasUserCand(nameOne))) {
129  m.addUserCand(nameOne, reco::CandidatePtr(refProdOne.id(), ji, refProdOne.productGetter()));
130  overlaps.push_back(reco::CandidatePtr(refProdMany.id(), mi, refProdMany.productGetter()));
131  }
132  mi++;
133  }
134  j.setOverlaps(nameMany, overlaps);
135  ji++;
136  }
137 }

References dqmiolumiharvest::j, visualization-live-secondInstance_cfg::m, matchByCommonSourceCandidatePtr(), analyzePatCleaning_cfg::overlaps, and edm::PtrVectorBase::productGetter().

Referenced by produce().

◆ produce()

void PATObjectCrossLinker::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 162 of file PATObjectCrossLinker.cc.

162  {
163  using namespace edm;
165  iEvent.getByToken(jets_, jetsIn);
166  auto jets = std::make_unique<std::vector<pat::Jet>>();
167  for (const auto& j : *jetsIn)
168  jets->push_back(j);
169  auto jetRefProd = iEvent.getRefBeforePut<std::vector<pat::Jet>>("jets");
170 
172  iEvent.getByToken(muons_, muonsIn);
173  auto muons = std::make_unique<std::vector<pat::Muon>>();
174  for (const auto& m : *muonsIn)
175  muons->push_back(m);
176  auto muRefProd = iEvent.getRefBeforePut<std::vector<pat::Muon>>("muons");
177 
179  iEvent.getByToken(electrons_, electronsIn);
180  auto electrons = std::make_unique<std::vector<pat::Electron>>();
181  for (const auto& e : *electronsIn)
182  electrons->push_back(e);
183  auto eleRefProd = iEvent.getRefBeforePut<std::vector<pat::Electron>>("electrons");
184 
186  iEvent.getByToken(taus_, tausIn);
187  auto taus = std::make_unique<std::vector<pat::Tau>>();
188  for (const auto& t : *tausIn)
189  taus->push_back(t);
190  auto tauRefProd = iEvent.getRefBeforePut<std::vector<pat::Tau>>("taus");
191 
193  iEvent.getByToken(photons_, photonsIn);
194  auto photons = std::make_unique<std::vector<pat::Photon>>();
195  for (const auto& p : *photonsIn)
196  photons->push_back(p);
197  auto phRefProd = iEvent.getRefBeforePut<std::vector<pat::Photon>>("photons");
198 
199  matchOneToMany(jetRefProd, *jets, "jet", muRefProd, *muons, "muons");
200  matchOneToMany(jetRefProd, *jets, "jet", eleRefProd, *electrons, "electrons");
201  matchOneToMany(jetRefProd, *jets, "jet", tauRefProd, *taus, "taus");
202  matchOneToMany(jetRefProd, *jets, "jet", phRefProd, *photons, "photons");
203 
204  matchElectronToPhoton(eleRefProd, *electrons, "electron", phRefProd, *photons, "photons");
205 
206  iEvent.put(std::move(jets), "jets");
207  iEvent.put(std::move(muons), "muons");
208  iEvent.put(std::move(electrons), "electrons");
209  iEvent.put(std::move(taus), "taus");
210  iEvent.put(std::move(photons), "photons");
211 }

References MillePedeFileConverter_cfg::e, pwdgSkimBPark_cfi::electrons, electrons_, iEvent, dqmiolumiharvest::j, singleTopDQM_cfi::jets, jets_, visualization-live-secondInstance_cfg::m, matchElectronToPhoton(), matchOneToMany(), eostools::move(), PDWG_BPHSkim_cff::muons, muons_, AlCaHLTBitMon_ParallelJobs::p, BPHMonitor_cfi::photons, photons_, submitPVValidationJobs::t, Tau3MuMonitor_cff::taus, and taus_.

Member Data Documentation

◆ electrons_

const edm::EDGetTokenT<edm::View<pat::Electron> > PATObjectCrossLinker::electrons_
private

Definition at line 81 of file PATObjectCrossLinker.cc.

Referenced by produce().

◆ jets_

const edm::EDGetTokenT<edm::View<pat::Jet> > PATObjectCrossLinker::jets_
private

Definition at line 79 of file PATObjectCrossLinker.cc.

Referenced by produce().

◆ muons_

const edm::EDGetTokenT<edm::View<pat::Muon> > PATObjectCrossLinker::muons_
private

Definition at line 80 of file PATObjectCrossLinker.cc.

Referenced by produce().

◆ photons_

const edm::EDGetTokenT<edm::View<pat::Photon> > PATObjectCrossLinker::photons_
private

Definition at line 83 of file PATObjectCrossLinker.cc.

Referenced by produce().

◆ taus_

const edm::EDGetTokenT<edm::View<pat::Tau> > PATObjectCrossLinker::taus_
private

Definition at line 82 of file PATObjectCrossLinker.cc.

Referenced by produce().

PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
matchByCommonParentSuperClusterRef
bool matchByCommonParentSuperClusterRef(const C1 &c1, const C2 &c2)
Definition: MatchingUtils.h:21
PATObjectCrossLinker::muons_
const edm::EDGetTokenT< edm::View< pat::Muon > > muons_
Definition: PATObjectCrossLinker.cc:80
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
Tau3MuMonitor_cff.taus
taus
Definition: Tau3MuMonitor_cff.py:7
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
matchByCommonSourceCandidatePtr
bool matchByCommonSourceCandidatePtr(const C1 &c1, const C2 &c2)
Definition: MatchingUtils.h:9
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::PtrVectorBase::productGetter
EDProductGetter const * productGetter() const
Accessor for product getter.
Definition: PtrVectorBase.h:61
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
edm::Handle
Definition: AssociativeIterator.h:50
edm::PtrVector
Definition: PtrVector.h:36
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
PATObjectCrossLinker::photons_
const edm::EDGetTokenT< edm::View< pat::Photon > > photons_
Definition: PATObjectCrossLinker.cc:83
analyzePatCleaning_cfg.overlaps
overlaps
Definition: analyzePatCleaning_cfg.py:9
edm::View
Definition: CaloClusterFwd.h:14
PATObjectCrossLinker::matchElectronToPhoton
void matchElectronToPhoton(const C1 &refProdOne, C2 &itemsOne, const std::string &nameOne, const C3 &refProdMany, C4 &itemsMany, const std::string &nameMany)
Definition: PATObjectCrossLinker.cc:140
iEvent
int iEvent
Definition: GenABIO.cc:224
BPHMonitor_cfi.photons
photons
Definition: BPHMonitor_cfi.py:91
PATObjectCrossLinker::taus_
const edm::EDGetTokenT< edm::View< pat::Tau > > taus_
Definition: PATObjectCrossLinker.cc:82
edm::Ptr< Candidate >
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
pwdgSkimBPark_cfi.electrons
electrons
Definition: pwdgSkimBPark_cfi.py:6
PATObjectCrossLinker::jets_
const edm::EDGetTokenT< edm::View< pat::Jet > > jets_
Definition: PATObjectCrossLinker.cc:79
PATObjectCrossLinker::matchOneToMany
void matchOneToMany(const C1 &refProdOne, C2 &itemsOne, const std::string &nameOne, const C3 &refProdMany, C4 &itemsMany, const std::string &nameMany)
Definition: PATObjectCrossLinker.cc:117
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
PATObjectCrossLinker::electrons_
const edm::EDGetTokenT< edm::View< pat::Electron > > electrons_
Definition: PATObjectCrossLinker.cc:81
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
edm::InputTag
Definition: InputTag.h:15
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37