Project

General

Profile

Support #24900

NOvA transitioning Assn creation from art2 to art3

Added by Brian Rebel about 2 months ago. Updated about 2 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
09/02/2020
Due date:
% Done:

100%

Estimated time:
Scope:
Internal
Experiment:
NOvA
SSI Package:
art
Duration:

Description

The current way NOvA creates Assns is as

//----------------------------------------------------------------------
template<class T, class U> inline bool util::CreateAssn(art::EDProducer const& prod,
                                                        art::Event           & evt,
                                                        std::vector<T>       & a,
                                                        art::Ptr<U>            b,
                                                        art::Assns<T,U>      & assn,
                                                        size_t                 indx,
                                                        std::string     const& instance)
{
  bool ret = true;

  if(indx == UINT_MAX) indx = a.size()-1;

  try{
    art::ProductID aid = prod.getProductID< std::vector<T> >(instance);
    art::Ptr<T> aptr(aid, indx, evt.productGetter(aid));
    assn.addSingle(aptr, b);
  }
  catch(cet::exception &e){
    mf::LogWarning("AssociationUtil") << "unable to create requested " 
                      << "art:Assns, exception thrown: " 
                      << e;
    ret = false;
  }

  return ret;
}

where we get the product ID from the EDProducer making the objects and then use that to create an art::Ptr that then goes into the Assn. How should we change the above code to work in art3?

History

#1 Updated by Kyle Knoepfel about 2 months ago

  • Status changed from New to Feedback
  • Description updated (diff)

Brian, see https://github.com/LArSoft/lardata/blob/0fa94ca6184b5d75e2f3c2895811ba960265e071/lardata/Utilities/AssociationUtil.h#L581 and following. In particular, the producer argument is not necessary in art 3. There is code at the bottom of the file that will support old code that passes a reference to a producer.

Note that LArSoft intends to get rid of its CreateAssn utilities in favor of art::PtrMaker, art::Assns::addSingle, and now art::Assns::addMany.

Please let us know if this is sufficient to address your need.

#2 Updated by Brian Rebel about 2 months ago

Thanks, Kyle. I'll give this a shot. I will leave the future of NOvA's CreateAssn up to others - my main goal is just getting the code compiling with art3.

#3 Updated by Alexander Himmel about 2 months ago

First, totally agree with Brian that we should prioritize getting things working now since we have a lot of computing upgrades in flight with complicated interconnections.

Second, what is the benefit of the new methods instead of the utility? Trying to change over a lot of legacy NOvA code sounds like a fairly painful process, so the benefits would need to be fairly substantial, IMHO.

#4 Updated by Kyle Knoepfel about 2 months ago

Alex, Brian, yes I agree the goal here should be to get things working with minimal changes, which is why my statement was prefaced with "Note that".

The LArSoft collection of CreateAssn overloads has become very large and cumbersome to use. Upon inspection, it became clear that most of the utilities were either unnecessary or were trying to implement an "addMany" functionality, which was not natively supported by art. The cleanest solution was therefore to provide the required functionality by art (as of art 3.04) so that users don't have to implement it themselves.

The main benefit to moving away from the CreateAssn utilities in the future is that you wouldn't be maintaining it. In other words, we wouldn't be having this conversation. ;-)

#5 Updated by Kyle Knoepfel about 2 months ago

  • % Done changed from 0 to 100
  • Status changed from Feedback to Closed


Also available in: Atom PDF