6 modified files
hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -u -r1.2 -r1.3
--- HPSFADCTriggerDriver.java 22 Nov 2011 01:12:41 -0000 1.2
+++ HPSFADCTriggerDriver.java 9 Jan 2012 22:39:07 -0000 1.3
@@ -15,7 +15,7 @@
*
* @author Omar Moreno <[log in to unmask]>
* @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSFADCTriggerDriver.java,v 1.2 2011/11/22 01:12:41 meeg Exp $
+ * @version $Id: HPSFADCTriggerDriver.java,v 1.3 2012/01/09 22:39:07 meeg Exp $
*/
public class HPSFADCTriggerDriver extends HPSTriggerDriver {
@@ -43,6 +43,7 @@
clusterPairs = new LinkedList<HPSEcalCluster[]>();
}
+ @Override
public void startOfData() {
if (clusterCollectionName == null) {
throw new RuntimeException("The parameter ecalCollectionName was not set!");
@@ -163,6 +164,7 @@
return trigger;
}
+ @Override
public void endOfData() {
if (outputStream != null) {
outputStream.printf("Number of cluster pairs after successive trigger conditions:\n");
@@ -185,6 +187,7 @@
System.out.printf("Coplanarity: %d\n", coplanarityCount);
System.out.printf("Final count of passing cluster pairs: %d\n", nonuniqueTriggerCount);
System.out.printf("Trigger count: %d\n", numTriggers);
+ super.endOfData();
}
/**
@@ -229,11 +232,12 @@
int quad2 = getECalQuadrant(clusterPair[1]);
//if clusters are in the same quadrant, they're not opposite quadrants
- if (quad1 == quad2)
+ if (quad1 == quad2) {
return false;
- //opposite pairs of quadrants are either both even (2 and 4) or both off (1 and 3)
- else
+ } //opposite pairs of quadrants are either both even (2 and 4) or both off (1 and 3)
+ else {
return ((quad1 & 1) == (quad2 & 1));
+ }
}
/**
@@ -314,10 +318,11 @@
HPSEcalCluster lowEnergyCluster;
// Obtain the lowest energy cluster
- if (clusterPair[0].getEnergy() < clusterPair[1].getEnergy())
+ if (clusterPair[0].getEnergy() < clusterPair[1].getEnergy()) {
lowEnergyCluster = clusterPair[0];
- else
+ } else {
lowEnergyCluster = clusterPair[1];
+ }
double lowEClusterPosition[] = hitPosition(lowEnergyCluster.getSeedHit());
// Calculate its position
@@ -326,8 +331,9 @@
double clusterDistvsE = lowEnergyCluster.getEnergy() + lowEClusterDistance * (0.0032);
- if (clusterDistvsE > .8 /* GeV */)
+ if (clusterDistvsE > .8 /* GeV */) {
return true;
+ }
return false;
}
hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -u -r1.3 -r1.4
--- HPSTriggerDriver.java 17 Nov 2011 01:43:26 -0000 1.3
+++ HPSTriggerDriver.java 9 Jan 2012 22:39:08 -0000 1.4
@@ -16,84 +16,96 @@
* Prints triggers to file if file path specified.
*
* @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSTriggerDriver.java,v 1.3 2011/11/17 01:43:26 meeg Exp $
+ * @version $Id: HPSTriggerDriver.java,v 1.4 2012/01/09 22:39:08 meeg Exp $
*/
public abstract class HPSTriggerDriver extends Driver {
- Subdetector ecal;
- String ecalName;
- String clusterCollectionName;
- IDDecoder dec = null;
- String outputFileName;
- PrintWriter outputStream = null;
- int numTriggers;
-
- public HPSTriggerDriver() {
- }
-
- public void setClusterCollectionName(String clusterCollectionName) {
- this.clusterCollectionName = clusterCollectionName;
- }
-
- public void setEcalName(String ecalName) {
- this.ecalName = ecalName;
- }
-
- public void setOutputFileName(String outputFileName) {
- this.outputFileName = outputFileName;
- }
-
- public void startOfData() {
- if (clusterCollectionName == null) {
- throw new RuntimeException("The parameter ecalCollectionName was not set!");
- }
-
- if (ecalName == null) {
- throw new RuntimeException("The parameter ecalName was not set!");
- }
-
- if (outputFileName != null) {
- try {
- outputStream = new PrintWriter(outputFileName);
- } catch (IOException ex) {
- throw new RuntimeException("Invalid outputFilePath!");
- }
- }
-
- numTriggers = 0;
- }
-
- public void detectorChanged(Detector detector) {
- // Get the Subdetector.
- ecal = detector.getSubdetector(ecalName);
-
- // Cache ref to decoder.
- dec = ecal.getIDDecoder();
- }
-
- public void process(EventHeader event) {
- //System.out.println(this.getClass().getCanonicalName() + " - process");
-
- // Get the list of raw ECal hits.
- List<HPSEcalCluster> clusters = event.get(HPSEcalCluster.class, clusterCollectionName);
- if (clusters == null)
- throw new RuntimeException("Event is missing ECal clusters collection!");
-
- if (testTrigger(clusters)) {
- numTriggers++;
- if (outputStream != null)
- outputStream.printf("Trigger on event %d\n", event.getEventNumber());
- ClockSingleton.setTrigger();
- }
- }
+ Subdetector ecal;
+ String ecalName;
+ String clusterCollectionName;
+ IDDecoder dec = null;
+ String outputFileName;
+ PrintWriter outputStream = null;
+ int numTriggers;
+
+ public HPSTriggerDriver() {
+ }
+
+ public void setClusterCollectionName(String clusterCollectionName) {
+ this.clusterCollectionName = clusterCollectionName;
+ }
+
+ public void setEcalName(String ecalName) {
+ this.ecalName = ecalName;
+ }
+
+ public void setOutputFileName(String outputFileName) {
+ this.outputFileName = outputFileName;
+ }
+
+ @Override
+ public void startOfData() {
+ if (clusterCollectionName == null) {
+ throw new RuntimeException("The parameter ecalCollectionName was not set!");
+ }
+
+ if (ecalName == null) {
+ throw new RuntimeException("The parameter ecalName was not set!");
+ }
+
+ if (outputFileName != null) {
+ try {
+ outputStream = new PrintWriter(outputFileName);
+ } catch (IOException ex) {
+ throw new RuntimeException("Invalid outputFilePath!");
+ }
+ }
+
+ numTriggers = 0;
+ }
+
+ @Override
+ public void detectorChanged(Detector detector) {
+ // Get the Subdetector.
+ ecal = detector.getSubdetector(ecalName);
+
+ // Cache ref to decoder.
+ dec = ecal.getIDDecoder();
+ }
+
+ @Override
+ public void process(EventHeader event) {
+ //System.out.println(this.getClass().getCanonicalName() + " - process");
+
+ // Get the list of raw ECal hits.
+ List<HPSEcalCluster> clusters = event.get(HPSEcalCluster.class, clusterCollectionName);
+ if (clusters == null) {
+ throw new RuntimeException("Event is missing ECal clusters collection!");
+ }
+
+ if (testTrigger(clusters)) {
+ ClockSingleton.setTrigger();
+ if (ClockSingleton.triggered()) {
+ numTriggers++;
+ if (outputStream != null) {
+ outputStream.printf("Trigger on event %d\n", event.getEventNumber());
+ }
+ } else {
+ if (outputStream != null) {
+ outputStream.printf("Event %d rejected by dead time\n", event.getEventNumber());
+ }
+ }
+ }
+ }
public abstract boolean testTrigger(List<HPSEcalCluster> clusters);
- public void endOfData() {
- if (outputStream != null) {
- outputStream.printf("Trigger count: %d\n", numTriggers);
- outputStream.close();
- }
- System.out.printf("Trigger count: %d\n", numTriggers);
- }
+ @Override
+ public void endOfData() {
+ if (outputStream != null) {
+ outputStream.printf("Trigger count: %d\n", numTriggers);
+ outputStream.close();
+ }
+ System.out.printf("Trigger count: %d\n", numTriggers);
+ }
}
\ No newline at end of file
hps-java/src/main/java/org/lcsim/hps/analysis/ecal
diff -u -r1.3 -r1.4
--- HPSEcalTriggerPlotsDriver.java 9 Dec 2011 23:40:21 -0000 1.3
+++ HPSEcalTriggerPlotsDriver.java 9 Jan 2012 22:39:08 -0000 1.4
@@ -19,101 +19,106 @@
* Diagnostic plots for HPS ECal.
*
* @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSEcalTriggerPlotsDriver.java,v 1.3 2011/12/09 23:40:21 meeg Exp $
+ * @version $Id: HPSEcalTriggerPlotsDriver.java,v 1.4 2012/01/09 22:39:08 meeg Exp $
*/
public class HPSEcalTriggerPlotsDriver extends Driver {
- String ecalCollectionName = "EcalHits";
- String clusterCollectionName = "EcalClusters";
- AIDA aida = AIDA.defaultInstance();
- IHistogram2D hitXYPlot;
- IHistogram2D clusterHitXYPlot;
- IHistogram2D seedHitXYPlot;
- IHistogram2D triggerClusterHitXYPlot;
- IHistogram2D triggerSeedHitXYPlot;
- IDDecoder dec = null;
-
- public void setEcalCollectionName(String ecalCollectionName) {
- this.ecalCollectionName = ecalCollectionName;
- }
-
- public void setClusterCollectionName(String clusterCollectionName) {
- this.clusterCollectionName = clusterCollectionName;
- }
-
- public void startOfData() {
- hitXYPlot = aida.histogram2D(
- "Trigger plots: " + ecalCollectionName + " : Hits",
- 47, -23.5, 23.5, 11, -5.5, 5.5);
- clusterHitXYPlot = aida.histogram2D(
- "Trigger plots: " + clusterCollectionName + " : Crystals in clusters",
- 47, -23.5, 23.5, 11, -5.5, 5.5);
- seedHitXYPlot = aida.histogram2D(
- "Trigger plots: " + clusterCollectionName + " : Seed hits",
- 47, -23.5, 23.5, 11, -5.5, 5.5);
- triggerClusterHitXYPlot = aida.histogram2D(
- "Trigger plots: " + clusterCollectionName + " : Crystals in clusters, with trigger",
- 47, -23.5, 23.5, 11, -5.5, 5.5);
- triggerSeedHitXYPlot = aida.histogram2D(
- "Trigger plots: " + clusterCollectionName + " : Seed hits, with trigger",
- 47, -23.5, 23.5, 11, -5.5, 5.5);
- }
-
- public void process(EventHeader event) {
- List<HPSEcalCluster> clusters = event.get(HPSEcalCluster.class, clusterCollectionName);
- if (clusters == null)
- throw new RuntimeException("Missing cluster collection!");
-
- List<CalorimeterHit> hits = event.get(CalorimeterHit.class, ecalCollectionName);
- if (hits == null)
- throw new RuntimeException("Missing hit collection!");
-
- // Get ID helper.
- IIdentifierHelper helper =
- event.getMetaData(hits).getIDDecoder().getSubdetector().getDetectorElement().getIdentifierHelper();
-
- for (CalorimeterHit hit : hits) {
- IIdentifier id = hit.getIdentifier();
- int ix = helper.unpack(id).getValue(helper.getFieldIndex("ix"));
- int iy = helper.unpack(id).getValue(helper.getFieldIndex("iy"));
- hitXYPlot.fill(ix, iy);
- }
-
- for (HPSEcalCluster clus : clusters) {
- HPSRawCalorimeterHit seedHit = (HPSRawCalorimeterHit) clus.getSeedHit();
- IIdentifier id = seedHit.getIdentifier();
- int ix = helper.unpack(id).getValue(helper.getFieldIndex("ix"));
- int iy = helper.unpack(id).getValue(helper.getFieldIndex("iy"));
+ String ecalCollectionName = "EcalHits";
+ String clusterCollectionName = "EcalClusters";
+ AIDA aida = AIDA.defaultInstance();
+ IHistogram2D hitXYPlot;
+ IHistogram2D clusterHitXYPlot;
+ IHistogram2D seedHitXYPlot;
+ IHistogram2D triggerClusterHitXYPlot;
+ IHistogram2D triggerSeedHitXYPlot;
+ IDDecoder dec = null;
+
+ public void setEcalCollectionName(String ecalCollectionName) {
+ this.ecalCollectionName = ecalCollectionName;
+ }
+
+ public void setClusterCollectionName(String clusterCollectionName) {
+ this.clusterCollectionName = clusterCollectionName;
+ }
+
+ @Override
+ public void startOfData() {
+ hitXYPlot = aida.histogram2D(
+ "Trigger plots: " + ecalCollectionName + " : Hits",
+ 47, -23.5, 23.5, 11, -5.5, 5.5);
+ clusterHitXYPlot = aida.histogram2D(
+ "Trigger plots: " + clusterCollectionName + " : Crystals in clusters",
+ 47, -23.5, 23.5, 11, -5.5, 5.5);
+ seedHitXYPlot = aida.histogram2D(
+ "Trigger plots: " + clusterCollectionName + " : Seed hits",
+ 47, -23.5, 23.5, 11, -5.5, 5.5);
+ triggerClusterHitXYPlot = aida.histogram2D(
+ "Trigger plots: " + clusterCollectionName + " : Crystals in clusters, with trigger",
+ 47, -23.5, 23.5, 11, -5.5, 5.5);
+ triggerSeedHitXYPlot = aida.histogram2D(
+ "Trigger plots: " + clusterCollectionName + " : Seed hits, with trigger",
+ 47, -23.5, 23.5, 11, -5.5, 5.5);
+ }
+
+ @Override
+ public void process(EventHeader event) {
+ List<HPSEcalCluster> clusters = event.get(HPSEcalCluster.class, clusterCollectionName);
+ if (clusters == null) {
+ throw new RuntimeException("Missing cluster collection!");
+ }
+
+ List<CalorimeterHit> hits = event.get(CalorimeterHit.class, ecalCollectionName);
+ if (hits == null) {
+ throw new RuntimeException("Missing hit collection!");
+ }
+
+ // Get ID helper.
+ IIdentifierHelper helper =
+ event.getMetaData(hits).getIDDecoder().getSubdetector().getDetectorElement().getIdentifierHelper();
+
+ for (CalorimeterHit hit : hits) {
+ IIdentifier id = hit.getIdentifier();
+ int ix = helper.unpack(id).getValue(helper.getFieldIndex("ix"));
+ int iy = helper.unpack(id).getValue(helper.getFieldIndex("iy"));
+ hitXYPlot.fill(ix, iy);
+ }
+
+ for (HPSEcalCluster clus : clusters) {
+ HPSRawCalorimeterHit seedHit = (HPSRawCalorimeterHit) clus.getSeedHit();
+ IIdentifier id = seedHit.getIdentifier();
+ int ix = helper.unpack(id).getValue(helper.getFieldIndex("ix"));
+ int iy = helper.unpack(id).getValue(helper.getFieldIndex("iy"));
// dec = seedHit.getIDDecoder();
// dec.setID(seedHit.getCellID());
- seedHitXYPlot.fill(ix, iy);
- for (CalorimeterHit hit : clus.getCalorimeterHits()) {
- id = hit.getIdentifier();
- ix = helper.unpack(id).getValue(helper.getFieldIndex("ix"));
- iy = helper.unpack(id).getValue(helper.getFieldIndex("iy"));
+ seedHitXYPlot.fill(ix, iy);
+ for (CalorimeterHit hit : clus.getCalorimeterHits()) {
+ id = hit.getIdentifier();
+ ix = helper.unpack(id).getValue(helper.getFieldIndex("ix"));
+ iy = helper.unpack(id).getValue(helper.getFieldIndex("iy"));
// dec = hit.getIDDecoder();
// dec.setID(hit.getCellID());
- clusterHitXYPlot.fill(ix, iy);
- }
- }
-
- if (ClockSingleton.triggered())
- for (HPSEcalCluster clus : clusters) {
- HPSRawCalorimeterHit seedHit = (HPSRawCalorimeterHit) clus.getSeedHit();
- IIdentifier id = seedHit.getIdentifier();
- int ix = helper.unpack(id).getValue(helper.getFieldIndex("ix"));
- int iy = helper.unpack(id).getValue(helper.getFieldIndex("iy"));
+ clusterHitXYPlot.fill(ix, iy);
+ }
+ }
+
+ if (ClockSingleton.triggered()) {
+ for (HPSEcalCluster clus : clusters) {
+ HPSRawCalorimeterHit seedHit = (HPSRawCalorimeterHit) clus.getSeedHit();
+ IIdentifier id = seedHit.getIdentifier();
+ int ix = helper.unpack(id).getValue(helper.getFieldIndex("ix"));
+ int iy = helper.unpack(id).getValue(helper.getFieldIndex("iy"));
// dec = seedHit.getIDDecoder();
// dec.setID(seedHit.getCellID());
- triggerSeedHitXYPlot.fill(ix, iy);
- for (CalorimeterHit hit : clus.getCalorimeterHits()) {
- id = hit.getIdentifier();
- ix = helper.unpack(id).getValue(helper.getFieldIndex("ix"));
- iy = helper.unpack(id).getValue(helper.getFieldIndex("iy"));
+ triggerSeedHitXYPlot.fill(ix, iy);
+ for (CalorimeterHit hit : clus.getCalorimeterHits()) {
+ id = hit.getIdentifier();
+ ix = helper.unpack(id).getValue(helper.getFieldIndex("ix"));
+ iy = helper.unpack(id).getValue(helper.getFieldIndex("iy"));
// dec = hit.getIDDecoder();
// dec.setID(hit.getCellID());
- triggerClusterHitXYPlot.fill(ix, iy);
- }
- }
- }
+ triggerClusterHitXYPlot.fill(ix, iy);
+ }
+ }
+ }
+ }
}
hps-java/src/main/java/org/lcsim/hps/analysis/ecal
diff -u -r1.1 -r1.2
--- HPSMCParticlePlotsDriver.java 9 Dec 2011 23:40:21 -0000 1.1
+++ HPSMCParticlePlotsDriver.java 9 Jan 2012 22:39:08 -0000 1.2
@@ -3,7 +3,6 @@
import hep.aida.ICloud1D;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -17,150 +16,153 @@
* Diagnostic plots for HPS ECal.
*
* @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: HPSMCParticlePlotsDriver.java,v 1.1 2011/12/09 23:40:21 meeg Exp $
+ * @version $Id: HPSMCParticlePlotsDriver.java,v 1.2 2012/01/09 22:39:08 meeg Exp $
*/
public class HPSMCParticlePlotsDriver extends Driver {
- AIDA aida = AIDA.defaultInstance();
- // MCParticle plots.
- ICloud1D primaryEPlot;
- ICloud1D fsCountPlot;
- ICloud1D fsEPlot;
- ICloud1D fsGammaEPlot;
- ICloud1D fsElectronEPlot;
- ICloud1D fsPositronEPlot;
- ICloud1D fsGammaThetaPlot;
- ICloud1D fsElectronThetaPlot;
- ICloud1D fsPositronThetaPlot;
- ICloud1D eventEPlot;
-
- class MCParticleEComparator implements Comparator<MCParticle> {
-
- public int compare(MCParticle p1, MCParticle p2) {
- double e1 = p1.getEnergy();
- double e2 = p2.getEnergy();
- if (e1 < e2) {
- return -1;
- } else if (e1 == e2) {
- return 0;
- } else {
- return 1;
- }
- }
- }
-
-
- public void startOfData() {
- fsCountPlot = aida.cloud1D("MCParticle: Number of Final State Particles");
- fsCountPlot.annotation().addItem("xAxisLabel", "Number of FS Particles");
-
- fsEPlot = aida.cloud1D("MCParticle: FS Particle E");
- fsEPlot.annotation().addItem("xAxisLabel", "Particle E [GeV]");
-
- fsGammaEPlot = aida.cloud1D("MCParticle: FS Gamma E");
- fsGammaEPlot.annotation().addItem("xAxisLabel", "Particle E [GeV]");
-
- fsElectronEPlot = aida.cloud1D("MCParticle: FS Electron E");
- fsElectronEPlot.annotation().addItem("xAxisLabel", "Particle E [GeV]");
-
- fsPositronEPlot = aida.cloud1D("MCParticle: FS Positron E");
- fsPositronEPlot.annotation().addItem("xAxisLabel", "Particle E [GeV]");
-
- fsGammaThetaPlot = aida.cloud1D("MCParticle: FS Gamma Theta");
- fsGammaThetaPlot.annotation().addItem("xAxisLabel", "Particle angle [degrees]");
-
- fsElectronThetaPlot = aida.cloud1D("MCParticle: FS Electron Theta");
- fsElectronThetaPlot.annotation().addItem("xAxisLabel", "Particle angle [degrees]");
-
- fsPositronThetaPlot = aida.cloud1D("MCParticle: FS Positron Theta");
- fsPositronThetaPlot.annotation().addItem("xAxisLabel", "Particle angle [degrees]");
-
- primaryEPlot = aida.cloud1D("MCParticle: Highest Primary E in Event");
- primaryEPlot.annotation().addItem("xAxisLabel", "E [GeV]");
-
- eventEPlot = aida.cloud1D("MCParticle: Total Gen FS Electron E in Event");
- eventEPlot.annotation().addItem("xAxisLabel", "E [GeV]");
-
- }
-
- public void process(EventHeader event) {
-
- // MCParticles
- List<MCParticle> mcparticles = event.get(MCParticle.class).get(0);
-
- // Final State particles.
- List<MCParticle> fsParticles = makeGenFSParticleList(mcparticles);
-
- //System.out.println("fsParticles="+fsParticles.size());
- fsCountPlot.fill(fsParticles.size());
-
- for (MCParticle fs : fsParticles) {
- double fsE = fs.getEnergy();
- double theta = Math.atan2(Math.sqrt(fs.getPX()*fs.getPX()+fs.getPY()*fs.getPY()),fs.getPZ());
- int fsPdg = fs.getPDGID();
- fsEPlot.fill(fsE);
- if (ParticleTypeClassifier.isElectron(fsPdg)) {
- fsElectronEPlot.fill(fsE);
+
+ AIDA aida = AIDA.defaultInstance();
+ // MCParticle plots.
+ ICloud1D primaryEPlot;
+ ICloud1D fsCountPlot;
+ ICloud1D fsEPlot;
+ ICloud1D fsGammaEPlot;
+ ICloud1D fsElectronEPlot;
+ ICloud1D fsPositronEPlot;
+ ICloud1D fsGammaThetaPlot;
+ ICloud1D fsElectronThetaPlot;
+ ICloud1D fsPositronThetaPlot;
+ ICloud1D eventEPlot;
+
+ class MCParticleEComparator implements Comparator<MCParticle> {
+
+ public int compare(MCParticle p1, MCParticle p2) {
+ double e1 = p1.getEnergy();
+ double e2 = p2.getEnergy();
+ if (e1 < e2) {
+ return -1;
+ } else if (e1 == e2) {
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+ }
+
+ @Override
+ public void startOfData() {
+ fsCountPlot = aida.cloud1D("MCParticle: Number of Final State Particles");
+ fsCountPlot.annotation().addItem("xAxisLabel", "Number of FS Particles");
+
+ fsEPlot = aida.cloud1D("MCParticle: FS Particle E");
+ fsEPlot.annotation().addItem("xAxisLabel", "Particle E [GeV]");
+
+ fsGammaEPlot = aida.cloud1D("MCParticle: FS Gamma E");
+ fsGammaEPlot.annotation().addItem("xAxisLabel", "Particle E [GeV]");
+
+ fsElectronEPlot = aida.cloud1D("MCParticle: FS Electron E");
+ fsElectronEPlot.annotation().addItem("xAxisLabel", "Particle E [GeV]");
+
+ fsPositronEPlot = aida.cloud1D("MCParticle: FS Positron E");
+ fsPositronEPlot.annotation().addItem("xAxisLabel", "Particle E [GeV]");
+
+ fsGammaThetaPlot = aida.cloud1D("MCParticle: FS Gamma Theta");
+ fsGammaThetaPlot.annotation().addItem("xAxisLabel", "Particle angle [degrees]");
+
+ fsElectronThetaPlot = aida.cloud1D("MCParticle: FS Electron Theta");
+ fsElectronThetaPlot.annotation().addItem("xAxisLabel", "Particle angle [degrees]");
+
+ fsPositronThetaPlot = aida.cloud1D("MCParticle: FS Positron Theta");
+ fsPositronThetaPlot.annotation().addItem("xAxisLabel", "Particle angle [degrees]");
+
+ primaryEPlot = aida.cloud1D("MCParticle: Highest Primary E in Event");
+ primaryEPlot.annotation().addItem("xAxisLabel", "E [GeV]");
+
+ eventEPlot = aida.cloud1D("MCParticle: Total Gen FS Electron E in Event");
+ eventEPlot.annotation().addItem("xAxisLabel", "E [GeV]");
+
+ }
+
+ @Override
+ public void process(EventHeader event) {
+
+ // MCParticles
+ List<MCParticle> mcparticles = event.get(MCParticle.class).get(0);
+
+ // Final State particles.
+ List<MCParticle> fsParticles = makeGenFSParticleList(mcparticles);
+
+ //System.out.println("fsParticles="+fsParticles.size());
+ fsCountPlot.fill(fsParticles.size());
+
+ for (MCParticle fs : fsParticles) {
+ double fsE = fs.getEnergy();
+ double theta = Math.atan2(Math.sqrt(fs.getPX() * fs.getPX() + fs.getPY() * fs.getPY()), fs.getPZ());
+ int fsPdg = fs.getPDGID();
+ fsEPlot.fill(fsE);
+ if (ParticleTypeClassifier.isElectron(fsPdg)) {
+ fsElectronEPlot.fill(fsE);
fsElectronThetaPlot.fill(Math.toDegrees(theta));
- } else if (ParticleTypeClassifier.isPositron(fsPdg)) {
- fsPositronEPlot.fill(fsE);
+ } else if (ParticleTypeClassifier.isPositron(fsPdg)) {
+ fsPositronEPlot.fill(fsE);
fsPositronThetaPlot.fill(Math.toDegrees(theta));
- } else if (ParticleTypeClassifier.isPhoton(fsPdg)) {
- fsGammaEPlot.fill(fsE);
+ } else if (ParticleTypeClassifier.isPhoton(fsPdg)) {
+ fsGammaEPlot.fill(fsE);
fsGammaThetaPlot.fill(Math.toDegrees(theta));
- }
- }
+ }
+ }
- // Sort MCParticles on energy.
- Collections.sort(fsParticles, new MCParticleEComparator());
+ // Sort MCParticles on energy.
+ //Collections.sort(fsParticles, new MCParticleEComparator());
- // Energy of top two FS particles.
- //double e2 = fsParticles.get(0).getEnergy() + fsParticles.get(1).getEnergy();
+ // Energy of top two FS particles.
+ //double e2 = fsParticles.get(0).getEnergy() + fsParticles.get(1).getEnergy();
- // Energy of top three FS particles.
- //double e3 = e2 + fsParticles.get(2).getEnergy();
-
- // primary particle with most E
- MCParticle primary = getPrimary(mcparticles);
- double primaryE = primary.getEnergy();
- primaryEPlot.fill(primaryE);
-
- // event energy
- double eventE = getPrimaryE(mcparticles);
- eventEPlot.fill(eventE);
-
- }
-
- private double getPrimaryE(List<MCParticle> particles) {
- double electronE = 0;
- for (MCParticle particle : particles) {
- if (particle.getGeneratorStatus() == MCParticle.FINAL_STATE
- && Math.abs(particle.getPDGID()) == 11) {
- electronE += particle.getEnergy();
- }
- }
- return electronE;
- }
-
- private MCParticle getPrimary(List<MCParticle> particles) {
- double maxE = 0;
- MCParticle primary = null;
- for (MCParticle particle : particles) {
- if (particle.getGeneratorStatus() == MCParticle.FINAL_STATE
- && particle.getEnergy() > maxE) {
- maxE = particle.getEnergy();
- primary = particle;
- }
- }
- return primary;
- }
-
- private static List<MCParticle> makeGenFSParticleList(List<MCParticle> mcparticles) {
- List<MCParticle> fsParticles = new ArrayList<MCParticle>();
- for (MCParticle mcparticle : mcparticles) {
- if (mcparticle.getGeneratorStatus() == MCParticle.FINAL_STATE) {
- fsParticles.add(mcparticle);
- }
- }
- return fsParticles;
- }
+ // Energy of top three FS particles.
+ //double e3 = e2 + fsParticles.get(2).getEnergy();
+
+ if (!fsParticles.isEmpty()) {
+ // primary particle with most E
+ double primaryE = getPrimary(fsParticles).getEnergy();
+ primaryEPlot.fill(primaryE);
+ }
+
+ // event energy
+ double eventE = getPrimaryE(fsParticles);
+ eventEPlot.fill(eventE);
+ }
+
+ private double getPrimaryE(List<MCParticle> particles) {
+ double totalE = 0;
+ for (MCParticle particle : particles) {
+ if (Math.abs(particle.getPDGID()) == 11) {
+ totalE += particle.getEnergy();
+ }
+ }
+ return totalE;
+ }
+
+ private MCParticle getPrimary(List<MCParticle> particles) {
+ double maxE = 0;
+ MCParticle primary = null;
+ for (MCParticle particle : particles) {
+ if (particle.getEnergy() > maxE) {
+ maxE = particle.getEnergy();
+ primary = particle;
+ }
+ }
+ return primary;
+ }
+
+ private static List<MCParticle> makeGenFSParticleList(List<MCParticle> mcparticles) {
+ List<MCParticle> fsParticles = new ArrayList<MCParticle>();
+ for (MCParticle mcparticle : mcparticles) {
+ if (mcparticle.getGeneratorStatus() == MCParticle.FINAL_STATE) {
+ double theta = Math.atan2(Math.sqrt(mcparticle.getPX() * mcparticle.getPX() + mcparticle.getPY() * mcparticle.getPY()), mcparticle.getPZ());
+ if (theta > 1e-3) {
+ fsParticles.add(mcparticle);
+ }
+ }
+ }
+ return fsParticles;
+ }
}
hps-java/src/main/resources/org/lcsim/hps/steering
diff -u -r1.3 -r1.4
--- ecal_fadc_bkgd.lcsim 9 Dec 2011 23:40:21 -0000 1.3
+++ ecal_fadc_bkgd.lcsim 9 Jan 2012 22:39:08 -0000 1.4
@@ -1,7 +1,7 @@
<!--
Example LCSim steering file to run simple HPS ECal clustering and analysis.
@author Sho Uemura <[log in to unmask]>
- @version $Id: ecal_fadc_bkgd.lcsim,v 1.3 2011/12/09 23:40:21 meeg Exp $
+ @version $Id: ecal_fadc_bkgd.lcsim,v 1.4 2012/01/09 22:39:08 meeg Exp $
-->
<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
@@ -26,7 +26,7 @@
<driver name="EcalFADCPlots"/>
<driver name="EcalTriggerPlots"/>
<driver name="MCParticlePlots"/>
- <!--<driver name="Writer"/>-->
+<!-- <driver name="Writer"/>-->
<driver name="AidaSaveDriver"/>
<driver name="ClockDriver"/>
</execute>
@@ -58,7 +58,7 @@
<driver name="EcalTrigger"
type="org.lcsim.hps.recon.ecal.HPSFADCTriggerDriver">
<clusterCollectionName>EcalClusters</clusterCollectionName>
- <outputFileName>${inputFile}_triggers</outputFileName>
+ <outputFileName>${outputFile}_triggers</outputFileName>
<ecalName>Ecal</ecalName>
</driver>
<driver name="EcalPlots"
@@ -79,11 +79,11 @@
</driver>
<driver name="EventMarkerDriver"
type="org.lcsim.job.EventMarkerDriver">
- <eventInterval>100</eventInterval>
+ <eventInterval>1000</eventInterval>
</driver>
<driver name="AidaSaveDriver"
type="org.lcsim.job.AidaSaveDriver">
- <outputFileName>${inputFile}_ecalPlots</outputFileName>
+ <outputFileName>${outputFile}_ecalPlots</outputFileName>
</driver>
<driver name="ClockDriver"
type="org.lcsim.hps.util.ClockDriver">
hps-java/src/main/java/org/lcsim/hps/util
diff -u -r1.2 -r1.3
--- ClockSingleton.java 7 Oct 2011 23:14:55 -0000 1.2
+++ ClockSingleton.java 9 Jan 2012 22:39:08 -0000 1.3
@@ -10,54 +10,62 @@
* A better solution might be to store absolute time and triggers in the event.
*
* @author Sho Uemura <[log in to unmask]>
- * @version $Id: ClockSingleton.java,v 1.2 2011/10/07 23:14:55 meeg Exp $
+ * @version $Id: ClockSingleton.java,v 1.3 2012/01/09 22:39:08 meeg Exp $
*/
public class ClockSingleton {
- public static final ClockSingleton _instance = new ClockSingleton();
+ public static final ClockSingleton _instance = new ClockSingleton();
- private int clock;
- //time between events (bunch spacing)
- private double dt = 2.0;
-
- private boolean trigger = false;
-
- private ClockSingleton() {
- }
-
- public static void init() {
- _instance.clock = 0;
- }
-
- public static int getClock() {
- return _instance.clock;
- }
-
- public static double getTime() {
- return _instance.dt * _instance.clock;
- }
-
- public static double getDt() {
- return _instance.dt;
- }
-
- public static void setDt(double dt) {
- _instance.dt = dt;
- }
-
- public static boolean triggered() {
- return _instance.trigger;
- }
-
- public static void setTrigger(boolean trigger) {
- _instance.trigger = trigger;
- }
-
- public static void setTrigger() {
- _instance.trigger = true;
- }
-
- public static void step() {
- _instance.clock++;
- _instance.trigger = false;
- }
+ private int clock;
+ //time between events (bunch spacing)
+ private double dt = 2.0;
+
+ private boolean trigger = false;
+ private int lastTrigger;
+ private int deadTime = 10;
+
+ private ClockSingleton() {
+ }
+
+ public static void init() {
+ _instance.clock = 0;
+ }
+
+ public static int getClock() {
+ return _instance.clock;
+ }
+
+ public static double getTime() {
+ return _instance.dt * _instance.clock;
+ }
+
+ public static double getDt() {
+ return _instance.dt;
+ }
+
+ public static void setDt(double dt) {
+ _instance.dt = dt;
+ }
+
+ public static void setDeadTime(int deadTime) {
+ _instance.deadTime = deadTime;
+ }
+
+ public static boolean triggered() {
+ return _instance.trigger;
+ }
+
+// public static void setTrigger(boolean trigger) {
+// _instance.trigger = trigger;
+// }
+ public static void setTrigger() {
+ if (getClock() - _instance.lastTrigger >= _instance.deadTime) {
+ _instance.trigger = true;
+ _instance.lastTrigger = getClock();
+ }
+ }
+
+ public static void step() {
+ _instance.clock++;
+ _instance.trigger = false;
+ }
}
CVSspam 0.2.12