CMS 3D CMS Logo

Functions
geometryDiffVisualization Namespace Reference

Functions

def csc_colors (endcap, station, ring, chamber)
 
def draw_disk (geom1, geom2, endcap, station, filename, length_factor=1., angle_factor=100., colors=csc_colors, template_dir='./')
 
def draw_station (geom1, geom2, station, filename, length_factor=100., angle_factor=100., colors=dt_colors, template_dir='./')
 
def draw_wheel (geom1, geom2, wheel, filename, length_factor=100., angle_factor=100., colors=dt_colors, template_dir='./')
 
def dt_colors (wheel, station, sector)
 

Function Documentation

def geometryDiffVisualization.csc_colors (   endcap,
  station,
  ring,
  chamber 
)

Definition at line 10 of file geometryDiffVisualization.py.

References svgfig.rgb().

10 def csc_colors(endcap, station, ring, chamber):
11  return rgb(0.1, 0.9, 0.)
12 
def csc_colors(endcap, station, ring, chamber)
def rgb(r, g, b, maximum=1.)
Definition: svgfig.py:39
def geometryDiffVisualization.draw_disk (   geom1,
  geom2,
  endcap,
  station,
  filename,
  length_factor = 1.,
  angle_factor = 100.,
  colors = csc_colors,
  template_dir = './' 
)

Definition at line 115 of file geometryDiffVisualization.py.

References funct.cos(), createfilelist.int, list(), svgfig.pathtoPath(), and funct.sin().

115 def draw_disk(geom1, geom2, endcap, station, filename, length_factor=1., angle_factor=100., colors=csc_colors, template_dir='./'):
116  if station == 1:
117  disk_template = load_svg(template_dir + "disk1_template.svg")
118  if station in (2, 3):
119  disk_template = load_svg(template_dir + "disk23_template.svg")
120  if endcap == 1 and station == 4:
121  disk_template = load_svg(template_dir + "diskp4_template.svg")
122  if endcap == 2 and station == 4:
123  disk_template = load_svg(template_dir + "diskm4_template.svg")
124 
125  scale_factor = 0.233
126 
127  new_boxes = SVG("g")
128 
129  for treeindex, svgitem in disk_template:
130  if isinstance(svgitem, SVG) and "id" in svgitem.attr and svgitem["id"] == "fakecenter":
131  fakecenter = pathtoPath(pathtoPath(svgitem).SVG())
132  sumx = 0.
133  sumy = 0.
134  sum1 = 0.
135  for i, di in enumerate(fakecenter.d):
136  if di[0] in ("M", "L"):
137  sumx += di[1]
138  sumy += di[2]
139  sum1 += 1.
140  originx = sumx/sum1
141  originy = sumy/sum1
142 
143  for treeindex, svgitem in disk_template:
144  if isinstance(svgitem, SVG) and "id" in svgitem.attr and svgitem["id"][:3] == "ME_":
145  m = re.match("ME_([0-9]+)_([0-9]+)", svgitem["id"])
146  if m is None: raise Exception
147 
148  ring, chamber = int(m.group(1)), int(m.group(2))
149  xdiff = scale_factor * length_factor * (geom1.csc[endcap, station, ring, chamber].x - geom2.csc[endcap, station, ring, chamber].x) * signConventions["CSC", endcap, station, ring, chamber][0]
150  ydiff = -scale_factor * length_factor * (geom1.csc[endcap, station, ring, chamber].y - geom2.csc[endcap, station, ring, chamber].y) * signConventions["CSC", endcap, station, ring, chamber][1]
151  phizdiff = -angle_factor * (geom1.csc[endcap, station, ring, chamber].phiz - geom2.csc[endcap, station, ring, chamber].phiz) * signConventions["CSC", endcap, station, ring, chamber][2]
152 
153  svgitem["style"] = "fill:#e1e1e1;fill-opacity:1;stroke:#000000;stroke-width:1.0;stroke-dasharray:1, 1;stroke-dashoffset:0"
154 
155  newBox = pathtoPath(svgitem)
156 
157  # Inkscape outputs wrong SVG: paths are filled with movetos, rather than linetos; this fixes that
158  first = True
159  for i, di in enumerate(newBox.d):
160  if not first and di[0] == "m":
161  di = list(di)
162  di[0] = "l"
163  newBox.d[i] = tuple(di)
164  first = False
165 
166  # convert to absolute coordinates
167  newBox = pathtoPath(newBox.SVG())
168 
169  # find the center of the object
170  sumx = 0.
171  sumy = 0.
172  sum1 = 0.
173  for i, di in enumerate(newBox.d):
174  if di[0] == "L":
175  sumx += di[1]
176  sumy += di[2]
177  sum1 += 1.
178  centerx = sumx/sum1
179  centery = sumy/sum1
180 
181  phipos = atan2(centery - originy, centerx - originx) - pi/2.
182  for i, di in enumerate(newBox.d):
183  if di[0] in ("M", "L"):
184  di = list(di)
185  di[1] += cos(phipos)*xdiff - sin(phipos)*ydiff
186  di[2] += sin(phipos)*xdiff + cos(phipos)*ydiff
187  newBox.d[i] = tuple(di)
188 
189  centerx += cos(phipos)*xdiff - sin(phipos)*ydiff
190  centery += sin(phipos)*xdiff + cos(phipos)*ydiff
191 
192  for i, di in enumerate(newBox.d):
193  if di[0] in ("M", "L"):
194  di = list(di)
195  dispx = cos(phizdiff) * (di[1] - centerx) - sin(phizdiff) * (di[2] - centery)
196  dispy = sin(phizdiff) * (di[1] - centerx) + cos(phizdiff) * (di[2] - centery)
197  di[1] = dispx + centerx
198  di[2] = dispy + centery
199  newBox.d[i] = tuple(di)
200 
201  newBox = newBox.SVG()
202  newBox["style"] = "fill:%s;fill-opacity:0.5;stroke:#000000;stroke-width:1.0;stroke-opacity:1;stroke-dasharray:none" % colors(endcap, station, ring, chamber)
203  newBox["id"] = newBox["id"] + "_moved"
204 
205  new_boxes.append(newBox)
206 
207  for treeindex, svgitem in disk_template:
208  if isinstance(svgitem, SVG) and svgitem.t == "g" and "id" in svgitem.attr and svgitem["id"] == "chambers":
209  svgitem.append(new_boxes)
210 
211  elif isinstance(svgitem, SVG) and "id" in svgitem.attr and svgitem["id"] == "diskx":
212  if endcap == 1: svgitem[0] = "Disk %+d" % station
213  else: svgitem[0] = "Disk %+d" % (-station)
214  svgitem[0] += " (length x%g, angle x%g)" % (length_factor, angle_factor)
215 
216  disk_template.save(filename)
217 
def draw_disk(geom1, geom2, endcap, station, filename, length_factor=1., angle_factor=100., colors=csc_colors, template_dir='./')
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
def pathtoPath(svg)
Definition: svgfig.py:1006
Definition: colors.py:1
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
def geometryDiffVisualization.draw_station (   geom1,
  geom2,
  station,
  filename,
  length_factor = 100.,
  angle_factor = 100.,
  colors = dt_colors,
  template_dir = './' 
)

Definition at line 13 of file geometryDiffVisualization.py.

References objects.autophobj.float, and createfilelist.int.

13 def draw_station(geom1, geom2, station, filename, length_factor=100., angle_factor=100., colors=dt_colors, template_dir='./'):
14  if station == 4:
15  station_template = load_svg(template_dir + "station4_template.svg")
16  else:
17  station_template = load_svg(template_dir + "station_template.svg")
18 
19  if station == 1: x_scale_factor = 1/6.
20  if station == 2: x_scale_factor = 1/7.
21  if station == 3: x_scale_factor = 1/8.5
22  if station == 4: x_scale_factor = 1/10.
23  y_scale_factor = 1/7.
24 
25  # make a new group to put the moved chambers into
26  new_boxes = SVG("g")
27 
28  # loop over the SVG tree, looking for our chambers (by id)
29  for treeindex, svgitem in station_template:
30  if isinstance(svgitem, SVG) and "id" in svgitem.attr and svgitem["id"][:3] == "MB_":
31  m = re.match("MB_([0-9mpz]+)_([0-9]+)", svgitem["id"])
32  if m is None: raise Exception
33 
34  wheel = m.group(1)
35  if wheel == "m2": wheel = -2
36  elif wheel == "m1": wheel = -1
37  elif wheel == "z": wheel = 0
38  elif wheel == "p1": wheel = 1
39  elif wheel == "p2": wheel = 2
40  sector = int(m.group(2))
41 
42  xdiff = x_scale_factor * length_factor * (geom1.dt[wheel, station, sector].x - geom2.dt[wheel, station, sector].x) * signConventions["DT", wheel, station, sector][0]
43  ydiff = -y_scale_factor * length_factor * (geom1.dt[wheel, station, sector].y - geom2.dt[wheel, station, sector].y) * signConventions["DT", wheel, station, sector][1]
44  phizdiff = -angle_factor * (geom1.dt[wheel, station, sector].phiz - geom2.dt[wheel, station, sector].phiz) * signConventions["DT", wheel, station, sector][2]
45 
46  sx = float(svgitem["x"]) + float(svgitem["width"])/2.
47  sy = float(svgitem["y"]) + float(svgitem["height"])/2.
48 
49  svgitem["transform"] = "translate(%g,%g)" % (sx, sy)
50  svgitem["x"] = -float(svgitem["width"])/2.
51  svgitem["y"] = -float(svgitem["height"])/2.
52 
53  svgitem["style"] = "fill:#e1e1e1;fill-opacity:1;stroke:#000000;stroke-width:1.0;stroke-dasharray:1, 1;stroke-dashoffset:0"
54 
55  newBox = svgitem.clone()
56  newBox["transform"] = "translate(%g,%g) rotate(%g) " % (sx + xdiff, sy + ydiff, phizdiff * 180./pi)
57  newBox["style"] = "fill:%s;fill-opacity:0.5;stroke:#000000;stroke-width:1.0;stroke-opacity:1;stroke-dasharray:none" % colors(wheel, station, sector)
58 
59  new_boxes.append(newBox)
60 
61  for treeindex, svgitem in station_template:
62  if isinstance(svgitem, SVG) and svgitem.t == "g" and "id" in svgitem.attr and svgitem["id"] == "chambers":
63  svgitem.append(new_boxes)
64 
65  elif isinstance(svgitem, SVG) and "id" in svgitem.attr and svgitem["id"] == "stationx":
66  svgitem[0] = "Station %d" % station
67  svgitem[0] += " (length x%g, angle x%g)" % (length_factor, angle_factor)
68 
69  station_template.save(filename)
70 
Definition: colors.py:1
def draw_station(geom1, geom2, station, filename, length_factor=100., angle_factor=100., colors=dt_colors, template_dir='./')
def geometryDiffVisualization.draw_wheel (   geom1,
  geom2,
  wheel,
  filename,
  length_factor = 100.,
  angle_factor = 100.,
  colors = dt_colors,
  template_dir = './' 
)

Definition at line 71 of file geometryDiffVisualization.py.

References funct.cos(), objects.autophobj.float, createfilelist.int, and funct.sin().

71 def draw_wheel(geom1, geom2, wheel, filename, length_factor=100., angle_factor=100., colors=dt_colors, template_dir='./'):
72  wheel_template = load_svg(template_dir + "wheel_template.svg")
73 
74  # make a new group to put the moved chambers into
75  new_boxes = SVG("g")
76 
77  # loop over the SVG tree, looking for our chambers (by id)
78  for treeindex, svgitem in wheel_template:
79  if isinstance(svgitem, SVG) and "id" in svgitem.attr and svgitem["id"][:3] == "MB_":
80  m = re.match("MB_([0-9]+)_([0-9]+)", svgitem["id"])
81  if m is None: raise Exception
82 
83  station, sector = int(m.group(1)), int(m.group(2))
84  xdiff = -length_factor * (geom1.dt[wheel, station, sector].x - geom2.dt[wheel, station, sector].x) * signConventions["DT", wheel, station, sector][0]
85  zdiff = length_factor * (geom1.dt[wheel, station, sector].z - geom2.dt[wheel, station, sector].z) * signConventions["DT", wheel, station, sector][2]
86  phiydiff = -angle_factor * (geom1.dt[wheel, station, sector].phiy - geom2.dt[wheel, station, sector].phiy) * signConventions["DT", wheel, station, sector][1]
87 
88  m = re.search("translate\(([0-9\.\-\+eE]+),\s([0-9\.\-\+eE]+)\)\srotate\(([0-9\.\-\+eE]+)\)",svgitem["transform"])
89 
90  tx = float(m.group(1))
91  ty = float(m.group(2))
92  tr = float(m.group(3))
93 
94  newBox = svgitem.clone()
95 
96  svgitem["style"] = "fill:#e1e1e1;fill-opacity:1;stroke:#000000;stroke-width:5.0;stroke-dasharray:1, 1;stroke-dashoffset:0"
97  newBox["style"] = "fill:%s;fill-opacity:0.5;stroke:#000000;stroke-width:5.0;stroke-opacity:1;stroke-dasharray:none" % colors(wheel, station, sector)
98  newBox["id"] = newBox["id"] + "_moved"
99 
100  newBox["transform"] = "translate(%g,%g) rotate(%g)" % (tx - xdiff*cos(tr*pi/180.) + zdiff*sin(tr*pi/180.), ty - xdiff*sin(tr*pi/180.) - zdiff*cos(tr*pi/180.), tr - phiydiff*180./pi)
101 
102  new_boxes.append(newBox)
103 
104  for treeindex, svgitem in wheel_template:
105  if isinstance(svgitem, SVG) and svgitem.t == "g" and "id" in svgitem.attr and svgitem["id"] == "chambers":
106  svgitem.append(new_boxes)
107 
108  elif isinstance(svgitem, SVG) and "id" in svgitem.attr and svgitem["id"] == "wheelx":
109  if wheel == 0: svgitem[0] = "Wheel 0"
110  else: svgitem[0] = "Wheel %+d" % wheel
111  svgitem[0] += " (length x%g, angle x%g)" % (length_factor, angle_factor)
112 
113  wheel_template.save(filename)
114 
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
def draw_wheel(geom1, geom2, wheel, filename, length_factor=100., angle_factor=100., colors=dt_colors, template_dir='./')
Definition: colors.py:1
def geometryDiffVisualization.dt_colors (   wheel,
  station,
  sector 
)

Definition at line 7 of file geometryDiffVisualization.py.

References svgfig.rgb().

7 def dt_colors(wheel, station, sector):
8  return rgb(0.1, 0.9, 0.)
9 
def dt_colors(wheel, station, sector)
def rgb(r, g, b, maximum=1.)
Definition: svgfig.py:39