Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert granularity #771

Merged
merged 33 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3e8404d
Update forward_insert.xml
sebouh137 Aug 20, 2024
d838546
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 20, 2024
cbd796c
Update forward_insert.xml
sebouh137 Aug 20, 2024
8d9c2ef
Update InsertCalorimeter_geo.cpp
sebouh137 Aug 20, 2024
6057919
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 20, 2024
5042998
Update forward_insert.xml
sebouh137 Aug 20, 2024
1fcbc36
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 20, 2024
8211aed
Update InsertCalorimeter_geo.cpp
sebouh137 Aug 20, 2024
c83af09
Update InsertCalorimeter_geo.cpp
sebouh137 Aug 20, 2024
e480086
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 20, 2024
24708f4
Update InsertCalorimeter_geo.cpp
sebouh137 Aug 20, 2024
401440a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 20, 2024
effcf93
Update forward_insert.xml
sebouh137 Aug 20, 2024
2f16451
Update InsertCalorimeter_geo.cpp
sebouh137 Aug 20, 2024
44e1912
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 20, 2024
386029f
Update forward_insert_homogeneous.xml
sebouh137 Aug 20, 2024
78a87a4
Update InsertCalorimeter_geo.cpp
sebouh137 Aug 21, 2024
3ba7d8a
Update forward_insert.xml
sebouh137 Aug 21, 2024
3b2e54e
updated the segmentations to update what I have in my layouts. note: …
sebouh137 Aug 21, 2024
0b1b090
include a gap between the edge of the PCB and the corners of the hexa…
sebouh137 Aug 22, 2024
b3a6a6f
Merge branch 'main' into insert_multiseg
sebouh137 Aug 22, 2024
821b11c
removed front plate of insert
sebouh137 Aug 22, 2024
20cf60a
Merge branch 'insert_multiseg' of https://github.com/eic/epic into in…
sebouh137 Aug 22, 2024
96ba413
changed number of hg layers from 20 to 16
sebouh137 Aug 22, 2024
ae3102b
changed number of hg layers from 20 to 16
sebouh137 Aug 22, 2024
0684e3e
Update compact/hcal/forward_insert.xml
sebouh137 Aug 24, 2024
b9275b7
Update compact/hcal/forward_insert.xml
sebouh137 Aug 24, 2024
0ae4099
Update compact/hcal/forward_insert.xml
sebouh137 Aug 24, 2024
0a28d1d
Update compact/hcal/forward_insert.xml
sebouh137 Aug 24, 2024
df4a0e5
Update forward_insert.xml
sebouh137 Aug 24, 2024
34483a4
Update forward_insert_homogeneous.xml
sebouh137 Aug 24, 2024
0e9d93c
Update InsertCalorimeter_geo.cpp
sebouh137 Aug 24, 2024
6464ff2
Merge branch 'main' into insert_multiseg
sebouh137 Aug 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compact/definitions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,8 @@ Service gaps in FW direction (before endcapP ECAL) and BW direction (before endc
<constant name="HcalEndcapPInsert_zmin" value="EcalEndcapP_zmin + EcalEndcapP_length"/>
<constant name="HcalEndcapPInsert_length" value="134.75*cm"/>
<constant name="HcalEndcapPInsert_zmax" value="HcalEndcapPInsert_zmin + HcalEndcapPInsert_length"/>
<constant name="HcalEndcapPInsert_width" value="59.6*cm"/>
<constant name="HcalEndcapPInsert_height" value="59.7485*cm"/>
<constant name="HcalEndcapPInsert_width" value="59.26*cm"/>
<constant name="HcalEndcapPInsert_height" value="59.29*cm"/>
<constant name="HcalEndcapPInsert_xposition" value="EcalEndcapPInsert_xposition"/>
<constant name="HcalEndcapPInsert_yposition" value="EcalEndcapPInsert_yposition"/>

Expand Down
3 changes: 2 additions & 1 deletion compact/ecal/forward_insert_homogeneous.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
final_hole_x="EcalEndcapPInsert_hole_xposition"
initial_hole_y="EcalEndcapPInsert_hole_yposition"
final_hole_y="EcalEndcapPInsert_hole_yposition"
left_right_gap="0.38*cm"
/>
</detector>
</detectors>
Expand All @@ -99,7 +100,7 @@
grid_size_x="24.925*mm"
grid_size_y="24.65*mm"
/>
<id>system:8,barrel:3,module:4,layer:8,slice:5,x:32:-16,y:-16</id>
<id>system:8,barrel:3,module:4,layer:7,side:1,slice:5,x:32:-16,y:-16</id>
sebouh137 marked this conversation as resolved.
Show resolved Hide resolved
</readout>

</readouts>
Expand Down
93 changes: 70 additions & 23 deletions compact/hcal/forward_insert.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@
<constant name="HcalEndcapPInsertESRFoilThickness" value="0.015*cm"/>

<constant name="LFHCAL_FrontWallThickness" value="1.50*cm"/>
<documentation>
#### Cell Sizes
</documentation>
<constant name="HcalEndcapPInsertCellSizeHG" value="2.16*cm"/>
<constant name="HcalEndcapPInsertCellSizeLGLeft" value="2.84*cm"/>
<constant name="HcalEndcapPInsertCellSizeLGRight" value="3.1*cm"/>
<documentation>
#### Transverse offsets of cells
</documentation>
<constant name="HcalEndcapPInsertCellToPCBEdge" value="0.04*cm"/>
<constant name="HcalEndcapPInsertOffsetXHGRight" value="-HcalEndcapPInsert_width/2.+HcalEndcapPInsertCellToPCBEdge-HcalEndcapPInsertCellSizeHG*0.25"/>
<constant name="HcalEndcapPInsertOffsetYHGRight" value="HcalEndcapPInsertCellSizeHG*sqrt(3)/2*0"/>
<constant name="HcalEndcapPInsertOffsetXHGLeft" value="HcalEndcapPInsert_width/2.-HcalEndcapPInsertCellToPCBEdge-HcalEndcapPInsertCellSizeHG*0"/>
<constant name="HcalEndcapPInsertOffsetYHGLeft" value="HcalEndcapPInsertCellSizeHG*sqrt(3)/2*0"/>
<constant name="HcalEndcapPInsertOffsetXLGRight" value="-HcalEndcapPInsert_width/2.+HcalEndcapPInsertCellToPCBEdge-HcalEndcapPInsertCellSizeLGRight*0.5"/>
<constant name="HcalEndcapPInsertOffsetYLGRight" value="HcalEndcapPInsertCellSizeLGRight*0*sqrt(3)/2"/>
<constant name="HcalEndcapPInsertOffsetXLGLeft" value="HcalEndcapPInsert_width/2.-HcalEndcapPInsertCellToPCBEdge+HcalEndcapPInsertCellSizeLGLeft*0.5"/>
<constant name="HcalEndcapPInsertOffsetYLGLeft" value="HcalEndcapPInsertCellSizeLGLeft*0*sqrt(3)/2"/>
sebouh137 marked this conversation as resolved.
Show resolved Hide resolved

<documentation>
- Insert N Layers and computed Thickness
Expand All @@ -49,15 +67,15 @@
HcalEndcapPInsertAirThickness "
/>
<constant name="HcalEndcapPInsertBackplateThickness" value="HcalEndcapPInsertAbsorberThickness"/>
<constant name="HcalEndcapPInsertLayer_NSteelRepeat" value="64"/>
<constant name="HcalEndcapPInsertLayer_NSteelRepeat" value="60"/>
</define>

<detectors>
<documentation>
### Forward (Positive Z) Endcap Insert for Hadronic Calorimeter
Insert goes in the middle of the forward endcap HCal -- around the beampipe

Insert is 1 front layer of Steel/Sc + 64 layers of Steel/Sc + 1 backplate of steel
Insert is 60 layers of Steel/Sc + 1 backplate of steel
Each of the layers (sans backplate) includes air gaps (front and back of each layer),
ESR foil (front and back of scintillator), a PCB, and an aluminum scitnillator cover

Expand All @@ -73,6 +91,7 @@
vis="HcalEndcapInsertVis"
readout="HcalEndcapPInsertHits"
calorimeterType="HAD_ENDCAP"
left_right_gap="0.38*cm"
>
<position x="HcalEndcapPInsert_xposition" y="HcalEndcapPInsert_yposition" z="HcalEndcapPInsert_zmin"/>
<dimensions
Expand All @@ -81,18 +100,6 @@
z="HcalEndcapPInsert_length"
/>
<backplate thickness="HcalEndcapPInsertBackplateThickness"/>
<comment> Front layer to match front walls of LFHCAL modules </comment>
<comment> Slices will be ordered according to the slice order listed here </comment>
<layer repeat="1" thickness="HcalEndcapPInsertFrontLayerThickness" vis="InvisibleWithDaughters">
<slice material="Steel235" thickness="LFHCAL_FrontWallThickness" vis="LFHCAL8MModVis" />
<slice material="Air" thickness="HcalEndcapPInsertAirThickness"/>
<slice material="Aluminum" thickness="HcalEndcapPInsertScintillatorCoverThickness" vis="AnlProcess_Blue"/>
<slice material="Polystyrene" thickness="HcalEndcapPInsertESRFoilThickness" vis="AnlGray"/>
<slice material="Polystyrene" thickness="HcalEndcapPInsertPolystyreneThickness" sensitive="true" limits="cal_limits" vis="AnlLightGray"/>
<slice material="Polystyrene" thickness="HcalEndcapPInsertESRFoilThickness" vis="AnlGray"/>
<slice material="Fr4" thickness="HcalEndcapPInsertPCBThickness"/>
<slice material="Air" thickness="HcalEndcapPInsertAirThickness"/>
</layer>
<comment> Steel/Sc layers </comment>
<layer repeat="HcalEndcapPInsertLayer_NSteelRepeat" thickness="HcalEndcapPInsertSingleLayerThickness" vis="InvisibleWithDaughters">
<slice material="Steel235" thickness="HcalEndcapPInsertAbsorberThickness" vis="LFHCAL8MModVis"/>
Expand Down Expand Up @@ -128,21 +135,61 @@

<readouts>
<documentation>
Readout is segmented into hexagons with sides of 1.889 cm
The hexagons positions cycle through four sets of layer configurations ("H4 staggering")
Readout is segmented into hexagons with sides of 2.16 cm, 2.84 cm, and 3.10 cm in the high-granularity upstream section (layers 1-16, for both left and right sides),
the left downstream section (layers 17-60), and the right downstream section (layers 17-60), respectively.
The hexagons positions in the first 16 layers cycle through four sets of layer configurations ("H4 staggering")
i.e. hexagons in layers 1-4 (5-8, ...) are all offset transversely from each other
with the centers of the cells of one layer being at the midpoints of the edges of the cells in
the other layers
the other layers.

Staggering defined in https://github.com/AIDASoft/DD4hep/blob/1962f7d1ace4484efb8886d66a6759a83c5107a3/DDCore/include/DDSegmentation/HexGrid.h#L112-L114
and https://github.com/AIDASoft/DD4hep/blob/1962f7d1ace4484efb8886d66a6759a83c5107a3/DDCore/src/segmentations/HexGrid.cpp#L102-L120
</documentation>
<readout name="HcalEndcapPInsertHits">
<segmentation
type="HexGrid"
side_length="1.889*cm"
stagger="2"
/>
<id>system:8,layer:8,slice:8,x:32:-16,y:-16</id>
<segmentation type="MultiSegmentation" key="layer">
<segmentation name="insert_hg" type="MultiSegmentation" key="side" key_min="1" key_max="16">
<segmentation
name="insert_hg_left"
type="HexGrid"
side_length="HcalEndcapPInsertCellSizeHG"
stagger="2"
key_value="1"
offset_x="HcalEndcapPInsertOffsetXHGLeft"
offset_y="HcalEndcapPInsertOffsetYHGLeft"
/>
<segmentation
name="insert_hg_right"
type="HexGrid"
side_length="HcalEndcapPInsertCellSizeHG"
stagger="2"
key_value="0"
offset_x="HcalEndcapPInsertOffsetXHGRight"
offset_y="HcalEndcapPInsertOffsetYHGRight"
/>
</segmentation>
<segmentation name="insert_lg" type="MultiSegmentation" key="side" key_min="17" key_max="60">
<segmentation
name="insert_lg_left"
type="HexGrid"
side_length="HcalEndcapPInsertCellSizeLGLeft"
stagger="0"
key_value="1"
offset_x="HcalEndcapPInsertOffsetXLGLeft"
offset_y="HcalEndcapPInsertOffsetYLGLeft"
/>
<segmentation
name="insert_lg_right"
type="HexGrid"
side_length="HcalEndcapPInsertCellSizeLGRight"
stagger="0"
key_value="0"
offset_x="HcalEndcapPInsertOffsetXLGRight"
offset_y="HcalEndcapPInsertOffsetYLGRight"
/>
</segmentation>
</segmentation>

<id>system:8,side:1,layer:8,slice:7,x:32:-16,y:-16</id>
</readout>

</readouts>
Expand Down
180 changes: 98 additions & 82 deletions src/InsertCalorimeter_geo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ static Ref_t createDetector(Detector& desc, xml_h handle, SensitiveDetector sens
pos.y();
const std::pair<double, double> hole_y_parameters(hole_y_initial, hole_y_final);

const double left_right_gap =
dd4hep::getAttrOrDefault<double>(detElem, _Unicode(left_right_gap), 0.38 * cm);
// Getting thickness of backplate
/*
The hole radius & position is determined by liner interpolation
Expand Down Expand Up @@ -100,93 +102,107 @@ static Ref_t createDetector(Detector& desc, xml_h handle, SensitiveDetector sens
// FIXME Workaround for https://github.com/eic/epic/issues/411
assembly.setVisAttributes(desc.visAttributes("InvisibleWithDaughters"));
PlacedVolume pv;

// Keeps track of the z location as we move longiduinally through the insert
// Will use this tracking variable as input to get_hole_rxy
double z_distance_traversed = 0.;

int layer_num = 1;

// Looping through all the different layer sections (W/Sc, Steel/Sc, backplate)
for (xml_coll_t c(detElem, _U(layer)); c; c++) {
xml_comp_t x_layer = c;
int repeat = x_layer.repeat();
double layer_thickness = x_layer.thickness();

// Looping through the number of repeated layers in each section
for (int i = 0; i < repeat; i++) {
std::string layer_name = detName + _toString(layer_num, "_layer%d");
Box layer(width / 2., height / 2., layer_thickness / 2.);

// Hole radius and position for each layer is determined from z position at the front of the layer
const auto hole_rxy = get_hole_rxy(z_distance_traversed);
double hole_r = std::get<0>(hole_rxy);
double hole_x = std::get<1>(hole_rxy);
double hole_y = std::get<2>(hole_rxy);

// Removing beampipe shape from each layer
Tube layer_hole(0., hole_r, layer_thickness / 2.);
SubtractionSolid layer_with_hole(layer, layer_hole, Position(hole_x, hole_y, 0.));
Volume layer_vol(layer_name, layer_with_hole, air);

int slice_num = 1;
double slice_z = -layer_thickness / 2.; // Keeps track of slices' z locations in each layer

// Looping over each layer's slices
for (xml_coll_t l(x_layer, _U(slice)); l; l++) {
xml_comp_t x_slice = l;
double slice_thickness = x_slice.thickness();
std::string slice_name = layer_name + _toString(slice_num, "slice%d");
Material slice_mat = desc.material(x_slice.materialStr());
slice_z += slice_thickness / 2.; // Going to slice halfway point

// Each slice within a layer has the same hole radius and x-y position
Box slice(width / 2., height / 2., slice_thickness / 2.);
Tube slice_hole(0., hole_r, slice_thickness / 2.);
SubtractionSolid slice_with_hole(slice, slice_hole, Position(hole_x, hole_y, 0.));
Volume slice_vol(slice_name, slice_with_hole, slice_mat);

// Setting appropriate slices as sensitive
if (x_slice.isSensitive()) {
sens.setType("calorimeter");
slice_vol.setSensitiveDetector(sens);
for (int side_num = 0; side_num < 2; side_num++) { // 0 = right, 1 = left
std::string side_name = side_num == 1 ? "L" : "R";
// Keeps track of the z location as we move longiduinally through the insert
// Will use this tracking variable as input to get_hole_rxy
double z_distance_traversed = 0.;

int layer_num = 1;

// Looping through all the different layer sections (W/Sc, Steel/Sc, backplate)
for (xml_coll_t c(detElem, _U(layer)); c; c++) {
xml_comp_t x_layer = c;
int repeat = x_layer.repeat();
double layer_thickness = x_layer.thickness();

// Looping through the number of repeated layers in each section
for (int i = 0; i < repeat; i++) {
std::string layer_name = detName + _toString(layer_num, "_layer%d") + "_" + side_name;
Box layer(width / 2., height / 2., layer_thickness / 2.);

// Hole radius and position for each layer is determined from z position at the front of the layer
const auto hole_rxy = get_hole_rxy(z_distance_traversed);
double hole_r = std::get<0>(hole_rxy);
double hole_x = std::get<1>(hole_rxy);
double hole_y = std::get<2>(hole_rxy);

// Removing beampipe shape from each layer
Tube layer_hole(0., hole_r, layer_thickness / 2.);
SubtractionSolid layer_with_hole(layer, layer_hole, Position(hole_x, hole_y, 0.));
// Only select the left or right side of the layer
Box side_cut(width / 2., height, layer_thickness);
Position side_cut_position((width / 2 - left_right_gap / 2) * (1 - 2 * side_num) - pos.x(),
0, 0);
SubtractionSolid layer_side_with_hole(layer_with_hole, side_cut, side_cut_position);
Volume layer_vol(layer_name, layer_side_with_hole, air);

int slice_num = 1;
double slice_z = -layer_thickness / 2.; // Keeps track of slices' z locations in each layer

// Looping over each layer's slices
for (xml_coll_t l(x_layer, _U(slice)); l; l++) {
xml_comp_t x_slice = l;
double slice_thickness = x_slice.thickness();
std::string slice_name = layer_name + _toString(slice_num, "slice%d");
Material slice_mat = desc.material(x_slice.materialStr());
slice_z += slice_thickness / 2.; // Going to slice halfway point

// Each slice within a layer has the same hole radius and x-y position
Box slice(width / 2., height / 2., slice_thickness / 2.);
Tube slice_hole(0., hole_r, slice_thickness / 2.);
SubtractionSolid slice_with_hole(slice, slice_hole, Position(hole_x, hole_y, 0.));
Box side_cut_slice(width / 2., height, layer_thickness);
Position side_cut_position_slice(
(width / 2 - left_right_gap / 2) * (1 - 2 * side_num) - pos.x(), 0, 0);
SubtractionSolid slice_side_with_hole(slice_with_hole, side_cut_slice,
side_cut_position_slice);
Volume slice_vol(slice_name, slice_side_with_hole, slice_mat);

// Setting appropriate slices as sensitive
if (x_slice.isSensitive()) {
sens.setType("calorimeter");
slice_vol.setSensitiveDetector(sens);
}

// Setting slice attributes
slice_vol.setAttributes(desc, x_slice.regionStr(), x_slice.limitsStr(), x_slice.visStr());

// Placing slice within layer
pv = layer_vol.placeVolume(slice_vol,
Transform3D(RotationZYX(0, 0, 0), Position(0., 0., slice_z)));
pv.addPhysVolID("slice", slice_num);
pv.addPhysVolID("side", side_num);
slice_z += slice_thickness / 2.;
z_distance_traversed += slice_thickness;
slice_num++;
}

// Setting slice attributes
slice_vol.setAttributes(desc, x_slice.regionStr(), x_slice.limitsStr(), x_slice.visStr());

// Placing slice within layer
pv = layer_vol.placeVolume(slice_vol,
Transform3D(RotationZYX(0, 0, 0), Position(0., 0., slice_z)));
pv.addPhysVolID("slice", slice_num);
slice_z += slice_thickness / 2.;
z_distance_traversed += slice_thickness;
slice_num++;
// Setting layer attributes
layer_vol.setAttributes(desc, x_layer.regionStr(), x_layer.limitsStr(), x_layer.visStr());
/*
Placing each layer inside assembly
-length/2. is front of detector in global coordinate system
+ (z_distance_traversed - layer_thickness) goes to the front of each layer
+ layer_thickness/2. places layer in correct spot
Example: After placement of slices in first layer, z_distance_traversed = layer_thickness
Subtracting layer_thickness goes back to the front of the first slice (Now, z = -length/2)
Adding layer_thickness / 2. goes to half the first layer thickness (proper place to put layer)
Each loop over repeat will increases z_distance_traversed by layer_thickness
*/
pv = assembly.placeVolume(
layer_vol,
Transform3D(RotationZYX(0, 0, 0),
Position(0., 0.,
-length / 2. + (z_distance_traversed - layer_thickness) +
layer_thickness / 2.)));

pv.addPhysVolID("layer", layer_num);
pv.addPhysVolID("side", side_num);
layer_num++;
}

// Setting layer attributes
layer_vol.setAttributes(desc, x_layer.regionStr(), x_layer.limitsStr(), x_layer.visStr());
/*
Placing each layer inside assembly
-length/2. is front of detector in global coordinate system
+ (z_distance_traversed - layer_thickness) goes to the front of each layer
+ layer_thickness/2. places layer in correct spot
Example: After placement of slices in first layer, z_distance_traversed = layer_thickness
Subtracting layer_thickness goes back to the front of the first slice (Now, z = -length/2)
Adding layer_thickness / 2. goes to half the first layer thickness (proper place to put layer)
Each loop over repeat will increases z_distance_traversed by layer_thickness
*/
pv = assembly.placeVolume(
layer_vol, Transform3D(RotationZYX(0, 0, 0),
Position(0., 0.,
-length / 2. + (z_distance_traversed - layer_thickness) +
layer_thickness / 2.)));

pv.addPhysVolID("layer", layer_num);
layer_num++;
}
}

DetElement det(detName, detID);
Volume motherVol = desc.pickMotherVolume(det);

Expand Down