Feature #16547

Updated by Kyle Knoepfel over 3 years ago

I would like to be able to figure out from the data file how associations connect objects.

The straightforward way for me to do that is to get an Assns<L,R> object, get the first item in the list, and look at the ProductID of each of the two lists it's associating. Then I want to figure out what label/process they each come from. That's trivially done by using productToBranch() in the BranchMapReader code, but that object is hidden as a private element of the DataGetterHelper which is in turn private inside the Event class.

Either making user-accessible get() calls for experts to dig down to the BranchMapReader, or providing top-level calls in Event would work.

I can trivially hack my own copy of the code base, but I'm planning to maintain downstream projects, and it would be convenient to have it patched into the release.

Here's how my code looks:

<pre><code class="cpp">

const gallery::BranchMapReader& bmr = ev.dataGetterHelper()->branchMapReader(); // these are the functions I hacked in to expose the internals

std::cout << "Associations " << std::endl;

typedef art::Assns<recob::Hit,recob::Wire> assn_t;

gallery::Handle< assn_t > assnhandle;

for(auto item: findByType<assn_t>(ev.getTTree())) {

cout<< "LABEL " << item.second << std::endl;


if(assnhandle.isValid()) {

std::cout << "Found " << assnhandle->size() << " associations." << std::endl;

if(assnhandle->size()>0) {

// Get first.

std::pair<art::Ptr<recob::Hit>,art::Ptr<recob::Wire>> p = *assnhandle->begin();

std::cout << << "\t" << p.first.key() << std::endl;

const art::BranchDescription* desc1 = bmr.productToBranch(;

const art::BranchDescription* desc2 = bmr.productToBranch(;

std::cout << "Links " <<desc1->branchName() << " to " << desc2->branchName() << std::endl;