LDMX Software
EveShapeDrawer.h
Go to the documentation of this file.
1
7#ifndef EVENTDISPLAY_EVESHAPEDRAWER_H_
8#define EVENTDISPLAY_EVESHAPEDRAWER_H_
9
10#include <math.h>
11
12#include <iostream>
13
14#include "EventDisplay/DetectorGeometry.h" //for BoundingBox
15#include "TEveGeoShape.h"
16#include "TGeoMatrix.h"
17#include "TGeoShape.h"
18#include "TGeoTube.h"
19#include "TVector3.h"
20
21namespace eventdisplay {
22
28 public:
33 static EveShapeDrawer EVE_SHAPE_DRAWER;
34 return EVE_SHAPE_DRAWER;
35 }
36
52 TEveGeoShape* drawHexPrism(Double_t xPos, Double_t yPos, Double_t zPos,
53 Double_t xRot, Double_t yRot, Double_t zRot,
54 Double_t h, Double_t r, Int_t color,
55 Int_t transparency, TString name) {
56 TGeoCombiTrans* locAndOrien = new TGeoCombiTrans(
57 xPos, yPos, zPos, new TGeoRotation(name, xRot, yRot, zRot));
58
59 TEveGeoShape* hexPrism = new TEveGeoShape(name);
60 TGeoShape* tube = new TGeoTube(name, 0, r, h / 2);
61 tube->SetUniqueID(uid_++);
62 hexPrism->SetShape(tube);
63 hexPrism->SetFillColor(color);
64 hexPrism->SetMainTransparency(transparency);
65 hexPrism->SetNSegments(6);
66 hexPrism->SetTransMatrix(*locAndOrien);
67
68 return hexPrism;
69 }
70
82 TEveGeoShape* drawHexPrism(HexPrism prism, Double_t xRot, Double_t yRot,
83 Double_t zRot, Int_t color, Int_t transparency,
84 TString name) {
85 return drawHexPrism(prism.x, prism.y, prism.z, xRot, yRot, zRot,
86 prism.height, prism.radius, color, transparency, name);
87 }
88
105 TEveGeoShape* drawRectPrism(Double_t xPos, Double_t yPos, Double_t zPos,
106 Double_t dX, Double_t dY, Double_t dZ,
107 Double_t xRot, Double_t yRot, Double_t zRot,
108 Int_t color, Int_t transparency, TString name) {
109 TGeoCombiTrans* locAndOrien = new TGeoCombiTrans(
110 xPos, yPos, zPos, new TGeoRotation(name, xRot, yRot, zRot));
111
112 TEveGeoShape* rectPrism = new TEveGeoShape(name);
113 TGeoShape* box = new TGeoBBox(name, dX / 2, dY / 2, dZ / 2);
114 box->SetUniqueID(uid_++);
115 rectPrism->SetShape(box);
116 rectPrism->SetFillColor(color);
117 rectPrism->SetMainTransparency(transparency);
118 rectPrism->SetTransMatrix(*locAndOrien);
119
120 return rectPrism;
121 }
122
134 TEveGeoShape* drawRectPrism(BoundingBox boundingbox, Double_t xRot,
135 Double_t yRot, Double_t zRot, Int_t color,
136 Int_t transparency, TString name) {
137 std::vector<double> center(3, 0);
138 std::vector<double> widths(3, 0);
139
140 for (unsigned int iC = 0; iC < 3; iC++) {
141 center[iC] = (boundingbox[iC].second + boundingbox[iC].first) / 2.0;
142 widths[iC] = abs(boundingbox[iC].second - boundingbox[iC].first);
143 }
144
145 return drawRectPrism(center[0], center[1], center[2], widths[0], widths[1],
146 widths[2], xRot, yRot, zRot, color, transparency,
147 name);
148 }
149
150 private:
151 UInt_t uid_ = 0; //* Unique ID counter for the drawings
152};
153
154} // namespace eventdisplay
155
156#endif
Header file for class DetectorGeometry.
std::vector< std::pair< double, double > > BoundingBox
@type BoundingBox
Helper class for drawing common shapes.
TEveGeoShape * drawRectPrism(Double_t xPos, Double_t yPos, Double_t zPos, Double_t dX, Double_t dY, Double_t dZ, Double_t xRot, Double_t yRot, Double_t zRot, Int_t color, Int_t transparency, TString name)
Draw a rectangular prism.
TEveGeoShape * drawHexPrism(HexPrism prism, Double_t xRot, Double_t yRot, Double_t zRot, Int_t color, Int_t transparency, TString name)
Draw a hexagonal prism.
TEveGeoShape * drawHexPrism(Double_t xPos, Double_t yPos, Double_t zPos, Double_t xRot, Double_t yRot, Double_t zRot, Double_t h, Double_t r, Int_t color, Int_t transparency, TString name)
Draw a hexagonal prism.
static EveShapeDrawer & getInstance()
Get Instance of Drawer.
TEveGeoShape * drawRectPrism(BoundingBox boundingbox, Double_t xRot, Double_t yRot, Double_t zRot, Int_t color, Int_t transparency, TString name)
Draw a rectangular prism.
Stores the necessary geometry details for a hexagonal prism.