Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-02-05 23:51:40

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 "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0020 #include "DataFormats/Common/interface/Handle.h"
0021 #include "DataFormats/VertexReco/interface/Vertex.h"
0022 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0023 
0024 class PATPrimaryVertexSelector {
0025 public:
0026   typedef reco::VertexCollection collection;
0027   typedef std::vector<const reco::Vertex*> container;
0028   typedef container::const_iterator const_iterator;
0029   PATPrimaryVertexSelector(const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC);
0030   /// needed for use with an ObjectSelector
0031   const_iterator begin() const { return selected_.begin(); }
0032   /// needed for use with an ObjectSelector
0033   const_iterator end() const { return selected_.end(); }
0034   /// needed for use with an ObjectSelector
0035   void select(const edm::Handle<collection>&, const edm::Event&, const edm::EventSetup&);
0036   /// needed for use with an ObjectSelector
0037   size_t size() const { return selected_.size(); }
0038   /// operator used in sorting the selected vertices
0039   bool operator()(const reco::Vertex*, const reco::Vertex*) const;
0040 
0041   static void fillPSetDescription(edm::ParameterSetDescription& desc);
0042 
0043 private:
0044   /// access to track-related vertex quantities (multiplicity and pt-sum)
0045   void getVertexVariables(const reco::Vertex&, unsigned int&, double&) const;
0046   /// track selection
0047   bool acceptTrack(const reco::Track&) const;
0048 
0049 private:
0050   container selected_;            /// container of selected vertices
0051   unsigned int multiplicityCut_;  /// minimum multiplicity of (selected) associated tracks
0052   float ptSumCut_;                /// minimum pt sum o (selected) associated tracks
0053   float trackEtaCut_;             /// eta cut used for the track selection
0054   float chi2Cut_;                 /// cut on the normalized chi2
0055   float dr2Cut_;                  /// cut on the (squared) transverse position
0056   float dzCut_;                   /// cut on the longitudinal position
0057 };
0058 
0059 #endif