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