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 
10 PFDisplacedVertexSeed::PFDisplacedVertexSeed() :
11  seedPoint_(GlobalPoint(0,0,0)),
12  totalWeight_(0)
13 {}
14 
15 
17  if(std::find(elements_.begin(),elements_.end(), element) == elements_.end()) {
18  elements_.emplace_back(std::move(element));
19  }
20 }
21 
23  elements_.reserve(newSize);
24 }
25 
26 
28 
29 
30  if ( isEmpty() ) {
31  seedPoint_ = dcaPoint;
33  }
34  else {
35  Basic3DVector<double>vertexSeedVector(seedPoint_);
36  Basic3DVector<double>dcaVector(dcaPoint);
37 
38 
39  dcaVector = (dcaVector*weight + vertexSeedVector*totalWeight_)/(totalWeight_+weight);
40  GlobalPoint P(dcaVector.x(), dcaVector.y(), dcaVector.z());
42  seedPoint_ = P;
43 
44  }
45 
46  reserveElements(elements_.size()+2);
47  addElement(r1);
48  addElement(r2);
49 
50 }
51 
52 
54 
55 
56  double weight = displacedVertex.totalWeight();
57  const GlobalPoint& dcaPoint = displacedVertex.seedPoint();
58 
59  Basic3DVector<double>vertexSeedVector(seedPoint_);
60  Basic3DVector<double>dcaVector(dcaPoint);
61 
62  dcaVector = (dcaVector*weight + vertexSeedVector*totalWeight_)/(totalWeight_+weight);
63  GlobalPoint P(dcaVector.x(), dcaVector.y(), dcaVector.z());
65  seedPoint_ = P;
66 
67  reserveElements(elements_.size()+displacedVertex.elements().size());
68  auto const oldSize=elements_.size();
69  //avoid checking elements we just added from displacedVertex.elements()
70  for(auto const& e: displacedVertex.elements()) {
71  if(std::find(elements_.begin(), elements_.begin()+oldSize,e) == elements_.begin()+oldSize) {
72  elements_.emplace_back(e);
73  }
74  }
75 }
76 
77 
78 void PFDisplacedVertexSeed::Dump( ostream& out ) const {
79  if(! out ) return;
80 
81  out<<"\t--- DisplacedVertexSeed --- "<<endl;
82  out<<"\tnumber of elements: "<<elements_.size()<<endl;
83 
84  out<<"\t Seed Point x = " << seedPoint().x()
85  <<"\t Seed Point y = " << seedPoint().y()
86  <<"\t Seed Point z = " << seedPoint().z() << endl;
87 
88  // Build element label (string) : elid from type, layer and occurence number
89  // use stringstream instead of sprintf to concatenate string and integer into string
90  for(auto const& ie : elements_) {
91 
92  math::XYZPoint Pi(ie.get()->innerPosition());
93  math::XYZPoint Po(ie.get()->outerPosition());
94 
95  float innermost_radius = sqrt(Pi.x()*Pi.x() + Pi.y()*Pi.y() + Pi.z()*Pi.z());
96  float outermost_radius = sqrt(Po.x()*Po.x() + Po.y()*Po.y() + Po.z()*Po.z());
97  float innermost_rho = sqrt(Pi.x()*Pi.x() + Pi.y()*Pi.y());
98  float outermost_rho = sqrt(Po.x()*Po.x() + Po.y()*Po.y());
99 
100  double pt = ie->pt();
101 
102 
103  out<<"ie = " << ie.key() << " pt = " << pt
104  <<" innermost hit radius = " << innermost_radius << " rho = " << innermost_rho
105  <<" outermost hit radius = " << outermost_radius << " rho = " << outermost_rho
106  <<endl;
107 
108  out<<"ie = " << ie.key() << " pt = " << pt
109  // <<" inn hit pos x = " << Pi.x() << " y = " << Pi.y() << " z = " << Pi.z()
110  <<" out hit pos x = " << Po.x() << " y = " << Po.y() << " z = " << Po.z()
111  <<endl;
112 
113  }
114 
115  out<<endl;
116 
117 
118 }
119 
120 
const double Pi
T y() const
Cartesian y coordinate.
T x() const
Cartesian x coordinate.
Definition: weight.py:1
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
void mergeWith(const PFDisplacedVertexSeed &displacedVertex)
Merge two Seeds if their seed Points are close enough.
void Dump(std::ostream &out=std::cout) const
cout function
T z() const
Cartesian z coordinate.
T sqrt(T t)
Definition: SSEVec.h:18
GlobalPoint seedPoint_
Seed point which indicated the approximative position of the vertex.
const GlobalPoint & seedPoint() const
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:17
bool isEmpty() const
Check if it is a new Seed.
fixed size matrix
void reserveElements(size_t)
Reserve space for elements.
const double totalWeight() const
const std::vector< TrackBaseRef > & elements() const
def move(src, dest)
Definition: eostools.py:510
std::vector< TrackBaseRef > elements_
---—— MEMBERS ----—— ///
void updateSeedPoint(const GlobalPoint &dcaPoint, const TrackBaseRef, const TrackBaseRef, double weight=1)