Trouble generating dictionaries for custom class


I wrote a couple of custom classes for use with a CMSSW plugin, but I’m having trouble getting a dictionary without hundreds of lines of errors.

In particular, I’m trying to resolve

An exception of category 'FatalRootError' occurred while
   [0] Constructing the EventProcessor
   [1] Constructing module: class=MYPLUGIN label='demo'
   Additional Info:
      [a] Fatal Root Error: @SUB=TTree::Branch
The class requested (vector<MyClass>) for the branch "test" refer to an stl collection and do not have a compiled CollectionProxy.  Please generate the dictionary for this class (vector<MyClass>)

I’ve tried compiling the class definition file with .L, but it gives me quite a few errors, such as

In function `MyClass::IsA() const': undefined reference to `MyClass::Class()' In function `MyClass::ShowMembers(TMemberInspector&) const': undefined reference to `MyClass::Class()' (*something*) undefined reference to `ROOT::GenerateInitInstance(MyClass const*)' (*something*) undefined reference to `MyClass::Streamer(TBuffer&)' Some dictionary files are created when I do this, but things fail to build/compile.

I’ve tried simply including “TInterpreter.h” in my plugin, then adding a line

gInterpreter->GenerateDictionary("std::vector<MyClass>","vector;MyClass.h"); which also gives me errors similar to the above. Several AutoDict_ dictionaries are created when I do this, but everything fails to build/compile. This works for generating the dictionary for something made of STL classes like std::vector<std::map<std::string,int>> but not for my own class.

Eventually, all the shared libraries, dictionaries, plugins, etc. will need to be compiled and linked/built by something called SCRAM. I’ve tried compiling my class files and class headers with SCRAM (it needs a very specific directory structure and a BuildFile, the details of which are not important here – essentially, once set up, SCRAM compiles my C++ source files), and they compile and build ONLY if I do not include the lines

// MyClass.h

[/code] Otherwise, I get similar undefined reference errors. I still cannot use this classes in my CMSSW plugin, as there is no valid dictionary.

In any case, even if I had a valid dictionary – what would I do with it? Where does it go?

The end goal is to be able to write my class to a TTree and save it in a ROOT file.

I can post any of my files as necessary. Thanks in advance.


Unless MyClass inherits from TObject you shouldn’t use ClassDef in the CMSSW environment. But you still need a dictionary; please refer to the CMSSW documentation on how that’s done for them.

Cheers, Axel.