CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

HSCPTrackSelector Struct Reference

List of all members.

Public Types

typedef reco::TrackCollection collection
typedef container::const_iterator const_iterator
typedef std::vector< const
reco::Track * > 
container

Public Member Functions

const_iterator begin () const
const_iterator end () const
 HSCPTrackSelector (const edm::ParameterSet &cfg)
bool matchingMuon (const reco::Track *track, const edm::Handle< reco::MuonCollection > &muons)
void select (const edm::Handle< reco::TrackCollection > &c, const edm::Event &evt, const edm::EventSetup &)
size_t size () const

Private Attributes

edm::InputTag dedxTag_
double maxInnerTrackdEdx
double maxMuonTrackdEdx
unsigned int mindEdxHitsInnerTrack
unsigned int mindEdxHitsMuonTrack
double minInnerTrackdEdx
double minMuonTrackdEdx
bool thedEdxSwitch
edm::InputTag theMuonSource
container theSelectedTracks
double trackerTrackPtCut

Detailed Description

Definition at line 28 of file HSCPTrackSelectorModule.cc.


Member Typedef Documentation

Definition at line 31 of file HSCPTrackSelectorModule.cc.

typedef container::const_iterator HSCPTrackSelector::const_iterator

Definition at line 30 of file HSCPTrackSelectorModule.cc.

typedef std::vector<const reco::Track*> HSCPTrackSelector::container

Definition at line 29 of file HSCPTrackSelectorModule.cc.


Constructor & Destructor Documentation

HSCPTrackSelector::HSCPTrackSelector ( const edm::ParameterSet cfg) [inline]

Definition at line 33 of file HSCPTrackSelectorModule.cc.

References dedxTag_, edm::ParameterSet::getParameter(), maxInnerTrackdEdx, maxMuonTrackdEdx, mindEdxHitsInnerTrack, mindEdxHitsMuonTrack, minInnerTrackdEdx, minMuonTrackdEdx, thedEdxSwitch, theMuonSource, and trackerTrackPtCut.

                                                 {
    trackerTrackPtCut = cfg.getParameter<double>( "trackerTrackPtMin" );
    dedxTag_          = cfg.getParameter<edm::InputTag>("InputDedx");
    theMuonSource     = cfg.getParameter<edm::InputTag>("muonSource");

    thedEdxSwitch         = cfg.getParameter<bool>("usededx");
    minInnerTrackdEdx     = cfg.getParameter<double>( "InnerTrackdEdxRightMin" );
    maxInnerTrackdEdx     = cfg.getParameter<double>( "InnerTrackdEdxLeftMax" );
    minMuonTrackdEdx      = cfg.getParameter<double>( "InnerMuondEdxRightMin" );
    maxMuonTrackdEdx      = cfg.getParameter<double>( "InnerMuondEdxLeftMax" );
    mindEdxHitsInnerTrack = cfg.getParameter<unsigned int>( "dEdxMeasurementsMinForInnerTrack" );
    mindEdxHitsMuonTrack  = cfg.getParameter<unsigned int>( "dEdxMeasurementsMinForMuonTrack" );
  }

Member Function Documentation

const_iterator HSCPTrackSelector::begin ( void  ) const [inline]

Definition at line 47 of file HSCPTrackSelectorModule.cc.

References theSelectedTracks.

{ return theSelectedTracks.begin(); }
const_iterator HSCPTrackSelector::end ( void  ) const [inline]

Definition at line 48 of file HSCPTrackSelectorModule.cc.

References theSelectedTracks.

{ return theSelectedTracks.end(); }
bool HSCPTrackSelector::matchingMuon ( const reco::Track track,
const edm::Handle< reco::MuonCollection > &  muons 
) [inline]

Definition at line 51 of file HSCPTrackSelectorModule.cc.

References reco::TrackBase::eta(), reco::TrackBase::phi(), and reco::TrackBase::pt().

Referenced by select().

                                                                                       {
    for(reco::MuonCollection::const_iterator itMuon = muons->begin(); itMuon != muons->end(); ++itMuon){
      const reco::Track* muonTrack = (*itMuon).get<reco::TrackRef>().get();
      if (!muonTrack)continue;

      //matching is needed because input track collection (made for dE/dx) has been refitted w.r.t track collection used for muon reco (we should do a tight maching to find equivalent track in the other collection)
      if(fabs(track->pt()-muonTrack->pt())<0.5 && fabs(track->eta()-muonTrack->eta())<0.02 && fabs(track->phi()-muonTrack->phi())<0.02)return true;
    }
    return false;
  }
void HSCPTrackSelector::select ( const edm::Handle< reco::TrackCollection > &  c,
const edm::Event evt,
const edm::EventSetup  
) [inline]

Definition at line 64 of file HSCPTrackSelectorModule.cc.

References dedxTag_, edm::Event::getByLabel(), i, reco::isMuon(), edm::HandleBase::isValid(), matchingMuon(), maxInnerTrackdEdx, maxMuonTrackdEdx, mindEdxHitsInnerTrack, mindEdxHitsMuonTrack, minInnerTrackdEdx, minMuonTrackdEdx, patZpeak::muons, thedEdxSwitch, theMuonSource, theSelectedTracks, and trackerTrackPtCut.

                                                                                                       {
    edm::Handle<edm::ValueMap<reco::DeDxData> > dEdxTrackHandle;
    if(thedEdxSwitch){evt.getByLabel(dedxTag_, dEdxTrackHandle); }

    edm::Handle<reco::MuonCollection> muons;
    evt.getByLabel(theMuonSource, muons);

    //Loop on all Tracks
    theSelectedTracks.clear();
    for(size_t i=0; i<c->size(); i++){
      reco::TrackRef trkRef = reco::TrackRef(c, i);
      
      double dedx=0; unsigned int dedxHit=0; if(thedEdxSwitch){dedx=dEdxTrackHandle->get(i).dEdx(); dedxHit=dEdxTrackHandle->get(i).numberOfMeasurements();}  //DIRTY WAY OF ACCESSING DEDX
      bool isMuon=muons.isValid() && matchingMuon(& *trkRef, muons);
      //printf("muon tracks %i --> pt=%6.2f  eta=%+6.2f phi=%+6.2f dEdx=%f\n", (int)isMuon,  trkRef->pt(), trkRef->eta(), trkRef->phi(), dedx);
      
      if(isMuon){
         if(thedEdxSwitch && (dedxHit<mindEdxHitsMuonTrack || (dedx>minMuonTrackdEdx && dedx<maxMuonTrackdEdx)) ){continue;}     
         theSelectedTracks.push_back(& * trkRef );
      }else{
         if(trkRef->pt()<trackerTrackPtCut)continue;
         if(thedEdxSwitch && (dedxHit<mindEdxHitsInnerTrack || (dedx>minInnerTrackdEdx && dedx<maxInnerTrackdEdx)) )continue;
         theSelectedTracks.push_back(& * trkRef );
      }
    }

    //debug printout
//    for (container::const_iterator it=theSelectedTracks.begin(); it != theSelectedTracks.end(); ++it) {
//       printf("Selected tracks %i --> pt=%6.2f  eta=%+6.2f phi=%+6.2f - isMuon=%i\n", (int)(it-theSelectedTracks.begin()),  (*it)->pt(), (*it)->eta(), (*it)->phi(), matchingMuon(*it, theSelectedMuonTracks));
//    }
  }
size_t HSCPTrackSelector::size ( void  ) const [inline]

Definition at line 49 of file HSCPTrackSelectorModule.cc.

References theSelectedTracks.

{ return theSelectedTracks.size(); }

Member Data Documentation

Definition at line 105 of file HSCPTrackSelectorModule.cc.

Referenced by HSCPTrackSelector(), and select().

Definition at line 100 of file HSCPTrackSelectorModule.cc.

Referenced by HSCPTrackSelector(), and select().

Definition at line 102 of file HSCPTrackSelectorModule.cc.

Referenced by HSCPTrackSelector(), and select().

Definition at line 103 of file HSCPTrackSelectorModule.cc.

Referenced by HSCPTrackSelector(), and select().

Definition at line 104 of file HSCPTrackSelectorModule.cc.

Referenced by HSCPTrackSelector(), and select().

Definition at line 99 of file HSCPTrackSelectorModule.cc.

Referenced by HSCPTrackSelector(), and select().

Definition at line 101 of file HSCPTrackSelectorModule.cc.

Referenced by HSCPTrackSelector(), and select().

Definition at line 107 of file HSCPTrackSelectorModule.cc.

Referenced by HSCPTrackSelector(), and select().

Definition at line 106 of file HSCPTrackSelectorModule.cc.

Referenced by HSCPTrackSelector(), and select().

Definition at line 97 of file HSCPTrackSelectorModule.cc.

Referenced by begin(), end(), select(), and size().

Definition at line 98 of file HSCPTrackSelectorModule.cc.

Referenced by HSCPTrackSelector(), and select().