lcsim-contrib/src/main/java/org/lcsim/contrib/Partridge/dilepton
diff -N DileptonAnalysis.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DileptonAnalysis.java 8 Feb 2010 22:14:45 -0000 1.1
@@ -0,0 +1,90 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.lcsim.contrib.Partridge.dilepton;
+
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.VecOp;
+
+import java.util.Random;
+//import org.lcsim.util.aida.AIDA;
+
+/**
+ *
+ * @author richp
+ */
+public class DileptonAnalysis {
+
+ private double _elmax = 300.;
+ private double _elmin = 15.;
+ private double _metmax = 300.;
+ private double _metmin = 20.;
+ private double _mtmin = 100.;
+ private double _mW = 80.;
+ private double _gamW = 2.3;
+ private double _eps = 1.e-6;
+ private Random _rn = new Random();
+// private AIDA _aida = AIDA.defaultInstance();
+
+ public DileptonAnalysis() {
+ }
+
+ public void Analyze() {
+
+ double el1 = _elmax * _rn.nextDouble();
+ double el2 = _elmax * _rn.nextDouble();
+ double met = _metmax * _rn.nextDouble();
+
+ if (el1 < _elmin || el2 < _elmin || met < _metmin) return;
+
+ System.out.println("Electron 1 energy: "+el1+" Electron 2 energy: "+el2+" MET: "+met);
+
+ Hep3Vector pl1 = newRandom(el1);
+ double pl1x = pl1.x();
+ Hep3Vector pl2 = newRandom(el2);
+ Hep3Vector umet = newRandom(1.);
+ double cth = umet.z();
+ double sth = Math.sqrt(1. - cth*cth);
+ double ptotmet = met / sth;
+ Hep3Vector pmet = VecOp.mult(ptotmet, umet);
+
+// double mt1 = Math.sqrt(Math.sqrt(pl2. * (el1 * met )
+ double wgtmax = -1.e99;
+ for (int i=0; i<1000000; i++) {
+ Hep3Vector unu1 = newRandom(1.);
+ Hep3Vector unu2 = newRandom(1.);
+ double denom = unu2.x()*unu1.y() - unu2.y()*unu1.x();
+ if (Math.abs(denom) < _eps) continue;
+ double enu1 = (pmet.y()*unu2.x() - pmet.x()*unu2.y()) / denom;
+ double enu2 = (pmet.x()*unu1.y() - pmet.y()*unu1.x()) / denom;
+ Hep3Vector pnu1 = VecOp.mult(enu1, unu1);
+ Hep3Vector pnu2 = VecOp.mult(enu2, unu2);
+ double m1 = Math.sqrt(el1*enu1 - pl1.x()*pnu1.x() - pl1.y()*pnu1.y() - pl1.z()*pnu1.z());
+ double m2 = Math.sqrt(el2*enu2 - pl2.x()*pnu2.x() - pl2.y()*pnu2.y() - pl2.z()*pnu2.z());
+ double wgt1 = 0.25 * _gamW*_gamW / ((m1 - _mW)*(m1 - _mW) + 0.25 * _gamW*_gamW);
+ double wgt2 = 0.25 * _gamW*_gamW / ((m2 - _mW)*(m2 - _mW) + 0.25 * _gamW*_gamW);
+ double wgt = wgt1 * wgt2;
+ if (wgt > wgtmax) {
+ System.out.println("New weight: "+wgt+" for step "+i+" enu1: "+enu1+" enu2: "+enu2);
+ wgtmax = wgt;
+ }
+// _aida.cloud1D("BW Weight").fill(wgt);
+ }
+
+ }
+
+ private Hep3Vector newRandom(double length) {
+
+ double phi = 2. * Math.PI * _rn.nextDouble();
+ double cth = 2. * _rn.nextDouble() - 1.;
+ double sth = Math.sqrt(1. - cth*cth);
+ double vx = length * Math.cos(phi) * sth;
+ double vy = length * Math.sin(phi) * sth;
+ double vz = length * cth;
+ Hep3Vector v = new BasicHep3Vector(vx, vy, vz);
+ return v;
+ }
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/Partridge/dilepton
diff -N DileptonMain.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DileptonMain.java 8 Feb 2010 22:14:45 -0000 1.1
@@ -0,0 +1,25 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.lcsim.contrib.Partridge.dilepton;
+
+/**
+ *
+ * @author richp
+ */
+public class DileptonMain {
+
+
+ public static void main(String[] args) {
+
+ DileptonAnalysis dla = new DileptonAnalysis();
+
+ for (int i=0; i<100; i++) {
+ dla.Analyze();
+ }
+ }
+
+
+}