Skip to content

Conversation

@kamathrohan
Copy link
Contributor

No description provided.

@kamathrohan kamathrohan marked this pull request as ready for review October 22, 2025 09:54
@stewartboogert stewartboogert self-requested a review October 23, 2025 11:50
@stewartboogert
Copy link
Collaborator

Ok looks pretty straightforward. I'll add minor comments in review. Other issues

  1. Does it all work if the extra transformation parameters are not provided
  2. Confirmation of this working is best done with "regression" tests showing trajectory changes which the coils are tilted, displaced etc. This PR will be accepted when there are appropriate "physics" tests.

true,
a + (sheet * dr) + dr / 2,
fullLengthZ,
tiltX,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Fix indenting

G4bool strengthIsCurrent,
G4double sheetRadius,
G4double fullLength,
G4double tiltX,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Fix indenting

I(0.0),
spatialLimit(std::min(1e-5*sheetRadius, 1e-5*fullLength)),
normalisation(1.0) ,
rotateX(tiltX),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Try to be more consistent in variable names. Could be rotateX(rotateXIn)

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree - should be consistent.


// Apply inverse rotations in reverse order (Z -> Y -> X)
// to transform from global frame to solenoid's local frame
localPosition.rotateZ(-rotateZ);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not formulate the transformation and just call the inverse method?

Copy link
Contributor

@lnevay lnevay left a comment

Choose a reason for hiding this comment

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

Does it make sense to have a rotation about the local unit Z for a cylindrical symmetric field? So this just rotates the x,y offset?

Few comments for minor changes - thanks!


**Rotations and Offsets**

Rotations follow the right-hand rule using axis-angle representation applied in XYZ order about the X, Y, and Z axes respectively. The reference frame assumes the solenoid is initially centered at the origin with its axis aligned along the z-direction. The position offsets then translate this solenoid center from the origin to an arbitrary location in the global coordinate system of the cooling channel.
Copy link
Contributor

Choose a reason for hiding this comment

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

"offsets then translate(s)".. just translates. I think not in the global frame but in the coordinate frame of the cooling channel element.

I(0.0),
spatialLimit(std::min(1e-5*sheetRadius, 1e-5*fullLength)),
normalisation(1.0) ,
rotateX(tiltX),
Copy link
Contributor

Choose a reason for hiding this comment

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

Agree - should be consistent.

// Apply inverse rotations in reverse order (Z -> Y -> X)
// to transform from global frame to solenoid's local frame
localPosition.rotateZ(-rotateZ);
localPosition.rotateY(-rotateY);
Copy link
Contributor

Choose a reason for hiding this comment

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

Like Stewart mentioned, I would perhaps use a G4RotationMatrix. You can prepare it in the constructor and the inverse as well. Then you can just multiply by the appropriate one each time.

globalField.rotateY(rotateY);
globalField.rotateZ(rotateZ);

return globalField;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please can you change this to some other name. The "globalField" is used in BDSIM to mean in the global frame, whereas this is still in the local frame of the element. You usually use one mega-cooling channel but conceptually it's 'local' as the global transform for the beamline is done in a wrapper class. How about unrotatedField and localField.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants