CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HSCPTrackSelectorModule.cc
Go to the documentation of this file.
1 
2 // -*- C++ -*-
3 //
4 // Package: HSCPTrackSelector
5 // Class: HSCPTrackSelector
6 //
7 // Original Author: Loic Quertenmont
8 // Created: Mon Apr 23 CDT 2012
9 //
10 
11 
14 
21 
22 // the following include is necessary to clone all track branches
23 // including recoTrackExtras and TrackingRecHitsOwned (in future also "owned clusters"?).
24 // if you remove it the code will compile, but the cloned
25 // tracks have only the recoTracks branch!
27 
29  typedef std::vector<const reco::Track*> container;
30  typedef container::const_iterator const_iterator;
32 
34  trackerTrackPtCut = cfg.getParameter<double>( "trackerTrackPtMin" );
35  dedxTag_ = cfg.getParameter<edm::InputTag>("InputDedx");
36  theMuonSource = cfg.getParameter<edm::InputTag>("muonSource");
37 
38  thedEdxSwitch = cfg.getParameter<bool>("usededx");
39  minInnerTrackdEdx = cfg.getParameter<double>( "InnerTrackdEdxRightMin" );
40  maxInnerTrackdEdx = cfg.getParameter<double>( "InnerTrackdEdxLeftMax" );
41  minMuonTrackdEdx = cfg.getParameter<double>( "InnerMuondEdxRightMin" );
42  maxMuonTrackdEdx = cfg.getParameter<double>( "InnerMuondEdxLeftMax" );
43  mindEdxHitsInnerTrack = cfg.getParameter<unsigned int>( "dEdxMeasurementsMinForInnerTrack" );
44  mindEdxHitsMuonTrack = cfg.getParameter<unsigned int>( "dEdxMeasurementsMinForMuonTrack" );
45  }
46 
47  const_iterator begin() const { return theSelectedTracks.begin(); }
48  const_iterator end() const { return theSelectedTracks.end(); }
49  size_t size() const { return theSelectedTracks.size(); }
50 
52  for(reco::MuonCollection::const_iterator itMuon = muons->begin(); itMuon != muons->end(); ++itMuon){
53  const reco::Track* muonTrack = (*itMuon).get<reco::TrackRef>().get();
54  if (!muonTrack)continue;
55 
56  //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)
57  if(fabs(track->pt()-muonTrack->pt())<0.5 && fabs(track->eta()-muonTrack->eta())<0.02 && fabs(track->phi()-muonTrack->phi())<0.02)return true;
58  }
59  return false;
60  }
61 
62 
63 
66  if(thedEdxSwitch){evt.getByLabel(dedxTag_, dEdxTrackHandle); }
67 
69  evt.getByLabel(theMuonSource, muons);
70 
71  //Loop on all Tracks
72  theSelectedTracks.clear();
73  for(size_t i=0; i<c->size(); i++){
74  reco::TrackRef trkRef = reco::TrackRef(c, i);
75 
76  double dedx=0; unsigned int dedxHit=0; if(thedEdxSwitch){dedx=dEdxTrackHandle->get(i).dEdx(); dedxHit=dEdxTrackHandle->get(i).numberOfMeasurements();} //DIRTY WAY OF ACCESSING DEDX
77  bool isMuon=muons.isValid() && matchingMuon(& *trkRef, muons);
78  //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);
79 
80  if(isMuon){
81  if(thedEdxSwitch && (dedxHit<mindEdxHitsMuonTrack || (dedx>minMuonTrackdEdx && dedx<maxMuonTrackdEdx)) ){continue;}
82  theSelectedTracks.push_back(& * trkRef );
83  }else{
84  if(trkRef->pt()<trackerTrackPtCut)continue;
85  if(thedEdxSwitch && (dedxHit<mindEdxHitsInnerTrack || (dedx>minInnerTrackdEdx && dedx<maxInnerTrackdEdx)) )continue;
86  theSelectedTracks.push_back(& * trkRef );
87  }
88  }
89 
90  //debug printout
91 // for (container::const_iterator it=theSelectedTracks.begin(); it != theSelectedTracks.end(); ++it) {
92 // 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));
93 // }
94  }
95 
96 private:
103  unsigned int mindEdxHitsInnerTrack;
104  unsigned int mindEdxHitsMuonTrack;
108 };
109 
111 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
bool isMuon(const Candidate &part)
Definition: pdgIdUtils.h:11
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
ObjectSelector< HSCPTrackSelector > HSCPTrackSelectorModule
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:139
container::const_iterator const_iterator
reco::TrackCollection collection
const_iterator begin() const
std::vector< const reco::Track * > container
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:141
double pt() const
track transverse momentum
Definition: TrackBase.h:131
bool isValid() const
Definition: HandleBase.h:76
HSCPTrackSelector(const edm::ParameterSet &cfg)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
void select(const edm::Handle< reco::TrackCollection > &c, const edm::Event &evt, const edm::EventSetup &)
const_iterator end() const
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
bool matchingMuon(const reco::Track *track, const edm::Handle< reco::MuonCollection > &muons)
tuple muons
Definition: patZpeak.py:38