Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:54

0001 // -*- C++ -*-
0002 //
0003 #include <vector>
0004 
0005 #include "TMatrixDEigen.h"
0006 #include "TMatrixDSym.h"
0007 #include "TDecompSVD.h"
0008 #include "TEveTrans.h"
0009 #include "TEveTrack.h"
0010 #include "TGeoSphere.h"
0011 #include "TGeoMatrix.h"
0012 #include "TEveGeoNode.h"
0013 #include "TEveGeoShape.h"
0014 #include "TEveVSDStructs.h"
0015 
0016 // include files
0017 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
0018 #include "Fireworks/Core/interface/FWEventItem.h"
0019 
0020 #include "DataFormats/BTauReco/interface/SecondaryVertexTagInfo.h"
0021 
0022 class FWSecVertexProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::SecondaryVertexTagInfo> {
0023 public:
0024   FWSecVertexProxyBuilder() {}
0025   ~FWSecVertexProxyBuilder() override {}
0026 
0027   REGISTER_PROXYBUILDER_METHODS();
0028 
0029   FWSecVertexProxyBuilder(const FWSecVertexProxyBuilder&) = delete;                   // stop default
0030   const FWSecVertexProxyBuilder& operator=(const FWSecVertexProxyBuilder&) = delete;  // stop default
0031 
0032 private:
0033   // ---------- member data --------------------------------
0034   using FWSimpleProxyBuilderTemplate<reco::SecondaryVertexTagInfo>::build;
0035   void build(const reco::SecondaryVertexTagInfo& iData,
0036              unsigned int iIndex,
0037              TEveElement& oItemHolder,
0038              const FWViewContext*) override;
0039 };
0040 
0041 void FWSecVertexProxyBuilder::build(const reco::SecondaryVertexTagInfo& iData,
0042                                     unsigned int iIndex,
0043                                     TEveElement& oItemHolder,
0044                                     const FWViewContext*) {
0045   TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
0046   TEvePointSet* pointSet = new TEvePointSet();
0047   pointSet->SetMainColor(item()->defaultDisplayProperties().color());
0048   for (unsigned int i = 0; i < iData.nVertices(); i++) {
0049     const reco::Vertex& v = iData.secondaryVertex(i);
0050     // do we need this stuff?
0051     TGeoSphere* sphere = new TGeoSphere(0, 0.002);  //would that leak?
0052     TGeoTranslation position(v.x(), v.y(), v.z());
0053     TEveGeoShape* shape = new TEveGeoShape();
0054     sphere->SetBoxDimensions(2.5, 2.5, 2.5);
0055     shape->SetShape(sphere);
0056     shape->SetMainColor(item()->defaultDisplayProperties().color());
0057     shape->SetMainTransparency(10);
0058 
0059     TEveTrans& t = shape->RefMainTrans();
0060     reco::Vertex::Error e = v.error();
0061     TMatrixDSym m(3);
0062     for (int i = 0; i < 3; i++)
0063       for (int j = 0; j < 3; j++) {
0064         m(i, j) = e(i, j);
0065       }
0066     TMatrixDEigen eig(m);
0067     TDecompSVD svd(m);
0068     TMatrixD mm = svd.GetU();
0069     //   TMatrixD mm =  eig.GetEigenVectors().Print();
0070     for (int i = 0; i < 3; i++)
0071       for (int j = 0; j < 3; j++) {
0072         t(i + 1, j + 1) = mm(i, j);
0073       }
0074     TVectorD vv(eig.GetEigenValuesRe());
0075     t.Scale(sqrt(vv(0)) * 1000., sqrt(vv(1)) * 1000., sqrt(vv(2)) * 1000.);
0076     t.SetPos(v.x(), v.y(), v.z());
0077 
0078     setupAddElement(shape, &oItemHolder);
0079 
0080     pointSet->SetNextPoint(v.x(), v.y(), v.z());
0081 
0082     for (reco::Vertex::trackRef_iterator it = v.tracks_begin(), itEnd = v.tracks_end(); it != itEnd; ++it) {
0083       const reco::Track& track = *it->get();
0084       TEveRecTrack t;
0085       t.fBeta = 1.;
0086       t.fV = TEveVector(track.vx(), track.vy(), track.vz());
0087       t.fP = TEveVector(track.px(), track.py(), track.pz());
0088       t.fSign = track.charge();
0089       TEveTrack* trk = new TEveTrack(&t, context().getTrackPropagator());
0090       trk->SetMainColor(item()->defaultDisplayProperties().color());
0091       trk->MakeTrack();
0092       setupAddElement(trk, &oItemHolder);
0093     }
0094   }
0095   setupAddElement(pointSet, &oItemHolder);
0096 }
0097 
0098 REGISTER_FWPROXYBUILDER(FWSecVertexProxyBuilder,
0099                         reco::SecondaryVertexTagInfo,
0100                         "SecVertex",
0101                         FWViewType::k3DBit | FWViewType::kAllRPZBits);