1 added + 2 modified, total 3 files
lcsim-contrib/src/main/java/org/lcsim/contrib/Partridge/TextFileToStdhep
diff -N TextFileToStdhep2.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TextFileToStdhep2.java 7 May 2009 23:59:44 -0000 1.1
@@ -0,0 +1,148 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.lcsim.contrib.Partridge.TextFileToStdhep;
+
+/**
+ *
+ * @author richp
+ */
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.StreamTokenizer;
+import java.util.ArrayList;
+import java.util.List;
+
+import hep.io.stdhep.StdhepBeginRun;
+import hep.io.stdhep.StdhepEndRun;
+import hep.io.stdhep.StdhepEvent;
+import hep.io.stdhep.StdhepWriter;
+
+public class TextFileToStdhep2 {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) throws IOException {
+
+ String file = "c:/sATLASFull-Test/MinBias_14TeV_1E35_1404bunches_100evts_diffractive_v20";
+// String file = "c:/sATLASFull-Test/MinBias_14TeV_40000int_v19";
+ String infile = file + ".txt";
+ String outfile = file + ".stdhep";
+ process(infile, outfile);
+ }
+
+ private static void process(String infile, String outfile) throws IOException {
+// try {
+ FileReader fr = new FileReader(infile);
+ StreamTokenizer tok = new StreamTokenizer(fr);
+ tok.resetSyntax();
+ tok.wordChars(33, 255);
+ tok.parseNumbers();
+ tok.whitespaceChars(0, ' ');
+ tok.eolIsSignificant(true);
+ List<Double> beg = getNumbersInLine(tok);
+ if (beg.size() != 7) {
+ throw new RuntimeException("Unexpected entry in begin run record");
+ }
+ int nreq = beg.get(0).intValue();
+ int ngen = beg.get(1).intValue();
+ int nwrit = beg.get(2).intValue();
+ float ecm = beg.get(3).floatValue();
+ float xsec = beg.get(4).floatValue();
+ double rn1 = beg.get(5);
+ double rn2 = beg.get(6);
+ StdhepWriter sw = new StdhepWriter(outfile, "Imported Stdhep Events",
+ "From file " + infile, nwrit);
+ sw.setCompatibilityMode(false);
+ StdhepBeginRun sb = new StdhepBeginRun(nreq, ngen, nwrit, ecm, xsec, rn1, rn2);
+ sw.writeRecord(sb);
+ for (int icross = 0; icross < nwrit; icross++) {
+ List<Double> nums = getNumbersInLine(tok);
+ if (nums.size() != 2) {
+ throw new RuntimeException("Unexpected entry for number of particles");
+ }
+ int nevhep = nums.get(0).intValue();
+ int nhep = nums.get(1).intValue();
+ System.out.println("Number of particles for event " + nevhep + ": " + nhep);
+ int isthep[] = new int[nhep];
+ int idhep[] = new int[nhep];
+ int jmohep[] = new int[2 * nhep];
+ int jdahep[] = new int[2 * nhep];
+ double phep[] = new double[5 * nhep];
+ double vhep[] = new double[4 * nhep];
+ for (int i = 0; i < nhep; i++) {
+ List<Double> vals = getNumbersInLine(tok);
+ if (vals.size() != 16) {
+ throw new RuntimeException("Unexpected entry for a particle");
+ }
+ int ip = vals.get(0).intValue();
+ if (ip != i + 1) {
+ throw new RuntimeException("Particle numbering mismatch");
+ }
+ isthep[i] = vals.get(1).intValue();
+ idhep[i] = vals.get(2).intValue();
+ jmohep[2 * i] = vals.get(3).intValue();
+ jmohep[2 * i + 1] = vals.get(4).intValue();
+ jdahep[2 * i] = vals.get(5).intValue();
+ jdahep[2 * i + 1] = vals.get(6).intValue();
+ for (int j = 0; j < 5; j++) {
+ phep[5 * i + j] = vals.get(j + 7);
+ }
+ for (int j = 0; j < 4; j++) {
+ vhep[4 * i + j] = vals.get(j + 12);
+ }
+
+// if (i == 0 || i == nhep - 1) {
+// System.out.println(ip + " st: " + isthep[i] + " id: " + idhep[i] +
+// " jmo: " + jmohep[2 * i] + " " + jmohep[2 * i + 1] +
+// " jda: " + jdahep[2 * i] + " " + jdahep[2 * i + 1]);
+// System.out.println("p: " + phep[5 * i] + " " + phep[5 * i + 1] + " " +
+// phep[5 * i + 2] + " " + phep[5 * i + 3] + " " + phep[5 * i + 4]);
+// System.out.println("v: " + vhep[4 * i] + " " + vhep[4 * i + 1] + " " +
+// vhep[4 * i + 2] + " " + vhep[4 * i + 3]);
+// }
+ }
+ StdhepEvent ev = new StdhepEvent(nevhep, nhep, isthep, idhep, jmohep, jdahep, phep, vhep);
+ sw.writeRecord(ev);
+ }
+ List<Double> end = getNumbersInLine(tok);
+ if (end.size() != 7) {
+ throw new RuntimeException("Unexpected entry in begin run record");
+ }
+ int nreqe = end.get(0).intValue();
+ int ngene = end.get(1).intValue();
+ int nwrite = end.get(2).intValue();
+ float ecme = end.get(3).floatValue();
+ float xsece = end.get(4).floatValue();
+ double rn1e = end.get(5);
+ double rn2e = end.get(6);
+ StdhepEndRun se = new StdhepEndRun(nreqe, ngene, nwrite, ecme, xsece, rn1e, rn2e);
+ sw.writeRecord(se);
+
+ sw.close();
+ fr.close();
+// } catch (IOException e) {
+// System.out.println("Error opening " + infile);
+// }
+ }
+
+ @SuppressWarnings("static-access")
+ private static List<Double> getNumbersInLine(StreamTokenizer tok) throws IOException {
+ List<Double> nums = new ArrayList<Double>();
+ while (tok.nextToken() != tok.TT_EOF) {
+ if (tok.ttype == tok.TT_EOL) {
+ break;
+ }
+
+ if (tok.ttype != tok.TT_NUMBER) {
+ throw new RuntimeException("Non numeric data encountered");
+ }
+
+ nums.add(tok.nval);
+ }
+
+ return nums;
+ }
+}
lcsim-contrib/src/main/java/org/lcsim/contrib/Partridge/TextFileToStdhep
diff -u -r1.2 -r1.3
--- GenerateMuons.java 25 Mar 2009 00:30:24 -0000 1.2
+++ GenerateMuons.java 7 May 2009 23:59:44 -0000 1.3
@@ -19,14 +19,14 @@
public static void main(String[] args) throws IOException {
Random generator = new Random();
- int nwrit = 10000;
- StdhepWriter sw = new StdhepWriter("c:\\muon_100GeV_1-179_10000_0.slcio", "Single muons",
+ int nwrit = 200;
+ StdhepWriter sw = new StdhepWriter("c:\\muon_1dot5GeV_10-170_200_0.stdhep", "Single muons",
"Single muons", nwrit);
sw.setCompatibilityMode(false);
for (int icross = 0; icross < nwrit; icross++) {
- double p = 100.;
+ double pt = 1.5;
double m = 0.105658;
- double theta = (178. * generator.nextDouble() + 1.) * Math.PI / 180.;
+ double theta = (160. * generator.nextDouble() + 10.) * Math.PI / 180.;
double phi = 2. * Math.PI * generator.nextDouble();
int nevhep = icross;
int nhep = 1;
@@ -40,10 +40,11 @@
int jdahep[] = new int[2];
for (int i=0; i<2; i++) jdahep[i] = 0;
double phep[] = new double[5];
- phep[0] = p * Math.sin(theta) * Math.cos(phi);
- phep[1] = p * Math.sin(theta) * Math.sin(phi);
- phep[2] = p * Math.cos(theta);
- phep[3] = Math.sqrt(p*p + m*m);
+ phep[0] = pt * Math.cos(phi);
+ phep[1] = pt * Math.sin(phi);
+ phep[2] = pt / Math.tan(theta);
+ double p2 = pt*pt + phep[2]*phep[2];
+ phep[3] = Math.sqrt(p2 + m*m);
phep[4] = m;
double vhep[] = new double[4];
for (int i=0; i<4; i++) vhep[i] = 0.;
lcsim-contrib/src/main/java/org/lcsim/contrib/Partridge/TextFileToStdhep
diff -u -r1.4 -r1.5
--- TextFileToStdhep.java 25 Mar 2009 00:30:24 -0000 1.4
+++ TextFileToStdhep.java 7 May 2009 23:59:44 -0000 1.5
@@ -30,10 +30,10 @@
// }
// String file = args[0];
for (int i = 0; i < 1; i++) {
- for (int j = 1; j < 2; j++) {
+ for (int j = 1; j < 6; j++) {
int k = 0;
if (i == 0 && j == 0) k = 1;
- String file = "c:/StdHepWriter/Minbias_14TeV_1E35_1404bunches_100evts_HCOnly" + k + i + j;
+ String file = "c:/sATLASFull-Test/MinBias_14TeV_100Int_HCOnly" + k + i + j;
String infile = file + ".txt";
String outfile = file + ".stdhep";
process(infile, outfile);
CVSspam 0.2.8