The current version of LINQtoTTree is rough – this is alpha in the sense of the features. The quality bar is pretty good – as long as you don’t stray too far from the things it was designed to do. Smile


This set of libraries builds on the ROOT.NET project, allowing one to code up LINQ expressions that can be run against a ROOT TTree. For example:

            FileInfo rootFile = new FileInfo(@"..\..\..\output.root");
            var rf1 = Queryablebtag.Create(rootFile);

            int count = rf1.Count();
            Console.WriteLine("The number of events in the ntuple is {0}.", count);

            var alljets = from e in rf1
                          from j in e.jets
                          select j;

            var hpt = alljets.Plot(“pTAllJets”, “pT for all jets; pT [GeV]”, 50, 0.0, 150.0, j => j.Pt() / 1000.0);

            var goodjets = from j in alljets
                           where j.Pt()/1000.0 > 30.0 && TMath::Abs(j.Eta()) < 2.0
                           select j;

            var hptGood = alljets.Plot(“pTGoodJets”, “pT for Good jets; pT [GeV]”, 50, 0.0, 150.0, j => j.Pt() / 1000.0); 

This produces two plots called hpt and hptGood.

The goal is to bring the power of functional programming’s composability to plot making and simple analysis without having to give up the speed of analyzing ROOT in C++. This project takes advantage of C#’s LINQ functionality to do this.


Last edited Aug 20, 2011 at 10:05 PM by gwatts, version 9


No comments yet.