CMS 3D CMS Logo

GoodSeedProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: PFTracking
4 // Class: GoodSeedProducer
5 //
6 // Original Author: Michele Pioppi
7 // March 2010. F. Beaudette. Produce PreId information
8 
10 
54 
55 #include "TMath.h"
56 #include "Math/VectorUtil.h"
57 
58 #include <fstream>
59 
60 namespace goodseedhelpers {
62  constexpr static unsigned int kMaxWeights = 9;
64  std::array<std::unique_ptr<const GBRForest>, kMaxWeights> gbr;
65  };
66 } // namespace goodseedhelpers
67 
68 class GoodSeedProducer final : public edm::stream::EDProducer<edm::GlobalCache<goodseedhelpers::HeavyObjectCache>> {
70 
71 public:
73 
74  static std::unique_ptr<goodseedhelpers::HeavyObjectCache> initializeGlobalCache(const edm::ParameterSet& conf) {
75  return std::make_unique<goodseedhelpers::HeavyObjectCache>(conf);
76  }
77 
79 
80 private:
81  void beginRun(const edm::Run& run, const edm::EventSetup&) override;
82  void produce(edm::Event&, const edm::EventSetup&) override;
83 
85  int getBin(float, float);
86 
90  // ----------member data ---------------------------
91 
94 
97 
100 
101  // needed by the above
103 
105  std::unique_ptr<PFTrackTransformer> pfTransformer_;
106 
109 
111  double minPt_;
112  double maxPt_;
113  double maxEta_;
114 
120  double minEoverP_;
121  double maxHoverP_;
122 
125 
127  double minEp_;
128  double maxEp_;
129 
132 
135 
138 
141 
143  float thr[150];
144 
145  // ----------access to event data
150  std::vector<edm::EDGetTokenT<std::vector<Trajectory>>> trajContainers_;
151  std::vector<edm::EDGetTokenT<reco::TrackCollection>> tracksContainers_;
152 
157 
158  std::unique_ptr<PFResolutionMap> resMapEtaECAL_;
159  std::unique_ptr<PFResolutionMap> resMapPhiECAL_;
160 
166 
170 
174  double Min_dr_;
175 
177  bool useTmva_;
178 
181 
183  std::map<reco::TrackRef, unsigned> refMap_;
184 };
185 
186 using namespace edm;
187 using namespace std;
188 using namespace reco;
189 
191  : pfTransformer_(nullptr),
192  conf_(iConfig),
193  resMapEtaECAL_(nullptr),
194  resMapPhiECAL_(nullptr),
195  fitterToken_(esConsumes(edm::ESInputTag("", iConfig.getParameter<string>("Fitter")))),
196  smootherToken_(esConsumes(edm::ESInputTag("", iConfig.getParameter<string>("Smoother")))),
197  trackerRecHitBuilderToken_(esConsumes(edm::ESInputTag("", iConfig.getParameter<std::string>("TTRHBuilder")))),
198  magneticFieldToken_(esConsumes()),
199  magneticFieldTokenBeginRun_(esConsumes<edm::Transition::BeginRun>()) {
200  LogInfo("GoodSeedProducer") << "Electron PreIdentification started ";
201 
202  //now do what ever initialization is needed
203  std::vector<edm::InputTag> tags = iConfig.getParameter<vector<InputTag>>("TkColList");
204  for (unsigned int i = 0; i < tags.size(); ++i) {
205  trajContainers_.push_back(consumes<vector<Trajectory>>(tags[i]));
206  tracksContainers_.push_back(consumes<reco::TrackCollection>(tags[i]));
207  }
208 
209  minPt_ = iConfig.getParameter<double>("MinPt");
210  maxPt_ = iConfig.getParameter<double>("MaxPt");
211  maxEta_ = iConfig.getParameter<double>("MaxEta");
212 
213  HcalIsolWindow_ = iConfig.getParameter<double>("HcalWindow");
214  EcalStripSumE_minClusEnergy_ = iConfig.getParameter<double>("EcalStripSumE_minClusEnergy");
215  EcalStripSumE_deltaEta_ = iConfig.getParameter<double>("EcalStripSumE_deltaEta");
216  EcalStripSumE_deltaPhiOverQ_minValue_ = iConfig.getParameter<double>("EcalStripSumE_deltaPhiOverQ_minValue");
217  EcalStripSumE_deltaPhiOverQ_maxValue_ = iConfig.getParameter<double>("EcalStripSumE_deltaPhiOverQ_maxValue");
218  minEoverP_ = iConfig.getParameter<double>("EOverPLead_minValue");
219  maxHoverP_ = iConfig.getParameter<double>("HOverPLead_maxValue");
220 
221  pfCLusTagECLabel_ = consumes<reco::PFClusterCollection>(iConfig.getParameter<InputTag>("PFEcalClusterLabel"));
222 
223  pfCLusTagHCLabel_ = consumes<reco::PFClusterCollection>(iConfig.getParameter<InputTag>("PFHcalClusterLabel"));
224 
225  pfCLusTagPSLabel_ = consumes<reco::PFClusterCollection>(iConfig.getParameter<InputTag>("PFPSClusterLabel"));
226 
227  preidgsf_ = iConfig.getParameter<string>("PreGsfLabel");
228  preidckf_ = iConfig.getParameter<string>("PreCkfLabel");
229  preidname_ = iConfig.getParameter<string>("PreIdLabel");
230 
231  fitterName_ = iConfig.getParameter<string>("Fitter");
232  smootherName_ = iConfig.getParameter<string>("Smoother");
233 
234  nHitsInSeed_ = iConfig.getParameter<int>("NHitsInSeed");
235 
236  clusThreshold_ = iConfig.getParameter<double>("ClusterThreshold");
237 
238  minEp_ = iConfig.getParameter<double>("MinEOverP");
239  maxEp_ = iConfig.getParameter<double>("MaxEOverP");
240 
241  //collection to produce
242  produceCkfseed_ = iConfig.getUntrackedParameter<bool>("ProduceCkfSeed", false);
243 
244  // to disable the electron part (for HI collisions for examples)
245  disablePreId_ = iConfig.getUntrackedParameter<bool>("DisablePreId", false);
246 
247  producePreId_ = iConfig.getUntrackedParameter<bool>("ProducePreId", true);
248  // if no electron, cannot produce the preid
249  if (disablePreId_)
250  producePreId_ = false;
251  PtThresholdSavePredId_ = iConfig.getUntrackedParameter<double>("PtThresholdSavePreId", 1.);
252 
253  LogDebug("GoodSeedProducer") << "Seeds for GSF will be produced ";
254 
255  // no disablePreId_ switch here. The collection will be empty if it is true
256  produces<ElectronSeedCollection>(preidgsf_);
257 
258  if (produceCkfseed_) {
259  LogDebug("GoodSeedProducer") << "Seeds for CKF will be produced ";
260  produces<TrajectorySeedCollection>(preidckf_);
261  }
262 
263  if (producePreId_) {
264  LogDebug("GoodSeedProducer") << "PreId debugging information will be produced ";
265 
266  produces<PreIdCollection>(preidname_);
267  if (tracksContainers_.size() == 1) // do not make a value map if more than one input track collection
269  }
270 
271  useQuality_ = iConfig.getParameter<bool>("UseQuality");
273 
274  useTmva_ = iConfig.getUntrackedParameter<bool>("UseTMVA", false);
275 
276  Min_dr_ = iConfig.getParameter<double>("Min_dr");
277 
278  trackerRecHitBuilderName_ = iConfig.getParameter<std::string>("TTRHBuilder");
279 }
280 
281 //
282 // member functions
283 //
284 
285 // ------------ method called to produce the data ------------
287  LogDebug("GoodSeedProducer") << "START event: " << iEvent.id().event() << " in run " << iEvent.id().run();
288  //Create empty output collections
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>>();
293  edm::ValueMap<reco::PreIdRef>::Filler mapFiller(*preIdMap_p);
294 
295  std::unique_ptr<TrajectoryFitter> fitter;
296  std::unique_ptr<TrajectorySmoother> smoother;
297 
298  //Tracking Tools
299  if (!disablePreId_) {
300  auto const& aFitter = &iSetup.getData(fitterToken_);
301  auto const& aSmoother = &iSetup.getData(smootherToken_);
302 
303  smoother.reset(aSmoother->clone());
304  fitter = aFitter->clone();
305  auto const& theTrackerRecHitBuilder = &iSetup.getData(trackerRecHitBuilderToken_);
306  hitCloner = static_cast<TkTransientTrackingRecHitBuilder const*>(theTrackerRecHitBuilder)->cloner();
307  fitter->setHitCloner(&hitCloner);
308  smoother->setHitCloner(&hitCloner);
309  }
310 
311  // clear temporary maps
312  refMap_.clear();
313 
314  //Magnetic Field
315  auto const& magneticField = &iSetup.getData(magneticFieldToken_);
316 
317  //Handle input collections
318  //ECAL clusters
319  Handle<PFClusterCollection> theECPfClustCollection;
320  iEvent.getByToken(pfCLusTagECLabel_, theECPfClustCollection);
321 
322  vector<PFCluster const*> basClus;
323  for (auto const& klus : *theECPfClustCollection.product()) {
324  if (klus.correctedEnergy() > clusThreshold_)
325  basClus.push_back(&klus);
326  }
327 
328  //HCAL clusters
329  Handle<PFClusterCollection> theHCPfClustCollection;
330  iEvent.getByToken(pfCLusTagHCLabel_, theHCPfClustCollection);
331 
332  //PS clusters
333  Handle<PFClusterCollection> thePSPfClustCollection;
334  iEvent.getByToken(pfCLusTagPSLabel_, thePSPfClustCollection);
335 
336  //Vector of track collections
337  for (unsigned int istr = 0; istr < tracksContainers_.size(); ++istr) {
338  //Track collection
339  Handle<TrackCollection> tkRefCollection;
340  iEvent.getByToken(tracksContainers_[istr], tkRefCollection);
341  const TrackCollection& Tk = *(tkRefCollection.product());
342 
343  LogDebug("GoodSeedProducer") << "Number of tracks in collection "
344  << "tracksContainers_[" << istr << "] to be analyzed " << Tk.size();
345 
346  //loop over the track collection
347  for (unsigned int i = 0; i < Tk.size(); ++i) {
348  if (useQuality_ && (!(Tk[i].quality(trackQuality_))))
349  continue;
350 
351  reco::PreId myPreId;
352  bool GoodPreId = false;
353 
354  TrackRef trackRef(tkRefCollection, i);
355  math::XYZVectorF tkmom(Tk[i].momentum());
356  auto tketa = tkmom.eta();
357  auto tkpt = std::sqrt(tkmom.perp2());
358  auto const& Seed = (*trackRef->seedRef());
359  if (Seed.nHits() == 0) { //if DeepCore is used in jetCore iteration the seed are hitless, in case skip
360  continue;
361  }
362 
363  if (!disablePreId_) {
364  int ipteta = getBin(Tk[i].eta(), Tk[i].pt());
365  int ibin = ipteta * 9;
366 
367  // FIXME the original code was buggy should be outerMomentum...
368  float oPTOB = 1.f / std::sqrt(Tk[i].innerMomentum().mag2());
369  // float chikfred=Tk[i].normalizedChi2();
370  float nchi = Tk[i].normalizedChi2();
371 
372  int nhitpi = Tk[i].found();
373  float EP = 0;
374 
375  // set track info
376  myPreId.setTrack(trackRef);
377  //CLUSTERS - TRACK matching
378 
379  auto pfmass = 0.0005;
380  auto pfoutenergy = sqrt((pfmass * pfmass) + Tk[i].outerMomentum().Mag2());
381 
383  Tk[i].outerMomentum().x(), Tk[i].outerMomentum().y(), Tk[i].outerMomentum().z(), pfoutenergy);
385  XYZTLorentzVector(Tk[i].outerPosition().x(), Tk[i].outerPosition().y(), Tk[i].outerPosition().z(), 0.);
386 
387  BaseParticlePropagator theOutParticle(RawParticle(mom, pos, Tk[i].charge()), 0, 0, B_.z());
388 
389  theOutParticle.propagateToEcalEntrance(false);
390 
391  float toteta = 1000.f;
392  float totphi = 1000.f;
393  float dr = 1000.f;
394  float EE = 0.f;
395  float feta = 0.f;
396  GlobalPoint ElecTrkEcalPos(0, 0, 0);
397 
398  PFClusterRef clusterRef;
399  math::XYZPoint meanShowerSaved;
400  if (theOutParticle.getSuccess() != 0) {
401  ElecTrkEcalPos = GlobalPoint(theOutParticle.particle().vertex().x(),
402  theOutParticle.particle().vertex().y(),
403  theOutParticle.particle().vertex().z());
404 
405  constexpr float psLim = 2.50746495928f; // std::sinh(1.65f);
406  bool isBelowPS = (ElecTrkEcalPos.z() * ElecTrkEcalPos.z()) > (psLim * psLim) * ElecTrkEcalPos.perp2();
407  // bool isBelowPS=(std::abs(ElecTrkEcalPos.eta())>1.65f);
408 
409  unsigned clusCounter = 0;
410  float max_ee = 0;
411  for (auto aClus : basClus) {
412  float tmp_ep = float(aClus->correctedEnergy()) * oPTOB;
413  if ((tmp_ep < minEp_) | (tmp_ep > maxEp_)) {
414  ++clusCounter;
415  continue;
416  }
417 
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;
421 
422  float etarec = meanShower.eta();
423  float phirec = meanShower.phi();
424 
425  float tmp_phi = std::abs(aClus->positionREP().phi() - phirec);
426  if (tmp_phi > float(TMath::Pi()))
427  tmp_phi -= float(TMath::TwoPi());
428 
429  float tmp_dr = std::sqrt(std::pow(tmp_phi, 2.f) + std::pow(aClus->positionREP().eta() - etarec, 2.f));
430 
431  if (tmp_dr < dr) {
432  dr = tmp_dr;
433  if (dr < Min_dr_) { // find the most closest and energetic ECAL cluster
434  if (aClus->correctedEnergy() > max_ee) {
435  toteta = aClus->positionREP().eta() - etarec;
436  totphi = tmp_phi;
437  EP = tmp_ep;
438  EE = aClus->correctedEnergy();
439  feta = aClus->positionREP().eta();
440  clusterRef = PFClusterRef(theECPfClustCollection, clusCounter);
441  meanShowerSaved = meanShower;
442  }
443  }
444  }
445  ++clusCounter;
446  }
447  }
448  float trk_ecalDeta_ = fabs(toteta);
449  float trk_ecalDphi_ = fabs(totphi);
450 
451  //Resolution maps
452  auto ecaletares = resMapEtaECAL_->GetBinContent(resMapEtaECAL_->FindBin(feta, EE));
453  auto ecalphires = resMapPhiECAL_->GetBinContent(resMapPhiECAL_->FindBin(feta, EE));
454 
455  //geomatrical compatibility
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);
459 
460  //Matching criteria
461  float eta_cut = thr[ibin + 0];
462  float phi_cut = thr[ibin + 1];
463  float ep_cutmin = thr[ibin + 2];
464  bool GoodMatching =
465  ((trk_ecalDeta_ < eta_cut) && (trk_ecalDphi_ < phi_cut) && (EP > ep_cutmin) && (nhitpi > 10));
466 
467  bool EcalMatching = GoodMatching;
468 
469  if (tkpt > maxPt_)
470  GoodMatching = true;
471  if (tkpt < minPt_)
472  GoodMatching = false;
473 
474  math::XYZPoint myPoint(ElecTrkEcalPos.x(), ElecTrkEcalPos.y(), ElecTrkEcalPos.z());
476  clusterRef, myPoint, meanShowerSaved, std::abs(toteta), std::abs(totphi), chieta, chiphi, chichi, EP);
477  myPreId.setECALMatching(EcalMatching);
478 
479  bool GoodRange = ((std::abs(tketa) < maxEta_) & (tkpt > minPt_));
480  //KF FILTERING FOR UNMATCHED EVENTS
481  int hit1max = int(thr[ibin + 3]);
482  float chiredmin = thr[ibin + 4];
483  bool GoodKFFiltering = ((nchi > chiredmin) | (nhitpi < hit1max));
484 
485  myPreId.setTrackFiltering(GoodKFFiltering);
486 
487  bool GoodTkId = false;
488 
489  if ((!GoodMatching) && (GoodKFFiltering) && (GoodRange)) {
490  chired = 1000;
491  chiRatio = 1000;
492  dpt = 0;
493  nhit = nhitpi;
494  chikfred = nchi;
495  trk_ecalDeta = trk_ecalDeta_;
496  trk_ecalDphi = trk_ecalDphi_;
497 
499  for (auto const& hit : Tk[i].recHits())
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());
504  GlobalTrajectoryParameters gtps(gp, gv, theTrack.charge(), &*magneticField);
505  TrajectoryStateOnSurface tsos(gtps, theTrack.innerStateCovariance(), *tmp[0]->surface());
506  Trajectory&& FitTjs = fitter->fitOne(Seed, tmp, tsos);
507 
508  if (FitTjs.isValid()) {
509  Trajectory&& SmooTjs = smoother->trajectory(FitTjs);
510  if (SmooTjs.isValid()) {
511  //Track refitted with electron hypothesis
512 
513  float pt_out = SmooTjs.firstMeasurement().updatedState().globalMomentum().perp();
514  float pt_in = SmooTjs.lastMeasurement().updatedState().globalMomentum().perp();
515  dpt = (pt_in > 0) ? fabs(pt_out - pt_in) / pt_in : 0.;
516  // the following is simply the number of degrees of freedom
517  chiRatio = SmooTjs.chiSquared() / Tk[i].chi2();
519  }
520  }
521 
522  //TMVA Analysis
523  if (useTmva_) {
524  float vars[10] = {nhit, chikfred, dpt, EP, chiRatio, chired, trk_ecalDeta, trk_ecalDphi, tkpt, tketa};
525 
526  float Ytmva = globalCache()->gbr[ipteta]->GetClassifier(vars);
527 
528  float BDTcut = thr[ibin + 5];
529  if (Ytmva > BDTcut)
530  GoodTkId = true;
531  myPreId.setMVA(GoodTkId, Ytmva);
533  } else {
534  float chiratiocut = thr[ibin + 6];
535  float gschicut = thr[ibin + 7];
536  float gsptmin = thr[ibin + 8];
537 
538  GoodTkId = ((dpt > gsptmin) & (chired < gschicut) & (chiRatio < chiratiocut));
539  }
540  }
541 
542  GoodPreId = GoodTkId | GoodMatching;
543 
544  myPreId.setFinalDecision(GoodPreId);
545 
546 #ifdef EDM_ML_DEBUG
547  if (GoodPreId)
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";
553 #endif
554 
555  } // end of !disablePreId_
556 
557  if (GoodPreId) {
558  //NEW SEED with n hits
559  ElectronSeed NewSeed(Seed);
560  NewSeed.setCtfTrack(trackRef);
561  output_preid->push_back(NewSeed);
562  } else {
563  if (produceCkfseed_) {
564  output_nopre->push_back(Seed);
565  }
566  }
567  if (producePreId_ && myPreId.pt() > PtThresholdSavePredId_) {
568  // save the index of the PreId object as to be able to create a Ref later
569  refMap_[trackRef] = output_preidinfo->size();
570  output_preidinfo->push_back(myPreId);
571  }
572  } //end loop on track collection
573  } //end loop on the vector of track collections
574 
575  // no disablePreId_ switch, it is simpler to have an empty collection rather than no collection
576  iEvent.put(std::move(output_preid), preidgsf_);
577  if (produceCkfseed_)
578  iEvent.put(std::move(output_nopre), preidckf_);
579  if (producePreId_) {
580  const edm::OrphanHandle<reco::PreIdCollection> preIdRefProd = iEvent.put(std::move(output_preidinfo), preidname_);
581  // now make the Value Map, but only if one input collection
582  if (tracksContainers_.size() == 1) {
583  Handle<TrackCollection> tkRefCollection;
584  iEvent.getByToken(tracksContainers_[0], tkRefCollection);
585  fillPreIdRefValueMap(tkRefCollection, preIdRefProd, mapFiller);
586  mapFiller.fill();
587  iEvent.put(std::move(preIdMap_p), preidname_);
588  }
589  }
590  // clear temporary maps
591  refMap_.clear();
592 }
593 
594 // intialize the cross-thread cache to hold gbr trees and resolution maps
595 namespace goodseedhelpers {
597  // mvas
598  const bool useTmva = conf.getUntrackedParameter<bool>("UseTMVA", false);
599 
600  if (useTmva) {
601  std::array<edm::FileInPath, kMaxWeights> weights = {{edm::FileInPath(conf.getParameter<string>("Weights1")),
602  edm::FileInPath(conf.getParameter<string>("Weights2")),
603  edm::FileInPath(conf.getParameter<string>("Weights3")),
604  edm::FileInPath(conf.getParameter<string>("Weights4")),
605  edm::FileInPath(conf.getParameter<string>("Weights5")),
606  edm::FileInPath(conf.getParameter<string>("Weights6")),
607  edm::FileInPath(conf.getParameter<string>("Weights7")),
608  edm::FileInPath(conf.getParameter<string>("Weights8")),
609  edm::FileInPath(conf.getParameter<string>("Weights9"))}};
610 
611  for (UInt_t j = 0; j < gbr.size(); ++j) {
613  }
614  }
615  }
616 } // namespace goodseedhelpers
617 
618 // ------------ method called once each job just before starting event loop ------------
620  //Magnetic Field
622  B_ = magneticField->inTesla(GlobalPoint(0, 0, 0));
623 
624  pfTransformer_ = std::make_unique<PFTrackTransformer>(B_);
625  pfTransformer_->OnlyProp();
626 
627  //Resolution maps
628  FileInPath ecalEtaMap(conf_.getParameter<string>("EtaMap"));
629  FileInPath ecalPhiMap(conf_.getParameter<string>("PhiMap"));
630  resMapEtaECAL_ = std::make_unique<PFResolutionMap>("ECAL_eta", ecalEtaMap.fullPath().c_str());
631  resMapPhiECAL_ = std::make_unique<PFResolutionMap>("ECAL_phi", ecalPhiMap.fullPath().c_str());
632 
633  //read threshold
634  FileInPath parFile(conf_.getParameter<string>("ThresholdFile"));
635  ifstream ifs(parFile.fullPath().c_str());
636  for (int iy = 0; iy < 81; ++iy)
637  ifs >> thr[iy];
638 }
639 
640 int GoodSeedProducer::getBin(float eta, float pt) {
641  int ie = 0;
642  int ip = 0;
643  if (fabs(eta) < 0.8)
644  ie = 0;
645  else {
646  if (fabs(eta) < 1.479)
647  ie = 1;
648  else
649  ie = 2;
650  }
651  if (pt < 6)
652  ip = 0;
653  else {
654  if (pt < 12)
655  ip = 1;
656  else
657  ip = 2;
658  }
659  int iep = ie * 3 + ip;
660  LogDebug("GoodSeedProducer") << "Track pt =" << pt << " eta=" << eta << " bin=" << iep;
661  return iep;
662 }
663 
665  const edm::OrphanHandle<reco::PreIdCollection>& preidhandle,
667  std::vector<reco::PreIdRef> values;
668 
669  unsigned ntracks = tracks->size();
670  for (unsigned itrack = 0; itrack < ntracks; ++itrack) {
671  reco::TrackRef theTrackRef(tracks, itrack);
672  std::map<reco::TrackRef, unsigned>::const_iterator itcheck = refMap_.find(theTrackRef);
673  if (itcheck == refMap_.end()) {
674  // the track has been early discarded
675  values.push_back(reco::PreIdRef());
676  } else {
677  edm::Ref<reco::PreIdCollection> preIdRef(preidhandle, itcheck->second);
678  values.push_back(preIdRef);
679  // std::cout << " Checking Refs " << (theTrackRef==preIdRef->trackRef()) << std::endl;
680  }
681  }
682  filler.insert(tracks, values.begin(), values.end());
683 }
684 
Vector3DBase
Definition: Vector3DBase.h:8
DDAxes::y
GoodSeedProducer::resMapEtaECAL_
std::unique_ptr< PFResolutionMap > resMapEtaECAL_
Definition: GoodSeedProducer.cc:158
RawParticle
Definition: RawParticle.h:37
mps_fire.i
i
Definition: mps_fire.py:428
edm::ESInputTag
Definition: ESInputTag.h:87
BaseParticlePropagator::propagateToEcalEntrance
bool propagateToEcalEntrance(bool first=true)
Definition: BaseParticlePropagator.cc:450
MessageLogger.h
TwoPi
const double TwoPi
Definition: CosmicMuonParameters.h:19
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
reco::PreId::pt
float pt() const
Definition: PreId.h:80
edm::Handle::product
T const * product() const
Definition: Handle.h:70
ESHandle.h
reco::PreId::setMVA
void setMVA(bool accepted, float mva, unsigned n=0)
Definition: PreId.h:63
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
Trajectory::chiSquared
float chiSquared() const
Definition: Trajectory.h:241
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
GoodSeedProducer::maxPt_
double maxPt_
Definition: GoodSeedProducer.cc:112
GoodSeedProducer
Definition: GoodSeedProducer.cc:68
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
GoodSeedProducer::pfCLusTagPSLabel_
edm::EDGetTokenT< reco::PFClusterCollection > pfCLusTagPSLabel_
Definition: GoodSeedProducer.cc:147
edm::Run
Definition: Run.h:45
GoodSeedProducer::propagatorName_
std::string propagatorName_
Definition: GoodSeedProducer.cc:155
edm::EDGetTokenT< reco::PFClusterCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
GoodSeedProducer::clusThreshold_
double clusThreshold_
Cut on the energy of the clusters.
Definition: GoodSeedProducer.cc:124
GBRForestTools.h
TransientRecHitRecord.h
pos
Definition: PixelAliasList.h:18
GoodSeedProducer::producePreId_
bool producePreId_
Produce the pre-id debugging collection.
Definition: GoodSeedProducer.cc:137
GoodSeedProducer::thr
float thr[150]
vector of thresholds for different bins of eta and pt
Definition: GoodSeedProducer.cc:143
GoodSeedProducer::conf_
edm::ParameterSet conf_
Definition: GoodSeedProducer.cc:146
BaseParticlePropagator.h
GoodSeedProducer::tracksContainers_
std::vector< edm::EDGetTokenT< reco::TrackCollection > > tracksContainers_
Definition: GoodSeedProducer.cc:151
reco::TrackBase::TrackQuality
TrackQuality
track quality
Definition: TrackBase.h:150
EDProducer.h
GoodSeedProducer::smootherName_
std::string smootherName_
Definition: GoodSeedProducer.cc:154
GoodSeedProducer::minEoverP_
double minEoverP_
Definition: GoodSeedProducer.cc:120
GoodSeedProducer::TSOS
TrajectoryStateOnSurface TSOS
Definition: GoodSeedProducer.cc:69
GoodSeedProducer::EcalStripSumE_deltaPhiOverQ_minValue_
double EcalStripSumE_deltaPhiOverQ_minValue_
Definition: GoodSeedProducer.cc:118
GoodSeedProducer::EcalStripSumE_deltaPhiOverQ_maxValue_
double EcalStripSumE_deltaPhiOverQ_maxValue_
Definition: GoodSeedProducer.cc:119
createGBRForest
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)
Definition: GBRForestTools.cc:257
GoodSeedProducer::maxEta_
double maxEta_
Definition: GoodSeedProducer.cc:113
TrajectoryMeasurement::updatedState
TrajectoryStateOnSurface const & updatedState() const
Definition: TrajectoryMeasurement.h:184
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
GoodSeedProducer::maxEp_
double maxEp_
Definition: GoodSeedProducer.cc:128
DDAxes::x
XYZTLorentzVector
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:25
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
vertices_cff.ntracks
ntracks
Definition: vertices_cff.py:34
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
HLT_FULL_cff.magneticField
magneticField
Definition: HLT_FULL_cff.py:348
Basic3DVector::eta
T eta() const
Definition: extBasic3DVector.h:146
reco::PreId
Definition: PreId.h:13
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
GBRForest.h
PFTrackTransformer.h
edm::Handle< reco::TrackCollection >
GoodSeedProducer::preidgsf_
std::string preidgsf_
Name of the Seed(Gsf) Collection.
Definition: GoodSeedProducer.cc:96
GoodSeedProducer::fitterToken_
const edm::ESGetToken< TrajectoryFitter, TrajectoryFitter::Record > fitterToken_
Definition: GoodSeedProducer.cc:161
GoodSeedProducer::chired
float chired
Definition: GoodSeedProducer.cc:172
BaseParticlePropagator
Definition: BaseParticlePropagator.h:82
GoodSeedProducer::useQuality_
bool useQuality_
TRACK QUALITY.
Definition: GoodSeedProducer.cc:168
TkTransientTrackingRecHitBuilder.h
edm::Ref< TrackCollection >
PreId.h
goodseedhelpers::HeavyObjectCache
Definition: GoodSeedProducer.cc:61
quality
const uint32_t *__restrict__ Quality * quality
Definition: CAHitNtupletGeneratorKernelsImpl.h:122
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
GoodSeedProducer::HcalIsolWindow_
double HcalIsolWindow_
Definition: GoodSeedProducer.cc:115
GoodSeedProducer::GoodSeedProducer
GoodSeedProducer(const edm::ParameterSet &, const goodseedhelpers::HeavyObjectCache *)
Definition: GoodSeedProducer.cc:190
edm::FileInPath
Definition: FileInPath.h:61
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
MakerMacros.h
reco::ElectronSeed
Definition: ElectronSeed.h:51
Track.h
goodseedhelpers::HeavyObjectCache::kMaxWeights
constexpr static unsigned int kMaxWeights
Definition: GoodSeedProducer.cc:62
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
GoodSeedProducer::getBin
int getBin(float, float)
Find the bin in pt and eta.
Definition: GoodSeedProducer.cc:640
GoodSeedProducer::nhit
float nhit
VARIABLES NEEDED FOR TMVA.
Definition: GoodSeedProducer.cc:172
vars
vars
Definition: DeepTauId.cc:164
PVValHelper::eta
Definition: PVValidationHelpers.h:70
GoodSeedProducer::produceCkfseed_
bool produceCkfseed_
Produce the Seed for Ckf tracks?
Definition: GoodSeedProducer.cc:131
HLT_FULL_cff.weights
weights
Definition: HLT_FULL_cff.py:99207
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DDAxes::z
GoodSeedProducer::useTmva_
bool useTmva_
USE OF TMVA.
Definition: GoodSeedProducer.cc:177
IdealMagneticFieldRecord.h
GoodSeedProducer::resMapPhiECAL_
std::unique_ptr< PFResolutionMap > resMapPhiECAL_
Definition: GoodSeedProducer.cc:159
PFCluster.h
GoodSeedProducer::trackerRecHitBuilderToken_
const edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > trackerRecHitBuilderToken_
Definition: GoodSeedProducer.cc:163
GoodSeedProducer::maxHoverP_
double maxHoverP_
Definition: GoodSeedProducer.cc:121
TrajectoryFitter.h
GlobalTrajectoryParameters
Definition: GlobalTrajectoryParameters.h:15
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, GlobalTag >
reco::PreId::setECALMatching
void setECALMatching(bool accepted, unsigned n=0)
Definition: PreId.h:60
l1t::PFClusterRef
edm::Ref< l1t::PFClusterCollection > PFClusterRef
Definition: PFCluster.h:74
FileInPath.h
Trajectory::ConstRecHitContainer
TrackingRecHit::ConstRecHitContainer ConstRecHitContainer
Definition: Trajectory.h:41
GoodSeedProducer::B_
math::XYZVector B_
B field.
Definition: GoodSeedProducer.cc:180
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
goodseedhelpers
Abstract.
Definition: GoodSeedProducer.cc:60
runTauDisplay.gp
gp
Definition: runTauDisplay.py:431
GoodSeedProducer::disablePreId_
bool disablePreId_
switch to disable the pre-id
Definition: GoodSeedProducer.cc:134
JetMETHLTOfflineSource_cfi.feta
feta
Definition: JetMETHLTOfflineSource_cfi.py:30
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
edm::Transition
Transition
Definition: Transition.h:12
GoodSeedProducer::beginRun
void beginRun(const edm::Run &run, const edm::EventSetup &) override
Definition: GoodSeedProducer.cc:619
GoodSeedProducer::nHitsInSeed_
int nHitsInSeed_
Number of hits in the seed;.
Definition: GoodSeedProducer.cc:108
Event.h
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:176
deltaR.h
Trajectory::lastMeasurement
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:150
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
GoodSeedProducer::fitterName_
std::string fitterName_
Definition: GoodSeedProducer.cc:153
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
reco::ElectronSeed::setCtfTrack
void setCtfTrack(const CtfTrackRef &)
Set additional info.
Definition: ElectronSeed.cc:39
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
LorentzVector.h
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
goodseedhelpers::HeavyObjectCache::HeavyObjectCache
HeavyObjectCache(const edm::ParameterSet &conf)
Definition: GoodSeedProducer.cc:596
mag2
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
Definition: Basic3DVectorLD.h:124
edm::stream::EDProducer
Definition: EDProducer.h:36
PFResolutionMap.h
MagneticField.h
edm::EventSetup
Definition: EventSetup.h:58
goodseedhelpers::HeavyObjectCache::gbr
std::array< std::unique_ptr< const GBRForest >, kMaxWeights > gbr
Definition: GoodSeedProducer.cc:64
TrajectorySmoother.h
PreIdFwd.h
GoodSeedProducer::pfTransformer_
std::unique_ptr< PFTrackTransformer > pfTransformer_
PFTrackTransformer.
Definition: GoodSeedProducer.cc:105
TrajectorySeedCollection.h
reco::PreId::setTrack
void setTrack(reco::TrackRef trackref)
Definition: PreId.h:31
GoodSeedProducer::initializeGlobalCache
static std::unique_ptr< goodseedhelpers::HeavyObjectCache > initializeGlobalCache(const edm::ParameterSet &conf)
Definition: GoodSeedProducer.cc:74
edm::ESGetToken
Definition: EventSetup.h:48
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PFGeometry.h
PropagationDirection.h
GoodSeedProducer::EcalStripSumE_minClusEnergy_
double EcalStripSumE_minClusEnergy_
Definition: GoodSeedProducer.cc:116
unit
Basic3DVector unit() const
Definition: Basic3DVectorLD.h:162
GoodSeedProducer::pfCLusTagHCLabel_
edm::EDGetTokenT< reco::PFClusterCollection > pfCLusTagHCLabel_
Definition: GoodSeedProducer.cc:149
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
ValueMap.h
GoodSeedProducer::chikfred
float chikfred
Definition: GoodSeedProducer.cc:173
GoodSeedProducer::minEp_
double minEp_
Min and MAx allowed values forEoverP.
Definition: GoodSeedProducer.cc:127
Trajectory.h
TrajectoryStateOnSurface::globalMomentum
GlobalVector globalMomentum() const
Definition: TrajectoryStateOnSurface.h:66
EE
Definition: GlobalHaloAlgo.cc:15
GoodSeedProducer::globalEndJob
static void globalEndJob(goodseedhelpers::HeavyObjectCache const *)
Definition: GoodSeedProducer.cc:78
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
edm::OrphanHandle
Definition: EDProductfwd.h:39
GoodSeedProducer::preidckf_
std::string preidckf_
Name of the Seed(Ckf) Collection.
Definition: GoodSeedProducer.cc:93
TkClonerImpl
Definition: TkClonerImpl.h:12
Trajectory::firstMeasurement
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:166
GoodSeedProducer::pfCLusTagECLabel_
edm::EDGetTokenT< reco::PFClusterCollection > pfCLusTagECLabel_
Definition: GoodSeedProducer.cc:148
GoodSeedProducer::dpt
float dpt
Definition: GoodSeedProducer.cc:172
Trajectory
Definition: Trajectory.h:38
GoodSeedProducer::trajContainers_
std::vector< edm::EDGetTokenT< std::vector< Trajectory > > > trajContainers_
Definition: GoodSeedProducer.cc:150
edm::ValueMap
Definition: ValueMap.h:107
edm::Transition::BeginRun
TrackingComponentsRecord.h
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
GoodSeedProducer::hitCloner
TkClonerImpl hitCloner
Definition: GoodSeedProducer.cc:102
GoodSeedProducer::trackQuality_
reco::TrackBase::TrackQuality trackQuality_
Definition: GoodSeedProducer.cc:169
GoodSeedProducer::trackerRecHitBuilderName_
std::string trackerRecHitBuilderName_
Definition: GoodSeedProducer.cc:156
math::XYZVectorF
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
Definition: Vector3D.h:16
GoodSeedProducer::trk_ecalDphi
float trk_ecalDphi
Definition: GoodSeedProducer.cc:173
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TrajectoryStateTransform.h
reco::PreId::setFinalDecision
void setFinalDecision(bool accepted, unsigned n=0)
Definition: PreId.h:59
GoodSeedProducer::refMap_
std::map< reco::TrackRef, unsigned > refMap_
Map used to create the TrackRef, PreIdRef value map.
Definition: GoodSeedProducer.cc:183
pixelTrack::qualityByName
Quality qualityByName(std::string const &name)
Definition: TrackSoAHeterogeneousT.h:16
triggerMatcherToHLTDebug_cfi.tags
tags
Definition: triggerMatcherToHLTDebug_cfi.py:9
Pi
const double Pi
Definition: CosmicMuonParameters.h:18
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
GoodSeedProducer::smootherToken_
const edm::ESGetToken< TrajectorySmoother, TrajectoryFitter::Record > smootherToken_
Definition: GoodSeedProducer.cc:162
GoodSeedProducer::chiRatio
float chiRatio
Definition: GoodSeedProducer.cc:172
GoodSeedProducer::trk_ecalDeta
float trk_ecalDeta
Definition: GoodSeedProducer.cc:173
GoodSeedProducer::magneticFieldTokenBeginRun_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldTokenBeginRun_
Definition: GoodSeedProducer.cc:165
edm::helper::Filler
Definition: ValueMap.h:22
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
GoodSeedProducer::fillPreIdRefValueMap
void fillPreIdRefValueMap(edm::Handle< reco::TrackCollection > tkhandle, const edm::OrphanHandle< reco::PreIdCollection > &, edm::ValueMap< reco::PreIdRef >::Filler &filler)
Definition: GoodSeedProducer.cc:664
ParameterSet.h
GoodSeedProducer::magneticFieldToken_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
Definition: GoodSeedProducer.cc:164
GoodSeedProducer::minPt_
double minPt_
Minimum transverse momentum and maximum pseudorapidity.
Definition: GoodSeedProducer.cc:111
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
reco::PreId::setTrackProperties
void setTrackProperties(float newchi2, float chi2ratio, float dpt)
Definition: PreId.h:53
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
GoodSeedProducer::preidname_
std::string preidname_
Name of the preid Collection (FB)
Definition: GoodSeedProducer.cc:99
reco::PreId::setECALMatchingProperties
void setECALMatchingProperties(PFClusterRef clusterRef, const math::XYZPoint &ecalpos, const math::XYZPoint &meanShower, float deta, float dphi, float chieta, float chiphi, float chi2, float eop)
Definition: PreId.h:33
GoodSeedProducer::Min_dr_
double Min_dr_
Definition: GoodSeedProducer.cc:174
trklet::Seed
Seed
Definition: Settings.h:49
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
edm::InputTag
Definition: InputTag.h:15
reco::PreId::setTrackFiltering
void setTrackFiltering(bool accepted, unsigned n=0)
Definition: PreId.h:62
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
PV3DBase::perp2
T perp2() const
Definition: PV3DBase.h:68
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:161
Trajectory::isValid
bool isValid() const
Definition: Trajectory.h:257
hit
Definition: SiStripHitEffFromCalibTree.cc:88
ElectronSeed.h
GoodSeedProducer::EcalStripSumE_deltaEta_
double EcalStripSumE_deltaEta_
Definition: GoodSeedProducer.cc:117
GoodSeedProducer::PtThresholdSavePredId_
double PtThresholdSavePredId_
Threshold to save Pre Idinfo.
Definition: GoodSeedProducer.cc:140
GoodSeedProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: GoodSeedProducer.cc:286