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 *, TrackingParticle const &) const
 
template<typename iter >
int getDoubleCount (iter begin, iter end, TrackerHitAssociator *associate, TrackingParticle const &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 > &, TrackingParticle const &) 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 ,
TrackingParticle const &   
) const
template<typename iter >
int TrackAssociatorByHits::getDoubleCount ( iter  begin,
iter  end,
TrackerHitAssociator associate,
TrackingParticle const &  t 
) const

Definition at line 525 of file TrackAssociatorByHits.cc.

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

528  {
529  int doublecount = 0 ;
530  std::vector<SimHitIdpr> SimTrackIdsDC;
531  // cout<<begin-end<<endl;
532  for (iter it = begin; it != end; it++){
533  int idcount = 0;
534  SimTrackIdsDC.clear();
535  associate->associateHitId(*getHitPtr(it), SimTrackIdsDC);
536  // cout<<SimTrackIdsDC.size()<<endl;
537  if(SimTrackIdsDC.size()>1){
538  // cout<<(t.g4Track_end()-t.g4Track_begin())<<endl;
539  for (TrackingParticle::g4t_iterator g4T = t . g4Track_begin(); g4T != t . g4Track_end(); ++g4T) {
540  if(find(SimTrackIdsDC.begin(), SimTrackIdsDC.end(),SimHitIdpr((*g4T).trackId(), SimTrackIdsDC.begin()->second)) != SimTrackIdsDC.end() ){
541  idcount++;
542  }
543  }
544  }
545  if (idcount>1) doublecount+=(idcount-1);
546  }
547  return doublecount;
548 }
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 442 of file TrackAssociatorByHits.cc.

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

447  {
448  matchedIds.clear();
449  ri=0;//valid rechits
450  for (iter it = begin; it != end; it++){
451  const TrackingRecHit *hit=getHitPtr(it);
452  if (hit->isValid()){
453  ri++;
454  uint32_t t_detID= hit->geographicalId().rawId();
455  SimTrackIds.clear();
456  associate->associateHitId(*hit, SimTrackIds);
457  //save all the id of matched simtracks
458  if(!SimTrackIds.empty()){
459  for(size_t j=0; j<SimTrackIds.size(); j++){
460  LogTrace("TrackAssociator") << " hit # " << ri << " valid=" << hit->isValid()
461  << " det id = " << t_detID << " SimId " << SimTrackIds[j].first
462  << " evt=" << SimTrackIds[j].second.event()
463  << " bc=" << SimTrackIds[j].second.bunchCrossing();
464  matchedIds.push_back(SimTrackIds[j]);
465  }
466  }
468  //****to be used when the crossing frame is in the event and with flag TrackAssociatorByHitsESProducer.associateRecoTracks = false
469  //std::vector<PSimHit> tmpSimHits = associate->associateHit(*getHitPtr(it));
471  //for(size_t j=0; j<tmpSimHits.size(); j++) {
472  // LogTrace("TrackAssociator") << " hit # " << ri << " valid=" << getHitPtr(it)->isValid()
473  // << " det id = " << t_detID << " SimId " << SimTrackIds[j].first
474  // << " evt=" << SimTrackIds[j].second.event()
475  // << " bc=" << SimTrackIds[j].second.bunchCrossing()
476  // << " process=" << tmpSimHits[j].processType()
477  // << " eloss=" << tmpSimHits[j].energyLoss()
478  // << " part type=" << tmpSimHits[j].particleType()
479  // << " pabs=" << tmpSimHits[j].pabs()
480  // << " trId=" << tmpSimHits[j].trackId();
481  //}
483  }else{
484  LogTrace("TrackAssociator") <<"\t\t Invalid Hit On "<<hit->geographicalId().rawId();
485  }
486  }//trackingRecHit loop
487 }
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,
TrackingParticle const &  t 
) const

Definition at line 490 of file TrackAssociatorByHits.cc.

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

492  {
493  int nshared = 0;
494  if (t.numberOfHits()==0) return nshared;//should use trackerPSimHit but is not const
495 
496  for(size_t j=0; j<matchedIds.size(); j++){
497  //LogTrace("TrackAssociator") << "now matchedId=" << matchedIds[j].first;
498  if(find(idcachev.begin(), idcachev.end(),matchedIds[j]) == idcachev.end() ){
499  //only the first time we see this ID
500  idcachev.push_back(matchedIds[j]);
501 
502  for (TrackingParticle::g4t_iterator g4T = t . g4Track_begin(); g4T != t . g4Track_end(); ++g4T) {
503 // LogTrace("TrackAssociator") << " TP (ID, Ev, BC) = " << (*g4T).trackId()
504 // << ", " << t.eventId().event() << ", "<< t.eventId().bunchCrossing()
505 // << " Match(ID, Ev, BC) = " << matchedIds[j].first
506 // << ", " << matchedIds[j].second.event() << ", "
507 // << matchedIds[j].second.bunchCrossing() ;
508  //<< "\t G4 Track Momentum " << (*g4T).momentum()
509  //<< " \t reco Track Momentum " << track->momentum();
510  if((*g4T).trackId() == matchedIds[j].first && t.eventId() == matchedIds[j].second){
511  int countedhits = std::count(matchedIds.begin(), matchedIds.end(), matchedIds[j]);
512  nshared += countedhits;
513 
514 // LogTrace("TrackAssociator") << "hits shared by this segment : " << countedhits;
515 // LogTrace("TrackAssociator") << "hits shared so far : " << nshared;
516  }
517  }//g4Tracks loop
518  }
519  }
520  return nshared;
521 }
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.