There are a number of ways you can turn your .ntup and .ntupom files into a C# class you can code LINQ queries against. You can use a command line utility, for example. Or you can rather use an MSBuild task (which is preferred). The advantage of the MSBuild task is that it isn’t a separate project and dependency resolution happens automatically.

Unfortunately, you have to code your project file by hand right now as I’ve not been able to automate the initial setup yet. However, it isn’t too difficult!

  1. Edit the project you are going to add the ntup and ntupom files to. Right click on the project name, and about half way down the list appears an option to Edit the Project File. Or you can rather select the Unload project and then right click again and select Open project file.
  2. Find the c# target include line. All edits should be made after this line. It should look something like the following:
    <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  3. Add the following XML code to the file. This will define a new target to run, and specify all the input and output files for dependency checking.
    <Import Project="$(ROOTSYS)\NETWrappers\LINQ\build\LINQTargets.targets"/>
  4. Change the AssemblyFile path above to point to your location of the msbuild dll (it is probably in the “build” directory of your files).
  5. Save the project file, close it, and right click on your project and select Reload. If any error messages are produced you should fix the syntax.
  6. Next, add the ntup and ntupom files to your project.
  7. For each ntup file, right click and select properties. Make sure the Build Action field is set to ROOTFileDataModel. For the .ntupom files it should be set to TTreeGroupSpec.

Now you should be able to right-click and build. And editing the ntup file should cause an automatic re-build. Note that the above setup will put the code in the ROOTLINQ namespace.

Known Issues

Sometimes I don’t get the IDE to display TTreeGroupSpec and ROOTFileDataModel in its drop-down. And I’m not 100% sure what makes it work and what doesn’t. If you add the files and can’t switch the build actions, then edit the project file and make sure it looks something like the following:

    <TTreeGroupSpec Include="CollectionTreeConfig-000.ntup"/>
    <TTreeGroupSpec Include="LumiMetaDataConfig-000.ntup" />
    <ROOTFileDataModel Include="user.omh.001123.AANT._00001.ntupom"\>

Further, these lines must occur after the Import statement you added above! Otherwise you’ll get some very funny errors about name spaces and “\” getting included in the files.

Last edited May 29, 2011 at 11:19 PM by gwatts, version 9


No comments yet.