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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 27 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_.

39  :
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 {
59  if ( usePfTracks_ ) {
60  pfTracks_ = consumes<reco::PFRecTrackCollection>(conf.getParameter<edm::InputTag>("pfTracks"));
61  hcalClusters_ = consumes<reco::PFClusterCollection>(conf.getParameter<edm::InputTag>("hcalClusters"));
62  }
63  kfTracks_ = consumes<reco::TrackCollection>(conf.getParameter<edm::InputTag>("tracks"));
64 
65  produces<reco::ElectronSeedCollection>();
66  produces<reco::PreIdCollection>();
67  produces<reco::PreIdCollection>("HCAL");
68  produces< edm::ValueMap<reco::PreIdRef> >(); // indexed by edm::Ref<ElectronSeed>.index()
69 }
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 73 of file LowPtGsfElectronSeedProducer.cc.

73 {}

Member Function Documentation

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

Definition at line 77 of file LowPtGsfElectronSeedProducer.cc.

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

Referenced by globalEndJob().

79 {
81 }
edm::ESHandle< MagneticField > field_
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py: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 517 of file LowPtGsfElectronSeedProducer.cc.

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

Referenced by globalEndJob(), and loop().

523 {
524  bool result = false;
525  for ( auto& name: globalCache()->modelNames() ) {
526  result |= globalCache()->eval(name,
527  ecalPreId,
528  hcalPreId,
529  rho,
530  spot,
531  ecalTools);
532  }
533  return passThrough_ || ( pfTrackRef->trackRef()->pt() > maxPtThreshold_ ) || result;
534 }
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 538 of file LowPtGsfElectronSeedProducer.cc.

References passThrough_.

544 {
545  // No implementation currently
546  return passThrough_;
547 }
void LowPtGsfElectronSeedProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 573 of file LowPtGsfElectronSeedProducer.cc.

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

Referenced by globalEndJob().

574 {
576  desc.add<edm::InputTag>("tracks",edm::InputTag("generalTracks"));
577  desc.add<edm::InputTag>("pfTracks",edm::InputTag("lowPtGsfElePfTracks"));
578  desc.add<edm::InputTag>("ecalClusters",edm::InputTag("particleFlowClusterECAL"));
579  desc.add<edm::InputTag>("hcalClusters",edm::InputTag("particleFlowClusterHCAL"));
580  desc.add<edm::InputTag>("EBRecHits",edm::InputTag("ecalRecHit","EcalRecHitsEB"));
581  desc.add<edm::InputTag>("EERecHits",edm::InputTag("ecalRecHit","EcalRecHitsEE"));
582  desc.add<edm::InputTag>("rho",edm::InputTag("fixedGridRhoFastjetAllTmp"));
583  desc.add<edm::InputTag>("BeamSpot",edm::InputTag("offlineBeamSpot"));
584  desc.add<std::string>("Fitter","GsfTrajectoryFitter_forPreId");
585  desc.add<std::string>("Smoother","GsfTrajectorySmoother_forPreId");
586  desc.add<std::string>("TTRHBuilder","WithAngleAndTemplate");
587  desc.add< std::vector<std::string> >("ModelNames",std::vector<std::string>());
588  desc.add< std::vector<std::string> >("ModelWeights",std::vector<std::string>());
589  desc.add< std::vector<double> >("ModelThresholds",std::vector<double>());
590  desc.add<bool>("PassThrough",false);
591  desc.add<bool>("UsePfTracks",true);
592  desc.add<double>("MinPtThreshold",1.0);
593  desc.add<double>("MaxPtThreshold",15.);
594  descriptions.add("lowPtGsfElectronSeeds",desc);
595 }
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 550 of file LowPtGsfElectronSeedProducer.cc.

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

Referenced by globalEndJob(), and produce().

554 {
555  std::vector<reco::PreIdRef> values;
556 
557  unsigned ntracks=tracksHandle->size();
558  for(unsigned itrack=0;itrack<ntracks;++itrack){
559  edm::Ref<CollType> trackRef(tracksHandle,itrack);
560  auto preIdRefIt = trksToPreIdIndx.find(trackRef.index());
561  if(preIdRefIt==trksToPreIdIndx.end()){
562  values.push_back(reco::PreIdRef());
563  }else{
564  edm::Ref<reco::PreIdCollection> preIdRef(preIdHandle,preIdRefIt->second);
565  values.push_back(preIdRef);
566  }
567  }
568  filler.insert(tracksHandle,values.begin(),values.end());
569 }
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 158 of file LowPtGsfElectronSeedProducer.cc.

References cmsBatch::handle.

Referenced by globalEndJob(), and loop().

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

Definition at line 163 of file LowPtGsfElectronSeedProducer.cc.

References cmsBatch::handle.

164 {
165  return reco::PFRecTrackRef(handle,idx)->trackRef();
166 }
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 38 of file LowPtGsfElectronSeedProducer.h.

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

Definition at line 470 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().

474 {
475 
477  for ( unsigned int ihit = 0; ihit < trackRef->recHitsSize(); ++ihit ) {
478  hits.push_back( trackRef->recHit(ihit)->cloneSH() );
479  }
480 
481  GlobalVector gv( trackRef->innerMomentum().x(),
482  trackRef->innerMomentum().y(),
483  trackRef->innerMomentum().z() );
484  GlobalPoint gp( trackRef->innerPosition().x(),
485  trackRef->innerPosition().y(),
486  trackRef->innerPosition().z() );
487 
489  gv,
490  trackRef->charge(),
491  &*field_ );
492 
493  TrajectoryStateOnSurface tsos( gtps,
494  trackRef->innerStateCovariance(),
495  *hits[0]->surface() );
496 
497  // Track fitted and smoothed under electron hypothesis
498  Trajectory traj1 = fitterPtr_->fitOne( seed, hits, tsos );
499  if ( !traj1.isValid() ) { return false; }
500  Trajectory traj2 = smootherPtr_->trajectory(traj1);
501  if ( !traj2.isValid() ) { return false; }
502 
503  // Set PreId content
504  float chi2Ratio = trackRef->chi2() > 0. ? traj2.chiSquared() / trackRef->chi2() : -1.;
505  float gsfReducedChi2 = chi2Ratio > -1. ? chi2Ratio * trackRef->normalizedChi2() : -1.;
506  float ptOut = traj2.firstMeasurement().updatedState().globalMomentum().perp();
507  float ptIn = traj2.lastMeasurement().updatedState().globalMomentum().perp();
508  float gsfDpt = ( ptIn > 0 ) ? fabs( ptOut - ptIn ) / ptIn : 0.;
509  preId.setTrackProperties(gsfReducedChi2,chi2Ratio,gsfDpt);
510 
511  return true;
512 
513 }
edm::ESHandle< MagneticField > field_
std::unique_ptr< TrajectorySmoother > smootherPtr_
T perp() const
Definition: PV3DBase.h:72
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:174
bool isValid() const
Definition: Trajectory.h:279
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:187
float chiSquared() const
Definition: Trajectory.h:262
TrackingRecHit::ConstRecHitContainer ConstRecHitContainer
Definition: Trajectory.h:45
void setTrackProperties(float newchi2, float chi2ratio, float dpt)
Definition: PreId.h:50
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 171 of file LowPtGsfElectronSeedProducer.cc.

References beamSpot_, builder_, TrajectorySmoother::clone(), TrajectoryFitter::clone(), decision(), ebRecHits_, RecoEcal_cff::ecalClusters, ecalClusters_, eeRecHits_, fitter_, fitterPtr_, edm::EventSetup::get(), getBaseRef(), cmsBatch::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().

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

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

Referenced by globalEndJob(), and loop().

307 {
308  propagateTrackToCalo( pfTrackRef, ecalClusters, matchedEcalClusters, ecalPreId, true );
309  propagateTrackToCalo( pfTrackRef, hcalClusters, matchedHcalClusters, hcalPreId, false );
310 }
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 314 of file LowPtGsfElectronSeedProducer.cc.

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

319 {
320 
321  // Store info for PreId
322  struct Info {
324  float dr2min = 1.e6;
325  float deta = 1.e6;
326  float dphi = 1.e6;
327  math::XYZPoint showerPos = math::XYZPoint(0.,0.,0.);
328  } info;
329 
330  // Find closest "seed cluster" to KF track extrapolated to ECAL (or HCAL)
332  if ( ecal ) { point = pfTrackRef->extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::ECALShowerMax); }
333  else { point = pfTrackRef->extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::HCALEntrance); }
334 
335  if ( point.isValid() ) {
336 
337  Info info;
338  for ( unsigned int iclu = 0; iclu < clusters.product()->size(); iclu++ ) {
339 
340  if ( std::find( matched.begin(), matched.end(), iclu ) == matched.end() ) {
341 
342  reco::PFClusterRef cluRef(clusters,iclu);
343 
344  // Determine dR squared
345  float dr2 = reco::deltaR2( cluRef->positionREP(), point.positionREP() );
346 
347  if ( dr2 < info.dr2min ) {
348  info.dr2min = dr2;
349  info.cluRef = cluRef;
350  info.deta = cluRef->positionREP().eta() - point.positionREP().eta();
351  info.dphi =
352  reco::deltaPhi( cluRef->positionREP().phi(), point.positionREP().phi() ) *
353  pfTrackRef->trackRef()->charge();
354  info.showerPos = point.position();
355  }
356 
357  }
358  }
359 
360  // Set PreId content if match found
361  if ( info.dr2min < 1.e5 ) {
362  float ep = info.cluRef->correctedEnergy() / std::sqrt( pfTrackRef->trackRef()->innerMomentum().mag2() );
363  preId.setECALMatchingProperties( info.cluRef,
364  point.position(), // ECAL or HCAL surface
365  info.showerPos, //
366  info.deta,
367  info.dphi,
368  0.f, // chieta
369  0.f, // chiphi
370  pfTrackRef->trackRef()->normalizedChi2(), // chi2
371  ep );
372  }
373 
374  } // clusters
375 
376 }
const REPPoint & positionREP() const
trajectory position in (rho, eta, phi) base
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
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:38
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:20
T sqrt(T t)
Definition: SSEVec.h:18
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:74
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 380 of file LowPtGsfElectronSeedProducer.cc.

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

387 {
388 
389  // Store info for PreId
390  struct Info {
392  float dr2min = 1.e6;
393  float deta = 1.e6;
394  float dphi = 1.e6;
395  math::XYZPoint showerPos = math::XYZPoint(0.,0.,0.);
396  } info;
397 
398  // Propagate 'electron' to ECAL surface
399  float energy = sqrt( mass_ + kfTrackRef->outerMomentum().Mag2() );
400  XYZTLorentzVector mom = XYZTLorentzVector( kfTrackRef->outerMomentum().x(),
401  kfTrackRef->outerMomentum().y(),
402  kfTrackRef->outerMomentum().z(),
403  energy );
404  XYZTLorentzVector pos = XYZTLorentzVector( kfTrackRef->outerPosition().x(),
405  kfTrackRef->outerPosition().y(),
406  kfTrackRef->outerPosition().z(),
407  0. );
408  math::XYZVector field(field_->inTesla(GlobalPoint(0,0,0)));
409  BaseParticlePropagator particle( RawParticle(mom,pos,kfTrackRef->charge()), 0, 0, field.z() );
410  particle.propagateToEcalEntrance(false);
411  if ( particle.getSuccess() == 0 ) { return; }
412 
413  // ECAL entry point for track
414  GlobalPoint ecal_pos(particle.particle().vertex().x(),
415  particle.particle().vertex().y(),
416  particle.particle().vertex().z());
417 
418  // Preshower limit
419  bool below_ps = pow(ecal_pos.z(),2.) > boundary_*ecal_pos.perp2();
420 
421  // Iterate through ECAL clusters
422  for ( unsigned int iclu = 0; iclu < ecalClusters.product()->size(); iclu++ ) {
423  reco::PFClusterRef cluRef(ecalClusters,iclu);
424 
425  // Correct ecal_pos for shower depth
426  double shower_depth = reco::PFCluster::getDepthCorrection(cluRef->correctedEnergy(),
427  below_ps,
428  false);
429  GlobalPoint showerPos = ecal_pos +
430  GlobalVector(particle.particle().momentum().x(),
431  particle.particle().momentum().y(),
432  particle.particle().momentum().z()).unit() * shower_depth;
433 
434  // Determine dR squared
435  float dr2 = reco::deltaR2( cluRef->positionREP(), showerPos );
436 
437  // Find nearest ECAL cluster
438  if ( dr2 < info.dr2min ) {
439  info.dr2min = dr2;
440  info.cluRef = cluRef;
441  info.deta = std::abs( cluRef->positionREP().eta() - showerPos.eta() );
442  info.dphi =
443  std::abs( reco::deltaPhi( cluRef->positionREP().phi(), showerPos.phi() )) *
444  kfTrackRef->charge();
445  info.showerPos = showerPos;
446  }
447 
448  }
449 
450  // Populate PreId object
451  math::XYZPoint point( ecal_pos.x(),
452  ecal_pos.y(),
453  ecal_pos.z() );
454 
455  // Set PreId content
456  ecalPreId.setECALMatchingProperties( info.cluRef,
457  point,
458  info.showerPos,
459  info.deta,
460  info.dphi,
461  0.f, // chieta
462  0.f, // chiphi
463  kfTrackRef->normalizedChi2(), // chi2
464  info.cluRef->correctedEnergy() / std::sqrt( kfTrackRef->innerMomentum().mag2() ) ); // E/p
465 
466 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
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:38
double z() const
z of vertex
Definition: RawParticle.h:303
T sqrt(T t)
Definition: SSEVec.h:18
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:100
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
T const * product() const
Definition: Handle.h:74
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
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:40
*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:27

Member Data Documentation

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

Definition at line 130 of file LowPtGsfElectronSeedProducer.h.

Referenced by loop(), and LowPtGsfElectronSeedProducer().

double LowPtGsfElectronSeedProducer::boundary_ = 2.50746495928*2.50746495928
staticprivate

Definition at line 140 of file LowPtGsfElectronSeedProducer.h.

Referenced by propagateTrackToCalo().

const std::string LowPtGsfElectronSeedProducer::builder_
private

Definition at line 133 of file LowPtGsfElectronSeedProducer.h.

Referenced by loop(), and LowPtGsfElectronSeedProducer().

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

Definition at line 127 of file LowPtGsfElectronSeedProducer.h.

Referenced by loop(), and LowPtGsfElectronSeedProducer().

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

Definition at line 125 of file LowPtGsfElectronSeedProducer.h.

Referenced by loop().

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

Definition at line 128 of file LowPtGsfElectronSeedProducer.h.

Referenced by loop(), and LowPtGsfElectronSeedProducer().

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

Definition at line 131 of file LowPtGsfElectronSeedProducer.h.

Referenced by loop(), and LowPtGsfElectronSeedProducer().

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

Definition at line 121 of file LowPtGsfElectronSeedProducer.h.

Referenced by lightGsfTracking(), and loop().

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

Definition at line 126 of file LowPtGsfElectronSeedProducer.h.

Referenced by LowPtGsfElectronSeedProducer(), and produce().

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

Definition at line 123 of file LowPtGsfElectronSeedProducer.h.

Referenced by LowPtGsfElectronSeedProducer(), and produce().

double LowPtGsfElectronSeedProducer::mass_ = 0.000511*0.000511
staticprivate

Definition at line 142 of file LowPtGsfElectronSeedProducer.h.

Referenced by propagateTrackToCalo().

const double LowPtGsfElectronSeedProducer::maxPtThreshold_
private

Definition at line 137 of file LowPtGsfElectronSeedProducer.h.

Referenced by decision(), and LowPtGsfElectronSeedProducer().

const double LowPtGsfElectronSeedProducer::minPtThreshold_
private

Definition at line 136 of file LowPtGsfElectronSeedProducer.h.

Referenced by loop(), and LowPtGsfElectronSeedProducer().

const bool LowPtGsfElectronSeedProducer::passThrough_
private

Definition at line 134 of file LowPtGsfElectronSeedProducer.h.

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

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

Definition at line 124 of file LowPtGsfElectronSeedProducer.h.

Referenced by LowPtGsfElectronSeedProducer(), and produce().

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

Definition at line 129 of file LowPtGsfElectronSeedProducer.h.

Referenced by loop(), and LowPtGsfElectronSeedProducer().

const std::string LowPtGsfElectronSeedProducer::smoother_
private

Definition at line 132 of file LowPtGsfElectronSeedProducer.h.

Referenced by loop(), and LowPtGsfElectronSeedProducer().

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

Definition at line 122 of file LowPtGsfElectronSeedProducer.h.

Referenced by lightGsfTracking(), and loop().

const bool LowPtGsfElectronSeedProducer::usePfTracks_
private

Definition at line 135 of file LowPtGsfElectronSeedProducer.h.

Referenced by LowPtGsfElectronSeedProducer(), and produce().