/// <summary> /// Create a TH1F plot from a stream of objects (with a lambda function to give flexability in conversion). /// </summary> /// <typeparam name="TSource">The type of the sequence that the plot will be run over</typeparam> /// <param name="source">The sequence over which a plot should be made. There will be one entry per item in the sequence.</param> /// <param name="plotName">The histogram will be created with this name</param> /// <param name="plotTitle">The histogram will be created with this title</param> /// <param name="nbins">Number of bins this histogram should have</param> /// <param name="lowBin">The xmin value for this histogram</param> /// <param name="highBin">The xmax value for this histogram</param> /// <param name="xValue">A lambda that returns the xvalue for each sequence item.</param> /// <param name="weight">A lambda that returns the weight for each sequence item. By default every entry has a weight of 1.</param> /// <returns></returns> public static ROOTNET.NTH1F Plot <TSource> ( this IQueryable <TSource> source, string plotName, string plotTitle, int nbins, double lowBin, double highBin, Expression <Func <TSource, double> > xValue, Expression <Func <TSource, double> > weight = null) { using (ROOTLock.Lock()) { if (weight == null) { Expression <Func <TSource, double> > constWeight = s => 1.0; weight = constWeight; } var hParameter = Expression.Parameter(typeof(ROOTNET.NTH1F), "h"); var vParameter = Expression.Parameter(typeof(TSource), "v"); // h.Fill(getter(v), weight(v)) is what we want to code up var callGetter = Expression.Invoke(xValue, vParameter); var callWeight = Expression.Invoke(weight, vParameter); var fillMethod = typeof(ROOTNET.NTH1F).GetMethod("Fill", new[] { typeof(double), typeof(double) }); var callFill = Expression.Call(hParameter, fillMethod, callGetter, callWeight); var lambda = Expression.Lambda <Action <ROOTNET.NTH1F, TSource> >(callFill, hParameter, vParameter); var h = new ROOTNET.NTH1F(plotName, plotTitle.ReplaceLatexStrings(), nbins, lowBin, highBin); ConfigureHisto(h); return(source.ApplyToObject(h, lambda)); } }
public async Task TestForSameResultHistosDiffNameTitle() { var f = MakeRootFile("TestForSameResultHistosDiffNameTitle"); var query = MakeQuery(2); var inputs = new object[0]; /// Cache a result var h = new ROOTNET.NTH1F("hi", "there", 10, 0.0, 10.0) { Directory = null }; h.SetBinContent(1, 5.0); var q = new QueryResultCache(); await q.CacheItem(q.GetKey(new Uri[] { f }, "test", inputs, null, query, dateChecker: u => File.GetLastWriteTime(u.LocalPath)), new NTObject[] { h }.AsRunInfoArray()); /// And make sure the lookup works now - make a different query, which is the same /// but with a slightly different query guy. var query1 = MakeQuery(4); var r = await Lookup <int>(q, f, "test", new object[0], null, query1, new DummySaver()); Assert.IsTrue(r.Item1, "Expected a cache hit"); }
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 async Task TestForFilesInDifferentOrders() { var f1 = MakeRootFile("TestHitDriver1"); var f2 = MakeRootFile("TestHitDriver2"); var query = MakeQuery(0); /// Cache a result var h = new ROOTNET.NTH1F("hi", "there", 10, 0.0, 10.0) { Directory = null }; h.SetBinContent(1, 5.0); var q = new QueryResultCache(); var k1 = q.GetKey(new Uri[] { f1, f2 }, "test", null, null, query, dateChecker: u => File.GetLastWriteTime(u.LocalPath)); var k2 = q.GetKey(new Uri[] { f2, f1 }, "test", null, null, query, dateChecker: u => File.GetLastWriteTime(u.LocalPath)); await q.CacheItem(k1, new NTObject[] { h }.AsRunInfoArray()); // // Now, do the lookup, but with files in a different order. // var r1 = await q.Lookup <int>(k1, new DummySaver(), null); var r2 = await q.Lookup <int>(k2, new DummySaver(), null); Assert.IsTrue(r1.Item1, "expected hit for same key"); Assert.IsTrue(r2.Item1, "expected hit for second key with different files"); }
public async Task TestForFileOutOfDateNoCheck() { var f = MakeRootFile("TestForFileOutOfDate"); var query = MakeQuery(0); /// Cache a result var h = new ROOTNET.NTH1F("hi", "there", 10, 0.0, 10.0) { Directory = null }; h.SetBinContent(1, 5.0); var q = new QueryResultCache(); await q.CacheItem(q.GetKey(new Uri[] { f }, "test", null, null, query, dateChecker: u => File.GetLastWriteTime(u.LocalPath)), new NTObject[] { h }.AsRunInfoArray()); /// Modify the file using (var w = File.CreateText(f.LocalPath)) { w.WriteLine("fork it!"); w.Close(); } /// And make sure the lookup fails now! var r = await Lookup <int>(q, f, "test", null, null, query, new DummySaver()); Assert.IsTrue(r.Item1, "altered file should not have triggered the re-check"); }
public static ROOTNET.NTH1F Plot <TSource> ( this IQueryable <TSource> source, string plotID, string plotTitle, int nbins, double lowBin, double highBin, Expression <Func <TSource, double> > getter) { var hParameter = Expression.Parameter(typeof(ROOTNET.NTH1F), "h"); var vParameter = Expression.Parameter(typeof(TSource), "v"); /// h.Fill(getter(v)) is what we want to code up var callGetter = Expression.Invoke(getter, vParameter); var fillMethod = typeof(ROOTNET.NTH1F).GetMethod("Fill", new Type[] { typeof(double) }); var callFill = Expression.Call(hParameter, fillMethod, callGetter); var lambda = Expression.Lambda <Action <ROOTNET.NTH1F, TSource> >(callFill, hParameter, vParameter); var seed = new ROOTNET.NTH1F(plotID, plotTitle, nbins, lowBin, highBin) { Directory = null }; return(source.ApplyToObject(seed, lambda)); }
public async Task CacheCycledInteger() { // A simple query var query = MakeQuery(0); var f = new Uri("http://www.nytimes.com"); // Cache an integer var h1 = new ROOTNET.NTH1F("hi", "there", 1, 0.0, 10.0) { Directory = null }; h1.SetBinContent(1, 5.0); var h2 = new ROOTNET.NTH1F("hi", "there", 1, 0.0, 10.0) { Directory = null }; h2.SetBinContent(1, 2.0); var cacheCycles = new NTObject[][] { new NTObject[] { h1 }, new NTObject[] { h2 } }; var q = new QueryResultCache(); var date = DateTime.Now; await q.CacheItem(q.GetKey(new Uri[] { f }, "test", null, null, query, dateChecker: u => date), cacheCycles.AsRunInfoArray2D()); // Now, do the lookup. var r = await Lookup <int>(q, f, "test", null, null, query, new DummySaver(), generateAdder : () => new DummyIntAdder()); Assert.IsTrue(r.Item1, "expected hit"); Assert.AreEqual(7, r.Item2, "incorrect return value"); }
/// <summary> /// Given a 2D plot, map to a 1D plot assuming radial distances. /// </summary> /// <param name="ctx"></param> /// <param name="plot"></param> /// <returns>1D plot of the 2D plot</returns> /// <remarks> /// - Radial conversion assumes that both coordinates are the same units. For example, if they are x and y distances. /// - Overflow & underflow bins are not handled. /// - Errors are not properly handled. /// </remarks> public static ROOTNET.Interface.NTH1 asRadial(IScopeContext ctx, ROOTNET.Interface.NTH2 plot) { // First, determine the distances var xmin = plot.Xaxis.GetBinLowEdge(1); var ymin = plot.Yaxis.GetBinLowEdge(1); var xmax = plot.Xaxis.GetBinUpEdge(plot.Xaxis.Nbins); var ymax = plot.Yaxis.GetBinUpEdge(plot.Yaxis.Nbins); var rmin = Math.Sqrt(xmin * xmin + ymin * ymin); var rmax = Math.Sqrt(xmax * xmax + ymax * ymax); var nbin = Math.Max(plot.Xaxis.Nbins, plot.Yaxis.Nbins); var result = new ROOTNET.NTH1F(plot.Name, plot.Title, nbin, rmin, rmax); // Loop over, adding everything in. for (int i_x = 1; i_x <= plot.Xaxis.Nbins; i_x++) { for (int i_y = 1; i_y <= plot.Yaxis.Nbins; i_y++) { var x = plot.Xaxis.GetBinCenter(i_x); var y = plot.Yaxis.GetBinCenter(i_y); var r = Math.Sqrt(x * x + y * y); result.Fill(r, plot.GetBinContent(i_x, i_y)); } } return(result); }
public void TestNameCombo() { GeneratedCode gc = new GeneratedCode(); var obj = new ROOTNET.NTH1F("hi", "there", 10, 0.0, 10.0); var n1 = gc.QueueForTransfer(obj); var n2 = gc.QueueForTransfer(obj); Assert.AreEqual(n1, n2, "Names should be identical"); Assert.AreEqual(1, gc.VariablesToTransfer.Count(), "# of variables to move over wire"); }
public void TestQueueForTransferNoNameChange() { var t = new TypeHandlerROOT(); var origRootObj = new ROOTNET.NTH1F("hi", "there", 10, 10.0, 20.0); var rootObj = Expression.Constant(origRootObj); var gc = new GeneratedCode(); var result = t.ProcessConstantReference(rootObj, gc, MEFUtilities.MEFContainer); Assert.IsNotNull(result); Assert.AreEqual(1, gc.VariablesToTransfer.Count(), "Variables to transfer"); Assert.AreEqual("hi", origRootObj.Name, "Name of original root object"); Assert.AreEqual("there", origRootObj.Title, "Title of original root object"); }
static ROOTNET.NTH1F drawHisto <TColor, TDepth>(Mat inImage, int row, int channel, string histoName = "default") where TColor : struct, IColor where TDepth : IComparable <TDepth>, new() { var testHisto = new ROOTNET.NTH1F(histoName, histoName, inImage.Width, 0.0, inImage.Width); Image <TColor, TDepth> tempImage = inImage.ToImage <TColor, TDepth>(); for (int pixel = 0; pixel < inImage.Width; pixel++) { testHisto.Fill(pixel, Convert.ToDouble(tempImage.Data[row, pixel, channel])); } return(testHisto); }
public void TestQueueTwice() { var t = new TypeHandlerROOT(); var origRootObj = new ROOTNET.NTH1F("hi", "there", 10, 10.0, 20.0); var rootObj = Expression.Constant(origRootObj); var gc = new GeneratedCode(); var result1 = t.ProcessConstantReference(rootObj, gc, MEFUtilities.MEFContainer); var result2 = t.ProcessConstantReference(rootObj, gc, MEFUtilities.MEFContainer); gc.DumpCodeToConsole(); Assert.AreEqual(1, gc.VariablesToTransfer.Count(), "Variables to transfer"); Assert.AreEqual(result1.RawValue, result2.RawValue, "Expected the same raw value for the same object in the same expression"); }
public async Task TestForDiffHistos() { var f = MakeRootFile("TestForTreeNameChanges"); var query = MakeQuery(0); /// Histogram that is feed as input var hInput = new ROOTNET.NTH1F("ops", "notthere", 10, 0.0, 30.0) { Directory = null }; hInput.SetBinContent(2, 5.0); var inputs = new object[] { hInput }; /// Cache a result var h = new ROOTNET.NTH1F("hi", "there", 10, 0.0, 10.0) { Directory = null }; h.SetBinContent(1, 5.0); var q = new QueryResultCache(); await q.CacheItem(q.GetKey(new Uri[] { f }, "test", inputs, null, query, dateChecker: u => File.GetLastWriteTime(u.LocalPath)), new NTObject[] { h }.AsRunInfoArray()); /// And make sure the lookup works now! var hInputLookup = new ROOTNET.NTH1F("ops", "notthere", 10, 0.0, 30.0) { Directory = null }; hInputLookup.SetBinContent(2, 5.5); var r = await Lookup <int>(q, f, "test", new object[] { hInputLookup }, null, query, new DummySaver()); Assert.IsFalse(r.Item1, "Cache should have been there"); }
/// <summary> /// Look to see if we can figure out what the hit is on this Uri. /// </summary> /// <param name="queryIndex"></param> /// <param name="f"></param> private async Task TestForCachingOnUri(int queryIndex, Uri f) { var query = MakeQuery(queryIndex); /// Cache a result var h = new ROOTNET.NTH1F("hi", "there", 10, 0.0, 10.0) { Directory = null }; h.SetBinContent(1, 5.0); var q = new QueryResultCache(); var k = q.GetKey(new Uri[] { f }, "test", null, null, query, dateChecker: u => File.GetLastWriteTime(u.LocalPath)); await q.CacheItem(k, (new NTObject[] { h }).AsRunInfoArray()); var r = await Lookup <int>(q, f, "test", null, null, query, new DummySaver()); Assert.IsTrue(r.Item1, "expected hit"); Assert.AreEqual(5, r.Item2, "incorrect return value"); }
public async Task TestForFileOutOfDate() { var u = MakeRootFile("TestForFileOutOfDate"); var f = new FileInfo(u.LocalPath); var query = MakeQuery(0); /// Cache a result var h = new ROOTNET.NTH1F("hi", "there", 10, 0.0, 10.0) { Directory = null }; h.SetBinContent(1, 5.0); var q = new QueryResultCache(); await q.CacheItem(q.GetKey(new Uri[] { u }, "test", null, null, query, dateChecker: uf => File.GetLastWriteTime(uf.LocalPath)), new NTObject[] { h }.AsRunInfoArray()); /// Modify the file using (var w = f.CreateText()) { w.WriteLine("fork it!"); w.Close(); } f.Refresh(); await Task.Delay(250); /// And make sure the lookup fails now! var r = await Lookup <int>(q, u, "test", null, null, query, new DummySaver(), checkDates : true); Assert.IsFalse(r.Item1, "altered file should have made this fail"); // Next, update the cache and look to make sure that the cache returns a hit this time! await q.CacheItem(q.GetKey(new Uri[] { u }, "test", null, null, query, dateChecker: uf => File.GetLastWriteTime(uf.LocalPath)), new NTObject[] { h }.AsRunInfoArray()); r = await Lookup <int>(q, u, "test", null, null, query, new DummySaver(), checkDates : true); Assert.IsTrue(r.Item1, "altered file should have made this fail"); }
public async Task TestForTreeNameChanges() { var f = MakeRootFile("TestForTreeNameChanges"); var query = MakeQuery(0); /// Cache a result var h = new ROOTNET.NTH1F("hi", "there", 10, 0.0, 10.0) { Directory = null }; h.SetBinContent(1, 5.0); var q = new QueryResultCache(); await q.CacheItem(q.GetKey(new Uri[] { f }, "test", null, null, query, dateChecker: u => File.GetLastWriteTime(u.LocalPath)), new NTObject[] { h }.AsRunInfoArray()); /// And make sure the lookup fails now! var r = await Lookup <int>(q, f, "test1", null, null, query, new DummySaver()); Assert.IsFalse(r.Item1, "different tree should have made this fail"); }
public async Task TestNoStuckInOpenFile() { // When we load up and return a cache, we are storing a histogram in the file - make sure it comes back w/out errors. var f = MakeRootFile("TestHitDriver"); var query = MakeQuery(0); // Cache a result var h = new ROOTNET.NTH1F("hi", "there", 10, 0.0, 10.0) { Directory = null }; h.SetBinContent(1, 5.0); var q = new QueryResultCache(); await q.CacheItem(q.GetKey(new Uri[] { f }, "test", null, null, query, dateChecker: u => File.GetLastWriteTime(u.LocalPath)), new NTObject[] { h }.AsRunInfoArray()); // Do the lookup. var r = await Lookup <ROOTNET.Interface.NTH1F>(q, f, "test", null, null, query, new DummyHistoSaver()); Assert.IsTrue(r.Item1, "expected hit"); Assert.AreEqual("hi", r.Item2.Name, "improper histogram came back"); }
public async Task CacheCycleDuplicateCycles() { // We cannot give a list of items to cache that have the same // cycle number. // A simple query var query = MakeQuery(0); var f = new Uri("http://www.nytimes.com"); // Cache an integer var h1 = new ROOTNET.NTH1F("hi", "there", 1, 0.0, 10.0) { Directory = null }; h1.SetBinContent(1, 5.0); var h2 = new ROOTNET.NTH1F("hi", "there", 1, 0.0, 10.0) { Directory = null }; h2.SetBinContent(1, 2.0); var cacheCycles = new RunInfo[][] { new [] { new RunInfo() { _cycle = 0, _result = h1 } }, new [] { new RunInfo() { _cycle = 0, _result = h2 } } }; var q = new QueryResultCache(); var date = DateTime.Now; await q.CacheItem(q.GetKey(new Uri[] { f }, "test", null, null, query, dateChecker: u => date), cacheCycles); }
public async Task CacheWithVeryLongSourceFilename() { // A simple query var query = MakeQuery(0); var f = new Uri("http://www.nytimes.com/mc15_1111111111111111111111111111111111111111111111111111111111111111111111111113TeV_304810_MadGraphPythia8EvtGen_A14NNPDF23LO_HSS_LLP_mH400_mS50_lt5m_merge_DAOD_EXOT15_e5102_s2698_r7772_r7676_p2877?nFiles=1"); // Cache an integer var h = new ROOTNET.NTH1F("hi", "there", 1, 0.0, 10.0) { Directory = null }; h.SetBinContent(1, 5.0); var q = new QueryResultCache(); var date = DateTime.Now; await q.CacheItem(q.GetKey(new Uri[] { f }, "test", null, null, query, dateChecker: u => date), new NTObject[] { h }.AsRunInfoArray()); // Now, do the lookup. var r = await Lookup <int>(q, f, "test", null, null, query, new DummySaver()); Assert.IsTrue(r.Item1, "expected hit"); Assert.AreEqual(5, r.Item2, "incorrect return value"); }
/// <summary> /// This is used to test PROOF queires. We have it b/c many initial PROOF errors come back /// as text printed to the screen. And our test harness can't capture those messages, unfortunately. /// </summary> /// <param name="args"></param> static void Main(string[] args) { FileInfo runner = new FileInfo("query0.cxx"); if (!runner.Exists) { Console.WriteLine("Not able to find query cxx file"); return; } var targetr = new ProofExecutor(); var env = CreateSimpleQueryEnvironment(); // // Create the query directory // var qDir = new DirectoryInfo(".\\query"); if (qDir.Exists) { Console.WriteLine("Deleting existing query directory!!"); qDir.Delete(true); } qDir.Create(); File.Copy("query0.cxx", ".\\query\\query0.cxx"); File.Copy("ntuple_CollectionTree.h", ".\\query\\ntuple_CollectionTree.h"); File.Copy("junk_macro_parsettree_CollectionTree.C", "query\\junk_macro_parsettree_CollectionTree.C"); runner = new FileInfo("query\\query0.cxx"); // // Now, the histos we are going to transfer over // var histos = new Dictionary<string, object>(); histos["aNTH1F_4"] = new ROOTNET.NTH1F("nothing", "this is it", 100, 0.0, 100.0); histos["aNTH1F_8"] = new ROOTNET.NTH1F("nothing1", "this is it", 100, 0.0, 100.0); histos["aNTH1F_11"] = new ROOTNET.NTH1F("nothing2", "this is it", 100, 0.0, 100.0); histos["aNTH1F_19"] = new ROOTNET.NTH1F("nothing3", "this is it", 100, 0.0, 100.0); histos["aNTH1F_27"] = new ROOTNET.NTH1F("nothing4", "this is it", 100, 0.0, 100.0); histos["aNTH1F_31"] = new ROOTNET.NTH1F("nothing5", "this is it", 100, 0.0, 100.0); histos["aNTH1F_34"] = new ROOTNET.NTH1F("nothing6", "this is it", 100, 0.0, 100.0); histos["aNTH1F_42"] = new ROOTNET.NTH1F("nothing7", "this is it", 100, 0.0, 100.0); // // Finally, run it. // targetr.Environment = env; var r = targetr.Execute(runner, qDir, histos); qDir.Refresh(); if (qDir.Exists) { Console.WriteLine("!!! Query directory still exists!"); } if (r == null) { Console.WriteLine("Hey - nothing came back!"); return; } Console.WriteLine("# of returned items: {0}", r.Count); #if false Assert.AreEqual("aInt32_1", r.Keys.First(), "Key name incorrect"); var o = r["aInt32_1"]; Assert.IsInstanceOfType(o, typeof(ROOTNET.NTH1I), "return histo type"); var h = o as ROOTNET.NTH1I; Assert.AreEqual(2000, (int)h.GetBinContent(1), "Answer from query"); #endif }
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 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 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"); }
static void Main(string[] args) { List <string> tempFileList = new List <string>(); //var h = new ROOTNET.NTH1F(); //File list from Blizz Americas Championship //tempFileList.Add("test.png"); //tempFileList.Add("test480.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h19m07s974.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h19m25s545.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h19m35s253.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h19m55s213.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h19m59s995.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h20m11s857.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h20m19s473.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h20m35s166.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h20m38s961.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h20m56s916.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h21m03s792.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h21m30s637.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h21m36s183.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h22m00s213.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h22m09s622.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h22m22s416.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h22m33s378.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h22m45s875.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h22m50s183.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h23m06s850.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h23m11s075.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h23m20s624.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h23m25s391.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h23m35s019.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h23m39s636.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h23m49s060.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h24m34s479.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h24m44s448.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h24m56s372.png"); tempFileList.Add("testImages/vlcsnap-2015-09-24-01h25m05s414.png"); fileImageProducer blizzAmericas = new fileImageProducer(tempFileList); var newFile = new ROOTNET.NTFile("output.root", "RECREATE"); //String win1 = "Edge output test"; //Window name //CvInvoke.NamedWindow(win1); //Create the window with the name persona 3 style Mat outImage = new Mat(); RegionOfInterest leftBlizz = new RegionOfInterest(510f / 1280f, 0f / 720f, 100f / 1280f, 20f / 700f); RegionOfInterest rightBlizz = new RegionOfInterest(665f / 1280f, 0f / 720f, 100f / 1280f, 20f / 700f); var bestRowHisto = new ROOTNET.NTH1I("bestRows", "Top rows by discrimination", 20, 0, 20); //newFile.Add(bestRowHisto); //Text for comparison. "TEMPO STORM" TextSize textSizeTest = new TextSize(leftBlizz.getROIImage(blizzAmericas.ElementAt(0).loadedImage)); PeakPattern peakPatternTest = new PeakPattern(leftBlizz.getROIImage(blizzAmericas.ElementAt(0).loadedImage), 200.0); //PeakPattern peakPatternTest2 = new PeakPattern(rightBlizz.getROIImage(blizzAmericas.Last().loadedImage)); for (int iImage = 0; iImage < blizzAmericas.Count(); iImage++) { Image testc = blizzAmericas.ElementAt(iImage); Mat leftRegion = leftBlizz.getROIImage(testc.loadedImage); Mat rightRegion = rightBlizz.getROIImage(testc.loadedImage); List <Tuple <int, int> > rowResult = topThree(entropyList <Bgr, byte>(leftRegion, rightRegion, new byte[] { 180, 180, 180 })); ROOTNET.NTH1F tempLeft = drawHisto <Bgr, double>(leftRegion, rowResult[0].Item1, 0, "left " + iImage); ROOTNET.NTH1F tempRight = drawHisto <Bgr, double>(rightRegion, rowResult[0].Item1, 0, "right " + iImage); //newFile.Add(tempLeft); //newFile.Add(tempRight); bestRowHisto.Fill(rowResult[0].Item1); bestRowHisto.Fill(rowResult[1].Item1); bestRowHisto.Fill(rowResult[3].Item1); //Console.WriteLine("Row {0} with {1}, row {2} with {3}, row {4} with {5}.", // rowResult[0].Item1, rowResult[0].Item2, // rowResult[1].Item1, rowResult[1].Item2, // rowResult[2].Item1, rowResult[2].Item2); Console.WriteLine("File {0}", tempFileList[iImage]); //Console.WriteLine("TextSize Probability left {0}, TextSize probability right {1}.", // textSizeTest.ProbabilityMatch(leftRegion), // textSizeTest.ProbabilityMatch(rightRegion)); Console.WriteLine("PeakPattern cosine left {0}, PeakPattern cosine right {1}.", peakPatternTest.ProbabilityMatch(leftRegion), peakPatternTest.ProbabilityMatch(rightRegion)); } //CvInvoke.Imshow(win1, testMat); //TesseractEngine testOCR = new TesseractEngine("langDat", "eng", Tesseract.EngineMode.Default); //testOCR.DefaultPageSegMode(Tesseract.PageSegMode.SingleChar); //testOCR. //ImageViewer.Show(outImage, "test"); //Some numbers from a 720p image in paint for ROI testing. //ImageViewer.Show(leftBlizz.getROIImage(blizzAmericas.ElementAt(0).loadedImage), "leftName"); //ImageViewer.Show(rightBlizz.getROIImage(blizzAmericas.ElementAt(0).loadedImage), "rightName"); Mat testProcessing = leftBlizz.getROIImage(blizzAmericas.ElementAt(0).loadedImage); Mat testProcessingRight = rightBlizz.getROIImage(blizzAmericas.ElementAt(1).loadedImage); System.Drawing.Rectangle textRegion = ProcessingTools.findTextEdge <Bgr, double>(testProcessing, new double[] { 180.0, 180.0, 180.0 }); System.Drawing.Rectangle textRegion2 = ProcessingTools.findTextEdge <Bgr, double>(testProcessingRight, new double[] { 180.0, 180.0, 180.0 }); //CvInvoke.Rectangle(testProcessing, textRegion, new Bgr(0, 0, 255).MCvScalar); //ImageViewer.Show(leftBlizz.getROIImage(blizzAmericas.ElementAt(0).loadedImage), "leftName"); //CvInvoke.Rectangle(testProcessingRight, textRegion2, new Bgr(0, 0, 255).MCvScalar); //ImageViewer.Show(testProcessingRight, "rightName"); //ImageViewer.Show(testProcessing); //Mat[] leftBlizzChannels = leftBlizz.getROIImage(outImage).Split(); //Mat[] rightBlizzChannels = rightBlizz.getROIImage(outImage).Split(); //foreach( Mat iMat in leftBlizzChannels) //{ // ImageViewer.Show(iMat); //} Console.ReadKey(); //Wait for return to finish! newFile.Write(); //newFile.Close(); }