56 #include "Math/VectorUtil.h"
75 return std::make_unique<goodseedhelpers::HeavyObjectCache>(conf);
188 using namespace reco;
191 : pfTransformer_(nullptr),
193 resMapEtaECAL_(nullptr),
194 resMapPhiECAL_(nullptr),
200 LogInfo(
"GoodSeedProducer") <<
"Electron PreIdentification started ";
203 std::vector<edm::InputTag>
tags = iConfig.
getParameter<vector<InputTag>>(
"TkColList");
204 for (
unsigned int i = 0;
i <
tags.size(); ++
i) {
253 LogDebug(
"GoodSeedProducer") <<
"Seeds for GSF will be produced ";
256 produces<ElectronSeedCollection>(
preidgsf_);
259 LogDebug(
"GoodSeedProducer") <<
"Seeds for CKF will be produced ";
260 produces<TrajectorySeedCollection>(
preidckf_);
264 LogDebug(
"GoodSeedProducer") <<
"PreId debugging information will be produced ";
287 LogDebug(
"GoodSeedProducer") <<
"START event: " <<
iEvent.id().event() <<
" in run " <<
iEvent.id().run();
289 auto output_preid = std::make_unique<ElectronSeedCollection>();
290 auto output_nopre = std::make_unique<TrajectorySeedCollection>();
291 auto output_preidinfo = std::make_unique<PreIdCollection>();
292 auto preIdMap_p = std::make_unique<edm::ValueMap<reco::PreIdRef>>();
295 std::unique_ptr<TrajectoryFitter> fitter;
296 std::unique_ptr<TrajectorySmoother> smoother;
303 smoother.reset(aSmoother->clone());
304 fitter = aFitter->clone();
306 hitCloner = static_cast<TkTransientTrackingRecHitBuilder const*>(theTrackerRecHitBuilder)->cloner();
322 vector<PFCluster const*> basClus;
323 for (
auto const& klus : *theECPfClustCollection.
product()) {
325 basClus.push_back(&klus);
343 LogDebug(
"GoodSeedProducer") <<
"Number of tracks in collection "
344 <<
"tracksContainers_[" << istr <<
"] to be analyzed " << Tk.size();
347 for (
unsigned int i = 0;
i < Tk.size(); ++
i) {
352 bool GoodPreId =
false;
356 auto tketa = tkmom.eta();
358 auto const&
Seed = (*trackRef->seedRef());
359 if (
Seed.nHits() == 0) {
365 int ibin = ipteta * 9;
370 float nchi = Tk[
i].normalizedChi2();
372 int nhitpi = Tk[
i].found();
379 auto pfmass = 0.0005;
380 auto pfoutenergy =
sqrt((pfmass * pfmass) + Tk[
i].outerMomentum().Mag2());
383 Tk[
i].outerMomentum().
x(), Tk[
i].outerMomentum().
y(), Tk[
i].outerMomentum().
z(), pfoutenergy);
391 float toteta = 1000.f;
392 float totphi = 1000.f;
400 if (theOutParticle.getSuccess() != 0) {
401 ElecTrkEcalPos =
GlobalPoint(theOutParticle.particle().vertex().x(),
402 theOutParticle.particle().vertex().y(),
403 theOutParticle.particle().vertex().z());
405 constexpr
float psLim = 2.50746495928f;
406 bool isBelowPS = (ElecTrkEcalPos.
z() * ElecTrkEcalPos.
z()) > (psLim * psLim) * ElecTrkEcalPos.
perp2();
409 unsigned clusCounter = 0;
411 for (
auto aClus : basClus) {
412 float tmp_ep =
float(aClus->correctedEnergy()) * oPTOB;
418 double ecalShowerDepth = PFCluster::getDepthCorrection(aClus->correctedEnergy(), isBelowPS,
false);
419 auto mom = theOutParticle.particle().momentum().Vect();
420 auto meanShower = ElecTrkEcalPos +
GlobalVector(mom.x(), mom.y(), mom.z()).
unit() * ecalShowerDepth;
422 float etarec = meanShower.
eta();
423 float phirec = meanShower.phi();
425 float tmp_phi =
std::abs(aClus->positionREP().phi() - phirec);
434 if (aClus->correctedEnergy() > max_ee) {
435 toteta = aClus->positionREP().eta() - etarec;
438 EE = aClus->correctedEnergy();
439 feta = aClus->positionREP().eta();
440 clusterRef =
PFClusterRef(theECPfClustCollection, clusCounter);
441 meanShowerSaved = meanShower;
448 float trk_ecalDeta_ = fabs(toteta);
449 float trk_ecalDphi_ = fabs(totphi);
456 float chieta = (toteta != 1000.f) ? toteta / ecaletares : toteta;
457 float chiphi = (totphi != 1000.f) ? totphi / ecalphires : totphi;
458 float chichi =
sqrt(chieta * chieta + chiphi * chiphi);
461 float eta_cut =
thr[ibin + 0];
462 float phi_cut =
thr[ibin + 1];
463 float ep_cutmin =
thr[ibin + 2];
465 ((trk_ecalDeta_ < eta_cut) && (trk_ecalDphi_ < phi_cut) && (EP > ep_cutmin) && (nhitpi > 10));
467 bool EcalMatching = GoodMatching;
472 GoodMatching =
false;
474 math::XYZPoint myPoint(ElecTrkEcalPos.
x(), ElecTrkEcalPos.
y(), ElecTrkEcalPos.
z());
476 clusterRef, myPoint, meanShowerSaved,
std::abs(toteta),
std::abs(totphi), chieta, chiphi, chichi, EP);
481 int hit1max =
int(
thr[ibin + 3]);
482 float chiredmin =
thr[ibin + 4];
483 bool GoodKFFiltering = ((nchi > chiredmin) | (nhitpi < hit1max));
487 bool GoodTkId =
false;
489 if ((!GoodMatching) && (GoodKFFiltering) && (GoodRange)) {
500 tmp.push_back(
hit->cloneSH());
501 auto const& theTrack = Tk[
i];
502 GlobalVector gv(theTrack.innerMomentum().x(), theTrack.innerMomentum().y(), theTrack.innerMomentum().z());
503 GlobalPoint gp(theTrack.innerPosition().x(), theTrack.innerPosition().y(), theTrack.innerPosition().z());
508 if (FitTjs.isValid()) {
509 Trajectory&& SmooTjs = smoother->trajectory(FitTjs);
515 dpt = (pt_in > 0) ? fabs(pt_out - pt_in) / pt_in : 0.;
526 float Ytmva = globalCache()->gbr[ipteta]->GetClassifier(
vars);
528 float BDTcut =
thr[ibin + 5];
531 myPreId.
setMVA(GoodTkId, Ytmva);
534 float chiratiocut =
thr[ibin + 6];
535 float gschicut =
thr[ibin + 7];
536 float gsptmin =
thr[ibin + 8];
542 GoodPreId = GoodTkId | GoodMatching;
548 LogDebug(
"GoodSeedProducer") <<
"Track (pt= " << Tk[
i].pt() <<
"GeV/c, eta= " << Tk[
i].eta()
549 <<
") preidentified for agreement between track and ECAL cluster";
550 if (GoodPreId && (!GoodMatching))
551 LogDebug(
"GoodSeedProducer") <<
"Track (pt= " << Tk[
i].pt() <<
"GeV/c, eta= " << Tk[
i].eta()
552 <<
") preidentified only for track properties";
561 output_preid->push_back(NewSeed);
564 output_nopre->push_back(
Seed);
569 refMap_[trackRef] = output_preidinfo->size();
570 output_preidinfo->push_back(myPreId);
611 for (UInt_t
j = 0;
j <
gbr.size(); ++
j) {
635 ifstream ifs(parFile.fullPath().c_str());
636 for (
int iy = 0; iy < 81; ++iy)
646 if (fabs(
eta) < 1.479)
659 int iep = ie * 3 + ip;
660 LogDebug(
"GoodSeedProducer") <<
"Track pt =" <<
pt <<
" eta=" <<
eta <<
" bin=" << iep;
667 std::vector<reco::PreIdRef>
values;
670 for (
unsigned itrack = 0; itrack <
ntracks; ++itrack) {
672 std::map<reco::TrackRef, unsigned>::const_iterator itcheck =
refMap_.find(theTrackRef);
673 if (itcheck ==
refMap_.end()) {
678 values.push_back(preIdRef);