public void TestLinkedQuery() { int numberOfIter = 10; var rootFile = TestUtils.CreateFileOfInt(numberOfIter); var q = new QueriableDummy <TestNtupe>(); var dude1 = q.Count(); var query1 = DummyQueryExectuor.LastQueryModel; var dude2 = q.Where(v => v.run > 20).Count(); var query2 = DummyQueryExectuor.LastQueryModel; var exe = new TTreeQueryExecutor(new Uri[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupe)); var result1 = exe.ExecuteScalarAsFuture <int>(query1); var result2 = exe.ExecuteScalarAsFuture <int>(query2); Assert.IsFalse(result1.HasValue, "r1 should not have a value yet"); Assert.IsFalse(result2.HasValue, "r2 should not have a value yet"); var r1v = result1.Value; Assert.IsTrue(result1.HasValue, "r1 should have a value"); Assert.IsTrue(result2.HasValue, "r2 should have a value"); Assert.AreEqual(0, result2.Value, "incorrect r2"); Assert.AreEqual(numberOfIter, result1.Value, "incorrect r1"); }
public void LocalBashCmdLineSendObjectsToSelector() { var rootFile = TestUtils.CreateFileOfInt(20); // Get a simple query that includes packing over a histogram. // The funny way we do the bin content is to make sure the histogram is accessed // in a query data dependent way - otherwise the system optimizes the histogram access // to the host! var q = new QueriableDummy <TestNtupe>(); var h = new ROOTNET.NTH1F("hi", "there", 1, 0.0, 10.0); h.Directory = null; h.Fill(5, 3.0); GC.WaitForPendingFinalizers(); var dude = q.Select(i => h.GetBinContent(i.run != 1 ? 1 : i.run)).Where(i => i > 2.5).Count(); var query = DummyQueryExectuor.LastQueryModel; // Ok, now we can actually see if we can make it "go". var exe = new TTreeQueryExecutor(new[] { rootFile.AsLocalBashUri() }, "dude", typeof(ntuple), typeof(TestNtupe)); exe.CompileDebug = true; int result = exe.ExecuteScalar <int>(query); Assert.AreEqual(20, result); }
public void LocalBashCmdLineDictifyClasses() { var rootFile = TestUtils.CreateFileOfInt(20); // Load up an extra dictionary ntuple._gClassesToDeclare = new[] { "vector<vector<vector<float>>>" }; ntuple._gClassesToDeclareIncludes = new[] { "vector" }; // Get a simple query we can "play" with var q = new QueriableDummy <TestNtupe>(); var dude = q.Where(r => LocalBashCmdLineDictifyClassesHelpers.DoDictDump() > 0).Count(); var query = DummyQueryExectuor.LastQueryModel; // Ok, now we can actually see if we can make it "go". var exe = new TTreeQueryExecutor(new[] { rootFile.AsLocalBashUri() }, "dude", typeof(ntuple), typeof(TestNtupe)); exe.CleanupQuery = false; bool seenTDataType = false; CommandLineExecutor.AddLogEndpoint(s => { seenTDataType |= s.Contains("TDataType"); Console.WriteLine(s); }); int result = exe.ExecuteScalar <int>(query); Assert.IsTrue(seenTDataType); }
public void RemoteBashCmdLocalIncludeFile() { // Write out the local include file. The system should pick it up from here. using (var writer = File.CreateText("bogus_function.h")) { writer.WriteLine("int bogus() { return 15; }"); writer.WriteLine(); writer.Close(); } // Run on ints, though for this test it won't matter. var rootFile = TestUtils.CreateFileOfInt(10); // Run the special function. var q = new QueriableDummy <TestNtupe>(); var listing = from evt in q where TTreeQueryExecutorTest.CPPHelperFunctions.ReturnCustomFuncValue() > 10.0 select evt; var dude = listing.Count(); var query = DummyQueryExectuor.LastQueryModel; // Run the execution environment. var exe = new TTreeQueryExecutor(new[] { rootFile.AsRemoteBashUri() }, "dude", typeof(ntuple), typeof(TestNtupe)); exe.CleanupQuery = false; int result = exe.ExecuteScalar <int>(query); Assert.AreEqual(10, result); }
/// <summary> /// Run a simple test that looks for errors and warnings /// </summary> /// <param name="configureMe"></param> private static void RunSimpleTestForErrorsAndWarnings(Action <TTreeQueryExecutor> configureMe) { var rootFile = TestUtils.CreateFileOfInt(20); // Get a simple query we can "play" with var q = new QueriableDummy <TestNtupe>(); var dude = q.Count(); var query = DummyQueryExectuor.LastQueryModel; // Ok, now we can actually see if we can make it "go". var exe = new TTreeQueryExecutor(new[] { rootFile.AsRemoteBashUri() }, "dude", typeof(ntuple), typeof(TestNtupe)); configureMe(exe); // Look for warning or error var errorLines = new List <string>(); CommandLineExecutor.AddLogEndpoint(s => { if (s.ToLower().Contains("warning") || s.ToLower().Contains("error")) { errorLines.Add(s); } }); int result = exe.ExecuteScalar <int>(query); foreach (var l in errorLines) { Console.WriteLine("************ Contains error or warning: " + l); } Assert.AreEqual(0, errorLines.Count, "See std out for list of error liens"); }
public void RemoteBashExceptionGeneratedBySTDLIB() { const int numberOfIter = 25; var rootFile = TestUtils.CreateFileOfVectorInt(numberOfIter); // Attempt to access something that is way out beyond the edge. This should cause an exception // in our vector code. var q = new QueriableDummy <TestNtupeArr>(); var dudeQ = from evt in q where (evt.myvectorofint[50] == 0) select evt; var dude = dudeQ.Count(); var query = DummyQueryExectuor.LastQueryModel; DummyQueryExectuor.FinalResult.DumpCodeToConsole(); // Ok, now we can actually see if we can make it "go". try { var exe = new TTreeQueryExecutor(new Uri[] { rootFile.AsRemoteBashUri() }, "dude", typeof(ntuple), typeof(TestNtupeArr)); var result = exe.ExecuteScalar <int>(query); } catch (AggregateException exp) { var exception = exp.UnrollAggregateExceptions(); Console.WriteLine($"Caught error with message: {exception.Message}"); Assert.IsTrue(exception.Message.Contains("Error caught in"), "Error message from running of root"); // We should catch a data processing exception when this occurs. throw exception; } }
public void TestDeltaR2() { var rootFile = TestUtils.CreateFileOfInt(10); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// Get a simple query we can "play" with /// var q = new QueriableDummy <LINQToTTreeLib.TTreeQueryExecutorTest.TestNtupe>(); var listing = from evt in q let tlz = ROOTUtils.CreateTLZ(evt.run * 2.2, 1.0, 0.0) where tlz.DeltaR2(tlz) < 1.0 select evt; var dude = listing.Count(); var query = DummyQueryExectuor.LastQueryModel; /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new Uri[] { rootFile }, "dude", typeof(ntuple), typeof(LINQToTTreeLib.TTreeQueryExecutorTest.TestNtupe)); int result = exe.ExecuteScalar <int>(query); Assert.AreEqual(10, result); }
public void TestDeltaR2() { var rootFile = TestUtils.CreateFileOfInt(10); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// Get a simple query we can "play" with /// var q = new QueriableDummy<LINQToTTreeLib.TTreeQueryExecutorTest.TestNtupe>(); var listing = from evt in q let tlz = ROOTUtils.CreateTLZ(evt.run * 2.2, 1.0, 0.0) where tlz.DeltaR2(tlz) < 1.0 select evt; var dude = listing.Count(); var query = DummyQueryExectuor.LastQueryModel; /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new Uri[] { rootFile }, "dude", typeof(ntuple), typeof(LINQToTTreeLib.TTreeQueryExecutorTest.TestNtupe)); int result = exe.ExecuteScalar<int>(query); Assert.AreEqual(10, result); }
public void TTreeWithZeroEntries() { // Test a full round trip for a really simple CSV dump. var rootFile = TestUtils.CreateFileOfInt(10); // Simple query that will return nothing. var q = new QueriableDummy <singleIntNtuple>(); q .Select(e => new customObjectAllValidTypes() { vDouble = (double)e.run, vBool = e.run == 10, vInt = (int)e.run }) .Where(e => false) .AsTTree(outputROOTFile: new FileInfo("allguys.root")); var query = DummyQueryExectuor.LastQueryModel; // Run it. var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(singleIntNtuple)); exe.CleanupQuery = false; var result = exe.ExecuteScalar <FileInfo[]>(query); Assert.IsNotNull(result); Assert.AreEqual(1, result.Length); var fout = ROOTNET.NTFile.Open(result[0].FullName, "READ"); var t = fout.Get("DataTree") as NTTree; Assert.IsNotNull(t); Assert.AreEqual(0, t.GetEntries()); }
public void TestSimpleLoopAndFilterCombine() { const int numberOfIter = 25; var rootFile = TestUtils.CreateFileOfVectorInt(numberOfIter); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// Get a simple query we can "play" with. That this works /// depends on each event having 10 entries in the array, which contains /// the numbers 0-10. /// var q = new QueriableDummy<TestUtils.TestNtupeArr>(); var dudeQ1 = from evt in q where (evt.myvectorofint.Max() > 5) select evt; var dude1 = dudeQ1.Count(); var query1 = DummyQueryExectuor.LastQueryModel; var dudeQ2 = from evt in q where (evt.myvectorofint.Max() > 5) select evt; var dude2 = dudeQ2.Count(); var query2 = DummyQueryExectuor.LastQueryModel; // // Convert to future's // ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new Uri[] { rootFile }, "dude", typeof(ntuple), typeof(TestUtils.TestNtupeArr)); var q1future = exe.ExecuteScalarAsFuture<int>(query1); var q2future = exe.ExecuteScalarAsFuture<int>(query2); // // Run them! // exe.ExecuteQueuedQueries(); // // And check // Assert.AreEqual(q1future.Value, numberOfIter); Assert.AreEqual(q2future.Value, numberOfIter); }
/// <summary> /// Run a query on a single file. /// </summary> /// <param name="queryBuilder"></param> /// <returns></returns> private static FileInfo[] RunQueryForSingleColumnTTree(Action queryBuilder) { // Test a full round trip for a really simple CSV dump. var rootFile = TestUtils.CreateFileOfInt(10); /// Get a simple query we can "play" with var query = QueryModelFor(queryBuilder); /// OK, now we can actually see if we can make it "go". var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(singleIntNtuple)); var result = exe.ExecuteScalar <FileInfo[]>(query); return(result); }
/// <summary> /// Reset all the counters, etc., in the LINQ library /// </summary> public static void ResetLINQLibrary() { var a = ROOTNET.NTROOT.gROOT.GetApplication(); MEFUtilities.MyClassInit(); DummyQueryExectuor.GlobalInitalized = false; ArrayExpressionParser.ResetParser(); TypeUtils._variableNameCounter = 0; LINQToTTreeLib.TypeHandlers.ReplacementMethodCalls.TypeHandlerReplacementCall.ClearTypeList(); var eng = new VelocityEngine(); eng.Init(); TTreeQueryExecutor.Reset(); ResetCacheDir(); }
public void LocalWinCmdLineCountOperator() { var rootFile = TestUtils.CreateFileOfInt(20); // Get a simple query we can "play" with var q = new QueriableDummy <TestNtupe>(); var dude = q.Count(); var query = DummyQueryExectuor.LastQueryModel; // Ok, now we can actually see if we can make it "go". var exe = new TTreeQueryExecutor(new[] { rootFile.AsLocalWinUri() }, "dude", typeof(ntuple), typeof(TestNtupe)); int result = exe.ExecuteScalar <int>(query); Assert.AreEqual(20, result); }
public void RemoteBashCmdSplitExecution() { var rootFile = TestUtils.CreateFileOfInt(20).AsRemoteBashUri(2); // Get a simple query we can "play" with var q = new QueriableDummy <TestNtupe>(); var dude = q.Count(); var query = DummyQueryExectuor.LastQueryModel; // Ok, now we can actually see if we can make it "go". var exe = new TTreeQueryExecutor(new[] { rootFile, rootFile }, "dude", typeof(ntuple), typeof(TestNtupe)); int result = exe.ExecuteScalar <int>(query); Assert.AreEqual(40, result); Assert.AreEqual(2, exe.CountExecutionRuns); }
public void TestSimpleLoopAndFilterCombine() { const int numberOfIter = 25; var rootFile = TestUtils.CreateFileOfVectorInt(numberOfIter); /// /// Get a simple query we can "play" with. That this works /// depends on each event having 10 entries in the array, which contains /// the numbers 0-10. /// var q = new QueriableDummy <TestUtils.TestNtupeArr>(); var dudeQ1 = from evt in q where (evt.myvectorofint.Max() > 5) select evt; var dude1 = dudeQ1.Count(); var query1 = DummyQueryExectuor.LastQueryModel; var dudeQ2 = from evt in q where (evt.myvectorofint.Max() > 5) select evt; var dude2 = dudeQ2.Count(); var query2 = DummyQueryExectuor.LastQueryModel; // // Convert to future's // var exe = new TTreeQueryExecutor(new Uri[] { rootFile }, "dude", typeof(ntuple), typeof(TestUtils.TestNtupeArr)); var q1future = exe.ExecuteScalarAsFuture <int>(query1); var q2future = exe.ExecuteScalarAsFuture <int>(query2); // // Run them! // exe.ExecuteQueuedQueries().Wait(); // // And check // Assert.AreEqual(q1future.Value, numberOfIter); Assert.AreEqual(q2future.Value, numberOfIter); }
public void SumInFutureQuery() { int numberOfIter = 10; var rootFile = TestUtils.CreateFileOfInt(numberOfIter); var q = new QueriableDummy <TestNtupe>(); var dude = q.Select(evt => evt.run).Sum(); var query = DummyQueryExectuor.LastQueryModel; var exe = new TTreeQueryExecutor(new Uri[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupe)); var result = exe.ExecuteScalarAsFuture <int>(query); Assert.IsNotNull(result, "future should exist!"); Assert.IsFalse(result.HasValue, "future shoudl not have executed by now!"); var val = result.Value; Assert.AreEqual(numberOfIter * 10, val, "incorrect result came back."); Assert.IsTrue(result.HasValue, "value should be marked by now!"); }
public void LocalBashCmdLineLoadExtraClassFiles() { var rootFile = TestUtils.CreateFileOfInt(20); // Setup an extra file to be loaded. string fnamebase = "TestLoadingCommonFilesObj"; var f = TTreeQueryExecutorTest.CreateCommonObject(fnamebase, new DirectoryInfo(".")); ntuple._gObjectFiles = new[] { f.FullName }; // Get a simple query we can "play" with var q = new QueriableDummy <TestNtupe>(); var dude = q.Where(r => LocalBashCmdLineLoadExtraClassFilesHelpers.DoObjectLookup() > 0).Count(); var query = DummyQueryExectuor.LastQueryModel; // Ok, now we can actually see if we can make it "go". var exe = new TTreeQueryExecutor(new[] { rootFile.AsLocalBashUri() }, "dude", typeof(ntuple), typeof(TestNtupe)); int result = exe.ExecuteScalar <int>(query); Assert.AreEqual(20, result); }
public void LocalBashMultiThreaded() { // Create one file of int, but use it 20 times. var rootFile = TestUtils.CreateFileOfInt(20); var files = Enumerable.Range(0, 20).Select(c => rootFile.AsLocalBashUri()).ToArray(); const int expectedSize = 20 * 20; // Get a simple query we can "play" with var q = new QueriableDummy <TestNtupe>(); var dude = q.Count(); var query = DummyQueryExectuor.LastQueryModel; // Ok, now we can actually see if we can make it "go". var exe = new TTreeQueryExecutor(files, "dude", typeof(ntuple), typeof(TestNtupe)); int result = exe.ExecuteScalar <int>(query); Assert.AreEqual(expectedSize, result); // We should have split this many files into the number of CPU's we have. Assert.AreEqual(Environment.ProcessorCount, exe.CountExecutionRuns); }
public void RemoteBashROOTFileResult() { var rootFile = TestUtils.CreateFileOfInt(20); // Get a simple query we can "play" with var q = new QueriableDummy <TestNtupe>(); var dude = q.AsTTree("mytree"); var query = DummyQueryExectuor.LastQueryModel; // Ok, now we can actually see if we can make it "go". var exe = new TTreeQueryExecutor(new[] { rootFile.AsRemoteBashUri() }, "dude", typeof(ntuple), typeof(TestNtupe)); exe.CompileDebug = true; exe.CleanupQuery = false; var result = exe.ExecuteScalar <FileInfo[]>(query); Assert.IsNotNull(result); Assert.AreEqual(1, result.Length); result[0].Refresh(); Assert.IsTrue(result[0].Exists); }
public void RemoteBashCmdLineCheckDebugDumps() { // When we run in debug mode, make sure the command line dumps are there. var rootFile = TestUtils.CreateFileOfInt(20); // Get a simple query we can "play" with var q = new QueriableDummy <TestNtupe>(); var dude = q.Count(); var query = DummyQueryExectuor.LastQueryModel; // Ok, now we can actually see if we can make it "go". var exe = new TTreeQueryExecutor(new[] { rootFile.AsRemoteBashUri() }, "dude", typeof(ntuple), typeof(TestNtupe)); // Capture the lines bool seenCacheInfo = false; CommandLineExecutor.AddLogEndpoint(s => seenCacheInfo |= s.ToLower().Contains("cache")); exe.CompileDebug = true; int result = exe.ExecuteScalar <int>(query); Assert.IsTrue(seenCacheInfo); }
public void RemoteBashNoROOTFound() { try { // This should cause a hard fail. RemoteBashExecutor.ROOTVersionNumber = "22322"; // Set it up to look for something else. var rootFile = TestUtils.CreateFileOfInt(20); // Get a simple query we can "play" with var q = new QueriableDummy <TestNtupe>(); var dude = q.Count(); var query = DummyQueryExectuor.LastQueryModel; // Ok, now we can actually see if we can make it "go". var exe = new TTreeQueryExecutor(new[] { rootFile.AsRemoteBashUri() }, "dude", typeof(ntuple), typeof(TestNtupe)); int result = exe.ExecuteScalar <int>(query); } catch (AggregateException exp) { throw exp.UnrollAggregateExceptions(); } }
public void TestInlineIfObjectCode() { const int numberOfIter = 25; var rootFile = TestUtils.CreateFileOfVectorInt(numberOfIter); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// Get a simple query we can "play" with. That this works /// depends on each event having 10 entries in the array, which contains /// the numbers 0-10. /// var q = new QueriableDummy<TestNtupeArr>(); var dudeQ = from evt in q let k = evt.myvectorofint[0] let j = k == 0 ? new ROOTNET.NTVector3(k, k, k) : null where (j == null) select evt; var dude = dudeQ.Count(); var query = DummyQueryExectuor.LastQueryModel; DummyQueryExectuor.FinalResult.DumpCodeToConsole(); /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new Uri[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupeArr)); var result = exe.ExecuteScalar<int>(query); Assert.AreEqual(0, result); }
public void TestSameHistoOverTice() { var rootFile = TestUtils.CreateFileOfInt(10); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// Get a simple query we can "play" with /// var q = new QueriableDummy<TestNtupe>(); var mainHist = new ROOTNET.NTH1F("hi", "there", 1000, 0.0, 1000.0); mainHist.Directory = null; var dude = from evt in q where mainHist.GetBinContent(evt.run) * mainHist.GetBinContent(evt.run) > 0.0 select evt; var final = dude.Count(); var query = DummyQueryExectuor.LastQueryModel; /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupe)); var result = exe.ExecuteScalar<int>(query); Assert.AreEqual(0, result, "Didn't add correctly"); Assert.AreEqual("hi", mainHist.Name, "histogram name changed"); }
public void TestSameHistInCombinedQueries() { var rootFile = TestUtils.CreateFileOfInt(10); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// Get two querries we can play with /// var q = new QueriableDummy<TestNtupe>(); var mainHist = new ROOTNET.NTH1F("hi", "there", 1000, 0.0, 1000.0); mainHist.Directory = null; var dude1 = from evt in q where mainHist.GetBinContent(evt.run) > 0.0 select evt; var final1 = dude1.Count(); var query1 = DummyQueryExectuor.LastQueryModel; var dude2 = from evt in q where mainHist.GetBinContent(evt.run) > 0.0 select evt; var final2 = dude2.Count(); var query2 = DummyQueryExectuor.LastQueryModel; /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupe)); var r1f = exe.ExecuteScalarAsFuture<int>(query1); var r2f = exe.ExecuteScalarAsFuture<int>(query2); var r1 = r1f.Value; var r2 = r2f.Value; Assert.AreEqual(0, r1, "r1 Didn't add correctly"); Assert.AreEqual(0, r2, "r2 Didn't add correctly"); Assert.AreEqual("hi", mainHist.Name, "histogram name changed"); }
public void TestSimpleResultDebugCompile() { var rootFile = TestUtils.CreateFileOfInt(10); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// Get a simple query we can "play" with /// var q = new QueriableDummy<TestNtupe>(); var dude = q.Count(); var query = DummyQueryExectuor.LastQueryModel; /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupe)); exe.CompileDebug = true; int result = exe.ExecuteScalar<int>(query); Assert.AreEqual(10, result); }
public void TestAggregateCodeForSimpleDoubleVariableType() { const int numberOfIter = 25; var rootFile = TestUtils.CreateFileOfVectorDouble(numberOfIter); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// Get a simple query we can "play" with. That this works /// depends on each event having 10 entries in the array, which contains /// the numbers 0-10. /// var q = new QueriableDummy<TestNtupeArrD>(); var evtvalue = 9.5 + 8.5 + 7.5 + 6.5 + 5.5 + 4.5 + 3.5 + 2.5 + 1.5 + 0.5; var dudeQ = from evt in q let r = evt.myvectorofdouble.Aggregate(0.0, (s, v) => s + v) where r == 9.5 + 8.5 + 7.5 + 6.5 + 5.5 + 4.5 + 3.5 + 2.5 + 1.5 + 0.5 select r; var dude = dudeQ.Aggregate(0.0, (acc, val) => acc + val); var query = DummyQueryExectuor.LastQueryModel; DummyQueryExectuor.FinalResult.DumpCodeToConsole(); /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupeArrD)); var result = exe.ExecuteScalar<double>(query); Assert.AreEqual(result, numberOfIter * evtvalue); }
public void TestGroupByWithInto() { const int numberOfIter = 25; const int vectorSize = 10; var rootFile = TestUtils.CreateFileOfVectorInt(numberOfIter, vectorSize); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// Get a simple query we can "play" with. That this works /// depends on each event having 10 entries in the array, which contains /// the numbers 0-10. /// var q = new QueriableDummy<TestNtupeArr>(); var dudeQ = from evt in q from v in evt.myvectorofint group v by v into lists from i in lists where i == 5 select i; var r = dudeQ.Count(); var query = DummyQueryExectuor.LastQueryModel; DummyQueryExectuor.FinalResult.DumpCodeToConsole(); // // Ok, now we can actually see if we can make it "go". // ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new Uri[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupeArr)); var result = exe.ExecuteScalar<int>(query); Assert.AreEqual(numberOfIter, result); }
public void TestInitalizerWithROOTVariable() { const int numberOfIter = 25; var rootFile = TestUtils.CreateFileOfInt(numberOfIter); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// Get a simple query we can "play" with /// var q = new QueriableDummy<TestNtupe>(); var holder = new ROOTNET.NTH1F("hi", "title", 2, 0.0, 2.0); holder.Directory = null; var dude = q.ApplyToObject(holder, (h, n) => h.Fill(n.run)); var query = DummyQueryExectuor.LastQueryModel; DummyQueryExectuor.FinalResult.DumpCodeToConsole(); /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupe)); var result = exe.ExecuteScalar<ROOTNET.Interface.NTH1F>(query); Assert.AreEqual(result.Entries, numberOfIter); Assert.AreEqual("hi", result.Name, "histogram name"); }
public void TestCArrayConstEnumerable() { // Test arr[5]. const int numberOfIter = 25; var rootFile = TestUtils.CreateFileOf("TestCArrayConstEnumerable.root", () => TTreeParserCPPTests.CreateTrees.CreateTreeWithIndexedConstSimpleVector(numberOfIter)); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// Get a simple query we can "play" with. That this works /// depends on each event having 10 entries in the array, which contains /// the numbers 0-10. /// var q = new QueriableDummy<TestNtupeCConstArr>(); var dudeQ = from evt in q let tmp = (from index in Enumerable.Range(0, 2) select evt.arr[index]).Count() where tmp == 2 select evt; var dude = dudeQ.Count(); var query = DummyQueryExectuor.LastQueryModel; DummyQueryExectuor.FinalResult.DumpCodeToConsole(); /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new Uri[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupeCConstArr)); var result = exe.ExecuteScalar<int>(query); Assert.AreEqual(25, result, "Incorrect number of iterations found"); }
public void TestFirstCodeCombine() { // Run a First(), but do it twice. The reason is to make sure that // the code doesn't step on itself with a break statement. const int numberOfIter = 25; var rootFile = TestUtils.CreateFileOfVectorInt(numberOfIter); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// Get a simple query we can "play" with. That this works /// depends on each event having 10 entries in the array, which contains /// the numbers 0-10. /// var q = new QueriableDummy<TestNtupeArr>(); var dudeQ1 = from evt in q where (evt.myvectorofint.First() > 0) select evt; var dude1 = dudeQ1.Count(); var query1 = DummyQueryExectuor.LastQueryModel; DummyQueryExectuor.FinalResult.DumpCodeToConsole(); var dudeQ2 = from evt in q where (evt.myvectorofint.Skip(1).First() > 0) select evt; var dude2 = dudeQ2.Count(); var query2 = DummyQueryExectuor.LastQueryModel; DummyQueryExectuor.FinalResult.DumpCodeToConsole(); /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new Uri[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupeArr)); var result2 = exe.ExecuteScalarAsFuture<int>(query2); var result1 = exe.ExecuteScalarAsFuture<int>(query1); Assert.AreEqual(0, result1.Value, "result 1"); Assert.AreEqual(numberOfIter, result2.Value, "result 2"); }
public void TestCachingOfSimpleHistoWithNameTitleChange() { /// Do two identical queries. Make sure only one causes an actual run! var rootFile = TestUtils.CreateFileOfInt(5); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupe)); Assert.AreEqual(0, exe.CountExecutionRuns, "exe runs initialization"); Assert.AreEqual(0, exe.CountCacheHits, "cache hits initialization"); /// /// Get a simple query we can "play" with /// var q = new QueriableDummy<TestNtupe>(); var dude = q.Plot("hi", "there", 10, 0.0, 20.0, d => d.run); var query = DummyQueryExectuor.LastQueryModel; DummyQueryExectuor.FinalResult.DumpCodeToConsole(); var result = exe.ExecuteScalar<ROOTNET.Interface.NTH1>(query); Assert.AreEqual(1, exe.CountExecutionRuns, "after exe run"); Assert.AreEqual(0, exe.CountCacheHits, "after exe run"); /// /// Re-run a slightly different query. Should still be cached. /// var dude2 = q.Plot("there", "high", 10, 0.0, 20.0, d => d.run); var query2 = DummyQueryExectuor.LastQueryModel; var result2 = exe.ExecuteScalar<ROOTNET.Interface.NTH1>(query2); Assert.AreEqual(1, exe.CountExecutionRuns, "after exe and cache run"); Assert.AreEqual(1, exe.CountCacheHits, "after exe and cache run"); }
public void TestPairwiseAllWithExternalRef() { // Definatly some problems with the code generated here: // TODO: //aBoolean_18Array[index1] = false; //aBoolean_18Array[index2] = false; // So this must be addressed. // // Look for a bug that happens when we have an external guy that references // something in the inside loop. // const int numberOfIter = 25; const int vecSize = 10; var rootFile = TestUtils.CreateFileOfVectorInt(numberOfIter, vecSize); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// We are looking at an array that has 10 entries in it. So if we create a /// unique combo, then we will have 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1 items, /// or 45 items. /// var q = new QueriableDummy<TestNtupeArr>(); var dudeQ = from evt in q where (from cmb in evt.myvectorofint.PairWiseAll((i1, i2) => CPPHelperFunctions.Calc(i1) != CPPHelperFunctions.Calc(i2)) select cmb).Count() == vecSize select evt; var dude = dudeQ.Count(); var query = DummyQueryExectuor.LastQueryModel; Console.WriteLine("Unoptimized"); DummyQueryExectuor.FinalResult.DumpCodeToConsole(); /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupeArr)); var result = exe.ExecuteScalar<int>(query); Assert.AreEqual(numberOfIter, result); }
public void TestCPPCodeAndStringPassing() { var rootFile = TestUtils.CreateFileOfInt(10); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// Get a simple query we can "play" with /// var q = new QueriableDummy<TestNtupe>(); var listing = from evt in q where CPPHelperFunctions.CalcLen("hi there dude my butt") > 10.0 select evt; var dude = listing.Count(); var query = DummyQueryExectuor.LastQueryModel; /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupe)); int result = exe.ExecuteScalar<int>(query); Assert.AreEqual(10, result); }
public void LocalIncludeFile() { // Write out the local include file. The system should pick it up from here. using (var writer = File.CreateText("bogus_function.h")) { writer.WriteLine("int bogus() { return 15; }"); writer.WriteLine(); writer.Close(); } // Run on ints, though for this test it won't matter. var rootFile = TestUtils.CreateFileOfInt(10); var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); // Run the special function. var q = new QueriableDummy<TestNtupe>(); var listing = from evt in q where CPPHelperFunctions.ReturnCustomFuncValue() > 10.0 select evt; var dude = listing.Count(); var query = DummyQueryExectuor.LastQueryModel; // Run the execution environment. ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupe)); exe.CleanupQuery = false; int result = exe.ExecuteScalar<int>(query); Assert.AreEqual(10, result); }
public void TestCreateTupleWithCreate() { var rootFile = TestUtils.CreateFileOfInt(10); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// Get a simple query we can "play" with /// var q = new QueriableDummy<TestNtupe>(); var dude = from evt in q select Tuple.Create(evt.run, evt.run); var r = dude.Where(i => i.Item1 > 0).Count(); var query = DummyQueryExectuor.LastQueryModel; /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new Uri[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupe)); int result = exe.ExecuteScalar<int>(query); Assert.AreEqual(10, result); }
public void TestUniqueCombinations() { const int numberOfIter = 25; var rootFile = TestUtils.CreateFileOfVectorInt(numberOfIter); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// We are looking at an array that has 10 entries in it. So if we create a /// unique combo, then we will have 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1 items, /// or 45 items. /// var q = new QueriableDummy<TestNtupeArr>(); var dudeQ = from evt in q where (evt.myvectorofint.UniqueCombinations().Count() == 45) select evt; var dude = dudeQ.Count(); var query = DummyQueryExectuor.LastQueryModel; /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupeArr)); var result = exe.ExecuteScalar<int>(query); Assert.AreEqual(result, numberOfIter); }
public void TestNestedCount() { const int numberOfIter = 25; var rootFile = TestUtils.CreateFileOfVectorInt(numberOfIter); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// Get a simple query we can "play" with. That this works /// depends on each event having 10 entries in the array, which contains /// the numbers 0-10. /// var q = new QueriableDummy<TestNtupeArr>(); var dudeQ = from evt in q where (evt.myvectorofint.Count() > 5) select evt; var dude = dudeQ.Count(); var query = DummyQueryExectuor.LastQueryModel; /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupeArr)); var result = exe.ExecuteScalar<int>(query); Assert.AreEqual(result, numberOfIter); }
public void TestSimpleReultOperatorNtupleOkButBogusProxyPath() { int numberOfIter = 10; var rootFile = TestUtils.CreateFileOfInt(numberOfIter); /// /// Get a simple query we can "play" with /// var q = new QueriableDummy<TestNtupe>(); var dude = q.Count(); var query = DummyQueryExectuor.LastQueryModel; /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = "junk.cppxdude"; var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple)); int result = exe.ExecuteScalar<int>(query); Assert.AreEqual(numberOfIter, result); }
private static FileInfo RunQueryForSingleColumnTTree(Action queryBuilder) { // Test a full round trip for a really simple CSV dump. var rootFile = TestUtils.CreateFileOfInt(10); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// Get a simple query we can "play" with /// var query = QueryModelFor(queryBuilder); /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(singleIntNtuple)); var result = exe.ExecuteScalar<FileInfo[]>(query); Assert.AreEqual(1, result.Length); return result[0]; }
public void TestSortDescending() { const int numberOfIter = 25; var rootFile = TestUtils.CreateFileOfVectorInt(numberOfIter); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// Get a simple query we can "play" with. That this works /// depends on each event having 10 entries in the array, which contains /// the numbers 0-10. /// var q = new QueriableDummy<TestNtupeArr>(); var dudeQ = from evt in q select (from v in evt.myvectorofint orderby v descending select v).Take(2).Sum(); // The last two elements are 9 and 8, so 9 + 8 = 17. var dude = dudeQ.Where(x => x == 17).Count(); var query = DummyQueryExectuor.LastQueryModel; // // Ok, now we can actually see if we can make it "go". // ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new Uri[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupeArr)); var result = exe.ExecuteScalar<int>(query); Assert.AreEqual(result, numberOfIter); }
/// <summary> /// Create an unfilled future, connected with a tree executor that /// can do the job of filling it in. /// </summary> public FutureValue(TTreeQueryExecutor tTreeQueryExecutor) { Value = default; HasValue = false; TreeExecutor = tTreeQueryExecutor ?? throw new ArgumentException("tree executor must not be null!"); }
public void TestPairWiseAll() { // // The way the unique combo works is it builds in a double loop. So if something inside that loop // throws a break it has to be transmitted out two levels. This is meant to test for that. // const int numberOfIter = 25; const int vecSize = 10; var rootFile = TestUtils.CreateFileOfVectorInt(numberOfIter, vecSize); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// We are looking at an array that has 10 entries in it. So if we create a /// unique combo, then we will have 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1 items, /// or 45 items. /// var q = new QueriableDummy<TestNtupeArr>(); var dudeQ = from evt in q where (from cmb in evt.myvectorofint.PairWiseAll((i1, i2) => i1 != i2) select cmb).Count() == vecSize select evt; var dude = dudeQ.Count(); var query = DummyQueryExectuor.LastQueryModel; DummyQueryExectuor.FinalResult.DumpCodeToConsole(); /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupeArr)); var result = exe.ExecuteScalar<int>(query); Assert.AreEqual(numberOfIter, result); }
public void TestForZeroInputFiles() { var rootFile = TestUtils.CreateFileOfInt(5); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// Get a simple query we can "play" with /// var q = new QueriableDummy<TestNtupe>(); var dude = q.Count(); var query = DummyQueryExectuor.LastQueryModel; /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new Uri[] { }, "dude", typeof(ntuple)); int result = exe.ExecuteScalar<int>(query); }
public TTreeQueryExecutor Constructor(Uri rootFile, string proxyLocation, string[] extraLocations, string treeName) { #if false FileInfo rootFile; switch (rootFileIndex) { case 0: rootFile = null; break; case 1: rootFile = new FileInfo("stupid.root"); break; case 2: rootFile = new FileInfo(@"..\..\..\..\DemosAndTests\output.root"); break; default: rootFile = null; break; } #endif ntuple._gProxyFile = proxyLocation; #if false FileInfo proxyFile = new FileInfo("Constructor_Test\\bogus.cpp"); if (proxyFile.Directory.Exists) proxyFile.Directory.Delete(true); proxyFile.Directory.Create(); switch (ntupleProxyIndex) { case 0: ntuple._gProxyFile = ""; break; case 1: ntuple._gProxyFile = proxyFile.FullName; break; case 2: using (var w = proxyFile.CreateText()) { w.Close(); } ntuple._gProxyFile = proxyFile.FullName; break; default: ntuple._gProxyFile = ""; break; } #endif #if false FileInfo extraFile = new FileInfo("Constructor_Test\\extra.cpp"); switch (ntupleExtraIndex) { case 0: ntuple._gObjectFiles = new string[0]; break; case 1: ntuple._gObjectFiles = new string[] { extraFile.FullName }; break; case 2: using (var w = extraFile.CreateText()) { w.Close(); } ntuple._gObjectFiles = new string[] { extraFile.FullName }; break; default: ntuple._gObjectFiles = new string[0]; break; } #endif ntuple._gObjectFiles = extraLocations; TTreeQueryExecutor target = new TTreeQueryExecutor(new Uri[] { rootFile }, treeName, typeof(ntuple)); Assert.IsNotNull(rootFile, "rootfile can't be null here"); Assert.IsTrue(File.Exists(rootFile.LocalPath), "root file must exist"); Assert.IsFalse(string.IsNullOrWhiteSpace(ntuple._gProxyFile), "proxy must be there"); Assert.IsTrue(File.Exists(ntuple._gProxyFile), "proxy file must exist"); if (ntuple._gObjectFiles != null) { Assert.IsTrue(ntuple._gObjectFiles.All(f => File.Exists(f)), "extra files must all exist"); } return target; }
public void TestIndexArray() { // Make sure we can process an index array (an array that is specified as arr[n]). // Create the ntuple file and the proxy that we will be using. const int numberOfIter = 25; var rootFile = TestUtils.CreateFileOfIndexedInt(numberOfIter); var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); // Do a simple query to make sure the # of items in each array is "10", and that // there are 25 such events. var q = new QueriableDummy<TestSingleIndexArray>(); var dudeQ = from evt in q where (evt.arr.Count() == 10) select evt; var dude = dudeQ.Count(); var query = DummyQueryExectuor.LastQueryModel; DummyQueryExectuor.FinalResult.DumpCodeToConsole(); /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new Uri[] { rootFile }, "dude", typeof(ntuple), typeof(TestSingleIndexArray)); var result = exe.ExecuteScalar<int>(query); Assert.AreEqual(result, numberOfIter); }
public void TestTempDirectoryLocationAndEmptying() { var rootFile = TestUtils.CreateFileOfInt(1); /// /// Get a simple query we can "play" with /// var q = new QueriableDummy<TestNtupe>(); var dude = q.Count(); var query = DummyQueryExectuor.LastQueryModel; /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); ntuple._gProxyFile = proxyFile.FullName; /// /// Ok, now we can actually see if we can make it "go". /// var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupe)); int result = exe.ExecuteScalar<int>(query); var dir = new DirectoryInfo(Path.GetTempPath() + "\\LINQToROOT"); ; dir.Refresh(); Assert.IsTrue(dir.Exists, "Temp directory doesn't exist"); Assert.AreEqual(0, dir.EnumerateFiles().Count(), "Expected no spare files in there!"); Assert.AreEqual(2, dir.EnumerateDirectories().Count(), "Incorrect # of subdirectories"); Assert.AreEqual("CommonFiles", dir.GetDirectories()[0].Name, "incorrect name of single existing directory"); }
public void TestDualQueryOnSameQueriable() { var rootFile = TestUtils.CreateFileOfInt(5); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// Get a simple query we can "play" with /// var q = new QueriableDummy<TestNtupe>(); var dude = q.Count(); var query = DummyQueryExectuor.LastQueryModel; /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupe)); int result = exe.ExecuteScalar<int>(query); /// /// Run the second one now /// var dude1 = q.Where(e => e.run > 10).Count(); query = DummyQueryExectuor.LastQueryModel; result = exe.ExecuteScalar<int>(query); }
public void TestLoadingCommonFiles() { /// Create a common C++ object that can be loaded and checked for. var d = PrepNonSpaceDir("TestLoadingCommonFiles"); string fnamebase = "TestLoadingCommonFilesObj"; var f = CreateCommonObject(fnamebase, d); /// /// Run a simple query - but fool it against another ntuple /// var rootFile = TestUtils.CreateFileOfInt(1); var q = new QueriableDummy<TestNtupe>(); var dude = q.Count(); var query = DummyQueryExectuor.LastQueryModel; /// /// First, make sure to clear out the common area. We are relying on the fact that we know /// where the common area is for this step. /// var commonArea = new DirectoryInfo(Path.GetTempPath() + @"\LINQToROOT\CommonFiles"); if (commonArea.Exists) { var filesToKill = (from fd in commonArea.EnumerateFiles() where fd.Name.Contains(fnamebase) select fd).ToArray(); foreach (var theFile in filesToKill) { theFile.Delete(); } } /// /// Setup all the files we will have to have! /// /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); ntuple._gProxyFile = proxyFile.FullName; ntuple._gObjectFiles = new string[] { f.FullName }; /// /// Now run /// var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupe)); int result = exe.ExecuteScalar<int>(query); Assert.AreEqual(1, result, "The result should have run correctly."); /// /// Next, see if we can find the files in the common area. /// commonArea.Refresh(); Assert.IsTrue(commonArea.Exists, string.Format("The common build area doesn't exist currently ({0}).", commonArea.FullName)); var filesFromOurObj = (from fd in commonArea.EnumerateFiles() where fd.Name.Contains(fnamebase) select fd).ToArray(); Assert.IsTrue(filesFromOurObj.Length > 0, "no files from our common object"); }
public void TestNewOfObject() { /// Make sure the "new" gets translated to C++ correctly and there are no errors! var rootFile = TestUtils.CreateFileOfInt(5); var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// Ok, now we can actually see if we can make it "go". /// ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupe)); /// /// Get a simple query we can "play" with /// var q = new QueriableDummy<TestNtupe>(); var letResult = from evt in q let temp = new ROOTNET.NTLorentzVector(evt.run, evt.run, evt.run, evt.run) where temp.Pt() > 0.0 select temp; var cnt = letResult.Count(); var query = DummyQueryExectuor.LastQueryModel; var result = exe.ExecuteScalar<int>(query); Assert.AreEqual(1, exe.CountExecutionRuns, "exe after exe run"); Assert.AreEqual(5, result, "count incorrect"); }
public void TestSortAscendingTranslated() { const int numberOfIter = 25; var rootFile = TestUtils.CreateFileOfVectorInt(numberOfIter); /// /// Generate a proxy .h file that we can use /// var proxyFile = TestUtils.GenerateROOTProxy(rootFile, "dude"); /// /// Get a simple query we can "play" with. That this works /// depends on each event having 10 entries in the array, which contains /// the numbers 0-10. /// var q = new QueriableDummy<TestNtupeArrEvents>(); var dudeQ = from evt in q select (from v in evt.jets orderby v.myvectorofint ascending select v).Take(2).Sum(j => j.myvectorofint); // The first two elements are 0 and 1, so 0 + 1 == 1. var dude = dudeQ.Sum(); var query = DummyQueryExectuor.LastQueryModel; DummyQueryExectuor.FinalResult.DumpCodeToConsole(); // // Ok, now we can actually see if we can make it "go". // ntuple._gProxyFile = proxyFile.FullName; var exe = new TTreeQueryExecutor(new Uri[] { rootFile }, "dude", typeof(ntuple), typeof(TestNtupeArrEvents)); var result = exe.ExecuteScalar<int>(query); Assert.AreEqual(result, numberOfIter); }