CMS 3D CMS Logo

FWVertexCandidateProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Vertexs
4 // Class : FWVertexCandidateProxyBuilder
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Tue Dec 2 14:17:03 EST 2008
11 //
12 // user include files// user include files
22 
25 
26 #include "TEvePointSet.h"
27 #include "TMatrixDEigen.h"
28 #include "TMatrixDSym.h"
29 #include "TDecompSVD.h"
30 #include "TVectorD.h"
31 #include "TEveTrans.h"
32 #include "TEveTrack.h"
33 #include "TEveTrackPropagator.h"
34 #include "TEveStraightLineSet.h"
35 #include "TEveBoxSet.h"
36 #include "TGeoSphere.h"
37 #include "TEveGeoNode.h"
38 #include "TEveVSDStructs.h"
39 
40 class FWVertexCandidateProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::VertexCompositePtrCandidate> {
41 public:
44 
45  void setItem(const FWEventItem* iItem) override {
47  if (iItem) {
48  iItem->getConfig()->assertParam("Draw Tracks", false);
49  iItem->getConfig()->assertParam("Draw Pseudo Track", false);
50  iItem->getConfig()->assertParam("Draw Ellipse", false);
51  iItem->getConfig()->assertParam("Scale Ellipse", 2l, 1l, 10l);
52  iItem->getConfig()->assertParam(
53  "Ellipse Color Index", 6l, 0l, (long)context().colorManager()->numberOfLimitedColors());
54  }
55  }
56 
58 
59 private:
60  FWVertexCandidateProxyBuilder(const FWVertexCandidateProxyBuilder&) = delete; // stop default
61  const FWVertexCandidateProxyBuilder& operator=(const FWVertexCandidateProxyBuilder&) = delete; // stop default
62 
64  void build(const reco::VertexCompositePtrCandidate& iData,
65  unsigned int iIndex,
66  TEveElement& oItemHolder,
67  const FWViewContext*) override;
68 
69  void localModelChanges(const FWModelId& iId,
70  TEveElement* iCompound,
71  FWViewType::EType viewType,
72  const FWViewContext* vc) override;
73 };
74 
76  unsigned int iIndex,
77  TEveElement& oItemHolder,
78  const FWViewContext*) {
79  const reco::VertexCompositePtrCandidate& v = iData;
80 
81  // marker
82  TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
83  TEvePointSet* pointSet = new TEvePointSet();
84  pointSet->SetNextPoint(v.vx(), v.vy(), v.vz());
85  setupAddElement(pointSet, &oItemHolder);
86 
87  // ellipse
88  if (item()->getConfig()->value<bool>("Draw Ellipse")) {
89  TEveEllipsoid* eveEllipsoid = new TEveEllipsoid("Ellipsoid", Form("Ellipsoid %d", iIndex));
90 
91  eveEllipsoid->RefPos().Set(v.vx(), v.vy(), v.vz());
92 
93  reco::Vertex::Error e = v.error();
94  TMatrixDSym m(3);
95  for (int i = 0; i < 3; i++)
96  for (int j = 0; j < 3; j++) {
97  m(i, j) = e(i, j);
98  eveEllipsoid->RefEMtx()(i + 1, j + 1) = e(i, j);
99  }
100 
101  // external scaling
102  double ellipseScale = 1.;
103  if (item()->getConfig()->value<long>("Scale Ellipse"))
104  ellipseScale = item()->getConfig()->value<long>("Scale Ellipse");
105 
106  eveEllipsoid->SetScale(ellipseScale);
107 
108  // cache 3D extend used in eval bbox and render 3D
109  TMatrixDEigen eig(m);
110  TVectorD vv(eig.GetEigenValuesRe());
111  eveEllipsoid->RefExtent3D().Set(sqrt(vv(0)) * ellipseScale, sqrt(vv(1)) * ellipseScale, sqrt(vv(2)) * ellipseScale);
112 
113  eveEllipsoid->SetLineWidth(2);
114  setupAddElement(eveEllipsoid, &oItemHolder);
115  eveEllipsoid->SetMainTransparency(TMath::Min(100, 80 + item()->defaultDisplayProperties().transparency() / 5));
116 
117  Color_t color = item()->getConfig()->value<long>("Ellipse Color Index");
118  // eveEllipsoid->SetFillColor(item()->defaultDisplayProperties().color());
119  // eveEllipsoid->SetLineColor(item()->defaultDisplayProperties().color());
120  eveEllipsoid->SetMainColor(color + context().colorManager()->offsetOfLimitedColors());
121  }
122 
123  // tracks
124  if (item()->getConfig()->value<bool>("Draw Tracks")) {
125  for (unsigned int j = 0; j < v.numberOfDaughters(); j++) {
126  const reco::Candidate* c = v.daughter(j);
127  std::cout << c << std::endl;
128  TEveTrack* trk = fireworks::prepareCandidate(*c, context().getTrackPropagator());
129 
130  trk->SetMainColor(item()->defaultDisplayProperties().color());
131  trk->MakeTrack();
132  setupAddElement(trk, &oItemHolder);
133  }
134  }
135  if (item()->getConfig()->value<bool>("Draw Pseudo Track")) {
136  TEveRecTrack t;
137  t.fBeta = 1.;
138  t.fV = TEveVector(v.vx(), v.vy(), v.vz());
139  t.fP = TEveVector(-v.p4().px(), -v.p4().py(), -v.p4().pz());
140  t.fSign = 1;
141  TEveTrack* trk = new TEveTrack(&t, context().getTrackPropagator());
142  trk->SetLineStyle(7);
143  trk->MakeTrack();
144  setupAddElement(trk, &oItemHolder);
145  }
146 }
147 
149  TEveElement* iCompound,
150  FWViewType::EType viewType,
151  const FWViewContext* vc) {
152  increaseComponentTransparency(iId.index(), iCompound, "Ellipsoid", 80);
153  TEveElement* el = iCompound->FindChild("Ellipsoid");
154  if (el)
155  el->SetMainColor(item()->getConfig()->value<long>("Ellipse Color Index") +
156  context().colorManager()->offsetOfLimitedColors());
157 }
158 
159 //
160 // static member functions
161 //
164  "CandVertices",
FWVertexCandidateProxyBuilder
Definition: FWVertexCandidateProxyBuilder.cc:40
mps_fire.i
i
Definition: mps_fire.py:355
FWVertexCandidateProxyBuilder::~FWVertexCandidateProxyBuilder
~FWVertexCandidateProxyBuilder() override
Definition: FWVertexCandidateProxyBuilder.cc:43
FWSimpleProxyBuilderTemplate.h
TEveEllipsoid::RefPos
TEveVector & RefPos()
Definition: TEveEllipsoid.h:36
FWViewType::EType
EType
Definition: FWViewType.h:31
FWEventItem::getConfig
FWProxyBuilderConfiguration * getConfig() const
Definition: FWEventItem.h:150
FWViewType::kAllRPZBits
static const int kAllRPZBits
Definition: FWViewType.h:67
REGISTER_FWPROXYBUILDER
#define REGISTER_FWPROXYBUILDER(_name_, _type_, _purpose_, _view_)
Definition: FWProxyBuilderFactory.h:33
FWModelId
Definition: FWModelId.h:28
reco::Vertex::Error
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:44
TEveEllipsoid::RefEMtx
TEveTrans & RefEMtx()
Definition: TEveEllipsoid.h:38
gather_cfg.cout
cout
Definition: gather_cfg.py:144
REGISTER_PROXYBUILDER_METHODS
#define REGISTER_PROXYBUILDER_METHODS()
Definition: register_dataproxybuilder_macro.h:28
TEveEllipsoid::SetScale
void SetScale(float x)
Definition: TEveEllipsoid.h:40
findQualityFiles.v
v
Definition: findQualityFiles.py:179
FWParameters.h
reco::VertexCompositePtrCandidate
Definition: VertexCompositePtrCandidate.h:16
FWVertexCandidateProxyBuilder::setItem
void setItem(const FWEventItem *iItem) override
Definition: FWVertexCandidateProxyBuilder.cc:45
FWColorManager.h
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
FWProxyBuilderBase::increaseComponentTransparency
void increaseComponentTransparency(unsigned int index, TEveElement *holder, const std::string &name, Char_t transpOffset)
Definition: FWProxyBuilderBase.cc:393
VertexCompositePtrCandidate.h
OrderedSet.t
t
Definition: OrderedSet.py:90
FWModelId::index
int index() const
Definition: FWModelId.h:41
Vertex.h
FWProxyBuilderConfiguration::assertParam
FWGenericParameter< T > * assertParam(const std::string &name, T def)
Definition: FWProxyBuilderConfiguration.cc:83
TEveEllipsoid::RefExtent3D
TEveVector & RefExtent3D()
Definition: TEveEllipsoid.h:37
TEveEllipsoid
Definition: TEveEllipsoid.h:13
FWProxyBuilderConfiguration.h
FWProxyBuilderBase::setupAddElement
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
Definition: FWProxyBuilderBase.cc:350
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
FWProxyBuilderBase::build
void build()
Definition: FWProxyBuilderBase.cc:110
FWEventItem.h
FWViewContext
Definition: FWViewContext.h:32
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:193
reco::Candidate
Definition: Candidate.h:27
VertexFwd.h
FWProxyBuilderBase::item
const FWEventItem * item() const
Definition: FWProxyBuilderBase.h:64
CandidateUtils.h
FWEventItem
Definition: FWEventItem.h:56
FWProxyBuilderConfiguration::value
T value(const std::string &name)
Definition: FWProxyBuilderConfiguration.cc:123
FWVertexCandidateProxyBuilder::FWVertexCandidateProxyBuilder
FWVertexCandidateProxyBuilder()
Definition: FWVertexCandidateProxyBuilder.cc:42
fireworks::prepareCandidate
TEveTrack * prepareCandidate(const reco::Candidate &track, TEveTrackPropagator *propagator)
Definition: CandidateUtils.cc:9
FWViewType::k3DBit
Definition: FWViewType.h:50
FWVertexCandidateProxyBuilder::localModelChanges
void localModelChanges(const FWModelId &iId, TEveElement *iCompound, FWViewType::EType viewType, const FWViewContext *vc) override
Definition: FWVertexCandidateProxyBuilder.cc:148
FWProxyBuilderBase::context
const fireworks::Context & context() const
Definition: FWProxyBuilderBase.cc:412
FWSimpleProxyBuilderTemplate
Definition: FWSimpleProxyBuilderTemplate.h:30
Min
T Min(T a, T b)
Definition: MathUtil.h:39
FWProxyBuilderBase::setItem
virtual void setItem(const FWEventItem *iItem)
Definition: FWProxyBuilderBase.cc:83
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
FWVertexCandidateProxyBuilder::operator=
const FWVertexCandidateProxyBuilder & operator=(const FWVertexCandidateProxyBuilder &)=delete
TEveEllipsoid.h
Context.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37