mcd-analysis/src/main/java/org/lcsim/mcd/analysis
diff -N CalAnalysisDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CalAnalysisDriver.java 11 Jan 2012 16:26:22 -0000 1.1
@@ -0,0 +1,69 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+//
+//package org.lcsim.mcd.analysis;
+
+import hep.aida.IAnalysisFactory;
+import hep.aida.ICloud1D;
+import hep.aida.IHistogram1D;
+import hep.aida.IHistogramFactory;
+import hep.aida.ITree;
+import java.util.List;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.EventHeader.LCMetaData;
+import org.lcsim.event.SimCalorimeterHit;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+/**
+ *
+ * @author wenzel
+ */
+public class CalAnalysisDriver extends Driver {
+
+ double clight = 299.792458; //speed of light [mm/nsec]
+ IAnalysisFactory af = IAnalysisFactory.create();
+ ITree tree = af.createTreeFactory().create();
+ IHistogramFactory hf = af.createHistogramFactory(tree);
+ // tree.mkdir("/Histograms");
+ // tree.cd("/Histograms");
+ IHistogram1D h1 = hf.createHistogram1D("time", 1000, -1., 1.);
+// IHistogram2D h2 = hf.createHistogram2D("Histogram 1D",);
+ //tree.mkdir("/Clouds");
+ //tree.cd("/Clouds");
+ ICloud1D c1 = hf.createCloud1D("Energy");
+ ICloud1D c2 = hf.createCloud1D("Radius");
+// private AIDA aida = AIDA.defaultInstance();
+// IHistogram1D h1 = aida.Histogram1D("Histogram 1D",50,-3,3);
+
+ @Override
+ protected void process(EventHeader event) {
+ List<List<SimCalorimeterHit>> calHitLists = event.get(SimCalorimeterHit.class);
+ for (List<SimCalorimeterHit> calHitList : calHitLists) {
+ LCMetaData meta = event.getMetaData(calHitList);
+
+ String calName = meta.getName();
+// System.out.println(calName);
+ if ("Edep_EcalBarrelHits".equals(calName)||"Edep_HcalBarrelHits".equals(calName)) {
+ for (SimCalorimeterHit h : calHitList) {
+ double time = h.getTime();
+ if (time < 0.0) {
+ System.out.println(time);
+ }
+ double energy = h.getRawEnergy();
+ double[] xpos = h.getPosition();
+ double radius = Math.sqrt(xpos[0] * xpos[0] + xpos[1] * xpos[1]);
+ double length = Math.sqrt(xpos[0] * xpos[0] + xpos[1] * xpos[1] + xpos[2] * xpos[2]);
+ h1.fill(time - length / clight, energy * 0.001);
+ c1.fill(energy);
+ c2.fill(radius);
+ //aida.cloud2D("rvsz").fill(xpos[2], radius);
+ //aida.cloud1D("energy").fill(energy);
+ }
+ }
+ }
+
+ }
+}