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 };
44 
47  ecalRecHitsEBToken_(cc.consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("ecalRecHitsEB"))),
48  ecalRecHitsEEToken_(cc.consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("ecalRecHitsEE")))
49 {
50 
51 
52 }
53 
55 {
58 }
59 
61 {
62  iSetup.get<CaloTopologyRecord>().get(caloTopoHandle_);
63 }
64 
65 
67 {
68 
69  const reco::CaloCluster& seedClus = *(ele.superCluster()->seed());
70  const EcalRecHitCollection* ecalRecHits = ele.isEB() ? &*ecalRecHitsEBHandle_ : &*ecalRecHitsEEHandle_;
71  const auto* caloTopo = caloTopoHandle_.product();
72 
73  auto full5x5ShowerShapes = ele.full5x5_showerShape();
74  full5x5ShowerShapes.e2x5Left = noZS::EcalClusterTools::e2x5Left (seedClus,ecalRecHits,caloTopo);
75  full5x5ShowerShapes.e2x5Right = noZS::EcalClusterTools::e2x5Right (seedClus,ecalRecHits,caloTopo);
76  full5x5ShowerShapes.e2x5Top = noZS::EcalClusterTools::e2x5Top (seedClus,ecalRecHits,caloTopo);
77  full5x5ShowerShapes.e2x5Bottom = noZS::EcalClusterTools::e2x5Bottom(seedClus,ecalRecHits,caloTopo);
78  ele.full5x5_setShowerShape(full5x5ShowerShapes);
79 
80  auto showerShapes = ele.showerShape();
81  showerShapes.e2x5Left = EcalClusterTools::e2x5Left (seedClus,ecalRecHits,caloTopo);
82  showerShapes.e2x5Right = EcalClusterTools::e2x5Right (seedClus,ecalRecHits,caloTopo);
83  showerShapes.e2x5Top = EcalClusterTools::e2x5Top (seedClus,ecalRecHits,caloTopo);
84  showerShapes.e2x5Bottom = EcalClusterTools::e2x5Bottom(seedClus,ecalRecHits,caloTopo);
85  ele.setShowerShape(showerShapes);
86 
88  auto satInfo = getSaturationInfo(*ele.superCluster());
89  eleSatInfo.nSaturatedXtals = satInfo.first;
90  eleSatInfo.isSeedSaturated = satInfo.second;
91  ele.setSaturationInfo(eleSatInfo);
92 }
93 
95 {
97  auto satInfo = getSaturationInfo(*pho.superCluster());
98  phoSatInfo.nSaturatedXtals = satInfo.first;
99  phoSatInfo.isSeedSaturated = satInfo.second;
100  pho.setSaturationInfo(phoSatInfo);
101 }
102 
103 
104 std::pair<int,bool> EG8XObjectUpdateModifier::getSaturationInfo(const reco::SuperCluster& superClus)const
105 {
106  bool isEB = superClus.seed()->seed().subdetId()==EcalBarrel;
107  const auto& ecalRecHits = isEB ? *ecalRecHitsEBHandle_ : *ecalRecHitsEEHandle_;
108 
109  int nrSatCrys = 0;
110  bool seedSaturated = false;
111  const auto& hitsAndFractions = superClus.seed()->hitsAndFractions();
112  for(const auto& hitFractionPair : hitsAndFractions) {
113  auto ecalRecHitIt = ecalRecHits.find(hitFractionPair.first);
114  if(ecalRecHitIt != ecalRecHits.end() &&
115  ecalRecHitIt->checkFlag(EcalRecHit::Flags::kSaturated)){
116  nrSatCrys++;
117  if(hitFractionPair.first == superClus.seed()->seed()) seedSaturated = true;
118  }
119  }
120  return {nrSatCrys,seedSaturated};
121 }
122 
125  "EG8XObjectUpdateModifier");
const ShowerShape & showerShape() const
Definition: GsfElectron.h:458
edm::EDGetTokenT< EcalRecHitCollection > ecalRecHitsEBToken_
Analysis-level Photon class.
Definition: Photon.h:47
static float e2x5Bottom(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void setSaturationInfo(const SaturationInfo &s)
Definition: GsfElectron.h:523
void setShowerShape(const ShowerShape &s)
Definition: GsfElectron.h:486
void setSaturationInfo(const SaturationInfo &s)
Definition: Photon.h:269
reco::SuperClusterRef superCluster() const override
Ref to SuperCluster.
void modifyObject(reco::GsfElectron &ele) const final
bool isEB() const
Definition: GsfElectron.h:356
static float e2x5Top(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
edm::Handle< EcalRecHitCollection > ecalRecHitsEBHandle_
void modifyObject(pat::Electron &ele) const final
int iEvent
Definition: GenABIO.cc:224
edm::ESHandle< CaloTopology > caloTopoHandle_
EG8XObjectUpdateModifier(const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
static float e2x5Right(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
std::pair< int, bool > getSaturationInfo(const reco::SuperCluster &superClus) const
edm::Handle< EcalRecHitCollection > ecalRecHitsEEHandle_
Analysis-level electron class.
Definition: Electron.h:52
static float e2x5Left(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
const ShowerShape & full5x5_showerShape() const
Definition: GsfElectron.h:483
void setEventContent(const edm::EventSetup &) final
HLT enums.
T get() const
Definition: EventSetup.h:71
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:185
void modifyObject(pat::Photon &pho) const final
#define DEFINE_EDM_PLUGIN(factory, type, name)
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:66
void full5x5_setShowerShape(const ShowerShape &s)
Definition: GsfElectron.h:487
T const * product() const
Definition: ESHandle.h:86
void setEvent(const edm::Event &) final
edm::EDGetTokenT< EcalRecHitCollection > ecalRecHitsEEToken_