339 LogDebug(
"GoodSeedProducer") <<
"START event: " <<
iEvent.id().event() <<
" in run " <<
iEvent.id().run();
341 auto output_preid = std::make_unique<ElectronSeedCollection>();
342 auto output_nopre = std::make_unique<TrajectorySeedCollection>();
343 auto output_preidinfo = std::make_unique<PreIdCollection>();
344 auto preIdMap_p = std::make_unique<edm::ValueMap<reco::PreIdRef>>();
347 std::unique_ptr<TrajectoryFitter> fitter;
348 std::unique_ptr<TrajectorySmoother> smoother;
355 smoother.reset(aSmoother->clone());
356 fitter = aFitter->clone();
374 vector<PFCluster const*> basClus;
375 for (
auto const& klus : *theECPfClustCollection.
product()) {
377 basClus.push_back(&klus);
395 LogDebug(
"GoodSeedProducer") <<
"Number of tracks in collection " 396 <<
"tracksContainers_[" << istr <<
"] to be analyzed " << Tk.size();
399 for (
unsigned int i = 0;
i < Tk.size(); ++
i) {
404 bool GoodPreId =
false;
408 auto tketa = tkmom.eta();
410 auto const&
Seed = (*trackRef->seedRef());
414 int ibin = ipteta * 9;
419 float nchi = Tk[
i].normalizedChi2();
421 int nhitpi = Tk[
i].found();
428 auto pfmass = 0.0005;
429 auto pfoutenergy =
sqrt((pfmass * pfmass) + Tk[
i].outerMomentum().Mag2());
432 Tk[
i].outerMomentum().
x(), Tk[
i].outerMomentum().
y(), Tk[
i].outerMomentum().
z(), pfoutenergy);
440 float toteta = 1000.f;
441 float totphi = 1000.f;
449 if (theOutParticle.getSuccess() != 0) {
450 ElecTrkEcalPos =
GlobalPoint(theOutParticle.particle().vertex().x(),
451 theOutParticle.particle().vertex().y(),
452 theOutParticle.particle().vertex().z());
455 bool isBelowPS = (ElecTrkEcalPos.z() * ElecTrkEcalPos.z()) > (psLim * psLim) * ElecTrkEcalPos.perp2();
458 unsigned clusCounter = 0;
460 for (
auto aClus : basClus) {
461 float tmp_ep =
float(aClus->correctedEnergy()) * oPTOB;
467 double ecalShowerDepth = PFCluster::getDepthCorrection(aClus->correctedEnergy(), isBelowPS,
false);
468 auto mom = theOutParticle.particle().momentum().Vect();
469 auto meanShower = ElecTrkEcalPos +
GlobalVector(mom.x(), mom.y(), mom.z()).
unit() * ecalShowerDepth;
471 float etarec = meanShower.
eta();
472 float phirec = meanShower.phi();
474 float tmp_phi =
std::abs(aClus->positionREP().phi() - phirec);
483 if (aClus->correctedEnergy() > max_ee) {
484 toteta = aClus->positionREP().eta() - etarec;
487 EE = aClus->correctedEnergy();
488 feta = aClus->positionREP().eta();
489 clusterRef =
PFClusterRef(theECPfClustCollection, clusCounter);
490 meanShowerSaved = meanShower;
497 float trk_ecalDeta_ = fabs(toteta);
498 float trk_ecalDphi_ = fabs(totphi);
505 float chieta = (toteta != 1000.f) ? toteta / ecaletares : toteta;
506 float chiphi = (totphi != 1000.f) ? totphi / ecalphires : totphi;
507 float chichi =
sqrt(chieta * chieta + chiphi * chiphi);
510 float eta_cut =
thr[ibin + 0];
511 float phi_cut =
thr[ibin + 1];
512 float ep_cutmin =
thr[ibin + 2];
514 ((trk_ecalDeta_ < eta_cut) && (trk_ecalDphi_ < phi_cut) && (EP > ep_cutmin) && (nhitpi > 10));
516 bool EcalMatching = GoodMatching;
521 GoodMatching =
false;
523 math::XYZPoint myPoint(ElecTrkEcalPos.x(), ElecTrkEcalPos.y(), ElecTrkEcalPos.z());
525 clusterRef, myPoint, meanShowerSaved,
std::abs(toteta),
std::abs(totphi), chieta, chiphi, chichi, EP);
530 int hit1max =
int(
thr[ibin + 3]);
531 float chiredmin =
thr[ibin + 4];
532 bool GoodKFFiltering = ((nchi > chiredmin) | (nhitpi < hit1max));
536 bool GoodTkId =
false;
538 if ((!GoodMatching) && (GoodKFFiltering) && (GoodRange)) {
549 tmp.push_back(
hit->cloneSH());
550 auto const& theTrack = Tk[
i];
551 GlobalVector gv(theTrack.innerMomentum().x(), theTrack.innerMomentum().y(), theTrack.innerMomentum().z());
552 GlobalPoint gp(theTrack.innerPosition().x(), theTrack.innerPosition().y(), theTrack.innerPosition().z());
557 if (FitTjs.isValid()) {
558 Trajectory&& SmooTjs = smoother->trajectory(FitTjs);
564 dpt = (pt_in > 0) ? fabs(pt_out - pt_in) / pt_in : 0.;
575 float Ytmva = globalCache()->gbr[ipteta]->GetClassifier(
vars);
577 float BDTcut =
thr[ibin + 5];
580 myPreId.
setMVA(GoodTkId, Ytmva);
583 float chiratiocut =
thr[ibin + 6];
584 float gschicut =
thr[ibin + 7];
585 float gsptmin =
thr[ibin + 8];
591 GoodPreId = GoodTkId | GoodMatching;
597 LogDebug(
"GoodSeedProducer") <<
"Track (pt= " << Tk[
i].pt() <<
"GeV/c, eta= " << Tk[
i].eta()
598 <<
") preidentified for agreement between track and ECAL cluster";
599 if (GoodPreId && (!GoodMatching))
600 LogDebug(
"GoodSeedProducer") <<
"Track (pt= " << Tk[
i].pt() <<
"GeV/c, eta= " << Tk[
i].eta()
601 <<
") preidentified only for track properties";
609 NewSeed.setCtfTrack(trackRef);
610 output_preid->push_back(NewSeed);
613 output_nopre->push_back(
Seed);
618 refMap_[trackRef] = output_preidinfo->size();
619 output_preidinfo->push_back(myPreId);
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
void setECALMatchingProperties(PFClusterRef clusterRef, const math::XYZPoint &ecalpos, const math::XYZPoint &meanShower, float deta, float dphi, float chieta, float chiphi, float chi2, float eop)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
std::string preidckf_
Name of the Seed(Ckf) Collection.
edm::EDGetTokenT< reco::PFClusterCollection > pfCLusTagPSLabel_
T const * product() const
Global3DPoint GlobalPoint
std::unique_ptr< PFResolutionMap > resMapEtaECAL_
std::vector< Track > TrackCollection
collection of Tracks
float thr[150]
vector of thresholds for different bins of eta and pt
TrajectoryMeasurement const & lastMeasurement() const
void setTrack(reco::TrackRef trackref)
int getBin(float, float)
Find the bin in pt and eta.
void setMVA(bool accepted, float mva, unsigned n=0)
void setTrackFiltering(bool accepted, unsigned n=0)
math::XYZVector B_
B field.
std::string preidname_
Name of the preid Collection (FB)
Abs< T >::type abs(const T &t)
bool useQuality_
TRACK QUALITY.
void fillPreIdRefValueMap(edm::Handle< reco::TrackCollection > tkhandle, const edm::OrphanHandle< reco::PreIdCollection > &, edm::ValueMap< reco::PreIdRef >::Filler &filler)
std::vector< edm::EDGetTokenT< reco::TrackCollection > > tracksContainers_
double minPt_
Minimum transverse momentum and maximum pseudorapidity.
bool disablePreId_
switch to disable the pre-id
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
reco::TrackBase::TrackQuality trackQuality_
Basic3DVector unit() const
double clusThreshold_
Cut on the energy of the clusters.
bool propagateToEcalEntrance(bool first=true)
bool produceCkfseed_
Produce the Seed for Ckf tracks?
const edm::ESGetToken< TrajectorySmoother, TrajectoryFitter::Record > smootherToken_
bool useTmva_
USE OF TMVA.
std::unique_ptr< PFResolutionMap > resMapPhiECAL_
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
XYZPointD XYZPoint
point in space with cartesian internal representation
const edm::ESGetToken< TrajectoryFitter, TrajectoryFitter::Record > fitterToken_
std::map< reco::TrackRef, unsigned > refMap_
Map used to create the TrackRef, PreIdRef value map.
GlobalVector globalMomentum() const
TrajectoryStateOnSurface const & updatedState() const
TrackingRecHit::ConstRecHitContainer ConstRecHitContainer
void setTrackProperties(float newchi2, float chi2ratio, float dpt)
void setECALMatching(bool accepted, unsigned n=0)
TrajectoryMeasurement const & firstMeasurement() const
bool producePreId_
Produce the pre-id debugging collection.
edm::EDGetTokenT< reco::PFClusterCollection > pfCLusTagHCLabel_
const edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > trackerRecHitBuilderToken_
std::string preidgsf_
Name of the Seed(Gsf) Collection.
edm::EDGetTokenT< reco::PFClusterCollection > pfCLusTagECLabel_
double minEp_
Min and MAx allowed values forEoverP.
float nhit
VARIABLES NEEDED FOR TMVA.
Power< A, B >::type pow(const A &a, const B &b)
double PtThresholdSavePredId_
Threshold to save Pre Idinfo.
Global3DVector GlobalVector
void setFinalDecision(bool accepted, unsigned n=0)
math::XYZTLorentzVector XYZTLorentzVector
edm::Ref< l1t::PFClusterCollection > PFClusterRef