CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/src/Fireworks/Vertices/plugins/FWSecVertexProxyBuilder.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // $Id: FWSecVertexProxyBuilder.cc,v 1.5 2011/03/21 14:57:42 arizzi Exp $
00003 //
00004 #include <vector>
00005 
00006 #include "TMatrixDEigen.h"
00007 #include "TMatrixDSym.h"  
00008 #include "TDecompSVD.h"
00009 #include "TEveTrans.h"
00010 #include "TEveTrack.h"
00011 #include "TGeoSphere.h"
00012 #include "TGeoMatrix.h"
00013 #include "TEveGeoNode.h"
00014 #include "TEveVSDStructs.h"
00015 
00016 // include files
00017 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
00018 #include "Fireworks/Core/interface/FWEventItem.h"
00019 
00020 #include "DataFormats/BTauReco/interface/SecondaryVertexTagInfo.h"
00021 
00022 class FWSecVertexProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::SecondaryVertexTagInfo>  {
00023    
00024 public:
00025    FWSecVertexProxyBuilder(){}
00026    virtual ~FWSecVertexProxyBuilder(){}
00027   
00028    REGISTER_PROXYBUILDER_METHODS();
00029  
00030 private:
00031    FWSecVertexProxyBuilder(const FWSecVertexProxyBuilder&); // stop default
00032    const FWSecVertexProxyBuilder& operator=(const FWSecVertexProxyBuilder&); // stop default
00033    
00034    // ---------- member data --------------------------------
00035    void build(const reco::SecondaryVertexTagInfo& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*);
00036 };
00037 
00038 void 
00039 FWSecVertexProxyBuilder::build(const reco::SecondaryVertexTagInfo& iData, unsigned int iIndex,TEveElement& oItemHolder, const FWViewContext*) 
00040 {
00041    TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
00042    TEvePointSet* pointSet = new TEvePointSet();
00043    pointSet->SetMainColor(item()->defaultDisplayProperties().color());
00044    for(unsigned int i=0;i<iData.nVertices();i++)
00045    {
00046       const reco::Vertex & v = iData.secondaryVertex(i);
00047       // do we need this stuff?
00048       TGeoSphere * sphere = new TGeoSphere(0, 0.002); //would that leak?
00049       TGeoTranslation position(v.x(), v.y(), v.z() );
00050       TEveGeoShape * shape = new TEveGeoShape();
00051       sphere->SetBoxDimensions(2.5,2.5,2.5);
00052       shape->SetShape(sphere);
00053       shape->SetMainColor(item()->defaultDisplayProperties().color());
00054       shape->SetMainTransparency(10);
00055  
00056       TEveTrans & t =   shape->RefMainTrans();
00057       reco::Vertex::Error e= v.error();
00058       TMatrixDSym m(3);
00059       for(int i=0;i<3;i++)
00060          for(int j=0;j<3;j++)
00061          {
00062             m(i,j) = e(i,j);
00063          }
00064       TMatrixDEigen eig(m);
00065       TDecompSVD svd(m);
00066       TMatrixD mm = svd.GetU();
00067       //   TMatrixD mm =  eig.GetEigenVectors().Print();
00068       for(int i=0;i<3;i++)
00069          for(int j=0;j<3;j++)
00070          {
00071             t(i+1,j+1) = mm(i,j);
00072          }   
00073       TVectorD vv ( eig.GetEigenValuesRe())   ; 
00074       t.Scale(sqrt(vv(0))*1000.,sqrt(vv(1))*1000.,sqrt(vv(2))*1000.);
00075       t.SetPos(v.x(),v.y(),v.z());
00076 
00077       setupAddElement(shape, &oItemHolder);
00078 
00079       pointSet->SetNextPoint( v.x(), v.y(), v.z() );
00080 
00081       for(reco::Vertex::trackRef_iterator it = v.tracks_begin(), itEnd = v.tracks_end(); 
00082           it != itEnd; ++it)
00083       {
00084          const reco::Track & track = *it->get();
00085          TEveRecTrack t;
00086          t.fBeta = 1.;
00087          t.fV = TEveVector(track.vx(), track.vy(), track.vz());
00088          t.fP = TEveVector(track.px(), track.py(), track.pz());
00089          t.fSign = track.charge();
00090          TEveTrack* trk = new TEveTrack(&t, context().getTrackPropagator());
00091          trk->SetMainColor(item()->defaultDisplayProperties().color());
00092          trk->MakeTrack();
00093          setupAddElement(trk, &oItemHolder);
00094       }
00095    }
00096    setupAddElement(pointSet, &oItemHolder);
00097 }
00098 
00099 REGISTER_FWPROXYBUILDER(FWSecVertexProxyBuilder, reco::SecondaryVertexTagInfo, "SecVertex", FWViewType::k3DBit | FWViewType::kAllRPZBits);