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;
28 
29  void modifyObject(reco::GsfElectron& ele) const final;
30  void modifyObject(reco::Photon& pho) const final;
31 
32  void modifyObject(pat::Electron& ele) const final{return modifyObject(static_cast<reco::GsfElectron&>(ele));}
33  void modifyObject(pat::Photon& pho) const final{return modifyObject(static_cast<reco::Photon&>(pho));}
34 
35 private:
36  std::pair<int,bool> getSaturationInfo(const reco::SuperCluster& superClus)const;
37 
45 
46 };
47 
50  ecalRecHitsEBTag_(conf.getParameter<edm::InputTag>("ecalRecHitsEB")),
51  ecalRecHitsEETag_(conf.getParameter<edm::InputTag>("ecalRecHitsEE"))
52 {
53 
54 
55 }
56 
58 {
61 }
62 
64 {
67 }
68 
70 {
71  iSetup.get<CaloTopologyRecord>().get(caloTopoHandle_);
72 }
73 
74 
76 {
77 
78  const reco::CaloCluster& seedClus = *(ele.superCluster()->seed());
79  const EcalRecHitCollection* ecalRecHits = ele.isEB() ? &*ecalRecHitsEBHandle_ : &*ecalRecHitsEEHandle_;
80  const auto* caloTopo = caloTopoHandle_.product();
81 
82  auto full5x5ShowerShapes = ele.full5x5_showerShape();
83  full5x5ShowerShapes.e2x5Left = noZS::EcalClusterTools::e2x5Left (seedClus,ecalRecHits,caloTopo);
84  full5x5ShowerShapes.e2x5Right = noZS::EcalClusterTools::e2x5Right (seedClus,ecalRecHits,caloTopo);
85  full5x5ShowerShapes.e2x5Top = noZS::EcalClusterTools::e2x5Top (seedClus,ecalRecHits,caloTopo);
86  full5x5ShowerShapes.e2x5Bottom = noZS::EcalClusterTools::e2x5Bottom(seedClus,ecalRecHits,caloTopo);
87  ele.full5x5_setShowerShape(full5x5ShowerShapes);
88 
89  auto showerShapes = ele.showerShape();
90  showerShapes.e2x5Left = EcalClusterTools::e2x5Left (seedClus,ecalRecHits,caloTopo);
91  showerShapes.e2x5Right = EcalClusterTools::e2x5Right (seedClus,ecalRecHits,caloTopo);
92  showerShapes.e2x5Top = EcalClusterTools::e2x5Top (seedClus,ecalRecHits,caloTopo);
93  showerShapes.e2x5Bottom = EcalClusterTools::e2x5Bottom(seedClus,ecalRecHits,caloTopo);
94  ele.setShowerShape(showerShapes);
95 
97  auto satInfo = getSaturationInfo(*ele.superCluster());
98  eleSatInfo.nSaturatedXtals = satInfo.first;
99  eleSatInfo.isSeedSaturated = satInfo.second;
100  ele.setSaturationInfo(eleSatInfo);
101 }
102 
104 {
105  reco::Photon::SaturationInfo phoSatInfo;
106  auto satInfo = getSaturationInfo(*pho.superCluster());
107  phoSatInfo.nSaturatedXtals = satInfo.first;
108  phoSatInfo.isSeedSaturated = satInfo.second;
109  pho.setSaturationInfo(phoSatInfo);
110 }
111 
112 
113 std::pair<int,bool> EG8XObjectUpdateModifier::getSaturationInfo(const reco::SuperCluster& superClus)const
114 {
115  bool isEB = superClus.seed()->seed().subdetId()==EcalBarrel;
116  const auto& ecalRecHits = isEB ? *ecalRecHitsEBHandle_ : *ecalRecHitsEEHandle_;
117 
118  int nrSatCrys = 0;
119  bool seedSaturated = false;
120  const auto& hitsAndFractions = superClus.seed()->hitsAndFractions();
121  for(const auto& hitFractionPair : hitsAndFractions) {
122  auto ecalRecHitIt = ecalRecHits.find(hitFractionPair.first);
123  if(ecalRecHitIt != ecalRecHits.end() &&
124  ecalRecHitIt->checkFlag(EcalRecHit::Flags::kSaturated)){
125  nrSatCrys++;
126  if(hitFractionPair.first == superClus.seed()->seed()) seedSaturated = true;
127  }
128  }
129  return {nrSatCrys,seedSaturated};
130 }
131 
134  "EG8XObjectUpdateModifier");
const ShowerShape & showerShape() const
Definition: GsfElectron.h:451
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< EcalRecHitCollection > ecalRecHitsEBToken_
Analysis-level Photon class.
Definition: Photon.h:47
EG8XObjectUpdateModifier(const edm::ParameterSet &conf)
static float e2x5Bottom(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
void setSaturationInfo(const SaturationInfo &s)
Definition: GsfElectron.h:515
void setShowerShape(const ShowerShape &s)
Definition: GsfElectron.h:478
void setSaturationInfo(const SaturationInfo &s)
Definition: Photon.h:257
reco::SuperClusterRef superCluster() const override
Ref to SuperCluster.
void modifyObject(reco::GsfElectron &ele) const final
bool isEB() const
Definition: GsfElectron.h:352
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:230
edm::ESHandle< CaloTopology > caloTopoHandle_
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_
const T & get() const
Definition: EventSetup.h:55
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:475
void setConsumes(edm::ConsumesCollector &) final
void setEventContent(const edm::EventSetup &) final
HLT enums.
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:184
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:479
T const * product() const
Definition: ESHandle.h:86
void setEvent(const edm::Event &) final
edm::EDGetTokenT< EcalRecHitCollection > ecalRecHitsEEToken_