Update from art v2 to art v3

Use of art v3_00 involves a number of breaking changes.
Please see Kyle's presentation on problems found in the code.

Header changes


  • art/Framework/Core/EngineCreator.h has been moved to art/Framework/Core/detail/EngineCreator.h
    • this header should not be used


  • canvas/Persistency/Provenance/ModuleDescription.h is now art/Persistency/Provenance/ModuleDescription.h


  • art/Persistency/Provenance/MasterProductRegistry.h no longer exists
    • remove this header, there is no replacement

Missing headers

invalid use of incomplete type 'class art::Event'

  • #include "art/Framework/Principal/Event.h"

Undefined references

undefined reference to art::ModuleDescription::processName

  • add art_Persistency_Provenance to the link list

undefined reference to art::input::RootMutexSentry::RootMutexSentry

  • add art_Framework_IO_Root_detail_sources

undefined reference to art::ProductRegistryHelper::insertOrThrow

  • add art_Framework_Core

undefined reference to art::input::RootMutexSentry::RootMutexSentry()

  • add art_Framework_IO_Root_detail_sources

NuTools update notes

  • nutools v2_26_00 has been built with art v3_00_00.
    • This release also has changes that enable the GENIE interface to be compiled with either genie v2 or genie v3.
    • This release was built with genie v2_12_10c.
    • This release includes dk2nudata v01_07_02 and dk2nugenie v01_07_02b.
  • Note that art::ModuleDescription is replaced by art::ModuleContext
  • NuRandomService
    • This service uses EngineCreator
    • Any module that calls NuRandomService::createEngine must call the non-default constructor of the base class. See here and click on "Modules calling createEngine".
    • add art_Framework_Principal to the library link list
    • the art service interface has changed
    • The RandomNumberGenerator service no longer has any notion of the "current" module. Because of that, it is necessary to specify the appropriate schedule ID and module label values when calling getEngine.
    • NuRandomService is not currently thread safe

using getEngine

  • getEngine is designed to be called within a module.
  • For calls which are not part of a constructor:
       art::ServiceHandle<art::RandomNumberGenerator> rng;
    -  CLHEP::HepRandomEngine &engine = rng->getEngine();
    +  CLHEP::HepRandomEngine &engine = rng->getEngine(art::ScheduleID::first(),
    +                                                  moduleDescription().moduleLabel());
       CLHEP::RandFlat   flat(engine);
  • For calls within a constructor:
     MyModule::MyModule(fhicl::ParameterSet const & pset)
    -  : ...
    +  : EDProducer(pset), ...
       art::ServiceHandle<art::RandomNumberGenerator> rng;
    -  CLHEP::HepRandomEngine &engine = rng->getEngine();
    +  CLHEP::HepRandomEngine &engine = rng->getEngine(art::ScheduleID::first(),
    +                                                  pset.get<std::string>("module_label");
       fFlatRandom = new CLHEP::RandFlat(engine);
  • Calls to getEngine which are not part of a module require expert help to fix.
    • The solution involves passing in a moduleDescription from the calling function.


The signature of preProcessEvent now requires two arguments:

       virtual void   reconfigure(fhicl::ParameterSet const& pset) override;
-      void   preProcessEvent(const art::Event& evt);
+      void   preProcessEvent(const art::Event& evt, art::ScheduleContext);
       void   postOpenFile(const std::string& filename);

preProcessEvent is designed to be called by the framework. It should never be called directly. However, the following temporary solution is possible.
     // it requires a specific implementation of DetectorClocksService.
     art::ServiceHandle<detinfo::DetectorClocksServiceStandard> tss;
     // In case trigger simulation is run in the same job...
-    tss->preProcessEvent(evt);
+    //FIXME: you should never call preProcessEvent
+    tss->preProcessEvent(evt, art::ScheduleContext::invalid());

HoughBaseAlg transform interface changes

All HoughBaseAlg::Transform and HoughBaseAlg::FastTransform functions now require a CLHEP::HepRandomEngine& reference argument to be passed in. The location of the argument depends on the specific function being called.

  size_t FastTransform(std::vector<art::Ptr<recob::Cluster>> const& clusIn,
                       std::vector<recob::Cluster>& ccol,  
                       std::vector< art::PtrVector<recob::Hit>>& clusHitsOut,
+                      CLHEP::HepRandomEngine& engine,
                       art::Event const& evt,
                       std::string const& label);

  size_t Transform(std::vector<art::Ptr<recob::Hit>> const& hits,
+                  CLHEP::HepRandomEngine& engine,
                   std::vector<unsigned int>* fpointId_to_clusterId,
                   unsigned int clusterId, // The id of the cluster we are examining
                   unsigned int* nClusters,
                   std::vector<protoTrack> *protoTracks);

  // interface to look for lines only on a set of hits,without slope and totalQ arrays
  size_t FastTransform(
-      std::vector<art::Ptr<recob::Hit>>      & clusIn,
+      std::vector<art::Ptr<recob::Hit>> const& clusIn,
       std::vector<art::PtrVector<recob::Hit>>& clusHitsOut,
+      CLHEP::HepRandomEngine& engine);

  // interface to look for lines only on a set of hits
  size_t FastTransform(
-      std::vector<art::Ptr<recob::Hit>>      & clusIn,
+      std::vector<art::Ptr<recob::Hit>> const& clusIn,
       std::vector<art::PtrVector<recob::Hit>>& clusHitsOut,
+      CLHEP::HepRandomEngine& engine,
       std::vector<double>& slope,
       std::vector<ChargeInfo_t>& totalQ);


The fuzzyClusterAlg::run_fuzzy_cluster call now requires an explicit reference to a CLHEP::HepRandomEngine object:

-    void run_fuzzy_cluster(const std::vector<art::Ptr<recob::Hit> >& allhits);
+    void run_fuzzy_cluster(const std::vector<art::Ptr<recob::Hit> >& allhits,
+                           CLHEP::HepRandomEngine& engine);


  • art::PtrMaker no longer requires a *this reference. See the miscellaneous breaking changes of art v3.
  • Remove *this from the instantiations:
    -  art::PtrMaker<recob::Shower> ptrMaker(event, *this);
    +  art::PtrMaker<recob::Shower> ptrMaker(event);

WeightCalc subclasses

The RandomNumberGenerator::getEngine(...) function cannot be called in any of the classes that inherit from evwgh::WeightCalc. To provide random-number engine access, an additional argument has been added to the Configure function. Please make the following change:

- Configure(fhicl::ParameterSet const&) override
+ Configure(fhicl::ParameterSet const&, CLHEP::HepRandomEngine& engine) override

where the engine reference can be used to create any CLHEP random-number distribution. Note that the engine variable is a reference to an art-owned engine.

art dump-config

The output of, for instance, lar --dump-config <file> may report warnings that were not reported by art in art v2. Further, the reported warnings may not require a resolution. There have been some scripts that checked for "excessive lines of output". This check is fragile. The most reliable check for this test is simply to ensure that art ends with status 0.