lcsim/src/org/lcsim/contrib/CarstenHensel
diff -N FixedConeClustererAnalyzer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ FixedConeClustererAnalyzer.java 22 Aug 2005 02:35:21 -0000 1.1
@@ -0,0 +1,130 @@
+/*
+ * FixedConeClustererAnalyzer.java
+ *
+ * Created on August 21, 2005, 8:08 PM
+ *
+ *
+ */
+
+package org.lcsim.contrib.CarstenHensel;
+
+import hep.aida.ICloud1D;
+import hep.aida.ICloud2D;
+import hep.aida.IHistogram1D;
+import hep.aida.ITree;
+import java.text.DecimalFormat;
+import java.text.FieldPosition;
+import java.util.List;
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.MCParticle;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+/**
+ *
+ * @author carsten
+ */
+public class FixedConeClustererAnalyzer extends Driver{
+ private AIDA aida = AIDA.defaultInstance();
+ private ITree tree;
+ private DecimalFormat df;
+ private double SAMP_FRAC;
+ private double radiusCut;
+ private int debug;
+ private int eventCounter = 0;
+
+ /** Creates a new instance of FixedConeClustererAnalyzer */
+ public FixedConeClustererAnalyzer() {
+ this.df = new DecimalFormat();
+
+ }
+
+ public FixedConeClustererAnalyzer(ITree tree) {
+ this();
+ this.tree = tree;
+ this.tree.mkdir(this.toString());
+ }
+
+ public void setAttributes(double samplingFraction, int debug, double radiusCut){
+ this.SAMP_FRAC = samplingFraction;
+ this.debug = debug;
+ this.radiusCut = radiusCut;
+ }
+
+ public boolean eventPassed(List<MCParticle> mcParticles) {
+ boolean passed = false;
+ for (MCParticle mcParticle : mcParticles) {
+ if (mcParticle.getGeneratorStatus() == MCParticle.FINAL_STATE) {
+
+ /*
+ * Rejects photons with radius < 1260. Here, radius is not an
+ * angle but is an actual radius.
+ *
+ * 'pre-selection'
+ */
+
+ if (mcParticle.getType().getName().equals("gamma")
+ && mcParticle.getEndPoint().magnitude() < this.radiusCut) {
+ passed = false;
+ } else {
+ passed = true;
+ }
+ }
+ }
+ return passed;
+ }
+
+ public void process(EventHeader event) {
+ aida.cloud1D("FCCA").fill(1.0);
+ List<MCParticle> mcParticles = event.getMCParticles();
+ if (!this.eventPassed(mcParticles)) {
+ return;
+ } else {
+ this.eventCounter++;
+
+ }
+ }
+
+
+ public void testEfficiency(double eInit, double eMostEnergetic, double eMax, double angle) {
+ double[] K = {0.10,0.25,0.5,1.0,2.0,3.0};
+ StringBuffer buf = new StringBuffer();
+
+ //for (double k : K) {
+ for (double k = 0.1; k < 2.0; k += 0.1) {
+ buf.delete(0, buf.length());
+ buf.insert(0, "k_");
+ df.setMaximumFractionDigits(2);
+ df.setMinimumFractionDigits(2);
+ df.format(k, buf, new FieldPosition(df.INTEGER_FIELD));
+ String kStr = buf.toString();
+
+ IHistogram1D effHist = aida.histogram1D("Efficiency " + kStr,2,-.5,1.5);
+ ICloud1D diffTest = aida.cloud1D("Efficiency test difference " + kStr);
+ ICloud2D effMin = aida.cloud2D("Efficiency test min vs eMostEnergetic " + kStr);
+
+ double effMinVal = eMax - k*0.2*Math.sqrt(eInit)*SAMP_FRAC;
+
+ diffTest.fill(eMostEnergetic-effMinVal);
+ effMin.fill(eMostEnergetic, effMinVal);
+
+ if (eMostEnergetic > effMinVal) {
+ effHist.fill(1.0);
+
+
+ if (this.debug > 0)
+ System.out.println("Filled efficiency with 1");
+ }
+ else {
+ effHist.fill(0.0);
+ if (this.debug > 0)
+ System.out.println("Filled efficiency with 0");
+ }
+ }
+ }
+
+ public void endOfData() {
+ System.out.println(this.eventCounter + " events analyzed by FCCA");
+ }
+
+}