eic / EICrecon

EIC Reconstruction - JANA based
https://eic.github.io/EICrecon
GNU Lesser General Public License v3.0
6 stars 28 forks source link

Inaccessible branches from `podio::EventStore` #334

Closed c-dilks closed 1 year ago

c-dilks commented 1 year ago

Environment: (where does this bug occur, have you tried other environments)

Steps to reproduce: (give a step by step account of how to trigger the bug)

Some branches (Collections) are inaccessible when reading the output data using podio::EventStore (the common EventStore, not EICrecon's podio plugin version).

Here is a ROOT macro test_read.C to demonstrate the issue; it can be run on any recent eicrecon output file that has the specified branches:

R__LOAD_LIBRARY(podio)
R__LOAD_LIBRARY(podioDict)
R__LOAD_LIBRARY(podioRootIO)
R__LOAD_LIBRARY(edm4hep)
R__LOAD_LIBRARY(edm4eic)
R__LOAD_LIBRARY(edm4hepDict)
R__LOAD_LIBRARY(edm4eicDict)
R__LOAD_LIBRARY(fmt)
#include "podio/EventStore.h"
#include "podio/ROOTReader.h"
#include "podio/CollectionBase.h"
#include "fmt/format.h"

#include "edm4hep/MCParticleCollection.h"
#include "edm4eic/ReconstructedParticleCollection.h"
#include "edm4eic/MCRecoParticleAssociationCollection.h"

void test_read(
    int testNum=1,
    const char *root_file_name = "rec.tree.edm4eic.root"
    )
{
  podio::ROOTReader reader;
  podio::EventStore store;
  reader.openFile(root_file_name);
  store.setReader(&reader);

  if(testNum==0) { // `get` the collections from the 1st event, and print their sizes
    auto &simParts = store.get<edm4hep::MCParticleCollection>("MCParticles");
    auto &recParts = store.get<edm4eic::ReconstructedParticleCollection>("ReconstructedChargedParticles");
    fmt::print("simParts.size={}\n",simParts.size());
    fmt::print("recParts.size={}\n",recParts.size());
  }

  else if(testNum==1) { // `get` the association collection from the 1st event
    auto &assocs = store.get<edm4eic::MCRecoParticleAssociationCollection>("ReconstructedChargedParticlesAssociations");
    fmt::print("assocs.size={}\n",assocs.size());

  }

  else if(testNum==2) { // print the collection and data types
    std::vector<std::string> collNames = {
      "MCParticles"
        , "ReconstructedChargedParticles"
        , "ReconstructedChargedParticlesAssociations"
    };
    for(auto collName : collNames) {
      const auto collID = store.getCollectionIDTable()->collectionID(collName);
      podio::CollectionBase *collBase;
      if(store.get(collID, collBase))
        fmt::print("\ndata types for collection '{}'\n{:>50}\n{:>50}\n{:>50}\n",
            collName,
            collBase->getTypeName(),
            collBase->getValueTypeName(),
            collBase->getDataTypeName()
            );
    }
  }

}

Given eicrecon output file rec.tree.edm4eic.root, run the three tests:

root -b -q -l test_read.C'(0)'
root -b -q -l test_read.C'(1)'
root -b -q -l test_read.C'(2)'

Expected Result: (what do you expect when you execute the steps above)

Test 0 is okay, since it only access MCParticles and ReconstructedChargedParticles

Processing test_read.C(0)...
simParts.size=10
recParts.size=1

Test 1 should be similar, something like this:

Processing test_read.C(1)...
assocs.size=10

Test 2 should print the types

Processing test_read.C(2)...

data types for collection 'MCParticles'
                     edm4hep::MCParticleCollection
                               edm4hep::MCParticle
                           edm4hep::MCParticleData

data types for collection 'ReconstructedChargedParticles'
          edm4eic::ReconstructedParticleCollection
                    edm4eic::ReconstructedParticle
                edm4eic::ReconstructedParticleData

data types for collection 'ReconstructedChargedParticlesAssociations'
      edm4eic::MCRecoParticleAssociationCollection
                edm4eic::MCRecoParticleAssociation
            edm4eic::MCRecoParticleAssociationData

Actual Result: (what do you get when you execute the steps above)

Test 0 is okay, since it only access MCParticles and ReconstructedChargedParticles

Processing test_read.C(0)...
simParts.size=10
recParts.size=1

Test 1 crashes, since it accesses ReconstructedChargedParticlesAssociations, one of the problematic branches

Processing test_read.C(1)...

 *** Break *** segmentation violation

===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00007f07a91b5c46 in wait4 () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007f07a912a2fb in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007f07a982035d in TUnixSystem::StackTrace() () from /opt/software/linux-debian-x86_64/gcc-12.2.0/root-6.26.06-to6dg6u6muoorlvtlnt6sfkin2lvmxhl/bin/../lib/libCore.so.6.26
#3  0x00007f07a981fcf4 in TUnixSystem::DispatchSignals(ESignals) () from /opt/software/linux-debian-x86_64/gcc-12.2.0/root-6.26.06-to6dg6u6muoorlvtlnt6sfkin2lvmxhl/bin/../lib/libCore.so.6.26
#4  <signal handler called>
#5  0x00007f07a9234609 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#6  0x00007f0798710b29 in podio::CollectionIDTable::name[abi:cxx11](int) const () from /opt/software/linux-debian-x86_64/gcc-12.2.0/podio-0.15-ejugz5lwj3trxsarqd4i6ljws3jcmpic/lib/libpodio.so
#7  0x00007f07987141d5 in podio::EventStore::get(int, podio::CollectionBase*&) const () from /opt/software/linux-debian-x86_64/gcc-12.2.0/podio-0.15-ejugz5lwj3trxsarqd4i6ljws3jcmpic/lib/libpodio.so
#8  0x00007f07983b4098 in edm4eic::MCRecoParticleAssociationCollectionData::setReferences(podio::ICollectionProvider const*, bool) () from /home/dilks/builds/eic/local/lib/libedm4eic.so
#9  0x00007f07983b0d90 in edm4eic::MCRecoParticleAssociationCollection::setReferences(podio::ICollectionProvider const*) () from /home/dilks/builds/eic/local/lib/libedm4eic.so
#10 0x00007f0798713e13 in podio::EventStore::doGet(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, podio::CollectionBase*&, bool) const () from /opt/software/linux-debian-x86_64/gcc-12.2.0/podio-0.15-ejugz5lwj3trxsarqd4i6ljws3jcmpic/lib/libpodio.so
#11 0x00007f0797e226ff in ?? ()
#12 0x0000000000000056 in ?? ()
#13 0x0000000000000000 in ?? ()
===========================================================

The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum https://root.cern/forum
Only if you are really convinced it is a bug in ROOT then please submit a
report at https://root.cern/bugs Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5  0x00007f07a9234609 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#6  0x00007f0798710b29 in podio::CollectionIDTable::name[abi:cxx11](int) const () from /opt/software/linux-debian-x86_64/gcc-12.2.0/podio-0.15-ejugz5lwj3trxsarqd4i6ljws3jcmpic/lib/libpodio.so
#7  0x00007f07987141d5 in podio::EventStore::get(int, podio::CollectionBase*&) const () from /opt/software/linux-debian-x86_64/gcc-12.2.0/podio-0.15-ejugz5lwj3trxsarqd4i6ljws3jcmpic/lib/libpodio.so
#8  0x00007f07983b4098 in edm4eic::MCRecoParticleAssociationCollectionData::setReferences(podio::ICollectionProvider const*, bool) () from /home/dilks/builds/eic/local/lib/libedm4eic.so
#9  0x00007f07983b0d90 in edm4eic::MCRecoParticleAssociationCollection::setReferences(podio::ICollectionProvider const*) () from /home/dilks/builds/eic/local/lib/libedm4eic.so
#10 0x00007f0798713e13 in podio::EventStore::doGet(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, podio::CollectionBase*&, bool) const () from /opt/software/linux-debian-x86_64/gcc-12.2.0/podio-0.15-ejugz5lwj3trxsarqd4i6ljws3jcmpic/lib/libpodio.so
#11 0x00007f0797e226ff in ?? ()
#12 0x0000000000000056 in ?? ()
#13 0x0000000000000000 in ?? ()
===========================================================

Test 2 runs correctly until we try to access ReconstructedChargedParticlesAssociations. You can generalize the for loop here, using auto collNames = collIDTable->names(); instead; in this case you will find many more branches that crash upon access.

Processing test_read.C(2)...

data types for collection 'MCParticles'
                     edm4hep::MCParticleCollection
                               edm4hep::MCParticle
                           edm4hep::MCParticleData

data types for collection 'ReconstructedChargedParticles'
          edm4eic::ReconstructedParticleCollection
                    edm4eic::ReconstructedParticle
                edm4eic::ReconstructedParticleData

 *** Break *** segmentation violation

===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00007fcbd58a3c46 in wait4 () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007fcbd58182fb in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007fcbd5f0e35d in TUnixSystem::StackTrace() () from /opt/software/linux-debian-x86_64/gcc-12.2.0/root-6.26.06-to6dg6u6muoorlvtlnt6sfkin2lvmxhl/bin/../lib/libCore.so.6.26
#3  0x00007fcbd5f0dcf4 in TUnixSystem::DispatchSignals(ESignals) () from /opt/software/linux-debian-x86_64/gcc-12.2.0/root-6.26.06-to6dg6u6muoorlvtlnt6sfkin2lvmxhl/bin/../lib/libCore.so.6.26
#4  <signal handler called>
#5  0x00007fcbd5922609 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#6  0x00007fcbc4dfeb29 in podio::CollectionIDTable::name[abi:cxx11](int) const () from /opt/software/linux-debian-x86_64/gcc-12.2.0/podio-0.15-ejugz5lwj3trxsarqd4i6ljws3jcmpic/lib/libpodio.so
#7  0x00007fcbc4e021d5 in podio::EventStore::get(int, podio::CollectionBase*&) const () from /opt/software/linux-debian-x86_64/gcc-12.2.0/podio-0.15-ejugz5lwj3trxsarqd4i6ljws3jcmpic/lib/libpodio.so
#8  0x00007fcbc4aa2098 in edm4eic::MCRecoParticleAssociationCollectionData::setReferences(podio::ICollectionProvider const*, bool) () from /home/dilks/builds/eic/local/lib/libedm4eic.so
#9  0x00007fcbc4a9ed90 in edm4eic::MCRecoParticleAssociationCollection::setReferences(podio::ICollectionProvider const*) () from /home/dilks/builds/eic/local/lib/libedm4eic.so
#10 0x00007fcbc4e01e13 in podio::EventStore::doGet(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, podio::CollectionBase*&, bool) const () from /opt/software/linux-debian-x86_64/gcc-12.2.0/podio-0.15-ejugz5lwj3trxsarqd4i6ljws3jcmpic/lib/libpodio.so
#11 0x00007fcbc4e021e8 in podio::EventStore::get(int, podio::CollectionBase*&) const () from /opt/software/linux-debian-x86_64/gcc-12.2.0/podio-0.15-ejugz5lwj3trxsarqd4i6ljws3jcmpic/lib/libpodio.so
#12 0x00007fcbc450f849 in ?? ()
#13 0x0000000000000035 in ?? ()
#14 0x72a4a3e65fe47d00 in ?? ()
#15 0x00007fcbd5b30ec0 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#16 0xffff01ffffff9c88 in ?? ()
#17 0x00007fcbd5abb860 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#18 0x00007ffe4c5afee8 in ?? ()
#19 0x00000002000000c8 in ?? ()
#20 0x00007fcbd520d7f0 in ?? () from /usr/._local/of5cf3tn5a7rmsgaoyaet2arrijpbqvt/lib/libRIO.so
#21 0x00007fcbd5abb840 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#22 0x000055a900b506b0 in ?? ()
#23 0x0000000000000029 in ?? ()
#24 0x0000000000000029 in ?? ()
#25 0x000000000073656c in ?? ()
#26 0x000055a8f4966720 in ?? ()
#27 0x00007fcbd186e550 in ?? () from /usr/._local/of5cf3tn5a7rmsgaoyaet2arrijpbqvt/lib/libCling.so
#28 0x00007ffe4c5afd18 in ?? ()
#29 0x000055a8f86cd5d0 in ?? ()
#30 0x000055a8f6abc710 in ?? ()
#31 0x00007ffe4c5afe90 in ?? ()
#32 0x00007ffe4c5b0128 in ?? ()
#33 0x00007ffe4c5b0148 in ?? ()
#34 0x00007ffe4c5b0168 in ?? ()
#35 0x0000000000000000 in ?? ()
===========================================================

The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum https://root.cern/forum
Only if you are really convinced it is a bug in ROOT then please submit a
report at https://root.cern/bugs Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5  0x00007fcbd5922609 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#6  0x00007fcbc4dfeb29 in podio::CollectionIDTable::name[abi:cxx11](int) const () from /opt/software/linux-debian-x86_64/gcc-12.2.0/podio-0.15-ejugz5lwj3trxsarqd4i6ljws3jcmpic/lib/libpodio.so
#7  0x00007fcbc4e021d5 in podio::EventStore::get(int, podio::CollectionBase*&) const () from /opt/software/linux-debian-x86_64/gcc-12.2.0/podio-0.15-ejugz5lwj3trxsarqd4i6ljws3jcmpic/lib/libpodio.so
#8  0x00007fcbc4aa2098 in edm4eic::MCRecoParticleAssociationCollectionData::setReferences(podio::ICollectionProvider const*, bool) () from /home/dilks/builds/eic/local/lib/libedm4eic.so
#9  0x00007fcbc4a9ed90 in edm4eic::MCRecoParticleAssociationCollection::setReferences(podio::ICollectionProvider const*) () from /home/dilks/builds/eic/local/lib/libedm4eic.so
#10 0x00007fcbc4e01e13 in podio::EventStore::doGet(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, podio::CollectionBase*&, bool) const () from /opt/software/linux-debian-x86_64/gcc-12.2.0/podio-0.15-ejugz5lwj3trxsarqd4i6ljws3jcmpic/lib/libpodio.so
#11 0x00007fcbc4e021e8 in podio::EventStore::get(int, podio::CollectionBase*&) const () from /opt/software/linux-debian-x86_64/gcc-12.2.0/podio-0.15-ejugz5lwj3trxsarqd4i6ljws3jcmpic/lib/libpodio.so
#12 0x00007fcbc450f849 in ?? ()
#13 0x0000000000000035 in ?? ()
#14 0x72a4a3e65fe47d00 in ?? ()
#15 0x00007fcbd5b30ec0 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#16 0xffff01ffffff9c88 in ?? ()
#17 0x00007fcbd5abb860 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#18 0x00007ffe4c5afee8 in ?? ()
#19 0x00000002000000c8 in ?? ()
#20 0x00007fcbd520d7f0 in ?? () from /usr/._local/of5cf3tn5a7rmsgaoyaet2arrijpbqvt/lib/libRIO.so
#21 0x00007fcbd5abb840 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#22 0x000055a900b506b0 in ?? ()
#23 0x0000000000000029 in ?? ()
#24 0x0000000000000029 in ?? ()
#25 0x000000000073656c in ?? ()
#26 0x000055a8f4966720 in ?? ()
#27 0x00007fcbd186e550 in ?? () from /usr/._local/of5cf3tn5a7rmsgaoyaet2arrijpbqvt/lib/libCling.so
#28 0x00007ffe4c5afd18 in ?? ()
#29 0x000055a8f86cd5d0 in ?? ()
#30 0x000055a8f6abc710 in ?? ()
#31 0x00007ffe4c5afe90 in ?? ()
#32 0x00007ffe4c5b0128 in ?? ()
#33 0x00007ffe4c5b0148 in ?? ()
#34 0x00007ffe4c5b0168 in ?? ()
#35 0x0000000000000000 in ?? ()
===========================================================
c-dilks commented 1 year ago

Another, maybe related problem: the MCParticles branch becomes inaccessible after reading one event, when attempting to read the second. For example:

  for(unsigned e=0; e<reader.getEntries(); e++) {
    // access collections, and print their sizes
    fmt::print("Event {}:",e);
    auto &simParts = store.get<edm4hep::MCParticleCollection>("MCParticles"); fmt::print(" simParts.size={}",simParts.size());
    auto &recParts = store.get<edm4eic::ReconstructedParticleCollection>("ReconstructedChargedParticles"); fmt::print(" recParts.size={}",recParts.size());
    fmt::print("\n");
    // next event
    store.clear();
    reader.endOfEvent();
  }

Expected result:

testing on single-particle simulations, reconstructed from Juggler

Event 0: simParts.size=4 recParts.size=1
Event 1: simParts.size=3 recParts.size=1
Event 2: simParts.size=3 recParts.size=1
Event 3: simParts.size=3 recParts.size=1
Event 4: simParts.size=6 recParts.size=1
Event 5: simParts.size=2 recParts.size=1
...

Actual result:

Tested on DIS production 22.11.0, an updated file from Dmitry, and on a file I produced locally from eicrecon

Event 0: simParts.size=4 recParts.size=1

 *** Break *** segmentation violation
Event 1:

===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00007fcaa44c5c46 in wait4 () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007fcaa443a2fb in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007fcaa4b3035d in TUnixSystem::StackTrace() () from /opt/software/linux-debian-x86_64/gcc-12.2.0/root-6.26.06-to6dg6u6muoorlvtlnt6sfkin2lvmxhl/bin/../lib/libCore.so.6.26
#3  0x00007fcaa4b2fcf4 in TUnixSystem::DispatchSignals(ESignals) () from /opt/software/linux-debian-x86_64/gcc-12.2.0/root-6.26.06-to6dg6u6muoorlvtlnt6sfkin2lvmxhl/bin/../lib/libCore.so.6.26
#4  <signal handler called>
#5  0x00007fca937abe28 in edm4hep::MutableMCParticle::MutableMCParticle(edm4hep::MCParticleObj*) () from /opt/software/linux-debian-x86_64/gcc-12.2.0/edm4hep-0.6-i2hmstpmbqgbd737obs6jk3al3ruyu6t/lib/libedm4hep.so
#6  0x00007fca937ad23f in edm4hep::MCParticleCollection::operator[](unsigned int) () from /opt/software/linux-debian-x86_64/gcc-12.2.0/edm4hep-0.6-i2hmstpmbqgbd737obs6jk3al3ruyu6t/lib/libedm4hep.so
#7  0x00007fca937af795 in edm4hep::MCParticleCollectionData::setReferences(podio::ICollectionProvider const*, bool) () from /opt/software/linux-debian-x86_64/gcc-12.2.0/edm4hep-0.6-i2hmstpmbqgbd737obs6jk3al3ruyu6t/lib/libedm4hep.so
#8  0x00007fca93a23e13 in podio::EventStore::doGet(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, podio::CollectionBase*&, bool) const () from /opt/software/linux-debian-x86_64/gcc-12.2.0/podio-0.15-ejugz5lwj3trxsarqd4i6ljws3jcmpic/lib/libpodio.so
#9  0x00007fca93132c7f in ?? ()
#10 0x00005556e76ec920 in ?? ()
#11 0x0000000000000000 in ?? ()
===========================================================

The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum https://root.cern/forum
Only if you are really convinced it is a bug in ROOT then please submit a
report at https://root.cern/bugs Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5  0x00007fca937abe28 in edm4hep::MutableMCParticle::MutableMCParticle(edm4hep::MCParticleObj*) () from /opt/software/linux-debian-x86_64/gcc-12.2.0/edm4hep-0.6-i2hmstpmbqgbd737obs6jk3al3ruyu6t/lib/libedm4hep.so
#6  0x00007fca937ad23f in edm4hep::MCParticleCollection::operator[](unsigned int) () from /opt/software/linux-debian-x86_64/gcc-12.2.0/edm4hep-0.6-i2hmstpmbqgbd737obs6jk3al3ruyu6t/lib/libedm4hep.so
#7  0x00007fca937af795 in edm4hep::MCParticleCollectionData::setReferences(podio::ICollectionProvider const*, bool) () from /opt/software/linux-debian-x86_64/gcc-12.2.0/edm4hep-0.6-i2hmstpmbqgbd737obs6jk3al3ruyu6t/lib/libedm4hep.so
#8  0x00007fca93a23e13 in podio::EventStore::doGet(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, podio::CollectionBase*&, bool) const () from /opt/software/linux-debian-x86_64/gcc-12.2.0/podio-0.15-ejugz5lwj3trxsarqd4i6ljws3jcmpic/lib/libpodio.so
#9  0x00007fca93132c7f in ?? ()
#10 0x00005556e76ec920 in ?? ()
#11 0x0000000000000000 in ?? ()
===========================================================
DraTeots commented 1 year ago

Hopefully will be fixed with PODIO update

c-dilks commented 1 year ago

No longer using EventStore, therefore no longer relevant.