CMS 3D CMS Logo

EG8XObjectUpdateModifier.cc
Go to the documentation of this file.
14 
15 #include <vdt/vdtMath.h>
16 
17 //this modifier fills variables where not present in CMSSW_8X
18 //use case is when reading older 80X samples in newer releases, aka legacy
19 
21 public:
24 
25  void setEvent(const edm::Event&) final;
26  void setEventContent(const edm::EventSetup&) final;
27 
28  void modifyObject(reco::GsfElectron& ele) const final;
29  void modifyObject(reco::Photon& pho) const final;
30 
31  void modifyObject(pat::Electron& ele) const final { return modifyObject(static_cast<reco::GsfElectron&>(ele)); }
32  void modifyObject(pat::Photon& pho) const final { return modifyObject(static_cast<reco::Photon&>(pho)); }
33 
34 private:
35  std::pair<int, bool> getSaturationInfo(const reco::SuperCluster& superClus) const;
36 
42 };
43 
45  : ModifyObjectValueBase(conf),
46  ecalRecHitsEBToken_(cc.consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("ecalRecHitsEB"))),
47  ecalRecHitsEEToken_(cc.consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("ecalRecHitsEE"))) {}
48 
52 }
53 
56 }
57 
59  const reco::CaloCluster& seedClus = *(ele.superCluster()->seed());
60  const EcalRecHitCollection* ecalRecHits = ele.isEB() ? &*ecalRecHitsEBHandle_ : &*ecalRecHitsEEHandle_;
61  const auto* caloTopo = caloTopoHandle_.product();
62 
63  auto full5x5ShowerShapes = ele.full5x5_showerShape();
64  full5x5ShowerShapes.e2x5Left = noZS::EcalClusterTools::e2x5Left(seedClus, ecalRecHits, caloTopo);
65  full5x5ShowerShapes.e2x5Right = noZS::EcalClusterTools::e2x5Right(seedClus, ecalRecHits, caloTopo);
66  full5x5ShowerShapes.e2x5Top = noZS::EcalClusterTools::e2x5Top(seedClus, ecalRecHits, caloTopo);
67  full5x5ShowerShapes.e2x5Bottom = noZS::EcalClusterTools::e2x5Bottom(seedClus, ecalRecHits, caloTopo);
68  ele.full5x5_setShowerShape(full5x5ShowerShapes);
69 
70  auto showerShapes = ele.showerShape();
71  showerShapes.e2x5Left = EcalClusterTools::e2x5Left(seedClus, ecalRecHits, caloTopo);
72  showerShapes.e2x5Right = EcalClusterTools::e2x5Right(seedClus, ecalRecHits, caloTopo);
73  showerShapes.e2x5Top = EcalClusterTools::e2x5Top(seedClus, ecalRecHits, caloTopo);
74  showerShapes.e2x5Bottom = EcalClusterTools::e2x5Bottom(seedClus, ecalRecHits, caloTopo);
75  ele.setShowerShape(showerShapes);
76 
78  auto satInfo = getSaturationInfo(*ele.superCluster());
79  eleSatInfo.nSaturatedXtals = satInfo.first;
80  eleSatInfo.isSeedSaturated = satInfo.second;
81  ele.setSaturationInfo(eleSatInfo);
82 }
83 
86  auto satInfo = getSaturationInfo(*pho.superCluster());
87  phoSatInfo.nSaturatedXtals = satInfo.first;
88  phoSatInfo.isSeedSaturated = satInfo.second;
89  pho.setSaturationInfo(phoSatInfo);
90 }
91 
92 std::pair<int, bool> EG8XObjectUpdateModifier::getSaturationInfo(const reco::SuperCluster& superClus) const {
93  bool isEB = superClus.seed()->seed().subdetId() == EcalBarrel;
94  const auto& ecalRecHits = isEB ? *ecalRecHitsEBHandle_ : *ecalRecHitsEEHandle_;
95 
96  int nrSatCrys = 0;
97  bool seedSaturated = false;
98  const auto& hitsAndFractions = superClus.seed()->hitsAndFractions();
99  for (const auto& hitFractionPair : hitsAndFractions) {
100  auto ecalRecHitIt = ecalRecHits.find(hitFractionPair.first);
101  if (ecalRecHitIt != ecalRecHits.end() && ecalRecHitIt->checkFlag(EcalRecHit::Flags::kSaturated)) {
102  nrSatCrys++;
103  if (hitFractionPair.first == superClus.seed()->seed())
104  seedSaturated = true;
105  }
106  }
107  return {nrSatCrys, seedSaturated};
108 }
109 
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
Handle.h
reco::GsfElectron::isEB
bool isEB() const
Definition: GsfElectron.h:336
EG8XObjectUpdateModifier::getSaturationInfo
std::pair< int, bool > getSaturationInfo(const reco::SuperCluster &superClus) const
Definition: EG8XObjectUpdateModifier.cc:92
reco::Photon::superCluster
reco::SuperClusterRef superCluster() const override
Ref to SuperCluster.
reco::GsfElectron::setSaturationInfo
void setSaturationInfo(const SaturationInfo &s)
Definition: GsfElectron.h:500
reco::Photon::SaturationInfo::nSaturatedXtals
int nSaturatedXtals
Definition: Photon.h:259
ESHandle.h
EG8XObjectUpdateModifier::EG8XObjectUpdateModifier
EG8XObjectUpdateModifier(const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
Definition: EG8XObjectUpdateModifier.cc:44
reco::SuperCluster
Definition: SuperCluster.h:18
edm::EDGetTokenT
Definition: EDGetToken.h:33
EcalClusterToolsT::e2x5Bottom
static float e2x5Bottom(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
Definition: EcalClusterTools.h:593
edm
HLT enums.
Definition: AlignableModifier.h:19
pat::Photon
Analysis-level Photon class.
Definition: Photon.h:46
EG8XObjectUpdateModifier::~EG8XObjectUpdateModifier
~EG8XObjectUpdateModifier() override
Definition: EG8XObjectUpdateModifier.cc:23
reco::Photon::SaturationInfo
Definition: Photon.h:258
edm::SortedCollection< EcalRecHit >
EG8XObjectUpdateModifier::setEvent
void setEvent(const edm::Event &) final
Definition: EG8XObjectUpdateModifier.cc:49
CaloTopologyRecord
Definition: CaloTopologyRecord.h:10
reco::GsfElectron::full5x5_setShowerShape
void full5x5_setShowerShape(const ShowerShape &s)
Definition: GsfElectron.h:468
reco::GsfElectron::SaturationInfo::nSaturatedXtals
int nSaturatedXtals
Definition: GsfElectron.h:491
EG8XObjectUpdateModifier::ecalRecHitsEBToken_
edm::EDGetTokenT< EcalRecHitCollection > ecalRecHitsEBToken_
Definition: EG8XObjectUpdateModifier.cc:40
reco::GsfElectron::showerShape
const ShowerShape & showerShape() const
Definition: GsfElectron.h:439
edm::Handle
Definition: AssociativeIterator.h:50
EcalBarrel
Definition: EcalSubdetector.h:10
EcalRecHitCollections.h
reco::GsfElectron::setShowerShape
void setShowerShape(const ShowerShape &s)
Definition: GsfElectron.h:467
reco::GsfElectron::full5x5_showerShape
const ShowerShape & full5x5_showerShape() const
Definition: GsfElectron.h:464
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
EcalClusterToolsT::e2x5Top
static float e2x5Top(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
Definition: EcalClusterTools.h:585
ModifyObjectValueBase.h
reco::CaloCluster
Definition: CaloCluster.h:31
EG8XObjectUpdateModifier
Definition: EG8XObjectUpdateModifier.cc:20
edm::ESHandle< CaloTopology >
EG8XObjectUpdateModifier::setEventContent
void setEventContent(const edm::EventSetup &) final
Definition: EG8XObjectUpdateModifier.cc:54
reco::GsfElectron
Definition: GsfElectron.h:35
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
EDGetToken.h
EG8XObjectUpdateModifier::modifyObject
void modifyObject(pat::Electron &ele) const final
Definition: EG8XObjectUpdateModifier.cc:31
CaloGeometryRecord.h
EcalSubdetector.h
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
reco::SuperCluster::seed
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:77
ModifyObjectValueBase
Definition: ModifyObjectValueBase.h:18
edmplugin::PluginFactory
Definition: PluginFactory.h:34
EcalClusterTools.h
EG8XObjectUpdateModifier::caloTopoHandle_
edm::ESHandle< CaloTopology > caloTopoHandle_
Definition: EG8XObjectUpdateModifier.cc:37
EG8XObjectUpdateModifier::modifyObject
void modifyObject(reco::GsfElectron &ele) const final
Definition: EG8XObjectUpdateModifier.cc:58
CaloTopologyRecord.h
reco::GsfElectron::ShowerShape::e2x5Left
float e2x5Left
Definition: GsfElectron.h:388
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
reco::GsfElectron::SaturationInfo::isSeedSaturated
bool isSeedSaturated
Definition: GsfElectron.h:492
get
#define get
cc
EcalRecHit.h
EcalClusterToolsT::e2x5Right
static float e2x5Right(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
Definition: EcalClusterTools.h:569
InputTag.h
EG8XObjectUpdateModifier::ecalRecHitsEEHandle_
edm::Handle< EcalRecHitCollection > ecalRecHitsEEHandle_
Definition: EG8XObjectUpdateModifier.cc:39
CaloTopology.h
reco::Photon
Definition: Photon.h:21
EG8XObjectUpdateModifier::modifyObject
void modifyObject(pat::Photon &pho) const final
Definition: EG8XObjectUpdateModifier.cc:32
EcalClusterToolsT::e2x5Left
static float e2x5Left(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
Definition: EcalClusterTools.h:577
reco::Photon::SaturationInfo::isSeedSaturated
bool isSeedSaturated
Definition: Photon.h:260
reco::GsfElectron::superCluster
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:163
reco::Photon::setSaturationInfo
void setSaturationInfo(const SaturationInfo &s)
Definition: Photon.h:268
pat::Electron
Analysis-level electron class.
Definition: Electron.h:51
EG8XObjectUpdateModifier::ecalRecHitsEEToken_
edm::EDGetTokenT< EcalRecHitCollection > ecalRecHitsEEToken_
Definition: EG8XObjectUpdateModifier.cc:41
ParameterSet.h
edm::Event
Definition: Event.h:73
reco::GsfElectron::SaturationInfo
Definition: GsfElectron.h:490
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
EG8XObjectUpdateModifier::ecalRecHitsEBHandle_
edm::Handle< EcalRecHitCollection > ecalRecHitsEBHandle_
Definition: EG8XObjectUpdateModifier.cc:38