CMS 3D CMS Logo

FWVertexProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Vertexs
4 // Class : FWVertexProxyBuilder
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 "TEveGeoShape.h"
39 #include "TEveVSDStructs.h"
40 
41 class FWVertexProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::Vertex> {
42 public:
44  ~FWVertexProxyBuilder() override {}
45 
46  void setItem(const FWEventItem* iItem) override {
48  if (iItem) {
49  iItem->getConfig()->assertParam("Draw Tracks", false);
50  iItem->getConfig()->assertParam("Draw Pseudo Track", false);
51  iItem->getConfig()->assertParam("Draw Ellipse", false);
52  iItem->getConfig()->assertParam("Scale Ellipse", 2l, 1l, 10l);
53  iItem->getConfig()->assertParam(
54  "Ellipse Color Index", 6l, 0l, (long)context().colorManager()->numberOfLimitedColors());
55  iItem->getConfig()->assertParam("Event Center Index", -1l, -1l, 500l);
56  }
57  }
58 
60 
61 private:
62  FWVertexProxyBuilder(const FWVertexProxyBuilder&) = delete; // stop default
63  const FWVertexProxyBuilder& operator=(const FWVertexProxyBuilder&) = delete; // stop default
64 
66  void build(const reco::Vertex& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
67 
68  void localModelChanges(const FWModelId& iId,
69  TEveElement* iCompound,
70  FWViewType::EType viewType,
71  const FWViewContext* vc) override;
72 };
73 
75  unsigned int iIndex,
76  TEveElement& oItemHolder,
77  const FWViewContext* vc) {
78  const reco::Vertex& v = iData;
79 
80  // marker
81  TEveGeoManagerHolder gmgr(TEveGeoShape::GetGeoMangeur());
82  TEvePointSet* pointSet = new TEvePointSet();
83  pointSet->SetNextPoint(v.x(), v.y(), v.z());
84  setupAddElement(pointSet, &oItemHolder);
85 
86  // ellipse
87  if (item()->getConfig()->value<bool>("Draw Ellipse")) {
88  TEveEllipsoid* eveEllipsoid = new TEveEllipsoid("Ellipsoid", Form("Ellipsoid %d", iIndex));
89 
90  eveEllipsoid->RefPos().Set(v.x(), v.y(), v.z());
91 
92  reco::Vertex::Error e = v.error();
93  TMatrixDSym m(3);
94  for (int i = 0; i < 3; i++)
95  for (int j = 0; j < 3; j++) {
96  m(i, j) = e(i, j);
97  eveEllipsoid->RefEMtx()(i + 1, j + 1) = e(i, j);
98  }
99 
100  // external scaling
101  double ellipseScale = 1.;
102  if (item()->getConfig()->value<long>("Scale Ellipse"))
103  ellipseScale = item()->getConfig()->value<long>("Scale Ellipse");
104 
105  eveEllipsoid->SetScale(ellipseScale);
106 
107  // cache 3D extend used in eval bbox and render 3D
108  TMatrixDEigen eig(m);
109  TVectorD vv(eig.GetEigenValuesRe());
110  eveEllipsoid->RefExtent3D().Set(sqrt(vv(0)) * ellipseScale, sqrt(vv(1)) * ellipseScale, sqrt(vv(2)) * ellipseScale);
111 
112  eveEllipsoid->SetLineWidth(2);
113  setupAddElement(eveEllipsoid, &oItemHolder);
114  eveEllipsoid->SetMainTransparency(TMath::Min(100, 80 + item()->defaultDisplayProperties().transparency() / 5));
115 
116  Color_t color = item()->getConfig()->value<long>("Ellipse Color Index");
117  // eveEllipsoid->SetFillColor(item()->defaultDisplayProperties().color());
118  // eveEllipsoid->SetLineColor(item()->defaultDisplayProperties().color());
119  eveEllipsoid->SetMainColor(color + context().colorManager()->offsetOfLimitedColors());
120  }
121 
122  // tracks
123  if (item()->getConfig()->value<bool>("Draw Tracks")) {
124  for (reco::Vertex::trackRef_iterator it = v.tracks_begin(); it != v.tracks_end(); ++it) {
125  float w = v.trackWeight(*it);
126  if (w < 0.5)
127  continue;
128 
129  const reco::Track& track = *it->get();
130  TEveRecTrack t;
131  t.fBeta = 1.;
132  t.fV = TEveVector(track.vx(), track.vy(), track.vz());
133  t.fP = TEveVector(track.px(), track.py(), track.pz());
134  t.fSign = track.charge();
135  TEveTrack* trk = new TEveTrack(&t, context().getTrackPropagator());
136  trk->SetMainColor(item()->defaultDisplayProperties().color());
137  trk->MakeTrack();
138  setupAddElement(trk, &oItemHolder);
139  }
140  }
141  if (item()->getConfig()->value<bool>("Draw Pseudo Track")) {
142  TEveRecTrack t;
143  t.fBeta = 1.;
144  t.fV = TEveVector(v.x(), v.y(), v.z());
145  t.fP = TEveVector(-v.p4().px(), -v.p4().py(), -v.p4().pz());
146  t.fSign = 1;
147  TEveTrack* trk = new TEveTrack(&t, context().getTrackPropagator());
148  trk->SetLineStyle(7);
149  trk->MakeTrack();
150  setupAddElement(trk, &oItemHolder);
151  }
152 
154  int cIdx = item()->getConfig()->value<long>("Event Center Index");
155  if (cIdx == -1) {
157  }
158  if (cIdx >= 0 && int(iIndex) == int(cIdx)) {
159  fwLog(fwlog::kInfo) << "FWVertexProxyBuilder set event center "
160  << Form("idx [%d], (%f %f %f) \n", cIdx, v.x(), v.y(), v.z());
161  context->commonPrefs()->setEventCenter(v.x(), v.y(), v.z());
162  }
163 }
164 
166  TEveElement* iCompound,
167  FWViewType::EType viewType,
168  const FWViewContext* vc) {
169  increaseComponentTransparency(iId.index(), iCompound, "Ellipsoid", 80);
170  TEveElement* el = iCompound->FindChild("Ellipsoid");
171  if (el)
172  el->SetMainColor(item()->getConfig()->value<long>("Ellipse Color Index") +
173  context().colorManager()->offsetOfLimitedColors());
174 }
175 
176 //
177 // static member functions
178 //
reco::Vertex::trackRef_iterator
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:38
FWVertexProxyBuilder::localModelChanges
void localModelChanges(const FWModelId &iId, TEveElement *iCompound, FWViewType::EType viewType, const FWViewContext *vc) override
Definition: FWVertexProxyBuilder.cc:165
fwLog
#define fwLog(_level_)
Definition: fwLog.h:45
mps_fire.i
i
Definition: mps_fire.py:428
fireworks::Context
Definition: Context.h:41
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
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
REGISTER_PROXYBUILDER_METHODS
#define REGISTER_PROXYBUILDER_METHODS()
Definition: register_dataproxybuilder_macro.h:28
FWVertexProxyBuilder::~FWVertexProxyBuilder
~FWVertexProxyBuilder() override
Definition: FWVertexProxyBuilder.cc:44
TEveEllipsoid::SetScale
void SetScale(float x)
Definition: TEveEllipsoid.h:40
findQualityFiles.v
v
Definition: findQualityFiles.py:179
FWParameters.h
FWVertexProxyBuilder::operator=
const FWVertexProxyBuilder & operator=(const FWVertexProxyBuilder &)=delete
FWColorManager.h
FWVertexProxyBuilder
Definition: FWVertexProxyBuilder.cc:41
CmsShowCommon::setEventCenter
void setEventCenter(float, float, float)
Definition: CmsShowCommon.cc:307
w
const double w
Definition: UKUtility.cc:23
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
reco::Track
Definition: Track.h:27
CmsShowCommon::resetEventCenter
void resetEventCenter()
Definition: CmsShowCommon.cc:313
FWProxyBuilderBase::increaseComponentTransparency
void increaseComponentTransparency(unsigned int index, TEveElement *holder, const std::string &name, Char_t transpOffset)
Definition: FWProxyBuilderBase.cc:393
FWModelId::index
int index() const
Definition: FWModelId.h:41
fireworks::Context::commonPrefs
CmsShowCommon * commonPrefs() const
Definition: Context.cc:160
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
FWVertexProxyBuilder::setItem
void setItem(const FWEventItem *iItem) override
Definition: FWVertexProxyBuilder.cc:46
TEveEllipsoid
Definition: TEveEllipsoid.h:13
FWProxyBuilderConfiguration.h
FWProxyBuilderBase::setupAddElement
void setupAddElement(TEveElement *el, TEveElement *parent, bool set_color=true) const
Definition: FWProxyBuilderBase.cc:350
fwLog.h
FWProxyBuilderBase::build
void build()
Definition: FWProxyBuilderBase.cc:110
FWEventItem.h
FWViewContext
Definition: FWViewContext.h:32
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
VertexFwd.h
FWProxyBuilderBase::item
const FWEventItem * item() const
Definition: FWProxyBuilderBase.h:64
fwlog::kInfo
Definition: fwLog.h:35
CmsShowCommon.h
FWEventItem
Definition: FWEventItem.h:56
FWVertexProxyBuilder::FWVertexProxyBuilder
FWVertexProxyBuilder()
Definition: FWVertexProxyBuilder.cc:43
FWProxyBuilderConfiguration::value
T value(const std::string &name)
Definition: FWProxyBuilderConfiguration.cc:123
FWViewType::k3DBit
Definition: FWViewType.h:50
fireworks::Context::getInstance
static Context * getInstance()
Definition: Context.cc:193
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
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
TEveEllipsoid.h
reco::Vertex
Definition: Vertex.h:35
Context.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37