56 #include "Math/VectorUtil.h"
60 namespace goodseedhelpers {
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) {
250 producePreId_ =
false;
253 LogDebug(
"GoodSeedProducer") <<
"Seeds for GSF will be produced ";
258 if (produceCkfseed_) {
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();
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());
362 int ibin = ipteta * 9;
367 float nchi = Tk[
i].normalizedChi2();
369 int nhitpi = Tk[
i].found();
376 auto pfmass = 0.0005;
377 auto pfoutenergy =
sqrt((pfmass * pfmass) + Tk[
i].outerMomentum().Mag2());
380 Tk[
i].outerMomentum().
x(), Tk[
i].outerMomentum().
y(), Tk[
i].outerMomentum().
z(), pfoutenergy);
388 float toteta = 1000.f;
389 float totphi = 1000.f;
397 if (theOutParticle.getSuccess() != 0) {
398 ElecTrkEcalPos =
GlobalPoint(theOutParticle.particle().vertex().x(),
399 theOutParticle.particle().vertex().y(),
400 theOutParticle.particle().vertex().z());
402 constexpr
float psLim = 2.50746495928f;
403 bool isBelowPS = (ElecTrkEcalPos.
z() * ElecTrkEcalPos.
z()) > (psLim * psLim) * ElecTrkEcalPos.
perp2();
406 unsigned clusCounter = 0;
408 for (
auto aClus : basClus) {
409 float tmp_ep = float(aClus->correctedEnergy()) * oPTOB;
415 double ecalShowerDepth = PFCluster::getDepthCorrection(aClus->correctedEnergy(), isBelowPS,
false);
416 auto mom = theOutParticle.particle().momentum().Vect();
417 auto meanShower = ElecTrkEcalPos +
GlobalVector(mom.x(), mom.y(), mom.z()).
unit() * ecalShowerDepth;
419 float etarec = meanShower.
eta();
420 float phirec = meanShower.phi();
422 float tmp_phi =
std::abs(aClus->positionREP().phi() - phirec);
431 if (aClus->correctedEnergy() > max_ee) {
432 toteta = aClus->positionREP().eta() - etarec;
435 EE = aClus->correctedEnergy();
436 feta = aClus->positionREP().eta();
437 clusterRef =
PFClusterRef(theECPfClustCollection, clusCounter);
438 meanShowerSaved = meanShower;
445 float trk_ecalDeta_ = fabs(toteta);
446 float trk_ecalDphi_ = fabs(totphi);
453 float chieta = (toteta != 1000.f) ? toteta / ecaletares : toteta;
454 float chiphi = (totphi != 1000.f) ? totphi / ecalphires : totphi;
455 float chichi =
sqrt(chieta * chieta + chiphi * chiphi);
458 float eta_cut =
thr[ibin + 0];
459 float phi_cut =
thr[ibin + 1];
460 float ep_cutmin =
thr[ibin + 2];
462 ((trk_ecalDeta_ < eta_cut) && (trk_ecalDphi_ < phi_cut) && (EP > ep_cutmin) && (nhitpi > 10));
464 bool EcalMatching = GoodMatching;
469 GoodMatching =
false;
471 math::XYZPoint myPoint(ElecTrkEcalPos.
x(), ElecTrkEcalPos.
y(), ElecTrkEcalPos.
z());
473 clusterRef, myPoint, meanShowerSaved,
std::abs(toteta),
std::abs(totphi), chieta, chiphi, chichi, EP);
478 int hit1max = int(
thr[ibin + 3]);
479 float chiredmin =
thr[ibin + 4];
480 bool GoodKFFiltering = ((nchi > chiredmin) | (nhitpi < hit1max));
484 bool GoodTkId =
false;
486 if ((!GoodMatching) && (GoodKFFiltering) && (GoodRange)) {
497 tmp.push_back(
hit->cloneSH());
498 auto const& theTrack = Tk[
i];
499 GlobalVector gv(theTrack.innerMomentum().x(), theTrack.innerMomentum().y(), theTrack.innerMomentum().z());
500 GlobalPoint gp(theTrack.innerPosition().x(), theTrack.innerPosition().y(), theTrack.innerPosition().z());
503 Trajectory&& FitTjs = fitter->fitOne(Seed, tmp, tsos);
505 if (FitTjs.isValid()) {
506 Trajectory&& SmooTjs = smoother->trajectory(FitTjs);
512 dpt = (pt_in > 0) ? fabs(pt_out - pt_in) / pt_in : 0.;
523 float Ytmva = globalCache()->gbr[ipteta]->GetClassifier(vars);
525 float BDTcut =
thr[ibin + 5];
528 myPreId.
setMVA(GoodTkId, Ytmva);
531 float chiratiocut =
thr[ibin + 6];
532 float gschicut =
thr[ibin + 7];
533 float gsptmin =
thr[ibin + 8];
539 GoodPreId = GoodTkId | GoodMatching;
545 LogDebug(
"GoodSeedProducer") <<
"Track (pt= " << Tk[
i].pt() <<
"GeV/c, eta= " << Tk[
i].eta()
546 <<
") preidentified for agreement between track and ECAL cluster";
547 if (GoodPreId && (!GoodMatching))
548 LogDebug(
"GoodSeedProducer") <<
"Track (pt= " << Tk[
i].pt() <<
"GeV/c, eta= " << Tk[
i].eta()
549 <<
") preidentified only for track properties";
558 output_preid->push_back(NewSeed);
561 output_nopre->push_back(Seed);
566 refMap_[trackRef] = output_preidinfo->size();
567 output_preidinfo->push_back(myPreId);
592 namespace goodseedhelpers {
608 for (UInt_t
j = 0;
j <
gbr.size(); ++
j) {
632 ifstream ifs(parFile.fullPath().c_str());
633 for (
int iy = 0; iy < 81; ++iy)
643 if (fabs(eta) < 1.479)
656 int iep = ie * 3 + ip;
657 LogDebug(
"GoodSeedProducer") <<
"Track pt =" << pt <<
" eta=" << eta <<
" bin=" << iep;
664 std::vector<reco::PreIdRef>
values;
666 unsigned ntracks = tracks->size();
667 for (
unsigned itrack = 0; itrack < ntracks; ++itrack) {
669 std::map<reco::TrackRef, unsigned>::const_iterator itcheck =
refMap_.find(theTrackRef);
670 if (itcheck ==
refMap_.end()) {
675 values.push_back(preIdRef);
679 filler.
insert(tracks, values.begin(), values.end());
int nHitsInSeed_
Number of hits in the seed;.
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
HeavyObjectCache(const edm::ParameterSet &conf)
void setECALMatchingProperties(PFClusterRef clusterRef, const math::XYZPoint &ecalpos, const math::XYZPoint &meanShower, float deta, float dphi, float chieta, float chiphi, float chi2, float eop)
std::string preidckf_
Name of the Seed(Ckf) Collection.
Quality qualityByName(std::string const &name)
edm::EDGetTokenT< reco::PFClusterCollection > pfCLusTagPSLabel_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
TrackQuality
track quality
#define DEFINE_FWK_MODULE(type)
uint32_t const *__restrict__ Quality * quality
void insert(const H &h, I begin, I end)
Global3DPoint GlobalPoint
std::unique_ptr< PFResolutionMap > resMapEtaECAL_
std::vector< Track > TrackCollection
collection of Tracks
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldTokenBeginRun_
auto const & tracks
cannot be loose
double EcalStripSumE_minClusEnergy_
float thr[150]
vector of thresholds for different bins of eta and pt
std::array< std::unique_ptr< const GBRForest >, kMaxWeights > gbr
GoodSeedProducer(const edm::ParameterSet &, const goodseedhelpers::HeavyObjectCache *)
void setCtfTrack(const CtfTrackRef &)
Set additional info.
void setTrack(reco::TrackRef trackref)
bool getData(T &iHolder) const
int getBin(float, float)
Find the bin in pt and eta.
void setMVA(bool accepted, float mva, unsigned n=0)
double EcalStripSumE_deltaEta_
double EcalStripSumE_deltaPhiOverQ_minValue_
double EcalStripSumE_deltaPhiOverQ_maxValue_
void setTrackFiltering(bool accepted, unsigned n=0)
void produce(edm::Event &, const edm::EventSetup &) override
TrajectoryStateOnSurface TSOS
math::XYZVector B_
B field.
std::string preidname_
Name of the preid Collection (FB)
TrajectoryMeasurement const & lastMeasurement() const
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
std::string propagatorName_
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
static void globalEndJob(goodseedhelpers::HeavyObjectCache const *)
void beginRun(const edm::Run &run, const edm::EventSetup &) override
reco::TrackBase::TrackQuality trackQuality_
double clusThreshold_
Cut on the energy of the clusters.
bool propagateToEcalEntrance(bool first=true)
Log< level::Info, false > LogInfo
static constexpr unsigned int kMaxWeights
bool produceCkfseed_
Produce the Seed for Ckf tracks?
const edm::ESGetToken< TrajectorySmoother, TrajectoryFitter::Record > smootherToken_
TrajectoryMeasurement const & firstMeasurement() const
T const * product() const
bool useTmva_
USE OF TMVA.
XYZVectorD XYZVector
spatial vector with cartesian internal representation
std::unique_ptr< PFResolutionMap > resMapPhiECAL_
XYZPointD XYZPoint
point in space with cartesian internal representation
T getParameter(std::string const &) const
const edm::ESGetToken< TrajectoryFitter, TrajectoryFitter::Record > fitterToken_
std::map< reco::TrackRef, unsigned > refMap_
Map used to create the TrackRef, PreIdRef value map.
TrackingRecHit::ConstRecHitContainer ConstRecHitContainer
void setTrackProperties(float newchi2, float chi2ratio, float dpt)
void setECALMatching(bool accepted, unsigned n=0)
GlobalVector globalMomentum() const
produces< ElectronSeedCollection >()
bool producePreId_
Produce the pre-id debugging collection.
std::unique_ptr< PFTrackTransformer > pfTransformer_
PFTrackTransformer.
std::string fullPath() const
std::string trackerRecHitBuilderName_
std::string smootherName_
TrajectoryStateOnSurface const & updatedState() const
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)
std::vector< edm::EDGetTokenT< std::vector< Trajectory > > > trajContainers_
static std::unique_ptr< goodseedhelpers::HeavyObjectCache > initializeGlobalCache(const edm::ParameterSet &conf)
double PtThresholdSavePredId_
Threshold to save Pre Idinfo.
Global3DVector GlobalVector
void setFinalDecision(bool accepted, unsigned n=0)
math::XYZTLorentzVector XYZTLorentzVector
edm::Ref< l1t::PFClusterCollection > PFClusterRef
Basic3DVector unit() const