Feature #22147

would like art::Event::getManyLabelsByType

Added by Thomas Junk over 1 year ago. Updated over 1 year ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:
Spent time:
SSI Package:


I see an example of calling art::Event::getManyByType in larsim/LArG4/, and would like to use it to read in many instances of artdaq::Fragments. I might know all their labels, but want to be prepared for a case where I want to read all of them in, even with new labels I haven't seen before (the daq group might throw us some curveballs).

I'd like to do some selection on the labels as I am not interested in reading in all fragments, and I would like to even call removeCachedProduct in between processing each of these fragments in order to save memory. I'd therefore rather not have all of the products read in by getManyByType in memory all at once.

A proposed solution: a new function (or some way to call existing functions) that gets all the labels of branches containing a specified data product that we can use as input to GetValidHandle or GetByLabel. The function should not read the contents of the data products into memory, just give us the labels. We still have to give it an example handle so it knows what data product to look for.


#1 Updated by Kyle Knoepfel over 1 year ago

  • Description updated (diff)

#2 Updated by Thomas Junk over 1 year ago

I should mention that the instances should be returned as well, either separately or as part of the label strings with colons in a way that GetByLabel or GetValidHandle can use.

#3 Updated by Kyle Knoepfel over 1 year ago

  • Status changed from New to Accepted

The request sounds reasonable. We will meet with you to learn more about the required behavior and constraints.

#4 Updated by Kyle Knoepfel over 1 year ago

  • % Done changed from 0 to 100
  • Target version set to 3.03.00
  • Assignee set to Kyle Knoepfel
  • Status changed from Accepted to Resolved
  • Category set to Infrastructure

This has been implemented with commits art:71b0187 and art:c4c352c. The interface is called getInputTags instead of getManyLabelsByType for the following reasons:

  • The module label is insufficient to fully specify the product. The art::InputTag will encode all the necessary information (except for the type, which is user-provided).
  • Although the 'ByType' suffix parallels the getManyByType name, it could be a cumbersome name to type, especially when the syntax already requires a C++ type.
  • This will be the first release to offer a getMany function that directly returns an std::vector<Handle<T>> object.

#5 Updated by Kyle Knoepfel over 1 year ago

An additional function, getProductTokens has been added so that users will only need to specify the type once. For example:

auto const tokens = event.getProductTokens<MyProduct>();
for (auto const& token : tokens) {
  auto const h = event.getValidHandle(token);

Note that it is not required to specify MyProduct when calling getValidHandle with a token.

#6 Updated by Thomas Junk over 1 year ago

Many thanks! We will give this a try at some point. Currently we are relying on knowing a priori what the tags are and this new feature lets us be more flexible as we had asked.

#7 Updated by Kyle Knoepfel over 1 year ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF