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

void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) override
 
 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 171 of file LowPtGsfElectronSeedProducer.cc.

References edm::ParameterSet::getParameter().

173  : field_(),
174  fitterPtr_(),
175  smootherPtr_(),
176  kfTracks_(),
177  pfTracks_(),
178  ecalClusters_{consumes(conf.getParameter<edm::InputTag>("ecalClusters"))},
179  hcalClusters_(),
180  ebRecHits_{consumes(conf.getParameter<edm::InputTag>("EBRecHits"))},
181  eeRecHits_{consumes(conf.getParameter<edm::InputTag>("EERecHits"))},
182  rho_(consumes(conf.getParameter<edm::InputTag>("rho"))),
183  beamSpot_(consumes(conf.getParameter<edm::InputTag>("BeamSpot"))),
186  builderToken_{esConsumes(conf.getParameter<edm::ESInputTag>("TTRHBuilder"))},
187  magToken_{esConsumes<edm::Transition::BeginLuminosityBlock>()},
188  ecalClusterToolsESGetTokens_{consumesCollector()},
189  passThrough_(conf.getParameter<bool>("PassThrough")),
190  usePfTracks_(conf.getParameter<bool>("UsePfTracks")),
191  minPtThreshold_(conf.getParameter<double>("MinPtThreshold")),
192  maxPtThreshold_(conf.getParameter<double>("MaxPtThreshold")) {
193  if (usePfTracks_) {
194  pfTracks_ = consumes(conf.getParameter<edm::InputTag>("pfTracks"));
195  hcalClusters_ = consumes(conf.getParameter<edm::InputTag>("hcalClusters"));
196  }
197  kfTracks_ = consumes(conf.getParameter<edm::InputTag>("tracks"));
198 
199  produces<reco::ElectronSeedCollection>();
200  produces<reco::PreIdCollection>();
201  produces<reco::PreIdCollection>("HCAL");
202  produces<edm::ValueMap<reco::PreIdRef> >(); // indexed by edm::Ref<ElectronSeed>.index()
203 }
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:303
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

◆ beginLuminosityBlock()

void LowPtGsfElectronSeedProducer::beginLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &  setup 
)
override

Definition at line 207 of file LowPtGsfElectronSeedProducer.cc.

References field_, magToken_, and singleTopDQM_cfi::setup.

207  {
208  field_ = setup.getHandle(magToken_);
209 }
edm::ESHandle< MagneticField > field_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magToken_

◆ 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 600 of file LowPtGsfElectronSeedProducer.cc.

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

Referenced by loop().

605  {
606  bool result = false;
607  for (auto& name : globalCache()->modelNames()) {
608  result |= globalCache()->eval(name, ecalPreId, hcalPreId, rho, spot, ecalTools);
609  }
610  return passThrough_ || (pfTrackRef->trackRef()->pt() > maxPtThreshold_) || result;
611 }

◆ 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 615 of file LowPtGsfElectronSeedProducer.cc.

References passThrough_.

620  {
621  // No implementation currently
622  return passThrough_;
623 }

◆ fillDescriptions()

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

Definition at line 648 of file LowPtGsfElectronSeedProducer.cc.

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

648  {
650  desc.add<edm::InputTag>("tracks", edm::InputTag("generalTracks"));
651  desc.add<edm::InputTag>("pfTracks", edm::InputTag("lowPtGsfElePfTracks"));
652  desc.add<edm::InputTag>("ecalClusters", edm::InputTag("particleFlowClusterECAL"));
653  desc.add<edm::InputTag>("hcalClusters", edm::InputTag("particleFlowClusterHCAL"));
654  desc.add<edm::InputTag>("EBRecHits", edm::InputTag("ecalRecHit", "EcalRecHitsEB"));
655  desc.add<edm::InputTag>("EERecHits", edm::InputTag("ecalRecHit", "EcalRecHitsEE"));
656  desc.add<edm::InputTag>("rho", edm::InputTag("fixedGridRhoFastjetAllTmp"));
657  desc.add<edm::InputTag>("BeamSpot", edm::InputTag("offlineBeamSpot"));
658  desc.add<edm::ESInputTag>("Fitter", edm::ESInputTag{"", "GsfTrajectoryFitter_forPreId"});
659  desc.add<edm::ESInputTag>("Smoother", edm::ESInputTag{"", "GsfTrajectorySmoother_forPreId"});
660  desc.add<edm::ESInputTag>("TTRHBuilder", edm::ESInputTag{"", "WithAngleAndTemplate"});
661  desc.add<std::vector<std::string> >("ModelNames", {});
662  desc.add<std::vector<std::string> >("ModelWeights", {});
663  desc.add<std::vector<double> >("ModelThresholds", {});
664  desc.add<bool>("PassThrough", false);
665  desc.add<bool>("UsePfTracks", true);
666  desc.add<double>("MinPtThreshold", 1.0);
667  desc.add<double>("MaxPtThreshold", 15.);
668  descriptions.add("lowPtGsfElectronSeeds", desc);
669 }
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 626 of file LowPtGsfElectronSeedProducer.cc.

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

Referenced by produce().

629  {
630  std::vector<reco::PreIdRef> values;
631 
632  unsigned ntracks = tracksHandle->size();
633  for (unsigned itrack = 0; itrack < ntracks; ++itrack) {
634  edm::Ref<CollType> trackRef(tracksHandle, itrack);
635  auto preIdRefIt = trksToPreIdIndx.find(trackRef.index());
636  if (preIdRefIt == trksToPreIdIndx.end()) {
637  values.push_back(reco::PreIdRef());
638  } else {
639  edm::Ref<reco::PreIdCollection> preIdRef(preIdHandle, preIdRefIt->second);
640  values.push_back(preIdRef);
641  }
642  }
643  filler.insert(tracksHandle, values.begin(), values.end());
644 }

◆ getBaseRef() [1/2]

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

Definition at line 279 of file LowPtGsfElectronSeedProducer.cc.

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

Referenced by loop().

279  {
280  return reco::TrackRef(handle, idx);
281 }
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 283 of file LowPtGsfElectronSeedProducer.cc.

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

284  {
285  return reco::PFRecTrackRef(handle, idx)->trackRef();
286 }
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 562 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().

564  {
566  for (unsigned int ihit = 0; ihit < trackRef->recHitsSize(); ++ihit) {
567  hits.push_back(trackRef->recHit(ihit)->cloneSH());
568  }
569 
570  GlobalVector gv(trackRef->innerMomentum().x(), trackRef->innerMomentum().y(), trackRef->innerMomentum().z());
571  GlobalPoint gp(trackRef->innerPosition().x(), trackRef->innerPosition().y(), trackRef->innerPosition().z());
572 
573  GlobalTrajectoryParameters gtps(gp, gv, trackRef->charge(), &*field_);
574 
575  TrajectoryStateOnSurface tsos(gtps, trackRef->innerStateCovariance(), *hits[0]->surface());
576 
577  // Track fitted and smoothed under electron hypothesis
578  Trajectory traj1 = fitterPtr_->fitOne(seed, hits, tsos);
579  if (!traj1.isValid()) {
580  return false;
581  }
582  Trajectory traj2 = smootherPtr_->trajectory(traj1);
583  if (!traj2.isValid()) {
584  return false;
585  }
586 
587  // Set PreId content
588  float chi2Ratio = trackRef->chi2() > 0. ? traj2.chiSquared() / trackRef->chi2() : -1.;
589  float gsfReducedChi2 = chi2Ratio > -1. ? chi2Ratio * trackRef->normalizedChi2() : -1.;
590  float ptOut = traj2.firstMeasurement().updatedState().globalMomentum().perp();
591  float ptIn = traj2.lastMeasurement().updatedState().globalMomentum().perp();
592  float gsfDpt = (ptIn > 0) ? fabs(ptOut - ptIn) / ptIn : 0.;
593  preId.setTrackProperties(gsfReducedChi2, chi2Ratio, gsfDpt);
594 
595  return true;
596 }
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 291 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().

298  {
299  // Pileup
300  auto const& rho = event.get(rho_);
301 
302  // Beam spot
303  auto const& spot = event.get(beamSpot_);
304 
305  // Track fitter
306  fitterPtr_ = setup.getData(trajectoryFitterToken_).clone();
307 
308  // Track smoother
309  smootherPtr_.reset(setup.getData(trajectorySmootherToken_).clone());
310 
311  // RecHit cloner
312  TkClonerImpl hitCloner = static_cast<TkTransientTrackingRecHitBuilder const&>(setup.getData(builderToken_)).cloner();
313  fitterPtr_->setHitCloner(&hitCloner);
314  smootherPtr_->setHitCloner(&hitCloner);
315 
316  // ECAL clusters
317  auto ecalClusters = event.getHandle(ecalClusters_);
318 
319  // Utility to access to shower shape vars
321 
322  // Ensure each cluster is only matched once to a track
323  std::vector<int> matchedEcalClusters;
324  std::vector<int> matchedHcalClusters;
325 
326  // Reserve
327  seeds.reserve(handle->size());
328  ecalPreIds.reserve(handle->size());
329  hcalPreIds.reserve(handle->size());
330 
331  // Iterate through (PF or KF) tracks
332  for (unsigned int itrk = 0; itrk < handle.product()->size(); itrk++) {
333  edm::Ref<std::vector<T> > templatedRef(handle, itrk); // TrackRef or PFRecTrackRef
334  reco::TrackRef trackRef = getBaseRef(handle, itrk);
335 
336  if (!(trackRef->quality(reco::TrackBase::qualityByName("highPurity")))) {
337  continue;
338  }
339  if (!passThrough_ && (trackRef->pt() < minPtThreshold_)) {
340  continue;
341  }
342 
343  // Create ElectronSeed
344  reco::ElectronSeed seed(*(trackRef->seedRef()));
345  if (seed.nHits() == 0) { //if DeepCore is used in jetCore iteration the seed are hitless, in case skip
346  continue;
347  }
348  seed.setCtfTrack(trackRef);
349 
350  // Create PreIds
351  unsigned int nModels = globalCache()->modelNames().size();
352  reco::PreId ecalPreId(nModels);
353  reco::PreId hcalPreId(nModels);
354 
355  // Add track ref to PreId
356  ecalPreId.setTrack(trackRef);
357  hcalPreId.setTrack(trackRef);
358 
359  // Add Track-Calo matching variables to PreIds
361  templatedRef, ecalClusters, hcalClusters, matchedEcalClusters, matchedHcalClusters, ecalPreId, hcalPreId);
362 
363  // Add variables related to GSF tracks to PreId
364  lightGsfTracking(ecalPreId, trackRef, seed);
365 
366  // Decision based on BDT
367  bool result = decision(templatedRef, ecalPreId, hcalPreId, rho, spot, ecalTools);
368 
369  // If fails BDT, do not store seed
370  if (!result) {
371  continue;
372  }
373 
374  // Store PreId
375  ecalPreIds.push_back(ecalPreId);
376  hcalPreIds.push_back(hcalPreId);
377  trksToPreIdIndx[trackRef.index()] = ecalPreIds.size() - 1;
378 
379  // Store ElectronSeed and corresponding edm::Ref<PreId>.index()
380  seeds.push_back(seed);
381  }
382 }
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 213 of file LowPtGsfElectronSeedProducer.cc.

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

213  {
214  // Products
215  auto seeds = std::make_unique<reco::ElectronSeedCollection>();
216  auto ecalPreIds = std::make_unique<reco::PreIdCollection>();
217  auto hcalPreIds = std::make_unique<reco::PreIdCollection>();
218 
219  const edm::RefProd<reco::PreIdCollection> preIdsRefProd = event.getRefBeforePut<reco::PreIdCollection>();
220 
221  // HCAL clusters (only used with PF tracks)
223 
224  //we always need kftracks as we link the preids to them
226  event.getByToken(kfTracks_, kfTracks);
227 
228  TrackIndxMap trksToPreIdIndx;
229  if (usePfTracks_) {
231  event.getByToken(pfTracks_, pfTracks);
232  event.getByToken(hcalClusters_, hcalClusters);
233 
234  //check consistency between kfTracks and pfTracks collection
235  for (auto& trk : *pfTracks) {
236  if (trk.trackRef().isNonnull()) {
237  if (trk.trackRef().id() != kfTracks.id()) {
238  throw cms::Exception("ConfigError")
239  << "kfTracks is not the collection that pfTracks was built from, please fix this";
240  }
241  break; //we only need one valid track ref to check this so end the loop
242  }
243  }
244 
245  loop(pfTracks, // PF tracks
246  hcalClusters,
247  *seeds,
248  *ecalPreIds,
249  *hcalPreIds,
250  trksToPreIdIndx,
251  event,
252  setup);
253 
254  } else {
255  loop(kfTracks, // KF tracks
256  hcalClusters,
257  *seeds,
258  *ecalPreIds,
259  *hcalPreIds,
260  trksToPreIdIndx,
261  event,
262  setup);
263  }
264 
265  auto ecalPreIdsHandle = event.put(std::move(ecalPreIds));
266  event.put(std::move(hcalPreIds), "HCAL");
267  event.put(std::move(seeds));
268 
269  auto preIdVMOut = std::make_unique<edm::ValueMap<reco::PreIdRef> >();
270  edm::ValueMap<reco::PreIdRef>::Filler mapFiller(*preIdVMOut);
271  fillPreIdRefValueMap(kfTracks, trksToPreIdIndx, ecalPreIdsHandle, mapFiller);
272  mapFiller.fill();
273  event.put(std::move(preIdVMOut));
274 }
std::vector< reco::PreId > PreIdCollection
Definition: PreIdFwd.h:6
ProductID id() const
Definition: HandleBase.cc:29
edm::EDGetTokenT< reco::PFClusterCollection > hcalClusters_
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 408 of file LowPtGsfElectronSeedProducer.cc.

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

Referenced by loop().

414  {
415  propagateTrackToCalo(pfTrackRef, ecalClusters, matchedEcalClusters, ecalPreId, true);
416  propagateTrackToCalo(pfTrackRef, hcalClusters, matchedHcalClusters, hcalPreId, false);
417 }
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 421 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().

425  {
426  // Store info for PreId
427  struct Info {
429  float dr2min = 1.e6;
430  float deta = 1.e6;
431  float dphi = 1.e6;
432  math::XYZPoint showerPos = math::XYZPoint(0., 0., 0.);
433  } info;
434 
435  // Find closest "seed cluster" to KF track extrapolated to ECAL (or HCAL)
437  if (ecal) {
438  point = pfTrackRef->extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::ECALShowerMax);
439  } else {
440  point = pfTrackRef->extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::HCALEntrance);
441  }
442 
443  if (point.isValid()) {
444  Info info;
445  for (unsigned int iclu = 0; iclu < clusters.product()->size(); iclu++) {
446  if (std::find(matched.begin(), matched.end(), iclu) == matched.end()) {
447  reco::PFClusterRef cluRef(clusters, iclu);
448 
449  // Determine dR squared
450  float dr2 = reco::deltaR2(cluRef->positionREP(), point.positionREP());
451 
452  if (dr2 < info.dr2min) {
453  info.dr2min = dr2;
454  info.cluRef = cluRef;
455  info.deta = cluRef->positionREP().eta() - point.positionREP().eta();
456  info.dphi =
457  reco::deltaPhi(cluRef->positionREP().phi(), point.positionREP().phi()) * pfTrackRef->trackRef()->charge();
458  info.showerPos = point.position();
459  }
460  }
461  }
462 
463  // Set PreId content if match found
464  if (info.dr2min < 1.e5) {
465  float ep = info.cluRef->correctedEnergy() / std::sqrt(pfTrackRef->trackRef()->innerMomentum().mag2());
466  preId.setECALMatchingProperties(info.cluRef,
467  point.position(), // ECAL or HCAL surface
468  info.showerPos, //
469  info.deta,
470  info.dphi,
471  0.f, // chieta
472  0.f, // chiphi
473  pfTrackRef->trackRef()->normalizedChi2(), // chi2
474  ep);
475  }
476 
477  } // clusters
478 }
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 482 of file LowPtGsfElectronSeedProducer.cc.

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

489  {
490  // Store info for PreId
491  struct Info {
493  float dr2min = 1.e6;
494  float deta = 1.e6;
495  float dphi = 1.e6;
496  math::XYZPoint showerPos = math::XYZPoint(0., 0., 0.);
497  } info;
498 
499  // Propagate 'electron' to ECAL surface
500  float energy = sqrt(mass_ + kfTrackRef->outerMomentum().Mag2());
502  kfTrackRef->outerMomentum().x(), kfTrackRef->outerMomentum().y(), kfTrackRef->outerMomentum().z(), energy);
504  kfTrackRef->outerPosition().x(), kfTrackRef->outerPosition().y(), kfTrackRef->outerPosition().z(), 0.);
505  math::XYZVector field(field_->inTesla(GlobalPoint(0, 0, 0)));
506  BaseParticlePropagator particle(RawParticle(mom, pos, kfTrackRef->charge()), 0, 0, field.z());
507  particle.propagateToEcalEntrance(false);
508  if (particle.getSuccess() == 0) {
509  return;
510  }
511 
512  // ECAL entry point for track
513  GlobalPoint ecal_pos(
514  particle.particle().vertex().x(), particle.particle().vertex().y(), particle.particle().vertex().z());
515 
516  // Preshower limit
517  bool below_ps = pow(ecal_pos.z(), 2.) > boundary_ * ecal_pos.perp2();
518 
519  // Iterate through ECAL clusters
520  for (unsigned int iclu = 0; iclu < ecalClusters.product()->size(); iclu++) {
521  reco::PFClusterRef cluRef(ecalClusters, iclu);
522 
523  // Correct ecal_pos for shower depth
524  double shower_depth = reco::PFCluster::getDepthCorrection(cluRef->correctedEnergy(), below_ps, false);
525  GlobalPoint showerPos = ecal_pos + GlobalVector(particle.particle().momentum().x(),
526  particle.particle().momentum().y(),
527  particle.particle().momentum().z())
528  .unit() *
529  shower_depth;
530 
531  // Determine dR squared
532  float dr2 = reco::deltaR2(cluRef->positionREP(), showerPos);
533 
534  // Find nearest ECAL cluster
535  if (dr2 < info.dr2min) {
536  info.dr2min = dr2;
537  info.cluRef = cluRef;
538  info.deta = std::abs(cluRef->positionREP().eta() - showerPos.eta());
539  info.dphi = std::abs(reco::deltaPhi(cluRef->positionREP().phi(), showerPos.phi())) * kfTrackRef->charge();
540  info.showerPos = showerPos;
541  }
542  }
543 
544  // Populate PreId object
545  math::XYZPoint point(ecal_pos.x(), ecal_pos.y(), ecal_pos.z());
546 
547  // Set PreId content
548  ecalPreId.setECALMatchingProperties(
549  info.cluRef,
550  point,
551  info.showerPos,
552  info.deta,
553  info.dphi,
554  0.f, // chieta
555  0.f, // chiphi
556  kfTrackRef->normalizedChi2(), // chi2
557  info.cluRef->correctedEnergy() / std::sqrt(kfTrackRef->innerMomentum().mag2())); // E/p
558 }
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 150 of file LowPtGsfElectronSeedProducer.cc.

Referenced by loop().

◆ boundary_

constexpr double LowPtGsfElectronSeedProducer::boundary_ = 2.50746495928 * 2.50746495928
staticprivate

Definition at line 164 of file LowPtGsfElectronSeedProducer.cc.

Referenced by propagateTrackToCalo().

◆ builderToken_

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

Definition at line 154 of file LowPtGsfElectronSeedProducer.cc.

Referenced by loop().

◆ ebRecHits_

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

Definition at line 147 of file LowPtGsfElectronSeedProducer.cc.

Referenced by loop().

◆ ecalClusters_

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

Definition at line 145 of file LowPtGsfElectronSeedProducer.cc.

Referenced by loop().

◆ ecalClusterToolsESGetTokens_

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

Definition at line 156 of file LowPtGsfElectronSeedProducer.cc.

Referenced by loop().

◆ eeRecHits_

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

Definition at line 148 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 141 of file LowPtGsfElectronSeedProducer.cc.

Referenced by lightGsfTracking(), and loop().

◆ hcalClusters_

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

Definition at line 146 of file LowPtGsfElectronSeedProducer.cc.

Referenced by produce().

◆ kfTracks_

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

Definition at line 143 of file LowPtGsfElectronSeedProducer.cc.

Referenced by produce().

◆ magToken_

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

Definition at line 155 of file LowPtGsfElectronSeedProducer.cc.

Referenced by beginLuminosityBlock().

◆ mass_

constexpr double LowPtGsfElectronSeedProducer::mass_ = 0.000511 * 0.000511
staticprivate

Definition at line 166 of file LowPtGsfElectronSeedProducer.cc.

Referenced by propagateTrackToCalo().

◆ maxPtThreshold_

const double LowPtGsfElectronSeedProducer::maxPtThreshold_
private

Definition at line 161 of file LowPtGsfElectronSeedProducer.cc.

Referenced by decision().

◆ minPtThreshold_

const double LowPtGsfElectronSeedProducer::minPtThreshold_
private

Definition at line 160 of file LowPtGsfElectronSeedProducer.cc.

Referenced by loop().

◆ passThrough_

const bool LowPtGsfElectronSeedProducer::passThrough_
private

Definition at line 158 of file LowPtGsfElectronSeedProducer.cc.

Referenced by decision(), and loop().

◆ pfTracks_

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

Definition at line 144 of file LowPtGsfElectronSeedProducer.cc.

Referenced by produce().

◆ rho_

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

Definition at line 149 of file LowPtGsfElectronSeedProducer.cc.

Referenced by loop().

◆ smootherPtr_

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

Definition at line 142 of file LowPtGsfElectronSeedProducer.cc.

Referenced by lightGsfTracking(), and loop().

◆ trajectoryFitterToken_

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

Definition at line 152 of file LowPtGsfElectronSeedProducer.cc.

Referenced by loop().

◆ trajectorySmootherToken_

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

Definition at line 153 of file LowPtGsfElectronSeedProducer.cc.

Referenced by loop().

◆ usePfTracks_

const bool LowPtGsfElectronSeedProducer::usePfTracks_
private

Definition at line 159 of file LowPtGsfElectronSeedProducer.cc.

Referenced by produce().