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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 46 of file PATObjectCrossLinker.cc.

Constructor & Destructor Documentation

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

Definition at line 84 of file PATObjectCrossLinker.cc.

84  :
85  jets_(consumes<edm::View<pat::Jet>>( params.getParameter<edm::InputTag>("jets") )),
86  muons_(consumes<edm::View<pat::Muon>>( params.getParameter<edm::InputTag>("muons") )),
87  electrons_(consumes<edm::View<pat::Electron>>( params.getParameter<edm::InputTag>("electrons") )),
88  taus_(consumes<edm::View<pat::Tau>>( params.getParameter<edm::InputTag>("taus") )),
89  photons_(consumes<edm::View<pat::Photon>>( params.getParameter<edm::InputTag>("photons") ))
90 
91 {
92  produces<std::vector<pat::Jet>>("jets");
93  produces<std::vector<pat::Muon>>("muons");
94  produces<std::vector<pat::Electron>>("electrons");
95  produces<std::vector<pat::Tau>>("taus");
96  produces<std::vector<pat::Photon>>("photons");
97 
98 }
T getParameter(std::string const &) const
const edm::EDGetTokenT< edm::View< pat::Muon > > muons_
const edm::EDGetTokenT< edm::View< pat::Jet > > jets_
const edm::EDGetTokenT< edm::View< pat::Electron > > electrons_
const edm::EDGetTokenT< edm::View< pat::Tau > > taus_
const edm::EDGetTokenT< edm::View< pat::Photon > > photons_
PATObjectCrossLinker::~PATObjectCrossLinker ( )
override

Definition at line 101 of file PATObjectCrossLinker.cc.

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

Member Function Documentation

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

Definition at line 209 of file PATObjectCrossLinker.cc.

210 {
211 }
void PATObjectCrossLinker::endStream ( )
overrideprivate

Definition at line 215 of file PATObjectCrossLinker.cc.

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

Definition at line 220 of file PATObjectCrossLinker.cc.

References edm::ConfigurationDescriptions::addDefault(), DEFINE_FWK_MODULE, 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 138 of file PATObjectCrossLinker.cc.

References funct::m, matchByCommonParentSuperClusterRef(), analyzePatCleaning_cfg::overlaps, and edm::PtrVectorBase::productGetter().

Referenced by produce().

140 {
141  size_t ji=0;
142  for(auto & j: itemsOne) {
143  edm::PtrVector<reco::Candidate> overlaps(refProdMany.id());
144  size_t mi=0;
145  for(auto & m: itemsMany){
146  if(matchByCommonParentSuperClusterRef(j,m) && (!m.hasUserCand(nameOne))){
147  m.addUserCand(nameOne,reco::CandidatePtr(refProdOne.id(), ji, refProdOne.productGetter()));
148  overlaps.push_back(reco::CandidatePtr(refProdMany.id(), mi, refProdMany.productGetter()));
149  }
150  mi++;
151  }
152  j.setOverlaps(nameMany,overlaps);
153  ji++;
154  }
155 }
bool matchByCommonParentSuperClusterRef(const C1 &c1, const C2 &c2)
Definition: MatchingUtils.h:20
EDProductGetter const * productGetter() const
Accessor for product getter.
Definition: PtrVectorBase.h:62
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 118 of file PATObjectCrossLinker.cc.

References funct::m, matchByCommonSourceCandidatePtr(), analyzePatCleaning_cfg::overlaps, and edm::PtrVectorBase::productGetter().

Referenced by produce().

120 {
121  size_t ji=0;
122  for(auto & j: itemsOne) {
123  edm::PtrVector<reco::Candidate> overlaps(refProdMany.id());
124  size_t mi=0;
125  for(auto & m: itemsMany){
126  if(matchByCommonSourceCandidatePtr(j,m) && (!m.hasUserCand(nameOne))){
127  m.addUserCand(nameOne,reco::CandidatePtr(refProdOne.id(), ji, refProdOne.productGetter()));
128  overlaps.push_back(reco::CandidatePtr(refProdMany.id(), mi, refProdMany.productGetter()));
129  }
130  mi++;
131  }
132  j.setOverlaps(nameMany,overlaps);
133  ji++;
134  }
135 }
bool matchByCommonSourceCandidatePtr(const C1 &c1, const C2 &c2)
Definition: MatchingUtils.h:9
EDProductGetter const * productGetter() const
Accessor for product getter.
Definition: PtrVectorBase.h:62
void PATObjectCrossLinker::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 159 of file PATObjectCrossLinker.cc.

References MillePedeFileConverter_cfg::e, nano_cff::electrons, electrons_, edm::Event::getByToken(), edm::Event::getRefBeforePut(), fwrapper::jets, jets_, funct::m, matchElectronToPhoton(), matchOneToMany(), eostools::move(), extraflags_cff::muons, muons_, AlCaHLTBitMon_ParallelJobs::p, muons_cff::photons, photons_, edm::Event::put(), protons_cff::t, nano_cff::taus, and taus_.

160 {
161  using namespace edm;
163  iEvent.getByToken(jets_, jetsIn);
164  auto jets = std::make_unique<std::vector<pat::Jet>>();
165  for(const auto & j : *jetsIn) jets->push_back(j);
166  auto jetRefProd = iEvent.getRefBeforePut< std::vector<pat::Jet> >("jets");
167 
169  iEvent.getByToken(muons_, muonsIn);
170  auto muons = std::make_unique<std::vector<pat::Muon>>();
171  for(const auto & m : *muonsIn) muons->push_back(m);
172  auto muRefProd = iEvent.getRefBeforePut< std::vector<pat::Muon> >("muons");
173 
175  iEvent.getByToken(electrons_, electronsIn);
176  auto electrons = std::make_unique<std::vector<pat::Electron>>();
177  for(const auto & e : *electronsIn) electrons->push_back(e);
178  auto eleRefProd = iEvent.getRefBeforePut< std::vector<pat::Electron> >("electrons");
179 
181  iEvent.getByToken(taus_, tausIn);
182  auto taus = std::make_unique<std::vector<pat::Tau>>();
183  for(const auto & t : *tausIn) taus->push_back(t);
184  auto tauRefProd = iEvent.getRefBeforePut< std::vector<pat::Tau> >("taus");
185 
187  iEvent.getByToken(photons_, photonsIn);
188  auto photons = std::make_unique<std::vector<pat::Photon>>();
189  for(const auto & p : *photonsIn) photons->push_back(p);
190  auto phRefProd = iEvent.getRefBeforePut< std::vector<pat::Photon> >("photons");
191 
192  matchOneToMany(jetRefProd,*jets,"jet",muRefProd,*muons,"muons");
193  matchOneToMany(jetRefProd,*jets,"jet",eleRefProd,*electrons,"electrons");
194  matchOneToMany(jetRefProd,*jets,"jet",tauRefProd,*taus,"taus");
195  matchOneToMany(jetRefProd,*jets,"jet",phRefProd,*photons,"photons");
196 
197  matchElectronToPhoton(eleRefProd,*electrons,"electron",phRefProd,*photons,"photons");
198 
199  iEvent.put(std::move(jets),"jets");
200  iEvent.put(std::move(muons),"muons");
201  iEvent.put(std::move(electrons),"electrons");
202  iEvent.put(std::move(taus),"taus");
203  iEvent.put(std::move(photons),"photons");
204 
205 }
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:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
const edm::EDGetTokenT< edm::View< pat::Muon > > muons_
vector< PseudoJet > jets
const edm::EDGetTokenT< edm::View< pat::Jet > > jets_
const edm::EDGetTokenT< edm::View< pat::Electron > > electrons_
RefProd< PROD > getRefBeforePut()
Definition: Event.h:150
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_
HLT enums.
const edm::EDGetTokenT< edm::View< pat::Photon > > photons_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

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

Definition at line 74 of file PATObjectCrossLinker.cc.

Referenced by produce().

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

Definition at line 72 of file PATObjectCrossLinker.cc.

Referenced by produce().

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

Definition at line 73 of file PATObjectCrossLinker.cc.

Referenced by produce().

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

Definition at line 76 of file PATObjectCrossLinker.cc.

Referenced by produce().

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

Definition at line 75 of file PATObjectCrossLinker.cc.

Referenced by produce().