CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
edm::EDGetTokenT< EcalRecHitCollection > ecalRecHitsEBToken_
Analysis-level Photon class.
Definition: Photon.h:46
static float e2x5Bottom(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
void setSaturationInfo(const SaturationInfo &s)
Definition: GsfElectron.h:522
void setShowerShape(const ShowerShape &s)
Definition: GsfElectron.h:491
void modifyObject(pat::Electron &ele) const final
void setSaturationInfo(const SaturationInfo &s)
Definition: Photon.h:315
static float e2x5Top(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
bool isEB() const
Definition: GsfElectron.h:328
void modifyObject(pat::Photon &pho) const final
EcalRecHitCollection const * ecalRecHitsEE_
int iEvent
Definition: GenABIO.cc:224
const ShowerShape & full5x5_showerShape() const
Definition: GsfElectron.h:488
reco::SuperClusterRef superCluster() const override
Ref to SuperCluster.
EG8XObjectUpdateModifier(const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
static float e2x5Right(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
EcalRecHitCollection const * ecalRecHitsEB_
void modifyObject(reco::GsfElectron &ele) const final
std::pair< int, bool > getSaturationInfo(const reco::SuperCluster &superClus) const
Analysis-level electron class.
Definition: Electron.h:51
static float e2x5Left(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
edm::ESGetToken< CaloTopology, CaloTopologyRecord > caloTopoToken_
const ShowerShape & showerShape() const
Definition: GsfElectron.h:467
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:79
void setEventContent(const edm::EventSetup &) final
#define DEFINE_EDM_PLUGIN(factory, type, name)
void full5x5_setShowerShape(const ShowerShape &s)
Definition: GsfElectron.h:492
void setEvent(const edm::Event &) final
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:155
edm::EDGetTokenT< EcalRecHitCollection > ecalRecHitsEEToken_