File indexing completed on 2024-09-07 04:35:52
0001 #ifndef GsfElectron_h
0002 #define GsfElectron_h
0003
0004 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
0005 #include "DataFormats/EgammaCandidates/interface/GsfElectronCore.h"
0006 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
0007 #include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h"
0008
0009 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0010 #include "DataFormats/TrackReco/interface/Track.h"
0011 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
0012 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
0013 #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
0014 #include "DataFormats/CaloTowers/interface/CaloTowerDetId.h"
0015
0016 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0017 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
0018 #include <vector>
0019 #include <limits>
0020 #include <numeric>
0021
0022 namespace reco {
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 class GsfElectron : public RecoCandidate {
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 public:
0047
0048 struct ChargeInfo;
0049 struct TrackClusterMatching;
0050 struct TrackExtrapolations;
0051 struct ClosestCtfTrack;
0052 struct FiducialFlags;
0053 struct ShowerShape;
0054 struct IsolationVariables;
0055 struct ConversionRejection;
0056 struct ClassificationVariables;
0057 struct SaturationInfo;
0058
0059 GsfElectron();
0060 GsfElectron(const GsfElectronCoreRef &);
0061 GsfElectron(const GsfElectron &, const GsfElectronCoreRef &);
0062 GsfElectron(const GsfElectron &electron,
0063 const GsfElectronCoreRef &core,
0064 const CaloClusterPtr &electronCluster,
0065 const TrackRef &closestCtfTrack,
0066 const TrackBaseRef &conversionPartner,
0067 const GsfTrackRefVector &ambiguousTracks);
0068 GsfElectron(int charge,
0069 const ChargeInfo &,
0070 const GsfElectronCoreRef &,
0071 const TrackClusterMatching &,
0072 const TrackExtrapolations &,
0073 const ClosestCtfTrack &,
0074 const FiducialFlags &,
0075 const ShowerShape &,
0076 const ConversionRejection &);
0077 GsfElectron(int charge,
0078 const ChargeInfo &,
0079 const GsfElectronCoreRef &,
0080 const TrackClusterMatching &,
0081 const TrackExtrapolations &,
0082 const ClosestCtfTrack &,
0083 const FiducialFlags &,
0084 const ShowerShape &,
0085 const ShowerShape &,
0086 const ConversionRejection &,
0087 const SaturationInfo &);
0088 GsfElectron *clone() const override;
0089 GsfElectron *clone(const GsfElectronCoreRef &core,
0090 const CaloClusterPtr &electronCluster,
0091 const TrackRef &closestCtfTrack,
0092 const TrackBaseRef &conversionPartner,
0093 const GsfTrackRefVector &ambiguousTracks) const;
0094 ~GsfElectron() override {}
0095
0096 private:
0097 void init();
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109 public:
0110
0111
0112
0113
0114
0115 struct ChargeInfo {
0116 int scPixCharge;
0117 bool isGsfCtfScPixConsistent;
0118 bool isGsfScPixConsistent;
0119 bool isGsfCtfConsistent;
0120 ChargeInfo()
0121 : scPixCharge(0), isGsfCtfScPixConsistent(false), isGsfScPixConsistent(false), isGsfCtfConsistent(false) {}
0122 };
0123
0124
0125
0126
0127 int scPixCharge() const { return chargeInfo_.scPixCharge; }
0128 bool isGsfCtfScPixChargeConsistent() const { return chargeInfo_.isGsfCtfScPixConsistent; }
0129 bool isGsfScPixChargeConsistent() const { return chargeInfo_.isGsfScPixConsistent; }
0130 bool isGsfCtfChargeConsistent() const { return chargeInfo_.isGsfCtfConsistent; }
0131 const ChargeInfo &chargeInfo() const { return chargeInfo_; }
0132
0133
0134 bool isElectron() const override { return true; }
0135 bool overlap(const Candidate &) const override;
0136
0137 private:
0138
0139 ChargeInfo chargeInfo_;
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149 public:
0150
0151 virtual GsfElectronCoreRef core() const;
0152 void setCore(const reco::GsfElectronCoreRef &core) { core_ = core; }
0153
0154
0155 SuperClusterRef superCluster() const override { return core()->superCluster(); }
0156 GsfTrackRef gsfTrack() const override { return core()->gsfTrack(); }
0157 float ctfGsfOverlap() const { return core()->ctfGsfOverlap(); }
0158 bool ecalDrivenSeed() const { return core()->ecalDrivenSeed(); }
0159 bool trackerDrivenSeed() const { return core()->trackerDrivenSeed(); }
0160 virtual SuperClusterRef parentSuperCluster() const { return core()->parentSuperCluster(); }
0161 bool closestCtfTrackRefValid() const {
0162 return closestCtfTrackRef().isAvailable() && closestCtfTrackRef().isNonnull();
0163 }
0164
0165 float closestCtfTrackNormChi2() const {
0166 return closestCtfTrackRefValid() ? closestCtfTrackRef()->normalizedChi2() : 0;
0167 }
0168 int closestCtfTrackNLayers() const {
0169 return closestCtfTrackRefValid() ? closestCtfTrackRef()->hitPattern().trackerLayersWithMeasurement() : -1;
0170 }
0171
0172
0173 struct ClosestCtfTrack {
0174 TrackRef ctfTrack;
0175 float shFracInnerHits;
0176 ClosestCtfTrack() : shFracInnerHits(0.) {}
0177 ClosestCtfTrack(TrackRef track, float sh) : ctfTrack(track), shFracInnerHits(sh) {}
0178 };
0179 float shFracInnerHits() const { return core()->ctfGsfOverlap(); }
0180 virtual TrackRef closestCtfTrackRef() const { return core()->ctfTrack(); }
0181 virtual ClosestCtfTrack closestCtfTrack() const {
0182 return ClosestCtfTrack(core()->ctfTrack(), core()->ctfGsfOverlap());
0183 }
0184
0185 private:
0186
0187 GsfElectronCoreRef core_;
0188
0189
0190
0191
0192
0193 public:
0194 struct TrackClusterMatching {
0195 CaloClusterPtr electronCluster;
0196 float eSuperClusterOverP;
0197 float eSeedClusterOverP;
0198 float eSeedClusterOverPout;
0199 float eEleClusterOverPout;
0200 float deltaEtaSuperClusterAtVtx;
0201 float deltaEtaSeedClusterAtCalo;
0202 float deltaEtaEleClusterAtCalo;
0203 float deltaPhiEleClusterAtCalo;
0204 float deltaPhiSuperClusterAtVtx;
0205 float deltaPhiSeedClusterAtCalo;
0206 TrackClusterMatching()
0207 : eSuperClusterOverP(0.),
0208 eSeedClusterOverP(0.),
0209 eSeedClusterOverPout(0.),
0210 eEleClusterOverPout(0.),
0211 deltaEtaSuperClusterAtVtx(std::numeric_limits<float>::max()),
0212 deltaEtaSeedClusterAtCalo(std::numeric_limits<float>::max()),
0213 deltaEtaEleClusterAtCalo(std::numeric_limits<float>::max()),
0214 deltaPhiEleClusterAtCalo(std::numeric_limits<float>::max()),
0215 deltaPhiSuperClusterAtVtx(std::numeric_limits<float>::max()),
0216 deltaPhiSeedClusterAtCalo(std::numeric_limits<float>::max()) {}
0217 };
0218
0219
0220 CaloClusterPtr electronCluster() const { return trackClusterMatching_.electronCluster; }
0221 float eSuperClusterOverP() const { return trackClusterMatching_.eSuperClusterOverP; }
0222 float eSeedClusterOverP() const { return trackClusterMatching_.eSeedClusterOverP; }
0223 float eSeedClusterOverPout() const { return trackClusterMatching_.eSeedClusterOverPout; }
0224 float eEleClusterOverPout() const { return trackClusterMatching_.eEleClusterOverPout; }
0225 float deltaEtaSuperClusterTrackAtVtx() const { return trackClusterMatching_.deltaEtaSuperClusterAtVtx; }
0226 float deltaEtaSeedClusterTrackAtCalo() const { return trackClusterMatching_.deltaEtaSeedClusterAtCalo; }
0227 float deltaEtaEleClusterTrackAtCalo() const { return trackClusterMatching_.deltaEtaEleClusterAtCalo; }
0228 float deltaPhiSuperClusterTrackAtVtx() const { return trackClusterMatching_.deltaPhiSuperClusterAtVtx; }
0229 float deltaPhiSeedClusterTrackAtCalo() const { return trackClusterMatching_.deltaPhiSeedClusterAtCalo; }
0230 float deltaPhiEleClusterTrackAtCalo() const { return trackClusterMatching_.deltaPhiEleClusterAtCalo; }
0231 float deltaEtaSeedClusterTrackAtVtx() const {
0232 return superCluster().isNonnull() && superCluster()->seed().isNonnull()
0233 ? trackClusterMatching_.deltaEtaSuperClusterAtVtx - superCluster()->eta() +
0234 superCluster()->seed()->eta()
0235 : std::numeric_limits<float>::max();
0236 }
0237 const TrackClusterMatching &trackClusterMatching() const { return trackClusterMatching_; }
0238
0239
0240 void setDeltaEtaSuperClusterAtVtx(float de) { trackClusterMatching_.deltaEtaSuperClusterAtVtx = de; }
0241 void setDeltaPhiSuperClusterAtVtx(float dphi) { trackClusterMatching_.deltaPhiSuperClusterAtVtx = dphi; }
0242
0243 private:
0244
0245 TrackClusterMatching trackClusterMatching_;
0246
0247
0248
0249
0250
0251 public:
0252 struct TrackExtrapolations {
0253 math::XYZPointF positionAtVtx;
0254 math::XYZPointF positionAtCalo;
0255 math::XYZVectorF momentumAtVtx;
0256
0257 math::XYZVectorF momentumAtCalo;
0258
0259 math::XYZVectorF momentumOut;
0260
0261 math::XYZVectorF momentumAtEleClus;
0262 math::XYZVectorF momentumAtVtxWithConstraint;
0263 };
0264
0265
0266 math::XYZPointF trackPositionAtVtx() const { return trackExtrapolations_.positionAtVtx; }
0267 math::XYZPointF trackPositionAtCalo() const { return trackExtrapolations_.positionAtCalo; }
0268 math::XYZVectorF trackMomentumAtVtx() const { return trackExtrapolations_.momentumAtVtx; }
0269 math::XYZVectorF trackMomentumAtCalo() const { return trackExtrapolations_.momentumAtCalo; }
0270 math::XYZVectorF trackMomentumOut() const { return trackExtrapolations_.momentumOut; }
0271 math::XYZVectorF trackMomentumAtEleClus() const { return trackExtrapolations_.momentumAtEleClus; }
0272 math::XYZVectorF trackMomentumAtVtxWithConstraint() const {
0273 return trackExtrapolations_.momentumAtVtxWithConstraint;
0274 }
0275 const TrackExtrapolations &trackExtrapolations() const { return trackExtrapolations_; }
0276
0277
0278 void setTrackExtrapolations(const TrackExtrapolations &te) { trackExtrapolations_ = te; }
0279
0280
0281 math::XYZPointF TrackPositionAtVtx() const { return trackPositionAtVtx(); }
0282 math::XYZPointF TrackPositionAtCalo() const { return trackPositionAtCalo(); }
0283
0284 private:
0285
0286 TrackExtrapolations trackExtrapolations_;
0287
0288
0289
0290
0291
0292 public:
0293
0294 math::XYZPoint superClusterPosition() const { return superCluster()->position(); }
0295 int basicClustersSize() const {
0296 return superCluster()->clustersSize();
0297 }
0298 CaloCluster_iterator basicClustersBegin() const { return superCluster()->clustersBegin(); }
0299 CaloCluster_iterator basicClustersEnd() const { return superCluster()->clustersEnd(); }
0300
0301
0302 math::XYZPoint caloPosition() const { return superCluster()->position(); }
0303
0304
0305
0306
0307
0308 public:
0309 struct FiducialFlags {
0310 bool isEB;
0311 bool isEE;
0312 bool isEBEEGap;
0313 bool isEBEtaGap;
0314 bool isEBPhiGap;
0315 bool isEEDeeGap;
0316 bool isEERingGap;
0317 FiducialFlags()
0318 : isEB(false),
0319 isEE(false),
0320 isEBEEGap(false),
0321 isEBEtaGap(false),
0322 isEBPhiGap(false),
0323 isEEDeeGap(false),
0324 isEERingGap(false) {}
0325 };
0326
0327
0328 bool isEB() const { return fiducialFlags_.isEB; }
0329 bool isEE() const { return fiducialFlags_.isEE; }
0330 bool isGap() const { return ((isEBEEGap()) || (isEBGap()) || (isEEGap())); }
0331 bool isEBEEGap() const { return fiducialFlags_.isEBEEGap; }
0332 bool isEBGap() const { return (isEBEtaGap() || isEBPhiGap()); }
0333 bool isEBEtaGap() const { return fiducialFlags_.isEBEtaGap; }
0334 bool isEBPhiGap() const { return fiducialFlags_.isEBPhiGap; }
0335 bool isEEGap() const { return (isEEDeeGap() || isEERingGap()); }
0336 bool isEEDeeGap() const { return fiducialFlags_.isEEDeeGap; }
0337 bool isEERingGap() const { return fiducialFlags_.isEERingGap; }
0338 const FiducialFlags &fiducialFlags() const { return fiducialFlags_; }
0339
0340
0341 void setFFlagIsEB(const bool b) { fiducialFlags_.isEB = b; }
0342 void setFFlagIsEE(const bool b) { fiducialFlags_.isEE = b; }
0343 void setFFlagIsEBEEGap(const bool b) { fiducialFlags_.isEBEEGap = b; }
0344 void setFFlagIsEBEtaGap(const bool b) { fiducialFlags_.isEBEtaGap = b; }
0345 void setFFlagIsEBPhiGap(const bool b) { fiducialFlags_.isEBPhiGap = b; }
0346 void setFFlagIsEEDeeGap(const bool b) { fiducialFlags_.isEEDeeGap = b; }
0347 void setFFlagIsEERingGap(const bool b) { fiducialFlags_.isEERingGap = b; }
0348
0349 private:
0350
0351 FiducialFlags fiducialFlags_;
0352
0353
0354
0355
0356
0357 public:
0358 struct ShowerShape {
0359 float sigmaEtaEta;
0360 float sigmaIetaIeta;
0361 float sigmaIphiIphi;
0362 float e1x5;
0363 float e2x5Max;
0364 float e5x5;
0365 float r9;
0366 float hcalDepth1OverEcal;
0367 float hcalDepth2OverEcal;
0368 float hcalDepth1OverEcalBc;
0369 float hcalDepth2OverEcalBc;
0370 std::array<float, 7>
0371 hcalOverEcal;
0372 std::array<float, 7>
0373 hcalOverEcalBc;
0374 std::vector<CaloTowerDetId> hcalTowersBehindClusters;
0375 bool invalidHcal;
0376 bool pre7DepthHcal;
0377 float sigmaIetaIphi;
0378 float eMax;
0379 float e2nd;
0380 float eTop;
0381 float eLeft;
0382 float eRight;
0383 float eBottom;
0384 float e2x5Top;
0385 float e2x5Left;
0386 float e2x5Right;
0387 float e2x5Bottom;
0388 ShowerShape()
0389 : sigmaEtaEta(std::numeric_limits<float>::max()),
0390 sigmaIetaIeta(std::numeric_limits<float>::max()),
0391 sigmaIphiIphi(std::numeric_limits<float>::max()),
0392 e1x5(0.f),
0393 e2x5Max(0.f),
0394 e5x5(0.f),
0395 r9(-std::numeric_limits<float>::max()),
0396 hcalDepth1OverEcal(0.f),
0397 hcalDepth2OverEcal(0.f),
0398 hcalDepth1OverEcalBc(0.f),
0399 hcalDepth2OverEcalBc(0.f),
0400 hcalOverEcal{{0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f}},
0401 hcalOverEcalBc{{0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f}},
0402 invalidHcal(false),
0403 pre7DepthHcal(true),
0404 sigmaIetaIphi(0.f),
0405 eMax(0.f),
0406 e2nd(0.f),
0407 eTop(0.f),
0408 eLeft(0.f),
0409 eRight(0.f),
0410 eBottom(0.f),
0411 e2x5Top(0.f),
0412 e2x5Left(0.f),
0413 e2x5Right(0.f),
0414 e2x5Bottom(0.f) {}
0415 };
0416
0417
0418 float sigmaEtaEta() const { return showerShape_.sigmaEtaEta; }
0419 float sigmaIetaIeta() const { return showerShape_.sigmaIetaIeta; }
0420 float sigmaIphiIphi() const { return showerShape_.sigmaIphiIphi; }
0421 float e1x5() const { return showerShape_.e1x5; }
0422 float e2x5Max() const { return showerShape_.e2x5Max; }
0423 float e5x5() const { return showerShape_.e5x5; }
0424 float r9() const { return showerShape_.r9; }
0425 float hcalOverEcal(const ShowerShape &ss, int depth) const {
0426 if (ss.pre7DepthHcal) {
0427 if (depth == 0)
0428 return ss.hcalDepth1OverEcal + ss.hcalDepth2OverEcal;
0429 else if (depth == 1)
0430 return ss.hcalDepth1OverEcal;
0431 else if (depth == 2)
0432 return ss.hcalDepth2OverEcal;
0433
0434 return 0.f;
0435 } else {
0436 const auto &hovere = ss.hcalOverEcal;
0437 return (!(depth > 0 and depth < 8)) ? std::accumulate(std::begin(hovere), std::end(hovere), 0.f)
0438 : hovere[depth - 1];
0439 }
0440 }
0441 float hcalOverEcal(int depth = 0) const { return hcalOverEcal(showerShape_, depth); }
0442 float hcalOverEcalBc(const ShowerShape &ss, int depth) const {
0443 if (ss.pre7DepthHcal) {
0444 if (depth == 0)
0445 return ss.hcalDepth1OverEcalBc + ss.hcalDepth2OverEcalBc;
0446 else if (depth == 1)
0447 return ss.hcalDepth1OverEcalBc;
0448 else if (depth == 2)
0449 return ss.hcalDepth2OverEcalBc;
0450
0451 return 0.f;
0452 } else {
0453 const auto &hovere = ss.hcalOverEcalBc;
0454 return (!(depth > 0 and depth < 8)) ? std::accumulate(std::begin(hovere), std::end(hovere), 0.f)
0455 : hovere[depth - 1];
0456 }
0457 }
0458 float hcalOverEcalBc(int depth = 0) const { return hcalOverEcalBc(showerShape_, depth); }
0459 const std::vector<CaloTowerDetId> &hcalTowersBehindClusters() const {
0460 return showerShape_.hcalTowersBehindClusters;
0461 }
0462 bool hcalOverEcalValid() const { return !showerShape_.invalidHcal; }
0463 float eLeft() const { return showerShape_.eLeft; }
0464 float eRight() const { return showerShape_.eRight; }
0465 float eTop() const { return showerShape_.eTop; }
0466 float eBottom() const { return showerShape_.eBottom; }
0467 const ShowerShape &showerShape() const { return showerShape_; }
0468
0469
0470 float full5x5_sigmaEtaEta() const { return full5x5_showerShape_.sigmaEtaEta; }
0471 float full5x5_sigmaIetaIeta() const { return full5x5_showerShape_.sigmaIetaIeta; }
0472 float full5x5_sigmaIphiIphi() const { return full5x5_showerShape_.sigmaIphiIphi; }
0473 float full5x5_e1x5() const { return full5x5_showerShape_.e1x5; }
0474 float full5x5_e2x5Max() const { return full5x5_showerShape_.e2x5Max; }
0475 float full5x5_e5x5() const { return full5x5_showerShape_.e5x5; }
0476 float full5x5_r9() const { return full5x5_showerShape_.r9; }
0477 float full5x5_hcalOverEcal(int depth = 0) const { return hcalOverEcal(full5x5_showerShape_, depth); }
0478 float full5x5_hcalOverEcalBc(int depth = 0) const { return hcalOverEcalBc(full5x5_showerShape_, depth); }
0479 bool full5x5_hcalOverEcalValid() const { return !full5x5_showerShape_.invalidHcal; }
0480 float full5x5_e2x5Left() const { return full5x5_showerShape_.e2x5Left; }
0481 float full5x5_e2x5Right() const { return full5x5_showerShape_.e2x5Right; }
0482 float full5x5_e2x5Top() const { return full5x5_showerShape_.e2x5Top; }
0483 float full5x5_e2x5Bottom() const { return full5x5_showerShape_.e2x5Bottom; }
0484 float full5x5_eLeft() const { return full5x5_showerShape_.eLeft; }
0485 float full5x5_eRight() const { return full5x5_showerShape_.eRight; }
0486 float full5x5_eTop() const { return full5x5_showerShape_.eTop; }
0487 float full5x5_eBottom() const { return full5x5_showerShape_.eBottom; }
0488 const ShowerShape &full5x5_showerShape() const { return full5x5_showerShape_; }
0489
0490
0491 void setShowerShape(const ShowerShape &s) { showerShape_ = s; }
0492 void full5x5_setShowerShape(const ShowerShape &s) { full5x5_showerShape_ = s; }
0493
0494
0495 float scSigmaEtaEta() const { return sigmaEtaEta(); }
0496 float scSigmaIEtaIEta() const { return sigmaIetaIeta(); }
0497 float scE1x5() const { return e1x5(); }
0498 float scE2x5Max() const { return e2x5Max(); }
0499 float scE5x5() const { return e5x5(); }
0500 float hadronicOverEm() const { return hcalOverEcal(); }
0501
0502 private:
0503
0504 ShowerShape showerShape_;
0505 ShowerShape full5x5_showerShape_;
0506
0507
0508
0509
0510
0511 public:
0512 struct SaturationInfo {
0513 int nSaturatedXtals;
0514 bool isSeedSaturated;
0515 SaturationInfo() : nSaturatedXtals(0), isSeedSaturated(false) {}
0516 };
0517
0518
0519 float nSaturatedXtals() const { return saturationInfo_.nSaturatedXtals; }
0520 float isSeedSaturated() const { return saturationInfo_.isSeedSaturated; }
0521 const SaturationInfo &saturationInfo() const { return saturationInfo_; }
0522 void setSaturationInfo(const SaturationInfo &s) { saturationInfo_ = s; }
0523
0524 private:
0525 SaturationInfo saturationInfo_;
0526
0527
0528
0529
0530
0531 public:
0532 struct IsolationVariables {
0533 float tkSumPt;
0534 float tkSumPtHEEP;
0535 float ecalRecHitSumEt;
0536 float hcalDepth1TowerSumEt;
0537 float hcalDepth2TowerSumEt;
0538 float hcalDepth1TowerSumEtBc;
0539 float hcalDepth2TowerSumEtBc;
0540 std::array<float, 7> hcalRecHitSumEt;
0541 std::array<float, 7> hcalRecHitSumEtBc;
0542 bool pre7DepthHcal;
0543 IsolationVariables()
0544 : tkSumPt(0.),
0545 tkSumPtHEEP(0.),
0546 ecalRecHitSumEt(0.),
0547 hcalDepth1TowerSumEt(0.f),
0548 hcalDepth2TowerSumEt(0.f),
0549 hcalDepth1TowerSumEtBc(0.f),
0550 hcalDepth2TowerSumEtBc(0.f),
0551 hcalRecHitSumEt{{0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f}},
0552 hcalRecHitSumEtBc{{0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f}},
0553 pre7DepthHcal(true) {}
0554 };
0555
0556
0557 float dr03TkSumPt() const { return dr03_.tkSumPt; }
0558 float dr03TkSumPtHEEP() const { return dr03_.tkSumPtHEEP; }
0559 float dr03EcalRecHitSumEt() const { return dr03_.ecalRecHitSumEt; }
0560 float hcalTowerSumEt(const IsolationVariables &iv, int depth) const {
0561 if (iv.pre7DepthHcal) {
0562 if (depth == 0)
0563 return iv.hcalDepth1TowerSumEt + iv.hcalDepth2TowerSumEt;
0564 else if (depth == 1)
0565 return iv.hcalDepth1TowerSumEt;
0566 else if (depth == 2)
0567 return iv.hcalDepth2TowerSumEt;
0568
0569 return 0.f;
0570 } else {
0571 const auto &hcaliso = iv.hcalRecHitSumEt;
0572 return (!(depth > 0 and depth < 8)) ? std::accumulate(std::begin(hcaliso), std::end(hcaliso), 0.f)
0573 : hcaliso[depth - 1];
0574 }
0575 }
0576 float dr03HcalTowerSumEt(int depth = 0) const { return hcalTowerSumEt(dr03_, depth); }
0577 float hcalTowerSumEtBc(const IsolationVariables &iv, int depth) const {
0578 if (iv.pre7DepthHcal) {
0579 if (depth == 0)
0580 return iv.hcalDepth1TowerSumEtBc + iv.hcalDepth2TowerSumEtBc;
0581 else if (depth == 1)
0582 return iv.hcalDepth1TowerSumEtBc;
0583 else if (depth == 2)
0584 return iv.hcalDepth2TowerSumEtBc;
0585
0586 return 0.f;
0587 } else {
0588 const auto &hcaliso = iv.hcalRecHitSumEtBc;
0589 return (!(depth > 0 and depth < 8)) ? std::accumulate(std::begin(hcaliso), std::end(hcaliso), 0.f)
0590 : hcaliso[depth - 1];
0591 }
0592 }
0593 float dr03HcalTowerSumEtBc(int depth = 0) const { return hcalTowerSumEtBc(dr03_, depth); }
0594 const IsolationVariables &dr03IsolationVariables() const { return dr03_; }
0595
0596
0597 float dr04TkSumPt() const { return dr04_.tkSumPt; }
0598 float dr04TkSumPtHEEP() const { return dr04_.tkSumPtHEEP; }
0599 float dr04EcalRecHitSumEt() const { return dr04_.ecalRecHitSumEt; }
0600 float dr04HcalTowerSumEt(int depth = 0) const { return hcalTowerSumEt(dr04_, depth); }
0601 float dr04HcalTowerSumEtBc(int depth = 0) const { return hcalTowerSumEtBc(dr04_, depth); }
0602 const IsolationVariables &dr04IsolationVariables() const { return dr04_; }
0603
0604
0605 void setDr03Isolation(const IsolationVariables &dr03) { dr03_ = dr03; }
0606 void setDr04Isolation(const IsolationVariables &dr04) { dr04_ = dr04; }
0607
0608
0609 void setIsolation03(const IsolationVariables &dr03) { dr03_ = dr03; }
0610 void setIsolation04(const IsolationVariables &dr04) { dr04_ = dr04; }
0611 const IsolationVariables &isolationVariables03() const { return dr03_; }
0612 const IsolationVariables &isolationVariables04() const { return dr04_; }
0613
0614
0615 void hcalToRun2EffDepth();
0616
0617 private:
0618
0619 IsolationVariables dr03_;
0620 IsolationVariables dr04_;
0621
0622
0623
0624
0625
0626 public:
0627 struct ConversionRejection {
0628 int flags;
0629 TrackBaseRef partner;
0630 float dist;
0631 float dcot;
0632 float radius;
0633 float vtxFitProb;
0634 ConversionRejection()
0635 : flags(-1),
0636 dist(std::numeric_limits<float>::max()),
0637 dcot(std::numeric_limits<float>::max()),
0638 radius(std::numeric_limits<float>::max()),
0639 vtxFitProb(std::numeric_limits<float>::max()) {}
0640 };
0641
0642
0643 int convFlags() const { return conversionRejection_.flags; }
0644 TrackBaseRef convPartner() const { return conversionRejection_.partner; }
0645 float convDist() const { return conversionRejection_.dist; }
0646 float convDcot() const { return conversionRejection_.dcot; }
0647 float convRadius() const { return conversionRejection_.radius; }
0648 float convVtxFitProb() const { return conversionRejection_.vtxFitProb; }
0649 const ConversionRejection &conversionRejectionVariables() const { return conversionRejection_; }
0650 void setConversionRejectionVariables(const ConversionRejection &convRej) { conversionRejection_ = convRej; }
0651
0652 private:
0653
0654 ConversionRejection conversionRejection_;
0655
0656
0657
0658
0659
0660 public:
0661 struct PflowIsolationVariables {
0662
0663 float sumChargedHadronPt;
0664 float sumNeutralHadronEt;
0665 float sumPhotonEt;
0666
0667 float sumChargedParticlePt;
0668 float sumNeutralHadronEtHighThreshold;
0669 float sumPhotonEtHighThreshold;
0670 float sumPUPt;
0671
0672 float sumEcalClusterEt;
0673 float sumHcalClusterEt;
0674 PflowIsolationVariables()
0675 : sumChargedHadronPt(0),
0676 sumNeutralHadronEt(0),
0677 sumPhotonEt(0),
0678 sumChargedParticlePt(0),
0679 sumNeutralHadronEtHighThreshold(0),
0680 sumPhotonEtHighThreshold(0),
0681 sumPUPt(0),
0682 sumEcalClusterEt(0),
0683 sumHcalClusterEt(0) {}
0684 };
0685
0686 struct MvaInput {
0687 int earlyBrem;
0688 int lateBrem;
0689 float sigmaEtaEta;
0690 float hadEnergy;
0691 float deltaEta;
0692 int nClusterOutsideMustache;
0693 float etOutsideMustache;
0694 MvaInput()
0695 : earlyBrem(-2),
0696 lateBrem(-2),
0697 sigmaEtaEta(std::numeric_limits<float>::max()),
0698 hadEnergy(0.),
0699 deltaEta(std::numeric_limits<float>::max()),
0700 nClusterOutsideMustache(-2),
0701 etOutsideMustache(-std::numeric_limits<float>::max()) {}
0702 };
0703
0704 static constexpr float mvaPlaceholder = -999999999.;
0705
0706 struct MvaOutput {
0707 int status;
0708 float mva_Isolated;
0709 float mva_e_pi;
0710 float mvaByPassForIsolated;
0711 float dnn_e_sigIsolated;
0712 float dnn_e_sigNonIsolated;
0713 float dnn_e_bkgNonIsolated;
0714 float dnn_e_bkgTau;
0715 float dnn_e_bkgPhoton;
0716 MvaOutput()
0717 : status(-1),
0718 mva_Isolated(mvaPlaceholder),
0719 mva_e_pi(mvaPlaceholder),
0720 mvaByPassForIsolated(mvaPlaceholder),
0721 dnn_e_sigIsolated(mvaPlaceholder),
0722 dnn_e_sigNonIsolated(mvaPlaceholder),
0723 dnn_e_bkgNonIsolated(mvaPlaceholder),
0724 dnn_e_bkgTau(mvaPlaceholder),
0725 dnn_e_bkgPhoton(mvaPlaceholder) {}
0726 };
0727
0728
0729 const PflowIsolationVariables &pfIsolationVariables() const { return pfIso_; }
0730
0731 float ecalPFClusterIso() const { return pfIso_.sumEcalClusterEt; };
0732 float hcalPFClusterIso() const { return pfIso_.sumHcalClusterEt; };
0733
0734 const MvaInput &mvaInput() const { return mvaInput_; }
0735 const MvaOutput &mvaOutput() const { return mvaOutput_; }
0736
0737
0738 void setPfIsolationVariables(const PflowIsolationVariables &iso) { pfIso_ = iso; }
0739 void setMvaInput(const MvaInput &mi) { mvaInput_ = mi; }
0740 void setMvaOutput(const MvaOutput &mo) { mvaOutput_ = mo; }
0741
0742
0743 float mva_Isolated() const { return mvaOutput_.mva_Isolated; }
0744 float mva_e_pi() const { return mvaOutput_.mva_e_pi; }
0745 float dnn_signal_Isolated() const { return mvaOutput_.dnn_e_sigIsolated; }
0746 float dnn_signal_nonIsolated() const { return mvaOutput_.dnn_e_sigNonIsolated; }
0747 float dnn_bkg_nonIsolated() const { return mvaOutput_.dnn_e_bkgNonIsolated; }
0748 float dnn_bkg_Tau() const { return mvaOutput_.dnn_e_bkgTau; }
0749 float dnn_bkg_Photon() const { return mvaOutput_.dnn_e_bkgPhoton; }
0750
0751 private:
0752 PflowIsolationVariables pfIso_;
0753 MvaInput mvaInput_;
0754 MvaOutput mvaOutput_;
0755
0756
0757
0758
0759
0760 public:
0761
0762 bool ecalDriven() const;
0763 bool passingCutBasedPreselection() const { return passCutBasedPreselection_; }
0764 bool passingPflowPreselection() const { return passPflowPreselection_; }
0765 bool ambiguous() const { return ambiguous_; }
0766 GsfTrackRefVector::size_type ambiguousGsfTracksSize() const { return ambiguousGsfTracks_.size(); }
0767 auto const &ambiguousGsfTracks() const { return ambiguousGsfTracks_; }
0768
0769
0770 void setPassCutBasedPreselection(bool flag) { passCutBasedPreselection_ = flag; }
0771 void setPassPflowPreselection(bool flag) { passPflowPreselection_ = flag; }
0772 void setAmbiguous(bool flag) { ambiguous_ = flag; }
0773 void clearAmbiguousGsfTracks() { ambiguousGsfTracks_.clear(); }
0774 void addAmbiguousGsfTrack(const reco::GsfTrackRef &t) { ambiguousGsfTracks_.push_back(t); }
0775
0776
0777 void setPassMvaPreselection(bool flag) { passMvaPreslection_ = flag; }
0778 bool passingMvaPreselection() const { return passMvaPreslection_; }
0779
0780 private:
0781
0782 bool passCutBasedPreselection_;
0783 bool passPflowPreselection_;
0784 bool passMvaPreslection_;
0785 bool ambiguous_;
0786 GsfTrackRefVector ambiguousGsfTracks_;
0787
0788
0789
0790
0791
0792 public:
0793 struct ClassificationVariables {
0794 float trackFbrem;
0795 float superClusterFbrem;
0796 constexpr static float kDefaultValue = -1.e30;
0797 ClassificationVariables() : trackFbrem(kDefaultValue), superClusterFbrem(kDefaultValue) {}
0798 };
0799 enum Classification { UNKNOWN = -1, GOLDEN = 0, BIGBREM = 1, BADTRACK = 2, SHOWERING = 3, GAP = 4 };
0800
0801
0802 float trackFbrem() const { return classVariables_.trackFbrem; }
0803 float superClusterFbrem() const { return classVariables_.superClusterFbrem; }
0804 const ClassificationVariables &classificationVariables() const { return classVariables_; }
0805 Classification classification() const { return class_; }
0806
0807
0808 int numberOfBrems() const { return basicClustersSize() - 1; }
0809 float fbrem() const { return trackFbrem(); }
0810
0811
0812 void setTrackFbrem(float fbrem) { classVariables_.trackFbrem = fbrem; }
0813 void setSuperClusterFbrem(float fbrem) { classVariables_.superClusterFbrem = fbrem; }
0814 void setClassificationVariables(const ClassificationVariables &cv) { classVariables_ = cv; }
0815 void setClassification(Classification myclass) { class_ = myclass; }
0816
0817 private:
0818
0819 ClassificationVariables classVariables_;
0820 Classification class_;
0821
0822
0823
0824
0825
0826
0827
0828
0829
0830
0831
0832
0833
0834
0835
0836
0837
0838
0839
0840
0841
0842
0843 public:
0844 enum P4Kind { P4_UNKNOWN = -1, P4_FROM_SUPER_CLUSTER = 0, P4_COMBINATION = 1, P4_PFLOW_COMBINATION = 2 };
0845
0846 struct Corrections {
0847 bool isEcalEnergyCorrected;
0848 float correctedEcalEnergy;
0849 float correctedEcalEnergyError;
0850
0851 float trackMomentumError;
0852
0853 LorentzVector fromSuperClusterP4;
0854 float fromSuperClusterP4Error;
0855 LorentzVector combinedP4;
0856 float combinedP4Error;
0857 LorentzVector pflowP4;
0858 float pflowP4Error;
0859 P4Kind candidateP4Kind;
0860
0861 Corrections()
0862 : isEcalEnergyCorrected(false),
0863 correctedEcalEnergy(0.),
0864 correctedEcalEnergyError(999.),
0865 trackMomentumError(999.),
0866 fromSuperClusterP4Error(999.),
0867 combinedP4Error(999.),
0868 pflowP4Error(999.),
0869 candidateP4Kind(P4_UNKNOWN) {}
0870 };
0871
0872
0873 void setCorrectedEcalEnergyError(float newEnergyError);
0874 void setCorrectedEcalEnergy(float newEnergy);
0875 void setCorrectedEcalEnergy(float newEnergy, bool rescaleDependentValues);
0876 void setTrackMomentumError(float trackMomentumError);
0877 void setP4(P4Kind kind, const LorentzVector &p4, float p4Error, bool setCandidate);
0878 using RecoCandidate::setP4;
0879
0880
0881 bool isEcalEnergyCorrected() const { return corrections_.isEcalEnergyCorrected; }
0882 float correctedEcalEnergy() const { return corrections_.correctedEcalEnergy; }
0883 float correctedEcalEnergyError() const { return corrections_.correctedEcalEnergyError; }
0884 float trackMomentumError() const { return corrections_.trackMomentumError; }
0885 const LorentzVector &p4(P4Kind kind) const;
0886 using RecoCandidate::p4;
0887 float p4Error(P4Kind kind) const;
0888 P4Kind candidateP4Kind() const { return corrections_.candidateP4Kind; }
0889 const Corrections &corrections() const { return corrections_; }
0890
0891
0892 void setCorrections(const Corrections &c) { corrections_ = c; }
0893
0894
0895 void setEcalEnergyError(float energyError) { setCorrectedEcalEnergyError(energyError); }
0896 float ecalEnergy() const { return correctedEcalEnergy(); }
0897 float ecalEnergyError() const { return correctedEcalEnergyError(); }
0898
0899 float caloEnergy() const { return correctedEcalEnergy(); }
0900 bool isEnergyScaleCorrected() const { return isEcalEnergyCorrected(); }
0901 void correctEcalEnergy(float newEnergy, float newEnergyError, bool corrEovP = true) {
0902 setCorrectedEcalEnergy(newEnergy, corrEovP);
0903 setEcalEnergyError(newEnergyError);
0904 }
0905 void correctMomentum(const LorentzVector &p4, float trackMomentumError, float p4Error) {
0906 setTrackMomentumError(trackMomentumError);
0907 setP4(P4_COMBINATION, p4, p4Error, true);
0908 }
0909
0910 private:
0911
0912 Corrections corrections_;
0913
0914 public:
0915 struct PixelMatchVariables {
0916
0917 float dPhi1;
0918
0919 float dPhi2;
0920
0921 float dRz1;
0922
0923 float dRz2;
0924
0925 unsigned char subdetectors;
0926 PixelMatchVariables() : dPhi1(-999), dPhi2(-999), dRz1(-999), dRz2(-999), subdetectors(0) {}
0927 ~PixelMatchVariables() {}
0928 };
0929 void setPixelMatchSubdetectors(int sd1, int sd2) { pixelMatchVariables_.subdetectors = 10 * sd1 + sd2; }
0930 void setPixelMatchDPhi1(float dPhi1) { pixelMatchVariables_.dPhi1 = dPhi1; }
0931 void setPixelMatchDPhi2(float dPhi2) { pixelMatchVariables_.dPhi2 = dPhi2; }
0932 void setPixelMatchDRz1(float dRz1) { pixelMatchVariables_.dRz1 = dRz1; }
0933 void setPixelMatchDRz2(float dRz2) { pixelMatchVariables_.dRz2 = dRz2; }
0934
0935 int pixelMatchSubdetector1() const { return pixelMatchVariables_.subdetectors / 10; }
0936 int pixelMatchSubdetector2() const { return pixelMatchVariables_.subdetectors % 10; }
0937 float pixelMatchDPhi1() const { return pixelMatchVariables_.dPhi1; }
0938 float pixelMatchDPhi2() const { return pixelMatchVariables_.dPhi2; }
0939 float pixelMatchDRz1() const { return pixelMatchVariables_.dRz1; }
0940 float pixelMatchDRz2() const { return pixelMatchVariables_.dRz2; }
0941
0942 private:
0943 PixelMatchVariables pixelMatchVariables_;
0944 };
0945
0946 }
0947
0948 #endif