CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
LowPtGsfElectronSeedProducer Class Referencefinal

#include <RecoEgamma/EgammaElectronProducers/plugins/LowPtGsfElectronSeedProducer.cc>

Inheritance diagram for LowPtGsfElectronSeedProducer:
edm::stream::EDProducer< edm::GlobalCache< lowptgsfeleseed::HeavyObjectCache > >

Public Types

using TrackIndxMap = std::unordered_map< reco::TrackRef::key_type, size_t >
 
- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< lowptgsfeleseed::HeavyObjectCache > >
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Public Member Functions

 LowPtGsfElectronSeedProducer (const edm::ParameterSet &, const lowptgsfeleseed::HeavyObjectCache *)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< lowptgsfeleseed::HeavyObjectCache > >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 
static void globalEndJob (lowptgsfeleseed::HeavyObjectCache const *)
 
static std::unique_ptr< lowptgsfeleseed::HeavyObjectCacheinitializeGlobalCache (const edm::ParameterSet &conf)
 

Private Member Functions

bool decision (const reco::PFRecTrackRef &pfTrackRef, reco::PreId &ecal, reco::PreId &hcal, double rho, const reco::BeamSpot &spot, noZS::EcalClusterLazyTools &ecalTools)
 
bool decision (const reco::TrackRef &kfTrackRef, reco::PreId &ecal, reco::PreId &hcal, double rho, const reco::BeamSpot &spot, noZS::EcalClusterLazyTools &ecalTools)
 
template<typename CollType >
void fillPreIdRefValueMap (edm::Handle< CollType > tracksHandle, const TrackIndxMap &trksToPreIdIndx, const edm::OrphanHandle< reco::PreIdCollection > &preIdHandle, edm::ValueMap< reco::PreIdRef >::Filler &filler)
 
reco::TrackRef getBaseRef (edm::Handle< std::vector< reco::Track > > handle, int idx) const
 
reco::TrackRef getBaseRef (edm::Handle< std::vector< reco::PFRecTrack > > handle, int idx) const
 
bool lightGsfTracking (reco::PreId &, const reco::TrackRef &, const reco::ElectronSeed &)
 
template<typename T >
void loop (const edm::Handle< std::vector< T > > &handle, edm::Handle< reco::PFClusterCollection > &hcalClusters, reco::ElectronSeedCollection &seeds, reco::PreIdCollection &ecalPreIds, reco::PreIdCollection &hcalPreIds, TrackIndxMap &trksToPreIdIndx, edm::Event &, const edm::EventSetup &)
 
void propagateTrackToCalo (const reco::PFRecTrackRef &pfTrackRef, const edm::Handle< reco::PFClusterCollection > &ecalClusters, const edm::Handle< reco::PFClusterCollection > &hcalClusters, std::vector< int > &matchedEcalClusters, std::vector< int > &matchedHcalClusters, reco::PreId &ecalPreId, reco::PreId &hcalPreId)
 
void propagateTrackToCalo (const reco::PFRecTrackRef &pfTrackRef, const edm::Handle< reco::PFClusterCollection > &clusters, std::vector< int > &matchedClusters, reco::PreId &preId, bool ecal)
 
void propagateTrackToCalo (const reco::TrackRef &pfTrack, const edm::Handle< reco::PFClusterCollection > &ecalClusters, const edm::Handle< reco::PFClusterCollection > &hcalClusters, std::vector< int > &matchedEcalClusters, std::vector< int > &matchedHcalClusters, reco::PreId &ecalPreId, reco::PreId &hcalPreId)
 

Private Attributes

const edm::EDGetTokenT< reco::BeamSpotbeamSpot_
 
const edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecordbuilderToken_
 
const edm::EDGetTokenT< EcalRecHitCollectionebRecHits_
 
const edm::EDGetTokenT< reco::PFClusterCollectionecalClusters_
 
const noZS::EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
 
const edm::EDGetTokenT< EcalRecHitCollectioneeRecHits_
 
edm::ESHandle< MagneticFieldfield_
 
std::unique_ptr< TrajectoryFitterfitterPtr_
 
edm::EDGetTokenT< reco::PFClusterCollectionhcalClusters_
 
edm::EDGetTokenT< reco::TrackCollectionkfTracks_
 
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecordmagToken_
 
const double maxPtThreshold_
 
const double minPtThreshold_
 
const bool passThrough_
 
edm::EDGetTokenT< reco::PFRecTrackCollectionpfTracks_
 
const edm::EDGetTokenT< double > rho_
 
std::unique_ptr< TrajectorySmoothersmootherPtr_
 
const edm::ESGetToken< TrajectoryFitter, TrajectoryFitter::RecordtrajectoryFitterToken_
 
const edm::ESGetToken< TrajectorySmoother, TrajectoryFitter::RecordtrajectorySmootherToken_
 
const bool usePfTracks_
 

Static Private Attributes

static constexpr double boundary_ = 2.50746495928 * 2.50746495928
 
static constexpr double mass_ = 0.000511 * 0.000511
 

Detailed Description

Description: EDProducer of ElectronSeed objects Implementation: <Notes on="" implementation>="">

Definition at line 57 of file LowPtGsfElectronSeedProducer.cc.

Member Typedef Documentation

◆ TrackIndxMap

Definition at line 60 of file LowPtGsfElectronSeedProducer.cc.

Constructor & Destructor Documentation

◆ LowPtGsfElectronSeedProducer()

LowPtGsfElectronSeedProducer::LowPtGsfElectronSeedProducer ( const edm::ParameterSet conf,
const lowptgsfeleseed::HeavyObjectCache  
)
explicit

Definition at line 169 of file LowPtGsfElectronSeedProducer.cc.

References edm::ParameterSet::getParameter().

171  : field_(),
172  fitterPtr_(),
173  smootherPtr_(),
174  kfTracks_(),
175  pfTracks_(),
176  ecalClusters_{consumes(conf.getParameter<edm::InputTag>("ecalClusters"))},
177  hcalClusters_(),
178  ebRecHits_{consumes(conf.getParameter<edm::InputTag>("EBRecHits"))},
179  eeRecHits_{consumes(conf.getParameter<edm::InputTag>("EERecHits"))},
180  rho_(consumes(conf.getParameter<edm::InputTag>("rho"))),
181  beamSpot_(consumes(conf.getParameter<edm::InputTag>("BeamSpot"))),
184  builderToken_{esConsumes(conf.getParameter<edm::ESInputTag>("TTRHBuilder"))},
186  ecalClusterToolsESGetTokens_{consumesCollector()},
187  passThrough_(conf.getParameter<bool>("PassThrough")),
188  usePfTracks_(conf.getParameter<bool>("UsePfTracks")),
189  minPtThreshold_(conf.getParameter<double>("MinPtThreshold")),
190  maxPtThreshold_(conf.getParameter<double>("MaxPtThreshold")) {
191  if (usePfTracks_) {
192  pfTracks_ = consumes(conf.getParameter<edm::InputTag>("pfTracks"));
193  hcalClusters_ = consumes(conf.getParameter<edm::InputTag>("hcalClusters"));
194  }
195  kfTracks_ = consumes(conf.getParameter<edm::InputTag>("tracks"));
196 
197  produces<reco::ElectronSeedCollection>();
198  produces<reco::PreIdCollection>();
199  produces<reco::PreIdCollection>("HCAL");
200  produces<edm::ValueMap<reco::PreIdRef> >(); // indexed by edm::Ref<ElectronSeed>.index()
201 }
edm::ESHandle< MagneticField > field_
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::unique_ptr< TrajectorySmoother > smootherPtr_
const edm::EDGetTokenT< reco::PFClusterCollection > ecalClusters_
edm::EDGetTokenT< reco::PFClusterCollection > hcalClusters_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magToken_
const edm::ESGetToken< TrajectorySmoother, TrajectoryFitter::Record > trajectorySmootherToken_
const edm::EDGetTokenT< reco::BeamSpot > beamSpot_
const edm::ESGetToken< TrajectoryFitter, TrajectoryFitter::Record > trajectoryFitterToken_
const noZS::EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
edm::EDGetTokenT< reco::TrackCollection > kfTracks_
const edm::EDGetTokenT< EcalRecHitCollection > ebRecHits_
const edm::EDGetTokenT< EcalRecHitCollection > eeRecHits_
const edm::EDGetTokenT< double > rho_
edm::EDGetTokenT< reco::PFRecTrackCollection > pfTracks_
const edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > builderToken_
std::unique_ptr< TrajectoryFitter > fitterPtr_

Member Function Documentation

◆ decision() [1/2]

bool LowPtGsfElectronSeedProducer::decision ( const reco::PFRecTrackRef pfTrackRef,
reco::PreId ecal,
reco::PreId hcal,
double  rho,
const reco::BeamSpot spot,
noZS::EcalClusterLazyTools ecalTools 
)
private

Definition at line 593 of file LowPtGsfElectronSeedProducer.cc.

References maxPtThreshold_, Skims_PA_cff::name, passThrough_, mps_fire::result, and rho.

Referenced by loop().

598  {
599  bool result = false;
600  for (auto& name : globalCache()->modelNames()) {
601  result |= globalCache()->eval(name, ecalPreId, hcalPreId, rho, spot, ecalTools);
602  }
603  return passThrough_ || (pfTrackRef->trackRef()->pt() > maxPtThreshold_) || result;
604 }

◆ decision() [2/2]

bool LowPtGsfElectronSeedProducer::decision ( const reco::TrackRef kfTrackRef,
reco::PreId ecal,
reco::PreId hcal,
double  rho,
const reco::BeamSpot spot,
noZS::EcalClusterLazyTools ecalTools 
)
private

Definition at line 608 of file LowPtGsfElectronSeedProducer.cc.

References passThrough_.

613  {
614  // No implementation currently
615  return passThrough_;
616 }

◆ fillDescriptions()

void LowPtGsfElectronSeedProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 641 of file LowPtGsfElectronSeedProducer.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and ProducerED_cfi::InputTag.

641  {
643  desc.add<edm::InputTag>("tracks", edm::InputTag("generalTracks"));
644  desc.add<edm::InputTag>("pfTracks", edm::InputTag("lowPtGsfElePfTracks"));
645  desc.add<edm::InputTag>("ecalClusters", edm::InputTag("particleFlowClusterECAL"));
646  desc.add<edm::InputTag>("hcalClusters", edm::InputTag("particleFlowClusterHCAL"));
647  desc.add<edm::InputTag>("EBRecHits", edm::InputTag("ecalRecHit", "EcalRecHitsEB"));
648  desc.add<edm::InputTag>("EERecHits", edm::InputTag("ecalRecHit", "EcalRecHitsEE"));
649  desc.add<edm::InputTag>("rho", edm::InputTag("fixedGridRhoFastjetAllTmp"));
650  desc.add<edm::InputTag>("BeamSpot", edm::InputTag("offlineBeamSpot"));
651  desc.add<edm::ESInputTag>("Fitter", edm::ESInputTag{"", "GsfTrajectoryFitter_forPreId"});
652  desc.add<edm::ESInputTag>("Smoother", edm::ESInputTag{"", "GsfTrajectorySmoother_forPreId"});
653  desc.add<edm::ESInputTag>("TTRHBuilder", edm::ESInputTag{"", "WithAngleAndTemplate"});
654  desc.add<std::vector<std::string> >("ModelNames", {});
655  desc.add<std::vector<std::string> >("ModelWeights", {});
656  desc.add<std::vector<double> >("ModelThresholds", {});
657  desc.add<bool>("PassThrough", false);
658  desc.add<bool>("UsePfTracks", true);
659  desc.add<double>("MinPtThreshold", 1.0);
660  desc.add<double>("MaxPtThreshold", 15.);
661  descriptions.add("lowPtGsfElectronSeeds", desc);
662 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ fillPreIdRefValueMap()

template<typename CollType >
void LowPtGsfElectronSeedProducer::fillPreIdRefValueMap ( edm::Handle< CollType >  tracksHandle,
const TrackIndxMap trksToPreIdIndx,
const edm::OrphanHandle< reco::PreIdCollection > &  preIdHandle,
edm::ValueMap< reco::PreIdRef >::Filler &  filler 
)
private

Definition at line 619 of file LowPtGsfElectronSeedProducer.cc.

References trigObjTnPSource_cfi::filler, edm::Ref< C, T, F >::index(), vertices_cff::ntracks, and contentValuesCheck::values.

Referenced by produce().

622  {
623  std::vector<reco::PreIdRef> values;
624 
625  unsigned ntracks = tracksHandle->size();
626  for (unsigned itrack = 0; itrack < ntracks; ++itrack) {
627  edm::Ref<CollType> trackRef(tracksHandle, itrack);
628  auto preIdRefIt = trksToPreIdIndx.find(trackRef.index());
629  if (preIdRefIt == trksToPreIdIndx.end()) {
630  values.push_back(reco::PreIdRef());
631  } else {
632  edm::Ref<reco::PreIdCollection> preIdRef(preIdHandle, preIdRefIt->second);
633  values.push_back(preIdRef);
634  }
635  }
636  filler.insert(tracksHandle, values.begin(), values.end());
637 }

◆ getBaseRef() [1/2]

reco::TrackRef LowPtGsfElectronSeedProducer::getBaseRef ( edm::Handle< std::vector< reco::Track > >  handle,
int  idx 
) const
private

Definition at line 272 of file LowPtGsfElectronSeedProducer.cc.

References patZpeak::handle, and heavyIonCSV_trainingSettings::idx.

Referenced by loop().

272  {
273  return reco::TrackRef(handle, idx);
274 }
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20

◆ getBaseRef() [2/2]

reco::TrackRef LowPtGsfElectronSeedProducer::getBaseRef ( edm::Handle< std::vector< reco::PFRecTrack > >  handle,
int  idx 
) const
private

Definition at line 276 of file LowPtGsfElectronSeedProducer.cc.

References patZpeak::handle, and heavyIonCSV_trainingSettings::idx.

277  {
278  return reco::PFRecTrackRef(handle, idx)->trackRef();
279 }
edm::Ref< PFRecTrackCollection > PFRecTrackRef
persistent reference to PFRecTrack objects
Definition: PFRecTrackFwd.h:15

◆ globalEndJob()

static void LowPtGsfElectronSeedProducer::globalEndJob ( lowptgsfeleseed::HeavyObjectCache const *  )
inlinestatic

Definition at line 67 of file LowPtGsfElectronSeedProducer.cc.

67 {}

◆ initializeGlobalCache()

static std::unique_ptr<lowptgsfeleseed::HeavyObjectCache> LowPtGsfElectronSeedProducer::initializeGlobalCache ( const edm::ParameterSet conf)
inlinestatic

Definition at line 63 of file LowPtGsfElectronSeedProducer.cc.

63  {
64  return std::make_unique<lowptgsfeleseed::HeavyObjectCache>(lowptgsfeleseed::HeavyObjectCache(conf));
65  }

◆ lightGsfTracking()

bool LowPtGsfElectronSeedProducer::lightGsfTracking ( reco::PreId preId,
const reco::TrackRef trackRef,
const reco::ElectronSeed seed 
)
private

Definition at line 555 of file LowPtGsfElectronSeedProducer.cc.

References Trajectory::chiSquared(), field_, Trajectory::firstMeasurement(), fitterPtr_, TrajectoryStateOnSurface::globalMomentum(), runTauDisplay::gp, hfClusterShapes_cfi::hits, Trajectory::isValid(), Trajectory::lastMeasurement(), PV3DBase< T, PVType, FrameType >::perp(), fileCollector::seed, reco::PreId::setTrackProperties(), smootherPtr_, and TrajectoryMeasurement::updatedState().

Referenced by loop().

557  {
559  for (unsigned int ihit = 0; ihit < trackRef->recHitsSize(); ++ihit) {
560  hits.push_back(trackRef->recHit(ihit)->cloneSH());
561  }
562 
563  GlobalVector gv(trackRef->innerMomentum().x(), trackRef->innerMomentum().y(), trackRef->innerMomentum().z());
564  GlobalPoint gp(trackRef->innerPosition().x(), trackRef->innerPosition().y(), trackRef->innerPosition().z());
565 
566  GlobalTrajectoryParameters gtps(gp, gv, trackRef->charge(), &*field_);
567 
568  TrajectoryStateOnSurface tsos(gtps, trackRef->innerStateCovariance(), *hits[0]->surface());
569 
570  // Track fitted and smoothed under electron hypothesis
571  Trajectory traj1 = fitterPtr_->fitOne(seed, hits, tsos);
572  if (!traj1.isValid()) {
573  return false;
574  }
575  Trajectory traj2 = smootherPtr_->trajectory(traj1);
576  if (!traj2.isValid()) {
577  return false;
578  }
579 
580  // Set PreId content
581  float chi2Ratio = trackRef->chi2() > 0. ? traj2.chiSquared() / trackRef->chi2() : -1.;
582  float gsfReducedChi2 = chi2Ratio > -1. ? chi2Ratio * trackRef->normalizedChi2() : -1.;
583  float ptOut = traj2.firstMeasurement().updatedState().globalMomentum().perp();
584  float ptIn = traj2.lastMeasurement().updatedState().globalMomentum().perp();
585  float gsfDpt = (ptIn > 0) ? fabs(ptOut - ptIn) / ptIn : 0.;
586  preId.setTrackProperties(gsfReducedChi2, chi2Ratio, gsfDpt);
587 
588  return true;
589 }
edm::ESHandle< MagneticField > field_
std::unique_ptr< TrajectorySmoother > smootherPtr_
T perp() const
Definition: PV3DBase.h:69
bool isValid() const
Definition: Trajectory.h:257
float chiSquared() const
Definition: Trajectory.h:241
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:150
GlobalVector globalMomentum() const
TrajectoryStateOnSurface const & updatedState() const
TrackingRecHit::ConstRecHitContainer ConstRecHitContainer
Definition: Trajectory.h:41
void setTrackProperties(float newchi2, float chi2ratio, float dpt)
Definition: PreId.h:53
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:166
std::unique_ptr< TrajectoryFitter > fitterPtr_

◆ loop()

template<typename T >
void LowPtGsfElectronSeedProducer::loop ( const edm::Handle< std::vector< T > > &  handle,
edm::Handle< reco::PFClusterCollection > &  hcalClusters,
reco::ElectronSeedCollection seeds,
reco::PreIdCollection ecalPreIds,
reco::PreIdCollection hcalPreIds,
TrackIndxMap trksToPreIdIndx,
edm::Event event,
const edm::EventSetup setup 
)
private

Definition at line 284 of file LowPtGsfElectronSeedProducer.cc.

References beamSpot_, builderToken_, runTheMatrix::const, decision(), ebRecHits_, RecoEcal_cff::ecalClusters, ecalClusters_, ecalClusterToolsESGetTokens_, eeRecHits_, fitterPtr_, EcalClusterLazyToolsBase::ESGetTokens::get(), getBaseRef(), patZpeak::handle, lowPtGsfElectronSeeds_cfi::hcalClusters, edm::Ref< C, T, F >::index(), lightGsfTracking(), minPtThreshold_, passThrough_, propagateTrackToCalo(), reco::TrackBase::qualityByName(), mps_fire::result, rho, rho_, fileCollector::seed, DetachedQuadStep_cff::seeds, reco::PreId::setTrack(), singleTopDQM_cfi::setup, smootherPtr_, trajectoryFitterToken_, and trajectorySmootherToken_.

Referenced by produce().

291  {
292  // Pileup
293  auto const& rho = event.get(rho_);
294 
295  // Beam spot
296  auto const& spot = event.get(beamSpot_);
297 
298  // Track fitter
299  fitterPtr_ = setup.getData(trajectoryFitterToken_).clone();
300 
301  // Track smoother
302  smootherPtr_.reset(setup.getData(trajectorySmootherToken_).clone());
303 
304  // RecHit cloner
305  TkClonerImpl hitCloner = static_cast<TkTransientTrackingRecHitBuilder const&>(setup.getData(builderToken_)).cloner();
306  fitterPtr_->setHitCloner(&hitCloner);
307  smootherPtr_->setHitCloner(&hitCloner);
308 
309  // ECAL clusters
310  auto ecalClusters = event.getHandle(ecalClusters_);
311 
312  // Utility to access to shower shape vars
314 
315  // Ensure each cluster is only matched once to a track
316  std::vector<int> matchedEcalClusters;
317  std::vector<int> matchedHcalClusters;
318 
319  // Reserve
320  seeds.reserve(handle->size());
321  ecalPreIds.reserve(handle->size());
322  hcalPreIds.reserve(handle->size());
323 
324  // Iterate through (PF or KF) tracks
325  for (unsigned int itrk = 0; itrk < handle.product()->size(); itrk++) {
326  edm::Ref<std::vector<T> > templatedRef(handle, itrk); // TrackRef or PFRecTrackRef
327  reco::TrackRef trackRef = getBaseRef(handle, itrk);
328 
329  if (!(trackRef->quality(reco::TrackBase::qualityByName("highPurity")))) {
330  continue;
331  }
332  if (!passThrough_ && (trackRef->pt() < minPtThreshold_)) {
333  continue;
334  }
335 
336  // Create ElectronSeed
337  reco::ElectronSeed seed(*(trackRef->seedRef()));
338  if (seed.nHits() == 0) { //if DeepCore is used in jetCore iteration the seed are hitless, in case skip
339  continue;
340  }
341  seed.setCtfTrack(trackRef);
342 
343  // Create PreIds
344  unsigned int nModels = globalCache()->modelNames().size();
345  reco::PreId ecalPreId(nModels);
346  reco::PreId hcalPreId(nModels);
347 
348  // Add track ref to PreId
349  ecalPreId.setTrack(trackRef);
350  hcalPreId.setTrack(trackRef);
351 
352  // Add Track-Calo matching variables to PreIds
354  templatedRef, ecalClusters, hcalClusters, matchedEcalClusters, matchedHcalClusters, ecalPreId, hcalPreId);
355 
356  // Add variables related to GSF tracks to PreId
357  lightGsfTracking(ecalPreId, trackRef, seed);
358 
359  // Decision based on BDT
360  bool result = decision(templatedRef, ecalPreId, hcalPreId, rho, spot, ecalTools);
361 
362  // If fails BDT, do not store seed
363  if (!result) {
364  continue;
365  }
366 
367  // Store PreId
368  ecalPreIds.push_back(ecalPreId);
369  hcalPreIds.push_back(hcalPreId);
370  trksToPreIdIndx[trackRef.index()] = ecalPreIds.size() - 1;
371 
372  // Store ElectronSeed and corresponding edm::Ref<PreId>.index()
373  seeds.push_back(seed);
374  }
375 }
std::unique_ptr< TrajectorySmoother > smootherPtr_
void propagateTrackToCalo(const reco::PFRecTrackRef &pfTrackRef, const edm::Handle< reco::PFClusterCollection > &ecalClusters, const edm::Handle< reco::PFClusterCollection > &hcalClusters, std::vector< int > &matchedEcalClusters, std::vector< int > &matchedHcalClusters, reco::PreId &ecalPreId, reco::PreId &hcalPreId)
bool decision(const reco::PFRecTrackRef &pfTrackRef, reco::PreId &ecal, reco::PreId &hcal, double rho, const reco::BeamSpot &spot, noZS::EcalClusterLazyTools &ecalTools)
bool lightGsfTracking(reco::PreId &, const reco::TrackRef &, const reco::ElectronSeed &)
const edm::EDGetTokenT< reco::PFClusterCollection > ecalClusters_
const edm::ESGetToken< TrajectorySmoother, TrajectoryFitter::Record > trajectorySmootherToken_
const edm::EDGetTokenT< reco::BeamSpot > beamSpot_
const edm::ESGetToken< TrajectoryFitter, TrajectoryFitter::Record > trajectoryFitterToken_
const noZS::EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
ESData get(edm::EventSetup const &eventSetup) const
const edm::EDGetTokenT< EcalRecHitCollection > ebRecHits_
const edm::EDGetTokenT< EcalRecHitCollection > eeRecHits_
const edm::EDGetTokenT< double > rho_
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:126
key_type index() const
Definition: Ref.h:253
const edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > builderToken_
reco::TrackRef getBaseRef(edm::Handle< std::vector< reco::Track > > handle, int idx) const
std::unique_ptr< TrajectoryFitter > fitterPtr_
Definition: event.py:1

◆ produce()

void LowPtGsfElectronSeedProducer::produce ( edm::Event event,
const edm::EventSetup setup 
)
override

Definition at line 205 of file LowPtGsfElectronSeedProducer.cc.

References Exception, field_, fillPreIdRefValueMap(), lowPtGsfElectronSeeds_cfi::hcalClusters, hcalClusters_, edm::HandleBase::id(), kfTracks_, loop(), magToken_, eostools::move(), lowPtGsfElectronSeeds_cfi::pfTracks, pfTracks_, DetachedQuadStep_cff::seeds, singleTopDQM_cfi::setup, and usePfTracks_.

205  {
206  field_ = setup.getHandle(magToken_);
207  // Products
208  auto seeds = std::make_unique<reco::ElectronSeedCollection>();
209  auto ecalPreIds = std::make_unique<reco::PreIdCollection>();
210  auto hcalPreIds = std::make_unique<reco::PreIdCollection>();
211 
212  const edm::RefProd<reco::PreIdCollection> preIdsRefProd = event.getRefBeforePut<reco::PreIdCollection>();
213 
214  // HCAL clusters (only used with PF tracks)
216 
217  //we always need kftracks as we link the preids to them
219  event.getByToken(kfTracks_, kfTracks);
220 
221  TrackIndxMap trksToPreIdIndx;
222  if (usePfTracks_) {
224  event.getByToken(pfTracks_, pfTracks);
225  event.getByToken(hcalClusters_, hcalClusters);
226 
227  //check consistency between kfTracks and pfTracks collection
228  for (auto& trk : *pfTracks) {
229  if (trk.trackRef().isNonnull()) {
230  if (trk.trackRef().id() != kfTracks.id()) {
231  throw cms::Exception("ConfigError")
232  << "kfTracks is not the collection that pfTracks was built from, please fix this";
233  }
234  break; //we only need one valid track ref to check this so end the loop
235  }
236  }
237 
238  loop(pfTracks, // PF tracks
239  hcalClusters,
240  *seeds,
241  *ecalPreIds,
242  *hcalPreIds,
243  trksToPreIdIndx,
244  event,
245  setup);
246 
247  } else {
248  loop(kfTracks, // KF tracks
249  hcalClusters,
250  *seeds,
251  *ecalPreIds,
252  *hcalPreIds,
253  trksToPreIdIndx,
254  event,
255  setup);
256  }
257 
258  auto ecalPreIdsHandle = event.put(std::move(ecalPreIds));
259  event.put(std::move(hcalPreIds), "HCAL");
260  event.put(std::move(seeds));
261 
262  auto preIdVMOut = std::make_unique<edm::ValueMap<reco::PreIdRef> >();
263  edm::ValueMap<reco::PreIdRef>::Filler mapFiller(*preIdVMOut);
264  fillPreIdRefValueMap(kfTracks, trksToPreIdIndx, ecalPreIdsHandle, mapFiller);
265  mapFiller.fill();
266  event.put(std::move(preIdVMOut));
267 }
edm::ESHandle< MagneticField > field_
std::vector< reco::PreId > PreIdCollection
Definition: PreIdFwd.h:6
ProductID id() const
Definition: HandleBase.cc:29
edm::EDGetTokenT< reco::PFClusterCollection > hcalClusters_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magToken_
std::unordered_map< reco::TrackRef::key_type, size_t > TrackIndxMap
void loop(const edm::Handle< std::vector< T > > &handle, edm::Handle< reco::PFClusterCollection > &hcalClusters, reco::ElectronSeedCollection &seeds, reco::PreIdCollection &ecalPreIds, reco::PreIdCollection &hcalPreIds, TrackIndxMap &trksToPreIdIndx, edm::Event &, const edm::EventSetup &)
void fillPreIdRefValueMap(edm::Handle< CollType > tracksHandle, const TrackIndxMap &trksToPreIdIndx, const edm::OrphanHandle< reco::PreIdCollection > &preIdHandle, edm::ValueMap< reco::PreIdRef >::Filler &filler)
edm::EDGetTokenT< reco::TrackCollection > kfTracks_
edm::EDGetTokenT< reco::PFRecTrackCollection > pfTracks_
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1

◆ propagateTrackToCalo() [1/3]

void LowPtGsfElectronSeedProducer::propagateTrackToCalo ( const reco::PFRecTrackRef pfTrackRef,
const edm::Handle< reco::PFClusterCollection > &  ecalClusters,
const edm::Handle< reco::PFClusterCollection > &  hcalClusters,
std::vector< int > &  matchedEcalClusters,
std::vector< int > &  matchedHcalClusters,
reco::PreId ecalPreId,
reco::PreId hcalPreId 
)
private

Definition at line 401 of file LowPtGsfElectronSeedProducer.cc.

References RecoEcal_cff::ecalClusters, and lowPtGsfElectronSeeds_cfi::hcalClusters.

Referenced by loop().

407  {
408  propagateTrackToCalo(pfTrackRef, ecalClusters, matchedEcalClusters, ecalPreId, true);
409  propagateTrackToCalo(pfTrackRef, hcalClusters, matchedHcalClusters, hcalPreId, false);
410 }
void propagateTrackToCalo(const reco::PFRecTrackRef &pfTrackRef, const edm::Handle< reco::PFClusterCollection > &ecalClusters, const edm::Handle< reco::PFClusterCollection > &hcalClusters, std::vector< int > &matchedEcalClusters, std::vector< int > &matchedHcalClusters, reco::PreId &ecalPreId, reco::PreId &hcalPreId)

◆ propagateTrackToCalo() [2/3]

void LowPtGsfElectronSeedProducer::propagateTrackToCalo ( const reco::PFRecTrackRef pfTrackRef,
const edm::Handle< reco::PFClusterCollection > &  clusters,
std::vector< int > &  matchedClusters,
reco::PreId preId,
bool  ecal 
)
private

Definition at line 414 of file LowPtGsfElectronSeedProducer.cc.

References bsc_activity_cfg::clusters, reco::deltaPhi(), reco::deltaR2(), SiStripBadComponentsDQMServiceTemplate_cfg::ep, spr::find(), info(), muonTagProbeFilters_cff::matched, point, reco::PreId::setECALMatchingProperties(), and mathSSE::sqrt().

418  {
419  // Store info for PreId
420  struct Info {
422  float dr2min = 1.e6;
423  float deta = 1.e6;
424  float dphi = 1.e6;
425  math::XYZPoint showerPos = math::XYZPoint(0., 0., 0.);
426  } info;
427 
428  // Find closest "seed cluster" to KF track extrapolated to ECAL (or HCAL)
430  if (ecal) {
431  point = pfTrackRef->extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::ECALShowerMax);
432  } else {
433  point = pfTrackRef->extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::HCALEntrance);
434  }
435 
436  if (point.isValid()) {
437  Info info;
438  for (unsigned int iclu = 0; iclu < clusters.product()->size(); iclu++) {
439  if (std::find(matched.begin(), matched.end(), iclu) == matched.end()) {
440  reco::PFClusterRef cluRef(clusters, iclu);
441 
442  // Determine dR squared
443  float dr2 = reco::deltaR2(cluRef->positionREP(), point.positionREP());
444 
445  if (dr2 < info.dr2min) {
446  info.dr2min = dr2;
447  info.cluRef = cluRef;
448  info.deta = cluRef->positionREP().eta() - point.positionREP().eta();
449  info.dphi =
450  reco::deltaPhi(cluRef->positionREP().phi(), point.positionREP().phi()) * pfTrackRef->trackRef()->charge();
451  info.showerPos = point.position();
452  }
453  }
454  }
455 
456  // Set PreId content if match found
457  if (info.dr2min < 1.e5) {
458  float ep = info.cluRef->correctedEnergy() / std::sqrt(pfTrackRef->trackRef()->innerMomentum().mag2());
459  preId.setECALMatchingProperties(info.cluRef,
460  point.position(), // ECAL or HCAL surface
461  info.showerPos, //
462  info.deta,
463  info.dphi,
464  0.f, // chieta
465  0.f, // chiphi
466  pfTrackRef->trackRef()->normalizedChi2(), // chi2
467  ep);
468  }
469 
470  } // clusters
471 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
static const TGPicture * info(bool iBackgroundIsBlack)
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
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
T sqrt(T t)
Definition: SSEVec.h:19
edm::Ref< PFClusterCollection > PFClusterRef
persistent reference to PFCluster objects
Definition: PFClusterFwd.h:15
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5

◆ propagateTrackToCalo() [3/3]

void LowPtGsfElectronSeedProducer::propagateTrackToCalo ( const reco::TrackRef pfTrack,
const edm::Handle< reco::PFClusterCollection > &  ecalClusters,
const edm::Handle< reco::PFClusterCollection > &  hcalClusters,
std::vector< int > &  matchedEcalClusters,
std::vector< int > &  matchedHcalClusters,
reco::PreId ecalPreId,
reco::PreId hcalPreId 
)
private

Definition at line 475 of file LowPtGsfElectronSeedProducer.cc.

References funct::abs(), boundary_, reco::deltaPhi(), reco::deltaR2(), RecoEcal_cff::ecalClusters, hcalRecHitTable_cff::energy, field_, reco::PFCluster::getDepthCorrection(), info(), MagneticField::inTesla(), mass_, point, funct::pow(), BaseParticlePropagator::propagateToEcalEntrance(), reco::PreId::setECALMatchingProperties(), mathSSE::sqrt(), unit(), and RawParticle::z().

482  {
483  // Store info for PreId
484  struct Info {
486  float dr2min = 1.e6;
487  float deta = 1.e6;
488  float dphi = 1.e6;
489  math::XYZPoint showerPos = math::XYZPoint(0., 0., 0.);
490  } info;
491 
492  // Propagate 'electron' to ECAL surface
493  float energy = sqrt(mass_ + kfTrackRef->outerMomentum().Mag2());
495  kfTrackRef->outerMomentum().x(), kfTrackRef->outerMomentum().y(), kfTrackRef->outerMomentum().z(), energy);
497  kfTrackRef->outerPosition().x(), kfTrackRef->outerPosition().y(), kfTrackRef->outerPosition().z(), 0.);
498  math::XYZVector field(field_->inTesla(GlobalPoint(0, 0, 0)));
499  BaseParticlePropagator particle(RawParticle(mom, pos, kfTrackRef->charge()), 0, 0, field.z());
500  particle.propagateToEcalEntrance(false);
501  if (particle.getSuccess() == 0) {
502  return;
503  }
504 
505  // ECAL entry point for track
506  GlobalPoint ecal_pos(
507  particle.particle().vertex().x(), particle.particle().vertex().y(), particle.particle().vertex().z());
508 
509  // Preshower limit
510  bool below_ps = pow(ecal_pos.z(), 2.) > boundary_ * ecal_pos.perp2();
511 
512  // Iterate through ECAL clusters
513  for (unsigned int iclu = 0; iclu < ecalClusters.product()->size(); iclu++) {
514  reco::PFClusterRef cluRef(ecalClusters, iclu);
515 
516  // Correct ecal_pos for shower depth
517  double shower_depth = reco::PFCluster::getDepthCorrection(cluRef->correctedEnergy(), below_ps, false);
518  GlobalPoint showerPos = ecal_pos + GlobalVector(particle.particle().momentum().x(),
519  particle.particle().momentum().y(),
520  particle.particle().momentum().z())
521  .unit() *
522  shower_depth;
523 
524  // Determine dR squared
525  float dr2 = reco::deltaR2(cluRef->positionREP(), showerPos);
526 
527  // Find nearest ECAL cluster
528  if (dr2 < info.dr2min) {
529  info.dr2min = dr2;
530  info.cluRef = cluRef;
531  info.deta = std::abs(cluRef->positionREP().eta() - showerPos.eta());
532  info.dphi = std::abs(reco::deltaPhi(cluRef->positionREP().phi(), showerPos.phi())) * kfTrackRef->charge();
533  info.showerPos = showerPos;
534  }
535  }
536 
537  // Populate PreId object
538  math::XYZPoint point(ecal_pos.x(), ecal_pos.y(), ecal_pos.z());
539 
540  // Set PreId content
541  ecalPreId.setECALMatchingProperties(
542  info.cluRef,
543  point,
544  info.showerPos,
545  info.deta,
546  info.dphi,
547  0.f, // chieta
548  0.f, // chiphi
549  kfTrackRef->normalizedChi2(), // chi2
550  info.cluRef->correctedEnergy() / std::sqrt(kfTrackRef->innerMomentum().mag2())); // E/p
551 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
edm::ESHandle< MagneticField > field_
static const TGPicture * info(bool iBackgroundIsBlack)
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
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
T sqrt(T t)
Definition: SSEVec.h:19
edm::Ref< PFClusterCollection > PFClusterRef
persistent reference to PFCluster objects
Definition: PFClusterFwd.h:15
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double z() const
z of vertex
Definition: RawParticle.h:284
Basic3DVector unit() const
bool propagateToEcalEntrance(bool first=true)
static double getDepthCorrection(double energy, bool isBelowPS=false, bool isHadron=false)
Definition: PFCluster.cc:39
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
Global3DVector GlobalVector
Definition: GlobalVector.h:10
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:25

Member Data Documentation

◆ beamSpot_

const edm::EDGetTokenT<reco::BeamSpot> LowPtGsfElectronSeedProducer::beamSpot_
private

Definition at line 148 of file LowPtGsfElectronSeedProducer.cc.

Referenced by loop().

◆ boundary_

constexpr double LowPtGsfElectronSeedProducer::boundary_ = 2.50746495928 * 2.50746495928
staticprivate

Definition at line 162 of file LowPtGsfElectronSeedProducer.cc.

Referenced by propagateTrackToCalo().

◆ builderToken_

const edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> LowPtGsfElectronSeedProducer::builderToken_
private

Definition at line 152 of file LowPtGsfElectronSeedProducer.cc.

Referenced by loop().

◆ ebRecHits_

const edm::EDGetTokenT<EcalRecHitCollection> LowPtGsfElectronSeedProducer::ebRecHits_
private

Definition at line 145 of file LowPtGsfElectronSeedProducer.cc.

Referenced by loop().

◆ ecalClusters_

const edm::EDGetTokenT<reco::PFClusterCollection> LowPtGsfElectronSeedProducer::ecalClusters_
private

Definition at line 143 of file LowPtGsfElectronSeedProducer.cc.

Referenced by loop().

◆ ecalClusterToolsESGetTokens_

const noZS::EcalClusterLazyTools::ESGetTokens LowPtGsfElectronSeedProducer::ecalClusterToolsESGetTokens_
private

Definition at line 154 of file LowPtGsfElectronSeedProducer.cc.

Referenced by loop().

◆ eeRecHits_

const edm::EDGetTokenT<EcalRecHitCollection> LowPtGsfElectronSeedProducer::eeRecHits_
private

Definition at line 146 of file LowPtGsfElectronSeedProducer.cc.

Referenced by loop().

◆ field_

edm::ESHandle<MagneticField> LowPtGsfElectronSeedProducer::field_
private

◆ fitterPtr_

std::unique_ptr<TrajectoryFitter> LowPtGsfElectronSeedProducer::fitterPtr_
private

Definition at line 139 of file LowPtGsfElectronSeedProducer.cc.

Referenced by lightGsfTracking(), and loop().

◆ hcalClusters_

edm::EDGetTokenT<reco::PFClusterCollection> LowPtGsfElectronSeedProducer::hcalClusters_
private

Definition at line 144 of file LowPtGsfElectronSeedProducer.cc.

Referenced by produce().

◆ kfTracks_

edm::EDGetTokenT<reco::TrackCollection> LowPtGsfElectronSeedProducer::kfTracks_
private

Definition at line 141 of file LowPtGsfElectronSeedProducer.cc.

Referenced by produce().

◆ magToken_

const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> LowPtGsfElectronSeedProducer::magToken_
private

Definition at line 153 of file LowPtGsfElectronSeedProducer.cc.

Referenced by produce().

◆ mass_

constexpr double LowPtGsfElectronSeedProducer::mass_ = 0.000511 * 0.000511
staticprivate

Definition at line 164 of file LowPtGsfElectronSeedProducer.cc.

Referenced by propagateTrackToCalo().

◆ maxPtThreshold_

const double LowPtGsfElectronSeedProducer::maxPtThreshold_
private

Definition at line 159 of file LowPtGsfElectronSeedProducer.cc.

Referenced by decision().

◆ minPtThreshold_

const double LowPtGsfElectronSeedProducer::minPtThreshold_
private

Definition at line 158 of file LowPtGsfElectronSeedProducer.cc.

Referenced by loop().

◆ passThrough_

const bool LowPtGsfElectronSeedProducer::passThrough_
private

Definition at line 156 of file LowPtGsfElectronSeedProducer.cc.

Referenced by decision(), and loop().

◆ pfTracks_

edm::EDGetTokenT<reco::PFRecTrackCollection> LowPtGsfElectronSeedProducer::pfTracks_
private

Definition at line 142 of file LowPtGsfElectronSeedProducer.cc.

Referenced by produce().

◆ rho_

const edm::EDGetTokenT<double> LowPtGsfElectronSeedProducer::rho_
private

Definition at line 147 of file LowPtGsfElectronSeedProducer.cc.

Referenced by loop().

◆ smootherPtr_

std::unique_ptr<TrajectorySmoother> LowPtGsfElectronSeedProducer::smootherPtr_
private

Definition at line 140 of file LowPtGsfElectronSeedProducer.cc.

Referenced by lightGsfTracking(), and loop().

◆ trajectoryFitterToken_

const edm::ESGetToken<TrajectoryFitter, TrajectoryFitter::Record> LowPtGsfElectronSeedProducer::trajectoryFitterToken_
private

Definition at line 150 of file LowPtGsfElectronSeedProducer.cc.

Referenced by loop().

◆ trajectorySmootherToken_

const edm::ESGetToken<TrajectorySmoother, TrajectoryFitter::Record> LowPtGsfElectronSeedProducer::trajectorySmootherToken_
private

Definition at line 151 of file LowPtGsfElectronSeedProducer.cc.

Referenced by loop().

◆ usePfTracks_

const bool LowPtGsfElectronSeedProducer::usePfTracks_
private

Definition at line 157 of file LowPtGsfElectronSeedProducer.cc.

Referenced by produce().