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=0, const edm::EventSetup *setup=0) 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=0, const edm::EventSetup *setup=0) const
 compare reco to sim the handle of reco::Track and TrackingParticle collections
reco::RecoToSimCollectionSeed associateRecoToSim (const edm::Handle< edm::View< TrajectorySeed > > &, const edm::Handle< TrackingParticleCollection > &, const edm::Event *event=0, const edm::EventSetup *setup=0) const
reco::SimToRecoCollectionSeed associateSimToReco (const edm::Handle< edm::View< TrajectorySeed > > &, const edm::Handle< TrackingParticleCollection > &, const edm::Event *event=0, const edm::EventSetup *setup=0) const
reco::SimToRecoCollection associateSimToReco (const edm::RefToBaseVector< reco::Track > &, const edm::RefVector< TrackingParticleCollection > &, const edm::Event *event=0, const edm::EventSetup *setup=0) 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=0, const edm::EventSetup *setup=0) 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
int LayerFromDetid (const DetId &) const

Private Attributes

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 38 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"))
{
  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 65 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 = 0,
const edm::EventSetup setup = 0 
) const [virtual]

Association Reco To Sim with Collections.

Implements TrackAssociatorBase.

Referenced by associateRecoToSim().

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

Reimplemented from TrackAssociatorBase.

reco::RecoToSimCollection TrackAssociatorByHits::associateRecoToSim ( edm::Handle< edm::View< reco::Track > > &  tCH,
edm::Handle< TrackingParticleCollection > &  tPCH,
const edm::Event event = 0,
const edm::EventSetup setup = 0 
) 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(), event(), and HcalObjRepresent::setup().

                                                                                      {
    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 = 0,
const edm::EventSetup setup = 0 
) 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(), event(), and HcalObjRepresent::setup().

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

Association Sim To Reco with Collections.

Implements TrackAssociatorBase.

Referenced by associateSimToReco().

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

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 546 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;
}
const TrackingRecHit* TrackAssociatorByHits::getHitPtr ( edm::OwnVector< TrackingRecHit >::const_iterator  iter) const [inline, private]

Definition at line 98 of file TrackAssociatorByHits.h.

{return &*iter;}
const TrackingRecHit* TrackAssociatorByHits::getHitPtr ( trackingRecHit_iterator  iter) const [inline, private]

Definition at line 99 of file TrackAssociatorByHits.h.

{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 463 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
}
int TrackAssociatorByHits::getShared ( std::vector< SimHitIdpr > &  matchedIds,
std::vector< SimHitIdpr > &  idcachev,
TrackingParticleCollection::const_iterator  t 
) const

Definition at line 511 of file TrackAssociatorByHits.cc.

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

                                                                                       {
  int nshared = 0;
  if (t->trackPSimHit().size()==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;
}
int TrackAssociatorByHits::LayerFromDetid ( const DetId detId) const [private]

Definition at line 291 of file TrackAssociatorByHits.cc.

References PXFDetId::disk(), TIBDetId::layer(), TOBDetId::layer(), PXBDetId::layer(), align::tib::layerNumber(), LogTrace, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, DetId::rawId(), DetId::subdetId(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, TIDDetId::wheel(), and TECDetId::wheel().

{
  int layerNumber=0;
  unsigned int subdetId = static_cast<unsigned int>(detId.subdetId()); 
  if ( subdetId == StripSubdetector::TIB) 
    { 
      TIBDetId tibid(detId.rawId()); 
      layerNumber = tibid.layer();
    }
  else if ( subdetId ==  StripSubdetector::TOB )
    { 
      TOBDetId tobid(detId.rawId()); 
      layerNumber = tobid.layer();
    }
  else if ( subdetId ==  StripSubdetector::TID) 
    { 
      TIDDetId tidid(detId.rawId());
      layerNumber = tidid.wheel();
    }
  else if ( subdetId ==  StripSubdetector::TEC )
    { 
      TECDetId tecid(detId.rawId()); 
      layerNumber = tecid.wheel(); 
    }
  else if ( subdetId ==  PixelSubdetector::PixelBarrel ) 
    { 
      PXBDetId pxbid(detId.rawId()); 
      layerNumber = pxbid.layer();  
    }
  else if ( subdetId ==  PixelSubdetector::PixelEndcap ) 
    { 
      PXFDetId pxfid(detId.rawId()); 
      layerNumber = pxfid.disk();  
    }
  else
    LogTrace("TrackAssociator") << "Unknown subdetid: " <<  subdetId;
  
  return layerNumber;
} 

Member Data Documentation

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.