CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RecoTrackSelector.h
Go to the documentation of this file.
1 #ifndef RecoSelectors_RecoTrackSelector_h
2 #define RecoSelectors_RecoTrackSelector_h
3 /* \class RecoTrackSelector
4  *
5  * \author Giuseppe Cerati, INFN
6  *
7  * $Date: 2013/06/24 12:25:14 $
8  * $Revision: 1.4 $
9  *
10  */
15 
17  public:
19  typedef std::vector<const reco::Track *> container;
20  typedef container::const_iterator const_iterator;
21 
25  ptMin_(cfg.getParameter<double>("ptMin")),
26  minRapidity_(cfg.getParameter<double>("minRapidity")),
27  maxRapidity_(cfg.getParameter<double>("maxRapidity")),
28  tip_(cfg.getParameter<double>("tip")),
29  lip_(cfg.getParameter<double>("lip")),
30  minHit_(cfg.getParameter<int>("minHit")),
31  min3DHit_(cfg.getParameter<int>("min3DHit")),
32  maxChi2_(cfg.getParameter<double>("maxChi2")),
33  bsSrc_(cfg.getParameter<edm::InputTag>("beamSpot")),
34  bs(0)
35  {
36  std::vector<std::string> quality = cfg.getParameter<std::vector<std::string> >("quality");
37  for (unsigned int j=0;j<quality.size();j++) quality_.push_back(reco::TrackBase::qualityByName(quality[j]));
38  std::vector<std::string> algorithm = cfg.getParameter<std::vector<std::string> >("algorithm");
39  for (unsigned int j=0;j<algorithm.size();j++) algorithm_.push_back(reco::TrackBase::algoByName(algorithm[j]));
40  }
41 
42  RecoTrackSelector ( double ptMin, double minRapidity, double maxRapidity,
43  double tip, double lip, int minHit, int min3DHit, double maxChi2,
44  std::vector<std::string> quality , std::vector<std::string> algorithm ) :
45  ptMin_( ptMin ), minRapidity_( minRapidity ), maxRapidity_( maxRapidity ),
46  tip_( tip ), lip_( lip ), minHit_( minHit ), min3DHit_( min3DHit), maxChi2_( maxChi2 ), bs(0)
47  {
48  for (unsigned int j=0;j<quality.size();j++) quality_.push_back(reco::TrackBase::qualityByName(quality[j]));
49  for (unsigned int j=0;j<algorithm.size();j++) algorithm_.push_back(reco::TrackBase::algoByName(algorithm[j]));
50  }
51 
52  const_iterator begin() const { return selected_.begin(); }
53  const_iterator end() const { return selected_.end(); }
54 
56  selected_.clear();
58  event.getByLabel(bsSrc_,beamSpot);
59  bs = beamSpot.product();
60  for( reco::TrackCollection::const_iterator trk = c->begin();
61  trk != c->end(); ++ trk )
62  if ( operator()(*trk) ) {
63  selected_.push_back( & * trk );
64  }
65  }
66 
69 
70  if ((bs==0)|| (previousEvent != event.id())) {
72  event.getByLabel(bsSrc_,beamSpot);
73  bs = beamSpot.product();
74  previousEvent = event.id();
75  }
76  return operator()(t);
77  }
78 
79  bool operator()( const reco::Track & t, const reco::BeamSpot* bs_) {
80  bs = bs_;
81  return operator()(t);
82  }
83 
84  bool operator()( const reco::Track & t) {
85  bool quality_ok = true;
86  if (quality_.size()!=0) {
87  quality_ok = false;
88  for (unsigned int i = 0; i<quality_.size();++i) {
89  if (t.quality(quality_[i])){
90  quality_ok = true;
91  break;
92  }
93  }
94  }
95  bool algo_ok = true;
96  if (algorithm_.size()!=0) {
97  if (std::find(algorithm_.begin(),algorithm_.end(),t.algo())==algorithm_.end()) algo_ok = false;
98  }
99  return
103  fabs(t.pt()) >= ptMin_ &&
104  t.eta() >= minRapidity_ && t.eta() <= maxRapidity_ &&
105  fabs(t.dxy(bs->position())) <= tip_ &&
106  fabs(t.dsz(bs->position())) <= lip_ &&
107  t.normalizedChi2()<=maxChi2_ &&
108  quality_ok &&
109  algo_ok);
110  }
111 
112  size_t size() const { return selected_.size(); }
113 
114  protected:
115  double ptMin_;
116  double minRapidity_;
117  double maxRapidity_;
118  double tip_;
119  double lip_;
120  int minHit_;
122  double maxChi2_;
123  std::vector<reco::TrackBase::TrackQuality> quality_;
124  std::vector<reco::TrackBase::TrackAlgorithm> algorithm_;
129 };
130 
131 #endif
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
< trclass="colgroup">< tdclass="colgroup"colspan=5 > Ecal cluster collections</td ></tr >< tr >< td >< ahref="classreco_1_1BasicCluster.html"> reco::BasicCluster</a ></td >< td >< ahref="DataFormats_EgammaReco.html"> reco::BasicClusterCollection</a ></td >< td >< ahref="#"> hybridSuperClusters</a ></td >< tdclass="description"> Basic clusters reconstructed with hybrid algorithm(barrel only)</td >< td >S.Rahatlou</td ></tr >< tr >< td >< a href
edm::InputTag bsSrc_
container::const_iterator const_iterator
RecoTrackSelector(double ptMin, double minRapidity, double maxRapidity, double tip, double lip, int minHit, int min3DHit, double maxChi2, std::vector< std::string > quality, std::vector< std::string > algorithm)
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
Definition: TrackBase.h:111
std::vector< reco::TrackBase::TrackQuality > quality_
const_iterator end() const
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
int pixelLayersWithMeasurement() const
Definition: HitPattern.h:726
RecoTrackSelector()
Constructors.
int numberOfValidStripLayersWithMonoAndStereo() const
Definition: HitPattern.cc:224
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
double dsz() const
dsz parameter (THIS IS NOT the SZ impact parameter to (0,0,0) if refPoint is far from (0...
Definition: TrackBase.h:125
edm::EventID previousEvent
TrackAlgorithm algo() const
Definition: TrackBase.h:332
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:141
const_iterator begin() const
int trackerLayersWithMeasurement() const
Definition: HitPattern.h:721
bool operator()(const reco::Track &t, edm::Event &event)
Operator() performs the selection: e.g. if (recoTrackSelector(track)) {...}.
double pt() const
track transverse momentum
Definition: TrackBase.h:131
int j
Definition: DBlmapReader.cc:9
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:223
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:46
std::vector< reco::TrackBase::TrackAlgorithm > algorithm_
RecoTrackSelector(const edm::ParameterSet &cfg)
T const * product() const
Definition: Handle.h:74
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:377
void select(const edm::Handle< collection > &c, const edm::Event &event, const edm::EventSetup &)
edm::EventID id() const
Definition: EventBase.h:56
bool operator()(const reco::Track &t, const reco::BeamSpot *bs_)
size_t size() const
std::vector< const reco::Track * > container
const reco::BeamSpot * bs
bool operator()(const reco::Track &t)
static TrackAlgorithm algoByName(const std::string &name)
Definition: TrackBase.cc:55
const Point & position() const
position
Definition: BeamSpot.h:63
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:121
reco::TrackCollection collection