CMS 3D CMS Logo

PFDisplacedVertexSeed.cc
Go to the documentation of this file.
2 
5 
6 using namespace std;
7 using namespace reco;
8 
9 PFDisplacedVertexSeed::PFDisplacedVertexSeed() : seedPoint_(GlobalPoint(0, 0, 0)), totalWeight_(0) {}
10 
12  if (std::find(elements_.begin(), elements_.end(), element) == elements_.end()) {
13  elements_.emplace_back(std::move(element));
14  }
15 }
16 
17 void PFDisplacedVertexSeed::reserveElements(size_t newSize) { elements_.reserve(newSize); }
18 
22  double weight) {
23  if (isEmpty()) {
24  seedPoint_ = dcaPoint;
26  } else {
27  Basic3DVector<double> vertexSeedVector(seedPoint_);
28  Basic3DVector<double> dcaVector(dcaPoint);
29 
30  dcaVector = (dcaVector * weight + vertexSeedVector * totalWeight_) / (totalWeight_ + weight);
31  GlobalPoint P(dcaVector.x(), dcaVector.y(), dcaVector.z());
33  seedPoint_ = P;
34  }
35 
36  reserveElements(elements_.size() + 2);
37  addElement(r1);
38  addElement(r2);
39 }
40 
42  double weight = displacedVertex.totalWeight();
43  const GlobalPoint& dcaPoint = displacedVertex.seedPoint();
44 
45  Basic3DVector<double> vertexSeedVector(seedPoint_);
46  Basic3DVector<double> dcaVector(dcaPoint);
47 
48  dcaVector = (dcaVector * weight + vertexSeedVector * totalWeight_) / (totalWeight_ + weight);
49  GlobalPoint P(dcaVector.x(), dcaVector.y(), dcaVector.z());
51  seedPoint_ = P;
52 
53  reserveElements(elements_.size() + displacedVertex.elements().size());
54  auto const oldSize = elements_.size();
55  //avoid checking elements we just added from displacedVertex.elements()
56  for (auto const& e : displacedVertex.elements()) {
57  if (std::find(elements_.begin(), elements_.begin() + oldSize, e) == elements_.begin() + oldSize) {
58  elements_.emplace_back(e);
59  }
60  }
61 }
62 
63 void PFDisplacedVertexSeed::Dump(ostream& out) const {
64  if (!out)
65  return;
66 
67  out << "\t--- DisplacedVertexSeed --- " << endl;
68  out << "\tnumber of elements: " << elements_.size() << endl;
69 
70  out << "\t Seed Point x = " << seedPoint().x() << "\t Seed Point y = " << seedPoint().y()
71  << "\t Seed Point z = " << seedPoint().z() << endl;
72 
73  // Build element label (string) : elid from type, layer and occurence number
74  // use stringstream instead of sprintf to concatenate string and integer into string
75  for (auto const& ie : elements_) {
76  math::XYZPoint Pi(ie.get()->innerPosition());
77  math::XYZPoint Po(ie.get()->outerPosition());
78 
79  float innermost_radius = sqrt(Pi.x() * Pi.x() + Pi.y() * Pi.y() + Pi.z() * Pi.z());
80  float outermost_radius = sqrt(Po.x() * Po.x() + Po.y() * Po.y() + Po.z() * Po.z());
81  float innermost_rho = sqrt(Pi.x() * Pi.x() + Pi.y() * Pi.y());
82  float outermost_rho = sqrt(Po.x() * Po.x() + Po.y() * Po.y());
83 
84  double pt = ie->pt();
85 
86  out << "ie = " << ie.key() << " pt = " << pt << " innermost hit radius = " << innermost_radius
87  << " rho = " << innermost_rho << " outermost hit radius = " << outermost_radius << " rho = " << outermost_rho
88  << endl;
89 
90  out << "ie = " << ie.key() << " pt = "
91  << pt
92  // <<" inn hit pos x = " << Pi.x() << " y = " << Pi.y() << " z = " << Pi.z()
93  << " out hit pos x = " << Po.x() << " y = " << Po.y() << " z = " << Po.z() << endl;
94  }
95 
96  out << endl;
97 }
const double Pi
T x() const
Cartesian x coordinate.
bool isEmpty() const
Check if it is a new Seed.
const GlobalPoint & seedPoint() const
Definition: weight.py:1
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
void mergeWith(const PFDisplacedVertexSeed &displacedVertex)
Merge two Seeds if their seed Points are close enough.
const double totalWeight() const
T y() const
Cartesian y coordinate.
void Dump(std::ostream &out=std::cout) const
cout function
const std::vector< TrackBaseRef > & elements() const
T sqrt(T t)
Definition: SSEVec.h:19
GlobalPoint seedPoint_
Seed point which indicated the approximative position of the vertex.
T z() const
Cartesian z coordinate.
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
std::pair< OmniClusterRef, TrackingParticleRef > P
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float >, ROOT::Math::GlobalCoordinateSystemTag > GlobalPoint
point in global coordinate system
Definition: Point3D.h:18
fixed size matrix
void reserveElements(size_t)
Reserve space for elements.
std::vector< TrackBaseRef > elements_
---—— MEMBERS ----—— ///
def move(src, dest)
Definition: eostools.py:511
void updateSeedPoint(const GlobalPoint &dcaPoint, const TrackBaseRef, const TrackBaseRef, double weight=1)