CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
geometryDiffVisualization Namespace Reference

Functions

def csc_colors
 
def draw_disk
 
def draw_station
 
def draw_wheel
 
def dt_colors
 

Function Documentation

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

Definition at line 10 of file geometryDiffVisualization.py.

References svgfig.rgb().

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

Definition at line 113 of file geometryDiffVisualization.py.

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

114 def draw_disk(geom1, geom2, endcap, station, filename, length_factor=1., angle_factor=100., colors=csc_colors):
115  if station == 1: disk_template = load_svg("disk1_template.svg")
116  if station in (2, 3): disk_template = load_svg("disk23_template.svg")
117  if endcap == 1 and station == 4: disk_template = load_svg("diskp4_template.svg")
118  if endcap == 2 and station == 4: disk_template = load_svg("diskm4_template.svg")
119 
120  scale_factor = 0.233
121 
122  new_boxes = SVG("g")
123 
124  for treeindex, svgitem in disk_template:
125  if isinstance(svgitem, SVG) and "id" in svgitem.attr and svgitem["id"] == "fakecenter":
126  fakecenter = pathtoPath(pathtoPath(svgitem).SVG())
127  sumx = 0.
128  sumy = 0.
129  sum1 = 0.
130  for i, di in enumerate(fakecenter.d):
131  if di[0] in ("M", "L"):
132  sumx += di[1]
133  sumy += di[2]
134  sum1 += 1.
135  originx = sumx/sum1
136  originy = sumy/sum1
137 
138  for treeindex, svgitem in disk_template:
139  if isinstance(svgitem, SVG) and "id" in svgitem.attr and svgitem["id"][:3] == "ME_":
140  m = re.match("ME_([0-9]+)_([0-9]+)", svgitem["id"])
141  if m is None: raise Exception
142 
143  ring, chamber = int(m.group(1)), int(m.group(2))
144  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]
145  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]
146  phizdiff = -angle_factor * (geom1.csc[endcap, station, ring, chamber].phiz - geom2.csc[endcap, station, ring, chamber].phiz) * signConventions["CSC", endcap, station, ring, chamber][2]
147 
148  svgitem["style"] = "fill:#e1e1e1;fill-opacity:1;stroke:#000000;stroke-width:1.0;stroke-dasharray:1, 1;stroke-dashoffset:0"
149 
150  newBox = pathtoPath(svgitem)
151 
152  # Inkscape outputs wrong SVG: paths are filled with movetos, rather than linetos; this fixes that
153  first = True
154  for i, di in enumerate(newBox.d):
155  if not first and di[0] == "m":
156  di = list(di)
157  di[0] = "l"
158  newBox.d[i] = tuple(di)
159  first = False
160 
161  # convert to absolute coordinates
162  newBox = pathtoPath(newBox.SVG())
163 
164  # find the center of the object
165  sumx = 0.
166  sumy = 0.
167  sum1 = 0.
168  for i, di in enumerate(newBox.d):
169  if di[0] == "L":
170  sumx += di[1]
171  sumy += di[2]
172  sum1 += 1.
173  centerx = sumx/sum1
174  centery = sumy/sum1
175 
176  phipos = atan2(centery - originy, centerx - originx) - pi/2.
177  for i, di in enumerate(newBox.d):
178  if di[0] in ("M", "L"):
179  di = list(di)
180  di[1] += cos(phipos)*xdiff - sin(phipos)*ydiff
181  di[2] += sin(phipos)*xdiff + cos(phipos)*ydiff
182  newBox.d[i] = tuple(di)
183 
184  centerx += cos(phipos)*xdiff - sin(phipos)*ydiff
185  centery += sin(phipos)*xdiff + cos(phipos)*ydiff
186 
187  for i, di in enumerate(newBox.d):
188  if di[0] in ("M", "L"):
189  di = list(di)
190  dispx = cos(phizdiff) * (di[1] - centerx) - sin(phizdiff) * (di[2] - centery)
191  dispy = sin(phizdiff) * (di[1] - centerx) + cos(phizdiff) * (di[2] - centery)
192  di[1] = dispx + centerx
193  di[2] = dispy + centery
194  newBox.d[i] = tuple(di)
195 
196  newBox = newBox.SVG()
197  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)
198  newBox["id"] = newBox["id"] + "_moved"
199 
200  new_boxes.append(newBox)
201 
202  for treeindex, svgitem in disk_template:
203  if isinstance(svgitem, SVG) and svgitem.t == "g" and "id" in svgitem.attr and svgitem["id"] == "chambers":
204  svgitem.append(new_boxes)
205 
206  elif isinstance(svgitem, SVG) and "id" in svgitem.attr and svgitem["id"] == "diskx":
207  if endcap == 1: svgitem[0] = "Disk %+d" % station
208  else: svgitem[0] = "Disk %+d" % (-station)
209  svgitem[0] += " (length x%g, angle x%g)" % (length_factor, angle_factor)
210 
211  disk_template.save(filename)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::vector< Color_t > colors
Definition: eve_filter.cc:26
def pathtoPath
Definition: svgfig.py:1006
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
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 
)

Definition at line 13 of file geometryDiffVisualization.py.

References colors.

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

Definition at line 69 of file geometryDiffVisualization.py.

References colors, funct.cos(), and funct.sin().

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

Definition at line 7 of file geometryDiffVisualization.py.

References svgfig.rgb().

7 
8 def dt_colors(wheel, station, sector):
9  return rgb(0.1, 0.9, 0.)
def rgb
Definition: svgfig.py:39