rat-pac / ratpac-two

Open source edition of RAT-PAC
Other
11 stars 23 forks source link

Usage of PMT Envelope double-places the PMT body, breaks GDML persistency #120

Open JamesJieranShen opened 8 months ago

JamesJieranShen commented 8 months ago

This commit changes how the PMT geometry is defined compared to older versions of rat. The PMT geometry logic is currently as follows:

  1. create a volume called the pmt_envelope.
  2. place the pmt body in pmt_envelope, call this placement body_phys. (first placement)
  3. Create daughter volumes (dynodes, waveguides, inner volumes used to carve out the glass shape)
  4. Declare border surfaces (photocathodes, mirrors) between body_phys and the inner volumes.
  5. Take the created pmt, place it in the detector (second placement).

This approach causes issues with the GDML writer. pmt_envelope is not part of the detector geometry and is therefore not written to the geometry. However, the border surface definitions refer to the physical volumes they are defined with, notably body_phys. However, body_phys is never written to the gdml file since it is a placement in pmt_envelope.

Optimal solution is to fix this in the pmt geo factories such that we don't refer to a dangling physical volume that's not part of the actual geometry definition. If this is challenging, the GDMLWriter might be modified somehow to handle this edge case.

@masmiley, do you know anything about this? I am not sure if you were responsible for this change or Morgan, since Morgan committed the change but the PR mentions your name. Thanks in advance!

MorganAskins commented 7 months ago

The pmt envelope is a hack for geant-4 to help improve the particle propagation speed. The dynamic step size within a volume is loosely based on the smallest elements of that volume, so if you are in a huge detector but have very precise PMTs sitting in that detector then you get very small steps across the whole thing. The envelope tricks geant-4 into thinking the PMTs are just simple cubes up until you hit the envelope and then transport becomes more precise.

Placing the PMT twice does sound like a bug that should be fixed. The main thing to check after any fix is simply: