CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Fireworks/Vertices/plugins/FWVertexWithTracksProxyBuilder.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Vertexs
00004 // Class  :     FWVertexWithTracksProxyBuilder
00005 //
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Chris Jones
00010 //         Created:  Tue Dec  2 14:17:03 EST 2008
00011 // $Id: FWVertexWithTracksProxyBuilder.cc,v 1.2 2011/03/21 15:01:53 arizzi Exp $
00012 //
00013 
00014 // system include files
00015 
00016 // user include files
00017 #include "Fireworks/Core/interface/FWEventItem.h"
00018 #include "DataFormats/VertexReco/interface/Vertex.h"
00019 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00020 #include "TEvePointSet.h"
00021 
00022 #include "TMatrixDEigen.h"
00023 #include "TMatrixDSym.h"
00024 #include "TDecompSVD.h"
00025 #include "TVectorD.h"
00026 #include "TEveTrans.h"
00027 #include "TEveTrack.h"
00028 #include "TEveTrackPropagator.h"
00029 #include "TEveBoxSet.h"
00030 #include "TGeoSphere.h"
00031 #include "TEveGeoNode.h"
00032 #include "TEveVSDStructs.h"
00033 
00034 // include files
00035 #include "Fireworks/Core/interface/FWEvePtr.h"
00036 #include "Fireworks/Core/src/CmsShowMain.h"
00037 
00038 #include "DataFormats/TrackReco/interface/Track.h"
00039 
00040 // user include files
00041 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
00042 
00043 //class FWVertexProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::Vertex> {
00044 
00045 class FWVertexWithTracksProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::Vertex> {
00046 
00047 public:
00048    FWVertexWithTracksProxyBuilder();
00049    //virtual ~FWVertexWithTracksProxyBuilder();
00050 
00051    // ---------- const member functions ---------------------
00052 
00053    // ---------- static member functions --------------------
00054 
00055    // ---------- member functions ---------------------------
00056    REGISTER_PROXYBUILDER_METHODS();
00057 
00058 private:
00059    FWVertexWithTracksProxyBuilder(const FWVertexWithTracksProxyBuilder&); // stop default
00060 
00061    const FWVertexWithTracksProxyBuilder& operator=(const FWVertexWithTracksProxyBuilder&); // stop default
00062 
00063    virtual void build(const reco::Vertex& iData, unsigned int iIndex,TEveElement& oItemHolder, const FWViewContext*) ;
00064 
00065    // ---------- member data --------------------------------
00066 };
00067 
00068 //
00069 // constants, enums and typedefs
00070 //
00071 
00072 //
00073 // static data member definitions
00074 //
00075 
00076 //
00077 // constructors and destructor
00078 //
00079 FWVertexWithTracksProxyBuilder::FWVertexWithTracksProxyBuilder()
00080 {
00081 }
00082 
00083 
00084 //
00085 // member functions
00086 //
00087 void
00088 FWVertexWithTracksProxyBuilder::build(const reco::Vertex& iData, unsigned int iIndex,TEveElement& oItemHolder, const FWViewContext*) 
00089 {
00090 
00091   TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
00092    TEvePointSet* pointSet = new TEvePointSet();
00093    pointSet->SetMainColor(item()->defaultDisplayProperties().color());
00094 //   for(unsigned int i=0;i<iData.nVertices();i++)
00095 //   {
00096       const reco::Vertex & v = iData;
00097       // do we need this stuff?
00098       TGeoSphere * sphere = new TGeoSphere(0, 0.002); //would that leak?
00099       TGeoTranslation position(v.x(), v.y(), v.z() );
00100       TEveGeoShape * shape = new TEveGeoShape();
00101       sphere->SetBoxDimensions(2.5,2.5,2.5);
00102       shape->SetShape(sphere);
00103       shape->SetMainColor(item()->defaultDisplayProperties().color());
00104       shape->SetMainTransparency(10);
00105 
00106       TEveTrans & t =   shape->RefMainTrans();
00107       reco::Vertex::Error e= v.error();
00108       TMatrixDSym m(3);
00109       for(int i=0;i<3;i++)
00110          for(int j=0;j<3;j++)
00111          {
00112             m(i,j) = e(i,j);
00113          }
00114       TMatrixDEigen eig(m);
00115       TDecompSVD svd(m);
00116       TMatrixD mm = svd.GetU();
00117       //   TMatrixD mm =  eig.GetEigenVectors().Print();
00118       for(int i=0;i<3;i++)
00119          for(int j=0;j<3;j++)
00120          {
00121             t(i+1,j+1) = mm(i,j);
00122          }
00123       TVectorD vv ( eig.GetEigenValuesRe())   ;
00124       t.Scale(sqrt(vv(0))*1000.,sqrt(vv(1))*1000.,sqrt(vv(2))*1000.);
00125       t.SetPos(v.x(),v.y(),v.z());
00126       oItemHolder.AddElement(shape);
00127       pointSet->SetNextPoint( v.x(), v.y(), v.z() );
00128       for(reco::Vertex::trackRef_iterator it = v.tracks_begin() ;
00129           it != v.tracks_end()  ; ++it)
00130      {
00131                float w = v.trackWeight(*it);
00132                if (w < 0.5) continue;
00133 
00134          const reco::Track & track = *it->get();
00135          TEveRecTrack t;
00136          t.fBeta = 1.;
00137          t.fV = TEveVector(track.vx(), track.vy(), track.vz());
00138          t.fP = TEveVector(track.px(), track.py(), track.pz());
00139          t.fSign = track.charge();
00140          TEveTrack* trk = new TEveTrack(&t, context().getTrackPropagator());
00141          trk->SetMainColor(item()->defaultDisplayProperties().color());
00142          trk->MakeTrack();
00143          oItemHolder.AddElement( trk );
00144       }
00145 
00146 //   }
00147    oItemHolder.AddElement( pointSet );
00148 
00149 
00150 
00151 
00152 }
00153 
00154 
00155 //
00156 // const member functions
00157 //
00158 
00159 //
00160 // static member functions
00161 //
00162 REGISTER_FWPROXYBUILDER(FWVertexWithTracksProxyBuilder, reco::Vertex, "VerticesWithTracks", FWViewType::k3DBit | FWViewType::kAllRPZBits);