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 // $Id: FWSecVertexProxyBuilder.cc,v 1.5 2011/03/21 14:57:42 arizzi Exp $
3 //
4 #include <vector>
5 
6 #include "TMatrixDEigen.h"
7 #include "TMatrixDSym.h"
8 #include "TDecompSVD.h"
9 #include "TEveTrans.h"
10 #include "TEveTrack.h"
11 #include "TGeoSphere.h"
12 #include "TGeoMatrix.h"
13 #include "TEveGeoNode.h"
14 #include "TEveVSDStructs.h"
15 
16 // include files
19 
21 
22 class FWSecVertexProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::SecondaryVertexTagInfo> {
23 
24 public:
27 
29 
30 private:
31  FWSecVertexProxyBuilder(const FWSecVertexProxyBuilder&); // stop default
32  const FWSecVertexProxyBuilder& operator=(const FWSecVertexProxyBuilder&); // stop default
33 
34  // ---------- member data --------------------------------
35  void build(const reco::SecondaryVertexTagInfo& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*);
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
int i
Definition: DBlmapReader.cc:9
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:59
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:45
double y() const
y coordinate
Definition: Vertex.h:97
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:44
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:133
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:46
int j
Definition: DBlmapReader.cc:9
double z() const
y coordinate
Definition: Vertex.h:99
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:137
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:147
double x() const
x coordinate
Definition: Vertex.h:95
Error error() const
return SMatrix
Definition: Vertex.h:116
double vy() const
y coordinate of the reference point on track
Definition: TrackBase.h:145
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector&lt;TrackRef&gt;
Definition: Vertex.h:38
int charge() const
track electric charge
Definition: TrackBase.h:113
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:40
mathSSE::Vec4< T > v
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:135
double vx() const
x coordinate of the reference point on track
Definition: TrackBase.h:143