Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:46

0001 #ifndef PatAlgos_PATPrimaryVertexSelector_H_
0002 #define PatAlgos_PATPrimaryVertexSelector_H_
0003 
0004 /**
0005   \class    pat::PATPrimaryVertexSelector PATPrimaryVertexSelector.h "PhysicsTools/PatAlgos/interface/PATPrimaryVertexSelector.h"
0006 
0007    The PATPrimaryVertexSelector is used together with an ObjectSelector to clean and
0008    sort a collection of primary vertices. The code is very close to what is done in
0009    SusyAnalyzer: it allows a selection based on the (normalized) chi2 of the vertex fit,
0010    the position, the multiplicity and the pt-sum of the associated tracks. The tracks
0011    entering in the calculation of the last two quantities can be restricted in eta.
0012    The output collection is sorted by the sum of the track pts.
0013 
0014 */
0015 
0016 #include "FWCore/Framework/interface/Event.h"
0017 #include "FWCore/Framework/interface/EventSetup.h"
0018 #include "FWCore/Framework/interface/ConsumesCollector.h"
0019 #include "DataFormats/Common/interface/Handle.h"
0020 #include "DataFormats/VertexReco/interface/Vertex.h"
0021 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0022 
0023 class PATPrimaryVertexSelector {
0024 public:
0025   typedef reco::VertexCollection collection;
0026   typedef std::vector<const reco::Vertex*> container;
0027   typedef container::const_iterator const_iterator;
0028   PATPrimaryVertexSelector(const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC);
0029   /// needed for use with an ObjectSelector
0030   const_iterator begin() const { return selected_.begin(); }
0031   /// needed for use with an ObjectSelector
0032   const_iterator end() const { return selected_.end(); }
0033   /// needed for use with an ObjectSelector
0034   void select(const edm::Handle<collection>&, const edm::Event&, const edm::EventSetup&);
0035   /// needed for use with an ObjectSelector
0036   size_t size() const { return selected_.size(); }
0037   /// operator used in sorting the selected vertices
0038   bool operator()(const reco::Vertex*, const reco::Vertex*) const;
0039 
0040 private:
0041   /// access to track-related vertex quantities (multiplicity and pt-sum)
0042   void getVertexVariables(const reco::Vertex&, unsigned int&, double&) const;
0043   /// track selection
0044   bool acceptTrack(const reco::Track&) const;
0045 
0046 private:
0047   container selected_;            /// container of selected vertices
0048   unsigned int multiplicityCut_;  /// minimum multiplicity of (selected) associated tracks
0049   float ptSumCut_;                /// minimum pt sum o (selected) associated tracks
0050   float trackEtaCut_;             /// eta cut used for the track selection
0051   float chi2Cut_;                 /// cut on the normalized chi2
0052   float dr2Cut_;                  /// cut on the (squared) transverse position
0053   float dzCut_;                   /// cut on the longitudinal position
0054 };
0055 
0056 #endif