GeometryDrawer.cxx
Go to the documentation of this file.
1 /// \file GeometryDrawer.cxx
2 /// \brief Class to aid in the rendering of Geometry objects
3 /// \author messier@indiana.edu
4 /// \version $Id: GeometryDrawer.cxx,v 1.2 2010/11/11 18:11:22 p-novaart Exp $
5 #include "TPolyLine.h"
6 #include "TPolyLine3D.h"
7 #include "TLine.h"
8 #include "TBox.h"
9 #include "TText.h"
10 #include "TMath.h"
11 
12 #include "Geometry/GeometryGAr.h"
13 #include "nuevdb/EventDisplayBase/View2D.h"
14 #include "nuevdb/EventDisplayBase/View3D.h"
16 
18 
19 namespace gar {
20  namespace evd{
21 
22  //......................................................................
24  {
25  }
26 
27  //......................................................................
29  {
30  }
31 
32  //......................................................................
33  void GeometryDrawer::DetOutline3D(evdb::View3D* view)
34  {
36 
37  // these are relative to the center of the TPC. We will add the detector offsets
38  // on each point
39 
40  double xlo = -geo->TPCLength()/2;
41  double xhi = geo->TPCLength()/2;
42  double ylo = -geo->TPCRadius();
43  double yhi = geo->TPCRadius();
44  //double zlo = -geo->TPCRadius();
45  double zhi = geo->TPCRadius();
46  double r=yhi;
47 
48  double fracinner = 788.0/2580.;
49 
50  double ang = TMath::Pi()*2.0/18.0;
51 
52  int c = kGray;
53  int s = 1;
54  int w = 1;
55  TPolyLine3D& spos = view->AddPolyLine3D(19, c, w, s);
56  TPolyLine3D& sposi = view->AddPolyLine3D(19, c, w, s);
57  for (int i=0;i<19;++i)
58  {
59  // nb. coordinates are so Y is up, but ROOT thinks Z is up, so report (z,x,y)
60  spos.SetPoint(i,r*TMath::Cos(i*ang)+geo->TPCZCent(),xhi+geo->TPCXCent(),r*TMath::Sin(i*ang)+geo->TPCYCent());
61  sposi.SetPoint(i,fracinner*r*TMath::Cos(i*ang)+geo->TPCZCent(),xhi+geo->TPCXCent(),fracinner*r*TMath::Sin(i*ang)+geo->TPCYCent());
62  }
63  TPolyLine3D& sneg = view->AddPolyLine3D(19, c, w, s);
64  TPolyLine3D& snegi = view->AddPolyLine3D(19, c, w, s);
65  for (int i=0;i<19;++i)
66  {
67  // nb. coordinates are so Y is up, but ROOT thinks Z is up, so report (z,x,y)
68  sneg.SetPoint(i,r*TMath::Cos(i*ang)+geo->TPCZCent(),xlo+geo->TPCXCent(),r*TMath::Sin(i*ang)+geo->TPCYCent());
69  snegi.SetPoint(i,fracinner*r*TMath::Cos(i*ang)+geo->TPCZCent(),xlo+geo->TPCXCent(),fracinner*r*TMath::Sin(i*ang)+geo->TPCYCent());
70  }
71 
72  c = kGray+2;
73  s = 1;
74  w = 1;
75  for (int i=0;i<18;++i)
76  {
77  TPolyLine3D& gridt = view->AddPolyLine3D(4, c, w, s);
78  // nb. coordinates are so Y is up, but ROOT thinks Z is up, so report (z,x,y)
79  gridt.SetPoint(0,fracinner*r*TMath::Cos(i*ang)+geo->TPCZCent(),xlo+geo->TPCXCent(),fracinner*r*TMath::Sin(i*ang)+geo->TPCYCent());
80  gridt.SetPoint(1,r*TMath::Cos(i*ang)+geo->TPCZCent(),xlo+geo->TPCXCent(),r*TMath::Sin(i*ang)+geo->TPCYCent());
81  gridt.SetPoint(2,r*TMath::Cos(i*ang)+geo->TPCZCent(),xhi+geo->TPCXCent(),r*TMath::Sin(i*ang)+geo->TPCYCent());
82  gridt.SetPoint(3,fracinner*r*TMath::Cos(i*ang)+geo->TPCZCent(),xhi+geo->TPCXCent(),fracinner*r*TMath::Sin(i*ang)+geo->TPCYCent());
83  }
84 
85  // Indicate coordinate system
86  double x0 = -0.20; // Center location of the key
87  double y0 = 1.10*ylo; // Center location of the key
88  double z0 = -0.10*zhi; // Center location of the key
89  double sz = 0.20*zhi; // Scale size of the key in z direction
90 
91  c = kCyan;
92 
93  TPolyLine3D& xaxis = view->AddPolyLine3D(2, c, w, s);
94  TPolyLine3D& yaxis = view->AddPolyLine3D(2, c, w, s);
95  TPolyLine3D& zaxis = view->AddPolyLine3D(2, c, s, w);
96  // nb. coordinates are so Y is up, but ROOT thinks Z is up, so report (z,x,y)
97  xaxis.SetPoint(0, z0+geo->TPCZCent(), x0+geo->TPCXCent(), y0+geo->TPCYCent());
98  xaxis.SetPoint(1, z0+geo->TPCZCent(), sz+x0+geo->TPCXCent(), y0+geo->TPCYCent());
99 
100  yaxis.SetPoint(0, z0+geo->TPCZCent(), x0+geo->TPCXCent(), y0+geo->TPCYCent());
101  yaxis.SetPoint(1, z0+geo->TPCZCent(), x0+geo->TPCXCent(), y0+sz+geo->TPCYCent());
102 
103  zaxis.SetPoint(0, z0+geo->TPCZCent(), x0+geo->TPCXCent(), y0+geo->TPCYCent());
104  zaxis.SetPoint(1, z0+sz+geo->TPCZCent(), x0+geo->TPCXCent(), y0+geo->TPCYCent());
105 
106  TPolyLine3D& xpoint = view->AddPolyLine3D(3, c, w, s);
107  TPolyLine3D& ypoint = view->AddPolyLine3D(3, c, w, s);
108  TPolyLine3D& zpoint = view->AddPolyLine3D(3, c, w, s);
109 
110  xpoint.SetPoint(0, z0-0.05*sz+geo->TPCZCent(), 0.95*sz+x0+geo->TPCXCent(), y0+geo->TPCYCent());
111  xpoint.SetPoint(1, z0+geo->TPCZCent() , 1.00*sz+x0+geo->TPCXCent(), y0+geo->TPCYCent());
112  xpoint.SetPoint(2, z0+0.05*sz+geo->TPCZCent(), 0.95*sz+x0+geo->TPCXCent(), y0+geo->TPCYCent());
113 
114  ypoint.SetPoint(0, z0-0.05*sz+geo->TPCZCent(), x0+geo->TPCXCent(), 0.95*sz+y0+geo->TPCYCent());
115  ypoint.SetPoint(1, z0+geo->TPCZCent() , x0+geo->TPCXCent(), 1.00*sz+y0+geo->TPCYCent());
116  ypoint.SetPoint(2, z0+0.05*sz+geo->TPCZCent(), x0+geo->TPCXCent(), 0.95*sz+y0+geo->TPCYCent());
117 
118  zpoint.SetPoint(0, 0.95*sz+z0+geo->TPCZCent(), x0-0.05*sz+geo->TPCXCent(), y0+geo->TPCYCent());
119  zpoint.SetPoint(1, 1.00*sz+z0+geo->TPCZCent(), x0+0.00*sz+geo->TPCXCent(), y0+geo->TPCYCent());
120  zpoint.SetPoint(2, 0.95*sz+z0+geo->TPCZCent(), x0+0.05*sz+geo->TPCXCent(), y0+geo->TPCYCent());
121 
122  TPolyLine3D& zleg = view->AddPolyLine3D(4, c, w, s);
123  zleg.SetPoint(0, z0+1.05*sz+geo->TPCZCent(), x0-0.05*sz+geo->TPCXCent(), y0+0.05*sz+geo->TPCYCent());
124  zleg.SetPoint(1, z0+1.05*sz+geo->TPCZCent(), x0+0.05*sz+geo->TPCXCent(), y0+0.05*sz+geo->TPCYCent());
125  zleg.SetPoint(2, z0+1.05*sz+geo->TPCZCent(), x0-0.05*sz+geo->TPCXCent(), y0-0.05*sz+geo->TPCYCent());
126  zleg.SetPoint(3, z0+1.05*sz+geo->TPCZCent(), x0+0.05*sz+geo->TPCXCent(), y0-0.05*sz+geo->TPCYCent());
127 
128  TPolyLine3D& yleg = view->AddPolyLine3D(5, c, w, s);
129  yleg.SetPoint(0, z0+geo->TPCZCent(), x0-0.05*sz+geo->TPCXCent(), y0+1.15*sz+geo->TPCYCent());
130  yleg.SetPoint(1, z0+geo->TPCZCent(), x0+0.00*sz+geo->TPCXCent(), y0+1.10*sz+geo->TPCYCent());
131  yleg.SetPoint(2, z0+geo->TPCZCent(), x0+0.00*sz+geo->TPCXCent(), y0+1.05*sz+geo->TPCYCent());
132  yleg.SetPoint(3, z0+geo->TPCZCent(), x0+0.00*sz+geo->TPCXCent(), y0+1.10*sz+geo->TPCYCent());
133  yleg.SetPoint(4, z0+geo->TPCZCent(), x0+0.05*sz+geo->TPCXCent(), y0+1.15*sz+geo->TPCYCent());
134 
135  TPolyLine3D& xleg = view->AddPolyLine3D(7, c, w, s);
136  xleg.SetPoint(0, z0-0.05*sz+geo->TPCZCent(), x0+1.05*sz+geo->TPCXCent(), y0+0.05*sz+geo->TPCYCent());
137  xleg.SetPoint(1, z0-0.00*sz+geo->TPCZCent(), x0+1.05*sz+geo->TPCXCent(), y0+0.00*sz+geo->TPCYCent());
138  xleg.SetPoint(2, z0+0.05*sz+geo->TPCZCent(), x0+1.05*sz+geo->TPCXCent(), y0+0.05*sz+geo->TPCYCent());
139  xleg.SetPoint(3, z0-0.00*sz+geo->TPCZCent(), x0+1.05*sz+geo->TPCXCent(), y0+0.00*sz+geo->TPCYCent());
140  xleg.SetPoint(4, z0-0.05*sz+geo->TPCZCent(), x0+1.05*sz+geo->TPCXCent(), y0-0.05*sz+geo->TPCYCent());
141  xleg.SetPoint(5, z0-0.00*sz+geo->TPCZCent(), x0+1.05*sz+geo->TPCXCent(), y0+0.00*sz+geo->TPCYCent());
142  xleg.SetPoint(6, z0+0.05*sz+geo->TPCZCent(), x0+1.05*sz+geo->TPCXCent(), y0-0.05*sz+geo->TPCYCent());
143 
144  }
145 
146  }
147 }// namespace
148 ////////////////////////////////////////////////////////////////////////
LArSoft includes.
Definition: InfoTransfer.h:33
void DetOutline3D(evdb::View3D *view)
Class to aid in the rendering of Geometry objects.
General GArSoft Utilities.
LArSoft geometry interface.
Definition: ChannelGeo.h:16
art framework interface to geometry description
static QCString * s
Definition: config.cpp:1042