Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-03 04:10:05

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 "Fireworks/Candidates/interface/CandidateUtils.h"
0017 
0018 // include files
0019 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
0020 #include "Fireworks/Core/interface/FWEventItem.h"
0021 
0022 #include "DataFormats/BTauReco/interface/CandSecondaryVertexTagInfo.h"
0023 
0024 class FWSecVertexCandidateProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::CandSecondaryVertexTagInfo> {
0025 public:
0026   FWSecVertexCandidateProxyBuilder() {}
0027   ~FWSecVertexCandidateProxyBuilder() override {}
0028 
0029   REGISTER_PROXYBUILDER_METHODS();
0030 
0031   FWSecVertexCandidateProxyBuilder(const FWSecVertexCandidateProxyBuilder&) = delete;                   // stop default
0032   const FWSecVertexCandidateProxyBuilder& operator=(const FWSecVertexCandidateProxyBuilder&) = delete;  // stop default
0033 
0034 private:
0035   // ---------- member data --------------------------------
0036   using FWSimpleProxyBuilderTemplate<reco::CandSecondaryVertexTagInfo>::build;
0037   void build(const reco::CandSecondaryVertexTagInfo& iData,
0038              unsigned int iIndex,
0039              TEveElement& oItemHolder,
0040              const FWViewContext*) override;
0041 };
0042 
0043 void FWSecVertexCandidateProxyBuilder::build(const reco::CandSecondaryVertexTagInfo& iData,
0044                                              unsigned int iIndex,
0045                                              TEveElement& oItemHolder,
0046                                              const FWViewContext*) {
0047   TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
0048   TEvePointSet* pointSet = new TEvePointSet();
0049   pointSet->SetMainColor(item()->defaultDisplayProperties().color());
0050   for (unsigned int i = 0; i < iData.nVertices(); i++) {
0051     const reco::VertexCompositePtrCandidate& v = iData.secondaryVertex(i);
0052     // do we need this stuff?
0053     TGeoSphere* sphere = new TGeoSphere(0, 0.002);  //would that leak?
0054     TGeoTranslation position(v.vx(), v.vy(), v.vz());
0055     TEveGeoShape* shape = new TEveGeoShape();
0056     sphere->SetBoxDimensions(2.5, 2.5, 2.5);
0057     shape->SetShape(sphere);
0058     shape->SetMainColor(item()->defaultDisplayProperties().color());
0059     shape->SetMainTransparency(10);
0060 
0061     TEveTrans& t = shape->RefMainTrans();
0062     reco::Vertex::Error e = v.error();
0063     TMatrixDSym m(3);
0064     for (int i = 0; i < 3; i++)
0065       for (int j = 0; j < 3; j++) {
0066         m(i, j) = e(i, j);
0067       }
0068     TMatrixDEigen eig(m);
0069     TDecompSVD svd(m);
0070     TMatrixD mm = svd.GetU();
0071     //   TMatrixD mm =  eig.GetEigenVectors().Print();
0072     for (int i = 0; i < 3; i++)
0073       for (int j = 0; j < 3; j++) {
0074         t(i + 1, j + 1) = mm(i, j);
0075       }
0076     TVectorD vv(eig.GetEigenValuesRe());
0077     t.Scale(sqrt(vv(0)) * 1000., sqrt(vv(1)) * 1000., sqrt(vv(2)) * 1000.);
0078     t.SetPos(v.vx(), v.vy(), v.vz());
0079 
0080     setupAddElement(shape, &oItemHolder);
0081 
0082     pointSet->SetNextPoint(v.vx(), v.vy(), v.vz());
0083 
0084     for (unsigned int j = 0; j < v.numberOfDaughters(); j++) {
0085       const reco::Candidate* c = v.daughter(j);
0086       std::cout << c << std::endl;
0087       TEveTrack* trk = fireworks::prepareCandidate(*c, context().getTrackPropagator());
0088 
0089       trk->SetMainColor(item()->defaultDisplayProperties().color());
0090       trk->MakeTrack();
0091       setupAddElement(trk, &oItemHolder);
0092     }
0093   }
0094   setupAddElement(pointSet, &oItemHolder);
0095 }
0096 
0097 REGISTER_FWPROXYBUILDER(FWSecVertexCandidateProxyBuilder,
0098                         reco::CandSecondaryVertexTagInfo,
0099                         "SecVertexCand",
0100                         FWViewType::k3DBit | FWViewType::kAllRPZBits);