Print

Print


Commit in hps-java/src/main/java/org/lcsim/hps/monitoring/ecal on MAIN
EcalEvsX.java+155-1181.7 -> 1.8
get this monitoring plot out of my .cvsignore

hps-java/src/main/java/org/lcsim/hps/monitoring/ecal
EcalEvsX.java 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- EcalEvsX.java	22 May 2012 20:14:18 -0000	1.7
+++ EcalEvsX.java	31 Aug 2012 01:32:09 -0000	1.8
@@ -6,139 +6,176 @@
 import hep.aida.IPlotterStyle;
 import hep.physics.vec.*;
 
+import java.util.ArrayList;
 import java.util.List;
+import org.lcsim.event.CalorimeterHit;
 import org.lcsim.event.Cluster;
 
 import org.lcsim.event.EventHeader;
 import org.lcsim.geometry.Detector;
-import org.lcsim.hps.monitoring.Resettable;
+import org.lcsim.geometry.subdetector.HPSEcal3;
+import org.lcsim.geometry.subdetector.HPSEcal3.NeighborMap;
+import org.lcsim.hps.recon.ecal.HPSEcalConditions;
 import org.lcsim.util.Driver;
 import org.lcsim.util.aida.AIDA;
 
-public class EcalEvsX extends Driver implements Resettable {
+public class EcalEvsX extends Driver {
 
-	String subdetectorName = "Ecal";
-	String inputCollection = "EcalClusters";
-	AIDA aida = AIDA.defaultInstance();
-	IPlotter plotter;
-	IHistogram2D EvsXPlot;
-	IHistogram1D invMassPlot;
-	IHistogram2D clusterPairEnergyPlot;
-	IHistogram2D clusterPairPositionPlot;
-	Detector detector;
-	int eventn = 0;
-	double targetZ = 0;
-
-	public void setInputCollection(String inputCollection) {
-		this.inputCollection = inputCollection;
-	}
-
-	public void setSubdetectorName(String subdetectorName) {
-		this.subdetectorName = subdetectorName;
-	}
-
-	public void setTargetZ(double targetZ) {
-		this.targetZ = targetZ;
-	}
-
-	protected void detectorChanged(Detector detector) {
-
-		this.detector = detector;
-
-		if (detector.getSubdetector(subdetectorName) == null) {
-			throw new RuntimeException("There is no subdetector called " + subdetectorName + " in this detector");
-		}
-
-		// Setup the plotter.
-		plotter = aida.analysisFactory().createPlotterFactory().create("HPS ECal E vs X Plot");
-		plotter.style().dataStyle().errorBarStyle().setVisible(false);
-
-		// Setup plots.
-		aida.tree().cd("/");
-		EvsXPlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : E vs X", 50, -350.0, 350.0, 200, -100, 2000);
-		invMassPlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Photon Pair Mass", 50, 0.0, 100.0);
-		clusterPairEnergyPlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : Cluster Pair Energies", 1000, -100, 2000, 1000, -100, 2000);
-		clusterPairPositionPlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : Cluster Pair Positions", 50, -350, 350, 50, -350, 350);
+    String inputCollection = "EcalClusters";
+    AIDA aida = AIDA.defaultInstance();
+    IPlotter plotter;
+    IHistogram2D EvsXPlot;
+    IHistogram1D invMassPlot;
+    IHistogram2D clusterPairEnergyPlot;
+    IHistogram2D clusterPairPositionPlot;
+    Detector detector;
+    int eventn = 0;
+    double targetZ = 0;
+
+    public void setInputCollection(String inputCollection) {
+        this.inputCollection = inputCollection;
+    }
+
+    public void setTargetZ(double targetZ) {
+        this.targetZ = targetZ;
+    }
+
+    @Override
+    protected void detectorChanged(Detector detector) {
+
+        this.detector = detector;
+
+        // Setup the plotter.
+        plotter = aida.analysisFactory().createPlotterFactory().create("HPS ECal E vs X Plot");
+        plotter.style().dataStyle().errorBarStyle().setVisible(false);
+
+        // Setup plots.
+        aida.tree().cd("/");
+//        EvsXPlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : E vs X", 50, -350.0, 350.0, 200, -100, 2000);
+        EvsXPlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : E vs X", 50, -350.0, 350.0, 100, 0, 2000);
+        invMassPlot = aida.histogram1D(detector.getDetectorName() + " : " + inputCollection + " : Photon Pair Mass", 100, 0.0, 250.0);
+        clusterPairEnergyPlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : Cluster Pair Energies", 1000, -100, 2000, 1000, -100, 2000);
+        clusterPairPositionPlot = aida.histogram2D(detector.getDetectorName() + " : " + inputCollection + " : Cluster Pair Positions", 50, -350, 350, 50, -350, 350);
 
-		// Create the plotter regions.
-		plotter.createRegions(2, 2);
+        // Create the plotter regions.
+        plotter.createRegions(2, 2);
 //        plotter.style().statisticsBoxStyle().setVisible(false);
-		IPlotterStyle style = plotter.region(0).style();
-		style.setParameter("hist2DStyle", "colorMap");
-		style.statisticsBoxStyle().setVisible(false);
-		style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
-		plotter.region(1).style().yAxisStyle().setParameter("scale", "log");
-		plotter.region(0).plot(EvsXPlot);
-		plotter.region(1).plot(invMassPlot);
-		plotter.region(2).plot(clusterPairEnergyPlot);
-		style = plotter.region(2).style();
-		style.setParameter("hist2DStyle", "colorMap");
-		style.statisticsBoxStyle().setVisible(false);
-		style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
-		style.zAxisStyle().setParameter("scale", "log");
-		plotter.region(3).plot(clusterPairPositionPlot);
-		style = plotter.region(3).style();
-		style.setParameter("hist2DStyle", "colorMap");
-		style.statisticsBoxStyle().setVisible(false);
-		style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
-		style.zAxisStyle().setParameter("scale", "log");
-		plotter.show();
-	}
-
-	public void process(EventHeader event) {
-		if (event.hasCollection(Cluster.class, inputCollection)) {
-			List<Cluster> clusters = event.get(Cluster.class, inputCollection);
-			boolean left = false;
-			boolean right = false;
-			for (Cluster cluster : clusters) {
-				if (cluster.getPosition()[0] > 0) {
-					right = true;
-				}
-				if (cluster.getPosition()[0] < 0) {
-					left = true;
-				}
-			}
-			if (left && right) {
-				for (Cluster cluster : clusters) {
-					EvsXPlot.fill(cluster.getPosition()[0], cluster.getEnergy());
-				}
-			}
-			for (int i = 0; i < clusters.size() - 1; i++) {
-				double e1 = clusters.get(i).getEnergy();
-				double x1 = clusters.get(i).getPosition()[0];
-				for (int j = i + 1; j < clusters.size(); j++) {
-					double e2 = clusters.get(j).getEnergy();
-					double x2 = clusters.get(j).getPosition()[0];
+        IPlotterStyle style = plotter.region(0).style();
+        style.setParameter("hist2DStyle", "colorMap");
+        style.statisticsBoxStyle().setVisible(false);
+        style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+        plotter.region(1).style().yAxisStyle().setParameter("scale", "log");
+        plotter.region(0).plot(EvsXPlot);
+        plotter.region(1).plot(invMassPlot);
+        plotter.region(2).plot(clusterPairEnergyPlot);
+        style = plotter.region(2).style();
+        style.setParameter("hist2DStyle", "colorMap");
+        style.statisticsBoxStyle().setVisible(false);
+        style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+        style.zAxisStyle().setParameter("scale", "log");
+        plotter.region(3).plot(clusterPairPositionPlot);
+        style = plotter.region(3).style();
+        style.setParameter("hist2DStyle", "colorMap");
+        style.statisticsBoxStyle().setVisible(false);
+        style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow");
+        style.zAxisStyle().setParameter("scale", "log");
+        plotter.show();
+    }
+
+    @Override
+    public void process(EventHeader event) {
+//        int orTrig = 0;
+//        int topTrig = 0;
+//        int botTrig = 0;
+//        if (event.hasCollection(TriggerData.class, "TriggerBank")) {
+//            List<TriggerData> triggerList = event.get(TriggerData.class, "TriggerBank");
+//            if (!triggerList.isEmpty()) {
+//                TriggerData triggerData = triggerList.get(0);
+//
+//                orTrig = triggerData.getOrTrig();
+//                topTrig = triggerData.getTopTrig();
+//                botTrig = triggerData.getBotTrig();
+//            }
+//        }
+
+        if (event.hasCollection(Cluster.class, inputCollection)) {
+            List<Cluster> clusters = event.get(Cluster.class, inputCollection);
+            List<Cluster> goodClusters = new ArrayList<Cluster>();
+            for (Cluster cluster : clusters) {
+                if (true || isGoodCluster(cluster)) {
+                    goodClusters.add(cluster);
+                }
+            }
+//            boolean left = false;
+//            boolean right = false;
+//            for (Cluster cluster : goodClusters) {
+//                if (cluster.getPosition()[0] > 0) {
+//                    right = true;
+//                }
+//                if (cluster.getPosition()[0] < 0) {
+//                    left = true;
+//                }
+//            }
+//            if (left && right) {
+//            if (goodClusters.size()>1) {
+//                for (Cluster cluster : goodClusters) {
+            for (Cluster cluster : clusters) {
+                EvsXPlot.fill(cluster.getPosition()[0], cluster.getEnergy());
+            }
+//            }
+//            if (!event.hasCollection(TrackerHit.class, "HelicalTrackHits") || event.get(TrackerHit.class, "HelicalTrackHits").isEmpty()) {
+                for (int i = 0; i < goodClusters.size() - 1; i++) {
+                    Cluster clus1 = goodClusters.get(i);
+                    double e1 = clus1.getEnergy();
+                    double x1 = clus1.getPosition()[0];
+                    if (clus1.getPosition()[1] > 0 && x1 > 0) {
+                        x1 = 350 - x1;
+                    }
+                    for (int j = i + 1; j < goodClusters.size(); j++) {
+                        Cluster clus2 = goodClusters.get(j);
+                        double e2 = clus2.getEnergy();
+                        double x2 = clus2.getPosition()[0];
+                        if (clus2.getPosition()[1] > 0 && x2 > 0) {
+                            x2 = 350 - x2;
+                        }
 //                    if (clusters.get(i).getPosition()[1] * clusters.get(j).getPosition()[1] > 0) {
 //                        continue;
 //                    }
-					clusterPairEnergyPlot.fill(Math.max(e1, e2), Math.min(e1, e2));
-					clusterPairPositionPlot.fill(Math.max(x1, x2), Math.min(x1, x2));
+                        clusterPairEnergyPlot.fill(Math.max(e1, e2), Math.min(e1, e2));
+                        clusterPairPositionPlot.fill(Math.max(x1, x2), Math.min(x1, x2));
 //                    double e1e2 = clusters.get(i).getEnergy() * clusters.get(j).getEnergy();
 //                    double dx2 = Math.pow(clusters.get(i).getPosition()[0] - clusters.get(j).getPosition()[0], 2) + Math.pow(clusters.get(i).getPosition()[1] - clusters.get(j).getPosition()[1], 2);
 //                    invMassPlot.fill(Math.sqrt(e1e2 * dx2 / (135 * 135)));
-					invMassPlot.fill(VecOp.add(clusterAsPhoton(clusters.get(i)), clusterAsPhoton(clusters.get(j))).magnitude());
-				}
-			}
-
-			++eventn;
-		}
-	}
-
-	public HepLorentzVector clusterAsPhoton(Cluster cluster) {
-		Hep3Vector position = new BasicHep3Vector(cluster.getPosition());
-		Hep3Vector direction = VecOp.unit(VecOp.add(position, new BasicHep3Vector(0, 0, targetZ)));
-		return new BasicHepLorentzVector(cluster.getEnergy(), VecOp.mult(cluster.getEnergy(), direction));
-	}
-
-	public void endOfData() {
-		if (plotter != null) {
-			plotter.hide();
-			plotter.destroyRegions();
-		}
-	}
-
-	public void reset() {
-		EvsXPlot.reset();
-	}
+                        invMassPlot.fill(VecOp.add(clusterAsPhoton(clus1), clusterAsPhoton(clus2)).magnitude());
+                    }
+                }
+//            }
+
+            ++eventn;
+        }
+    }
+
+    public HepLorentzVector clusterAsPhoton(Cluster cluster) {
+        Hep3Vector position = new BasicHep3Vector(cluster.getPosition());
+        Hep3Vector direction = VecOp.unit(VecOp.add(position, new BasicHep3Vector(41.27, 0, targetZ)));
+        return new BasicHepLorentzVector(cluster.getEnergy(), VecOp.mult(cluster.getEnergy(), direction));
+    }
+
+    public boolean isGoodCluster(Cluster cluster) {
+        NeighborMap map = ((HPSEcal3) HPSEcalConditions.getSubdetector()).getNeighborMap();
+        for (CalorimeterHit hit : cluster.getCalorimeterHits()) {
+            if (map.get(hit.getCellID()).size() > 6) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public void endOfData() {
+        if (plotter != null) {
+            plotter.hide();
+            plotter.destroyRegions();
+        }
+    }
 }
\ No newline at end of file
CVSspam 0.2.12


Use REPLY-ALL to reply to list

To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1