CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
TrackAssociatorByHits Class Reference

#include <TrackAssociatorByHits.h>

Inheritance diagram for TrackAssociatorByHits:
TrackAssociatorBase

Public Types

enum  SimToRecoDenomType { denomnone, denomsim, denomreco }
 

Public Member Functions

virtual reco::RecoToSimCollection associateRecoToSim (const edm::RefToBaseVector< reco::Track > &, const edm::RefVector< TrackingParticleCollection > &, const edm::Event *event, const edm::EventSetup *setup) const override
 Association Reco To Sim with Collections. More...
 
virtual reco::RecoToSimCollection associateRecoToSim (edm::Handle< edm::View< reco::Track > > &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event, const edm::EventSetup *setup) const override
 compare reco to sim the handle of reco::Track and TrackingParticle collections More...
 
virtual
reco::RecoToSimCollectionSeed 
associateRecoToSim (edm::Handle< edm::View< TrajectorySeed > > &, edm::Handle< TrackingParticleCollection > &, const edm::Event *event, const edm::EventSetup *setup) const override
 
virtual reco::SimToRecoCollection associateSimToReco (const edm::RefToBaseVector< reco::Track > &, const edm::RefVector< TrackingParticleCollection > &, const edm::Event *event, const edm::EventSetup *setup) const override
 Association Sim To Reco with Collections. More...
 
virtual reco::SimToRecoCollection associateSimToReco (edm::Handle< edm::View< reco::Track > > &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event, const edm::EventSetup *setup) const override
 compare reco to sim the handle of reco::Track and TrackingParticle collections More...
 
virtual
reco::SimToRecoCollectionSeed 
associateSimToReco (edm::Handle< edm::View< TrajectorySeed > > &, edm::Handle< TrackingParticleCollection > &, const edm::Event *event, const edm::EventSetup *setup) const override
 
template<typename iter >
int getDoubleCount (iter, iter, TrackerHitAssociator *, TrackingParticleCollection::const_iterator) const
 
template<typename iter >
int getDoubleCount (iter begin, iter end, TrackerHitAssociator *associate, TrackingParticleCollection::const_iterator t) const
 
template<typename iter >
void getMatchedIds (std::vector< SimHitIdpr > &, std::vector< SimHitIdpr > &, int &, iter, iter, TrackerHitAssociator *) const
 
template<typename iter >
void getMatchedIds (std::vector< SimHitIdpr > &matchedIds, std::vector< SimHitIdpr > &SimTrackIds, int &ri, iter begin, iter end, TrackerHitAssociator *associate) const
 
int getShared (std::vector< SimHitIdpr > &, std::vector< SimHitIdpr > &, TrackingParticleCollection::const_iterator) const
 
 TrackAssociatorByHits (const edm::ParameterSet &)
 
 ~TrackAssociatorByHits ()
 
- Public Member Functions inherited from TrackAssociatorBase
virtual
reco::RecoToSimCollectionTCandidate 
associateRecoToSim (edm::Handle< TrackCandidateCollection > &, edm::Handle< TrackingParticleCollection > &, const edm::Event *event, const edm::EventSetup *setup) const
 
virtual
reco::SimToRecoCollectionTCandidate 
associateSimToReco (edm::Handle< TrackCandidateCollection > &, edm::Handle< TrackingParticleCollection > &, const edm::Event *event, const edm::EventSetup *setup) const
 
 TrackAssociatorBase ()
 Constructor. More...
 
virtual ~TrackAssociatorBase ()
 Destructor. More...
 

Private Member Functions

const TrackingRecHitgetHitPtr (edm::OwnVector< TrackingRecHit >::const_iterator iter) const
 
const TrackingRecHitgetHitPtr (trackingRecHit_iterator iter) const
 

Private Attributes

edm::InputTag _simHitTpMapTag
 
const bool AbsoluteNumberOfHits
 
const edm::ParameterSetconf_
 
const double cut_RecoToSim
 
const double purity_SimToReco
 
const double quality_SimToReco
 
SimToRecoDenomType SimToRecoDenominator
 
const bool ThreeHitTracksAreSpecial
 
const bool UseGrouped
 
const bool UsePixels
 
const bool UseSplitting
 

Detailed Description

Definition at line 21 of file TrackAssociatorByHits.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

TrackAssociatorByHits::TrackAssociatorByHits ( const edm::ParameterSet conf)
explicit

Definition at line 35 of file TrackAssociatorByHits.cc.

References conf_, denomnone, denomreco, denomsim, edm::hlt::Exception, edm::ParameterSet::getParameter(), SimToRecoDenominator, AlCaHLTBitMon_QueryRunRegistry::string, and tmp.

35  :
36  conf_(conf),
37  AbsoluteNumberOfHits(conf_.getParameter<bool>("AbsoluteNumberOfHits")),
39  quality_SimToReco(conf_.getParameter<double>("Quality_SimToReco")),
40  purity_SimToReco(conf_.getParameter<double>("Purity_SimToReco")),
41  cut_RecoToSim(conf_.getParameter<double>("Cut_RecoToSim")),
42  UsePixels(conf_.getParameter<bool>("UsePixels")),
43  UseGrouped(conf_.getParameter<bool>("UseGrouped")),
44  UseSplitting(conf_.getParameter<bool>("UseSplitting")),
45  ThreeHitTracksAreSpecial(conf_.getParameter<bool>("ThreeHitTracksAreSpecial")),
47 {
48  std::string tmp = conf_.getParameter<string>("SimToRecoDenominator");
49  if (tmp=="sim") {
51  } else if (tmp == "reco") {
53  }
54 
56  throw cms::Exception("TrackAssociatorByHits") << "SimToRecoDenominator not specified as sim or reco";
57  }
58 
59 }
T getParameter(std::string const &) const
const edm::ParameterSet & conf_
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
SimToRecoDenomType SimToRecoDenominator
TrackAssociatorByHits::~TrackAssociatorByHits ( )

Definition at line 63 of file TrackAssociatorByHits.cc.

64 {
65  //do cleanup here
66 }

Member Function Documentation

virtual reco::RecoToSimCollection TrackAssociatorByHits::associateRecoToSim ( const edm::RefToBaseVector< reco::Track > &  ,
const edm::RefVector< TrackingParticleCollection > &  ,
const edm::Event event,
const edm::EventSetup setup 
) const
overridevirtual

Association Reco To Sim with Collections.

Implements TrackAssociatorBase.

virtual reco::RecoToSimCollection TrackAssociatorByHits::associateRecoToSim ( edm::Handle< edm::View< reco::Track > > &  tCH,
edm::Handle< TrackingParticleCollection > &  tPCH,
const edm::Event event,
const edm::EventSetup setup 
) const
inlineoverridevirtual

compare reco to sim the handle of reco::Track and TrackingParticle collections

Reimplemented from TrackAssociatorBase.

Definition at line 47 of file TrackAssociatorByHits.h.

References TrackAssociatorBase::associateRecoToSim().

50  {
51  return TrackAssociatorBase::associateRecoToSim(tCH,tPCH,event,setup);
52  }
virtual reco::RecoToSimCollection associateRecoToSim(edm::Handle< edm::View< reco::Track > > &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event, const edm::EventSetup *setup) const
compare reco to sim the handle of reco::Track and TrackingParticle collections
virtual reco::RecoToSimCollectionSeed TrackAssociatorByHits::associateRecoToSim ( edm::Handle< edm::View< TrajectorySeed > > &  ,
edm::Handle< TrackingParticleCollection > &  ,
const edm::Event event,
const edm::EventSetup setup 
) const
overridevirtual

Reimplemented from TrackAssociatorBase.

virtual reco::SimToRecoCollection TrackAssociatorByHits::associateSimToReco ( const edm::RefToBaseVector< reco::Track > &  ,
const edm::RefVector< TrackingParticleCollection > &  ,
const edm::Event event,
const edm::EventSetup setup 
) const
overridevirtual

Association Sim To Reco with Collections.

Implements TrackAssociatorBase.

virtual reco::SimToRecoCollection TrackAssociatorByHits::associateSimToReco ( edm::Handle< edm::View< reco::Track > > &  tCH,
edm::Handle< TrackingParticleCollection > &  tPCH,
const edm::Event event,
const edm::EventSetup setup 
) const
inlineoverridevirtual

compare reco to sim the handle of reco::Track and TrackingParticle collections

Reimplemented from TrackAssociatorBase.

Definition at line 56 of file TrackAssociatorByHits.h.

References TrackAssociatorBase::associateSimToReco().

59  {
60  return TrackAssociatorBase::associateSimToReco(tCH,tPCH,event,setup);
61  }
virtual reco::SimToRecoCollection associateSimToReco(edm::Handle< edm::View< reco::Track > > &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event, const edm::EventSetup *setup) const
compare reco to sim the handle of reco::Track and TrackingParticle collections
virtual reco::SimToRecoCollectionSeed TrackAssociatorByHits::associateSimToReco ( edm::Handle< edm::View< TrajectorySeed > > &  ,
edm::Handle< TrackingParticleCollection > &  ,
const edm::Event event,
const edm::EventSetup setup 
) const
overridevirtual

Reimplemented from TrackAssociatorBase.

template<typename iter >
int TrackAssociatorByHits::getDoubleCount ( iter  ,
iter  ,
TrackerHitAssociator ,
TrackingParticleCollection::const_iterator   
) const
template<typename iter >
int TrackAssociatorByHits::getDoubleCount ( iter  begin,
iter  end,
TrackerHitAssociator associate,
TrackingParticleCollection::const_iterator  t 
) const

Definition at line 521 of file TrackAssociatorByHits.cc.

References TrackerHitAssociator::associateHitId(), end, spr::find(), and getDQMSummary::iter.

524  {
525  int doublecount = 0 ;
526  std::vector<SimHitIdpr> SimTrackIdsDC;
527  // cout<<begin-end<<endl;
528  for (iter it = begin; it != end; it++){
529  int idcount = 0;
530  SimTrackIdsDC.clear();
531  associate->associateHitId(*getHitPtr(it), SimTrackIdsDC);
532  // cout<<SimTrackIdsDC.size()<<endl;
533  if(SimTrackIdsDC.size()>1){
534  // cout<<(t->g4Track_end()-t->g4Track_begin())<<endl;
535  for (TrackingParticle::g4t_iterator g4T = t -> g4Track_begin(); g4T != t -> g4Track_end(); ++g4T) {
536  if(find(SimTrackIdsDC.begin(), SimTrackIdsDC.end(),SimHitIdpr((*g4T).trackId(), SimTrackIdsDC.begin()->second)) != SimTrackIdsDC.end() ){
537  idcount++;
538  }
539  }
540  }
541  if (idcount>1) doublecount+=(idcount-1);
542  }
543  return doublecount;
544 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
const TrackingRecHit * getHitPtr(edm::OwnVector< TrackingRecHit >::const_iterator iter) const
#define end
Definition: vmac.h:37
std::vector< SimTrack >::const_iterator g4t_iterator
std::pair< uint32_t, EncodedEventId > SimHitIdpr
std::vector< SimHitIdpr > associateHitId(const TrackingRecHit &thit) const
#define begin
Definition: vmac.h:30
const TrackingRecHit* TrackAssociatorByHits::getHitPtr ( edm::OwnVector< TrackingRecHit >::const_iterator  iter) const
inlineprivate

Definition at line 103 of file TrackAssociatorByHits.h.

References getDQMSummary::iter.

103 {return &*iter;}
const TrackingRecHit* TrackAssociatorByHits::getHitPtr ( trackingRecHit_iterator  iter) const
inlineprivate

Definition at line 104 of file TrackAssociatorByHits.h.

References getDQMSummary::iter.

104 {return &**iter;}
template<typename iter >
void TrackAssociatorByHits::getMatchedIds ( std::vector< SimHitIdpr > &  ,
std::vector< SimHitIdpr > &  ,
int &  ,
iter  ,
iter  ,
TrackerHitAssociator  
) const
template<typename iter >
void TrackAssociatorByHits::getMatchedIds ( std::vector< SimHitIdpr > &  matchedIds,
std::vector< SimHitIdpr > &  SimTrackIds,
int &  ri,
iter  begin,
iter  end,
TrackerHitAssociator associate 
) const

Definition at line 438 of file TrackAssociatorByHits.cc.

References TrackerHitAssociator::associateHitId(), end, TrackingRecHit::geographicalId(), TrackingRecHit::isValid(), getDQMSummary::iter, j, LogTrace, and DetId::rawId().

443  {
444  matchedIds.clear();
445  ri=0;//valid rechits
446  for (iter it = begin; it != end; it++){
447  const TrackingRecHit *hit=getHitPtr(it);
448  if (hit->isValid()){
449  ri++;
450  uint32_t t_detID= hit->geographicalId().rawId();
451  SimTrackIds.clear();
452  associate->associateHitId(*hit, SimTrackIds);
453  //save all the id of matched simtracks
454  if(!SimTrackIds.empty()){
455  for(size_t j=0; j<SimTrackIds.size(); j++){
456  LogTrace("TrackAssociator") << " hit # " << ri << " valid=" << hit->isValid()
457  << " det id = " << t_detID << " SimId " << SimTrackIds[j].first
458  << " evt=" << SimTrackIds[j].second.event()
459  << " bc=" << SimTrackIds[j].second.bunchCrossing();
460  matchedIds.push_back(SimTrackIds[j]);
461  }
462  }
464  //****to be used when the crossing frame is in the event and with flag TrackAssociatorByHitsESProducer.associateRecoTracks = false
465  //std::vector<PSimHit> tmpSimHits = associate->associateHit(*getHitPtr(it));
467  //for(size_t j=0; j<tmpSimHits.size(); j++) {
468  // LogTrace("TrackAssociator") << " hit # " << ri << " valid=" << getHitPtr(it)->isValid()
469  // << " det id = " << t_detID << " SimId " << SimTrackIds[j].first
470  // << " evt=" << SimTrackIds[j].second.event()
471  // << " bc=" << SimTrackIds[j].second.bunchCrossing()
472  // << " process=" << tmpSimHits[j].processType()
473  // << " eloss=" << tmpSimHits[j].energyLoss()
474  // << " part type=" << tmpSimHits[j].particleType()
475  // << " pabs=" << tmpSimHits[j].pabs()
476  // << " trId=" << tmpSimHits[j].trackId();
477  //}
479  }else{
480  LogTrace("TrackAssociator") <<"\t\t Invalid Hit On "<<hit->geographicalId().rawId();
481  }
482  }//trackingRecHit loop
483 }
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
const TrackingRecHit * getHitPtr(edm::OwnVector< TrackingRecHit >::const_iterator iter) const
int j
Definition: DBlmapReader.cc:9
#define end
Definition: vmac.h:37
#define LogTrace(id)
bool isValid() const
std::vector< SimHitIdpr > associateHitId(const TrackingRecHit &thit) const
#define begin
Definition: vmac.h:30
DetId geographicalId() const
int TrackAssociatorByHits::getShared ( std::vector< SimHitIdpr > &  matchedIds,
std::vector< SimHitIdpr > &  idcachev,
TrackingParticleCollection::const_iterator  t 
) const

Definition at line 486 of file TrackAssociatorByHits.cc.

References prof2calltree::count, spr::find(), and j.

488  {
489  int nshared = 0;
490  if (t->numberOfHits()==0) return nshared;//should use trackerPSimHit but is not const
491 
492  for(size_t j=0; j<matchedIds.size(); j++){
493  //LogTrace("TrackAssociator") << "now matchedId=" << matchedIds[j].first;
494  if(find(idcachev.begin(), idcachev.end(),matchedIds[j]) == idcachev.end() ){
495  //only the first time we see this ID
496  idcachev.push_back(matchedIds[j]);
497 
498  for (TrackingParticle::g4t_iterator g4T = t -> g4Track_begin(); g4T != t -> g4Track_end(); ++g4T) {
499 // LogTrace("TrackAssociator") << " TP (ID, Ev, BC) = " << (*g4T).trackId()
500 // << ", " << t->eventId().event() << ", "<< t->eventId().bunchCrossing()
501 // << " Match(ID, Ev, BC) = " << matchedIds[j].first
502 // << ", " << matchedIds[j].second.event() << ", "
503 // << matchedIds[j].second.bunchCrossing() ;
504  //<< "\t G4 Track Momentum " << (*g4T).momentum()
505  //<< " \t reco Track Momentum " << track->momentum();
506  if((*g4T).trackId() == matchedIds[j].first && t->eventId() == matchedIds[j].second){
507  int countedhits = std::count(matchedIds.begin(), matchedIds.end(), matchedIds[j]);
508  nshared += countedhits;
509 
510 // LogTrace("TrackAssociator") << "hits shared by this segment : " << countedhits;
511 // LogTrace("TrackAssociator") << "hits shared so far : " << nshared;
512  }
513  }//g4Tracks loop
514  }
515  }
516  return nshared;
517 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
int j
Definition: DBlmapReader.cc:9
std::vector< SimTrack >::const_iterator g4t_iterator

Member Data Documentation

edm::InputTag TrackAssociatorByHits::_simHitTpMapTag
private

Definition at line 106 of file TrackAssociatorByHits.h.

const bool TrackAssociatorByHits::AbsoluteNumberOfHits
private

Definition at line 93 of file TrackAssociatorByHits.h.

const edm::ParameterSet& TrackAssociatorByHits::conf_
private

Definition at line 92 of file TrackAssociatorByHits.h.

Referenced by TrackAssociatorByHits().

const double TrackAssociatorByHits::cut_RecoToSim
private

Definition at line 97 of file TrackAssociatorByHits.h.

const double TrackAssociatorByHits::purity_SimToReco
private

Definition at line 96 of file TrackAssociatorByHits.h.

const double TrackAssociatorByHits::quality_SimToReco
private

Definition at line 95 of file TrackAssociatorByHits.h.

SimToRecoDenomType TrackAssociatorByHits::SimToRecoDenominator
private

Definition at line 94 of file TrackAssociatorByHits.h.

Referenced by TrackAssociatorByHits().

const bool TrackAssociatorByHits::ThreeHitTracksAreSpecial
private

Definition at line 101 of file TrackAssociatorByHits.h.

const bool TrackAssociatorByHits::UseGrouped
private

Definition at line 99 of file TrackAssociatorByHits.h.

const bool TrackAssociatorByHits::UsePixels
private

Definition at line 98 of file TrackAssociatorByHits.h.

const bool TrackAssociatorByHits::UseSplitting
private

Definition at line 100 of file TrackAssociatorByHits.h.