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

Implement G4Trap in Opticks #5

Open
ggalgoczi opened this issue Oct 16, 2024 · 11 comments
Open

Implement G4Trap in Opticks #5

ggalgoczi opened this issue Oct 16, 2024 · 11 comments
Assignees

Comments

@ggalgoczi
Copy link

No description provided.

@ggalgoczi
Copy link
Author

G4Trd does not need to be implemented since it can be translated analytically into a G4Trap.

@ggalgoczi
Copy link
Author

Can I assign it to you @plexoos ?

@plexoos
Copy link
Member

plexoos commented Oct 21, 2024

Yes, I'll see what I can do

@plexoos plexoos self-assigned this Oct 21, 2024
@plexoos
Copy link
Member

plexoos commented Nov 19, 2024

We have both G4Trap and G4Trd (aka trap and trd in GDML) volumes used in the pfRICH geometry. G4Trd is a special case of G4Trap with the z-axis being its central axis.

@ggalgoczi
Copy link
Author

That is correct, I provided a way to automatically convert all G4Trds into G4Traps. I can not find it right now but will add a comment here when I do.

Hence only G4Traps need to implemented in this task into Opticks.

@plexoos
Copy link
Member

plexoos commented Nov 19, 2024

Looks like we can associate up to 6 double parameters with each node https://github.com/BNLNPPS/esi-opticks/blob/esi/sysrap/s_pa.h#L50. But G4Trap requires 11 parameters (9 of which are independent) 🤔

@ggalgoczi
Copy link
Author

Yes, I feel like we have to change this sourcecode and add additional variables which will lead to need to change quite a bit of code...

Simon suggested the following steps to do this:

  1. study Geant4 implementation of G4Trap (g4-;g4-cls G4Trap)
  2. study old Opticks translations with extg4/X4Solid.*
  3. study new Opticks translations with u4/U4Solid.*

@plexoos
Copy link
Member

plexoos commented Nov 19, 2024

We are in luck. All of the trap volumes in pfrich_min have zero angles:

$ grep -r trap geom/pfrich_min.gdml 
    <trap alpha1="0" alpha2="0" aunit="deg" lunit="mm" name="FlangeWedge0x56008b62c830" phi="0" theta="0" x1="116.238315670544" x2="62.0667122987972" x3="116.238315670544" x4="62.0667122987972" y1="54.0187869822485" y2="54.0187869822485" z="6.35"/>
    <trap alpha1="0" alpha2="0" aunit="deg" lunit="mm" name="FlangeWedge0x56008bf67cc0" phi="0" theta="0" x1="103.069073741954" x2="48.8974703702069" x3="103.069073741954" x4="48.8974703702069" y1="54.0187869822485" y2="54.0187869822485" z="7.35"/>
    <trap alpha1="0" alpha2="0" aunit="deg" lunit="mm" name="FlangeWedge0x56008b759510" phi="0" theta="0" x1="116.238315670544" x2="62.0667122987972" x3="116.238315670544" x4="62.0667122987972" y1="54.0187869822485" y2="54.0187869822485" z="431.65"/>
    <trap alpha1="0" alpha2="0" aunit="deg" lunit="mm" name="FlangeWedge0x56008b62c3e0" phi="0" theta="0" x1="103.069073741954" x2="48.8974703702069" x3="103.069073741954" x4="48.8974703702069" y1="54.0187869822485" y2="54.0187869822485" z="432.65"/>
    <trap alpha1="0" alpha2="0" aunit="deg" lunit="mm" name="FlangeWedge0x56008bf88180" phi="0" theta="0" x1="116.774668179175" x2="62.6030648074284" x3="116.774668179175" x4="62.6030648074284" y1="54.0187869822485" y2="54.0187869822485" z="435.65"/>
    <trap alpha1="0" alpha2="0" aunit="deg" lunit="mm" name="FlangeWedge0x56008b62c550" phi="0" theta="0" x1="103.069073741954" x2="48.8974703702069" x3="103.069073741954" x4="48.8974703702069" y1="54.0187869822485" y2="54.0187869822485" z="435.65"/>
    <trap alpha1="0" alpha2="0" aunit="deg" lunit="mm" name="FlangeWedge0x56008bf697f0" phi="0" theta="0" x1="114.42186850798" x2="60.2502651362331" x3="114.42186850798" x4="60.2502651362331" y1="54.0187869822485" y2="54.0187869822485" z="6.35"/>
    <trap alpha1="0" alpha2="0" aunit="deg" lunit="mm" name="FlangeWedge0x56008bf6a230" phi="0" theta="0" x1="103.069073741954" x2="48.8974703702069" x3="103.069073741954" x4="48.8974703702069" y1="54.0187869822485" y2="54.0187869822485" z="7.35"/>
    <trap alpha1="0" alpha2="0" aunit="deg" lunit="mm" name="FlangeWedge0x56008bf68b00" phi="0" theta="0" x1="103.069073741954" x2="48.8974703702069" x3="103.069073741954" x4="48.8974703702069" y1="54.0187869822485" y2="54.0187869822485" z="7.35"/>
    <trap alpha1="0" alpha2="0" aunit="deg" lunit="mm" name="FlangeWedge0x56008c098340" phi="0" theta="0" x1="103.069073741954" x2="48.8974703702069" x3="103.069073741954" x4="48.8974703702069" y1="54.0187869822485" y2="54.0187869822485" z="10.7"/>
    <trap alpha1="0" alpha2="0" aunit="deg" lunit="mm" name="FlangeWedge0x56008b600820" phi="0" theta="0" x1="103.069073741954" x2="48.8974703702069" x3="103.069073741954" x4="48.8974703702069" y1="54.0187869822485" y2="54.0187869822485" z="492"/>

@ggalgoczi
Copy link
Author

I saw your commit @plexoos, very interesting! Did you test it? Does it work or does G4Trap need to be converted into Polyhedron and have a function to calculate it's bounding box for GPU use?

By the way do you know what sn and snd stand for?

@plexoos
Copy link
Member

plexoos commented Nov 25, 2024

AFAICT, sn/snd are the types that hold information about each node in the geometry tree. I implemented the right angular wedge from the trapezoid definitions, and it seems to allow processing a simplified geometry with a union that includes a trapezoid. More tests are needed.

@ggalgoczi
Copy link
Author

ggalgoczi commented Nov 25, 2024

nconvexpolyhedron* nconvexpolyhedron::CreateTrapezoid(float z, float x1, float y1, float x2, float y2 )
was used to convert G4Trd in previous Opticks version into Polyhedron. Do we want to do the same?

The intersection is implemented for Polyhedron for Optix7!
./CSG/csg_intersect_leaf_convexpolyhedron.h

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

No branches or pull requests

2 participants