Skip to content
Open
Show file tree
Hide file tree
Changes from 8 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
2 changes: 1 addition & 1 deletion compact/far_backward/beamline_extension_electron.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<detector
name="Magnets_Q4eR_to_B7eR"
type="CylindricalMagnetChain"
vis="RedVis">
vis="FFMagnetVis">
<magnet id="0" name="Magnet_Q4eR"
x="Q4eR_CenterX" y="0" z="Q4eR_CenterZ" theta="Q4eR_Theta"
length="Q4eR_Length" rin="Q4eR_InnerRadius" rout="Q4eR_OuterRadius">
Expand Down
2 changes: 1 addition & 1 deletion compact/far_backward/beamline_extension_hadron.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<comment> Hadron side beam magnet volumes </comment>

<detector name="Magnet_Q2PR" type="ip6_CylindricalDipoleMagnet" vis="RedVis">
<detector name="Magnet_Q2PR" type="ip6_CylindricalDipoleMagnet" vis="FFMagnetVis">
<placement x="(Q2PR_StartX+Q2PR_EndX)/2" y="0" z="(Q2PR_StartZ+Q2PR_EndZ)/2" theta="Q1BPR_Theta"/>
<dimensions x="Q2PR_InnerRadius*4" y="Q2PR_InnerRadius*4" z="Q2PR_Length" r="2.0*Q2PR_InnerRadius"/>
<apperture x="Q2PR_InnerRadius*2" y="Q2PR_InnerRadius*2" r="Q2PR_InnerRadius"/>
Expand Down
2 changes: 2 additions & 0 deletions compact/far_backward/definitions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@

<constant name="B2BeR_InnerRadius" value="111.0*mm"/>
<constant name="B2BeR_Length" value="3.18*m"/>
<constant name="B2BeR_CenterX" value="0*mm"/>
<constant name="B2BeR_CenterPosition" value="-13.275*m"/>
<constant name="B2BeR_Theta" value="0.0*rad"/>

<constant name="Q3eR_InnerRadius" value="0.05*m"/>
<constant name="Q3eR_Length" value="0.6*m"/>
Expand Down
8 changes: 4 additions & 4 deletions compact/far_backward/magnets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
</pipe>
<pipe id="6" name="Pipe_B2AeR_to_B2BeR"/>
<pipe id="7" name="Pipe_in_B2BeR"
xcenter="0" zcenter="B2BeR_CenterPosition"
length="B2BeR_Length" theta="0"
xcenter="B2BeR_CenterX" zcenter="B2BeR_CenterPosition"
length="B2BeR_Length" theta="B2BeR_Theta"
rout1="B2BeR_InnerRadius" rout2="B2BeR_InnerRadius">
</pipe>
</detector>
Expand Down Expand Up @@ -67,7 +67,7 @@
</detector>

<detector name="Magnet_B2BeR" type="ip6_CylindricalDipoleMagnet" vis="FFMagnetVis">
<placement x="0" y="0" z="B2BeR_CenterPosition" theta="0*rad"/>
<placement x="B2BeR_CenterX" y="0" z="B2BeR_CenterPosition" theta="B2BeR_Theta"/>
<dimensions x="B2BeR_InnerRadius*4" y="B2BeR_InnerRadius*4" z="B2BeR_Length" r="1.5*B2BeR_InnerRadius"/>
<apperture x="B2BeR_InnerRadius*2" y="B2BeR_InnerRadius*2" r="B2BeR_InnerRadius"/>
<coil dx="2*cm" dy="1.5*cm" /><!--unchecked-->
Expand All @@ -76,7 +76,7 @@
<detector
name="Magnets_Q3eR"
type="CylindricalMagnetChain"
vis="RedVis">
vis="FFMagnetVis">
<magnet id="0" name="Magnet_Q3eR"
x="Q3eR_XPosition" y="0" z="Q3eR_CenterPosition" theta="Q3eR_Theta"
length="Q3eR_Length" rin="Q3eR_InnerRadius" rout="4*Q3eR_InnerRadius">
Expand Down
1 change: 1 addition & 0 deletions compact/far_backward/taggers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<bounding xmin="Vacuum_BB_MinX" xmax="Vacuum_BB_MaxX"
ymin="Vacuum_BB_MinY" ymax="Vacuum_BB_MaxY"
zmin="Vacuum_BB_MinZ" zmax="Vacuum_BB_MaxZ"
theta="B2BeR_Theta"
/>
<rotation theta="Beam_Theta"/>
<dimensions xL="Beam_WidthL" xR="Beam_WidthR" y="Beam_Height" z="Beam_Length"/>
Expand Down
4 changes: 2 additions & 2 deletions compact/far_forward/electron_beamline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</detector>

<!-- Q0eF magnet -->
<detector name="Q0EF" type="ip6_CylindricalDipoleMagnet" vis="RedVis">
<detector name="Q0EF" type="ip6_CylindricalDipoleMagnet" vis="FFMagnetVis">
<placement x="0" y="0" z="(Q0EF_StartZ+Q0EF_EndZ)/2." theta="0"/>
<dimensions x="Q0EF_InnerRadius*4" y="Q0EF_InnerRadius*4" z="Q0EF_StartZ-Q0EF_EndZ" r="1.9*Q0EF_InnerRadius" />
<apperture x="Q0EF_InnerRadius*2" y="Q0EF_InnerRadius*2" r="Q0EF_InnerRadius" />
Expand All @@ -72,7 +72,7 @@
</detector>

<!-- Q1eF magnet -->
<detector name="Q1EF" type="ip6_CylindricalDipoleMagnet" vis="RedVis">
<detector name="Q1EF" type="ip6_CylindricalDipoleMagnet" vis="FFMagnetVis">
<placement x="0" y="0" z="(Q1EF_StartZ+Q1EF_EndZ)/2." theta="0"/>
<dimensions x="Q1EF_InnerRadius*4" y="Q1EF_InnerRadius*4" z="Q1EF_StartZ-Q1EF_EndZ" r="1.9*Q1EF_InnerRadius" />
<apperture x="Q1EF_InnerRadius*2" y="Q1EF_InnerRadius*2" r="Q1EF_InnerRadius" />
Expand Down
36 changes: 18 additions & 18 deletions src/BackwardsTaggers_geo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static Ref_t create_detector(Detector& desc, xml_h e, SensitiveDetector sens) {
double off = pos.z();

// Beamline rotation
xml_dim_t rot = x_det.rotation();
double out_theta = x_det.rotation().theta();

// Beampipe thickness
double wall = dd4hep::getAttrOrDefault<double>(x_det, _Unicode(wall), 1 * mm);
Expand All @@ -61,6 +61,7 @@ static Ref_t create_detector(Detector& desc, xml_h e, SensitiveDetector sens) {
double BB_MaxX = BB.xmax();
double BB_MaxY = BB.ymax();
double BB_MaxZ = BB.zmax();
double in_theta = BB.theta();

double BB_X = abs(BB_MaxX - BB_MinX);
double BB_Y = abs(BB_MaxY - BB_MinY);
Expand All @@ -76,7 +77,7 @@ static Ref_t create_detector(Detector& desc, xml_h e, SensitiveDetector sens) {
double Lumi_R = EB.attr<double>(_Unicode(lumiR));

// Maximum theta to exit the dipole from
double exitTheta = EB.attr<double>(_Unicode(maxTheta));
double maxTheta = EB.attr<double>(_Unicode(maxTheta));

// Generic box for making intersection solid with
double xbox = 10 * m;
Expand Down Expand Up @@ -117,9 +118,9 @@ static Ref_t create_detector(Detector& desc, xml_h e, SensitiveDetector sens) {

// Theta coverage expected
double thetamin =
dd4hep::getAttrOrDefault<double>(mod, _Unicode(theta_min), 0.030 * rad) - rot.theta();
dd4hep::getAttrOrDefault<double>(mod, _Unicode(theta_min), 0.030 * rad) - out_theta;
double thetamax =
dd4hep::getAttrOrDefault<double>(mod, _Unicode(theta_max), 0.030 * rad) - rot.theta();
dd4hep::getAttrOrDefault<double>(mod, _Unicode(theta_max), 0.030 * rad) - out_theta;

// Align box to max or minimum theta expected at the tagger from focal point
bool max_align = dd4hep::getAttrOrDefault<bool>(mod, _Unicode(max_align), false);
Expand Down Expand Up @@ -223,33 +224,32 @@ static Ref_t create_detector(Detector& desc, xml_h e, SensitiveDetector sens) {
// CutTube Lumi_Exit (0, Lumi_R, ED_Z, 0,2*pi, sin(angle),0,cos(angle), 0,0,1);

// Add entry boxes to main beamline volume
Wall_Box = UnionSolid(Wall_Box, Entry_Beam_Box, Transform3D(RotationY(-rot.theta())));
Vacuum_Box = UnionSolid(Vacuum_Box, Entry_Vacuum_Box, Transform3D(RotationY(-rot.theta())));
Vacuum_Box = UnionSolid(Vacuum_Box, Lumi_Exit, Transform3D(RotationY(-rot.theta())));
Wall_Box = UnionSolid(Wall_Box, Entry_Beam_Box, Transform3D(RotationY(-out_theta)));
Vacuum_Box = UnionSolid(Vacuum_Box, Entry_Vacuum_Box, Transform3D(RotationY(-out_theta)));
Vacuum_Box = UnionSolid(Vacuum_Box, Lumi_Exit, Transform3D(RotationY(-out_theta)));
}

//-----------------------------------------------------------------
// Restrict tagger boxes into region defined by exitTheta from the dipole magnet
// Restrict tagger boxes into region defined by maxTheta from the dipole magnet
//-----------------------------------------------------------------
double exitDist = BB_MinZ - off;
double cutX = (ED_X - exitDist * tan(-rot.theta())) * cos(rot.theta());
double cutZ =
(ED_X - exitDist * tan(-rot.theta())) * sin(rot.theta()) + exitDist * cos(rot.theta());
double cutXwall = (ED_X - wall - exitDist * tan(-rot.theta())) * cos(rot.theta());
double cutX = (ED_X - exitDist * tan(-out_theta)) * cos(out_theta);
double cutZ = (ED_X - exitDist * tan(-out_theta)) * sin(out_theta) + exitDist * cos(out_theta);
double cutXwall = (ED_X - wall - exitDist * tan(-out_theta)) * cos(out_theta);
double cutZwall =
(ED_X - wall - exitDist * tan(-rot.theta())) * sin(rot.theta()) + exitDist * cos(rot.theta());
(ED_X - wall - exitDist * tan(-out_theta)) * sin(out_theta) + exitDist * cos(out_theta);

Wall_Box = IntersectionSolid(Wall_Box, Cut_Box,
Transform3D(RotationY(exitTheta), Position(xbox - cutX, 0, cutZ)));
Transform3D(RotationY(maxTheta), Position(xbox - cutX, 0, cutZ)));
Vacuum_Box =
IntersectionSolid(Vacuum_Box, Cut_Box,
Transform3D(RotationY(exitTheta), Position(xbox - cutXwall, 0, cutZwall)));
Transform3D(RotationY(maxTheta), Position(xbox - cutXwall, 0, cutZwall)));

//-----------------------------------------------------------------
// Cut solids so they are only in the far backwards box
//-----------------------------------------------------------------
RotationY rotate2(-rot.theta());
Position position(0, 0, (exitDist - BB_Z) / cos(rot.theta()));
RotationY rotate2(in_theta - out_theta);
Position position(0, 0, (exitDist - BB_Z) / cos(out_theta - in_theta));

IntersectionSolid Wall_Box_Sub(Wall_Box, Far_Backwards_Box, Transform3D(rotate2, position));
IntersectionSolid Vacuum_Box_Sub(Vacuum_Box, Far_Backwards_Box, Transform3D(rotate2, position));
Expand All @@ -271,7 +271,7 @@ static Ref_t create_detector(Detector& desc, xml_h e, SensitiveDetector sens) {
backAssembly.placeVolume(DetAssemblyAir);

// placement in mother volume
Transform3D tr(RotationY(rot.theta()), Position(pos.x(), pos.y(), pos.z()));
Transform3D tr(RotationY(out_theta), Position(pos.x(), pos.y(), pos.z()));
PlacedVolume detPV = desc.pickMotherVolume(det).placeVolume(backAssembly, tr);
detPV.addPhysVolID("system", detID);

Expand Down
10 changes: 8 additions & 2 deletions src/CylindricalMagnetChain_geo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ static Ref_t create_magnet(Detector& description, xml_h e, SensitiveDetector /*
xml_comp_t magnet(magnet_coll);

string name = getAttrOrDefault<string>(magnet, _Unicode(name), "");
int id = getAttrOrDefault<int>(magnet, _Unicode(id), 0);
double x = getAttrOrDefault<double>(magnet, _Unicode(x), 0);
double y = getAttrOrDefault<double>(magnet, _Unicode(y), 0);
double z = getAttrOrDefault<double>(magnet, _Unicode(z), 0);
Expand All @@ -45,9 +46,14 @@ static Ref_t create_magnet(Detector& description, xml_h e, SensitiveDetector /*
Tube yoke_tube(rin, rout, 0.5 * length);
Volume v_yoke("v_yoke_" + name, yoke_tube, m_Iron);

v_yoke.setVisAttributes(description.visAttributes(vis_name));
v_yoke.setVisAttributes(x_det.visStr());

assembly.placeVolume(v_yoke, Transform3D(RotationY(theta), Position(x, y, z)));
auto yoke_pv = assembly.placeVolume(v_yoke, Transform3D(RotationY(theta), Position(x, y, z)));

yoke_pv.addPhysVolID("element", id);
DetElement yoke_de(sdet, name, id);
yoke_de.setPlacement(yoke_pv);
yoke_de.setAttributes(description, v_yoke, x_det.regionStr(), x_det.limitsStr(), vis_name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd still like to avoid this, if we can. We only have 255 detector IDs in our 8-bit field for segmentations, and less than half are left. If we start giving IDs to all magnets, we're going to run out quickly.

Note that you can add regions and limits to volumes too:

DDCore/include/DD4hep/Volumes.h:
    const Volume& setAttributes(const Detector& description, const std::string& region, const std::string& limits,
                                const std::string& vis) const;

Can you verify that visualization is not affected when avoiding the ID for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed the DetElement and recovered the visualization using setAttributes. The physical volume ID is still required to give the volume a unique identifier in the tree but shouldn't count towards the detector IDs

}

// Final placement
Expand Down
2 changes: 1 addition & 1 deletion templates/epic.xml.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
The ip6 (or other ip) defines should be included first.
These files have only a define tags.
</documentation>
<include ref="${DETECTOR_PATH}/compact/fields/beamline_{{ ebeam | default("18", true) }}x{{ pbeam | default("275", true) }}.xml" />
<include ref="${DETECTOR_PATH}/compact/definitions.xml" />
<include ref="${DETECTOR_PATH}/compact/far_forward/definitions.xml" />
<include ref="${DETECTOR_PATH}/compact/far_backward/definitions.xml" />
<include ref="${DETECTOR_PATH}/compact/fields/beamline_{{ ebeam | default("18", true) }}x{{ pbeam | default("275", true) }}.xml" />
<include ref="${DETECTOR_PATH}/compact/version.xml"/>
<include ref="${DD4hepINSTALL}/DDDetectors/compact/detector_types.xml"/>
</define>
Expand Down
Loading