Using templates, inheritance and ACLIC


I have built a template “TProofCollection” inheriting from both TNamed and std::vector:

class TProofCollection:public TNamed, public std::vector {
TProofCollection(const char* title = “”, const char* name = “”):
TNamed(title, name) {}


typedef TProofCollection TProofCollectionI;
typedef TProofCollection TProofCollectionF;
typedef TProofCollection TProofCollectionD;

On the .C file I just have to do:

[code]#include “TProofCollection.h”

#if !defined(CINT)

And then I can build TProofCollection’s of ints, floats and doubles.

However when I try to have a TProofCollection (where EventInfo is some private class inheriting from TObject with a few fields) I am able to compile everything with ACLIC (no errors), but I cannot even construct an object of that class with the error:

Error: Can't call TProofCollection<EventInfo>::TProofCollection<EventInfo>("Name","Title") in current scope proofcollection.C:36: Possible candidates are... (in TProofCollection<EventInfo>) *** Interpreter error recovered ***

If I try to build a TSelector derived class that uses a TProofCollection I get:

Info in <TUnixSystem::ACLiC>: creating shared library /mnt_pool/fanaeXXX/user/iglez/PROOF/TopAnalysis/./ dlopen error: /mnt_pool/fanae105/user/iglez/PROOF/TopAnalysis/./ undefined symbol: _ZN16TProofCollectionI9EventInfoE11ShowMembersER16TMemberInspectorPc Load Error: Failed to load Dynamic link library /mnt_pool/fanaeXXX/user/iglez/PROOF/TopAnalysis/./ /usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crt1.o: In function `_start': (.text+0x20): undefined reference to `main' /mnt_pool/fanaeXXX/user/iglez/PROOF/TopAnalysis/./MyAnalysisMiniTrees_C_ACLiC_dict.o: In function `TProofCollection<EventInfo>::IsA() const': MyAnalysisMiniTrees_C_ACLiC_dict.cxx:(.text._ZNK16TProofCollectionI9EventInfoE3IsAEv[TProofCollection<EventInfo>::IsA() const]+0xd): undefined reference to `TProofCollection<EventInfo>::Class()' /mnt_pool/fanaeXXX/user/iglez/PROOF/TopAnalysis/./MyAnalysisMiniTrees_C_ACLiC_dict.o:([vtable for TProofCollection<EventInfo>]+0x1d0): undefined reference to `TProofCollection<EventInfo>::ShowMembers(TMemberInspector&, char*)' /mnt_pool/fanaeXXX/user/iglez/PROOF/TopAnalysis/./MyAnalysisMiniTrees_C_ACLiC_dict.o:([vtable for TProofCollection<EventInfo>]+0x1d8): undefined reference to `TProofCollection<EventInfo>::Streamer(TBuffer&)' collect2: ld returned 1 exit status *** Interpreter error recovered ***

Which points me to some problem in the ACLIC creation of the dictionaries. I wonder if I have hit a limitation in ACLIC/ROOT or, most probably, I am missing something on my code.

I have attached the quite simple code. Just unpack it and run proofcollection.C to see the effect.
proofcollection.tar.gz (66.9 KB)


you need to create a dictionary for TProofCollection. See e.g. /viewtopic.php?t=10029 on how to easily do that for templates.

Cheers, Axel.

Hi Axel,

Thank you very much for your useful information. I could go a bit further with your recommendation. I added the lines

#pragma link C++ class TProofCollection;

to a file I load with ACLIC.So I can now build objects of type TProofCollection. However when I try to use some of the inherited methods from std::vector I fail. For example:
… (loading dictionaries with ACLIC)

root [2] TProofCollection<EventInfo>* col = new TProofCollection<EventInfo>("name", "title")
root [3] EventInfo ei
root [4] col->push_back(ei)
Error: Can't call TProofCollection<EventInfo>::push_back(ei) in current scope (tmpfile):1:
Possible candidates are...
(in TProofCollection<EventInfo>)
(in vector<EventInfo,allocator<EventInfo> >)
*** Interpreter error recovered ***

I have attached the file with the files modified accordingly. Do you know by chance what else I am missing?


proofcollection.tar.gz (98.6 KB)


you should also create the dictionary for vector.

Cheers, Axel.


Thanks to Gerry (see post [url]Collections in PROOF I found the solution. See there for details but basically what was missing in my code is the set of pragmas for the iterators. For example I had to add:

#pragma link C++ class TProofCollection<EventInfo>; #pragma link C++ class std::vector<EventInfo>; #pragma link C++ class std::vector<EventInfo>::iterator; #pragma link C++ operators std::vector<EventInfo>::iterator; #pragma link C++ class std::vector<EventInfo>::const_iterator; #pragma link C++ operators std::vector<EventInfo>::const_iterator; #pragma link C++ class std::vector<EventInfo>::reverse_iterator; #pragma link C++ operators std::vector<EventInfo>::reverse_iterator;

to my newly created collection of EventInfo objects.