Skip to content

Commit

Permalink
Merge pull request #7025 from alja/andrea73
Browse files Browse the repository at this point in the history
New proxy Candidates and Vertices builders from arizzi
  • Loading branch information
cmsbuild committed Jan 6, 2015
2 parents f912298 + 13a3351 commit bb6f156
Show file tree
Hide file tree
Showing 6 changed files with 384 additions and 3 deletions.
27 changes: 27 additions & 0 deletions Fireworks/Candidates/plugins/FWCandidateProxyBuilder.cc
Expand Up @@ -19,13 +19,25 @@
#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<reco::Candidate> {

public:
FWCandidateProxyBuilder() {}
virtual ~FWCandidateProxyBuilder() {}

virtual void setItem(const FWEventItem* iItem) override
{
FWProxyBuilderBase::setItem(iItem);
if (iItem)
{
iItem->getConfig()->assertParam("Draw backward extrapolation", false);
}
}

REGISTER_PROXYBUILDER_METHODS();

private:
Expand All @@ -44,6 +56,21 @@ FWCandidateProxyBuilder::build(const reco::Candidate& iData, unsigned int iIndex

trk->MakeTrack();
setupAddElement(trk, &oItemHolder);

if ( item()->getConfig()->value<bool>("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);

}

}

//
Expand Down
65 changes: 65 additions & 0 deletions Fireworks/Candidates/plugins/FWCandidatePtrProxyBuilder.cc
@@ -0,0 +1,65 @@
// -*- C++ -*-
//
// Package: CandidatePtrs
// Class : FWCandidatePtrProxyBuilder
//
// Implementation:
// <Notes on 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<reco::CandidatePtr> {

public:
FWCandidatePtrProxyBuilder() {}
virtual ~FWCandidatePtrProxyBuilder() {}

REGISTER_PROXYBUILDER_METHODS();

private:
FWCandidatePtrProxyBuilder(const FWCandidatePtrProxyBuilder&); // stop default
const FWCandidatePtrProxyBuilder& operator=(const FWCandidatePtrProxyBuilder&); // stop default

using FWSimpleProxyBuilderTemplate<reco::CandidatePtr>::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);
27 changes: 24 additions & 3 deletions Fireworks/Tracks/plugins/FWTrajectorySeedProxyBuilder.cc
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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);
}

//
Expand Down
1 change: 1 addition & 0 deletions Fireworks/Vertices/plugins/BuildFile.xml
Expand Up @@ -3,6 +3,7 @@
<use name="DataFormats/VertexReco"/>
<use name="Fireworks/Core"/>
<use name="Fireworks/Vertices"/>
<use name="Fireworks/Candidates"/>
<use name="roothistmatrix"/>
<lib name="Eve"/>
<lib name="Geom"/>
Expand Down
98 changes: 98 additions & 0 deletions Fireworks/Vertices/plugins/FWSecVertexCandidateProxyBuilder.cc
@@ -0,0 +1,98 @@
// -*- C++ -*-
//
#include <vector>

#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<reco::CandSecondaryVertexTagInfo> {

public:
FWSecVertexCandidateProxyBuilder(){}
virtual ~FWSecVertexCandidateProxyBuilder(){}

REGISTER_PROXYBUILDER_METHODS();

private:
FWSecVertexCandidateProxyBuilder(const FWSecVertexCandidateProxyBuilder&); // stop default
const FWSecVertexCandidateProxyBuilder& operator=(const FWSecVertexCandidateProxyBuilder&); // stop default

// ---------- member data --------------------------------
using FWSimpleProxyBuilderTemplate<reco::CandSecondaryVertexTagInfo>::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;i<iData.nVertices();i++)
{
const reco::VertexCompositePtrCandidate & v = iData.secondaryVertex(i);
// do we need this stuff?
TGeoSphere * sphere = new TGeoSphere(0, 0.002); //would that leak?
TGeoTranslation position(v.vx(), v.vy(), v.vz() );
TEveGeoShape * shape = new TEveGeoShape();
sphere->SetBoxDimensions(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;j<v.numberOfDaughters();j++)
{
const reco::Candidate * c = v.daughter(j);
std::cout << c << std::endl;
TEveTrack* trk = fireworks::prepareCandidate( *c, context().getTrackPropagator() );

trk->SetMainColor(item()->defaultDisplayProperties().color());
trk->MakeTrack();
setupAddElement(trk, &oItemHolder);
}
}
setupAddElement(pointSet, &oItemHolder);
}

REGISTER_FWPROXYBUILDER(FWSecVertexCandidateProxyBuilder, reco::CandSecondaryVertexTagInfo, "SecVertexCand", FWViewType::k3DBit | FWViewType::kAllRPZBits);

0 comments on commit bb6f156

Please sign in to comment.