Before any of the tools can work on custom objects stored in a TTree, there must be full knowledge of all C++ data structures that are used in the TTree. This amounts to making sure that all the objects are known and translated by ROOT.NET. The ROOT.NET wrappers wrap all known ROOT objects. The same thing must be done for your custom objects. If there are no custom objects in your TTree you can skip this step.

The first step is to create a make file project that will build the DLL that contains the C++ objects. I tend to use ACLIC in order to accomplish this, and these instructions are geared towards that approach. Any approach that correctly builds the library and runs rootcint to generate the dictionaries is fine. The key is the dictionaries: that is what is used by ROOT.NET in order to translate the objects.

  1. Create a make file project
  2. Add the C++ files to it that contains the objects you are interested in having built.
  3. Create a small helper file called compile.C that contains the following code:
    void compile(char *fname)
    {
        gSystem->CompileMacro(fname, "k");
    }
  4. And then a make file that contains the following code to build two of these objects (it also will build the .NET translation libraries.
    #
    # Build the ROOT objects into dll's
    #
    
    all: netwrapper
    clean: cleanlibraries cleannetwrapper
    
    #
    # Some Defines to make life simpler
    #
    
    SolutionDir = ..\\
    
    ROOT = root -l -b -q
    ADDON = "c:\root\NETWrappers\bin\ROOT.NET Addon Library Converter.exe" c:\root\NETWrappers $(SolutionDir)
    
    DLLLibraries = MuonInBJet_cpp.dll BTagJet_cpp.dll
    
    #
    # Build the project that translates
    #
    
    WrapperProjectName = NTupleWrappers
    
    netwrapper: $(SolutionDir)$(WrapperProjectName)\\$(WrapperProjectName).vcxproj
    
    $(SolutionDir)$(WrapperProjectName)\\$(WrapperProjectName).vcxproj: libraries 
        $(ADDON) $(WrapperProjectName) $(DLLLibraries)
    
    cleannetwrapper:
        del /Q $(SolutionDir)$(WrapperProjectName)\\
    
    #
    # The root dll's that do the build
    #
    
    libraries: $(DLLLibraries)
    
    MuonInBJet_cpp.dll BTagJet_cpp.dll : MuonInBJet.cpp MuonInBJet.h BTagJet.cpp BTagJet.h
        $(ROOT) compile.C(\"MuonInBJet.cpp\")
        $(ROOT) compile.C(\"BTagJet.cpp\")
    
    cleanlibraries:
        del /Q MuonInBJet_cpp.dll
        del /Q BTagJet_cpp.dll
  5. When this runs, it will create DLL’s and the .lib files needed to access the DLL’s and link against them. Note the call to $(ADDON) – this is the stand-alone version of the converter that will create the ROOT.NET wrappers around the ROOT C++ objects. This process creates a second project (a C++/CLI project).
  6. Add this C++/CLI project to your solution
  7. Right click and select dependencies and make sure that the first makefile project is listed as a dependent. Sometimes you have to deal with re-running the wrapper maker, and you’ll get a funny dialog box in VS complaining that the C++/CLI project has been updated outside your project. Allow the reload to happen. When this happens you’ll have to build twice in a row to make everything work. And, yes, effort is made to prevent needless updating of the project file.

Last edited Aug 14, 2011 at 6:44 AM by gwatts, version 1

Comments

No comments yet.