AIDASoft / DD4hep

Detector Description Toolkit for High Energy Physics
http://dd4hep.cern.ch
GNU Lesser General Public License v3.0
53 stars 100 forks source link

issue using optical surfaces #1014

Closed saraheno closed 1 year ago

saraheno commented 2 years ago

Hi, I am trying to now use the optical surfaces in my code. However, it does not seem to be working. I tried to put in a perfect mirror surface at: https://github.com/saraheno/SingleDualCrystal/blob/d8edfe896acbea941322f6fb97207bb142d8faa4/compact/DRJunk.xml#L212

This is used in the geometry at https://github.com/saraheno/SingleDualCrystal/blob/d8edfe896acbea941322f6fb97207bb142d8faa4/src/DRCrystal_geo.cpp#L213

but when I try running using
ddsim --compactFile=./DRJunk.xml --runType=vis -G --steeringFile junkst.py --outputFile=testSCEPCAL.root --part.userParticleHandler='' -G --gun.position="0.,30.,0." --gun.direction "0 -1 0" --gun.energy "1*GeV" --gun.particle="mu-"

photons are still escaping the media. Is the optical surface at the wrong place? do I need to put it in between the layers and the tower, and not the tower and the environment? or is that surface not really a mirror?

thank you, Sarah Eno

andresailer commented 2 years ago

How does one tell that photons have left the media?

saraheno commented 2 years ago

Visually, via the interactive display when running an event. In this attachment, you can see one coming out at the bottom. escape

andresailer commented 2 years ago

Can you list the geant4 commands you are using to enable the tracks etc.?

saraheno commented 2 years ago

do you mean these ones: https://github.com/saraheno/SingleDualCrystal/blob/main/compact/vis.mac

andresailer commented 2 years ago

Yes, those were the commands I was looking for. I can see the same escaping photons.

andresailer commented 2 years ago

I have no experience with optical surfaces. So apart from saying I see the same thing, I don't know any further. I did notice though that your values for the reflectivity values do not seem to cover the energy of the optical photons printed out when running your simulation. Though extending the range didn't make the escaping stop either.

saraheno commented 2 years ago

So should I maybe contact the GEANT4 team? Can I add you in, as they may be reluctant to help us with it since it is attached via dd4hep?

saraheno commented 1 year ago

Hi Hans, I made the gdml file following Andre's instructions. I see the surface in two lines in the file:

https://github.com/saraheno/SingleDualCrystal/blob/6589de4b77b686399b7236cf3d33de8f708833f1/compact/DRSingleCrystal.gdml#L224

and

<bordersurface name="/world/DRCrystal#HallCrys" surfaceproperty="/world/DRCrystal#mirrorSurface">

so I think that the surface is in there? And yet photons are escaping the crystal? Is this something you can help with?

Best Sarah Eno

hanswenzel commented 1 year ago
Hi Sarah,
that's definitely recent enough. So there is definitely something wrong in the compact to gdml conversion. It's not only the SCINTILLATIONYIELD but other properties like e.g. the FASTTIMECONSTANT that should be defined as matrices not constants.
 Another problem in the gdml file is:
    <bordersurface name="/world/DRCrystal#HallCrys" surfaceproperty="/world/DRCrystal#mirrorSurface">
      <physvolref ref="tower_0" ref="DRCrystal_0"/>
    </bordersurface>
a bordersurface needs 2 physical  volumes (compared to a skin surface that only needs 1 logical volume) e.g:
-- </bordersurface>
So I don't know dd4hep but the gdml file that is produced and should represent the Geant4 geometry definitely is not valid.
I modified the gdml file and attached it to this mail as well as a screenshot of CaTS reading in this file. I will shoot some optical photons into this geometry to see if the surface works properly but I think Geant4 is just fine.
](url) ![Screenshot at 2022-12-06 12-29-11](https://user-images.githubusercontent.com/7925307/205998272-0b63df1b-29d8-4b13-b93a-54c1a38d0d0c.png)
saraheno commented 1 year ago

@MarkusFrankATcernch @hanswenzel I want to make sure I understand where we are on this. Is it:

Is this summary correct? Do both of you agree with this summary?

MarkusFrankATcernch commented 1 year ago

@saraheno

MarkusFrankATcernch commented 1 year ago

@hanswenzel How does one check with Geant4 the validity of GDML ? If the file below is syntactically correct, I could submit the fix to the ROOT team...

DRSingleCrystal.gdml.gz

hanswenzel commented 1 year ago

actually I am using https://github.com/hanswenzel/CaTS to visualize geometries input in form of gdml. It comes with quite a few examples in the gdml directory.

One extension to the gdml file that I make use of is that you can apply visual attributes (colors/transparency) to volumes. I find it helps to debug geometries. Also it gives you access to the geometry tools available in Geant4 (e.g. overlap check) and verifies that the geometry is valid. (Usually it will just crash when things are wrong.) Give it a try and and let me know how it goes. Another quick check can be done with editors (emacs) and IDE's (netbeans, visual code) that have a xml mode each of them will high lite xml syntax errors.

saraheno commented 1 year ago

So I fixed this by changing the optical surface from opticalsurface name="/world/DRCrystal#mirrorSurface" finish="polished" model="glisur" type="dielectric_dielectric"

to opticalsurface name="/world/DRCrystal#mirrorSurface" finish="polished" model="glisur" type="dielectric_metal"

I guess even though both my volumes were technically dielectrics, this is what is needed for perfect reflection.