26 float trk_nhits_ = -1.;
27 float trk_high_quality_ = -1.;
28 float trk_chi2red_ = -1.;
30 float ktf_ecal_cluster_e_ = -1.;
31 float ktf_ecal_cluster_deta_ = -42.;
32 float ktf_ecal_cluster_dphi_ = -42.;
33 float ktf_ecal_cluster_e3x3_ = -1.;
34 float ktf_ecal_cluster_e5x5_ = -1.;
35 float ktf_ecal_cluster_covEtaEta_ = -42.;
36 float ktf_ecal_cluster_covEtaPhi_ = -42.;
37 float ktf_ecal_cluster_covPhiPhi_ = -42.;
38 float ktf_ecal_cluster_r9_ = -0.1;
39 float ktf_ecal_cluster_circularity_ = -0.1;
40 float ktf_hcal_cluster_e_ = -1.;
41 float ktf_hcal_cluster_deta_ = -42.;
42 float ktf_hcal_cluster_dphi_ = -42.;
43 float preid_gsf_dpt_ = -1.;
44 float preid_trk_gsf_chiratio_ = -1.;
45 float preid_gsf_chi2red_ = -1.;
46 float trk_dxy_sig_ = -1.;
49 const auto& trk =
ecal.trackRef();
50 if (trk.isNonnull()) {
52 trk_eta_ = trk->eta();
53 trk_phi_ = trk->phi();
55 trk_nhits_ =
static_cast<float>(trk->found());
57 trk_chi2red_ = trk->normalizedChi2();
58 if (trk->dxy(spot) > 0.) {
59 trk_dxy_sig_ = trk->dxyError() / trk->dxy(spot);
61 ktf_ecal_cluster_dphi_ *= trk->charge();
65 rho_ =
static_cast<float>(rho);
68 const auto& ecal_clu =
ecal.clusterRef();
69 if (ecal_clu.isNonnull()) {
70 ktf_ecal_cluster_e_ = ecal_clu->energy();
71 ktf_ecal_cluster_deta_ =
ecal.geomMatching()[0];
72 ktf_ecal_cluster_dphi_ =
ecal.geomMatching()[1];
73 ktf_ecal_cluster_e3x3_ =
tools.e3x3(*ecal_clu);
74 ktf_ecal_cluster_e5x5_ =
tools.e5x5(*ecal_clu);
75 const auto& covs =
tools.localCovariances(*ecal_clu);
76 ktf_ecal_cluster_covEtaEta_ = covs[0];
77 ktf_ecal_cluster_covEtaPhi_ = covs[1];
78 ktf_ecal_cluster_covPhiPhi_ = covs[2];
79 if (ktf_ecal_cluster_e_ > 0.) {
80 ktf_ecal_cluster_r9_ = ktf_ecal_cluster_e3x3_ / ktf_ecal_cluster_e_;
82 if (ktf_ecal_cluster_e5x5_ > 0.) {
83 ktf_ecal_cluster_circularity_ = 1. -
tools.e1x5(*ecal_clu) / ktf_ecal_cluster_e5x5_;
85 ktf_ecal_cluster_circularity_ = -0.1;
90 const auto& hcal_clu =
hcal.clusterRef();
91 if (hcal_clu.isNonnull()) {
92 ktf_hcal_cluster_e_ = hcal_clu->energy();
93 ktf_hcal_cluster_deta_ =
hcal.geomMatching()[0];
94 ktf_hcal_cluster_dphi_ =
hcal.geomMatching()[1];
98 preid_gsf_dpt_ =
ecal.dpt();
99 preid_trk_gsf_chiratio_ =
ecal.chi2Ratio();
100 preid_gsf_chi2red_ =
ecal.gsfChi2();
103 std::vector<float>
output = {trk_pt_,
112 ktf_ecal_cluster_deta_,
113 ktf_ecal_cluster_dphi_,
114 ktf_ecal_cluster_e3x3_,
115 ktf_ecal_cluster_e5x5_,
116 ktf_ecal_cluster_covEtaEta_,
117 ktf_ecal_cluster_covEtaPhi_,
118 ktf_ecal_cluster_covPhiPhi_,
119 ktf_ecal_cluster_r9_,
120 ktf_ecal_cluster_circularity_,
122 ktf_hcal_cluster_deta_,
123 ktf_hcal_cluster_dphi_,
125 preid_trk_gsf_chiratio_,
137 float eid_rho = -999.;
138 float eid_sc_eta = -999.;
139 float eid_shape_full5x5_r9 = -999.;
140 float eid_sc_etaWidth = -999.;
141 float eid_sc_phiWidth = -999.;
142 float eid_shape_full5x5_HoverE = -999.;
143 float eid_trk_nhits = -999.;
144 float eid_trk_chi2red = -999.;
145 float eid_gsf_chi2red = -999.;
146 float eid_brem_frac = -999.;
147 float eid_gsf_nhits = -999.;
148 float eid_match_SC_EoverP = -999.;
149 float eid_match_eclu_EoverP = -999.;
150 float eid_match_SC_dEta = -999.;
151 float eid_match_SC_dPhi = -999.;
152 float eid_match_seed_dEta = -999.;
153 float eid_sc_E = -999.;
154 float eid_trk_p = -999.;
155 float gsf_mode_p = -999.;
156 float core_shFracHits = -999.;
157 float gsf_bdtout1 = -999.;
158 float gsf_dr = -999.;
159 float trk_dr = -999.;
160 float sc_Nclus = -999.;
161 float sc_clus1_nxtal = -999.;
162 float sc_clus1_dphi = -999.;
163 float sc_clus2_dphi = -999.;
164 float sc_clus1_deta = -999.;
165 float sc_clus2_deta = -999.;
166 float sc_clus1_E = -999.;
167 float sc_clus2_E = -999.;
168 float sc_clus1_E_ov_p = -999.;
169 float sc_clus2_E_ov_p = -999.;
175 eid_trk_nhits = tk->
found();
183 if (
gsf.isNonnull()) {
184 gsf_mode_p =
gsf->pMode();
185 eid_gsf_nhits = (
float)
gsf->found();
186 eid_gsf_chi2red =
gsf->normalizedChi2();
187 TVector3 gsfTV3(0, 0, 0);
188 gsfTV3.SetPtEtaPhi(
gsf->ptMode(),
gsf->etaMode(),
gsf->phiMode());
189 TVector3 eleTV3(0, 0, 0);
190 eleTV3.SetPtEtaPhi(ele.
pt(), ele.
eta(), ele.
phi());
191 gsf_dr = eleTV3.DeltaR(gsfTV3);
199 eid_sc_E = sc->energy();
200 eid_sc_eta = sc->eta();
201 eid_sc_etaWidth = sc->etaWidth();
202 eid_sc_phiWidth = sc->phiWidth();
203 sc_Nclus = sc->clustersSize();
209 eid_match_eclu_EoverP = (1. / ele.
ecalEnergy()) - (1. / ele.
p());
221 eid_brem_frac = ele.
fbrem();
230 if (
gsf.isNonnull()) {
234 double mass2 = 0.000511 * 0.000511;
246 sc_clus1_nxtal = -999;
247 sc_clus1_dphi = -999.;
248 sc_clus2_dphi = -999.;
249 sc_clus1_deta = -999.;
250 sc_clus2_deta = -999.;
253 sc_clus1_E_ov_p = -999.;
254 sc_clus2_E_ov_p = -999.;
268 sc_clus1_nxtal = (
int)sc_clus1_nxtal;
275 eid_rho = std::clamp(eid_rho, 0.
f, 100.
f);
276 eid_sc_eta = std::clamp(eid_sc_eta, -5.
f, 5.
f);
277 eid_shape_full5x5_r9 = std::clamp(eid_shape_full5x5_r9, 0.
f, 2.
f);
278 eid_sc_etaWidth = std::clamp(eid_sc_etaWidth, 0.
f, 3.14
f);
279 eid_sc_phiWidth = std::clamp(eid_sc_phiWidth, 0.
f, 3.14
f);
280 eid_shape_full5x5_HoverE = std::clamp(eid_shape_full5x5_HoverE, 0.
f, 50.
f);
281 eid_trk_nhits = std::clamp(eid_trk_nhits, -1.
f, 50.
f);
282 eid_trk_chi2red = std::clamp(eid_trk_chi2red, -1.
f, 50.
f);
283 eid_gsf_chi2red = std::clamp(eid_gsf_chi2red, -1.
f, 100.
f);
284 if (eid_brem_frac < 0.)
286 if (eid_brem_frac > 1.)
288 eid_gsf_nhits = std::clamp(eid_gsf_nhits, -1.
f, 50.
f);
289 eid_match_SC_EoverP = std::clamp(eid_match_SC_EoverP, 0.
f, 100.
f);
290 eid_match_eclu_EoverP = std::clamp(eid_match_eclu_EoverP, -1.
f, 1.
f);
291 eid_match_SC_dEta = std::clamp(eid_match_SC_dEta, -10.
f, 10.
f);
292 eid_match_SC_dPhi = std::clamp(eid_match_SC_dPhi, -3.14
f, 3.14
f);
293 eid_match_seed_dEta = std::clamp(eid_match_seed_dEta, -10.
f, 10.
f);
294 eid_sc_E = std::clamp(eid_sc_E, 0.
f, 1000.
f);
295 eid_trk_p = std::clamp(eid_trk_p, -1.
f, 1000.
f);
296 gsf_mode_p = std::clamp(gsf_mode_p, 0.
f, 1000.
f);
297 core_shFracHits = std::clamp(core_shFracHits, 0.
f, 1.
f);
298 gsf_bdtout1 = std::clamp(gsf_bdtout1, -20.
f, 20.
f);
307 sc_Nclus = std::clamp(sc_Nclus, 0.
f, 20.
f);
308 sc_clus1_nxtal = std::clamp(sc_clus1_nxtal, 0.
f, 100.
f);
309 sc_clus1_dphi = std::clamp(sc_clus1_dphi, -3.14
f, 3.14
f);
310 sc_clus2_dphi = std::clamp(sc_clus2_dphi, -3.14
f, 3.14
f);
311 sc_clus1_deta = std::clamp(sc_clus1_deta, -5.
f, 5.
f);
312 sc_clus2_deta = std::clamp(sc_clus2_deta, -5.
f, 5.
f);
313 sc_clus1_E = std::clamp(sc_clus1_E, 0.
f, 1000.
f);
314 sc_clus2_E = std::clamp(sc_clus2_E, 0.
f, 1000.
f);
315 if (sc_clus1_E_ov_p < 0.)
316 sc_clus1_E_ov_p = -1.;
317 if (sc_clus2_E_ov_p < 0.)
318 sc_clus2_E_ov_p = -1.;
321 std::vector<float>
output = {eid_rho,
323 eid_shape_full5x5_r9,
326 eid_shape_full5x5_HoverE,
333 eid_match_eclu_EoverP,
360 float eid_rho = -999.;
361 float eid_sc_eta = -999.;
362 float eid_shape_full5x5_r9 = -999.;
363 float eid_sc_etaWidth = -999.;
364 float eid_sc_phiWidth = -999.;
365 float eid_shape_full5x5_HoverE = -999.;
366 float eid_trk_nhits = -999.;
367 float eid_trk_chi2red = -999.;
368 float eid_gsf_chi2red = -999.;
369 float eid_brem_frac = -999.;
370 float eid_gsf_nhits = -999.;
371 float eid_match_SC_EoverP = -999.;
372 float eid_match_eclu_EoverP = -999.;
373 float eid_match_SC_dEta = -999.;
374 float eid_match_SC_dPhi = -999.;
375 float eid_match_seed_dEta = -999.;
376 float eid_sc_E = -999.;
377 float eid_trk_p = -999.;
378 float gsf_mode_p = -999.;
379 float core_shFracHits = -999.;
380 float gsf_bdtout1 = -999.;
381 float gsf_dr = -999.;
382 float trk_dr = -999.;
383 float sc_Nclus = -999.;
384 float sc_clus1_nxtal = -999.;
385 float sc_clus1_dphi = -999.;
386 float sc_clus2_dphi = -999.;
387 float sc_clus1_deta = -999.;
388 float sc_clus2_deta = -999.;
389 float sc_clus1_E = -999.;
390 float sc_clus2_E = -999.;
391 float sc_clus1_E_ov_p = -999.;
392 float sc_clus2_E_ov_p = -999.;
397 if (trk.isNonnull()) {
398 eid_trk_p = (
float)trk->p();
399 eid_trk_nhits = (
float)trk->found();
400 eid_trk_chi2red = (
float)trk->normalizedChi2();
401 TVector3 trkTV3(0, 0, 0);
402 trkTV3.SetPtEtaPhi(trk->pt(), trk->eta(), trk->phi());
403 TVector3 eleTV3(0, 0, 0);
404 eleTV3.SetPtEtaPhi(ele.
pt(), ele.
eta(), ele.
phi());
405 trk_dr = eleTV3.DeltaR(trkTV3);
411 const auto&
gsf = ele.
core()->gsfTrack();
412 if (
gsf.isNonnull()) {
413 gsf_mode_p =
gsf->pMode();
414 eid_gsf_nhits = (
float)
gsf->found();
415 eid_gsf_chi2red =
gsf->normalizedChi2();
416 TVector3 gsfTV3(0, 0, 0);
417 gsfTV3.SetPtEtaPhi(
gsf->ptMode(),
gsf->etaMode(),
gsf->phiMode());
418 TVector3 eleTV3(0, 0, 0);
419 eleTV3.SetPtEtaPhi(ele.
pt(), ele.
eta(), ele.
phi());
420 gsf_dr = eleTV3.DeltaR(gsfTV3);
426 const auto& sc = ele.
core()->superCluster();
427 if (sc.isNonnull()) {
428 eid_sc_E = sc->energy();
429 eid_sc_eta = sc->eta();
430 eid_sc_etaWidth = sc->etaWidth();
431 eid_sc_phiWidth = sc->phiWidth();
432 sc_Nclus = (
float)sc->clustersSize();
438 eid_match_eclu_EoverP = (1. / ele.
ecalEnergy()) - (1. / ele.
p());
450 eid_brem_frac = ele.
fbrem();
458 const auto&
gsf = ele.
core()->gsfTrack();
459 if (
gsf.isNonnull()) {
460 const auto& sc = ele.
core()->superCluster();
461 if (sc.isNonnull()) {
463 double mass2 = 0.000511 * 0.000511;
478 sc_clus1_nxtal = -999.;
479 sc_clus1_dphi = -999.;
480 sc_clus2_dphi = -999.;
481 sc_clus1_deta = -999.;
482 sc_clus2_deta = -999.;
485 sc_clus1_E_ov_p = -999.;
486 sc_clus2_E_ov_p = -999.;
506 eid_sc_eta = std::clamp(eid_sc_eta, -5.
f, 5.
f);
507 eid_shape_full5x5_r9 = std::clamp(eid_shape_full5x5_r9, 0.
f, 2.
f);
508 eid_sc_etaWidth = std::clamp(eid_sc_etaWidth, 0.
f, 3.14
f);
509 eid_sc_phiWidth = std::clamp(eid_sc_phiWidth, 0.
f, 3.14
f);
510 eid_shape_full5x5_HoverE = std::clamp(eid_shape_full5x5_HoverE, 0.
f, 50.
f);
511 eid_trk_nhits = std::clamp(eid_trk_nhits, -1.
f, 50.
f);
512 eid_trk_chi2red = std::clamp(eid_trk_chi2red, -1.
f, 50.
f);
513 eid_gsf_chi2red = std::clamp(eid_gsf_chi2red, -1.
f, 100.
f);
514 if (eid_brem_frac < 0.)
516 if (eid_brem_frac > 1.)
518 eid_gsf_nhits = std::clamp(eid_gsf_nhits, -1.
f, 50.
f);
519 eid_match_SC_EoverP = std::clamp(eid_match_SC_EoverP, 0.
f, 100.
f);
520 eid_match_eclu_EoverP = std::clamp(eid_match_eclu_EoverP, -1.
f, 1.
f);
521 eid_match_SC_dEta = std::clamp(eid_match_SC_dEta, -10.
f, 10.
f);
522 eid_match_SC_dPhi = std::clamp(eid_match_SC_dPhi, -3.14
f, 3.14
f);
523 eid_match_seed_dEta = std::clamp(eid_match_seed_dEta, -10.
f, 10.
f);
524 eid_sc_E = std::clamp(eid_sc_E, 0.
f, 1000.
f);
525 eid_trk_p = std::clamp(eid_trk_p, -1.
f, 1000.
f);
526 gsf_mode_p = std::clamp(gsf_mode_p, 0.
f, 1000.
f);
527 core_shFracHits = std::clamp(core_shFracHits, 0.
f, 1.
f);
528 gsf_bdtout1 = std::clamp(gsf_bdtout1, -20.
f, 20.
f);
537 sc_Nclus = std::clamp(sc_Nclus, 0.
f, 20.
f);
538 sc_clus1_nxtal = std::clamp(sc_clus1_nxtal, 0.
f, 100.
f);
539 if (sc_clus1_dphi < -3.14)
541 if (sc_clus1_dphi > 3.14)
543 if (sc_clus2_dphi < -3.14)
545 if (sc_clus2_dphi > 3.14)
547 sc_clus1_deta = std::clamp(sc_clus1_deta, -5.
f, 5.
f);
548 sc_clus2_deta = std::clamp(sc_clus2_deta, -5.
f, 5.
f);
549 sc_clus1_E = std::clamp(sc_clus1_E, 0.
f, 1000.
f);
550 sc_clus2_E = std::clamp(sc_clus2_E, 0.
f, 1000.
f);
551 if (sc_clus1_E_ov_p < 0.)
552 sc_clus1_E_ov_p = -1.;
553 if (sc_clus2_E_ov_p < 0.)
554 sc_clus2_E_ov_p = -1.;
557 std::vector<float>
output = {eid_rho,
559 eid_shape_full5x5_r9,
562 eid_shape_full5x5_HoverE,
569 eid_match_eclu_EoverP,
598 for (
auto const& cluster : sc.
clusters()) {
599 if (cluster->energy() > maxEne1) {
600 maxEne1 = cluster->energy();
607 for (
auto const& cluster : sc.
clusters()) {
609 if (cluster->energy() > maxEne2) {
610 maxEne2 = cluster->energy();
624 bool const& reach_ECAL,
626 float& sc_clus1_nxtal,
627 float& sc_clus1_dphi,
628 float& sc_clus2_dphi,
629 float& sc_clus1_deta,
630 float& sc_clus2_deta,
633 float& sc_clus1_E_ov_p,
634 float& sc_clus2_E_ov_p) {
646 for (
auto const& cluster : sc.
clusters()) {
647 float deta = ecal_pos.
eta() - cluster->eta();
650 sc_clus1_E = cluster->energy();
652 sc_clus1_E_ov_p = cluster->energy() /
gsf.pMode();
653 sc_clus1_nxtal = (
float)cluster->size();
654 if (reach_ECAL > 0) {
655 sc_clus1_deta = deta;
656 sc_clus1_dphi = dphi;
658 }
else if (clusNum ==
i2) {
659 sc_clus2_E = cluster->energy();
661 sc_clus2_E_ov_p = cluster->energy() /
gsf.pMode();
662 if (reach_ECAL > 0) {
663 sc_clus2_deta = deta;
664 sc_clus2_dphi = dphi;
constexpr double deltaPhi(double phi1, double phi2)
void findEnergeticClusters(reco::SuperCluster const &, int &, float &, float &, int &, int &)
double pt() const final
transverse momentum
Geom::Phi< T > phi() const
double p() const
momentum vector magnitude
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
bool isNonnull() const
Checks for non-null.
void trackClusterMatching(reco::SuperCluster const &, reco::GsfTrack const &, bool const &, GlobalPoint const &, float &, float &, float &, float &, float &, float &, float &, float &, float &)
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
float eSuperClusterOverP() const
unsigned short found() const
Number of valid hits on track.
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
double p() const final
magnitude of momentum vector
float shFracInnerHits() const
std::vector< float > features(const reco::PreId &ecal, const reco::PreId &hcal, double rho, const reco::BeamSpot &spot, noZS::EcalClusterLazyTools &ecalTools)
RawParticle const & particle() const
The particle being propagated.
std::vector< float > features_V0(reco::GsfElectron const &ele, float rho, float unbiased)
bool propagateToEcalEntrance(bool first=true)
virtual GsfElectronCoreRef core() const
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
float deltaPhiSuperClusterTrackAtVtx() const
std::vector< float > features_V1(reco::GsfElectron const &ele, float rho, float unbiased, float field_z, const reco::Track *trk=nullptr)
static TrackQuality qualityByName(const std::string &name)
float deltaEtaSuperClusterTrackAtVtx() const
int getSuccess() const
Has propagation been performed and was barrel or endcap reached ?
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
const CaloClusterPtrVector & clusters() const
const access to the cluster list itself
virtual TrackRef closestCtfTrackRef() const
float full5x5_hcalOverEcal(int depth=0) const
float deltaEtaSeedClusterTrackAtCalo() const
size_t clustersSize() const
number of BasicCluster constituents
double phi() const final
momentum azimuthal angle
Power< A, B >::type pow(const A &a, const B &b)
SuperClusterRef superCluster() const override
reference to a SuperCluster
math::XYZTLorentzVector XYZTLorentzVector
const XYZTLorentzVector & vertex() const
the vertex fourvector
double eta() const final
momentum pseudorapidity