Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 101-north-ecal-add-modules-around-beampipe
  • 104-add-realistic-cooling-for-gridpix
  • 116-fix-the-detector-views
  • 12-job-failed-106994
  • 126-improved-gem-rings
  • 131-update-tof-for-canyonlands
  • 134-make-new-3d-views-of-ff-region-and-detectors
  • 144-irt-geometry
  • 144-test-small-sensor-overlap
  • 147-fix-dirc-overlaps-and-make-it-great-again
  • 148-hcal-geometry-development
  • 148-hcal-geometry-development-wdconinc-suggestion
  • 149-dump-geometry-ci-job-should-also-produce-ff-geometry-separately
  • 21-electron-endcap-ecal-glass-outer-ring-implementation-needed-2
  • 23-add-barrel-tof
  • 24-tweak-zdc-longitudinal-size
  • 37-place-sifi-fibers-in-the-assembly-in-ecal-barrel
  • 38-mm-tracker-implementation
  • 40-quick-viz
  • 42-grid-pix-pid-detector
  • 53-acts-geometry-bug-outer-tracker-barrel
  • 54-dirc-better-parametrization
  • 56-astropix-sampling-fraction-test-2
  • 59-detailed-forward-gem-trd
  • 59-detailed-forward-gem-trd-2
  • 7-central-tracker-endcap-detail
  • 81-add-barrel-ecal-projection-at-positive-eta
  • 9-detector-plugin-for-w-scfi-calorimeter-layers
  • 98-update-barrel-and-endcap-tof
  • AllieWeary-master-patch-33350
  • WorkingGemTrd_MLmodel_andAnalysis
  • acadia
  • acts_surface_binning
  • acts_vertex_barrel
  • add_segmentation
  • adjust-barrel-emcalo-geometry
  • b0_acts
  • backward_ecal_cleanup
  • barrel-tracker-simplified
  • baseline-dimensions-rich-thickness
  • calibrations-ecal-hcal
  • calo-digitization-json
  • canyonlands
  • canyonlands-acts-dd4hep-plugin
  • cherry-pick-85aaf29d
  • cherry-pick-ee231e50
  • deathvalley
  • deathvalley-1.5T
  • deathvalley-acts-dd4hep-plugin
  • debug-vis
  • default_visibilities
  • documentation_tag
  • drich-optics-tests
  • drich-space-update
  • drich-two-mirrors
  • ecal-hcal-endcap-bore-and-length
  • hcal
  • hcal-klm
  • irt-erich
  • irt-init-v01
  • lengthen_ecalbarrel
  • line_drawing
  • lkosarzew-master-patch-25029
  • master
  • mlavinsky-master-patch-10431
  • module_frame
  • mriganka-branch02
  • niveditharam-master-patch-05822
  • optional_full_overlap_check
  • outer_tracker_fix
  • overlap_child_pipeline
  • remove_comment
  • rich-photos
  • shyam.kumar-master-patch-48113
  • sly2j-master-patch-62318
  • sphere-issue
  • sphere_tests
  • swapneshkhade-master-patch-16755
  • test
  • test-drich-tracker
  • testBranchRobin
  • test_tof_zy
  • tmp_view
  • tmp_viz
  • update_becal_nlayers
  • vanekjan-master-patch-74522
  • vdesai-master-patch-09582
  • vis_check
  • vis_dirc
  • vis_ref
  • wdconinc-master-patch-02076
  • weibin-master-patch-37475
  • zdc_prim_fix
  • zdemirog-master-patch-64142
  • zji-ScFiCal
  • acadia-v1.0
  • acadia-v1.0-alpha
  • acadia-v1.1
  • acadia-v2.0
  • acadia-v2.1
  • canyonlands-v1.0
  • canyonlands-v1.1
  • canyonlands-v1.2
  • canyonlands-v2.0
  • canyonlands-v2.1
  • canyonlands-v2.2
  • deathvalley-v1.0
  • deathvalley-v1.0-1.5T
  • deathvalley-v1.1
  • v0.1.0
  • v0.2.0
111 results

Target

Select target project
  • EIC/detectors/athena
  • zwzhao/athena
  • FernandoTA/athena
  • palspeic/athena
4 results
Select Git revision
  • 101-north-ecal-add-modules-around-beampipe
  • 104-add-realistic-cooling-for-gridpix
  • 116-fix-the-detector-views
  • 12-job-failed-106994
  • 126-improved-gem-rings
  • 131-update-tof-for-canyonlands
  • 134-make-new-3d-views-of-ff-region-and-detectors
  • 144-irt-geometry
  • 147-fix-dirc-overlaps-and-make-it-great-again
  • 21-electron-endcap-ecal-glass-outer-ring-implementation-needed-2
  • 23-add-barrel-tof
  • 24-tweak-zdc-longitudinal-size
  • 37-place-sifi-fibers-in-the-assembly-in-ecal-barrel
  • 38-mm-tracker-implementation
  • 40-quick-viz
  • 42-grid-pix-pid-detector
  • 53-acts-geometry-bug-outer-tracker-barrel
  • 54-dirc-better-parametrization
  • 56-astropix-sampling-fraction-test-2
  • 59-detailed-forward-gem-trd
  • 7-central-tracker-endcap-detail
  • 81-add-barrel-ecal-projection-at-positive-eta
  • 9-detector-plugin-for-w-scfi-calorimeter-layers
  • 98-update-barrel-and-endcap-tof
  • AllieWeary-master-patch-33350
  • acadia
  • acts_surface_binning
  • acts_vertex_barrel
  • add_segmentation
  • b0_acts
  • backward_ecal_cleanup
  • barrel-tracker-simplified
  • baseline-dimensions-rich-thickness
  • calibrations-ecal-hcal
  • calo-digitization-json
  • canyonlands
  • cherry-pick-85aaf29d
  • cherry-pick-ee231e50
  • deathvalley
  • deathvalley-1.5T
  • debug-vis
  • default_visibilities
  • documentation_tag
  • drich-optics-tests
  • drich-space-update
  • drich-two-mirrors
  • ecal-hcal-endcap-bore-and-length
  • hcal
  • hcal-klm
  • irt-erich
  • irt-init-v01
  • lengthen_ecalbarrel
  • line_drawing
  • master
  • module_frame
  • optional_full_overlap_check
  • outer_tracker_fix
  • overlap_child_pipeline
  • remove_comment
  • rich-photos
  • sly2j-master-patch-62318
  • sphere-issue
  • sphere_tests
  • test
  • test-drich-tracker
  • testBranchRobin
  • test_tof_zy
  • tmp_view
  • tmp_viz
  • update_becal_nlayers
  • vis_check
  • vis_dirc
  • vis_ref
  • zdc_prim_fix
  • zji-ScFiCal
  • acadia-v1.0
  • acadia-v1.0-alpha
  • acadia-v1.1
  • acadia-v2.0
  • acadia-v2.1
  • canyonlands-v1.0
  • canyonlands-v1.1
  • canyonlands-v1.2
  • canyonlands-v2.0
  • canyonlands-v2.1
  • canyonlands-v2.2
  • deathvalley-v1.0
  • deathvalley-v1.0-1.5T
  • deathvalley-v1.1
  • v0.1.0
  • v0.2.0
91 results
Show changes
Showing
with 1049 additions and 53 deletions
HepMC::Version 3.02.02
HepMC::Asciiv3-START_EVENT_LISTING
E 0 4 9
U GEV CM
P 1 0 11 0.0000000000000000e+00 0.0000000000000000e+00 -9.9999999869440064e+00 1.0000000000000000e+01 5.1099888971089147e-04 4
P 2 1 22 -5.8225640056623670e-03 3.7747924008719728e-02 -2.9249301763891555e+00 2.9248270767857321e+00 -4.5408321610621201e-02 3
P 3 1 11 5.8225640056623670e-03 -3.7747924008719728e-02 -7.0750698105548508e+00 7.0751729232142679e+00 5.1101967722736764e-04 1
P 4 0 2212 0.0000000000000000e+00 0.0000000000000000e+00 9.9995598131387851e+01 1.0000000000000000e+02 9.3827199999876709e-01 4
P 5 4 2212 0.0000000000000000e+00 0.0000000000000000e+00 9.9995598131482922e+01 1.0000000000009507e+02 9.3827199999973643e-01 3
V -3 0 [2,5]
P 6 -3 553 -1.4745608418116361e-02 -8.6828685571490272e-01 4.7980031183979008e+00 1.0642943648781511e+01 9.4603000000109834e+00 2
P 7 -3 2212 8.9230444123625328e-03 9.0603477972421620e-01 9.2272664838178372e+01 9.2281883429672035e+01 9.3827200000070576e-01 1
P 8 6 -13 4.4907597498767587e-01 2.0906320322010372e+00 -2.1757837479786910e+00 3.0524760533554351e+00 1.0565800000001382e-01 1
P 9 6 13 -4.6382158340577534e-01 -2.9589188879149320e+00 6.9737868663710216e+00 7.5904675954137195e+00 1.0565800000002223e-01 1
E 0 4 10
U GEV CM
P 1 0 11 0.0000000000000000e+00 0.0000000000000000e+00 -9.9999999869440064e+00 1.0000000000000000e+01 5.1099888971089147e-04 4
P 2 1 22 -2.6839726606050791e-04 1.1264659797828775e-03 -6.3401069726794805e+00 6.3401067668601172e+00 -1.9876609922101014e-03 3
P 3 1 11 2.6839726606050791e-04 -1.1264659797828775e-03 -3.6598930142645258e+00 3.6598932331398828e+00 5.1103633096365880e-04 1
P 4 0 2212 0.0000000000000000e+00 0.0000000000000000e+00 9.9995598131387851e+01 1.0000000000000000e+02 9.3827199999876709e-01 4
P 5 4 2212 0.0000000000000000e+00 0.0000000000000000e+00 9.9995598131482922e+01 1.0000000000009507e+02 9.3827199999973643e-01 3
V -3 0 [2,5]
P 6 -3 553 1.9156252814767760e-01 2.1790735768546463e-01 -2.8073109612741973e+00 9.8723072682332713e+00 9.4603000029807429e+00 2
P 7 -3 2212 -1.9183092541375127e-01 -2.1678089170561543e-01 9.6462802125352582e+01 9.6467799504704473e+01 9.3827199999779787e-01 1
P 8 6 -13 -2.4852998465289872e-01 2.3091049977702758e+00 -5.7337843777899966e+00 6.1871786743193251e+00 1.0565799999995498e-01 1
P 9 6 13 4.4342149179344215e-01 -2.1010576035711188e+00 2.9552377554469285e+00 3.6545395711486477e+00 1.0565800000003905e-01 1
P 10 6 22 -3.3289790532426214e-03 9.8599634176282647e-03 -2.8764338046322176e-02 3.0589019653741657e-02 3.2927225399135965e-10 1
E 0 4 9
U GEV CM
P 1 0 11 0.0000000000000000e+00 0.0000000000000000e+00 -9.9999999869440064e+00 1.0000000000000000e+01 5.1099888971089147e-04 4
P 2 1 22 2.1549001953953920e-01 5.3446029602846556e-01 -6.2965867413439192e-01 6.1195545733789913e-01 -5.9503304168678661e-01 3
P 3 1 11 -2.1549001953953920e-01 -5.3446029602846556e-01 -9.3703413128096145e+00 9.3880445426621009e+00 5.0981276742689016e-04 1
P 4 0 2212 0.0000000000000000e+00 0.0000000000000000e+00 9.9995598131387851e+01 1.0000000000000000e+02 9.3827199999876709e-01 4
P 5 4 2212 0.0000000000000000e+00 0.0000000000000000e+00 9.9995598131482922e+01 1.0000000000009507e+02 9.3827199999973643e-01 3
V -3 0 [2,5]
P 6 -3 553 2.2825834022061950e-01 3.3334310888886032e-01 3.5569092662904950e+01 3.6807891116586688e+01 9.4603000000031017e+00 2
P 7 -3 2212 -1.2768320678757170e-02 2.0111718714536578e-01 6.3796846795456545e+01 6.3804064341873378e+01 9.3827200000094813e-01 1
P 8 6 -13 -3.2477759288923482e+00 3.3065214111492942e+00 1.3631832024299879e+01 1.4398581189769127e+01 1.0565800000146809e-01 1
P 9 6 13 3.4760342691128936e+00 -2.9731783022605436e+00 2.1937260638593418e+01 2.2409309926805506e+01 1.0565799999797114e-01 1
E 0 4 9
U GEV CM
P 1 0 11 0.0000000000000000e+00 0.0000000000000000e+00 -9.9999999869440064e+00 1.0000000000000000e+01 5.1099888971089147e-04 4
P 2 1 22 8.1053930688133671e-03 -1.2356942914208306e-02 -2.8212751471844815e+00 2.8212599310500082e+00 -1.7442735092468440e-02 3
P 3 1 11 -8.1053930688133671e-03 1.2356942914208306e-02 -7.1787248397595249e+00 7.1787400689499918e+00 5.1101148051165002e-04 1
P 4 0 2212 0.0000000000000000e+00 0.0000000000000000e+00 9.9995598131387851e+01 1.0000000000000000e+02 9.3827199999876709e-01 4
P 5 4 2212 0.0000000000000000e+00 0.0000000000000000e+00 9.9995598131482922e+01 1.0000000000009507e+02 9.3827199999973643e-01 3
V -3 0 [2,5]
P 6 -3 553 -2.4074047134142244e-02 2.6879165673024504e-02 5.1101881387075991e+00 1.0752330024333787e+01 9.4602999999952058e+00 2
P 7 -3 2212 3.2179440203073603e-02 -3.9236108587412617e-02 9.2064134846942238e+01 9.2068929908251562e+01 9.3827200000167510e-01 1
P 8 6 -13 3.4101173607658830e+00 -1.3038459453885907e+00 5.9422927439678519e+00 6.9750212423676778e+00 1.0565800000106459e-01 1
P 9 6 13 -3.4341914079000371e+00 1.3307251110616287e+00 -8.3210460525766239e-01 3.7773087819715596e+00 1.0565800000016515e-01 1
E 0 1 3
U GEV MM
P 1 0 11 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+01 1.0000000000000000e+01 0.0000000000000000e+00 4
P 2 0 2212 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 9.3799999999999994e-01 9.3799999999999994e-01 4
V -1 0 [1,2]
P 3 -1 11 8.3077231638512800e-02 3.4688303864359871e-01 -9.3422177831854492e-01 1.0000001305604915e+00 5.1100000015238706e-04 1
E 0 1 3
U GEV MM
P 1 0 11 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+01 1.0000000000000000e+01 0.0000000000000000e+00 4
P 2 0 2212 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 9.3799999999999994e-01 9.3799999999999994e-01 4
V -1 0 [1,2]
P 3 -1 11 7.2104820115711854e-01 1.5628742640734802e-01 -1.8589415622754393e+00 2.0000000652802488e+00 5.1100000036965185e-04 1
E 0 1 3
U GEV MM
P 1 0 11 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+01 1.0000000000000000e+01 0.0000000000000000e+00 4
P 2 0 2212 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 9.3799999999999994e-01 9.3799999999999994e-01 4
V -1 0 [1,2]
P 3 -1 11 -1.4361173664326103e+00 -9.3836236801405426e-01 -2.4611060473140363e+00 3.0000000435201661e+00 5.1100000036965185e-04 1
E 0 1 3
U GEV MM
P 1 0 11 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+01 1.0000000000000000e+01 0.0000000000000000e+00 4
P 2 0 2212 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 9.3799999999999994e-01 9.3799999999999994e-01 4
V -1 0 [1,2]
P 3 -1 11 -2.6126728458756499e-01 2.0189611701651842e+00 -3.4431867796228350e+00 4.0000000326401244e+00 5.1099999515529708e-04 1
E 0 1 3
U GEV MM
P 1 0 11 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+01 1.0000000000000000e+01 0.0000000000000000e+00 4
P 2 0 2212 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 9.3799999999999994e-01 9.3799999999999994e-01 4
V -1 0 [1,2]
P 3 -1 11 8.5091281358231141e-01 -2.4919887833464918e+00 -4.2504046027827407e+00 5.0000000261121000e+00 5.1099999863153363e-04 1
E 0 1 3
U GEV MM
P 1 0 11 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+01 1.0000000000000000e+01 0.0000000000000000e+00 4
P 2 0 2212 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 9.3799999999999994e-01 9.3799999999999994e-01 4
V -1 0 [1,2]
P 3 -1 11 -2.5637625613563038e+00 2.9774447329110156e+00 -4.5345280230083720e+00 6.0000000217600835e+00 5.1100000210777007e-04 1
E 0 1 3
U GEV MM
P 1 0 11 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+01 1.0000000000000000e+01 0.0000000000000000e+00 4
P 2 0 2212 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 9.3799999999999994e-01 9.3799999999999994e-01 4
V -1 0 [1,2]
P 3 -1 11 8.5248676124549916e-01 1.3423464093622672e+00 -6.8169914507188132e+00 7.0000000186514999e+00 5.1100000210777007e-04 1
E 0 1 3
U GEV MM
P 1 0 11 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+01 1.0000000000000000e+01 0.0000000000000000e+00 4
P 2 0 2212 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 9.3799999999999994e-01 9.3799999999999994e-01 4
V -1 0 [1,2]
P 3 -1 11 2.7295844590149682e-01 -1.0660162875541499e+00 -7.9239575315293242e+00 8.0000000163200617e+00 5.1099999515529708e-04 1
E 0 1 3
U GEV MM
HepMC::Asciiv3-END_EVENT_LISTING
'''
A script to calcualte placement of ecal endcap modules
lxml is not included in container, get it by simply typing 'pip install lxml'
Author: Chao Peng (ANL)
Date: 06/17/2021
'''
import os
import numpy as np
import argparse
import DDG4
from lxml import etree as ET
from matplotlib import pyplot as plt
from matplotlib.collections import PatchCollection
from matplotlib.patches import Rectangle, Circle
CRYSTAL_SIZE = (20., 20., 200.) # mm
CRYSTAL_GAP = 0.5 # mm
CRYSTAL_ALIGNMENT = [
(5, 21), (5, 21), (5, 21), (4, 22),
(3, 23), (0, 26), (0, 24), (0, 24),
(0, 24), (0, 24), (0, 24), (0, 24),
(0, 22), (0, 22), (0, 20), (0, 20),
(0, 18), (0, 18), (0, 16), (0, 16),
(0, 14), (0, 14), (0, 12), (0, 12),
(0, 6), (0, 6),
]
GLASS_SIZE = (40., 40., 400.) # mm
GLASS_GAP = 1.0 # mm
GLASS_ALIGNMENT = [
(13, 10), (13, 10), (13, 10), (12, 10),
(12, 10), (12, 10), (11, 11), (10, 11),
(9, 12), (8, 13), (7, 13), (6, 14),
(3, 16), (0, 18), (0, 18), (0, 16),
(0, 16), (0, 14), (0, 13), (0, 11),
(0, 10), (0, 7), (0, 3),
]
# calculate positions of modules with a quad-alignment and module size
def individual_placement(alignment, module_x, module_y, gap=0.):
placements = []
for row, (start, num) in enumerate(alignment):
for col in np.arange(start, start + num):
placements.append(((col + 0.5)*(module_y + gap), (row + 0.5)*(module_x + gap)))
placements = np.asarray(placements)
return np.vstack((placements,
np.vstack((placements.T[0]*-1., placements.T[1])).T,
np.vstack((placements.T[0], placements.T[1]*-1.)).T,
np.vstack((placements.T[0]*-1., placements.T[1]*-1.)).T))
def draw_placement(axis, colors=('teal'), module_alignment=((CRYSTAL_SIZE, CRYSTAL_GAP, CRYSTAL_ALIGNMENT))):
xmin, ymin, xmax, ymax = 0., 0., 0., 0.
patches = []
numbers = []
for color, (mod_size, mod_gap, alignment) in zip(colors, module_alignment):
placements = individual_placement(alignment, *mod_size[:2], mod_gap)
boxes = [Rectangle((x - (mod_size[0] + mod_gap)/2., y - (mod_size[1] + mod_gap)/2.), mod_size[0], mod_size[1])
for x, y in placements]
patches.append(Rectangle((0., 0.), *mod_size[:2], facecolor=color, alpha=0.5, edgecolor='k'))
numbers.append(len(placements))
pc = PatchCollection(boxes, facecolor=color, alpha=0.5, edgecolor='k')
xmin = min(xmin, placements.T[0].min() - 8.*(mod_size[0] + mod_gap))
ymin = min(ymin, placements.T[1].min() - 8.*(mod_size[1] + mod_gap))
xmax = max(xmax, placements.T[0].max() + 8.*(mod_size[0] + mod_gap))
ymax = max(ymax, placements.T[1].max() + 8.*(mod_size[1] + mod_gap))
# Add collection to axes
axis.add_collection(pc)
axis.set_xlim(xmin, xmax)
axis.set_ylim(ymin, ymax)
return axis, patches, numbers
def compact_constants(path, names):
if not os.path.exists(path):
print('Cannot find compact file \"{}\".'.format(path))
return []
kernel = DDG4.Kernel()
description = kernel.detectorDescription()
kernel.loadGeometry("file:{}".format(path))
try:
vals = [description.constantAsDouble(n) for n in names]
except:
print('Fail to extract values from {}, return empty.'.format(names))
vals = []
kernel.terminate()
return vals
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-s', '--save', default='ce_ecal_placement_test.xml',
help='path to save compact file.')
parser.add_argument('-c', '--compact', default='',
help='compact file to get contant to plot')
parser.add_argument('--radii-constants', dest='radii', default='EcalBarrel_rmin',
help='constant names in compact file to plot, seprate by \",\"')
parser.add_argument('--individual', dest='indiv', action='store_true',
help='individual block placements instead of line placements')
args = parser.parse_args()
data = ET.Element('lccdd')
defines = ET.SubElement(data, 'define')
# constants: name, value
CONSTANTS = [
('CrystalModule_sx', '{:.2f}*mm'.format(CRYSTAL_SIZE[0])),
('CrystalModule_sy', '{:.2f}*mm'.format(CRYSTAL_SIZE[1])),
('CrystalModule_sz', '{:.2f}*mm'.format(CRYSTAL_SIZE[2])),
('CrystalModule_wrap', '{:.2f}*mm'.format(CRYSTAL_GAP)),
('GlassModule_sx', '{:.2f}*mm'.format(GLASS_SIZE[0])),
('GlassModule_sy', '{:.2f}*mm'.format(GLASS_SIZE[1])),
('GlassModule_sz', '{:.2f}*mm'.format(GLASS_SIZE[2])),
('GlassModule_wrap', '{:.2f}*mm'.format(GLASS_GAP)),
('CrystalModule_z0', '10.*cm'),
('GlassModule_z0', '0.0*cm'),
('EcalEndcapN_z0', '-EcalEndcapN_zmin-max(CrystalModule_sz,GlassModule_sz)/2.'),
('CrystalModule_dx', 'CrystalModule_sx + CrystalModule_wrap'),
('CrystalModule_dy', 'CrystalModule_sy + CrystalModule_wrap'),
('GlassModule_dx', 'GlassModule_sx + GlassModule_wrap'),
('GlassModule_dy', 'GlassModule_sy + GlassModule_wrap'),
]
# line-by-line alignment start pos, total number of blocks
for name, value in CONSTANTS:
constant = ET.SubElement(defines, 'constant')
constant.set('name', name)
constant.set('value', value)
# this value will be used multiple times, so define it here
readout_name = 'EcalEndcapNHits'
# detector and its dimension/position/rotation
dets = ET.SubElement(data, 'detectors')
cmt = ET.SubElement(dets, 'comment')
cmt.text = ' Backwards Endcap EM Calorimeter, placements generated by script '
det = ET.SubElement(dets, 'detector')
det.set('id', 'ECalEndcapN_ID')
det.set('name', 'EcalEndcapN')
det.set('type', 'HomogeneousCalorimeter')
det.set('readout', readout_name)
pos = ET.SubElement(det, 'position')
pos.set('x', '0')
pos.set('y', '0')
pos.set('z', 'EcalEndcapN_z0')
rot = ET.SubElement(det, 'rotation')
rot.set('x', '0')
rot.set('y', '0')
rot.set('z', '0')
# placements of modules
plm = ET.SubElement(det, 'placements')
pltype = 'individuals' if args.indiv else 'lines'
# crystal
crystal = ET.SubElement(plm, pltype)
crystal.set('sector', '1')
crystal_mod = ET.SubElement(crystal, 'module')
crystal_mod.set('sizex', 'CrystalModule_sx')
crystal_mod.set('sizey', 'CrystalModule_sy')
crystal_mod.set('sizez', 'CrystalModule_sz')
crystal_mod.set('material', 'PbWO4')
crystal_mod.set('vis', 'AnlTeal')
crystal_wrap = ET.SubElement(crystal, 'wrapper')
crystal_wrap.set('thickness', 'CrystalModule_wrap')
crystal_wrap.set('material', 'Epoxy')
crystal_wrap.set('vis', 'WhiteVis')
# crystal placements (for individuals)
if args.indiv:
for m, (x, y) in enumerate(individual_placement(CRYSTAL_ALIGNMENT, *CRYSTAL_SIZE[:2], CRYSTAL_GAP)):
module = ET.SubElement(crystal, 'placement')
module.set('x', '{:.3f}*mm'.format(x))
module.set('y', '{:.3f}*mm'.format(y))
module.set('z', 'CrystalModule_z0')
module.set('id', '{:d}'.format(m))
# crystal placements (for lines)
else:
crystal.set('mirrorx', 'true')
crystal.set('mirrory', 'true')
for row, (begin, nmods) in enumerate(CRYSTAL_ALIGNMENT):
line = ET.SubElement(crystal, 'line')
line.set('axis', 'x')
line.set('x', 'CrystalModule_dx/2.')
line.set('y', 'CrystalModule_dy*{:d}/2.'.format(row*2 + 1))
line.set('z', 'CrystalModule_z0')
line.set('begin', '{:d}'.format(begin))
line.set('nmods', '{:d}'.format(nmods))
# glass
glass = ET.SubElement(plm, pltype)
glass.set('sector', '2')
glass_mod = ET.SubElement(glass, 'module')
glass_mod.set('sizex', 'GlassModule_sx')
glass_mod.set('sizey', 'GlassModule_sy')
glass_mod.set('sizez', 'GlassModule_sz')
# TODO: change glass material
glass_mod.set('material', 'PbGlass')
glass_mod.set('vis', 'AnlBlue')
glass_wrap = ET.SubElement(glass, 'wrapper')
glass_wrap.set('thickness', 'GlassModule_wrap')
glass_wrap.set('material', 'Epoxy')
glass_wrap.set('vis', 'WhiteVis')
# crystal placements (for individuals)
if args.indiv:
for m, (x, y) in enumerate(individual_placement(GLASS_ALIGNMENT, *GLASS_SIZE[:2], GLASS_GAP)):
module = ET.SubElement(glass, 'placement')
module.set('x', '{:.3f}*mm'.format(x))
module.set('y', '{:.3f}*mm'.format(y))
module.set('z', 'GlassModule_z0')
module.set('id', '{:d}'.format(m))
# crystal placements (for lines)
else:
glass.set('mirrorx', 'true')
glass.set('mirrory', 'true')
for row, (begin, nmods) in enumerate(GLASS_ALIGNMENT):
line = ET.SubElement(glass, 'line')
line.set('axis', 'x')
line.set('x', 'GlassModule_dx/2.')
line.set('y', 'GlassModule_dy*{:d}/2.'.format(row*2 + 1))
line.set('z', 'GlassModule_z0')
line.set('begin', '{:d}'.format(begin))
line.set('nmods', '{:d}'.format(nmods))
# readout
readouts = ET.SubElement(data, 'readouts')
cmt = ET.SubElement(readouts, 'comment')
cmt.text = 'Effectively no segmentation, the segmentation is used to provide cell dimension info'
readout = ET.SubElement(readouts, 'readout')
readout.set('name', readout_name)
seg = ET.SubElement(readout, 'segmentation')
# need segmentation to provide cell dimension info
# seg.set('type', 'NoSegmentation')
seg.set('type', 'MultiSegmentation')
seg.set('key', 'sector')
crystal_seg = ET.SubElement(seg, 'segmentation')
crystal_seg.set('name', 'CrystalSeg')
crystal_seg.set('key_value', '1')
crystal_seg.set('type', 'CartesianGridXY')
crystal_seg.set('grid_size_x', 'CrystalModule_dx')
crystal_seg.set('grid_size_y', 'CrystalModule_dy')
glass_seg = ET.SubElement(seg, 'segmentation')
glass_seg.set('name', 'GlassSeg')
glass_seg.set('key_value', '2')
glass_seg.set('type', 'CartesianGridXY')
glass_seg.set('grid_size_x', 'GlassModule_dx')
glass_seg.set('grid_size_y', 'GlassModule_dy')
rid = ET.SubElement(readout, 'id')
rid.text = 'system:8,sector:4,module:20,x:32:-16,y:-16'
text = ET.tostring(data, pretty_print=True)
with open(args.save, 'wb') as f:
f.write(text)
fig, ax = plt.subplots(figsize=(12, 12), dpi=160)
ax, patches, nblocks = draw_placement(ax, ['teal', 'royalblue'],
[(CRYSTAL_SIZE, CRYSTAL_GAP, CRYSTAL_ALIGNMENT), (GLASS_SIZE, GLASS_GAP, GLASS_ALIGNMENT)])
ax.set_xlabel('x (mm)', fontsize=24)
ax.set_ylabel('y (mm)', fontsize=24)
ax.tick_params(direction='in', labelsize=22, which='both')
ax.set_axisbelow(True)
ax.grid(linestyle=':', which='both')
ax.legend(patches, ['{} {}'.format(num, name) for num, name in zip(nblocks, ['PbWO$_4$', 'SciGlass'])], fontsize=24)
if args.compact and args.radii:
names = [c.strip() for c in args.radii.split(',')]
radii = compact_constants(args.compact, names)
for name, radius in zip(names, radii):
ax.add_patch(Circle((0, 0), radius*10., facecolor='none', edgecolor='k', linewidth=2))
ax.annotate(name, xy=(radius*10/1.4, radius*10/1.4), fontsize=22)
fig.savefig('ce_ecal_placement.png')
......@@ -12,7 +12,7 @@ parser = argparse.ArgumentParser(
This program should be run in the "compact" directory.
''')
parser.add_argument("-v","--verbose", help="increase output verbosity", type=int, default=0)
parser.add_argument("--compact", help="compact detector file",default="reference_detector.xml")
parser.add_argument("--compact", help="compact detector file",default="athena.xml")
parser.add_argument("--vis", help="vis true/false", action="store_true",default=False)
parser.add_argument("--ui", help="ui setting tcsh or qt; default=qt", type=str,default="qt",dest="ui")
parser.add_argument("-b","--batch", help="batch turns off vis/ui", action="store_true",default=False, dest="batch")
......@@ -86,7 +86,7 @@ def run():
outputfile = args.output
if outputfile is None:
outputfile = 'data/reference_detector_' + time.strftime('%Y-%m-%d_%H-%M')
outputfile = 'data/athena_' + time.strftime('%Y-%m-%d_%H-%M')
#rootoutput = geant4.setupROOTOutput('RootOutput', outputfile)
#rootoutput.HandleMCTruth = True
......
R__LOAD_LIBRARY(libDDCore.so)
R__LOAD_LIBRARY(libActsPluginDD4hep.so)
R__LOAD_LIBRARY(libDDG4.so)
R__LOAD_LIBRARY(libDDG4IO.so)
#include "DD4hep/Detector.h"
#include "DD4hep/DetElement.h"
#include "DD4hep/Objects.h"
#include "DD4hep/Detector.h"
#include "DDG4/Geant4Data.h"
#include "DDRec/CellIDPositionConverter.h"
#include "DDRec/SurfaceManager.h"
#include "DDRec/Surface.h"
#include "TCanvas.h"
#include "TChain.h"
#include "Acts/Geometry/TrackingGeometry.hpp"
#include "Acts/Geometry/TrackingVolume.hpp"
#include "Acts/Plugins/DD4hep/ConvertDD4hepDetector.hpp"
/** Example loading ACTs.
*
*
*/
void test_ACTS(const char* compact = "athena.xml"){
using namespace ROOT::Math;
// -------------------------
// Get the DD4hep instance
// Load the compact XML file
// Initialize the position converter tool
dd4hep::Detector& detector = dd4hep::Detector::getInstance();
detector.fromCompact(compact);
dd4hep::rec::CellIDPositionConverter cellid_converter(detector);
//std::unique_ptr<const Acts::TrackingGeometry>
auto acts_tracking_geometry = Acts::convertDD4hepDetector (detector.world(),Acts::Logging::Level::VERBOSE);
//acts_tracking_geometry = Acts::convertDD4hepDetector (detector.world(),Acts::Logging::Level::INFO);
if(acts_tracking_geometry) {
std::cout << "success?\n";
}
// if(acts_tracking_geometry->highestTrackingVolume()) {
// std::cout << " volume name \n ";
// std::cout << acts_tracking_geometry->highestTrackingVolume()->volumeName() << std::endl;
// } else {
// std::cout << "derp\n";
// }
//}
}
......@@ -44,28 +44,30 @@ done
set -- "${POSITIONAL[@]}" # restore positional parameters
# Side view
dawncut 1 0 0 1 ${INPUT_FILE} ${FILE_TAG}_temp0.prim
dawncut -1 0 0 1 ${FILE_TAG}_temp0.prim ${FILE_TAG}.prim
../../bin/dawn_tweak --mag 10
dawn -d ${FILE_TAG}.prim
# Side view (lines)
dawncut -1 0 0 1 ${INPUT_FILE} ${FILE_TAG}.prim
# dawncut 1 0 0 1 ${INPUT_FILE} ${FILE_TAG}_temp0.prim
# dawncut -1 0 0 1 ${FILE_TAG}_temp0.prim ${FILE_TAG}.prim
../../bin/dawn_tweak --mag 10 --draw 3 --theta 165 --phi 75 --light-theta 180 --light-phi 90
dawn -d ${FILE_TAG}.prim
ps2pdf ${FILE_TAG}.eps ${FILE_TAG}_full.pdf
gs -o ${FILE_TAG}.pdf -sDEVICE=pdfwrite \
-c "[/CropBox [51 250 550 590] /PAGES pdfmark" \
-f ${FILE_TAG}_full.pdf
pdftoppm ${FILE_TAG}.pdf ${FILE_TAG} -png -singlefile -cropbox
pdftoppm ${FILE_TAG}.pdf ${FILE_TAG} -png -singlefile -cropbox -thinlinemode solid -aaVector yes -r 600
# Top view
#dawncut 0 -1 0 1 ${INPUT_FILE} ${FILE_TAG}.prim
dawncut 0 1 0 1 ${INPUT_FILE} ${FILE_TAG}_temp0.prim
dawncut 0 -1 0 1 ${FILE_TAG}_temp0.prim ${FILE_TAG}.prim
../../bin/dawn_tweak --theta 270 --mag 20
../../bin/dawn_tweak --mag 10 --draw 1 --theta 90 --phi 90
dawn -d ${FILE_TAG}.prim
ps2pdf ${FILE_TAG}.eps ${FILE_TAG}_top_full.pdf
gs -o ${FILE_TAG}_top.pdf -sDEVICE=pdfwrite \
-c "[/CropBox [51 250 550 590] /PAGES pdfmark" \
-f ${FILE_TAG}_top_full.pdf
pdftoppm ${FILE_TAG}_top.pdf ${FILE_TAG}_top -png -singlefile -cropbox
pdftoppm ${FILE_TAG}_top.pdf ${FILE_TAG}_top -png -singlefile -cropbox -thinlinemode solid -aaVector yes
1.34392e+07
90
180
0
0
0
25000
2.0
1
0.001
0
1
1
1
0.5
0.5
0.5
19
71
0.001
0.001
0.001
3
71
0.001
0
0
1
evince
0
0
1.34392e+07
0
180
0
0
0
0
8
1
0.001
0
1
1
1
0.5
0.5
0.5
19
71
0.01
0.01
0.01
3
70
0.01
1
1
1
evince
0
0
......@@ -18,7 +18,7 @@ tan ()
function print_the_help {
echo "USAGE: $0 -i <PRIM_FILE> "
echo "USAGE: $0 -i <PRIM_FILE> <slices ...> "
echo " OPTIONS: "
echo " -t,--tag filename tag (default: view1)"
exit
......@@ -48,12 +48,16 @@ do
shift # past argument
shift # past value
;;
*) # unknown option
#POSITIONAL+=("$1") # save it in an array for later
-[a-zA-Z]*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
echo "unknown option $1"
print_the_help
shift # past argument
;;
*) # positional options
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
......@@ -62,17 +66,6 @@ set -- "${POSITIONAL[@]}" # restore positional parameters
echo "view12 produces a series of slightly rotated XY slices a different z locations. Along beamline"
# slice at z = 2m
# note the offset has to change with sign of the direction to cut in the opposite direction.
dawncut 0 0 1 2005 ${INPUT_FILE} ${FILE_TAG}b_temp0.prim
dawncut 0 0 -1 -2000 ${FILE_TAG}b_temp0.prim ${FILE_TAG}b.prim
dawn -d ${FILE_TAG}b.prim
ps2pdf ${FILE_TAG}b.eps ${FILE_TAG}b_full.pdf
gs -o ${FILE_TAG}b.pdf -sDEVICE=pdfwrite \
-c "[/CropBox [50 175 550 675] /PAGES pdfmark" \
-f ${FILE_TAG}b_full.pdf
pdftoppm ${FILE_TAG}b.pdf ${FILE_TAG}b -png -singlefile -cropbox
original_file_tag="${FILE_TAG}"
make_slice(){
......@@ -90,9 +83,10 @@ make_slice(){
rm "${FILE_TAG}_temp0.prim"
rm "${FILE_TAG}.prim"
}
for zzz in $(seq 50 50 2000) ;
for zzz in $@ ;
do
make_slice ${zzz} &
make_slice ${zzz}
done
wait
......
......@@ -9,7 +9,7 @@ function print_the_help {
exit
}
FILE_TAG="view2"
FILE_TAG="view13"
INPUT_FILE="g4_0000.prim"
......
0.0
72.5
189.5
0
0
0
1500
55
3
0.001
0
1
1
1
0.5
0.5
0.5
25.5
71
0.001
0.001
0.001
1
70
0.001
1
0
1
evince
0
0
......@@ -23,7 +23,7 @@
function print_the_help {
echo "USAGE: $0 -i <PRIM_FILE> "
echo "USAGE: $0 -i <PRIM_FILE> <slices ...> "
echo " OPTIONS: "
echo " -t,--tag filename tag (default: view1)"
exit
......@@ -53,34 +53,22 @@ do
shift # past argument
shift # past value
;;
*) # unknown option
#POSITIONAL+=("$1") # save it in an array for later
-[a-zA-Z]*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
echo "unknown option $1"
print_the_help
shift # past argument
;;
*) # positional options
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
# units are mm
echo "view14 produces a series of slightly rotated XY slices a different z locations. Along beamline"
# slice at z = 2m
# note the offset has to change with sign of the direction to cut in the opposite direction.
dawncut 0 0 1 10005 ${INPUT_FILE} ${FILE_TAG}b_temp0.prim
dawncut 0 0 -1 -1000 ${FILE_TAG}b_temp0.prim ${FILE_TAG}b.prim
dawn -d ${FILE_TAG}b.prim
ps2pdf ${FILE_TAG}b.eps ${FILE_TAG}b_full.pdf
gs -o ${FILE_TAG}b.pdf -sDEVICE=pdfwrite \
-c "[/CropBox [50 175 550 675] /PAGES pdfmark" \
-f ${FILE_TAG}b_full.pdf
pdftoppm ${FILE_TAG}b.pdf ${FILE_TAG}b -png -singlefile -cropbox
echo "done ..."
original_file_tag="${FILE_TAG}"
make_slice(){
......@@ -102,7 +90,8 @@ make_slice(){
rm "${FILE_TAG}_temp0.prim"
rm "${FILE_TAG}.prim"
}
for zzz in $(seq 150 50 2000) ;
for zzz in $@ ;
do
make_slice ${zzz}
done
......
0.0
72.5
189.5
0
0
0
1500
50
3
0.001
0
1
1
1
0.5
0.5
0.5
25.5
71
0.001
0.001
0.001
1
70
0.001
1
0
1
evince
0
0
......@@ -23,7 +23,7 @@
function print_the_help {
echo "USAGE: $0 -i <PRIM_FILE> "
echo "USAGE: $0 -i <PRIM_FILE> <slices ...> "
echo " OPTIONS: "
echo " -t,--tag filename tag (default: view1)"
exit
......@@ -53,12 +53,16 @@ do
shift # past argument
shift # past value
;;
*) # unknown option
#POSITIONAL+=("$1") # save it in an array for later
-[a-zA-Z]*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
echo "unknown option $1"
print_the_help
shift # past argument
;;
*) # positional options
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
......@@ -104,7 +108,7 @@ make_slice(){
rm "${FILE_TAG}.prim"
}
for zzz in $(seq 150 50 2000) ;
for zzz in $@ ;
do
make_slice ${zzz}
done
......
......@@ -6,7 +6,7 @@
0
0
8
3
1
0.001
0
1
......
1.34392e+07
90
180
0
0
0
0
1
1
0.001
0
1
1
1
0.5
0.5
0.5
19
71
0.001
0.001
0.001
3
71
0.001
0
0
1
evince
0
0
#!/bin/bash
#export DAWN_PS_PREVIEWER="derp"
function print_the_help {
echo "USAGE: $0 <PRIM_FILE> "
echo " OPTIONS: "
echo " -t,--tag filename tag (default: view1)"
exit
}
FILE_TAG="view20"
INPUT_FILE="../../g4_0000.prim"
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-h|--help)
shift # past argument
print_the_help
;;
-t|--tag)
FILE_TAG="$2"
shift # past argument
shift # past value
;;
-i|--input)
INPUT_FILE="$2"
shift # past argument
shift # past value
;;
*) # unknown option
#POSITIONAL+=("$1") # save it in an array for later
echo "unknown option $1"
print_the_help
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
# Top view with a thin slice down the middle
dawncut 0 1 0 1 ${INPUT_FILE} ${FILE_TAG}_top_temp0.prim
dawncut 0 -1 0 1 ${FILE_TAG}_top_temp0.prim ${FILE_TAG}_top.prim
../../bin/dawn_tweak --mag 2 --draw 1 --theta 90 --phi 90
dawn -d ${FILE_TAG}_top.prim
ps2pdf ${FILE_TAG}_top.eps ${FILE_TAG}_top_full.pdf
gs -o ${FILE_TAG}_top.pdf -sDEVICE=pdfwrite \
-c "[/CropBox [51 250 550 590] /PAGES pdfmark" \
-f ${FILE_TAG}_top_full.pdf
pdftoppm ${FILE_TAG}_top.pdf ${FILE_TAG}_top -png -singlefile -cropbox -thinlinemode solid -aaVector yes
# Side view (lines)
dawncut 1 0 0 1 ${INPUT_FILE} ${FILE_TAG}_temp0.prim
dawncut -1 0 0 1 ${FILE_TAG}_temp0.prim ${FILE_TAG}.prim
../../bin/dawn_tweak --mag 1 --draw 1 --theta 180 --phi 90
dawn -d ${FILE_TAG}.prim
ps2pdf ${FILE_TAG}.eps ${FILE_TAG}_full.pdf
gs -o ${FILE_TAG}.pdf -sDEVICE=pdfwrite \
-c "[/CropBox [51 250 550 590] /PAGES pdfmark" \
-f ${FILE_TAG}_full.pdf
pdftoppm ${FILE_TAG}.pdf ${FILE_TAG} -png -singlefile -cropbox -thinlinemode solid -aaVector yes
#npdet_info print EcalEndcapN_z0 --value-only ../../athena.xml
#180.5 cm
zcut=$(npdet_info print EcalEndcapN_z0 --value-only ${DETECTOR_PATH}/athena.xml )
NMOD1=$(npdet_info print EcalEndcapN_NModules_Sector1 --value-only ${DETECTOR_PATH}/calorimeters.xml )
NMOD2=$(npdet_info print EcalEndcapN_NModules_Sector2 --value-only ${DETECTOR_PATH}/calorimeters.xml )
echo "NMOD1 = ${NMOD1}"
echo "NMOD2 = ${NMOD2}"
echo "zcut = ${zcut}"
# Top view with a thin slice down the middle
dawncut 0 0 1 -1800 ${INPUT_FILE} ${FILE_TAG}_endcapN_temp0.prim
dawncut 0 0 -1 2200 ${FILE_TAG}_endcapN_temp0.prim ${FILE_TAG}_endcapN.prim
../../bin/dawn_tweak --mag 5 --draw 3 --theta 180 --phi 0
dawn -d ${FILE_TAG}_endcapN.prim
ps2pdf ${FILE_TAG}_endcapN.eps ${FILE_TAG}_endcapN_full.pdf
gs -o ${FILE_TAG}_endcapN.pdf -sDEVICE=pdfwrite \
-c "[/CropBox [50 170 550 670] /PAGES pdfmark" \
-f ${FILE_TAG}_endcapN_full.pdf
pdftoppm ${FILE_TAG}_endcapN.pdf ${FILE_TAG}_endcapN -png -singlefile -cropbox -thinlinemode solid \
-aaVector yes -r 1200
convert -pointsize 180 -fill black -draw "text 200,200 \"$NMOD1 Crystals\"" \
${FILE_TAG}_endcapN.png ${FILE_TAG}_endcapN.png
convert -pointsize 180 -fill black -draw "text 200,400 \"$NMOD2 Glasses\"" \
${FILE_TAG}_endcapN.png ${FILE_TAG}_endcapN.png
1.34392e+07
0
0
1
0
0
491.1
1.2
5
0.001
0
1
1
1
0.5
0.5
0.5
19
71
0.01
0.01
0.01
3
70
0.01
1
1
1
evince
0
0
1.34392e+07
0
180
0
0
0
0
8.6
1
0.001
0
1
1
1
0.5
0.5
0.5
19
71
0.01
0.01
0.01
3
70
0.01
1
1
1
evince
0
0
......@@ -59,6 +59,7 @@ INPUT_FILE=${FILE_TAG}_input.prim
# units are mm
dawncut 0 0 -1 1 ${INPUT_FILE} ${FILE_TAG}a_temp0.prim
dawncut 0 0 1 1 ${FILE_TAG}a_temp0.prim ${FILE_TAG}a.prim
../../bin/dawn_tweak --mag 14
dawn -d ${FILE_TAG}a.prim
ps2pdf ${FILE_TAG}a.eps ${FILE_TAG}a_full.pdf
gs -o ${FILE_TAG}a.pdf -sDEVICE=pdfwrite \
......@@ -69,6 +70,7 @@ pdftoppm ${FILE_TAG}a.pdf ${FILE_TAG}a -png -singlefile -cropbox
#SiTracker Endcap layer 5 zstart = 860mm ( 90 mm thick )
dawncut 0 0 1 945 ${INPUT_FILE} ${FILE_TAG}b_temp0.prim
dawncut 0 0 -1 -865 ${FILE_TAG}b_temp0.prim ${FILE_TAG}b.prim
../../bin/dawn_tweak --mag 14
dawn -d ${FILE_TAG}b.prim
ps2pdf ${FILE_TAG}b.eps ${FILE_TAG}b_full.pdf
gs -o ${FILE_TAG}b.pdf -sDEVICE=pdfwrite \
......@@ -79,6 +81,7 @@ pdftoppm ${FILE_TAG}b.pdf ${FILE_TAG}b -png -singlefile -cropbox
#SiTracker Endcap layer 4 zstart = 695mm ( 90 mm thick )
dawncut 0 0 1 780 ${INPUT_FILE} ${FILE_TAG}c_temp0.prim
dawncut 0 0 -1 -700 ${FILE_TAG}c_temp0.prim ${FILE_TAG}c.prim
../../bin/dawn_tweak --mag 14
dawn -d ${FILE_TAG}c.prim
ps2pdf ${FILE_TAG}c.eps ${FILE_TAG}c_full.pdf
gs -o ${FILE_TAG}c.pdf -sDEVICE=pdfwrite \
......@@ -101,6 +104,7 @@ pdftoppm ${FILE_TAG}d.pdf ${FILE_TAG}d -png -singlefile -cropbox
# slice at z = -2m
dawncut 0 0 1 430 ${INPUT_FILE} ${FILE_TAG}e_temp0.prim
dawncut 0 0 -1 -370 ${FILE_TAG}e_temp0.prim ${FILE_TAG}e.prim
../../bin/dawn_tweak --mag 14
dawn -d ${FILE_TAG}e.prim
ps2pdf ${FILE_TAG}e.eps ${FILE_TAG}e_full.pdf
gs -o ${FILE_TAG}e.pdf -sDEVICE=pdfwrite \
......@@ -111,6 +115,7 @@ pdftoppm ${FILE_TAG}e.pdf ${FILE_TAG}e -png -singlefile -cropbox
#SiTracker Endcap layer 1 zstart = 200mm ( 30 mm thick )
dawncut 0 0 1 225 ${INPUT_FILE} ${FILE_TAG}f_temp0.prim
dawncut 0 0 -1 205 ${FILE_TAG}f_temp0.prim ${FILE_TAG}f.prim
../../bin/dawn_tweak --mag 14
dawn -d ${FILE_TAG}f.prim
ps2pdf ${FILE_TAG}f.eps ${FILE_TAG}f_full.pdf
gs -o ${FILE_TAG}f.pdf -sDEVICE=pdfwrite \
......
/** \addtogroup PID
* \brief Type: **Barrel bar detector (think DIRC) with longitudinal frame**.
* \author S. Joosten
*
* \ingroup PID
*
*
* \code
* \endcode
*
* @{
*/
#include "DD4hep/DetFactoryHelper.h"
#include "DD4hep/Printout.h"
#include "DD4hep/Shapes.h"
#include "DDRec/DetectorData.h"
#include "DDRec/Surface.h"
#include "XML/Layering.h"
#include <array>
using namespace std;
using namespace dd4hep;
/** Barrel Bar detector with optional framek
*
* - Optional "frame" tag within the module element (frame eats part of the module width
* and is longitudinal at both sides)
* - Detector is setup as a "tracker" so we can use the hits to perform fast MC
* for e.g. the DIRC
*
*/
static Ref_t create_BarrelBarDetectorWithSideFrame(Detector& description, xml_h e, SensitiveDetector sens)
{
typedef vector<PlacedVolume> Placements;
xml_det_t x_det = e;
Material air = description.air();
int det_id = x_det.id();
string det_name = x_det.nameStr();
DetElement sdet(det_name, det_id);
map<string, Volume> volumes;
map<string, Placements> sensitives;
map<string, std::vector<rec::VolPlane>> volplane_surfaces;
PlacedVolume pv;
dd4hep::xml::Dimension dimensions(x_det.dimensions());
xml_dim_t dirc_pos = x_det.position();
map<string, std::array<double, 2>> module_thicknesses;
Tube topVolumeShape(dimensions.rmin(), dimensions.rmax(), dimensions.length() * 0.5);
Volume assembly(det_name, topVolumeShape, air);
sens.setType("tracker");
// loop over the modules
for (xml_coll_t mi(x_det, _U(module)); mi; ++mi) {
xml_comp_t x_mod = mi;
string m_nam = x_mod.nameStr();
if (volumes.find(m_nam) != volumes.end()) {
printout(ERROR, "BarrelBarDetectorWithSideFrame",
string((string("Module with named ") + m_nam + string(" already exists."))).c_str());
throw runtime_error("Logics error in building modules.");
}
int ncomponents = 0;
int sensor_number = 1;
double total_thickness = 0;
// Compute module total thickness from components
xml_coll_t ci(x_mod, _U(module_component));
for (ci.reset(), total_thickness = 0.0; ci; ++ci) {
total_thickness += xml_comp_t(ci).thickness();
}
// the module assembly volume
Assembly m_vol(m_nam);
volumes[m_nam] = m_vol;
m_vol.setVisAttributes(description, x_mod.visStr());
// Optional module frame.
// frame is 2 longitudinal bars at the side of the module
//
// |___| <-- example module cross section (x-y plane), frame is flush with the
// bottom of the module and protrudes on the top if needed
//
// Get frame width, as it impacts the main module for being built. We
// construct the actual frame structure later (once we know the module width)
double frame_width = 0;
if (x_mod.hasChild("frame")) {
xml_comp_t m_frame = x_mod.child(_U(frame));
frame_width = m_frame.width();
}
double thickness_so_far = 0.0;
double thickness_sum = -total_thickness / 2.0;
double max_component_width = 0;
for (xml_coll_t ci(x_mod, _U(module_component)); ci; ++ci, ++ncomponents) {
xml_comp_t x_comp = ci;
xml_comp_t x_pos = x_comp.position(false);
string c_nam = _toString(ncomponents, "component%d");
double box_width = x_comp.width() - 2 * frame_width;
max_component_width = fmax(max_component_width, box_width);
Box c_box{box_width / 2, x_comp.length() / 2, x_comp.thickness() / 2};
Volume c_vol{c_nam, c_box, description.material(x_comp.materialStr())};
pv = m_vol.placeVolume(c_vol, Position(0, 0, thickness_sum + x_comp.thickness() / 2.0));
c_vol.setRegion(description, x_comp.regionStr());
c_vol.setLimitSet(description, x_comp.limitsStr());
c_vol.setVisAttributes(description, x_comp.visStr());
if (x_comp.isSensitive()) {
c_vol.setSensitiveDetector(sens);
sensitives[m_nam].push_back(pv);
module_thicknesses[m_nam] = {thickness_so_far + x_comp.thickness() / 2.0,
total_thickness - thickness_so_far - x_comp.thickness() / 2.0};
// -------- create a measurement plane for the tracking surface attched to the sensitive volume -----
rec::Vector3D u(0., 1., 0.);
rec::Vector3D v(0., 0., 1.);
rec::Vector3D n(1., 0., 0.);
// compute the inner and outer thicknesses that need to be assigned to the tracking surface
// depending on wether the support is above or below the sensor
double inner_thickness = module_thicknesses[m_nam][0];
double outer_thickness = module_thicknesses[m_nam][1];
rec::SurfaceType type(rec::SurfaceType::Sensitive);
rec::VolPlane surf(c_vol, type, inner_thickness, outer_thickness, u, v, n); //,o ) ;
volplane_surfaces[m_nam].push_back(surf);
}
thickness_sum += x_comp.thickness();
thickness_so_far += x_comp.thickness();
}
// Now add-on the frame
if (x_mod.hasChild("frame")) {
xml_comp_t m_frame = x_mod.child(_U(frame));
double frame_thickness = getAttrOrDefault<double>(m_frame, _U(thickness), total_thickness);
Box lframe_box{m_frame.width() / 2., m_frame.length() / 2., frame_thickness / 2.};
Box rframe_box{m_frame.width() / 2., m_frame.length() / 2., frame_thickness / 2.};
// Keep track of frame with so we can adjust the module bars appropriately
Volume lframe_vol{"left_frame", lframe_box, description.material(m_frame.materialStr())};
Volume rframe_vol{"right_frame", rframe_box, description.material(m_frame.materialStr())};
lframe_vol.setVisAttributes(description, m_frame.visStr());
rframe_vol.setVisAttributes(description, m_frame.visStr());
m_vol.placeVolume(lframe_vol, Position(frame_width / 2. + max_component_width / 2, 0.,
frame_thickness / 2. - total_thickness / 2.0));
m_vol.placeVolume(rframe_vol, Position(-frame_width / 2. - max_component_width / 2, 0.,
frame_thickness / 2. - total_thickness / 2.0));
}
}
// now build the layers
for (xml_coll_t li(x_det, _U(layer)); li; ++li) {
xml_comp_t x_layer = li;
xml_comp_t x_barrel = x_layer.child(_U(barrel_envelope));
xml_comp_t x_layout = x_layer.child(_U(rphi_layout));
xml_comp_t z_layout = x_layer.child(_U(z_layout)); // Get the <z_layout> element.
int lay_id = x_layer.id();
string m_nam = x_layer.moduleStr();
string lay_nam = _toString(x_layer.id(), "layer%d");
Tube lay_tub(x_barrel.inner_r(), x_barrel.outer_r(), x_barrel.z_length() / 2.0);
Volume lay_vol(lay_nam, lay_tub, air); // Create the layer envelope volume.
lay_vol.setVisAttributes(description, x_layer.visStr());
double phi0 = x_layout.phi0(); // Starting phi of first module.
double phi_tilt = x_layout.phi_tilt(); // Phi tilt of a module.
double rc = x_layout.rc(); // Radius of the module center.
int nphi = x_layout.nphi(); // Number of modules in phi.
double rphi_dr = x_layout.dr(); // The delta radius of every other module.
double phi_incr = (M_PI * 2) / nphi; // Phi increment for one module.
double phic = phi0; // Phi of the module center.
double z0 = z_layout.z0(); // Z position of first module in phi.
double nz = z_layout.nz(); // Number of modules to place in z.
double z_dr = z_layout.dr(); // Radial displacement parameter, of every other module.
Volume module_env = volumes[m_nam];
DetElement lay_elt(sdet, _toString(x_layer.id(), "layer%d"), lay_id);
Placements& sensVols = sensitives[m_nam];
// Z increment for module placement along Z axis.
// Adjust for z0 at center of module rather than
// the end of cylindrical envelope.
double z_incr = nz > 1 ? (2.0 * z0) / (nz - 1) : 0.0;
// Starting z for module placement along Z axis.
double module_z = -z0;
int module = 1;
// Loop over the number of modules in phi.
for (int ii = 0; ii < nphi; ii++) {
double dx = z_dr * std::cos(phic + phi_tilt); // Delta x of module position.
double dy = z_dr * std::sin(phic + phi_tilt); // Delta y of module position.
double x = rc * std::cos(phic); // Basic x module position.
double y = rc * std::sin(phic); // Basic y module position.
// Loop over the number of modules in z.
for (int j = 0; j < nz; j++) {
string module_name = _toString(module, "module%d");
DetElement mod_elt(lay_elt, module_name, module);
Transform3D tr(RotationZYX(0, ((M_PI / 2) - phic - phi_tilt), -M_PI / 2), Position(x, y, module_z));
pv = lay_vol.placeVolume(module_env, tr);
pv.addPhysVolID("module", module);
pv.addPhysVolID("section", j);
mod_elt.setPlacement(pv);
for (size_t ic = 0; ic < sensVols.size(); ++ic) {
PlacedVolume sens_pv = sensVols[ic];
DetElement comp_de(mod_elt, std::string("de_") + sens_pv.volume().name(), module);
comp_de.setPlacement(sens_pv);
rec::volSurfaceList(comp_de)->push_back(volplane_surfaces[m_nam][ic]);
}
/// Increase counters etc.
module++;
// Adjust the x and y coordinates of the module.
x += dx;
y += dy;
// Flip sign of x and y adjustments.
dx *= -1;
dy *= -1;
// Add z increment to get next z placement pos.
module_z += z_incr;
}
phic += phi_incr; // Increment the phi placement of module.
rc += rphi_dr; // Increment the center radius according to dr parameter.
rphi_dr *= -1; // Flip sign of dr parameter.
module_z = -z0; // Reset the Z placement parameter for module.
}
// Create the PhysicalVolume for the layer.
pv = assembly.placeVolume(lay_vol); // Place layer in mother
pv.addPhysVolID("layer", lay_id); // Set the layer ID.
lay_elt.setAttributes(description, lay_vol, x_layer.regionStr(), x_layer.limitsStr(), x_layer.visStr());
lay_elt.setPlacement(pv);
}
sdet.setAttributes(description, assembly, x_det.regionStr(), x_det.limitsStr(), x_det.visStr());
assembly.setVisAttributes(description.invisible());
pv = description.pickMotherVolume(sdet).placeVolume(assembly, Position(0, 0, dirc_pos.z()));
pv.addPhysVolID("system", det_id); // Set the subdetector system ID.
sdet.setPlacement(pv);
return sdet;
}
//@}
// clang-format off
DECLARE_DETELEMENT(BarrelBarDetectorWithSideFrame, create_BarrelBarDetectorWithSideFrame)
DECLARE_DETELEMENT(athena_FakeDIRC, create_BarrelBarDetectorWithSideFrame)