4 #include "TGLFontManager.h"
6 #include "TEveManager.h"
7 #include "TEveStraightLineSet.h"
9 #include "TEveTrackPropagator.h"
10 #include "TEveTrans.h"
12 #include "TEveGeoShape.h"
20 #include "TEveCaloData.h"
48 : m_modules(nullptr), m_moduleLabels(nullptr), m_hits(nullptr), m_legend(nullptr), m_orthographic(
false) {}
54 TGLViewer*
v, TGLViewer::ECameraType
type,
const TEveVectorD
b1, TEveVectorD
b3, TEveVector center) {
55 TGLCamera& cam =
v->RefCamera(
type);
56 TGLMatrix& trans = cam.RefCamBase();
58 trans.Set(trans.GetTranslation(),
b3.Arr(),
b1.Arr());
59 cam.Setup(
v->RefOverallBoundingBox(), kTRUE);
61 cam.SetExternalCenter(
true);
62 cam.SetCenterVec(center.fX, center.fY, center.fZ);
84 if (
conv->nTracks() < 2)
89 m_guiFrame->AddFrame(
new TGLabel(
m_guiFrame,
"Camera Views:"),
new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
92 TGHorizontalFrame*
f =
new TGHorizontalFrame(
m_guiFrame);
93 m_guiFrame->AddFrame(
f,
new TGLayoutHints(kLHintsExpandX, 2, 0, 0, 0));
97 TGTextButton*
b =
new TGTextButton(
f,
action->getName().c_str());
98 f->AddFrame(
b,
new TGLayoutHints(kLHintsExpandX));
99 TQObject::Connect(
b,
"Clicked()",
"CSGAction",
action,
"activate()");
100 b->SetToolTipText(
"plane normal: track0 x track1");
106 TGTextButton*
b =
new TGTextButton(
f,
action->getName().c_str());
107 f->AddFrame(
b,
new TGLayoutHints(kLHintsExpandX));
108 TQObject::Connect(
b,
"Clicked()",
"CSGAction",
action,
"activate()");
109 b->SetToolTipText(
"left fir: track1");
114 TGTextButton*
b =
new TGTextButton(
f,
action->getName().c_str());
115 f->AddFrame(
b,
new TGLayoutHints(kLHintsExpandX));
116 TQObject::Connect(
b,
"Clicked()",
"CSGAction",
action,
"activate()");
118 b->SetToolTipText(
"plane normal: track1 ");
131 b->SetState(kButtonDown,
false);
132 m_guiFrame->AddFrame(
b,
new TGLayoutHints(kLHintsNormal, 2, 3, 1, 4));
133 TQObject::Connect(
b,
"Clicked()",
"CSGAction",
action,
"activate()");
139 b->SetState(kButtonDown,
false);
140 m_guiFrame->AddFrame(
b,
new TGLayoutHints(kLHintsNormal, 2, 3, 1, 4));
141 TQObject::Connect(
b,
"Clicked()",
"CSGAction",
action,
"activate()");
145 TGCompositeFrame*
p = (TGCompositeFrame*)
m_guiFrame->GetParent();
149 m_modules =
new TEveElementList(
"Modules");
153 m_hits =
new TEveElementList(
"Hits");
164 TEveGeoShape*
gs = dynamic_cast<TEveGeoShape*>(*
i);
165 const auto& rhs = *(*(
i));
166 if (
gs ==
nullptr && (*
i !=
nullptr)) {
167 std::cerr <<
"Got a " <<
typeid(rhs).
name() <<
", expecting TEveGeoShape. ignoring (it must be the clusters)."
174 TString
name =
gs->GetElementTitle();
175 if (!
name.Contains(
"BAD") && !
name.Contains(
"INACTIVE") && !
name.Contains(
"LOST")) {
176 gs->SetMainColor(kBlue);
178 TEveText*
text =
new TEveText(
name.Data());
179 text->PtrMainTrans()->SetFrom(
gs->RefMainTrans().Array());
180 text->SetFontMode(TGLFont::kPixmap);
181 text->SetFontSize(12);
186 TEveTrackPropagator* prop =
new TEveTrackPropagator();
188 prop->SetStepper(TEveTrackPropagator::kRungeKutta);
192 prop->SetRnrDaughters(kTRUE);
193 prop->SetRnrReferences(kTRUE);
194 prop->SetRnrDecay(kTRUE);
197 prop->SetRnrFV(kTRUE);
198 prop->RefFVAtt().SetMarkerColor(
id.
item()->defaultDisplayProperties().color());
199 prop->RefFVAtt().SetMarkerSize(0.8);
202 prop->RefPMAtt().SetMarkerSize(0.5);
203 prop->RefPMAtt().SetMarkerColor(
id.
item()->defaultDisplayProperties().color());
207 trk1->SetLineWidth(2);
208 trk1->SetTitle(
"Track 1 and its ref states");
209 trk1->SetMainColor(
id.
item()->defaultDisplayProperties().color());
210 trk1->SetLineStyle(7);
215 trk0->SetLineWidth(2);
216 trk0->SetTitle(
"Track 0 and its ref states");
217 trk0->SetMainColor(
id.
item()->defaultDisplayProperties().color());
222 float phi =
conv->pairMomentum().phi();
223 float eta =
conv->pairMomentum().eta();
228 TEveCalo3D* calo3d =
new TEveCalo3D(
data);
229 gEve->AddElement(
data);
230 calo3d->SetBarrelRadius(129.00);
231 calo3d->SetEndCapPos(268.36);
233 float theta = TEveCaloData::EtaToTheta(
eta);
234 float ext =
data->GetMaxVal(
true) * calo3d->GetValToHeight();
237 float x = calo3d->GetBarrelRadius() * TMath::Cos(
phi);
238 float y = calo3d->GetBarrelRadius() * TMath::Sin(
phi);
239 float z = calo3d->GetBarrelRadius() / TMath::Tan(
theta);
241 calo3d->SetupBBoxCube(
ext,
x,
y,
z);
245 float r =
z * TMath::Tan(
theta);
246 calo3d->SetupBBoxCube(
ext,
r * TMath::Cos(
phi),
r * TMath::Sin(
phi),
z);
252 TEveVectorD fwd = trk1->GetMomentum().Cross(trk0->GetMomentum());
254 TEveVectorD lft = trk1->GetMomentum();
256 TEveVectorD
up = lft.Cross(fwd);
258 TEveVectorD
c = (trk1->GetVertex() + trk0->GetVertex()) * 0.5;
260 setCameraInit(
viewerGL(), TGLViewer::kCameraPerspXOZ, fwd,
up,
c);
261 setCameraInit(
viewerGL(), TGLViewer::kCameraPerspYOZ,
up, lft,
c);
262 setCameraInit(
viewerGL(), TGLViewer::kCameraPerspXOY, lft, fwd,
c);
264 setCameraInit(
viewerGL(), TGLViewer::kCameraOrthoXOY, fwd,
up,
c);
265 setCameraInit(
viewerGL(), TGLViewer::kCameraOrthoXOZ,
up, lft,
c);
266 setCameraInit(
viewerGL(), TGLViewer::kCameraOrthoZOY, lft, fwd,
c);
275 TEveStraightLineSet* bls =
new TEveStraightLineSet(
"base1");
276 bls->AddLine(
c, fwd +
c);
277 bls->SetMainColor(kBlue);
278 bls->SetMainTransparency(transp);
279 bls->SetPickable(
false);
284 TEveStraightLineSet* bls =
new TEveStraightLineSet(
"base2");
285 bls->AddLine(
c, lft +
c);
286 bls->SetMainColor(kBlue);
287 bls->SetMainTransparency(transp);
288 bls->SetPickable(
false);
293 TEveStraightLineSet* bls =
new TEveStraightLineSet(
"base3");
294 bls->AddLine(
c,
up +
c);
295 bls->SetMainColor(kBlue);
296 bls->SetMainTransparency(transp);
297 bls->SetPickable(
false);
302 TEveStraightLineSet* bls =
new TEveStraightLineSet(
"Photon",
"Photon");
304 bls->AddLine(
c.fX,
c.fY,
c.fZ,
bs->x0(),
bs->y0(),
bs->z0());
305 bls->SetMainColor(
id.
item()->defaultDisplayProperties().color());
306 bls->SetLineStyle(3);
310 viewerGL()->SetStyle(TGLRnrCtx::kOutline);
311 viewerGL()->ResetCamerasAfterNextUpdate();
325 TLatex* latex =
new TLatex(
x,
y,
"");
326 const double textsize(0.07);
327 latex->SetTextSize(2 * textsize);
330 y -= latex->GetTextSize() * 0.6;
332 latex->SetTextSize(textsize);
333 float lineH = latex->GetTextSize() * 0.6;
337 Form(
"p_{T}=%.1f GeV, #eta=%0.2f, #varphi=%0.2f",
339 conv->pairMomentum().eta(),
340 conv->pairMomentum().phi()));
344 Form(
"vtx=(%.1f, %.1f, %.1f) r=%.1f [cm]",
345 conv->conversionVertex().x(),
346 conv->conversionVertex().y(),
347 conv->conversionVertex().z(),
348 conv->conversionVertex().position().rho()));
350 latex->DrawLatex(
x,
y, Form(
"#Deltactg#theta=%.3f",
conv->pairCotThetaSeparation()));
352 latex->DrawLatex(
x,
y, Form(
"#Delta#phi_{vtx}=%.3f",
conv->dPhiTracksAtVtx()));
354 latex->DrawLatex(
x,
y, Form(
"dist. min. app.=%.3f cm",
conv->distOfMinimumApproach()));
359 latex->DrawLatex(
x,
y, Form(
"Trk0 q=%i", track0->
charge()));
361 latex->DrawLatex(
x,
y, Form(
"p_{T}=%.1f GeV, #eta=%0.2f, #varphi=%0.2f", track0->
pt(), track0->
eta(), track0->
phi()));
364 int nvalid_tk0 = 0, ninvalid_tk0 = 0, npix_tk0 = 0, nstrip_tk0 = 0;
376 latex->DrawLatex(
x,
y, Form(
"valid hits: %i (pix. %i, str. %i)", nvalid_tk0, npix_tk0, nstrip_tk0));
378 latex->DrawLatex(
x,
y, Form(
"invalid: %i", ninvalid_tk0));
381 int npix_mhi_tk0 = 0, nstrip_mhi_tk0 = 0;
389 latex->DrawLatex(
x,
y, Form(
"miss. inner hits: pix. %i, str. %i", npix_mhi_tk0, nstrip_mhi_tk0));
394 latex->DrawLatex(
x,
y, Form(
"Trk1 q=%i", track1->
charge()));
396 latex->DrawLatex(
x,
y, Form(
"p_{T}=%.1f GeV, #eta=%0.2f, #varphi=%0.2f", track1->
pt(), track1->
eta(), track1->
phi()));
400 int nvalid_tk1 = 0, ninvalid_tk1 = 0, npix_tk1 = 0, nstrip_tk1 = 0;
412 latex->DrawLatex(
x,
y, Form(
"valid hits: %i (pix. %i, str. %i)", nvalid_tk1, npix_tk1, nstrip_tk1));
414 latex->DrawLatex(
x,
y, Form(
"invalid: %i", ninvalid_tk1));
417 int npix_mhi_tk1 = 0, nstrip_mhi_tk1 = 0;
425 latex->DrawLatex(
x,
y, Form(
"miss. inner hits: pix. %i, str. %i", npix_mhi_tk1, nstrip_mhi_tk1));
431 class TEveElementList* tList,
437 TEvePointSet* pointSet =
new TEvePointSet();
438 pointSet->SetMarkerSize(
size);
439 pointSet->SetMarkerStyle(4);
440 pointSet->SetPickable(kTRUE);
441 pointSet->SetTitle(
"Pixel Hits");
442 pointSet->SetMarkerColor(color);
444 for (std::vector<TVector3>::const_iterator it =
points.begin(), itEnd =
points.end(); it != itEnd; ++it) {
445 pointSet->SetNextPoint(it->x(), it->y(), it->z());
447 tList->AddElement(pointSet);
452 TEveElement* trkList,
453 bool addNearbyHits) {
454 std::vector<TVector3> pixelPoints;
456 TEveElementList* pixels =
new TEveElementList(
"Pixels");
457 trkList->AddElement(pixels);
460 std::vector<TVector3> pixelExtraPoints;
472 TEveElementList*
strips =
new TEveElementList(
"Strips");
473 trkList->AddElement(
strips);
481 TEveElement* trkList,
483 std::set<unsigned int> ids;
486 DetId detid = (*recIt)->geographicalId();
487 if (!addLostHits && !(*recIt)->isValid())
489 if (detid.
rawId() != 0) {
491 switch (detid.
det()) {
507 name =
"Pixel Barrel ";
510 name =
"Pixel Endcap ";
539 if (
nullptr != shape) {
540 shape->SetMainTransparency(65);
541 shape->SetPickable(kTRUE);
542 switch ((*recIt)->type()) {
550 shape->SetMainColor(kRed);
556 shape->SetMainColor(28);
560 shape->SetMainColor(218);
563 shape->SetTitle(
name + ULong_t(detid.
rawId()));
564 trkList->AddElement(shape);
578 viewerGL()->SetDrawCameraCenter(kTRUE);