CMS 3D CMS Logo

RecoTrackSelector.h

Go to the documentation of this file.
00001 #ifndef RecoSelectors_RecoTrackSelector_h
00002 #define RecoSelectors_RecoTrackSelector_h
00003 /* \class RecoTrackSelector
00004  *
00005  * \author Giuseppe Cerati, INFN
00006  *
00007  *  $Date: 2008/06/09 14:07:49 $
00008  *  $Revision: 1.11 $
00009  *
00010  */
00011 #include "DataFormats/TrackReco/interface/Track.h"
00012 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00013 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00014 
00015 class RecoTrackSelector {
00016  public:
00017   typedef reco::TrackCollection collection;
00018   typedef std::vector<const reco::Track *> container;
00019   typedef container::const_iterator const_iterator;
00020 
00022   RecoTrackSelector() {}
00023   RecoTrackSelector ( const edm::ParameterSet & cfg ) :
00024     ptMin_(cfg.getParameter<double>("ptMin")),
00025     minRapidity_(cfg.getParameter<double>("minRapidity")),
00026     maxRapidity_(cfg.getParameter<double>("maxRapidity")),
00027     tip_(cfg.getParameter<double>("tip")),
00028     lip_(cfg.getParameter<double>("lip")),
00029     minHit_(cfg.getParameter<int>("minHit")),
00030     maxChi2_(cfg.getParameter<double>("maxChi2")),
00031     quality_(cfg.getParameter<std::string>("quality")),
00032     algorithm_(cfg.getParameter<std::string>("algorithm")) { }
00033 
00034   RecoTrackSelector ( double ptMin, double minRapidity, double maxRapidity,
00035                       double tip, double lip, int minHit, double maxChi2, 
00036                       std::string quality , std::string algorithm ) :
00037     ptMin_( ptMin ), minRapidity_( minRapidity ), maxRapidity_( maxRapidity ),
00038     tip_( tip ), lip_( lip ), minHit_( minHit ), maxChi2_( maxChi2 ),
00039     quality_(quality),algorithm_(algorithm) { }
00040 
00041   const_iterator begin() const { return selected_.begin(); }
00042   const_iterator end() const { return selected_.end(); }
00043   
00044   void select( const edm::Handle<collection>& c, const edm::Event & event, const edm::EventSetup&) {
00045     selected_.clear();
00046     edm::Handle<reco::BeamSpot> beamSpot;
00047     event.getByLabel("offlineBeamSpot",beamSpot); 
00048     for( reco::TrackCollection::const_iterator trk = c->begin(); 
00049          trk != c->end(); ++ trk )
00050       if ( operator()(*trk,beamSpot.product()) ) {
00051         selected_.push_back( & * trk );
00052       }
00053   }
00054 
00056   bool operator()( const reco::Track & t, const reco::BeamSpot* bs) {
00057     return
00058       (t.hitPattern().trackerLayersWithMeasurement() >= minHit_ &&
00059        fabs(t.pt()) >= ptMin_ &&
00060        t.eta() >= minRapidity_ && t.eta() <= maxRapidity_ &&
00061        fabs(t.dxy(bs->position())) <= tip_ &&
00062        fabs(t.dsz(bs->position())) <= lip_  &&
00063        t.normalizedChi2()<=maxChi2_ &&
00064        (t.quality(t.qualityByName(quality_)) || quality_ == "" ) &&
00065        (algorithm_ == t.algoName() || algorithm_ == ""));
00066   }
00067 
00068   size_t size() const { return selected_.size(); }
00069   
00070  private:
00071   double ptMin_;
00072   double minRapidity_;
00073   double maxRapidity_;
00074   double tip_;
00075   double lip_;
00076   int    minHit_;
00077   double maxChi2_;
00078   std::string quality_;
00079   std::string algorithm_;
00080   container selected_;
00081 };
00082 
00083 #endif

Generated on Tue Jun 9 17:41:50 2009 for CMSSW by  doxygen 1.5.4