56 #include "Math/VectorUtil.h" 75 return std::make_unique<goodseedhelpers::HeavyObjectCache>(conf);
189 using namespace reco;
193 desc.add<
double>(
"MaxEOverP", 3.0);
195 desc.add<
bool>(
"UseQuality",
true);
197 desc.add<
std::string>(
"ThresholdFile",
"RecoParticleFlow/PFTracking/data/Threshold.dat");
199 desc.add<
double>(
"MaxEta", 2.4);
200 desc.add<
std::string>(
"EtaMap",
"RecoParticleFlow/PFBlockProducer/data/resmap_ECAL_eta.dat");
201 desc.add<
std::string>(
"PhiMap",
"RecoParticleFlow/PFBlockProducer/data/resmap_ECAL_phi.dat");
203 desc.add<
int>(
"NHitsInSeed", 3);
207 desc.add<
double>(
"MinEOverP", 0.3);
208 desc.add<
std::string>(
"Weights1",
"RecoParticleFlow/PFTracking/data/MVA_BDTTrackDrivenSeed_cat1.xml");
209 desc.add<
std::string>(
"Weights2",
"RecoParticleFlow/PFTracking/data/MVA_BDTTrackDrivenSeed_cat2.xml");
210 desc.add<
std::string>(
"Weights3",
"RecoParticleFlow/PFTracking/data/MVA_BDTTrackDrivenSeed_cat3.xml");
211 desc.add<
std::string>(
"Weights4",
"RecoParticleFlow/PFTracking/data/MVA_BDTTrackDrivenSeed_cat4.xml");
212 desc.add<
std::string>(
"Weights5",
"RecoParticleFlow/PFTracking/data/MVA_BDTTrackDrivenSeed_cat5.xml");
213 desc.add<
std::string>(
"Weights6",
"RecoParticleFlow/PFTracking/data/MVA_BDTTrackDrivenSeed_cat6.xml");
214 desc.add<
std::string>(
"Weights7",
"RecoParticleFlow/PFTracking/data/MVA_BDTTrackDrivenSeed_cat7.xml");
215 desc.add<
std::string>(
"Weights8",
"RecoParticleFlow/PFTracking/data/MVA_BDTTrackDrivenSeed_cat8.xml");
216 desc.add<
std::string>(
"Weights9",
"RecoParticleFlow/PFTracking/data/MVA_BDTTrackDrivenSeed_cat9.xml");
219 desc.add<
std::string>(
"PSThresholdFile",
"RecoParticleFlow/PFTracking/data/PSThreshold.dat");
220 desc.add<
double>(
"MinPt", 2.0);
221 desc.add<std::vector<edm::InputTag>>(
"TkColList", {
edm::InputTag(
"generalTracks")});
222 desc.addUntracked<
bool>(
"UseTMVA",
true);
224 desc.add<
double>(
"MaxPt", 50.0);
225 desc.add<
bool>(
"ApplyIsolation",
false);
226 desc.add<
double>(
"EcalStripSumE_deltaPhiOverQ_minValue", -0.1);
227 desc.add<
double>(
"EcalStripSumE_minClusEnergy", 0.1);
228 desc.add<
double>(
"EcalStripSumE_deltaEta", 0.03);
229 desc.add<
double>(
"EcalStripSumE_deltaPhiOverQ_maxValue", 0.5);
230 desc.add<
double>(
"EOverPLead_minValue", 0.95);
231 desc.add<
double>(
"HOverPLead_maxValue", 0.05);
232 desc.add<
double>(
"HcalWindow", 0.184);
233 desc.add<
double>(
"ClusterThreshold", 0.5);
234 desc.add<
bool>(
"UsePreShower",
false);
236 desc.addUntracked<
bool>(
"ProducePreId",
true);
237 desc.addUntracked<
double>(
"PtThresholdSavePreId", 1.0);
238 desc.add<
double>(
"Min_dr", 0.2);
243 : pfTransformer_(nullptr),
245 resMapEtaECAL_(nullptr),
246 resMapPhiECAL_(nullptr),
252 LogInfo(
"GoodSeedProducer") <<
"Electron PreIdentification started ";
255 std::vector<edm::InputTag>
tags = iConfig.
getParameter<vector<InputTag>>(
"TkColList");
256 for (
unsigned int i = 0;
i <
tags.size(); ++
i) {
305 LogDebug(
"GoodSeedProducer") <<
"Seeds for GSF will be produced ";
308 produces<ElectronSeedCollection>(
preidgsf_);
311 LogDebug(
"GoodSeedProducer") <<
"Seeds for CKF will be produced ";
312 produces<TrajectorySeedCollection>(
preidckf_);
316 LogDebug(
"GoodSeedProducer") <<
"PreId debugging information will be produced ";
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;
351 if (!disablePreId_) {
352 auto const& aFitter = &iSetup.
getData(fitterToken_);
353 auto const& aSmoother = &iSetup.
getData(smootherToken_);
355 smoother.reset(aSmoother->clone());
356 fitter = aFitter->clone();
357 auto const& theTrackerRecHitBuilder = &iSetup.
getData(trackerRecHitBuilderToken_);
359 fitter->setHitCloner(&hitCloner);
360 smoother->setHitCloner(&hitCloner);
372 iEvent.getByToken(pfCLusTagECLabel_, theECPfClustCollection);
374 vector<PFCluster const*> basClus;
375 for (
auto const& klus : *theECPfClustCollection.
product()) {
376 if (klus.correctedEnergy() > clusThreshold_)
377 basClus.push_back(&klus);
382 iEvent.getByToken(pfCLusTagHCLabel_, theHCPfClustCollection);
386 iEvent.getByToken(pfCLusTagPSLabel_, thePSPfClustCollection);
389 for (
unsigned int istr = 0; istr < tracksContainers_.size(); ++istr) {
392 iEvent.getByToken(tracksContainers_[istr], tkRefCollection);
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) {
400 if (useQuality_ && (!(Tk[
i].
quality(trackQuality_))))
404 bool GoodPreId =
false;
408 auto tketa = tkmom.eta();
410 auto const&
Seed = (*trackRef->seedRef());
412 if (!disablePreId_) {
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;
462 if ((tmp_ep < minEp_) | (tmp_ep > maxEp_)) {
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);
501 auto ecaletares = resMapEtaECAL_->GetBinContent(resMapEtaECAL_->FindBin(
feta,
EE));
502 auto ecalphires = resMapPhiECAL_->GetBinContent(resMapPhiECAL_->FindBin(
feta,
EE));
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);
528 bool GoodRange = ((
std::abs(tketa) < maxEta_) & (tkpt > minPt_));
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)) {
544 trk_ecalDeta = trk_ecalDeta_;
545 trk_ecalDphi = trk_ecalDphi_;
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.;
567 chired = chiRatio * chikfred;
573 float vars[10] = {nhit, chikfred, dpt, EP, chiRatio, chired, trk_ecalDeta, trk_ecalDphi, tkpt, tketa};
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];
587 GoodTkId = ((dpt > gsptmin) & (chired < gschicut) & (chiRatio < chiratiocut));
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";
610 output_preid->push_back(NewSeed);
612 if (produceCkfseed_) {
613 output_nopre->push_back(
Seed);
616 if (producePreId_ && myPreId.
pt() > PtThresholdSavePredId_) {
618 refMap_[trackRef] = output_preidinfo->size();
619 output_preidinfo->push_back(myPreId);
631 if (tracksContainers_.size() == 1) {
633 iEvent.getByToken(tracksContainers_[0], tkRefCollection);
634 fillPreIdRefValueMap(tkRefCollection, preIdRefProd, mapFiller);
660 for (UInt_t
j = 0;
j <
gbr.size(); ++
j) {
673 pfTransformer_ = std::make_unique<PFTrackTransformer>(B_);
674 pfTransformer_->OnlyProp();
677 FileInPath ecalEtaMap(conf_.getParameter<
string>(
"EtaMap"));
678 FileInPath ecalPhiMap(conf_.getParameter<
string>(
"PhiMap"));
679 resMapEtaECAL_ = std::make_unique<PFResolutionMap>(
"ECAL_eta", ecalEtaMap.
fullPath().c_str());
680 resMapPhiECAL_ = std::make_unique<PFResolutionMap>(
"ECAL_phi", ecalPhiMap.
fullPath().c_str());
683 FileInPath parFile(conf_.getParameter<
string>(
"ThresholdFile"));
684 ifstream ifs(parFile.fullPath().c_str());
685 for (
int iy = 0;
iy < 81; ++
iy)
695 if (fabs(
eta) < 1.479)
708 int iep = ie * 3 + ip;
709 LogDebug(
"GoodSeedProducer") <<
"Track pt =" <<
pt <<
" eta=" <<
eta <<
" bin=" << iep;
716 std::vector<reco::PreIdRef>
values;
719 for (
unsigned itrack = 0; itrack <
ntracks; ++itrack) {
721 std::map<reco::TrackRef, unsigned>::const_iterator itcheck = refMap_.find(theTrackRef);
722 if (itcheck == refMap_.end()) {
727 values.push_back(preIdRef);
int nHitsInSeed_
Number of hits in the seed;.
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
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)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
std::string preidckf_
Name of the Seed(Ckf) Collection.
std::string fullPath() const
Quality qualityByName(std::string const &name)
edm::EDGetTokenT< reco::PFClusterCollection > pfCLusTagPSLabel_
TrackQuality
track quality
T const * product() const
Global3DPoint GlobalPoint
std::unique_ptr< PFResolutionMap > resMapEtaECAL_
std::vector< Track > TrackCollection
collection of Tracks
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldTokenBeginRun_
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 *)
TrajectoryMeasurement const & lastMeasurement() const
void setCtfTrack(const CtfTrackRef &)
Set additional info.
T getUntrackedParameter(std::string const &, T const &) 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)
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)
std::string propagatorName_
Abs< T >::type abs(const T &t)
bool useQuality_
TRACK QUALITY.
double z() const
z of vertex
void fillPreIdRefValueMap(edm::Handle< reco::TrackCollection > tkhandle, const edm::OrphanHandle< reco::PreIdCollection > &, edm::ValueMap< reco::PreIdRef >::Filler &filler)
#define DEFINE_FWK_MODULE(type)
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
int getBin(double x, std::vector< double > boundaries)
reco::TrackBase::TrackQuality trackQuality_
Basic3DVector unit() const
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_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool useTmva_
USE OF TMVA.
XYZVectorD XYZVector
spatial vector with cartesian internal representation
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.
std::unique_ptr< PFTrackTransformer > pfTransformer_
PFTrackTransformer.
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t iy(uint32_t id)
std::string trackerRecHitBuilderName_
std::string smootherName_
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)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
double PtThresholdSavePredId_
Threshold to save Pre Idinfo.
Global3DVector GlobalVector
void setFinalDecision(bool accepted, unsigned n=0)
math::XYZTLorentzVector XYZTLorentzVector
edm::Ref< l1t::PFClusterCollection > PFClusterRef