CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
23 public:
26 
28 
29 private:
30  FWSecVertexProxyBuilder(const FWSecVertexProxyBuilder&); // stop default
31  const FWSecVertexProxyBuilder& operator=(const FWSecVertexProxyBuilder&); // stop default
32 
33  // ---------- member data --------------------------------
34  void build(const reco::SecondaryVertexTagInfo& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
35 };
36 
37 void
38 FWSecVertexProxyBuilder::build(const reco::SecondaryVertexTagInfo& iData, unsigned int iIndex,TEveElement& oItemHolder, const FWViewContext*)
39 {
40  TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
41  TEvePointSet* pointSet = new TEvePointSet();
42  pointSet->SetMainColor(item()->defaultDisplayProperties().color());
43  for(unsigned int i=0;i<iData.nVertices();i++)
44  {
45  const reco::Vertex & v = iData.secondaryVertex(i);
46  // do we need this stuff?
47  TGeoSphere * sphere = new TGeoSphere(0, 0.002); //would that leak?
48  TGeoTranslation position(v.x(), v.y(), v.z() );
49  TEveGeoShape * shape = new TEveGeoShape();
50  sphere->SetBoxDimensions(2.5,2.5,2.5);
51  shape->SetShape(sphere);
52  shape->SetMainColor(item()->defaultDisplayProperties().color());
53  shape->SetMainTransparency(10);
54 
55  TEveTrans & t = shape->RefMainTrans();
57  TMatrixDSym m(3);
58  for(int i=0;i<3;i++)
59  for(int j=0;j<3;j++)
60  {
61  m(i,j) = e(i,j);
62  }
63  TMatrixDEigen eig(m);
64  TDecompSVD svd(m);
65  TMatrixD mm = svd.GetU();
66  // TMatrixD mm = eig.GetEigenVectors().Print();
67  for(int i=0;i<3;i++)
68  for(int j=0;j<3;j++)
69  {
70  t(i+1,j+1) = mm(i,j);
71  }
72  TVectorD vv ( eig.GetEigenValuesRe()) ;
73  t.Scale(sqrt(vv(0))*1000.,sqrt(vv(1))*1000.,sqrt(vv(2))*1000.);
74  t.SetPos(v.x(),v.y(),v.z());
75 
76  setupAddElement(shape, &oItemHolder);
77 
78  pointSet->SetNextPoint( v.x(), v.y(), v.z() );
79 
80  for(reco::Vertex::trackRef_iterator it = v.tracks_begin(), itEnd = v.tracks_end();
81  it != itEnd; ++it)
82  {
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 
const fireworks::Context & context() const
int i
Definition: DBlmapReader.cc:9
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:58
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:44
double y() const
y coordinate
Definition: Vertex.h:96
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:131
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
const FWEventItem * item() const
const FWSecVertexProxyBuilder & operator=(const FWSecVertexProxyBuilder &)
const Vertex & secondaryVertex(unsigned int index) const
T sqrt(T t)
Definition: SSEVec.h:48
int j
Definition: DBlmapReader.cc:9
double z() const
y coordinate
Definition: Vertex.h:98
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:135
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:145
double x() const
x coordinate
Definition: Vertex.h:94
Error error() const
return SMatrix
Definition: Vertex.h:115
double vy() const
y coordinate of the reference point on track
Definition: TrackBase.h:143
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector&lt;TrackRef&gt;
Definition: Vertex.h:37
int charge() const
track electric charge
Definition: TrackBase.h:111
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:39
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:133
double vx() const
x coordinate of the reference point on track
Definition: TrackBase.h:141