CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

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<>
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::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 ( 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 }
const edm::EDGetTokenT< edm::View< pat::Muon > > muons_
const edm::EDGetTokenT< edm::View< pat::Jet > > jets_
const edm::EDGetTokenT< edm::View< pat::Electron > > electrons_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::EDGetTokenT< edm::View< pat::Tau > > taus_
const edm::EDGetTokenT< edm::View< pat::Photon > > photons_
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

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

Definition at line 214 of file PATObjectCrossLinker.cc.

214 {}
void PATObjectCrossLinker::endStream ( )
overrideprivate

Definition at line 217 of file PATObjectCrossLinker.cc.

217 {}
void PATObjectCrossLinker::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 220 of file PATObjectCrossLinker.cc.

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

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 }
void addDefault(ParameterSetDescription const &psetDescription)
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.

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

Referenced by produce().

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 }
bool matchByCommonParentSuperClusterRef(const C1 &c1, const C2 &c2)
Definition: MatchingUtils.h:21
EDProductGetter const * productGetter() const
Accessor for product getter.
Definition: PtrVectorBase.h:63
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.

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

Referenced by produce().

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 }
bool matchByCommonSourceCandidatePtr(const C1 &c1, const C2 &c2)
Definition: MatchingUtils.h:9
EDProductGetter const * productGetter() const
Accessor for product getter.
Definition: PtrVectorBase.h:63
void PATObjectCrossLinker::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 162 of file PATObjectCrossLinker.cc.

References alignCSCRings::e, HI_PhotonSkim_cff::electrons, electrons_, edm::Event::getByToken(), edm::Event::getRefBeforePut(), dqmiolumiharvest::j, fwrapper::jets, jets_, visualization-live-secondInstance_cfg::m, matchElectronToPhoton(), matchOneToMany(), eostools::move(), patZpeak::muons, muons_, AlCaHLTBitMon_ParallelJobs::p, interactiveExample::photons, photons_, edm::Event::put(), submitPVValidationJobs::t, HLT_FULL_cff::taus, and taus_.

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 }
void matchOneToMany(const C1 &refProdOne, C2 &itemsOne, const std::string &nameOne, const C3 &refProdMany, C4 &itemsMany, const std::string &nameMany)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
const edm::EDGetTokenT< edm::View< pat::Muon > > muons_
vector< PseudoJet > jets
const edm::EDGetTokenT< edm::View< pat::Jet > > jets_
def move
Definition: eostools.py:511
const edm::EDGetTokenT< edm::View< pat::Electron > > electrons_
RefProd< PROD > getRefBeforePut()
Definition: Event.h:158
void matchElectronToPhoton(const C1 &refProdOne, C2 &itemsOne, const std::string &nameOne, const C3 &refProdMany, C4 &itemsMany, const std::string &nameMany)
const edm::EDGetTokenT< edm::View< pat::Tau > > taus_
tuple muons
Definition: patZpeak.py:41
const edm::EDGetTokenT< edm::View< pat::Photon > > photons_

Member Data Documentation

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

Definition at line 81 of file PATObjectCrossLinker.cc.

Referenced by produce().

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

Definition at line 79 of file PATObjectCrossLinker.cc.

Referenced by produce().

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

Definition at line 80 of file PATObjectCrossLinker.cc.

Referenced by produce().

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

Definition at line 83 of file PATObjectCrossLinker.cc.

Referenced by produce().

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

Definition at line 82 of file PATObjectCrossLinker.cc.

Referenced by produce().