ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/DGele/PhysicsTools/RecoAlgos/interface/RecoTrackSelector.h
Revision: 1.2
Committed: Tue Oct 20 17:43:17 2009 UTC (15 years, 6 months ago) by dgele
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +2 -2 lines
State: FILE REMOVED
Error occurred while calculating annotation data.
Log Message:
remove

File Contents

# Content
1 #ifndef RecoSelectors_RecoTrackSelector_h
2 #define RecoSelectors_RecoTrackSelector_h
3 /* \class RecoTrackSelector
4 *
5 * \author Giuseppe Cerati, INFN
6 *
7 * $Date: 2009/10/20 17:15:14 $
8 * $Revision: 1.1 $
9 *
10 */
11 #include "DataFormats/TrackReco/interface/Track.h"
12 #include "DataFormats/TrackReco/interface/TrackFwd.h"
13 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
14
15 class RecoTrackSelector {
16 public:
17 typedef reco::TrackCollection collection;
18 typedef std::vector<const reco::Track *> container;
19 typedef container::const_iterator const_iterator;
20
21 /// Constructors
22 RecoTrackSelector() {}
23 RecoTrackSelector ( const edm::ParameterSet & cfg ) :
24 ptMin_(cfg.getParameter<double>("ptMin")),
25 minRapidity_(cfg.getParameter<double>("minRapidity")),
26 maxRapidity_(cfg.getParameter<double>("maxRapidity")),
27 tip_(cfg.getParameter<double>("tip")),
28 lip_(cfg.getParameter<double>("lip")),
29 minHit_(cfg.getParameter<int>("minHit")),
30 maxChi2_(cfg.getParameter<double>("maxChi2")),
31 quality_(cfg.getParameter<std::string>("quality")),
32 algorithm_(cfg.getParameter<std::string>("algorithm")) { }
33
34 RecoTrackSelector ( double ptMin, double minRapidity, double maxRapidity,
35 double tip, double lip, int minHit, double maxChi2,
36 std::string quality , std::string algorithm ) :
37 ptMin_( ptMin ), minRapidity_( minRapidity ), maxRapidity_( maxRapidity ),
38 tip_( tip ), lip_( lip ), minHit_( minHit ), maxChi2_( maxChi2 ),
39 quality_(quality),algorithm_(algorithm) { }
40
41 const_iterator begin() const { return selected_.begin(); }
42 const_iterator end() const { return selected_.end(); }
43
44 void select( const edm::Handle<collection>& c, const edm::Event & event, const edm::EventSetup&) {
45 selected_.clear();
46 edm::Handle<reco::BeamSpot> beamSpot;
47 event.getByLabel("offlineBeamSpot",beamSpot);
48 for( reco::TrackCollection::const_iterator trk = c->begin();
49 trk != c->end(); ++ trk )
50 if ( operator()(*trk,beamSpot.product()) ) {
51 selected_.push_back( & * trk );
52 }
53 }
54
55 /// Operator() performs the selection: e.g. if (recoTrackSelector(track)) {...}
56 bool operator()( const reco::Track & t, const reco::BeamSpot* bs) {
57 return
58 (t.hitPattern().trackerLayersWithMeasurement() >= minHit_ &&
59 fabs(t.pt()) >= ptMin_ &&
60 t.eta() >= minRapidity_ && t.eta() <= maxRapidity_ &&
61 fabs(t.dxy(bs->position())) <= tip_ &&
62 fabs(t.dsz(bs->position())) <= lip_ &&
63 t.normalizedChi2()<=maxChi2_ &&
64 (t.quality(t.qualityByName(quality_)) || quality_ == "" ) &&
65 (algorithm_ == t.algoName() || algorithm_ == ""));
66 }
67
68 size_t size() const { return selected_.size(); }
69
70 private:
71 double ptMin_;
72 double minRapidity_;
73 double maxRapidity_;
74 double tip_;
75 double lip_;
76 int minHit_;
77 double maxChi2_;
78 std::string quality_;
79 std::string algorithm_;
80 container selected_;
81 };
82
83 #endif