-
Notifications
You must be signed in to change notification settings - Fork 101
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
DD4hepSimulation: pass self to the steeringFile eval #1376
base: master
Are you sure you want to change the base?
Conversation
Should help in case when steering is defined with a name other than "SIM", then, without this, depending on the dict ordering it may be overtaken by "SIM". We don't want that.
Test Results 14 files 14 suites 5h 26m 42s ⏱️ Results for commit da9f99b. |
Happy New Year to all! @andresailer |
Hi @veprbl How does your new steering file look like then? |
Old file: from DDSim.DD4hepSimulation import DD4hepSimulation
from g4units import mm, GeV, MeV, degree
SIM = DD4hepSimulation()
SIM.gun.energy = 10*GeV
SIM.gun.particle = "e-"
SIM.gun.position = (0.0, 0.0, 0.0)
SIM.gun.direction = (0.0, 0.0, 1.0)
SIM.gun.distribution = "cos(theta)"
SIM.gun.thetaMin = 45*degree
SIM.gun.thetaMax = 135*degree New file: from g4units import mm, GeV, MeV, degree
SIM.gun.energy = 10*GeV
SIM.gun.particle = "e-"
SIM.gun.position = (0.0, 0.0, 0.0)
SIM.gun.direction = (0.0, 0.0, 1.0)
SIM.gun.distribution = "cos(theta)"
SIM.gun.thetaMin = 45*degree
SIM.gun.thetaMax = 135*degree
npsim implemented so that we can provide reasonable defaults, but the implementation of option parsing in DD4hepSimulation breaks those when I am proposing swapping order of option setting in eic/npsim#29. That would, for now solve the original problem for us, but also make it impossible for users to undo our settings. |
ddsim has many defaults baked in, I guess I don't really understand what you mean... I don't like the SIM appearing out of nowhere in the steering file, that messes up linters, doesn't it? Also can you answer "yes/no" whether this is because of npsim? (this is just for my understanding) You want to have a executable with defaults for your detector simulation, instead of setting everything in a steering file and use that, correct? |
I meant ddsim binary itself uses the default-constructed
Linters are not supposed to care about semantics, but I share your concern. A proper way to do this is to structure config as from g4units import mm, GeV, MeV, degree
def init_simulation(sim: DD4hepSimulation):
# do things here
return sim That can be made backwards compatible too.
Yes.
Correct. Moreover, the defaults need to apply even if steering files are not used. |
I don't understand the release notes entries.
Where is this pre-defind SIM coming from?
You can already not completely override simulation settings in the steering file. These statements need to be refined and I guess be explicit about not using ddsim. Regarding linters: pylint cares about "semantics" (certainly pylint would complain if you start using undefined variables), I guess this goes beyond linting, but it is called py"lint", so apologies for the lax use of language. |
That refers to the
I've updated the wording. Is that better now?
Let me know if you want me to implement my proposal using functions to implement overlays. |
Thanks for all you answers! Would it be possible to subclass DD4hepSimulation (NPSimSimulation) and use that in the steering file instead? |
It would be possible to provide NPSimSimulation to be importable in the user steering files, however that would make those steering files incompatible with ddsim. Like you point out, that would be more work. I feel pretty confident about fixing external behaviour of |
BEGINRELEASENOTES
SIM = DD4hepSimulation()
, and instead use a pre-defined variable with nameSIM
. This allows for steering files that preserve the existing state ofDD4hepSimulation
that a custom user code had set prior to theparseOptions()
call.ENDRELEASENOTES
At ePIC we use an entry point like
https://github.com/eic/npsim/blob/01d54e67c7bbd671d1f87180e55c296286e639c5/src/dd4pod/python/npsim.py
However using this with
--steeringFile
unconditionally unsets our settings as new DD4hepSimulation object has to be created in the steering. The proposed change allows to write steering files without theThis is optional and should not break any existing use case. A next step could be to remove those two lines from output of the
--dumpSteeringFile
.