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 <LowPtGsfElectronSeedProducer.h>

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 > >
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache 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
 
 ~LowPtGsfElectronSeedProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< lowptgsfeleseed::HeavyObjectCache > >
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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 &, const edm::EventSetup &)
 
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 std::string builder_
 
const edm::EDGetTokenT< EcalRecHitCollectionebRecHits_
 
const edm::EDGetTokenT< reco::PFClusterCollectionecalClusters_
 
const edm::EDGetTokenT< EcalRecHitCollectioneeRecHits_
 
edm::ESHandle< MagneticFieldfield_
 
const std::string fitter_
 
std::unique_ptr< TrajectoryFitterfitterPtr_
 
edm::EDGetTokenT< reco::PFClusterCollectionhcalClusters_
 
edm::EDGetTokenT< reco::TrackCollectionkfTracks_
 
const double maxPtThreshold_
 
const double minPtThreshold_
 
const bool passThrough_
 
edm::EDGetTokenT< reco::PFRecTrackCollectionpfTracks_
 
const edm::EDGetTokenT< double > rho_
 
const std::string smoother_
 
std::unique_ptr< TrajectorySmoothersmootherPtr_
 
const bool usePfTracks_
 

Static Private Attributes

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

Detailed Description

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

Definition at line 28 of file LowPtGsfElectronSeedProducer.h.

Member Typedef Documentation

Definition at line 31 of file LowPtGsfElectronSeedProducer.h.

Constructor & Destructor Documentation

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

Definition at line 38 of file LowPtGsfElectronSeedProducer.cc.

References beamSpot_, builder_, ebRecHits_, eeRecHits_, fitter_, edm::ParameterSet::getParameter(), hcalClusters_, kfTracks_, maxPtThreshold_, minPtThreshold_, passThrough_, pfTracks_, rho_, smoother_, AlCaHLTBitMon_QueryRunRegistry::string, and usePfTracks_.

40  : field_(),
41  fitterPtr_(),
42  smootherPtr_(),
43  kfTracks_(),
44  pfTracks_(),
45  ecalClusters_{consumes<reco::PFClusterCollection>(conf.getParameter<edm::InputTag>("ecalClusters"))},
46  hcalClusters_(),
47  ebRecHits_{consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("EBRecHits"))},
48  eeRecHits_{consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("EERecHits"))},
49  rho_(consumes<double>(conf.getParameter<edm::InputTag>("rho"))),
50  beamSpot_(consumes<reco::BeamSpot>(conf.getParameter<edm::InputTag>("BeamSpot"))),
51  fitter_(conf.getParameter<std::string>("Fitter")),
52  smoother_(conf.getParameter<std::string>("Smoother")),
53  builder_(conf.getParameter<std::string>("TTRHBuilder")),
54  passThrough_(conf.getParameter<bool>("PassThrough")),
55  usePfTracks_(conf.getParameter<bool>("UsePfTracks")),
56  minPtThreshold_(conf.getParameter<double>("MinPtThreshold")),
57  maxPtThreshold_(conf.getParameter<double>("MaxPtThreshold")) {
58  if (usePfTracks_) {
59  pfTracks_ = consumes<reco::PFRecTrackCollection>(conf.getParameter<edm::InputTag>("pfTracks"));
60  hcalClusters_ = consumes<reco::PFClusterCollection>(conf.getParameter<edm::InputTag>("hcalClusters"));
61  }
62  kfTracks_ = consumes<reco::TrackCollection>(conf.getParameter<edm::InputTag>("tracks"));
63 
64  produces<reco::ElectronSeedCollection>();
65  produces<reco::PreIdCollection>();
66  produces<reco::PreIdCollection>("HCAL");
67  produces<edm::ValueMap<reco::PreIdRef> >(); // indexed by edm::Ref<ElectronSeed>.index()
68 }
T getParameter(std::string const &) const
edm::ESHandle< MagneticField > field_
std::unique_ptr< TrajectorySmoother > smootherPtr_
const edm::EDGetTokenT< reco::PFClusterCollection > ecalClusters_
edm::EDGetTokenT< reco::PFClusterCollection > hcalClusters_
const edm::EDGetTokenT< reco::BeamSpot > beamSpot_
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_
std::unique_ptr< TrajectoryFitter > fitterPtr_
LowPtGsfElectronSeedProducer::~LowPtGsfElectronSeedProducer ( )
override

Definition at line 72 of file LowPtGsfElectronSeedProducer.cc.

72 {}

Member Function Documentation

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

Definition at line 76 of file LowPtGsfElectronSeedProducer.cc.

References field_, and edm::EventSetup::get().

Referenced by globalEndJob().

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

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

Referenced by globalEndJob(), and loop().

481  {
482  bool result = false;
483  for (auto& name : globalCache()->modelNames()) {
484  result |= globalCache()->eval(name, ecalPreId, hcalPreId, rho, spot, ecalTools);
485  }
486  return passThrough_ || (pfTrackRef->trackRef()->pt() > maxPtThreshold_) || result;
487 }
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 491 of file LowPtGsfElectronSeedProducer.cc.

References passThrough_.

496  {
497  // No implementation currently
498  return passThrough_;
499 }
void LowPtGsfElectronSeedProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 524 of file LowPtGsfElectronSeedProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), DEFINE_FWK_MODULE, HLT_2018_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by globalEndJob().

524  {
526  desc.add<edm::InputTag>("tracks", edm::InputTag("generalTracks"));
527  desc.add<edm::InputTag>("pfTracks", edm::InputTag("lowPtGsfElePfTracks"));
528  desc.add<edm::InputTag>("ecalClusters", edm::InputTag("particleFlowClusterECAL"));
529  desc.add<edm::InputTag>("hcalClusters", edm::InputTag("particleFlowClusterHCAL"));
530  desc.add<edm::InputTag>("EBRecHits", edm::InputTag("ecalRecHit", "EcalRecHitsEB"));
531  desc.add<edm::InputTag>("EERecHits", edm::InputTag("ecalRecHit", "EcalRecHitsEE"));
532  desc.add<edm::InputTag>("rho", edm::InputTag("fixedGridRhoFastjetAllTmp"));
533  desc.add<edm::InputTag>("BeamSpot", edm::InputTag("offlineBeamSpot"));
534  desc.add<std::string>("Fitter", "GsfTrajectoryFitter_forPreId");
535  desc.add<std::string>("Smoother", "GsfTrajectorySmoother_forPreId");
536  desc.add<std::string>("TTRHBuilder", "WithAngleAndTemplate");
537  desc.add<std::vector<std::string> >("ModelNames", std::vector<std::string>());
538  desc.add<std::vector<std::string> >("ModelWeights", std::vector<std::string>());
539  desc.add<std::vector<double> >("ModelThresholds", std::vector<double>());
540  desc.add<bool>("PassThrough", false);
541  desc.add<bool>("UsePfTracks", true);
542  desc.add<double>("MinPtThreshold", 1.0);
543  desc.add<double>("MaxPtThreshold", 15.);
544  descriptions.add("lowPtGsfElectronSeeds", desc);
545 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
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 502 of file LowPtGsfElectronSeedProducer.cc.

References edm::Ref< C, T, F >::index(), edm::helper::Filler< Map >::insert(), and contentValuesCheck::values.

Referenced by globalEndJob(), and produce().

505  {
506  std::vector<reco::PreIdRef> values;
507 
508  unsigned ntracks = tracksHandle->size();
509  for (unsigned itrack = 0; itrack < ntracks; ++itrack) {
510  edm::Ref<CollType> trackRef(tracksHandle, itrack);
511  auto preIdRefIt = trksToPreIdIndx.find(trackRef.index());
512  if (preIdRefIt == trksToPreIdIndx.end()) {
513  values.push_back(reco::PreIdRef());
514  } else {
515  edm::Ref<reco::PreIdCollection> preIdRef(preIdHandle, preIdRefIt->second);
516  values.push_back(preIdRef);
517  }
518  }
519  filler.insert(tracksHandle, values.begin(), values.end());
520 }
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
reco::TrackRef LowPtGsfElectronSeedProducer::getBaseRef ( edm::Handle< std::vector< reco::Track > >  handle,
int  idx 
) const
private

Definition at line 148 of file LowPtGsfElectronSeedProducer.cc.

References patZpeak::handle.

Referenced by globalEndJob(), and loop().

148  {
149  return reco::TrackRef(handle, idx);
150 }
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
reco::TrackRef LowPtGsfElectronSeedProducer::getBaseRef ( edm::Handle< std::vector< reco::PFRecTrack > >  handle,
int  idx 
) const
private

Definition at line 152 of file LowPtGsfElectronSeedProducer.cc.

References patZpeak::handle.

153  {
154  return reco::PFRecTrackRef(handle, idx)->trackRef();
155 }
edm::Ref< PFRecTrackCollection > PFRecTrackRef
persistent reference to PFRecTrack objects
Definition: PFRecTrackFwd.h:15
static void LowPtGsfElectronSeedProducer::globalEndJob ( lowptgsfeleseed::HeavyObjectCache const *  )
inlinestatic
static std::unique_ptr<lowptgsfeleseed::HeavyObjectCache> LowPtGsfElectronSeedProducer::initializeGlobalCache ( const edm::ParameterSet conf)
inlinestatic

Definition at line 36 of file LowPtGsfElectronSeedProducer.h.

36  {
37  return std::make_unique<lowptgsfeleseed::HeavyObjectCache>(lowptgsfeleseed::HeavyObjectCache(conf));
38  }
bool LowPtGsfElectronSeedProducer::lightGsfTracking ( reco::PreId preId,
const reco::TrackRef trackRef,
const reco::ElectronSeed seed,
const edm::EventSetup setup 
)
private

Definition at line 437 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(), reco::PreId::setTrackProperties(), smootherPtr_, and TrajectoryMeasurement::updatedState().

Referenced by globalEndJob(), and loop().

440  {
442  for (unsigned int ihit = 0; ihit < trackRef->recHitsSize(); ++ihit) {
443  hits.push_back(trackRef->recHit(ihit)->cloneSH());
444  }
445 
446  GlobalVector gv(trackRef->innerMomentum().x(), trackRef->innerMomentum().y(), trackRef->innerMomentum().z());
447  GlobalPoint gp(trackRef->innerPosition().x(), trackRef->innerPosition().y(), trackRef->innerPosition().z());
448 
449  GlobalTrajectoryParameters gtps(gp, gv, trackRef->charge(), &*field_);
450 
451  TrajectoryStateOnSurface tsos(gtps, trackRef->innerStateCovariance(), *hits[0]->surface());
452 
453  // Track fitted and smoothed under electron hypothesis
454  Trajectory traj1 = fitterPtr_->fitOne(seed, hits, tsos);
455  if (!traj1.isValid()) {
456  return false;
457  }
458  Trajectory traj2 = smootherPtr_->trajectory(traj1);
459  if (!traj2.isValid()) {
460  return false;
461  }
462 
463  // Set PreId content
464  float chi2Ratio = trackRef->chi2() > 0. ? traj2.chiSquared() / trackRef->chi2() : -1.;
465  float gsfReducedChi2 = chi2Ratio > -1. ? chi2Ratio * trackRef->normalizedChi2() : -1.;
466  float ptOut = traj2.firstMeasurement().updatedState().globalMomentum().perp();
467  float ptIn = traj2.lastMeasurement().updatedState().globalMomentum().perp();
468  float gsfDpt = (ptIn > 0) ? fabs(ptOut - ptIn) / ptIn : 0.;
469  preId.setTrackProperties(gsfReducedChi2, chi2Ratio, gsfDpt);
470 
471  return true;
472 }
edm::ESHandle< MagneticField > field_
std::unique_ptr< TrajectorySmoother > smootherPtr_
T perp() const
Definition: PV3DBase.h:69
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:150
bool isValid() const
Definition: Trajectory.h:257
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:166
float chiSquared() const
Definition: Trajectory.h:241
TrackingRecHit::ConstRecHitContainer ConstRecHitContainer
Definition: Trajectory.h:41
void setTrackProperties(float newchi2, float chi2ratio, float dpt)
Definition: PreId.h:53
GlobalVector globalMomentum() const
TrajectoryStateOnSurface const & updatedState() const
std::unique_ptr< TrajectoryFitter > fitterPtr_
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 160 of file LowPtGsfElectronSeedProducer.cc.

References beamSpot_, builder_, TrajectorySmoother::clone(), TrajectoryFitter::clone(), watchdog::const, decision(), ebRecHits_, RecoEcal_cff::ecalClusters, ecalClusters_, eeRecHits_, fitter_, fitterPtr_, edm::EventSetup::get(), getBaseRef(), patZpeak::handle, lowPtGsfElectronSeeds_cfi::hcalClusters, edm::Ref< C, T, F >::index(), lightGsfTracking(), minPtThreshold_, passThrough_, edm::ESHandle< T >::product(), propagateTrackToCalo(), reco::TrackBase::qualityByName(), mps_fire::result, rho, rho_, SurveyInfoScenario_cff::seed, reco::ElectronSeed::setCtfTrack(), reco::PreId::setTrack(), smoother_, and smootherPtr_.

Referenced by globalEndJob(), and produce().

167  {
168  // Pileup
170  event.getByToken(rho_, rho);
171 
172  // Beam spot
174  event.getByToken(beamSpot_, spot);
175 
176  // Track fitter
178  setup.get<TrajectoryFitter::Record>().get(fitter_, fitter);
179  fitterPtr_ = fitter->clone();
180 
181  // Track smoother
183  setup.get<TrajectoryFitter::Record>().get(smoother_, smoother);
184  smootherPtr_.reset(smoother->clone());
185 
186  // RecHit cloner
188  setup.get<TransientRecHitRecord>().get(builder_, builder);
189  TkClonerImpl hitCloner = static_cast<TkTransientTrackingRecHitBuilder const*>(builder.product())->cloner();
190  fitterPtr_->setHitCloner(&hitCloner);
191  smootherPtr_->setHitCloner(&hitCloner);
192 
193  // ECAL clusters
195  event.getByToken(ecalClusters_, ecalClusters);
196 
197  // Utility to access to shower shape vars
198  noZS::EcalClusterLazyTools ecalTools(event, setup, ebRecHits_, eeRecHits_);
199 
200  // Ensure each cluster is only matched once to a track
201  std::vector<int> matchedEcalClusters;
202  std::vector<int> matchedHcalClusters;
203 
204  // Reserve
205  seeds.reserve(handle->size());
206  ecalPreIds.reserve(handle->size());
207  hcalPreIds.reserve(handle->size());
208 
209  // Iterate through (PF or KF) tracks
210  for (unsigned int itrk = 0; itrk < handle.product()->size(); itrk++) {
211  edm::Ref<std::vector<T> > templatedRef(handle, itrk); // TrackRef or PFRecTrackRef
212  reco::TrackRef trackRef = getBaseRef(handle, itrk);
213 
214  if (!(trackRef->quality(reco::TrackBase::qualityByName("highPurity")))) {
215  continue;
216  }
217  if (!passThrough_ && (trackRef->pt() < minPtThreshold_)) {
218  continue;
219  }
220 
221  // Create ElectronSeed
222  reco::ElectronSeed seed(*(trackRef->seedRef()));
223  seed.setCtfTrack(trackRef);
224 
225  // Create PreIds
226  unsigned int nModels = globalCache()->modelNames().size();
227  reco::PreId ecalPreId(nModels);
228  reco::PreId hcalPreId(nModels);
229 
230  // Add track ref to PreId
231  ecalPreId.setTrack(trackRef);
232  hcalPreId.setTrack(trackRef);
233 
234  // Add Track-Calo matching variables to PreIds
236  templatedRef, ecalClusters, hcalClusters, matchedEcalClusters, matchedHcalClusters, ecalPreId, hcalPreId);
237 
238  // Add variables related to GSF tracks to PreId
239  lightGsfTracking(ecalPreId, trackRef, seed, setup);
240 
241  // Decision based on BDT
242  bool result = decision(templatedRef, ecalPreId, hcalPreId, *rho, *spot, ecalTools);
243 
244  // If fails BDT, do not store seed
245  if (!result) {
246  continue;
247  }
248 
249  // Store PreId
250  ecalPreIds.push_back(ecalPreId);
251  hcalPreIds.push_back(hcalPreId);
252  trksToPreIdIndx[trackRef.index()] = ecalPreIds.size() - 1;
253 
254  // Store ElectronSeed and corresponding edm::Ref<PreId>.index()
255  seeds.push_back(seed);
256  }
257 }
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)
const edm::EDGetTokenT< reco::PFClusterCollection > ecalClusters_
key_type index() const
Definition: Ref.h:253
const edm::EDGetTokenT< reco::BeamSpot > beamSpot_
virtual TrajectorySmoother * clone() const =0
virtual std::unique_ptr< TrajectoryFitter > clone() const =0
bool lightGsfTracking(reco::PreId &, const reco::TrackRef &, const reco::ElectronSeed &, const edm::EventSetup &)
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
T const * product() const
Definition: Handle.h:69
T get() const
Definition: EventSetup.h:73
T const * product() const
Definition: ESHandle.h:86
reco::TrackRef getBaseRef(edm::Handle< std::vector< reco::Track > > handle, int idx) const
std::unique_ptr< TrajectoryFitter > fitterPtr_
void LowPtGsfElectronSeedProducer::produce ( edm::Event event,
const edm::EventSetup setup 
)
override

Definition at line 82 of file LowPtGsfElectronSeedProducer.cc.

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

Referenced by globalEndJob().

82  {
83  // Products
84  auto seeds = std::make_unique<reco::ElectronSeedCollection>();
85  auto ecalPreIds = std::make_unique<reco::PreIdCollection>();
86  auto hcalPreIds = std::make_unique<reco::PreIdCollection>();
87 
88  const edm::RefProd<reco::PreIdCollection> preIdsRefProd = event.getRefBeforePut<reco::PreIdCollection>();
89 
90  // HCAL clusters (only used with PF tracks)
92 
93  //we always need kftracks as we link the preids to them
95  event.getByToken(kfTracks_, kfTracks);
96 
97  TrackIndxMap trksToPreIdIndx;
98  if (usePfTracks_) {
100  event.getByToken(pfTracks_, pfTracks);
101  event.getByToken(hcalClusters_, hcalClusters);
102 
103  //check consistency between kfTracks and pfTracks collection
104  for (auto& trk : *pfTracks) {
105  if (trk.trackRef().isNonnull()) {
106  if (trk.trackRef().id() != kfTracks.id()) {
107  throw cms::Exception("ConfigError")
108  << "kfTracks is not the collection that pfTracks was built from, please fix this";
109  }
110  break; //we only need one valid track ref to check this so end the loop
111  }
112  }
113 
114  loop(pfTracks, // PF tracks
115  hcalClusters,
116  *seeds,
117  *ecalPreIds,
118  *hcalPreIds,
119  trksToPreIdIndx,
120  event,
121  setup);
122 
123  } else {
124  loop(kfTracks, // KF tracks
125  hcalClusters,
126  *seeds,
127  *ecalPreIds,
128  *hcalPreIds,
129  trksToPreIdIndx,
130  event,
131  setup);
132  }
133 
134  auto ecalPreIdsHandle = event.put(std::move(ecalPreIds));
135  event.put(std::move(hcalPreIds), "HCAL");
136  event.put(std::move(seeds));
137 
138  auto preIdVMOut = std::make_unique<edm::ValueMap<reco::PreIdRef> >();
139  edm::ValueMap<reco::PreIdRef>::Filler mapFiller(*preIdVMOut);
140  fillPreIdRefValueMap(kfTracks, trksToPreIdIndx, ecalPreIdsHandle, mapFiller);
141  mapFiller.fill();
142  event.put(std::move(preIdVMOut));
143 }
std::vector< reco::PreId > PreIdCollection
Definition: PreIdFwd.h:6
ProductID id() const
Definition: HandleBase.cc:13
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
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 283 of file LowPtGsfElectronSeedProducer.cc.

Referenced by globalEndJob(), and loop().

289  {
290  propagateTrackToCalo(pfTrackRef, ecalClusters, matchedEcalClusters, ecalPreId, true);
291  propagateTrackToCalo(pfTrackRef, hcalClusters, matchedHcalClusters, hcalPreId, false);
292 }
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 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 296 of file LowPtGsfElectronSeedProducer.cc.

References reco::deltaPhi(), reco::deltaR2(), SiStripBadComponentsDQMServiceTemplate_cfg::ep, spr::find(), info(), reco::PFTrajectoryPoint::isValid(), point, reco::PFTrajectoryPoint::position(), reco::PFTrajectoryPoint::positionREP(), edm::Handle< T >::product(), reco::PreId::setECALMatchingProperties(), and mathSSE::sqrt().

300  {
301  // Store info for PreId
302  struct Info {
304  float dr2min = 1.e6;
305  float deta = 1.e6;
306  float dphi = 1.e6;
307  math::XYZPoint showerPos = math::XYZPoint(0., 0., 0.);
308  } info;
309 
310  // Find closest "seed cluster" to KF track extrapolated to ECAL (or HCAL)
312  if (ecal) {
313  point = pfTrackRef->extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::ECALShowerMax);
314  } else {
315  point = pfTrackRef->extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::HCALEntrance);
316  }
317 
318  if (point.isValid()) {
319  Info info;
320  for (unsigned int iclu = 0; iclu < clusters.product()->size(); iclu++) {
321  if (std::find(matched.begin(), matched.end(), iclu) == matched.end()) {
322  reco::PFClusterRef cluRef(clusters, iclu);
323 
324  // Determine dR squared
325  float dr2 = reco::deltaR2(cluRef->positionREP(), point.positionREP());
326 
327  if (dr2 < info.dr2min) {
328  info.dr2min = dr2;
329  info.cluRef = cluRef;
330  info.deta = cluRef->positionREP().eta() - point.positionREP().eta();
331  info.dphi =
332  reco::deltaPhi(cluRef->positionREP().phi(), point.positionREP().phi()) * pfTrackRef->trackRef()->charge();
333  info.showerPos = point.position();
334  }
335  }
336  }
337 
338  // Set PreId content if match found
339  if (info.dr2min < 1.e5) {
340  float ep = info.cluRef->correctedEnergy() / std::sqrt(pfTrackRef->trackRef()->innerMomentum().mag2());
341  preId.setECALMatchingProperties(info.cluRef,
342  point.position(), // ECAL or HCAL surface
343  info.showerPos, //
344  info.deta,
345  info.dphi,
346  0.f, // chieta
347  0.f, // chiphi
348  pfTrackRef->trackRef()->normalizedChi2(), // chi2
349  ep);
350  }
351 
352  } // clusters
353 }
const REPPoint & positionREP() const
trajectory position in (rho, eta, phi) base
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
const math::XYZPoint & position() const
cartesian position (x, y, z)
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
bool isValid() const
is this point valid ?
T const * product() const
Definition: Handle.h:69
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
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 357 of file LowPtGsfElectronSeedProducer.cc.

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

364  {
365  // Store info for PreId
366  struct Info {
368  float dr2min = 1.e6;
369  float deta = 1.e6;
370  float dphi = 1.e6;
371  math::XYZPoint showerPos = math::XYZPoint(0., 0., 0.);
372  } info;
373 
374  // Propagate 'electron' to ECAL surface
375  float energy = sqrt(mass_ + kfTrackRef->outerMomentum().Mag2());
377  kfTrackRef->outerMomentum().x(), kfTrackRef->outerMomentum().y(), kfTrackRef->outerMomentum().z(), energy);
379  kfTrackRef->outerPosition().x(), kfTrackRef->outerPosition().y(), kfTrackRef->outerPosition().z(), 0.);
380  math::XYZVector field(field_->inTesla(GlobalPoint(0, 0, 0)));
381  BaseParticlePropagator particle(RawParticle(mom, pos, kfTrackRef->charge()), 0, 0, field.z());
382  particle.propagateToEcalEntrance(false);
383  if (particle.getSuccess() == 0) {
384  return;
385  }
386 
387  // ECAL entry point for track
388  GlobalPoint ecal_pos(
389  particle.particle().vertex().x(), particle.particle().vertex().y(), particle.particle().vertex().z());
390 
391  // Preshower limit
392  bool below_ps = pow(ecal_pos.z(), 2.) > boundary_ * ecal_pos.perp2();
393 
394  // Iterate through ECAL clusters
395  for (unsigned int iclu = 0; iclu < ecalClusters.product()->size(); iclu++) {
396  reco::PFClusterRef cluRef(ecalClusters, iclu);
397 
398  // Correct ecal_pos for shower depth
399  double shower_depth = reco::PFCluster::getDepthCorrection(cluRef->correctedEnergy(), below_ps, false);
400  GlobalPoint showerPos = ecal_pos + GlobalVector(particle.particle().momentum().x(),
401  particle.particle().momentum().y(),
402  particle.particle().momentum().z())
403  .unit() *
404  shower_depth;
405 
406  // Determine dR squared
407  float dr2 = reco::deltaR2(cluRef->positionREP(), showerPos);
408 
409  // Find nearest ECAL cluster
410  if (dr2 < info.dr2min) {
411  info.dr2min = dr2;
412  info.cluRef = cluRef;
413  info.deta = std::abs(cluRef->positionREP().eta() - showerPos.eta());
414  info.dphi = std::abs(reco::deltaPhi(cluRef->positionREP().phi(), showerPos.phi())) * kfTrackRef->charge();
415  info.showerPos = showerPos;
416  }
417  }
418 
419  // Populate PreId object
420  math::XYZPoint point(ecal_pos.x(), ecal_pos.y(), ecal_pos.z());
421 
422  // Set PreId content
423  ecalPreId.setECALMatchingProperties(
424  info.cluRef,
425  point,
426  info.showerPos,
427  info.deta,
428  info.dphi,
429  0.f, // chieta
430  0.f, // chiphi
431  kfTrackRef->normalizedChi2(), // chi2
432  info.cluRef->correctedEnergy() / std::sqrt(kfTrackRef->innerMomentum().mag2())); // E/p
433 }
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
double z() const
z of vertex
Definition: RawParticle.h:284
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
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
bool propagateToEcalEntrance(bool first=true)
static double getDepthCorrection(double energy, bool isBelowPS=false, bool isHadron=false)
Definition: PFCluster.cc:83
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
T const * product() const
Definition: Handle.h:69
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:30
*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
Basic3DVector unit() const

Member Data Documentation

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

Definition at line 123 of file LowPtGsfElectronSeedProducer.h.

Referenced by loop(), and LowPtGsfElectronSeedProducer().

double LowPtGsfElectronSeedProducer::boundary_ = 2.50746495928 * 2.50746495928
staticprivate

Definition at line 133 of file LowPtGsfElectronSeedProducer.h.

Referenced by propagateTrackToCalo().

const std::string LowPtGsfElectronSeedProducer::builder_
private

Definition at line 126 of file LowPtGsfElectronSeedProducer.h.

Referenced by loop(), and LowPtGsfElectronSeedProducer().

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

Definition at line 120 of file LowPtGsfElectronSeedProducer.h.

Referenced by loop(), and LowPtGsfElectronSeedProducer().

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

Definition at line 118 of file LowPtGsfElectronSeedProducer.h.

Referenced by loop().

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

Definition at line 121 of file LowPtGsfElectronSeedProducer.h.

Referenced by loop(), and LowPtGsfElectronSeedProducer().

edm::ESHandle<MagneticField> LowPtGsfElectronSeedProducer::field_
private
const std::string LowPtGsfElectronSeedProducer::fitter_
private

Definition at line 124 of file LowPtGsfElectronSeedProducer.h.

Referenced by loop(), and LowPtGsfElectronSeedProducer().

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

Definition at line 114 of file LowPtGsfElectronSeedProducer.h.

Referenced by lightGsfTracking(), and loop().

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

Definition at line 119 of file LowPtGsfElectronSeedProducer.h.

Referenced by LowPtGsfElectronSeedProducer(), and produce().

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

Definition at line 116 of file LowPtGsfElectronSeedProducer.h.

Referenced by LowPtGsfElectronSeedProducer(), and produce().

double LowPtGsfElectronSeedProducer::mass_ = 0.000511 * 0.000511
staticprivate

Definition at line 135 of file LowPtGsfElectronSeedProducer.h.

Referenced by propagateTrackToCalo().

const double LowPtGsfElectronSeedProducer::maxPtThreshold_
private

Definition at line 130 of file LowPtGsfElectronSeedProducer.h.

Referenced by decision(), and LowPtGsfElectronSeedProducer().

const double LowPtGsfElectronSeedProducer::minPtThreshold_
private

Definition at line 129 of file LowPtGsfElectronSeedProducer.h.

Referenced by loop(), and LowPtGsfElectronSeedProducer().

const bool LowPtGsfElectronSeedProducer::passThrough_
private

Definition at line 127 of file LowPtGsfElectronSeedProducer.h.

Referenced by decision(), loop(), and LowPtGsfElectronSeedProducer().

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

Definition at line 117 of file LowPtGsfElectronSeedProducer.h.

Referenced by LowPtGsfElectronSeedProducer(), and produce().

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

Definition at line 122 of file LowPtGsfElectronSeedProducer.h.

Referenced by loop(), and LowPtGsfElectronSeedProducer().

const std::string LowPtGsfElectronSeedProducer::smoother_
private

Definition at line 125 of file LowPtGsfElectronSeedProducer.h.

Referenced by loop(), and LowPtGsfElectronSeedProducer().

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

Definition at line 115 of file LowPtGsfElectronSeedProducer.h.

Referenced by lightGsfTracking(), and loop().

const bool LowPtGsfElectronSeedProducer::usePfTracks_
private

Definition at line 128 of file LowPtGsfElectronSeedProducer.h.

Referenced by LowPtGsfElectronSeedProducer(), and produce().