LArbys / LArCV

Liquid Argon Computer Vision
11 stars 9 forks source link

PyROOT issue in viewer (and proposed fix) #66

Closed coreyjadams closed 7 years ago

coreyjadams commented 7 years ago

Hi,

On Ubuntu 16.04, running root 6.04/06, and gcc 5.4, the viewer does not work properly. The problem is traced to the following line from mac/pyrgb/lib/datamanager.py: product = larcv.ProductName(i)

This function returns std::string, from core/DataFormat/ProductMap.h/cxx. For some reason, root6 has difficulty with these strings and I don't really understand.

It works just fine when I change the return type of ProductMap from 'const std::string' to 'const char *', and leave the implementation of the function and the viewer completely unchanged.

Can I push this modification?

drinkingkazu commented 7 years ago

Thanks for this report!

Just to be sure: we previously had an issue of this function not showing up in the dictionary (i.e. throws NameError for ProductName function as it does not exist). I just wanna make sure it is not related. When it doesn't work for you, is it a seg-fault?

coreyjadams commented 7 years ago

It's not a seg fault. This is the error message I get when the return value is const std::string:

IncrementalExecutor::executeFunction: symbol '_ZN5larcv11ProductNameENS_13ProductType_tE' unresolved while linking symbol '__cf_10'!
You are probably missing the definition of larcv::ProductName(larcv::ProductType_t)
Maybe you need to load the corresponding shared library?
Error in <TClingCallFunc::make_wrapper>: Failed to compile
  ==== SOURCE BEGIN ====
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-security"
__attribute__((used)) extern "C" void __cf_10(void* obj, int nargs, void** args, void* ret)
{
   if (ret) {
      new (ret) (const string) (larcv::ProductName(*(larcv::ProductType_t*)args[0]));
      return;
   }
   else {
      larcv::ProductName(*(larcv::ProductType_t*)args[0]);
      return;
   }
}
#pragma clang diagnostic pop
  ==== SOURCE END ====
Error in <TClingCallFunc::Exec(address, interpVal)>: Called with no wrapper, not implemented!
IncrementalExecutor::executeFunction: symbol '_ZN5larcv11ProductNameENS_13ProductType_tE' unresolved while linking symbol '__cf_14'!
You are probably missing the definition of larcv::ProductName(larcv::ProductType_t)
Maybe you need to load the corresponding shared library?
Error in <TClingCallFunc::make_wrapper>: Failed to compile
  ==== SOURCE BEGIN ====
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-security"
__attribute__((used)) extern "C" void __cf_14(void* obj, int nargs, void** args, void* ret)
{
   if (ret) {
      new (ret) (const string) (larcv::ProductName(*(larcv::ProductType_t*)args[0]));
      return;
   }
   else {
      larcv::ProductName(*(larcv::ProductType_t*)args[0]);
      return;
   }
}
#pragma clang diagnostic pop
  ==== SOURCE END ====
Error in <TClingCallFunc::Exec(address, interpVal)>: Called with no wrapper, not implemented!
IncrementalExecutor::executeFunction: symbol '_ZN5larcv11ProductNameENS_13ProductType_tE' unresolved while linking symbol '__cf_15'!
You are probably missing the definition of larcv::ProductName(larcv::ProductType_t)
Maybe you need to load the corresponding shared library?
Error in <TClingCallFunc::make_wrapper>: Failed to compile
  ==== SOURCE BEGIN ====
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-security"
__attribute__((used)) extern "C" void __cf_15(void* obj, int nargs, void** args, void* ret)
{
   if (ret) {
      new (ret) (const string) (larcv::ProductName(*(larcv::ProductType_t*)args[0]));
      return;
   }
   else {
      larcv::ProductName(*(larcv::ProductType_t*)args[0]);
      return;
   }
}
#pragma clang diagnostic pop
  ==== SOURCE END ====
Error in <TClingCallFunc::Exec(address, interpVal)>: Called with no wrapper, not implemented!
IncrementalExecutor::executeFunction: symbol '_ZN5larcv11ProductNameENS_13ProductType_tE' unresolved while linking symbol '__cf_16'!
You are probably missing the definition of larcv::ProductName(larcv::ProductType_t)
Maybe you need to load the corresponding shared library?
Error in <TClingCallFunc::make_wrapper>: Failed to compile
  ==== SOURCE BEGIN ====
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-security"
__attribute__((used)) extern "C" void __cf_16(void* obj, int nargs, void** args, void* ret)
{
   if (ret) {
      new (ret) (const string) (larcv::ProductName(*(larcv::ProductType_t*)args[0]));
      return;
   }
   else {
      larcv::ProductName(*(larcv::ProductType_t*)args[0]);
      return;
   }
}
#pragma clang diagnostic pop
  ==== SOURCE END ====
Error in <TClingCallFunc::Exec(address, interpVal)>: Called with no wrapper, not implemented!
Traceback (most recent call last):
  File "mac/view_rgb.py", line 14, in <module>
    rgbdisplay = rgbd.RGBDisplay(sys.argv[1:])
  File "/home/cadams/LArCV/mac/pyrgb/display/rgbdisplay.py", line 158, in __init__
    for prod in self.dm.keys['image2d']:
KeyError: 'image2d'

I think we have both seen this before, Kazu, in a few places. By the way, the proposed modification also requires this change in IOManager: std::string treename = std::string(ProductName(type)) + "" + name + "_tree"; std::string tree_desc = name + " tree"; std::string brname = std::string(ProductName(type)) + "" + name + "_branch";

coreyjadams commented 7 years ago

What a useless last comment, unless I include the line numbers for thos changed lines: Lines 182 and 184 of IOManager.cxx need to be modified to make the value of ProductName(type) a string to allow the '+' operation, I think.

drinkingkazu commented 7 years ago

Sounds great. Thanks for answering my question as well. It would be great if you can push. Thanks!

twongjirad commented 7 years ago

Was this fixed recently?

coreyjadams commented 7 years ago

Yes: https://github.com/LArbys/LArCV/commit/47ae9cc380d8702f4351f9913026172316558f9f

twongjirad commented 7 years ago

Thanks! Closing.