Print

Print


Commit in java/trunk/users/src/main/java/org/hps/users/kmccarty on MAIN
ClusterAnalysisDriver.java+94added 791
FADCAnalysisDriver.java+92added 791
HPSLcioDriver.java+101added 791
PionEnergyDriver.java+47added 791
+334
4 added files
Added my user directory.

java/trunk/users/src/main/java/org/hps/users/kmccarty
ClusterAnalysisDriver.java added at 791
--- java/trunk/users/src/main/java/org/hps/users/kmccarty/ClusterAnalysisDriver.java	                        (rev 0)
+++ java/trunk/users/src/main/java/org/hps/users/kmccarty/ClusterAnalysisDriver.java	2014-07-18 01:42:58 UTC (rev 791)
@@ -0,0 +1,94 @@
+package org.hps.users.kmccarty;
+
+import java.util.List;
+
+import hep.aida.IHistogram1D;
+import hep.aida.IHistogram2D;
+
+import org.hps.recon.ecal.HPSEcalCluster;
+import org.lcsim.event.EventHeader;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+public class ClusterAnalysisDriver extends Driver {
+	// Analysis plots.
+    AIDA aida = AIDA.defaultInstance();
+	IHistogram1D clusterTotalEnergy;
+	IHistogram1D clusterSeedEnergy;
+	IHistogram1D clusterHitCount;
+	IHistogram2D clusterDistribution;
+	
+	IHistogram1D fClusterTotalEnergy;
+	IHistogram1D fClusterSeedEnergy;
+	IHistogram1D fClusterHitCount;
+	IHistogram2D fClusterDistribution;
+	
+	IHistogram1D nClusterTotalEnergy;
+	IHistogram1D nClusterSeedEnergy;
+	IHistogram1D nClusterHitCount;
+	IHistogram2D nClusterDistribution;
+	
+	// Hit collection names.
+	private String clusterCollectionName = "EcalClusters";
+	
+	public void setClusterCollectionName(String clusterCollectionName) {
+		this.clusterCollectionName = clusterCollectionName;
+	}
+	
+	@Override
+	public void startOfData() {
+		// Initialize the histograms.
+		clusterTotalEnergy = aida.histogram1D("Cluster Plot :: Cluster Total Energy", 110, 0.00, 2.2);
+		clusterSeedEnergy = aida.histogram1D("Cluster Plot :: Seed Hit Energy", 110, 0.00, 2.2);
+		clusterHitCount = aida.histogram1D("Cluster Plot :: Cluster Hit Count", 8, 1, 9);
+		clusterDistribution = aida.histogram2D("Cluster Plot :: Seed Hit Distribution", 46, -23, 23, 11, -5.5, 5.5);
+		
+		// Initialize the filtered histograms.
+		fClusterTotalEnergy = aida.histogram1D("Cluster Plot :: Cluster Total Energy (Over 100 MeV)", 110, 0.00, 2.2);
+		fClusterSeedEnergy = aida.histogram1D("Cluster Plot :: Seed Hit Energy (Over 100 MeV)", 110, 0.00, 2.2);
+		fClusterHitCount = aida.histogram1D("Cluster Plot :: Cluster Hit Count (Over 100 MeV)", 8, 1, 9);
+		fClusterDistribution = aida.histogram2D("Cluster Plot :: Seed Hit Distribution (Over 100 MeV)", 46, -23, 23, 11, -5.5, 5.5);
+		
+		// Initialize the more filtered histograms.
+		nClusterTotalEnergy = aida.histogram1D("Cluster Plot :: Cluster Total Energy (Over 100 MeV, > 1 Hit)", 110, 0.00, 2.2);
+		nClusterSeedEnergy = aida.histogram1D("Cluster Plot :: Seed Hit Energy (Over 100 MeV, > 1 Hit)", 110, 0.00, 2.2);
+		nClusterHitCount = aida.histogram1D("Cluster Plot :: Cluster Hit Count (Over 100 MeV, > 1 Hit)", 8, 1, 9);
+		nClusterDistribution = aida.histogram2D("Cluster Plot :: Seed Hit Distribution (Over 100 MeV, > 1 Hit)", 46, -23, 23, 11, -5.5, 5.5);
+	}
+	
+	public void process(EventHeader event) {
+		// Check if there exists a cluster collection.
+		if(event.hasCollection(HPSEcalCluster.class, clusterCollectionName)) {
+			// Get the raw hit collection.
+			List<HPSEcalCluster> clusterList = event.get(HPSEcalCluster.class, clusterCollectionName);
+			
+			// Output the information on each hit to the histograms.
+			for(HPSEcalCluster cluster : clusterList) {
+				// Get the x and y indices for the hits.
+				int ix = cluster.getSeedHit().getIdentifierFieldValue("ix");
+				int iy = cluster.getSeedHit().getIdentifierFieldValue("iy");
+				if(ix > 0) { ix = ix - 1; }
+				
+				// Write to the histograms.
+				clusterTotalEnergy.fill(cluster.getEnergy());
+				clusterSeedEnergy.fill(cluster.getSeedHit().getCorrectedEnergy());
+				clusterHitCount.fill(cluster.getCalorimeterHits().size());
+				clusterDistribution.fill(ix, iy, 1.0);
+				
+				if(cluster.getSeedHit().getCorrectedEnergy() > 0.100) {
+					fClusterTotalEnergy.fill(cluster.getEnergy());
+					fClusterSeedEnergy.fill(cluster.getSeedHit().getCorrectedEnergy());
+					fClusterHitCount.fill(cluster.getCalorimeterHits().size());
+					fClusterDistribution.fill(ix, iy, 1.0);
+					
+					if(cluster.getCalorimeterHits().size() > 1) {
+						nClusterTotalEnergy.fill(cluster.getEnergy());
+						nClusterSeedEnergy.fill(cluster.getSeedHit().getCorrectedEnergy());
+						nClusterHitCount.fill(cluster.getCalorimeterHits().size());
+						nClusterDistribution.fill(ix, iy, 1.0);
+					}
+				}
+			}
+		}
+	}
+}

java/trunk/users/src/main/java/org/hps/users/kmccarty
FADCAnalysisDriver.java added at 791
--- java/trunk/users/src/main/java/org/hps/users/kmccarty/FADCAnalysisDriver.java	                        (rev 0)
+++ java/trunk/users/src/main/java/org/hps/users/kmccarty/FADCAnalysisDriver.java	2014-07-18 01:42:58 UTC (rev 791)
@@ -0,0 +1,92 @@
+package org.hps.users.kmccarty;
+
+import java.util.List;
+
+import hep.aida.IHistogram1D;
+import hep.aida.IHistogram2D;
+
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.EventHeader;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+public class FADCAnalysisDriver extends Driver {
+	// Analysis plots.
+    AIDA aida = AIDA.defaultInstance();
+	IHistogram1D rawHitEnergy;
+	IHistogram1D fadcHitEnergy;
+	IHistogram2D rawHitDistribution;
+	IHistogram2D fadcHitDistribution;
+	IHistogram2D fadcFilteredHitDistribution;
+	IHistogram1D eventRawHitCount;
+	IHistogram1D eventFADCHitCount;
+	
+	// Hit collection names.
+	private String rawHitsCollectionName = "EcalHits";
+	private String fadcHitsCollectionName = "EcalCorrectedHits";
+	
+	public void setFadcHitsCollectionName(String fadcHitsCollectionName) {
+		this.fadcHitsCollectionName = fadcHitsCollectionName;
+	}
+	
+	public void setRawHitsCollectionName(String rawHitsCollectionName) {
+		this.rawHitsCollectionName = rawHitsCollectionName;
+	}
+	
+	@Override
+	public void startOfData() {
+		// Initialize the histograms.
+		rawHitEnergy = aida.histogram1D("FADC Plot :: Raw Hit Energy", 110, 0.00, 2.2);
+		fadcHitEnergy = aida.histogram1D("FADC Plot :: FADC Hit Energy", 80, 0.00, 1.6);
+		rawHitDistribution = aida.histogram2D("FADC Plot :: Raw Hit Distribution", 46, -23, 23, 11, -5.5, 5.5);
+		fadcHitDistribution = aida.histogram2D("FADC Plot :: FADC Hit Distribution", 46, -23, 23, 11, -5.5, 5.5);
+		fadcFilteredHitDistribution = aida.histogram2D("FADC Plot :: FADC Hit Distribution Over 100 MeV", 46, -23, 23, 11, -5.5, 5.5);
+		eventRawHitCount = aida.histogram1D("FADC Plot :: Event Raw Hit Count", 159, 1, 160);
+		eventFADCHitCount = aida.histogram1D("FADC Plot :: Event FADC Hit Count", 15, 1, 16);
+	}
+	
+	public void process(EventHeader event) {
+		// Check if there exists a raw hits collection.
+		if(event.hasCollection(CalorimeterHit.class, rawHitsCollectionName)) {
+			// Get the raw hit collection.
+			List<CalorimeterHit> hitList = event.get(CalorimeterHit.class, rawHitsCollectionName);
+			
+			// Output the information on each hit to the histograms.
+			for(CalorimeterHit hit : hitList) {
+				// Get the x and y indices for the hits.
+				int ix = hit.getIdentifierFieldValue("ix");
+				int iy = hit.getIdentifierFieldValue("iy");
+				if(ix > 0) { ix = ix - 1; }
+				
+				// Write to the histograms.
+				rawHitEnergy.fill(hit.getCorrectedEnergy());
+				rawHitDistribution.fill(ix, iy, 1.0);
+				
+				// If there are hits, fill the hit count histogram.
+				if(hitList.size() != 0) { eventRawHitCount.fill(hitList.size()); }
+			}
+		}
+		
+		// Check if there exists an FADC hits collection.
+		if(event.hasCollection(CalorimeterHit.class, fadcHitsCollectionName)) {
+			// Get the raw hit collection.
+			List<CalorimeterHit> hitList = event.get(CalorimeterHit.class, fadcHitsCollectionName);
+			
+			// Output the information on each hit to the histograms.
+			for(CalorimeterHit hit : hitList) {
+				// Get the x and y indices for the hits.
+				int ix = hit.getIdentifierFieldValue("ix");
+				int iy = hit.getIdentifierFieldValue("iy");
+				if(ix > 0) { ix = ix - 1; }
+				
+				// Write to the histograms.
+				fadcHitEnergy.fill(hit.getCorrectedEnergy());
+				fadcHitDistribution.fill(ix, iy, 1.0);
+				if(hit.getCorrectedEnergy() > 0.100) { fadcFilteredHitDistribution.fill(ix, iy, 1.0); }
+				
+				// If there are hits, fill the hit count histogram.
+				if(hitList.size() != 0) { eventFADCHitCount.fill(hitList.size()); }
+			}
+		}
+	}
+}

java/trunk/users/src/main/java/org/hps/users/kmccarty
HPSLcioDriver.java added at 791
--- java/trunk/users/src/main/java/org/hps/users/kmccarty/HPSLcioDriver.java	                        (rev 0)
+++ java/trunk/users/src/main/java/org/hps/users/kmccarty/HPSLcioDriver.java	2014-07-18 01:42:58 UTC (rev 791)
@@ -0,0 +1,101 @@
+package org.hps.users.kmccarty;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.Set;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.lcio.LCIOWriter;
+import org.lcsim.util.Driver;
+
+/**
+ * Class <code>HPSLcioDriver</code> outputs LCSim runs to a file. It is
+ * able to reference HPS classes, and as such, allows data to be output
+ * as the original data type.
+ * @author Kyle McCarty
+ */
+public class HPSLcioDriver extends Driver {
+	// The path to the output file.
+	private String outputFilePath = "default.slcio";
+	// Whether empty events should be written.
+	private boolean writeEmptyEvents = false;
+	// The output file writer.
+	LCIOWriter writer = null;
+	
+	public void startOfData() {
+		// Initialize the output writer.
+		try {
+			File out = new File(outputFilePath);
+			writer = new LCIOWriter(out);
+		}
+		catch(IOException e) {
+			e.printStackTrace();
+			System.exit(1);
+		}
+		
+		// If the output writer is still null, then something went
+		// wrong. Terminate the process.
+		if(writer == null) {
+			System.err.println("Error :: LCIO writer improperly initialized.");
+			System.exit(1);
+		}
+	}
+	
+	@SuppressWarnings("rawtypes")
+	public void process(EventHeader event) {
+		// If empty events should be written, then the event can be
+		// output immediately without further investigation.
+		if(writeEmptyEvents) {
+			try { writer.write(event); }
+			catch(IOException e) {
+				System.err.println("Error :: Event can not be written.");
+			}
+		}
+		
+		// Otherwise, check to make sure that something exists in the
+		// event to output.
+		else {
+			// Get the lists present in the event.
+			Set<List> eventLists = event.getLists();
+			
+			// Track whether a list exists that is not empty.
+			boolean hasData = false;
+			
+			// Iterate through the lists.
+			dataLoop:
+			for(List list : eventLists) {
+				// If a list is not empty, than there is data and this
+				// event is qualified to be written.
+				if(list.size() != 0) {
+					hasData = true;
+					break dataLoop;
+				}
+			}
+			
+			// If the event has data, write it. Otherwise, do nothing.
+			if(hasData) {
+				try { writer.write(event); }
+				catch(IOException e) {
+					System.err.println("Error :: Event can not be written.");
+				}
+			}
+		}
+	}
+	
+	public void endOfData() {
+		// Close the writer.
+		try { writer.close(); }
+		catch(IOException e) {
+			System.err.println("Error closing writer.");
+		}
+	}
+	
+	public void setOutputFilePath(String outputFilePath) {
+		this.outputFilePath = outputFilePath;
+	}
+	
+	public void setWriteEmptyEvents(boolean writeEmptyEvents) {
+		this.writeEmptyEvents = writeEmptyEvents;
+	}
+}

java/trunk/users/src/main/java/org/hps/users/kmccarty
PionEnergyDriver.java added at 791
--- java/trunk/users/src/main/java/org/hps/users/kmccarty/PionEnergyDriver.java	                        (rev 0)
+++ java/trunk/users/src/main/java/org/hps/users/kmccarty/PionEnergyDriver.java	2014-07-18 01:42:58 UTC (rev 791)
@@ -0,0 +1,47 @@
+package org.hps.users.kmccarty;
+
+import java.util.List;
+
+import hep.aida.IHistogram1D;
+
+import org.lcsim.event.EventHeader;
+import org.lcsim.event.MCParticle;
+import org.lcsim.util.Driver;
+import org.lcsim.util.aida.AIDA;
+
+public class PionEnergyDriver extends Driver {
+	// Analysis plots.
+    AIDA aida = AIDA.defaultInstance();
+	IHistogram1D pionEnergy;
+	
+	// Collection names.
+	private String particleCollectionName = "MCParticles";
+	
+	public void setParticleCollectionName(String particleCollectionName) {
+		this.particleCollectionName = particleCollectionName;
+	}
+	
+	public void process(EventHeader event) {
+		// Check if there exists a Monte Carlo particle collection.
+		if(event.hasCollection(MCParticle.class, particleCollectionName)) {
+			// Get the Monte Carlo particles.
+			List<MCParticle> particleList = event.get(MCParticle.class, particleCollectionName);
+			
+			// Iterate over the particles and combine the t = 0 particle
+			// energies together to calculate the parent particle energy.
+			double parentEnergy = 0.0;
+			for(MCParticle particle : particleList) {
+				if(particle.getProductionTime() == 0.0) {
+					parentEnergy += particle.getEnergy();
+				}
+			}
+			
+			// Add the parent energy to the histogram.
+			pionEnergy.fill(parentEnergy);
+		}
+	}
+	
+	public void startOfData() {
+		pionEnergy = aida.histogram1D("Pion Analysis :: Pion Energy Distribution", 110, 0.0, 2.2);
+	}
+}
SVNspam 0.1