56 #include "Math/VectorUtil.h"
75 return std::make_unique<goodseedhelpers::HeavyObjectCache>(conf);
182 using namespace reco;
185 : pfTransformer_(nullptr), conf_(iConfig), resMapEtaECAL_(nullptr), resMapPhiECAL_(nullptr) {
186 LogInfo(
"GoodSeedProducer") <<
"Electron PreIdentification started ";
189 std::vector<edm::InputTag>
tags = iConfig.
getParameter<vector<InputTag>>(
"TkColList");
190 for (
unsigned int i = 0;
i <
tags.size(); ++
i) {
239 LogDebug(
"GoodSeedProducer") <<
"Seeds for GSF will be produced ";
242 produces<ElectronSeedCollection>(
preidgsf_);
245 LogDebug(
"GoodSeedProducer") <<
"Seeds for CKF will be produced ";
246 produces<TrajectorySeedCollection>(
preidckf_);
250 LogDebug(
"GoodSeedProducer") <<
"PreId debugging information will be produced ";
273 LogDebug(
"GoodSeedProducer") <<
"START event: " <<
iEvent.id().event() <<
" in run " <<
iEvent.id().run();
275 auto output_preid = std::make_unique<ElectronSeedCollection>();
276 auto output_nopre = std::make_unique<TrajectorySeedCollection>();
277 auto output_preidinfo = std::make_unique<PreIdCollection>();
278 auto preIdMap_p = std::make_unique<edm::ValueMap<reco::PreIdRef>>();
281 std::unique_ptr<TrajectoryFitter> fitter;
282 std::unique_ptr<TrajectorySmoother> smoother;
290 smoother.reset(aSmoother->
clone());
291 fitter = aFitter->
clone();
294 hitCloner = static_cast<TkTransientTrackingRecHitBuilder const*>(theTrackerRecHitBuilder.
product())->cloner();
311 vector<PFCluster const*> basClus;
312 for (
auto const& klus : *theECPfClustCollection.
product()) {
314 basClus.push_back(&klus);
332 LogDebug(
"GoodSeedProducer") <<
"Number of tracks in collection "
333 <<
"tracksContainers_[" << istr <<
"] to be analyzed " << Tk.size();
336 for (
unsigned int i = 0;
i < Tk.size(); ++
i) {
341 bool GoodPreId =
false;
345 auto tketa = tkmom.eta();
347 auto const& Seed = (*trackRef->seedRef());
350 int ibin = ipteta * 9;
355 float nchi = Tk[
i].normalizedChi2();
357 int nhitpi = Tk[
i].found();
364 auto pfmass = 0.0005;
365 auto pfoutenergy =
sqrt((pfmass * pfmass) + Tk[
i].outerMomentum().Mag2());
368 Tk[
i].outerMomentum().
x(), Tk[
i].outerMomentum().
y(), Tk[
i].outerMomentum().
z(), pfoutenergy);
376 float toteta = 1000.f;
377 float totphi = 1000.f;
385 if (theOutParticle.getSuccess() != 0) {
386 ElecTrkEcalPos =
GlobalPoint(theOutParticle.particle().vertex().x(),
387 theOutParticle.particle().vertex().y(),
388 theOutParticle.particle().vertex().z());
390 constexpr
float psLim = 2.50746495928f;
391 bool isBelowPS = (ElecTrkEcalPos.
z() * ElecTrkEcalPos.
z()) > (psLim * psLim) * ElecTrkEcalPos.
perp2();
394 unsigned clusCounter = 0;
396 for (
auto aClus : basClus) {
397 float tmp_ep =
float(aClus->correctedEnergy()) * oPTOB;
403 double ecalShowerDepth = PFCluster::getDepthCorrection(aClus->correctedEnergy(), isBelowPS,
false);
404 auto mom = theOutParticle.particle().momentum().Vect();
405 auto meanShower = ElecTrkEcalPos +
GlobalVector(mom.x(), mom.y(), mom.z()).
unit() * ecalShowerDepth;
407 float etarec = meanShower.
eta();
408 float phirec = meanShower.phi();
410 float tmp_phi =
std::abs(aClus->positionREP().phi() - phirec);
419 if (aClus->correctedEnergy() > max_ee) {
420 toteta = aClus->positionREP().eta() - etarec;
423 EE = aClus->correctedEnergy();
424 feta = aClus->positionREP().eta();
425 clusterRef =
PFClusterRef(theECPfClustCollection, clusCounter);
426 meanShowerSaved = meanShower;
433 float trk_ecalDeta_ = fabs(toteta);
434 float trk_ecalDphi_ = fabs(totphi);
441 float chieta = (toteta != 1000.f) ? toteta / ecaletares : toteta;
442 float chiphi = (totphi != 1000.f) ? totphi / ecalphires : totphi;
443 float chichi =
sqrt(chieta * chieta + chiphi * chiphi);
446 float eta_cut =
thr[ibin + 0];
447 float phi_cut =
thr[ibin + 1];
448 float ep_cutmin =
thr[ibin + 2];
450 ((trk_ecalDeta_ < eta_cut) && (trk_ecalDphi_ < phi_cut) && (EP > ep_cutmin) && (nhitpi > 10));
452 bool EcalMatching = GoodMatching;
457 GoodMatching =
false;
459 math::XYZPoint myPoint(ElecTrkEcalPos.
x(), ElecTrkEcalPos.
y(), ElecTrkEcalPos.
z());
461 clusterRef, myPoint, meanShowerSaved,
std::abs(toteta),
std::abs(totphi), chieta, chiphi, chichi, EP);
466 int hit1max =
int(
thr[ibin + 3]);
467 float chiredmin =
thr[ibin + 4];
468 bool GoodKFFiltering = ((nchi > chiredmin) | (nhitpi < hit1max));
472 bool GoodTkId =
false;
474 if ((!GoodMatching) && (GoodKFFiltering) && (GoodRange)) {
485 tmp.push_back(
hit->cloneSH());
486 auto const& theTrack = Tk[
i];
487 GlobalVector gv(theTrack.innerMomentum().x(), theTrack.innerMomentum().y(), theTrack.innerMomentum().z());
488 GlobalPoint gp(theTrack.innerPosition().x(), theTrack.innerPosition().y(), theTrack.innerPosition().z());
493 if (FitTjs.isValid()) {
494 Trajectory&& SmooTjs = smoother->trajectory(FitTjs);
500 dpt = (pt_in > 0) ? fabs(pt_out - pt_in) / pt_in : 0.;
511 float Ytmva = globalCache()->gbr[ipteta]->GetClassifier(
vars);
513 float BDTcut =
thr[ibin + 5];
516 myPreId.
setMVA(GoodTkId, Ytmva);
519 float chiratiocut =
thr[ibin + 6];
520 float gschicut =
thr[ibin + 7];
521 float gsptmin =
thr[ibin + 8];
527 GoodPreId = GoodTkId | GoodMatching;
533 LogDebug(
"GoodSeedProducer") <<
"Track (pt= " << Tk[
i].pt() <<
"GeV/c, eta= " << Tk[
i].eta()
534 <<
") preidentified for agreement between track and ECAL cluster";
535 if (GoodPreId && (!GoodMatching))
536 LogDebug(
"GoodSeedProducer") <<
"Track (pt= " << Tk[
i].pt() <<
"GeV/c, eta= " << Tk[
i].eta()
537 <<
") preidentified only for track properties";
546 output_preid->push_back(NewSeed);
549 output_nopre->push_back(Seed);
554 refMap_[trackRef] = output_preidinfo->size();
555 output_preidinfo->push_back(myPreId);
596 for (UInt_t
j = 0;
j <
gbr.size(); ++
j) {
621 ifstream ifs(parFile.fullPath().c_str());
622 for (
int iy = 0; iy < 81; ++iy)
632 if (fabs(
eta) < 1.479)
645 int iep = ie * 3 + ip;
646 LogDebug(
"GoodSeedProducer") <<
"Track pt =" <<
pt <<
" eta=" <<
eta <<
" bin=" << iep;
653 std::vector<reco::PreIdRef>
values;
655 unsigned ntracks =
tracks->size();
656 for (
unsigned itrack = 0; itrack < ntracks; ++itrack) {
658 std::map<reco::TrackRef, unsigned>::const_iterator itcheck =
refMap_.find(theTrackRef);
659 if (itcheck ==
refMap_.end()) {
664 values.push_back(preIdRef);