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 
37  CaloTopology const* caloTopo_ = nullptr;
40 
44 };
45 
47  : ModifyObjectValueBase(conf),
48  caloTopoToken_{cc.esConsumes()},
49  ecalRecHitsEBToken_(cc.consumes(conf.getParameter<edm::InputTag>("ecalRecHitsEB"))),
50  ecalRecHitsEEToken_(cc.consumes(conf.getParameter<edm::InputTag>("ecalRecHitsEE"))) {}
51 
55 }
56 
58  caloTopo_ = &iSetup.getData(caloTopoToken_);
59 }
60 
62  const reco::CaloCluster& seedClus = *(ele.superCluster()->seed());
63  const EcalRecHitCollection* ecalRecHits = ele.isEB() ? ecalRecHitsEB_ : ecalRecHitsEE_;
64 
65  auto full5x5ShowerShapes = ele.full5x5_showerShape();
66  full5x5ShowerShapes.e2x5Left = noZS::EcalClusterTools::e2x5Left(seedClus, ecalRecHits, caloTopo_);
67  full5x5ShowerShapes.e2x5Right = noZS::EcalClusterTools::e2x5Right(seedClus, ecalRecHits, caloTopo_);
68  full5x5ShowerShapes.e2x5Top = noZS::EcalClusterTools::e2x5Top(seedClus, ecalRecHits, caloTopo_);
69  full5x5ShowerShapes.e2x5Bottom = noZS::EcalClusterTools::e2x5Bottom(seedClus, ecalRecHits, caloTopo_);
70  ele.full5x5_setShowerShape(full5x5ShowerShapes);
71 
72  auto showerShapes = ele.showerShape();
73  showerShapes.e2x5Left = EcalClusterTools::e2x5Left(seedClus, ecalRecHits, caloTopo_);
74  showerShapes.e2x5Right = EcalClusterTools::e2x5Right(seedClus, ecalRecHits, caloTopo_);
75  showerShapes.e2x5Top = EcalClusterTools::e2x5Top(seedClus, ecalRecHits, caloTopo_);
76  showerShapes.e2x5Bottom = EcalClusterTools::e2x5Bottom(seedClus, ecalRecHits, caloTopo_);
77  ele.setShowerShape(showerShapes);
78 
80  auto satInfo = getSaturationInfo(*ele.superCluster());
81  eleSatInfo.nSaturatedXtals = satInfo.first;
82  eleSatInfo.isSeedSaturated = satInfo.second;
83  ele.setSaturationInfo(eleSatInfo);
84 }
85 
88  auto satInfo = getSaturationInfo(*pho.superCluster());
89  phoSatInfo.nSaturatedXtals = satInfo.first;
90  phoSatInfo.isSeedSaturated = satInfo.second;
91  pho.setSaturationInfo(phoSatInfo);
92 }
93 
94 std::pair<int, bool> EG8XObjectUpdateModifier::getSaturationInfo(const reco::SuperCluster& superClus) const {
95  bool isEB = superClus.seed()->seed().subdetId() == EcalBarrel;
96  const auto& ecalRecHits = isEB ? *ecalRecHitsEB_ : *ecalRecHitsEE_;
97 
98  int nrSatCrys = 0;
99  bool seedSaturated = false;
100  const auto& hitsAndFractions = superClus.seed()->hitsAndFractions();
101  for (const auto& hitFractionPair : hitsAndFractions) {
102  auto ecalRecHitIt = ecalRecHits.find(hitFractionPair.first);
103  if (ecalRecHitIt != ecalRecHits.end() && ecalRecHitIt->checkFlag(EcalRecHit::Flags::kSaturated)) {
104  nrSatCrys++;
105  if (hitFractionPair.first == superClus.seed()->seed())
106  seedSaturated = true;
107  }
108  }
109  return {nrSatCrys, seedSaturated};
110 }
111 
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:94
reco::Photon::superCluster
reco::SuperClusterRef superCluster() const override
Ref to SuperCluster.
reco::GsfElectron::setSaturationInfo
void setSaturationInfo(const SaturationInfo &s)
Definition: GsfElectron.h:530
reco::Photon::SaturationInfo::nSaturatedXtals
int nSaturatedXtals
Definition: Photon.h:300
ESHandle.h
EG8XObjectUpdateModifier::EG8XObjectUpdateModifier
EG8XObjectUpdateModifier(const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
Definition: EG8XObjectUpdateModifier.cc:46
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:598
pat::Photon
Analysis-level Photon class.
Definition: Photon.h:46
EG8XObjectUpdateModifier::~EG8XObjectUpdateModifier
~EG8XObjectUpdateModifier() override
Definition: EG8XObjectUpdateModifier.cc:23
reco::Photon::SaturationInfo
Definition: Photon.h:299
edm::SortedCollection< EcalRecHit >
EG8XObjectUpdateModifier::setEvent
void setEvent(const edm::Event &) final
Definition: EG8XObjectUpdateModifier.cc:52
reco::GsfElectron::full5x5_setShowerShape
void full5x5_setShowerShape(const ShowerShape &s)
Definition: GsfElectron.h:500
reco::GsfElectron::SaturationInfo::nSaturatedXtals
int nSaturatedXtals
Definition: GsfElectron.h:521
EG8XObjectUpdateModifier::ecalRecHitsEE_
EcalRecHitCollection const * ecalRecHitsEE_
Definition: EG8XObjectUpdateModifier.cc:39
EG8XObjectUpdateModifier::ecalRecHitsEBToken_
edm::EDGetTokenT< EcalRecHitCollection > ecalRecHitsEBToken_
Definition: EG8XObjectUpdateModifier.cc:42
reco::GsfElectron::showerShape
const ShowerShape & showerShape() const
Definition: GsfElectron.h:475
CaloTopology
Definition: CaloTopology.h:19
EcalBarrel
Definition: EcalSubdetector.h:10
EcalRecHitCollections.h
reco::GsfElectron::setShowerShape
void setShowerShape(const ShowerShape &s)
Definition: GsfElectron.h:499
reco::GsfElectron::full5x5_showerShape
const ShowerShape & full5x5_showerShape() const
Definition: GsfElectron.h:496
EcalClusterToolsT::e2x5Top
static float e2x5Top(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
Definition: EcalClusterTools.h:590
ModifyObjectValueBase.h
reco::CaloCluster
Definition: CaloCluster.h:31
EG8XObjectUpdateModifier
Definition: EG8XObjectUpdateModifier.cc:20
EG8XObjectUpdateModifier::setEventContent
void setEventContent(const edm::EventSetup &) final
Definition: EG8XObjectUpdateModifier.cc:57
EcalRecHit.h
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
EG8XObjectUpdateModifier::caloTopoToken_
edm::ESGetToken< CaloTopology, CaloTopologyRecord > caloTopoToken_
Definition: EG8XObjectUpdateModifier.cc:41
CaloGeometryRecord.h
EcalSubdetector.h
edm::ParameterSet
Definition: ParameterSet.h:47
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::modifyObject
void modifyObject(reco::GsfElectron &ele) const final
Definition: EG8XObjectUpdateModifier.cc:61
reco::GsfElectron::ShowerShape::e2x5Left
float e2x5Left
Definition: GsfElectron.h:393
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
reco::GsfElectron::SaturationInfo::isSeedSaturated
bool isSeedSaturated
Definition: GsfElectron.h:522
cc
edm::ESGetToken< CaloTopology, CaloTopologyRecord >
EcalClusterToolsT::e2x5Right
static float e2x5Right(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
Definition: EcalClusterTools.h:574
InputTag.h
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
CaloTopology.h
reco::Photon
Definition: Photon.h:22
CaloTopologyRecord.h
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:582
reco::Photon::SaturationInfo::isSeedSaturated
bool isSeedSaturated
Definition: Photon.h:301
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:309
pat::Electron
Analysis-level electron class.
Definition: Electron.h:51
EG8XObjectUpdateModifier::ecalRecHitsEEToken_
edm::EDGetTokenT< EcalRecHitCollection > ecalRecHitsEEToken_
Definition: EG8XObjectUpdateModifier.cc:43
ParameterSet.h
EG8XObjectUpdateModifier::caloTopo_
CaloTopology const * caloTopo_
Definition: EG8XObjectUpdateModifier.cc:37
edm::Event
Definition: Event.h:73
reco::GsfElectron::SaturationInfo
Definition: GsfElectron.h:520
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
EG8XObjectUpdateModifier::ecalRecHitsEB_
EcalRecHitCollection const * ecalRecHitsEB_
Definition: EG8XObjectUpdateModifier.cc:38