CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

TrackAssociatorByHits Class Reference

#include <TrackAssociatorByHits.h>

Inheritance diagram for TrackAssociatorByHits:
TrackAssociatorBase

List of all members.

Public Types

enum  SimToRecoDenomType { denomnone, denomsim, denomreco }

Public Member Functions

reco::RecoToSimCollection associateRecoToSim (const edm::RefToBaseVector< reco::Track > &, const edm::RefVector< TrackingParticleCollection > &, const edm::Event *event, const edm::EventSetup *setup) const
 Association Reco To Sim with Collections.
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
reco::RecoToSimCollectionSeed associateRecoToSim (edm::Handle< edm::View< TrajectorySeed > > &, edm::Handle< TrackingParticleCollection > &, const edm::Event *event, const edm::EventSetup *setup) const
reco::SimToRecoCollectionSeed associateSimToReco (edm::Handle< edm::View< TrajectorySeed > > &, edm::Handle< TrackingParticleCollection > &, const edm::Event *event, const edm::EventSetup *setup) const
reco::SimToRecoCollection associateSimToReco (const edm::RefToBaseVector< reco::Track > &, const edm::RefVector< TrackingParticleCollection > &, const edm::Event *event, const edm::EventSetup *setup) const
 Association Sim To Reco with Collections.
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
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 > &matchedIds, std::vector< SimHitIdpr > &SimTrackIds, int &ri, iter begin, iter end, TrackerHitAssociator *associate) const
template<typename iter >
void getMatchedIds (std::vector< SimHitIdpr > &, std::vector< SimHitIdpr > &, int &, iter, iter, TrackerHitAssociator *) const
int getShared (std::vector< SimHitIdpr > &, std::vector< SimHitIdpr > &, TrackingParticleCollection::const_iterator) const
 TrackAssociatorByHits (const edm::ParameterSet &)
 ~TrackAssociatorByHits ()

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

Enumerator:
denomnone 
denomsim 
denomreco 

Definition at line 25 of file TrackAssociatorByHits.h.


Constructor & Destructor Documentation

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

Definition at line 35 of file TrackAssociatorByHits.cc.

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

                                                                         :  
  conf_(conf),
  AbsoluteNumberOfHits(conf_.getParameter<bool>("AbsoluteNumberOfHits")),
  SimToRecoDenominator(denomnone),
  quality_SimToReco(conf_.getParameter<double>("Quality_SimToReco")),
  purity_SimToReco(conf_.getParameter<double>("Purity_SimToReco")),
  cut_RecoToSim(conf_.getParameter<double>("Cut_RecoToSim")),
  UsePixels(conf_.getParameter<bool>("UsePixels")),
  UseGrouped(conf_.getParameter<bool>("UseGrouped")),
  UseSplitting(conf_.getParameter<bool>("UseSplitting")),
  ThreeHitTracksAreSpecial(conf_.getParameter<bool>("ThreeHitTracksAreSpecial")),
  _simHitTpMapTag(conf_.getParameter<edm::InputTag>("simHitTpMapTag"))
{
  std::string tmp = conf_.getParameter<string>("SimToRecoDenominator");
  if (tmp=="sim") {
    SimToRecoDenominator = denomsim;
  } else if (tmp == "reco") {
    SimToRecoDenominator = denomreco;
  } 

  if (SimToRecoDenominator == denomnone) {
    throw cms::Exception("TrackAssociatorByHits") << "SimToRecoDenominator not specified as sim or reco";
  }

}
TrackAssociatorByHits::~TrackAssociatorByHits ( )

Definition at line 63 of file TrackAssociatorByHits.cc.

{
  //do cleanup here
}

Member Function Documentation

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

Association Reco To Sim with Collections.

Implements TrackAssociatorBase.

Referenced by associateRecoToSim().

reco::RecoToSimCollectionSeed TrackAssociatorByHits::associateRecoToSim ( edm::Handle< edm::View< TrajectorySeed > > &  ,
edm::Handle< TrackingParticleCollection > &  ,
const edm::Event event,
const edm::EventSetup setup 
) const [virtual]

Reimplemented from TrackAssociatorBase.

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

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

Reimplemented from TrackAssociatorBase.

Definition at line 44 of file TrackAssociatorByHits.h.

References associateRecoToSim().

                                                                                   {
    return TrackAssociatorBase::associateRecoToSim(tCH,tPCH,event,setup);
  }
reco::SimToRecoCollection TrackAssociatorByHits::associateSimToReco ( edm::Handle< edm::View< reco::Track > > &  tCH,
edm::Handle< TrackingParticleCollection > &  tPCH,
const edm::Event event,
const edm::EventSetup setup 
) const [inline, virtual]

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

Reimplemented from TrackAssociatorBase.

Definition at line 52 of file TrackAssociatorByHits.h.

References associateSimToReco().

                                                                                   {
    return TrackAssociatorBase::associateSimToReco(tCH,tPCH,event,setup);
  }  
reco::SimToRecoCollection TrackAssociatorByHits::associateSimToReco ( const edm::RefToBaseVector< reco::Track > &  ,
const edm::RefVector< TrackingParticleCollection > &  ,
const edm::Event event,
const edm::EventSetup setup 
) const [virtual]

Association Sim To Reco with Collections.

Implements TrackAssociatorBase.

Referenced by associateSimToReco().

reco::SimToRecoCollectionSeed TrackAssociatorByHits::associateSimToReco ( edm::Handle< edm::View< TrajectorySeed > > &  ,
edm::Handle< TrackingParticleCollection > &  ,
const edm::Event event,
const edm::EventSetup setup 
) const [virtual]

Reimplemented from TrackAssociatorBase.

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, and spr::find().

                                                                                            {
  int doublecount = 0 ;
  std::vector<SimHitIdpr> SimTrackIdsDC;
  //  cout<<begin-end<<endl;
  for (iter it = begin;  it != end; it++){
    int idcount = 0;
    SimTrackIdsDC.clear();
    associate->associateHitId(*getHitPtr(it), SimTrackIdsDC);
    //    cout<<SimTrackIdsDC.size()<<endl;
    if(SimTrackIdsDC.size()>1){
      //     cout<<(t->g4Track_end()-t->g4Track_begin())<<endl;
      for (TrackingParticle::g4t_iterator g4T = t -> g4Track_begin(); g4T !=  t -> g4Track_end(); ++g4T) {
        if(find(SimTrackIdsDC.begin(), SimTrackIdsDC.end(),SimHitIdpr((*g4T).trackId(), SimTrackIdsDC.begin()->second)) != SimTrackIdsDC.end() ){
          idcount++;
        }
      }
    }
    if (idcount>1) doublecount+=(idcount-1);
  }
  return doublecount;
}
template<typename iter >
int TrackAssociatorByHits::getDoubleCount ( iter  ,
iter  ,
TrackerHitAssociator ,
TrackingParticleCollection::const_iterator   
) const
const TrackingRecHit* TrackAssociatorByHits::getHitPtr ( trackingRecHit_iterator  iter) const [inline, private]

Definition at line 98 of file TrackAssociatorByHits.h.

{return &**iter;}
const TrackingRecHit* TrackAssociatorByHits::getHitPtr ( edm::OwnVector< TrackingRecHit >::const_iterator  iter) const [inline, private]

Definition at line 97 of file TrackAssociatorByHits.h.

{return &*iter;}
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(), j, LogTrace, and DetId::rawId().

                                                                                  {
    matchedIds.clear();
    ri=0;//valid rechits
    for (iter it = begin;  it != end; it++){
      const TrackingRecHit *hit=getHitPtr(it);
      if (hit->isValid()){
        ri++;
        uint32_t t_detID=  hit->geographicalId().rawId();
        SimTrackIds.clear();      
        associate->associateHitId(*hit, SimTrackIds);
        //save all the id of matched simtracks
        if(!SimTrackIds.empty()){
         for(size_t j=0; j<SimTrackIds.size(); j++){
           LogTrace("TrackAssociator") << " hit # " << ri << " valid=" << hit->isValid() 
                                       << " det id = " << t_detID << " SimId " << SimTrackIds[j].first 
                                       << " evt=" << SimTrackIds[j].second.event() 
                                       << " bc=" << SimTrackIds[j].second.bunchCrossing();  
           matchedIds.push_back(SimTrackIds[j]);                        
         }
        }
        //****to be used when the crossing frame is in the event and with flag TrackAssociatorByHitsESProducer.associateRecoTracks = false
        //std::vector<PSimHit> tmpSimHits = associate->associateHit(*getHitPtr(it));
        //for(size_t j=0; j<tmpSimHits.size(); j++) {
        //  LogTrace("TrackAssociator") << " hit # " << ri << " valid=" << getHitPtr(it)->isValid()
        //                              << " det id = " << t_detID << " SimId " << SimTrackIds[j].first
        //                              << " evt=" << SimTrackIds[j].second.event()
        //                              << " bc=" << SimTrackIds[j].second.bunchCrossing()
        //                              << " process=" << tmpSimHits[j].processType()
        //                              << " eloss=" << tmpSimHits[j].energyLoss()
        //                              << " part type=" << tmpSimHits[j].particleType()
        //                              << " pabs=" << tmpSimHits[j].pabs()
        //                              << " trId=" << tmpSimHits[j].trackId();
        //}
      }else{
        LogTrace("TrackAssociator") <<"\t\t Invalid Hit On "<<hit->geographicalId().rawId();
      }
    }//trackingRecHit loop
}
template<typename iter >
void TrackAssociatorByHits::getMatchedIds ( std::vector< SimHitIdpr > &  ,
std::vector< SimHitIdpr > &  ,
int &  ,
iter  ,
iter  ,
TrackerHitAssociator  
) 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.

                                                                                       {
  int nshared = 0;
  if (t->numberOfHits()==0) return nshared;//should use trackerPSimHit but is not const

  for(size_t j=0; j<matchedIds.size(); j++){
    //LogTrace("TrackAssociator") << "now matchedId=" << matchedIds[j].first;
    if(find(idcachev.begin(), idcachev.end(),matchedIds[j]) == idcachev.end() ){
      //only the first time we see this ID 
      idcachev.push_back(matchedIds[j]);
      
      for (TrackingParticle::g4t_iterator g4T = t -> g4Track_begin(); g4T !=  t -> g4Track_end(); ++g4T) {
//      LogTrace("TrackAssociator") << " TP   (ID, Ev, BC) = " << (*g4T).trackId() 
//                                  << ", " << t->eventId().event() << ", "<< t->eventId().bunchCrossing()
//                                  << " Match(ID, Ev, BC) = " <<  matchedIds[j].first
//                                  << ", " << matchedIds[j].second.event() << ", "
//                                  << matchedIds[j].second.bunchCrossing() ;
                                    //<< "\t G4  Track Momentum " << (*g4T).momentum() 
                                    //<< " \t reco Track Momentum " << track->momentum();             
        if((*g4T).trackId() == matchedIds[j].first && t->eventId() == matchedIds[j].second){
                int countedhits = std::count(matchedIds.begin(), matchedIds.end(), matchedIds[j]);
                nshared += countedhits;

//              LogTrace("TrackAssociator") << "hits shared by this segment : " << countedhits;
//              LogTrace("TrackAssociator") << "hits shared so far : " << nshared;
        }
      }//g4Tracks loop
    }
  }
  return nshared;
}

Member Data Documentation

Definition at line 100 of file TrackAssociatorByHits.h.

Definition at line 87 of file TrackAssociatorByHits.h.

Definition at line 86 of file TrackAssociatorByHits.h.

Referenced by TrackAssociatorByHits().

const double TrackAssociatorByHits::cut_RecoToSim [private]

Definition at line 91 of file TrackAssociatorByHits.h.

Definition at line 90 of file TrackAssociatorByHits.h.

Definition at line 89 of file TrackAssociatorByHits.h.

Definition at line 88 of file TrackAssociatorByHits.h.

Referenced by TrackAssociatorByHits().

Definition at line 95 of file TrackAssociatorByHits.h.

const bool TrackAssociatorByHits::UseGrouped [private]

Definition at line 93 of file TrackAssociatorByHits.h.

const bool TrackAssociatorByHits::UsePixels [private]

Definition at line 92 of file TrackAssociatorByHits.h.

Definition at line 94 of file TrackAssociatorByHits.h.