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

backward_PbWO4: adjust geometry to match latest CAD design #815

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
48 changes: 27 additions & 21 deletions compact/ecal/backward_PbWO4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
** some existed parameters are passed from "difinition.xml"
</comment>
<constant name="EcalEndcapN_structure_Oring_length" value="EcalEndcapN_length"/>
<constant name="EcalEndcapN_inner_support_length" value="25.*cm"/>
<constant name="EcalEndcapN_inner_support_length" value="20.5*cm"/>
<constant name="EcalEndcapN_envelope_length" value="max(EcalEndcapN_inner_support_length, EcalEndcapN_crystalmodule_total_length)" />
<constant name="EcalEndcapN_structure_Oring_thickness" value="2.0*cm"/>
<constant name="EcalEndcapN_structure_Oring_thickness" value="0.979*cm"/><!-- Currently not based on CAD thickness, only adjusted to allow correct tower placement. -->
<constant name="EcalEndcapN_structure_Oring_max" value="65.00*cm"/>
<constant name="EcalEndcapN_structure_Oring_min" value="EcalEndcapN_structure_Oring_max - EcalEndcapN_structure_Oring_thickness"/>
<constant name="EcalEndcapN_Protate" value="15.*degree"/>
Expand Down Expand Up @@ -98,14 +98,12 @@
<comment>
A small `x_offset` here is set to avoid overlap with regular cell aligment.
</comment>
<inner_support_collar
electron_rmin="65 * mm"
electron_rmax="73 * mm"
proton_rmin="35 * mm"
proton_rmax="43 * mm"
<inner_support
electron_r="63.13 * mm"
proton_r="32.73 * mm"
z_length="EcalEndcapN_inner_support_length"
x_offset="-1 * mm"
proton_x_offset="64 * mm"
x_offset="0 * mm"
proton_x_offset="67.75 * mm"
material="Copper"
vis="AnlOrange"
/>
Expand All @@ -114,20 +112,28 @@
The points information for constructing inner supporting structure [extrudedpolygon shape, 12 points in total]
</comment>
<points_extrudedpolygon>
<position x="3 * EcalEndcapN_crystalmodule_total_width" y="3.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="3 * EcalEndcapN_crystalmodule_total_width" y="2.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="5 * EcalEndcapN_crystalmodule_total_width" y="2.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="5 * EcalEndcapN_crystalmodule_total_width" y="-2.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="3 * EcalEndcapN_crystalmodule_total_width" y="-2.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="3 * EcalEndcapN_crystalmodule_total_width" y="-3.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="-3 * EcalEndcapN_crystalmodule_total_width" y="-3.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="-3 * EcalEndcapN_crystalmodule_total_width" y="-2.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="-4 * EcalEndcapN_crystalmodule_total_width" y="-2.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="-4 * EcalEndcapN_crystalmodule_total_width" y="2.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="-3 * EcalEndcapN_crystalmodule_total_width" y="2.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="-3 * EcalEndcapN_crystalmodule_total_width" y="3.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="2.5 * EcalEndcapN_crystalmodule_total_width" y="3.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="2.5 * EcalEndcapN_crystalmodule_total_width" y="2.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="4.5 * EcalEndcapN_crystalmodule_total_width" y="2.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="4.5 * EcalEndcapN_crystalmodule_total_width" y="1.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="5.5 * EcalEndcapN_crystalmodule_total_width" y="1.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="5.5 * EcalEndcapN_crystalmodule_total_width" y="-1.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="4.5 * EcalEndcapN_crystalmodule_total_width" y="-1.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="4.5 * EcalEndcapN_crystalmodule_total_width" y="-2.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="2.5 * EcalEndcapN_crystalmodule_total_width" y="-2.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="2.5 * EcalEndcapN_crystalmodule_total_width" y="-3.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="-2.5 * EcalEndcapN_crystalmodule_total_width" y="-3.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="-2.5 * EcalEndcapN_crystalmodule_total_width" y="-2.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="-3.5 * EcalEndcapN_crystalmodule_total_width" y="-2.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="-3.5 * EcalEndcapN_crystalmodule_total_width" y="2.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="-2.5 * EcalEndcapN_crystalmodule_total_width" y="2.5 * EcalEndcapN_crystalmodule_total_width"/>
<position x="-2.5 * EcalEndcapN_crystalmodule_total_width" y="3.5 * EcalEndcapN_crystalmodule_total_width"/>
</points_extrudedpolygon>

<placement
x_offset="0 * mm"
y_offset="0 * mm"
/>
<module
modulex="EcalEndcapN_crystalmodule_total_width"
moduley="EcalEndcapN_crystalmodule_total_width"
Expand Down
94 changes: 52 additions & 42 deletions src/HomogeneousCalorimeter_geo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,56 +40,66 @@ template <class XmlComp> Position get_xml_xyz(XmlComp& comp, dd4hep::xml::Strng_
return pos;
}

static Volume inner_support_collar(Detector& desc, xml_comp_t handle) {
static Volume build_inner_support(Detector& desc, xml_comp_t handle,
xml_coll_t pts_extrudedpolygon) {
// This consists of two circular tubes joined by straight sections

Material inner_ring_material = desc.material(handle.materialStr());

double electron_rmin = handle.attr<double>(_Unicode(electron_rmin));
double electron_rmax = handle.attr<double>(_Unicode(electron_rmax));
double proton_rmin = handle.attr<double>(_Unicode(proton_rmin));
double proton_rmax = handle.attr<double>(_Unicode(proton_rmax));
double electron_r = handle.attr<double>(_Unicode(electron_r));
double proton_r = handle.attr<double>(_Unicode(proton_r));
double proton_x_offset = handle.attr<double>(_Unicode(proton_x_offset));
double z_length = handle.z_length();

double straight_section_tilt =
acos(((electron_rmax + electron_rmin) - (proton_rmax + proton_rmin)) / 2 / proton_x_offset);
double mean_radius = (electron_rmax + electron_rmin + proton_rmax + proton_rmin) / 4;
std::vector<double> pt_innerframe_x; //The points information for inner supporting frame
std::vector<double> pt_innerframe_y;
for (xml_coll_t position_i(pts_extrudedpolygon, _U(position)); position_i; ++position_i) {
xml_comp_t position_comp = position_i;
pt_innerframe_x.push_back((position_comp.x()));
pt_innerframe_y.push_back((position_comp.y()));
}

std::vector<double> sec_z = {-z_length / 2., z_length / 2.};
std::vector<double> sec_x = {0., 0.};
std::vector<double> sec_y = {0., 0.};
std::vector<double> zscale = {1., 1.};

ExtrudedPolygon inner_support_envelope(pt_innerframe_x, pt_innerframe_y, sec_z, sec_x, sec_y,
zscale);

double straight_section_tilt = acos((electron_r - proton_r) / proton_x_offset);
double straight_section_length =
proton_x_offset + (proton_r - electron_r) * cos(straight_section_tilt);
Position straight_section_offset{
proton_x_offset / 2 + cos(straight_section_tilt) * mean_radius,
sin(straight_section_tilt) * mean_radius,
0,
};
Position straight_section_offset_mirror_y{
straight_section_offset.x(),
-straight_section_offset.y(),
straight_section_offset.z(),
straight_section_length / 2 + cos(straight_section_tilt) * electron_r,
0.,
0.,
};

Tube electron_side{electron_rmin, electron_rmax, z_length / 2, straight_section_tilt,
-straight_section_tilt};
Tube proton_side{proton_rmin, proton_rmax, z_length / 2, -straight_section_tilt,
straight_section_tilt};
// use double length for cutout (any value larger than 1 would work)
double cutout_length = 2 * z_length;

Tube electron_side{0., electron_r, cutout_length / 2};
Tube proton_side{0., proton_r, cutout_length / 2};
Trd1 electron_proton_straight_section{
(electron_rmax - electron_rmin) / 2,
(proton_rmax - proton_rmin) / 2,
z_length / 2,
proton_x_offset * sin(straight_section_tilt) / 2,
electron_r * sin(straight_section_tilt),
proton_r * sin(straight_section_tilt),
cutout_length / 2,
straight_section_length / 2,
};
UnionSolid inner_support{
UnionSolid inner_support_hole{
UnionSolid{
UnionSolid{
electron_side,
proton_side,
Position{proton_x_offset, 0., 0.},
},
electron_proton_straight_section,
Transform3D{straight_section_offset} * RotationZ(straight_section_tilt) *
RotationX(90 * deg),
electron_side,
proton_side,
Position{proton_x_offset, 0., 0.},
},
electron_proton_straight_section,
Transform3D{straight_section_offset_mirror_y} * RotationZ(-straight_section_tilt) *
RotationX(-90 * deg),
Transform3D{straight_section_offset} * RotationZ(90 * deg) * RotationX(90 * deg),
};

SubtractionSolid inner_support{
inner_support_envelope,
inner_support_hole,
};

Volume inner_support_vol{"inner_support_vol", inner_support, inner_ring_material};
Expand Down Expand Up @@ -275,9 +285,8 @@ static std::tuple<int, std::pair<int, int>> add_12surface_disk(Detector& desc, A
double Innerb = plm.attr<double>(_Unicode(inneradiusb));
double phimin = dd4hep::getAttrOrDefault<double>(plm, _Unicode(phimin), 0.);
double phimax = dd4hep::getAttrOrDefault<double>(plm, _Unicode(phimax), 2. * M_PI);
xml_coll_t pts_extrudedpolygon(plm, _Unicode(points_extrudedpolygon));

std::vector<double> pt_innerframe_x; //The points information for inner supporting frame
std::vector<double> pt_innerframe_y;
double half_modx = modSize.x() * 0.5, half_mody = modSize.y() * 0.5;

//=========================================================
Expand Down Expand Up @@ -316,8 +325,8 @@ static std::tuple<int, std::pair<int, int>> add_12surface_disk(Detector& desc, A
env.placeVolume(env_vol, tr_global); // Place the mother volume for all modules
env.placeVolume(ring12_vol, tr_global_Oring); // Place the outer supporting frame

xml_comp_t collar_comp = plm.child(_Unicode(inner_support_collar));
Volume inner_support_vol = inner_support_collar(desc, collar_comp);
xml_comp_t collar_comp = plm.child(_Unicode(inner_support));
Volume inner_support_vol = build_inner_support(desc, collar_comp, pts_extrudedpolygon);
env_vol.placeVolume(inner_support_vol,
Transform3D{RotationZ{Nrot}} * Translation3D(collar_comp.x_offset(0.),
collar_comp.y_offset(0.),
Expand All @@ -328,8 +337,10 @@ static std::tuple<int, std::pair<int, int>> add_12surface_disk(Detector& desc, A
// Placing The Modules
//=====================================================================

auto points = epic::geo::fillRectangles({half_modx, 0.}, modSize.x(), modSize.y(), 0.,
(rmax / std::cos(Prot)), phimin, phimax);
xml_comp_t placement = plm.child(_Unicode(placement));
auto points =
epic::geo::fillRectangles({placement.x_offset(0.), placement.y_offset(0.)}, modSize.x(),
modSize.y(), 0., (rmax / std::cos(Prot)), phimin, phimax);

std::pair<double, double> c1(0., 0.);
auto polyVertex = epic::geo::getPolygonVertices(c1, (rmax / std::cos(Prot)), M_PI / 12., 12);
Expand All @@ -339,7 +350,6 @@ static std::tuple<int, std::pair<int, int>> add_12surface_disk(Detector& desc, A
out_vertices.push_back(a);
}

xml_coll_t pts_extrudedpolygon(plm, _Unicode(points_extrudedpolygon));
for (xml_coll_t position_i(pts_extrudedpolygon, _U(position)); position_i; ++position_i) {
xml_comp_t position_comp = position_i;
epic::geo::Point inpt = {position_comp.x(), position_comp.y()};
Expand Down
Loading