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 Types | Private Attributes
PFGSFixLinker Class Reference

#include <PFGSFixLinker.h>

Inheritance diagram for PFGSFixLinker:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

template<typename T >
edm::Handle< TgetHandle (edm::Event const &_event, edm::EDGetTokenT< T > const &token, std::string const &name)
 
template<typename T >
void getToken (edm::EDGetTokenT< T > &token, edm::ParameterSet const &pset, std::string const &label)
 
 PFGSFixLinker (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~PFGSFixLinker ()
 
- 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 Types

typedef edm::ValueMap
< reco::GsfElectronRef
ElectronRefMap
 
typedef edm::View
< reco::PFCandidate
PFCandidateView
 
typedef edm::ValueMap
< reco::PhotonRef
PhotonRefMap
 

Private Attributes

edm::EDGetTokenT< ElectronRefMapelectronMapToken_
 
std::string electronsMapName_
 
edm::EDGetTokenT< PFCandidateViewinputCandidatesToken_
 
edm::EDGetTokenT
< reco::GsfElectronCollection
inputElectronsToken_
 
edm::EDGetTokenT
< reco::PhotonCollection
inputPhotonsToken_
 
edm::EDGetTokenT< PhotonRefMapphotonMapToken_
 
std::string photonsMapName_
 

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

Relink GS-fixed e/gamma objects

Author
Y. Iiyama (MIT)

Definition at line 22 of file PFGSFixLinker.h.

Member Typedef Documentation

Definition at line 48 of file PFGSFixLinker.h.

Definition at line 47 of file PFGSFixLinker.h.

Definition at line 49 of file PFGSFixLinker.h.

Constructor & Destructor Documentation

PFGSFixLinker::PFGSFixLinker ( const edm::ParameterSet _config)
explicit

Definition at line 18 of file PFGSFixLinker.cc.

References electronMapToken_, electronsMapName_, getToken(), inputCandidatesToken_, inputElectronsToken_, inputPhotonsToken_, photonMapToken_, and photonsMapName_.

18  :
19  electronsMapName_(_config.getParameter<std::string>("ValueMapElectrons")),
20  photonsMapName_(_config.getParameter<std::string>("ValueMapPhotons"))
21 {
22  getToken(inputCandidatesToken_, _config, "PFCandidate");
23  getToken(inputElectronsToken_, _config, "GsfElectrons");
24  getToken(inputPhotonsToken_, _config, "Photons");
25  getToken(electronMapToken_, _config, "GsfElectrons");
26  getToken(photonMapToken_, _config, "Photons");
27 
28  produces<reco::PFCandidateCollection>();
29  // new to old
30  produces<PFPtrMap>();
31 
32  // e/g collections to PF
33  produces<PFPtrMap>(electronsMapName_);
34  produces<PFPtrMap>(photonsMapName_);
35 }
T getParameter(std::string const &) const
std::string electronsMapName_
Definition: PFGSFixLinker.h:58
edm::EDGetTokenT< reco::PhotonCollection > inputPhotonsToken_
Definition: PFGSFixLinker.h:53
edm::EDGetTokenT< PFCandidateView > inputCandidatesToken_
Definition: PFGSFixLinker.h:51
edm::EDGetTokenT< ElectronRefMap > electronMapToken_
Definition: PFGSFixLinker.h:55
edm::EDGetTokenT< reco::GsfElectronCollection > inputElectronsToken_
Definition: PFGSFixLinker.h:52
void getToken(edm::EDGetTokenT< T > &token, edm::ParameterSet const &pset, std::string const &label)
Definition: PFGSFixLinker.h:31
std::string photonsMapName_
Definition: PFGSFixLinker.h:59
edm::EDGetTokenT< PhotonRefMap > photonMapToken_
Definition: PFGSFixLinker.h:56
PFGSFixLinker::~PFGSFixLinker ( )

Definition at line 37 of file PFGSFixLinker.cc.

38 {
39 }

Member Function Documentation

template<typename T >
edm::Handle<T> PFGSFixLinker::getHandle ( edm::Event const &  _event,
edm::EDGetTokenT< T > const &  token,
std::string const &  name 
)
inline

Definition at line 37 of file PFGSFixLinker.h.

References edm::Event::getByToken(), patZpeak::handle, and mergeVDriftHistosByStation::name.

Referenced by produce().

38  {
40  if (!_event.getByToken(token, handle))
41  throw cms::Exception("ProductNotFound") << name;
42 
43  return handle;
44  }
tuple handle
Definition: patZpeak.py:22
template<typename T >
void PFGSFixLinker::getToken ( edm::EDGetTokenT< T > &  token,
edm::ParameterSet const &  pset,
std::string const &  label 
)
inline

Definition at line 31 of file PFGSFixLinker.h.

References edm::ParameterSet::getParameter(), and diffTwoXMLs::label.

Referenced by PFGSFixLinker().

32  {
33  token = consumes<T>(pset.getParameter<edm::InputTag>(label));
34  }
void PFGSFixLinker::produce ( edm::Event _event,
const edm::EventSetup  
)
overridevirtual

Implements edm::stream::EDProducerBase.

Definition at line 42 of file PFGSFixLinker.cc.

References electronMapToken_, electronsMapName_, edm::helper::Filler< Map >::fill(), GainSwitchTools::findNewRef(), getHandle(), customizeTrackingMonitorSeedNumber::idx, inputCandidatesToken_, inputElectronsToken_, inputPhotonsToken_, edm::helper::Filler< Map >::insert(), reco::GsfElectron::P4_COMBINATION, pfElectrons_cff::pfElectrons, electronProducer_cff::pfPhotons, photonMapToken_, photonsMapName_, edm::Event::put(), and reco::Photon::regression2.

43 {
44  std::auto_ptr<reco::PFCandidateCollection> pOutput(new reco::PFCandidateCollection);
45 
46  auto& inCandidates(*getHandle(_event, inputCandidatesToken_, "PFCandidate"));
47  auto&& inElectronsHandle(getHandle(_event, inputElectronsToken_, "GsfElectrons"));
48  auto& electronMap(*getHandle(_event, electronMapToken_, "GsfElectronsMap"));
49  auto&& inPhotonsHandle(getHandle(_event, inputPhotonsToken_, "Photons"));
50  auto& photonMap(*getHandle(_event, photonMapToken_, "PhotonsMap"));
51 
52  std::vector<reco::PFCandidatePtr> oldPtrs;
53  std::vector<unsigned> pfElectronIndices(inElectronsHandle->size(), -1);
54  std::vector<unsigned> pfPhotonIndices(inPhotonsHandle->size(), -1);
55 
56  unsigned iP(0);
57  for (auto& inCand : inCandidates) {
58  oldPtrs.emplace_back(inCandidates.ptrAt(iP++));
59 
60  pOutput->emplace_back(inCand);
61  auto& outCand(pOutput->back());
62 
63  auto&& eRef(inCand.gsfElectronRef());
64  if (eRef.isNonnull()) {
65  auto&& newERef(GainSwitchTools::findNewRef(eRef, inElectronsHandle, electronMap));
66  auto& newE(*newERef);
67  auto& newSC(*newE.superCluster());
68 
69  pfElectronIndices[newERef.key()] = pOutput->size() - 1;
70 
71  outCand.setGsfElectronRef(newERef);
72  outCand.setSuperClusterRef(newE.superCluster());
73  outCand.setEcalEnergy(newSC.rawEnergy(), newE.ecalEnergy());
74  outCand.setDeltaP(newE.p4Error(reco::GsfElectron::P4_COMBINATION));
75  outCand.setP4(newE.p4(reco::GsfElectron::P4_COMBINATION));
76  }
77 
78  auto&& phRef(inCand.photonRef());
79  if (phRef.isNonnull()) {
80  auto&& newPhRef(GainSwitchTools::findNewRef(phRef, inPhotonsHandle, photonMap));
81  auto& newPh(*newPhRef);
82  auto& newSC(*newPh.superCluster());
83 
84  pfPhotonIndices[newPhRef.key()] = pOutput->size() - 1;
85 
86  outCand.setPhotonRef(newPhRef);
87  outCand.setSuperClusterRef(newPh.superCluster());
88  outCand.setEcalEnergy(newSC.rawEnergy(), newPh.getCorrectedEnergy(reco::Photon::regression2));
89  outCand.setDeltaP(newPh.getCorrectedEnergyError(reco::Photon::regression2));
90  outCand.setP4(newPh.p4(reco::Photon::regression2));
91  }
92  }
93 
94  auto&& outCandsHandle(_event.put(pOutput));
95 
96  std::auto_ptr<PFPtrMap> pPFMap(new PFPtrMap);
97  PFPtrMap::Filler pfMapFiller(*pPFMap);
98  pfMapFiller.insert(outCandsHandle, oldPtrs.begin(), oldPtrs.end());
99  pfMapFiller.fill();
100  _event.put(pPFMap);
101 
102  std::vector<reco::PFCandidatePtr> pfElectrons;
103  for (unsigned idx : pfElectronIndices) {
104  if (idx == unsigned(-1))
105  pfElectrons.emplace_back();
106  else
107  pfElectrons.emplace_back(outCandsHandle, idx);
108  }
109 
110  std::auto_ptr<PFPtrMap> pEleMap(new PFPtrMap);
111  PFPtrMap::Filler eleMapFiller(*pEleMap);
112  eleMapFiller.insert(inElectronsHandle, pfElectrons.begin(), pfElectrons.end());
113  eleMapFiller.fill();
114  _event.put(pEleMap, electronsMapName_);
115 
116  std::vector<reco::PFCandidatePtr> pfPhotons;
117  for (unsigned idx : pfPhotonIndices) {
118  if (idx == unsigned(-1))
119  pfPhotons.emplace_back();
120  else
121  pfPhotons.emplace_back(outCandsHandle, idx);
122  }
123 
124  std::auto_ptr<PFPtrMap> pPhoMap(new PFPtrMap);
125  PFPtrMap::Filler phoMapFiller(*pPhoMap);
126  phoMapFiller.insert(inPhotonsHandle, pfPhotons.begin(), pfPhotons.end());
127  phoMapFiller.fill();
128  _event.put(pPhoMap, photonsMapName_);
129 }
edm::Handle< T > getHandle(edm::Event const &_event, edm::EDGetTokenT< T > const &token, std::string const &name)
Definition: PFGSFixLinker.h:37
std::string electronsMapName_
Definition: PFGSFixLinker.h:58
edm::EDGetTokenT< reco::PhotonCollection > inputPhotonsToken_
Definition: PFGSFixLinker.h:53
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
edm::EDGetTokenT< PFCandidateView > inputCandidatesToken_
Definition: PFGSFixLinker.h:51
edm::EDGetTokenT< ElectronRefMap > electronMapToken_
Definition: PFGSFixLinker.h:55
edm::EDGetTokenT< reco::GsfElectronCollection > inputElectronsToken_
Definition: PFGSFixLinker.h:52
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
std::string photonsMapName_
Definition: PFGSFixLinker.h:59
static edm::Ref< typename H::element_type > findNewRef(R const &, H const &, M const &)
edm::EDGetTokenT< PhotonRefMap > photonMapToken_
Definition: PFGSFixLinker.h:56

Member Data Documentation

edm::EDGetTokenT<ElectronRefMap> PFGSFixLinker::electronMapToken_
private

Definition at line 55 of file PFGSFixLinker.h.

Referenced by PFGSFixLinker(), and produce().

std::string PFGSFixLinker::electronsMapName_
private

Definition at line 58 of file PFGSFixLinker.h.

Referenced by PFGSFixLinker(), and produce().

edm::EDGetTokenT<PFCandidateView> PFGSFixLinker::inputCandidatesToken_
private

Definition at line 51 of file PFGSFixLinker.h.

Referenced by PFGSFixLinker(), and produce().

edm::EDGetTokenT<reco::GsfElectronCollection> PFGSFixLinker::inputElectronsToken_
private

Definition at line 52 of file PFGSFixLinker.h.

Referenced by PFGSFixLinker(), and produce().

edm::EDGetTokenT<reco::PhotonCollection> PFGSFixLinker::inputPhotonsToken_
private

Definition at line 53 of file PFGSFixLinker.h.

Referenced by PFGSFixLinker(), and produce().

edm::EDGetTokenT<PhotonRefMap> PFGSFixLinker::photonMapToken_
private

Definition at line 56 of file PFGSFixLinker.h.

Referenced by PFGSFixLinker(), and produce().

std::string PFGSFixLinker::photonsMapName_
private

Definition at line 59 of file PFGSFixLinker.h.

Referenced by PFGSFixLinker(), and produce().