Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-25 02:14:10

0001 #ifndef RecoTracker_DisplacedRegionalTracking_DisplacedVertexCluster_h
0002 #define RecoTracker_DisplacedRegionalTracking_DisplacedVertexCluster_h
0003 
0004 #include <cmath>
0005 #include <limits>
0006 #include <vector>
0007 #include <utility>
0008 
0009 #include "DataFormats/Common/interface/View.h"
0010 #include "DataFormats/Candidate/interface/VertexCompositeCandidate.h"
0011 #include "DataFormats/Math/interface/Vector3D.h"
0012 
0013 class DisplacedVertexCluster;
0014 typedef std::vector<DisplacedVertexCluster>::iterator DisplacedVertexClusterItr;
0015 
0016 class DisplacedVertexCluster {
0017 public:
0018   static constexpr double kInvalidDouble = std::numeric_limits<double>::quiet_NaN();
0019 
0020   DisplacedVertexCluster()
0021       : valid_(false), rParam2_(kInvalidDouble), sumOfCenters_(0.0, 0.0, 0.0), centerOfMass_(0.0, 0.0, 0.0) {}
0022 
0023   DisplacedVertexCluster(const reco::VertexCompositeCandidate *const, const double);
0024 
0025   ~DisplacedVertexCluster() = default;
0026 
0027   bool valid() const { return valid_; }
0028   double rParam2() const { return rParam2_; }
0029   double rParam() const { return sqrt(rParam2()); }
0030   const std::vector<const reco::VertexCompositeCandidate *> &constituents() const { return constituents_; }
0031   const reco::VertexCompositeCandidate *constituent(const unsigned i) const { return constituents_.at(i); }
0032   unsigned nConstituents() const { return constituents_.size(); }
0033   const math::XYZVector &sumOfCenters() const { return sumOfCenters_; }
0034   const math::XYZVector &centerOfMass() const { return centerOfMass_; }
0035 
0036   double vx() const { return centerOfMass().x(); }
0037   double vy() const { return centerOfMass().y(); }
0038   double vz() const { return centerOfMass().z(); }
0039 
0040   void merge(const DisplacedVertexCluster &other);
0041   void setInvalid() { valid_ = false; }
0042 
0043   // struct representing the distance between two DisplacedVertexCluster objects
0044   struct Distance {
0045   public:
0046     Distance(DisplacedVertexClusterItr entity0, DisplacedVertexClusterItr entity1) : entities_(entity0, entity1) {}
0047     double distance2() const;
0048     double distance() const { return sqrt(distance2()); }
0049     std::pair<DisplacedVertexClusterItr, DisplacedVertexClusterItr> &entities() { return entities_; }
0050     const std::pair<DisplacedVertexClusterItr, DisplacedVertexClusterItr> &entities() const { return entities_; }
0051 
0052   private:
0053     std::pair<DisplacedVertexClusterItr, DisplacedVertexClusterItr> entities_;
0054   };
0055 
0056   typedef std::vector<Distance>::iterator DistanceItr;
0057 
0058 private:
0059   bool valid_;
0060   double rParam2_;
0061   std::vector<const reco::VertexCompositeCandidate *> constituents_;
0062   math::XYZVector sumOfCenters_;
0063   math::XYZVector centerOfMass_;
0064 };
0065 
0066 #endif