CMS 3D CMS Logo

DisplacedVertexCluster.h
Go to the documentation of this file.
1 #ifndef RecoTracker_DisplacedRegionalTracking_DisplacedVertexCluster_h
2 #define RecoTracker_DisplacedRegionalTracking_DisplacedVertexCluster_h
3 
4 #include <cmath>
5 #include <limits>
6 #include <vector>
7 #include <utility>
8 
12 
14 typedef std::vector<DisplacedVertexCluster>::iterator DisplacedVertexClusterItr;
15 
17 public:
18  static constexpr double kInvalidDouble = std::numeric_limits<double>::quiet_NaN();
19 
21  : valid_(false), rParam2_(kInvalidDouble), sumOfCenters_(0.0, 0.0, 0.0), centerOfMass_(0.0, 0.0, 0.0) {}
22 
23  DisplacedVertexCluster(const reco::VertexCompositeCandidate *const, const double);
24 
25  ~DisplacedVertexCluster() = default;
26 
27  bool valid() const { return valid_; }
28  double rParam2() const { return rParam2_; }
29  double rParam() const { return sqrt(rParam2()); }
30  const std::vector<const reco::VertexCompositeCandidate *> &constituents() const { return constituents_; }
31  const reco::VertexCompositeCandidate *constituent(const unsigned i) const { return constituents_.at(i); }
32  unsigned nConstituents() const { return constituents_.size(); }
33  const math::XYZVector &sumOfCenters() const { return sumOfCenters_; }
34  const math::XYZVector &centerOfMass() const { return centerOfMass_; }
35 
36  double vx() const { return centerOfMass().x(); }
37  double vy() const { return centerOfMass().y(); }
38  double vz() const { return centerOfMass().z(); }
39 
40  void merge(const DisplacedVertexCluster &other);
41  void setInvalid() { valid_ = false; }
42 
43  // struct representing the distance between two DisplacedVertexCluster objects
44  struct Distance {
45  public:
46  Distance(DisplacedVertexClusterItr entity0, DisplacedVertexClusterItr entity1) : entities_(entity0, entity1) {}
47  double distance2() const;
48  double distance() const { return sqrt(distance2()); }
49  std::pair<DisplacedVertexClusterItr, DisplacedVertexClusterItr> &entities() { return entities_; }
50  const std::pair<DisplacedVertexClusterItr, DisplacedVertexClusterItr> &entities() const { return entities_; }
51 
52  private:
53  std::pair<DisplacedVertexClusterItr, DisplacedVertexClusterItr> entities_;
54  };
55 
56  typedef std::vector<Distance>::iterator DistanceItr;
57 
58 private:
59  bool valid_;
60  double rParam2_;
61  std::vector<const reco::VertexCompositeCandidate *> constituents_;
64 };
65 
66 #endif
std::vector< const reco::VertexCompositeCandidate * > constituents_
const math::XYZVector & centerOfMass() const
static constexpr double kInvalidDouble
std::vector< DisplacedVertexCluster >::iterator DisplacedVertexClusterItr
std::pair< DisplacedVertexClusterItr, DisplacedVertexClusterItr > entities_
const std::vector< const reco::VertexCompositeCandidate * > & constituents() const
~DisplacedVertexCluster()=default
const reco::VertexCompositeCandidate * constituent(const unsigned i) const
std::vector< Distance >::iterator DistanceItr
T sqrt(T t)
Definition: SSEVec.h:19
std::pair< DisplacedVertexClusterItr, DisplacedVertexClusterItr > & entities()
Distance(DisplacedVertexClusterItr entity0, DisplacedVertexClusterItr entity1)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
const std::pair< DisplacedVertexClusterItr, DisplacedVertexClusterItr > & entities() const
const math::XYZVector & sumOfCenters() const
void merge(const DisplacedVertexCluster &other)