Exemple #1
0
        public void TupleCustomLeafNames()
        {
            FileInfo result = RunQueryForSingleColumnTTree(QueryTupleOurCustomObjectCustomLeafNames);

            Assert.IsTrue(result.Exists, "File exists");

            // Check the contents of the file.
            var f = NTFile.Open(result.FullName);

            try
            {
                var t = f.Get("DataTree") as ROOTNET.Interface.NTTree;
                Assert.IsNotNull(t, "Getting a tree from the file");

                var leaves = t.ListOfLeaves;
                Assert.AreEqual(3, leaves.Entries, "Number of leaves");
                Assert.AreEqual("c1", leaves[0].Name);
                Assert.AreEqual("c2", leaves[1].Name);
                Assert.AreEqual("col3", leaves[2].Name);
            }
            finally
            {
                f.Close();
            }
        }
        /// <summary>
        /// Fetch a Jenkins build artifact.
        /// Use the latestBuild link to always fetch the latest one.
        /// Use a specific build URL to fetch the current one.
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static NTFile jenkins(string url)
        {
            var fi = JenkAccess.GetBuildArtifiact(url).Result;

            var f = NTFile.Open(fi.FullName, "READ");

            if (!f.IsOpen())
            {
                throw new ArgumentException($"ROOT is unable to open file {fi.FullName} from the Jenkins build server ({url}).");
            }

            return(f);
        }
Exemple #3
0
        /// <summary>
        /// Open and get an ntuple
        /// </summary>
        /// <param name="rootFileName"></param>
        /// <param name="treeName"></param>
        /// <returns></returns>
        public static NTTree OpenAndGet(string rootFileName, string treeName)
        {
            Assert.IsTrue(File.Exists(rootFileName), string.Format("File {0} can't be found", rootFileName));
            var f = NTFile.Open(rootFileName, "READ");

            Assert.IsTrue(f.IsOpen(), "File open");
            var to = f.Get(treeName);

            Assert.IsNotNull(to, string.Format("{0} not in the file", treeName));
            var t = to as ROOTNET.NTTree;

            Assert.IsNotNull(t, string.Format("{0} is not a TTree object", treeName));
            return(t);
        }
        /// <summary>
        /// Simple test to use the MSBuild guys in a special targets file.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            var vs = Environment.GetEnvironmentVariables();

            foreach (var v in vs.Keys.Cast <string>().OrderBy(s => s))
            {
                Console.WriteLine(v);
            }

            var f = NTFile.Open("junk.root", "RECREATE");
            var h = new NTH1F("hi", "there", 10, 0.0, 1.0);

            h.Fill(0.5);
            f.Write();
            f.Close();
        }
Exemple #5
0
        public void TupleTitleAndItemsForAnonymousObject()
        {
            var f = NTFile.Open(RunQueryForSingleColumnTTree(QueryTupleOurCustomObject).FullName, "READ");

            try
            {
                var t     = f.Get("DataTree") as ROOTNET.Interface.NTTree;
                var blist = t.ListOfBranches.Select(b => b.Name).ToArray();
                Assert.AreEqual(3, blist.Length);
                Assert.IsTrue(blist.Contains("col1"));
                Assert.IsTrue(blist.Contains("col2"));
                Assert.IsTrue(blist.Contains("col3"));
            }
            finally
            {
                f.Close();
            }
        }
Exemple #6
0
        public void TupleSetTitleAndItems()
        {
            FileInfo result = RunQueryForSingleColumnTTree(QueryTupleOurCustomObjectTitleAndNameDefaultFile);

            Assert.IsTrue(result.Exists, "resulting file does not exist");
            var f = NTFile.Open(result.FullName);

            try
            {
                var t = f.Get("PhysicsTree") as ROOTNET.Interface.NTTree;
                Assert.IsNotNull(t, "Getting a tree from the file");

                Assert.AreEqual("PhysicsTree", t.Name);
                Assert.AreEqual("Data that we've written for a physics tree", t.Title);
            }
            finally
            {
                f.Close();
            }
        }
Exemple #7
0
        public void TupleStreamCompiled()
        {
            FileInfo result = RunQueryForSingleColumnTTree(QueryTupleOurCustomObject);

            Console.WriteLine(result.FullName);
            Assert.IsTrue(result.Exists, "File exists");
            Assert.AreNotEqual("hi.root", result.Name);
            Assert.AreEqual(".root", result.Extension);
            Assert.IsTrue(result.Name.StartsWith("hi"));

            // Check the contents of the file. It should have a Tree in it with 10 entries.
            var f = NTFile.Open(result.FullName);

            try {
                var t = f.Get("DataTree") as ROOTNET.Interface.NTTree;
                Assert.IsNotNull(t, "Getting a tree from the file");
                Assert.AreEqual(10, t.Entries);

                var leaves = t.ListOfLeaves;
                foreach (var leaf in leaves.Select(l => l.Name))
                {
                    WriteLine($"Leave name: {leaf}");
                }
                Assert.AreEqual(3, leaves.Entries, "Number of leaves");

                foreach (dynamic entry in t)
                {
                    WriteLine($"Entry value: col1: {entry.col1} col2: {entry.col2} col3: {entry.col3}");
                    Assert.AreEqual(10, entry.col1);
                    Assert.AreEqual(11, entry.col2);
                    Assert.AreEqual(12, entry.col3);
                }
            } finally
            {
                f.Close();
            }
        }