art-framework-suite / art

The implementation of the art physics event processing framework
Other
2 stars 7 forks source link

Run::getProcessParameterSet() functionality disabled #121

Closed PetrilloAtWork closed 2 years ago

PetrilloAtWork commented 2 years ago

I am trying to access the past job FHiCL configuration as early as possible. The second best option for that is at the beginning of a run (the best one would have been at file opening time).

art::DataViewImpl provides a getProcessParameterSet(), and art::Run is using it. Nevertheless I am failing to get a result from it: it consistently returns false.

I have stolen the code of its implementation, and it appears to work correctly on my input files... so I suppose it should work. I would like to know if there is a reason why this functionality is instead disabled for run and subrun principals (that's my interpretation of the line if (branchType_ != InEvent) { return false; }), and if there is none, I would like it to be enabled.

PetrilloAtWork commented 2 years ago

For the record, the same functionality can be indirectly obtained already, for example:

  for (art::ProcessConfiguration const& procConfig: run.processHistory()) {

    fhicl::ParameterSet config;
    if (!fhicl::ParameterSetRegistry::get(procConfig.parameterSetID(), config)) {
      throw cet::exception{ "ConfigExtractor" }
        << "Configuration of process '" << procConfig.processName()
        << "' can't be found!\n";
    }
    mf::LogInfo{ "ConfigExtractor" }
      << "Configuration of '" << procConfig.processName() << "' (release: "
      << procConfig.releaseVersion() << ", ID=" << procConfig.id() << "):"
      << '\n' << config.to_indented_string()
      ;

  } // for

prints all process configuration from a art::Run.

knoepfel commented 2 years ago

I agree that it is an unnecessary restriction to disable the function for (sub)runs. Can I ask why you need to access the process parameter set?

PetrilloAtWork commented 2 years ago

It is currently the only was we have to discover the configuration of DAQ of ICARUS runs. While this might be changed by having the DAQ write the configuration information also as a run data product, that has not happened so far, so we will still need the access to the configuration. However, note that even the data product solution is not particularly elegant, since it would likely consist in dumping the FHiCL configuration into a string data product. In my opinion, a real configuration data product is not feasible because the configuration is changing too rapidly for the data product class to keep up.

knoepfel commented 2 years ago

@PetrilloAtWork, I can remove the restriction. A better solution, however, may be to rely on the configuration system to provide the information you need (e.g.):

daq: {
  ...
}

physics: {
  producers: {
    p1: {
      module_type: MyProducer
      daq_info: @local::daq
    }
  }
}
knoepfel commented 2 years ago

Implemented with https://github.com/art-framework-suite/art/commit/dd8c04cd6299622c85ee03bbd1e845e7118e55d8. There is an interface change, however:

- fhicl::ParameterSet pset;
- if (e.getProcessParameterSet(process_name, pset)) {
-   // pset found for process_name
- }
+ if (auto pset = e.getProcessParameterSet(process_name)) {
+   // pset found for process_name 
+   // pset is of type std::optional<fhicl::ParameterSet> and can be dereferenced
+}
knoepfel commented 2 years ago

This will be included in art 3.11.