CMS 3D CMS Logo

FWSecVertexCandidateProxyBuilder.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 
16 
17 
18 // include files
21 
23 
24 class FWSecVertexCandidateProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::CandSecondaryVertexTagInfo> {
25 
26 public:
29 
31 
32 private:
34  const FWSecVertexCandidateProxyBuilder& operator=(const FWSecVertexCandidateProxyBuilder&) = delete; // stop default
35 
36  // ---------- member data --------------------------------
38  void build(const reco::CandSecondaryVertexTagInfo& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
39 };
40 
41 void
42 FWSecVertexCandidateProxyBuilder::build(const reco::CandSecondaryVertexTagInfo& iData, unsigned int iIndex,TEveElement& oItemHolder, const FWViewContext*)
43 {
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  {
50  // do we need this stuff?
51  TGeoSphere * sphere = new TGeoSphere(0, 0.002); //would that leak?
52  TGeoTranslation position(v.vx(), v.vy(), v.vz() );
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();
61  TMatrixDSym m(3);
62  for(int i=0;i<3;i++)
63  for(int j=0;j<3;j++)
64  {
65  m(i,j) = e(i,j);
66  }
67  TMatrixDEigen eig(m);
68  TDecompSVD svd(m);
69  TMatrixD mm = svd.GetU();
70  // TMatrixD mm = eig.GetEigenVectors().Print();
71  for(int i=0;i<3;i++)
72  for(int j=0;j<3;j++)
73  {
74  t(i+1,j+1) = mm(i,j);
75  }
76  TVectorD vv ( eig.GetEigenValuesRe()) ;
77  t.Scale(sqrt(vv(0))*1000.,sqrt(vv(1))*1000.,sqrt(vv(2))*1000.);
78  t.SetPos(v.vx(),v.vy(),v.vz());
79 
80  setupAddElement(shape, &oItemHolder);
81 
82  pointSet->SetNextPoint( v.vx(), v.vy(), v.vz() );
83 
84  for(unsigned int j=0;j<v.numberOfDaughters();j++)
85  {
86  const reco::Candidate * c = v.daughter(j);
87  std::cout << c << std::endl;
88  TEveTrack* trk = fireworks::prepareCandidate( *c, context().getTrackPropagator() );
89 
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
#define REGISTER_PROXYBUILDER_METHODS()
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
static const int kAllRPZBits
Definition: FWViewType.h:58
double vy() const override
y coordinate of vertex position
const VTX & secondaryVertex(unsigned int index) const
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
const FWEventItem * item() const
size_t numberOfDaughters() const override
number of daughters
T sqrt(T t)
Definition: SSEVec.h:18
double vz() const override
z coordinate of vertex position
const Candidate * daughter(size_type) const override
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
TEveTrack * prepareCandidate(const reco::Candidate &track, TEveTrackPropagator *propagator)
static int position[264][3]
Definition: ReadPGInfo.cc:509
const FWSecVertexCandidateProxyBuilder & operator=(const FWSecVertexCandidateProxyBuilder &)=delete
double vx() const override
x coordinate of vertex position