From 00946c071b315ef1b118be57ce42003857402aee Mon Sep 17 00:00:00 2001 From: Alja Mrak-Tadel Date: Tue, 30 Dec 2014 13:55:51 -0800 Subject: [PATCH 1/2] Add strip clusters. --- .../plugins/FWTrajectorySeedProxyBuilder.cc | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/Fireworks/Tracks/plugins/FWTrajectorySeedProxyBuilder.cc b/Fireworks/Tracks/plugins/FWTrajectorySeedProxyBuilder.cc index 3c84747858ada..db5e4ea9ff0bb 100644 --- a/Fireworks/Tracks/plugins/FWTrajectorySeedProxyBuilder.cc +++ b/Fireworks/Tracks/plugins/FWTrajectorySeedProxyBuilder.cc @@ -63,7 +63,8 @@ FWTrajectorySeedProxyBuilder::build( const TrajectorySeed& iData, unsigned int i // TEveVector startPos(pnt.x(), pnt.y(), pnt.z()); TEvePointSet* pointSet = new TEvePointSet; - TEveLine* lineSet = new TEveLine; + TEveLine* line = new TEveLine; + TEveStraightLineSet* lineSet = new TEveStraightLineSet; TrajectorySeed::const_iterator hit = iData.recHits().first; for(; hit != iData.recHits().second; hit++) { @@ -95,13 +96,33 @@ FWTrajectorySeedProxyBuilder::build( const TrajectorySeed& iData, unsigned int i geom->localToGlobal( id, localPoint, globalPoint ); pointSet->SetNextPoint( globalPoint[0], globalPoint[1], globalPoint[2] ); - lineSet->SetNextPoint( globalPoint[0], globalPoint[1], globalPoint[2] ); + line->SetNextPoint( globalPoint[0], globalPoint[1], globalPoint[2] ); + + } + + else { + const SiStripCluster *cluster = fireworks::extractClusterFromTrackingRecHit( &*hit ); + + if (cluster) { + short firststrip = cluster->firstStrip(); + float localTop[3] = { 0.0, 0.0, 0.0 }; + float localBottom[3] = { 0.0, 0.0, 0.0 }; + + fireworks::localSiStrip( firststrip, localTop, localBottom, pars, id ); + + float globalTop[3]; + float globalBottom[3]; + geom->localToGlobal( id, localTop, globalTop, localBottom, globalBottom ); + + lineSet->AddLine( globalTop[0], globalTop[1], globalTop[2], + globalBottom[0], globalBottom[1], globalBottom[2] ); + } } } setupAddElement( pointSet, &itemHolder ); + setupAddElement( line, &itemHolder ); setupAddElement( lineSet, &itemHolder ); - setupElement(pointSet); } // From 13a3351333e9ae2313ce831248ce2bf8fb026955 Mon Sep 17 00:00:00 2001 From: Andrea Date: Thu, 13 Nov 2014 13:57:06 +0100 Subject: [PATCH 2/2] fworks sv candidate --- .../plugins/FWCandidateProxyBuilder.cc | 27 +++ .../plugins/FWCandidatePtrProxyBuilder.cc | 65 +++++++ Fireworks/Vertices/plugins/BuildFile.xml | 1 + .../FWSecVertexCandidateProxyBuilder.cc | 98 ++++++++++ .../plugins/FWVertexCandidateProxyBuilder.cc | 169 ++++++++++++++++++ 5 files changed, 360 insertions(+) create mode 100644 Fireworks/Candidates/plugins/FWCandidatePtrProxyBuilder.cc create mode 100644 Fireworks/Vertices/plugins/FWSecVertexCandidateProxyBuilder.cc create mode 100644 Fireworks/Vertices/plugins/FWVertexCandidateProxyBuilder.cc diff --git a/Fireworks/Candidates/plugins/FWCandidateProxyBuilder.cc b/Fireworks/Candidates/plugins/FWCandidateProxyBuilder.cc index e23faa830b731..085207f7a0252 100644 --- a/Fireworks/Candidates/plugins/FWCandidateProxyBuilder.cc +++ b/Fireworks/Candidates/plugins/FWCandidateProxyBuilder.cc @@ -19,6 +19,9 @@ #include "Fireworks/Candidates/interface/CandidateUtils.h" #include "DataFormats/Candidate/interface/Candidate.h" +#include "Fireworks/Core/interface/FWEventItem.h" +#include "Fireworks/Core/interface/FWProxyBuilderConfiguration.h" + class FWCandidateProxyBuilder : public FWSimpleProxyBuilderTemplate { @@ -26,6 +29,15 @@ class FWCandidateProxyBuilder : public FWSimpleProxyBuilderTemplategetConfig()->assertParam("Draw backward extrapolation", false); + } + } + REGISTER_PROXYBUILDER_METHODS(); private: @@ -44,6 +56,21 @@ FWCandidateProxyBuilder::build(const reco::Candidate& iData, unsigned int iIndex trk->MakeTrack(); setupAddElement(trk, &oItemHolder); + + if ( item()->getConfig()->value("Draw backward extrapolation")) + { + TEveRecTrack t; + t.fBeta = 1.; + t.fV = TEveVector(iData.vx(),iData.vy(),iData.vz()); + t.fP = TEveVector(-iData.p4().px(), -iData.p4().py(), -iData.p4().pz()); + t.fSign = iData.charge(); + TEveTrack* trk2= new TEveTrack(&t, context().getTrackPropagator()); + trk2->SetLineStyle(7); + trk2->MakeTrack(); + setupAddElement(trk2, &oItemHolder); + + } + } // diff --git a/Fireworks/Candidates/plugins/FWCandidatePtrProxyBuilder.cc b/Fireworks/Candidates/plugins/FWCandidatePtrProxyBuilder.cc new file mode 100644 index 0000000000000..5abdfaeb8d307 --- /dev/null +++ b/Fireworks/Candidates/plugins/FWCandidatePtrProxyBuilder.cc @@ -0,0 +1,65 @@ +// -*- C++ -*- +// +// Package: CandidatePtrs +// Class : FWCandidatePtrProxyBuilder +// +// Implementation: +// +// +// Original Author: Chris Jones +// Created: Fri Dec 5 09:56:09 EST 2008 +// + +#include "TEveTrack.h" + +// user include files +#include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h" +#include "Fireworks/Core/interface/Context.h" + +#include "Fireworks/Candidates/interface/CandidateUtils.h" + +#include "DataFormats/Candidate/interface/Candidate.h" + +class FWCandidatePtrProxyBuilder : public FWSimpleProxyBuilderTemplate { + +public: + FWCandidatePtrProxyBuilder() {} + virtual ~FWCandidatePtrProxyBuilder() {} + + REGISTER_PROXYBUILDER_METHODS(); + +private: + FWCandidatePtrProxyBuilder(const FWCandidatePtrProxyBuilder&); // stop default + const FWCandidatePtrProxyBuilder& operator=(const FWCandidatePtrProxyBuilder&); // stop default + + using FWSimpleProxyBuilderTemplate::build; + void build(const reco::CandidatePtr& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override; +}; + + +void +FWCandidatePtrProxyBuilder::build(const reco::CandidatePtr& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) +{ + TEveTrack* trk = fireworks::prepareCandidate( *iData, context().getTrackPropagator() ); + + trk->MakeTrack(); + setupAddElement(trk, &oItemHolder); + { + TEveRecTrack t; + t.fBeta = 1.; + t.fV = TEveVector(iData->vx(),iData->vy(),iData->vz()); + t.fP = TEveVector(-iData->p4().px(), -iData->p4().py(), -iData->p4().pz()); + t.fSign = iData->charge(); + TEveTrack* trk2= new TEveTrack(&t, context().getTrackPropagator()); + trk2->SetLineStyle(7); + trk2->MakeTrack(); + setupAddElement(trk2, &oItemHolder); + + } + +} + +// +// static member functions +// +REGISTER_FWPROXYBUILDER(FWCandidatePtrProxyBuilder, reco::CandidatePtr, "CandidatePtrs", FWViewType::kAll3DBits | FWViewType::kAllRPZBits); diff --git a/Fireworks/Vertices/plugins/BuildFile.xml b/Fireworks/Vertices/plugins/BuildFile.xml index a318a576d2eb4..ea6c4d749b171 100644 --- a/Fireworks/Vertices/plugins/BuildFile.xml +++ b/Fireworks/Vertices/plugins/BuildFile.xml @@ -3,6 +3,7 @@ + diff --git a/Fireworks/Vertices/plugins/FWSecVertexCandidateProxyBuilder.cc b/Fireworks/Vertices/plugins/FWSecVertexCandidateProxyBuilder.cc new file mode 100644 index 0000000000000..3ddf9da9f6e30 --- /dev/null +++ b/Fireworks/Vertices/plugins/FWSecVertexCandidateProxyBuilder.cc @@ -0,0 +1,98 @@ +// -*- C++ -*- +// +#include + +#include "TMatrixDEigen.h" +#include "TMatrixDSym.h" +#include "TDecompSVD.h" +#include "TEveTrans.h" +#include "TEveTrack.h" +#include "TGeoSphere.h" +#include "TGeoMatrix.h" +#include "TEveGeoNode.h" +#include "TEveVSDStructs.h" + +#include "Fireworks/Candidates/interface/CandidateUtils.h" + + +// include files +#include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h" +#include "Fireworks/Core/interface/FWEventItem.h" + +#include "DataFormats/BTauReco/interface/CandSecondaryVertexTagInfo.h" + +class FWSecVertexCandidateProxyBuilder : public FWSimpleProxyBuilderTemplate { + +public: + FWSecVertexCandidateProxyBuilder(){} + virtual ~FWSecVertexCandidateProxyBuilder(){} + + REGISTER_PROXYBUILDER_METHODS(); + +private: + FWSecVertexCandidateProxyBuilder(const FWSecVertexCandidateProxyBuilder&); // stop default + const FWSecVertexCandidateProxyBuilder& operator=(const FWSecVertexCandidateProxyBuilder&); // stop default + + // ---------- member data -------------------------------- + using FWSimpleProxyBuilderTemplate::build; + void build(const reco::CandSecondaryVertexTagInfo& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override; +}; + +void +FWSecVertexCandidateProxyBuilder::build(const reco::CandSecondaryVertexTagInfo& iData, unsigned int iIndex,TEveElement& oItemHolder, const FWViewContext*) +{ + TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur()); + TEvePointSet* pointSet = new TEvePointSet(); + pointSet->SetMainColor(item()->defaultDisplayProperties().color()); + for(unsigned int i=0;iSetBoxDimensions(2.5,2.5,2.5); + shape->SetShape(sphere); + shape->SetMainColor(item()->defaultDisplayProperties().color()); + shape->SetMainTransparency(10); + + TEveTrans & t = shape->RefMainTrans(); + reco::Vertex::Error e= v.error(); + TMatrixDSym m(3); + for(int i=0;i<3;i++) + for(int j=0;j<3;j++) + { + m(i,j) = e(i,j); + } + TMatrixDEigen eig(m); + TDecompSVD svd(m); + TMatrixD mm = svd.GetU(); + // TMatrixD mm = eig.GetEigenVectors().Print(); + for(int i=0;i<3;i++) + for(int j=0;j<3;j++) + { + t(i+1,j+1) = mm(i,j); + } + TVectorD vv ( eig.GetEigenValuesRe()) ; + t.Scale(sqrt(vv(0))*1000.,sqrt(vv(1))*1000.,sqrt(vv(2))*1000.); + t.SetPos(v.vx(),v.vy(),v.vz()); + + setupAddElement(shape, &oItemHolder); + + pointSet->SetNextPoint( v.vx(), v.vy(), v.vz() ); + + for(unsigned int j=0;jSetMainColor(item()->defaultDisplayProperties().color()); + trk->MakeTrack(); + setupAddElement(trk, &oItemHolder); + } + } + setupAddElement(pointSet, &oItemHolder); +} + +REGISTER_FWPROXYBUILDER(FWSecVertexCandidateProxyBuilder, reco::CandSecondaryVertexTagInfo, "SecVertexCand", FWViewType::k3DBit | FWViewType::kAllRPZBits); diff --git a/Fireworks/Vertices/plugins/FWVertexCandidateProxyBuilder.cc b/Fireworks/Vertices/plugins/FWVertexCandidateProxyBuilder.cc new file mode 100644 index 0000000000000..0780b3fbd9b61 --- /dev/null +++ b/Fireworks/Vertices/plugins/FWVertexCandidateProxyBuilder.cc @@ -0,0 +1,169 @@ +// -*- C++ -*- +// +// Package: Vertexs +// Class : FWVertexCandidateProxyBuilder +// +// Implementation: +// +// +// Original Author: Chris Jones +// Created: Tue Dec 2 14:17:03 EST 2008 +// +// user include files// user include files +#include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h" +#include "Fireworks/Core/interface/FWProxyBuilderConfiguration.h" +#include "Fireworks/Core/interface/FWColorManager.h" +#include "Fireworks/Core/interface/FWEventItem.h" +#include "Fireworks/Core/interface/Context.h" +#include "Fireworks/Core/interface/FWParameters.h" +#include "DataFormats/Candidate/interface/VertexCompositePtrCandidate.h" +#include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/VertexReco/interface/VertexFwd.h" + +#include "Fireworks/Vertices/interface/TEveEllipsoid.h" +#include "Fireworks/Candidates/interface/CandidateUtils.h" + +#include "TEvePointSet.h" +#include "TMatrixDEigen.h" +#include "TMatrixDSym.h" +#include "TDecompSVD.h" +#include "TVectorD.h" +#include "TEveTrans.h" +#include "TEveTrack.h" +#include "TEveTrackPropagator.h" +#include "TEveStraightLineSet.h" +#include "TEveBoxSet.h" +#include "TGeoSphere.h" +#include "TEveGeoNode.h" +#include "TEveVSDStructs.h" + +class FWVertexCandidateProxyBuilder : public FWSimpleProxyBuilderTemplate +{ +public: + FWVertexCandidateProxyBuilder() {} + virtual ~FWVertexCandidateProxyBuilder() {} + + virtual void setItem(const FWEventItem* iItem) override + { + FWProxyBuilderBase::setItem(iItem); + if (iItem) + { + iItem->getConfig()->assertParam("Draw Tracks", false); + iItem->getConfig()->assertParam("Draw Pseudo Track", false); + iItem->getConfig()->assertParam("Draw Ellipse", false); + iItem->getConfig()->assertParam("Scale Ellipse",2l, 1l, 10l); + iItem->getConfig()->assertParam("Ellipse Color Index", 6l, 0l, (long)context().colorManager()->numberOfLimitedColors()); + } + } + + REGISTER_PROXYBUILDER_METHODS(); + +private: + FWVertexCandidateProxyBuilder(const FWVertexCandidateProxyBuilder&); // stop default + const FWVertexCandidateProxyBuilder& operator=(const FWVertexCandidateProxyBuilder&); // stop default + + using FWSimpleProxyBuilderTemplate ::build; + virtual void build(const reco::VertexCompositePtrCandidate& iData, unsigned int iIndex,TEveElement& oItemHolder, const FWViewContext*) override; + + virtual void localModelChanges(const FWModelId& iId, TEveElement* iCompound, + FWViewType::EType viewType, const FWViewContext* vc) override; + +}; + + +void +FWVertexCandidateProxyBuilder::build(const reco::VertexCompositePtrCandidate& iData, unsigned int iIndex, TEveElement& oItemHolder , const FWViewContext*) +{ + const reco::VertexCompositePtrCandidate & v = iData; + + // marker + TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur()); + TEvePointSet* pointSet = new TEvePointSet(); + pointSet->SetNextPoint( v.vx(), v.vy(), v.vz() ); + setupAddElement(pointSet, &oItemHolder); + + + // ellipse + if ( item()->getConfig()->value("Draw Ellipse")) + { + + TEveEllipsoid* eveEllipsoid = new TEveEllipsoid("Ellipsoid", Form("Ellipsoid %d", iIndex)); + + eveEllipsoid->RefPos().Set(v.vx(),v.vy(),v.vz()); + + reco::Vertex::Error e= v.error(); + TMatrixDSym m(3); + for(int i=0;i<3;i++) + for(int j=0;j<3;j++) + { + m(i,j) = e(i,j); + eveEllipsoid->RefEMtx()(i+1, j+1) = e(i,j); + } + + // external scaling + double ellipseScale = 1.; + if ( item()->getConfig()->value("Scale Ellipse")) + ellipseScale = item()->getConfig()->value("Scale Ellipse"); + + eveEllipsoid->SetScale(ellipseScale); + + // cache 3D extend used in eval bbox and render 3D + TMatrixDEigen eig(m); + TVectorD vv ( eig.GetEigenValuesRe()); + eveEllipsoid->RefExtent3D().Set(sqrt(vv(0))*ellipseScale,sqrt(vv(1))*ellipseScale,sqrt(vv(2))*ellipseScale); + + eveEllipsoid->SetLineWidth(2); + setupAddElement(eveEllipsoid, &oItemHolder); + eveEllipsoid->SetMainTransparency(TMath::Min(100, 80 + item()->defaultDisplayProperties().transparency() / 5)); + + + + Color_t color = item()->getConfig()->value("Ellipse Color Index"); + // eveEllipsoid->SetFillColor(item()->defaultDisplayProperties().color()); + // eveEllipsoid->SetLineColor(item()->defaultDisplayProperties().color()); + eveEllipsoid->SetMainColor(color + context().colorManager()->offsetOfLimitedColors()); + } + + // tracks + if ( item()->getConfig()->value("Draw Tracks")) + { + for(unsigned int j=0;jSetMainColor(item()->defaultDisplayProperties().color()); + trk->MakeTrack(); + setupAddElement(trk, &oItemHolder); + } + } + if ( item()->getConfig()->value("Draw Pseudo Track")) + { + TEveRecTrack t; + t.fBeta = 1.; + t.fV = TEveVector(v.vx(),v.vy(),v.vz()); + t.fP = TEveVector(-v.p4().px(), -v.p4().py(), -v.p4().pz()); + t.fSign = 1; + TEveTrack* trk = new TEveTrack(&t, context().getTrackPropagator()); + trk->SetLineStyle(7); + trk->MakeTrack(); + setupAddElement(trk, &oItemHolder); + + } +} + +void +FWVertexCandidateProxyBuilder::localModelChanges(const FWModelId& iId, TEveElement* iCompound, + FWViewType::EType viewType, const FWViewContext* vc) +{ + increaseComponentTransparency(iId.index(), iCompound, "Ellipsoid", 80); + TEveElement* el = iCompound->FindChild("Ellipsoid"); + if (el) + el->SetMainColor(item()->getConfig()->value("Ellipse Color Index") + context().colorManager()->offsetOfLimitedColors()); +} + +// +// static member functions +// +REGISTER_FWPROXYBUILDER(FWVertexCandidateProxyBuilder, reco::VertexCompositePtrCandidate, "CandVertices", FWViewType::k3DBit | FWViewType::kAllRPZBits);