268 Generate a WCT channel map file giving numpy arrays. 270 schema = output_file[output_file.rfind(
".")+1:]
271 click.echo(
'writing schema: "%s"' % schema)
273 if detector ==
"apa":
276 click.echo(
'generating Numpy file "%s"' % output_file)
277 numpy.savez(output_file, **dict(
278 chip_channel_spot = apa.chip_channel_spot,
279 chip_channel_layer = apa.chip_channel_layer,
280 connector_slot_board = numpy.asarray(range(10),dtype=numpy.int32).reshape(2,5)+1,
281 face_board_femb = numpy.asarray(range(20),dtype=numpy.int32).reshape(2,10)+1))
284 click.echo(
'generating LaTeX fragment file "%s"' % output_file)
285 with
open(output_file,
"w")
as fp:
286 color = dict(u=
"red", v=
"blue", w=
"black")
288 mat = numpy.asarray([
r"\textcolor{%s}{%s%02d}" % (color[p], p, w) \
289 for p,w
in apa.chip_channel_layer_spot_matrix.reshape(8*16,2)])\
292 cells = [
"ch%02d" % chn]
295 lines.append(
" & " .join(cells))
297 body = end.join(lines)
298 top =
"&".join([
"ASIC:"] + [
str(n+1)
for n
in range(8)]) +
r"\\" 300 tabular = [
r"\begin{center}",
r"\begin{tabular}{%s}"%form,
r"\hline", top,
301 r"\hline", body+
r"\\",
r"\hline",
r"\end{tabular}",
r"\end{center}",
""]
302 fp.write(
"\n".join(tabular))
304 layers = dict(u=[
""]*40, v=[
""]*40, w=[
""]*48)
305 for chipn, chip
in enumerate(apa.chip_channel_layer_spot_matrix):
306 for chn, (plane,wire)
in enumerate(chip):
307 layers[plane][wire-1] = (chipn,chn)
310 for letter, layer
in sorted(layers.items()):
313 form =
"|" +
"C{3.5mm}|"*nhalf
317 r"\begin{tabular}{%s}"%form,
321 r"\multicolumn{%d}{c}{%s layer, first half: conductor / chip / chan} \\" % (nhalf, letter.upper()),
323 wires =
"&".join([
"%2s"%ww
for ww
in range(1,nhalf+1)]) +
r"\\";
324 chips =
"&".join([
"%2s"%(cc[0]+1,)
for cc
in layer[:nhalf]]) +
r"\\";
325 chans =
"&".join([
"%2s"%cc[1]
for cc
in layer[:nhalf]]) +
r"\\";
326 lines += [wires,
r"\hline", chips, chans];
329 r"\multicolumn{%d}{c}{%s layer, second half: conductor / chip / chan} \\" % (nhalf, letter.upper()),
331 wires =
"&".join([
"%2s"%ww
for ww
in range(nhalf+1,nchans+1)]) +
r"\\";
332 chips =
"&".join([
"%2s"%(cc[0]+1,)
for cc
in layer[nhalf:]]) +
r"\\";
333 chans =
"&".join([
"%2s"%cc[1]
for cc
in layer[nhalf:]]) +
r"\\";
334 lines += [wires,
r"\hline", chips, chans];
336 lines += [
r"\hline",
r"\end{tabular}"]
337 lines += [
r"\end{center}"]
338 fp.write(
"\n".join(lines))
344 click.echo(
'Unknown detector type: "%s"' % detector)
348 @cli.command(
"gravio")
349 @click.argument(
"dotfile")
int open(const char *, int)
Opens a file descriptor.
def make_map(ctx, detector, output_file)
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.