WireCell / wire-cell-toolkit

Toolkit for Liquid Argon TPC Simulation and Reconstruction
https://wirecell.github.io/
Other
7 stars 22 forks source link

Need options to dump out final configuration/json used in WireCell::Main #277

Open HaiwangYu opened 9 months ago

HaiwangYu commented 9 months ago

With the many layered fcl and wire-cell includes, it becomes harder to determine the actual parameters used in WireCell::Main. E.g., @Laura Paulucci raised a question how to determine the nticks parameter value actually used. I think we probably need an option to dump the final configuration/json for easy debugging without checking all layers of includes. Meaning some integration of wcsonnet into WireCell::Main is probably useful. @brettviren what do you think?

Notes: https://github.com/LArSoft/larwirecell/blob/develop/larwirecell/Tools/WCLS_tool.cc#L175 https://github.com/WireCell/wire-cell-toolkit/blob/master/apps/src/Main.cxx#L260 https://github.com/WireCell/wire-cell-toolkit/blob/master/apps/apps/wcsonnet.cxx#L87-L92

brettviren commented 9 months ago

Hi @HaiwangYu

Yes, I think this is a worthwhile thing to address. DUNE's nascent "framework requirements" includes the need to be able to persist the configuration used by a job so it would also be useful there. Though, how exactly that persistence is meant to work is not yet specified.

Today, using wcsonnet would be the quickest way to see the final WCT configuration object in all its glory. The only hassle is that one must supply values for the various std.extVar (such as passed from FHiCL) or TLAs such as passed on the wire-cell command line. The hassle can be reduced by passing bogus values as long as the user is sure these do not impact whatever chunk of config that is of interest.

Going forward, to allow some kind of "as-configured" dumper, Main is the right place to start. The Main object uses a ConfigManager to collect all the configuration files (WCT actually can accept multiple, though we usually stick to just one). It's all() method returns the full object:

https://github.com/WireCell/wire-cell-toolkit/blob/master/util/inc/WireCellUtil/ConfigManager.h#L37

That object can then be given to Persist::dump() a save a JSON representation of the configuration object to a file or Persist:dumps() send JSON to logging or some output stream.

https://github.com/WireCell/wire-cell-toolkit/blob/master/util/inc/WireCellUtil/Persist.h#L80

The question is then how/where best to trigger/produce a config dump. It is only Main that has access to the full configuration object so that's the likely candidate. However, if we (eg DUNE) wants config to turn into an art::Event record, that should/must be done by a DFP node component, but currently there is no way for such a component to get access to the full config.

For now, I suggest we add methods and option to Main and wire-cell (and thus also available to the WC/LS interface) which allows something like this (for CLI example):

wire-cell --dump-configuration [target] [...usual arguments...]

Where target would be interpreted as: