Print

Print


Commit in lcsim/src/org/lcsim/contrib/LeiXia on MAIN
rms90_order.java+81added 1.1


lcsim/src/org/lcsim/contrib/LeiXia
rms90_order.java added at 1.1
diff -N rms90_order.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ rms90_order.java	29 Sep 2006 16:51:13 -0000	1.1
@@ -0,0 +1,81 @@
+import hep.aida.*;
+import java.util.Random;
+import org.freehep.application.*;
+import org.freehep.application.studio.*;
+
+public class rms90_order
+{
+   public static void main(String[] argv) throws java.io.IOException
+   {
+
+       IAnalysisFactory af = IAnalysisFactory.create();
+       ITree tree = af.createTreeFactory().create();
+       IHistogramFactory hf = af.createHistogramFactory(tree);
+
+       ITree aidaMasterTree = (ITree) ((Studio) Application.getApplication()).getLookup().lookup(ITree.class);
+       
+// here, put in the full path of the 1D cloud that contains your PFA result
+       ICloud1D InputCloud = (ICloud1D) aidaMasterTree.find("/rpc_PFA_np_hmx_006_dev2.aida/E_ppfa: barrel events 1");
+       int Entry = InputCloud.entries();
+       
+       ICloud2D test = hf.createCloud2D("test: rms");
+       
+       double[] list = new double[Entry];
+
+       int i = 0;
+       while (i < Entry)
+       {
+         list[i] = InputCloud.value(i);
+         i++;
+       }
+       
+       i = 1;
+       while (i>0)
+       {
+         i = 0;
+         for (int j=0; j < (Entry-1); j++)
+	 {
+	   if (list[j] > list[j+1])
+	   {
+	     double temp = list[j];
+	     list[j] = list[j+1];
+	     list[j+1] = temp;
+	     i++;
+	   }
+	 }
+       }
+       
+//       for (i = 0; i < Entry; i++)
+//       {
+//         System.out.println("list["+i+"] : "+list[i]);
+//       }
+       
+       double CentralFraction = 0.90;
+       double rms_min = 1000.;	// minimum rms for whatever CentralFraction range
+       double rms = 0.;
+       
+       int NTail = (int)(Entry*(1-CentralFraction));
+       
+       for (i = 0; i < NTail; i++)
+       {
+	 double xm = 0.;
+	 double xm2 = 0.;
+	 double xn = 0.;
+	 
+	 for (int j = i; j < (i+(Entry-NTail)); j++)
+	 {
+	   xm += list[j];
+	   xm2 += list[j]*list[j];
+	   xn += 1.;
+	 }
+
+	 rms = Math.sqrt(xm2/xn - (xm/xn)*(xm/xn));
+	 test.fill(i*1.0, rms);
+	 
+	 if (rms < rms_min) rms_min = rms;
+       }
+       
+       System.out.println("rms_90  : "+rms_min);
+	 
+   }
+}
CVSspam 0.2.8