Home | News | Documentation | Download

MakeProxy to read external classes in TTree

Hello,
I am trying to use MakeProxy indirectly via the TTree::Draw() interface in order to read branches in the following file (80 MB): /afs/cern.ch/user/l/leyton/public/run_1044.root
which has a somewhat complicated structure and uses external classes, e.g. RDCluster.

To make this easier on beginner-level students, I would like to do this in the simplest way possible, with minimal dependence on external libraries. Following the prescription for hsimple described at the bottom of the TTree::MakeProxy() documentation, I can run

reco->Draw("readTree.cxx+");

which automatically creates generatedSel.h and the corresponding shared library. I can then access the variables at the first level of the reco tree using the branch names as if they were data members:

Double_t readTree() {
  Double_t bmean = baseline_mean->at(0);
  return bmean;
}

So far so good. My issue comes when I want to read variables at the next level, for example variables belonging to the vector<RDCluster*> stored inside, named “clusters”. What is the appropriate syntax for accessing, e.g. the 0th value of “charge_top” of the 0th RDCluster? I have tried

Double_t myCharge = (clusters[0]).charge_top->at(0);

and also many others, but I always get some error. In this case, the error is "error: no member named ‘charge_top’ in ‘TObject’. I have also tried including the “RDCluster.hh” header file and casting the TObject. Again, I would like to do this as simply as possible.

thank you,
Michael

_ROOT Version: 6.08/06
_Platform: Mac OS 10.11.6
Compiler: Not Provided

Before trying to access your tree, try:
gFile->MakeProject("MyFile", "*", "recreate++");

Thanks for your reply.
Promising, but I get the following errors:

root [1] _file0->MakeProject("RecoTree", "*", "recreate++");
MakeProject has generated 5 classes in RecoTree
RecoTree/MAKEP file has been generated
In file included from input_line_12:6:
In file included from ./RecoTreeProjectHeaders.h:1:
./EvRaw0.h:28:37: error: expected expression
   std::map<int,std::vector<double,*> > wf;          //
                                    ^
./EvRaw0.h:28:39: error: expected a type
   std::map<int,std::vector<double,*> > wf;          //
                                      ^
Error: rootcint: compilation failure (./RecoTreeProjectDict0ad9590df1_dictUmbrella.h)
In file included from RecoTreeProjectSource.cxx:3:
In file included from ./RecoTreeProjectHeaders.h:1:
./EvRaw0.h:28:37: error: expected expression
   std::map<int,std::vector<double,*> > wf;          //
                                    ^
./EvRaw0.h:28:39: error: expected a type
   std::map<int,std::vector<double,*> > wf;          //
                                      ^
RecoTreeProjectSource.cxx:7:10: fatal error: 'RecoTreeProjectDict.cxx' file not found
#include "RecoTreeProjectDict.cxx"

Well, @pcanal will have some fun again.

Just checked: I get the same error message on lxplus (CentOS 7.8) and ROOT version 6.20/04.

Hi Michael,
this looks like a bug in MakeProject (the code generated is broken, e.g. std::map<int,std::vector<double,*>). Could you please open a bug report at https://sft.its.cern.ch/jira/projects/ROOT with the simplest possible recipe to reproduce the issue, so we can take a look?

To unblock you in the meanwhile, maybe @pcanal can propose a workaround.

Cheers,
Enrico

Hi Enrico,

Thank you. I submitted bug report ROOT-10796:
https://sft.its.cern.ch/jira/browse/ROOT-10796

A workaround in the meanwhile would be helpful. I was hoping to remove the affected classes from the MakeProject generation, but it seems this feature is not yet enabled and only the default * is used.

best,
Michael

1 Like

Hi,
@pcanal Any news on this? Hoping the topic will not close.
thanks

Hi @pcanal, any chance you could take a look at this? thank you

To workaround the problem you can call MakeProject then correct the broken file (EvRaw0.h) and re-run the library building (. MAKEP)

See https://github.com/root-project/root/pull/5891

Hi @pcanal,
Thank you. I’m trying to check out one of the versions that you patched, but I do not see any of your tags listed here:
https://root.cern.ch/gitweb/?p=root.git
I am looking for 6.22/02, 6.20/08, 6.18/06, etc.
Do I need to wait?
thanks