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 
23 public:
26 
28 
29 private:
30  FWSecVertexProxyBuilder(const FWSecVertexProxyBuilder&) = delete; // stop default
31  const FWSecVertexProxyBuilder& operator=(const FWSecVertexProxyBuilder&) = delete; // stop default
32 
33  // ---------- member data --------------------------------
35  void build(const reco::SecondaryVertexTagInfo& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
36 };
37 
38 void
39 FWSecVertexProxyBuilder::build(const reco::SecondaryVertexTagInfo& iData, unsigned int iIndex,TEveElement& oItemHolder, const FWViewContext*)
40 {
41  TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
42  TEvePointSet* pointSet = new TEvePointSet();
43  pointSet->SetMainColor(item()->defaultDisplayProperties().color());
44  for(unsigned int i=0;i<iData.nVertices();i++)
45  {
46  const reco::Vertex & v = iData.secondaryVertex(i);
47  // do we need this stuff?
48  TGeoSphere * sphere = new TGeoSphere(0, 0.002); //would that leak?
49  TGeoTranslation position(v.x(), v.y(), v.z() );
50  TEveGeoShape * shape = new TEveGeoShape();
51  sphere->SetBoxDimensions(2.5,2.5,2.5);
52  shape->SetShape(sphere);
53  shape->SetMainColor(item()->defaultDisplayProperties().color());
54  shape->SetMainTransparency(10);
55 
56  TEveTrans & t = shape->RefMainTrans();
58  TMatrixDSym m(3);
59  for(int i=0;i<3;i++)
60  for(int j=0;j<3;j++)
61  {
62  m(i,j) = e(i,j);
63  }
64  TMatrixDEigen eig(m);
65  TDecompSVD svd(m);
66  TMatrixD mm = svd.GetU();
67  // TMatrixD mm = eig.GetEigenVectors().Print();
68  for(int i=0;i<3;i++)
69  for(int j=0;j<3;j++)
70  {
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();
82  it != itEnd; ++it)
83  {
84  const reco::Track & track = *it->get();
85  TEveRecTrack t;
86  t.fBeta = 1.;
87  t.fV = TEveVector(track.vx(), track.vy(), track.vz());
88  t.fP = TEveVector(track.px(), track.py(), track.pz());
89  t.fSign = track.charge();
90  TEveTrack* trk = new TEveTrack(&t, context().getTrackPropagator());
91  trk->SetMainColor(item()->defaultDisplayProperties().color());
92  trk->MakeTrack();
93  setupAddElement(trk, &oItemHolder);
94  }
95  }
96  setupAddElement(pointSet, &oItemHolder);
97 }
98 
const fireworks::Context & context() const
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
const FWSecVertexProxyBuilder & operator=(const FWSecVertexProxyBuilder &)=delete
static const int kAllRPZBits
Definition: FWViewType.h:58
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:81
const VTX & secondaryVertex(unsigned int index) const
double y() const
y coordinate
Definition: Vertex.h:113
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:627
const FWEventItem * item() const
T sqrt(T t)
Definition: SSEVec.h:18
double z() const
z coordinate
Definition: Vertex.h:115
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:639
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:669
double x() const
x coordinate
Definition: Vertex.h:111
Error error() const
return SMatrix
Definition: Vertex.h:139
double vy() const
y coordinate of the reference point on track
Definition: TrackBase.h:663
static int position[264][3]
Definition: ReadPGInfo.cc:509
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:37
int charge() const
track electric charge
Definition: TrackBase.h:567
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:76
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:633
double vx() const
x coordinate of the reference point on track
Definition: TrackBase.h:657