Project

General

Profile

Feature #22147

would like art::Event::getManyLabelsByType

Added by Thomas Junk 4 months ago. Updated 21 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Infrastructure
Target version:
Start date:
03/15/2019
Due date:
% Done:

100%

Estimated time:
Spent time:
Scope:
Internal
Experiment:
DUNE
SSI Package:
Duration:

Description

I see an example of calling art::Event::getManyByType in larsim/LArG4/LArG4_module.cc, 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.

History

#1 Updated by Kyle Knoepfel 4 months ago

  • Description updated (diff)

#2 Updated by Thomas Junk 4 months 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 4 months 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 about 1 month 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 about 1 month 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 about 1 month 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 21 days ago

  • Status changed from Resolved to Closed


Also available in: Atom PDF