CMS 3D CMS Logo

FWSecVertexProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 #include <vector>
4 
5 #include "TMatrixDEigen.h"
6 #include "TMatrixDSym.h"
7 #include "TDecompSVD.h"
8 #include "TEveTrans.h"
9 #include "TEveTrack.h"
10 #include "TGeoSphere.h"
11 #include "TGeoMatrix.h"
12 #include "TEveGeoNode.h"
13 #include "TEveVSDStructs.h"
14 
15 // include files
18 
20 
21 class FWSecVertexProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::SecondaryVertexTagInfo> {
22 public:
25 
27 
28 private:
29  FWSecVertexProxyBuilder(const FWSecVertexProxyBuilder&) = delete; // stop default
30  const FWSecVertexProxyBuilder& operator=(const FWSecVertexProxyBuilder&) = delete; // stop default
31 
32  // ---------- member data --------------------------------
34  void build(const reco::SecondaryVertexTagInfo& iData,
35  unsigned int iIndex,
36  TEveElement& oItemHolder,
37  const FWViewContext*) override;
38 };
39 
41  unsigned int iIndex,
42  TEveElement& oItemHolder,
43  const FWViewContext*) {
44  TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
45  TEvePointSet* pointSet = new TEvePointSet();
46  pointSet->SetMainColor(item()->defaultDisplayProperties().color());
47  for (unsigned int i = 0; i < iData.nVertices(); i++) {
48  const reco::Vertex& v = iData.secondaryVertex(i);
49  // do we need this stuff?
50  TGeoSphere* sphere = new TGeoSphere(0, 0.002); //would that leak?
51  TGeoTranslation position(v.x(), v.y(), v.z());
52  TEveGeoShape* shape = new TEveGeoShape();
53  sphere->SetBoxDimensions(2.5, 2.5, 2.5);
54  shape->SetShape(sphere);
55  shape->SetMainColor(item()->defaultDisplayProperties().color());
56  shape->SetMainTransparency(10);
57 
58  TEveTrans& t = shape->RefMainTrans();
60  TMatrixDSym m(3);
61  for (int i = 0; i < 3; i++)
62  for (int j = 0; j < 3; j++) {
63  m(i, j) = e(i, j);
64  }
65  TMatrixDEigen eig(m);
66  TDecompSVD svd(m);
67  TMatrixD mm = svd.GetU();
68  // TMatrixD mm = eig.GetEigenVectors().Print();
69  for (int i = 0; i < 3; i++)
70  for (int j = 0; j < 3; j++) {
71  t(i + 1, j + 1) = mm(i, j);
72  }
73  TVectorD vv(eig.GetEigenValuesRe());
74  t.Scale(sqrt(vv(0)) * 1000., sqrt(vv(1)) * 1000., sqrt(vv(2)) * 1000.);
75  t.SetPos(v.x(), v.y(), v.z());
76 
77  setupAddElement(shape, &oItemHolder);
78 
79  pointSet->SetNextPoint(v.x(), v.y(), v.z());
80 
81  for (reco::Vertex::trackRef_iterator it = v.tracks_begin(), itEnd = v.tracks_end(); it != itEnd; ++it) {
82  const reco::Track& track = *it->get();
83  TEveRecTrack t;
84  t.fBeta = 1.;
85  t.fV = TEveVector(track.vx(), track.vy(), track.vz());
86  t.fP = TEveVector(track.px(), track.py(), track.pz());
87  t.fSign = track.charge();
88  TEveTrack* trk = new TEveTrack(&t, context().getTrackPropagator());
89  trk->SetMainColor(item()->defaultDisplayProperties().color());
90  trk->MakeTrack();
91  setupAddElement(trk, &oItemHolder);
92  }
93  }
94  setupAddElement(pointSet, &oItemHolder);
95 }
96 
99  "SecVertex",
const fireworks::Context & context() const
const FWSecVertexProxyBuilder & operator=(const FWSecVertexProxyBuilder &)=delete
static const int kAllRPZBits
Definition: FWViewType.h:67
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:73
const VTX & secondaryVertex(unsigned int index) const
double y() const
y coordinate
Definition: Vertex.h:117
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:605
const FWEventItem * item() const
T sqrt(T t)
Definition: SSEVec.h:19
double z() const
z coordinate
Definition: Vertex.h:119
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:611
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:626
double x() const
x coordinate
Definition: Vertex.h:115
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
Error error() const
return SMatrix
Definition: Vertex.h:149
double vy() const
y coordinate of the reference point on track
Definition: TrackBase.h:623
static int position[264][3]
Definition: ReadPGInfo.cc:289
int charge() const
track electric charge
Definition: TrackBase.h:575
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:71
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:37
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:608
double vx() const
x coordinate of the reference point on track
Definition: TrackBase.h:620