Print

Print


Commit in SlicDiagnostics/scripts on MAIN
compareTwoFiles.pnut+194added 1.1


SlicDiagnostics/scripts
compareTwoFiles.pnut added at 1.1
diff -N compareTwoFiles.pnut
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ compareTwoFiles.pnut	25 Jan 2007 21:36:22 -0000	1.1
@@ -0,0 +1,194 @@
+// Comparing two AIDA files with Histograms
+use("pnuts.lib")
+
+
+Integer = class java.lang.Integer;
+System = class java.lang.System;
+
+////////////////////////////////////////////////////////////
+////// EDIT HERE: Names of two files 
+fileName1 = "C:\\work\\Data\\file-0.aida";
+fileName2 = "C:\\work\\Data\\file-1.aida";
+
+//fileName1 = "C:\\work\\Data\\pythiaZPoleuds-0-1000_SLIC_v2r1p4_acme0605_calorimeter.aida";
+//fileName2 = "C:\\work\\Data\\pythiaZPoleuds-0-10000_SLIC_v2r0p0_acme0605_calorimeter.aida";
+////////////////////////////////////////////////////////////
+
+IAnalysisFactory = class hep.aida.IAnalysisFactory;
+af = IAnalysisFactory::create();
+tf = af.createTreeFactory();
+pf = af.createPlotterFactory();
+
+plotter = af.createPlotterFactory().create("Compare Plots");
+plotter.show();
+
+// Open files in JAS3
+start = System::currentTimeMillis();
+
+println("\nOpenning file: "+fileName1);
+flush();
+tree1 = tf.create(fileName1,"xml",true);
+println("Done");
+flush();
+
+println("\nOpenning file: "+fileName2);
+flush();
+tree2 = tf.create(fileName2,"xml",true);
+println("Done");
+flush();
+
+end = System::currentTimeMillis();
+ttime = (end-start)/1000;
+println("Total time openning files: " + ttime + " sec\n");
+flush();
+
+// Find names and types here
+names1 = tree1.listObjectNames("/", true);
+types1 = tree1.listObjectTypes("/", true);
+names2 = tree2.listObjectNames("/", true);
+types2 = tree2.listObjectTypes("/", true);
+
+
+// Configure plotting styles here
+
+style1 = pf.createPlotterStyle();
+style1.dataStyle().fillStyle().setVisible(false);
+style1.dataStyle().lineStyle().setColor("red");
+style1.dataStyle().lineStyle().setVisible(false);
+style1.dataStyle().errorBarStyle().setVisible(true);
+style1.dataStyle().markerStyle().setVisible(true);
+style1.dataStyle().markerStyle().setSize(6);
+style1.dataStyle().markerStyle().setShape("dot");
+style1.dataStyle().markerStyle().setColor("red");
+style1.statisticsBoxStyle().setVisible(true);
+
+style2 = pf.createPlotterStyle();
+style2.dataStyle().lineStyle().setVisible(true);
+style2.dataStyle().lineStyle().setColor("blue");
+style2.dataStyle().fillStyle().setVisible(false);
+style2.dataStyle().errorBarStyle().setVisible(false);
+style2.dataStyle().markerStyle().setVisible(false);
+style2.dataStyle().markerStyle().setColor("blue");
+style2.statisticsBoxStyle().setVisible(true);
+
+N = [0, 1, 2];
+
+
+//
+// Use this to plot set #k in the directory listing
+//
+function plot(k) {
+     N[0] = k;
+     plot();
+}
+
+
+//
+// Main plotting function, plots current set
+//
+function plot() {
+     nnn = N[0];
+
+     // Check if the number is valid
+
+     if (nnn < 0) {
+          println("**** Number " + nnn + " is negative,  will plot the FIRST histogram in the file");
+          flush();
+          nnn = 0;
+     } else if (nnn >= names1.length) {
+          println("**** Number " + nnn + " is more than maximum: " + names1.length + ",  will plot the LAST histogram in the file");
+          flush();
+          nnn = names1.length -1;
+           while (nnn > 0 && types1[nnn].trim().equalsIgnoreCase("dir")) {
+               nnn--;
+          }
+     }
+
+     while (types1[nnn].trim().equalsIgnoreCase("dir") ) {
+               nnn++;
+               if (nnn >= names1.length) {
+                    println("No valid histograms for that number or above");
+                    flush();
+                    N[0] = nnn;
+                    return;
+               }
+     }
+
+     //  Find and plot histograms
+ 
+     println("Plotting:  #" + nnn + "\t" + names1[nnn] + "\t" + types1[nnn]);
+     flush();
+     h1 = tree1.find(names1[nnn]);
+     h2 = tree2.find(names1[nnn]);
+
+     plotter.region(0).clear();
+     plotter.region(0).plot(h1, style1);
+     plotter.region(0).plot(h2, style2, "mode=overlay");
+     plotter.region(0).setTitle(names1[nnn]);
+     plotter.show();
+     N[0] = nnn;
+     return;
+}
+
+
+//
+// Use this to plot the next set
+//
+function next() {
+     iii = N[0];
+     plot(++iii);
+}
+
+
+//
+// Use this to plot the set before
+//
+function back() {
+     fff = 0;
+     iii = N[0] - 1;
+     if (iii < 0) {
+          plot(iii);
+     } else {
+           while (iii >= 0 && types1[iii].trim().equalsIgnoreCase("dir")) {
+               iii--;
+          }
+          plot(iii);
+     }
+}
+
+
+//
+// list directory functions
+//
+
+function ls() {
+     ls("/", false);
+}
+
+function ls(path) {
+     ls(path, false);
+}
+
+function ls(path, recursive) {
+     println("\nDirectory listing for path: " + path + ", recursive=" + recursive);
+     flush();
+
+     tmpNames1 = tree1.listObjectNames(path, true);
+     tmpTypes1 = tree1.listObjectTypes(path, true);
+     for (i=0; i<tmpNames1.length; i++) {
+          println("\t" + i + "\t" + tmpNames1[i] + "\t" + tmpTypes1[i]);
+     }
+     flush();
+}
+
+
+//
+// Refresh names and types
+//
+function refresh() {
+     names1 = tree1.listObjectNames("/", true);
+     types1 = tree1.listObjectTypes("/", true);
+     names2 = tree2.listObjectNames("/", true);
+     types2 = tree2.listObjectTypes("/", true);
+}
+
CVSspam 0.2.8