Author: mccaky
Date: Sun Dec 14 13:31:31 2014
New Revision: 1727
Log:
Updated HPSEcalClusterIC to properly extend HPSEcalCluster.
Modified:
java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/HPSEcalClusterIC.java
Modified: java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/HPSEcalClusterIC.java
=============================================================================
--- java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/HPSEcalClusterIC.java (original)
+++ java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/HPSEcalClusterIC.java Sun Dec 14 13:31:31 2014
@@ -4,26 +4,21 @@
import java.util.List;
import org.lcsim.event.CalorimeterHit;
-import org.lcsim.event.base.BaseCluster;
/**
* Cluster with addition to include shared hits and set position
* as calculated in full cluster code.
*
+ * @author Holly Szumila <[log in to unmask]>
* @author Sho Uemura <[log in to unmask]>
- * @author Holly Szumila <[log in to unmask]>
- *
*/
-public class HPSEcalClusterIC extends BaseCluster {
-
- private CalorimeterHit seedHit = null;
- private long cellID;
- private ArrayList<CalorimeterHit> sharedHitList = new ArrayList<CalorimeterHit>();
+public class HPSEcalClusterIC extends HPSEcalCluster {
+ private int particleID = 0;
private double[] rawPosition = new double[3];
-
- private int particleID = 0;
-
- // Variables for electron energy corrections
+ private ArrayList<CalorimeterHit> allHitList = new ArrayList<CalorimeterHit>();
+ private ArrayList<CalorimeterHit> sharedHitList = new ArrayList<CalorimeterHit>();
+
+ // Variables for electron energy corrections
static final double ELECTRON_ENERGY_A = -0.0027;
static final double ELECTRON_ENERGY_B = -0.06;
static final double ELECTRON_ENERGY_C = 0.95;
@@ -37,85 +32,100 @@
static final double PHOTON_ENERGY_C = 0.94;
// Variables for electron position corrections
static final double ELECTRON_POS_A = 0.0066;
- static final double ELECTRON_POS_B = -0.03;
- static final double ELECTRON_POS_C = 0.028;
- static final double ELECTRON_POS_D = -0.45;
- static final double ELECTRON_POS_E = 0.465;
+ static final double ELECTRON_POS_B = -0.03;
+ static final double ELECTRON_POS_C = 0.028;
+ static final double ELECTRON_POS_D = -0.45;
+ static final double ELECTRON_POS_E = 0.465;
// Variables for positron position corrections
- static final double POSITRON_POS_A = 0.0072;
- static final double POSITRON_POS_B = -0.031;
- static final double POSITRON_POS_C = 0.007;
- static final double POSITRON_POS_D = 0.342;
- static final double POSITRON_POS_E = 0.108;
+ static final double POSITRON_POS_A = 0.0072;
+ static final double POSITRON_POS_B = -0.031;
+ static final double POSITRON_POS_C = 0.007;
+ static final double POSITRON_POS_D = 0.342;
+ static final double POSITRON_POS_E = 0.108;
// Variables for photon position corrections
- static final double PHOTON_POS_A = 0.005;
- static final double PHOTON_POS_B = -0.032;
- static final double PHOTON_POS_C = 0.011;
- static final double PHOTON_POS_D = -0.037;
- static final double PHOTON_POS_E = 0.294;
+ static final double PHOTON_POS_A = 0.005;
+ static final double PHOTON_POS_B = -0.032;
+ static final double PHOTON_POS_C = 0.011;
+ static final double PHOTON_POS_D = -0.037;
+ static final double PHOTON_POS_E = 0.294;
public HPSEcalClusterIC(Long cellID) {
- this.cellID = cellID;
+ super(cellID);
}
public HPSEcalClusterIC(CalorimeterHit seedHit) {
- this.seedHit = seedHit;
- this.cellID = seedHit.getCellID();
- }
-
- public CalorimeterHit getSeedHit() {
- if (seedHit == null) {
- CalorimeterHit hit = hits.get(0);
- if (hit == null) {
- throw new RuntimeException("HPSEcalCluster has no hits");
- }
- seedHit = new HPSCalorimeterHit(0.0, 0.0, cellID, hit.getType());
- seedHit.setMetaData(hit.getMetaData());
- }
- return seedHit;
- }
+ super(seedHit.getCellID());
+ setSeedHit(seedHit);
+ }
+
+ public void addHit(CalorimeterHit hit) {
+ super.addHit(hit);
+ allHitList.add(hit);
+ }
+
/**
* Input shared hits between two clusters.
*/
public void addSharedHit(CalorimeterHit sharedHit) {
- sharedHitList.add(sharedHit);
+ sharedHitList.add(sharedHit);
+ allHitList.add(sharedHit);
}
/**
* Return shared hit list between two clusters.
*/
public List<CalorimeterHit> getSharedHits() {
- return sharedHitList;
+ return sharedHitList;
}
/**
* Inputs the uncorrected x,y,z position of the cluster.
*/
public void setRawPosition(double[] Position) {
- rawPosition = Position;
- }
+ rawPosition = Position;
+ }
+
+ /**
+ * Gets the cluster hits that are not shared with other clusters.
+ * @return Returns the clusters as a <code>List</code> object
+ * containing <code>CalorimeterHit</code> objects.
+ */
+ public List<CalorimeterHit> getUniqueHits() {
+ return super.getCalorimeterHits();
+ }
+
+ /**
+ * Gets all hits in the cluster.
+ */
+ public List<CalorimeterHit> getCalorimeterHits() {
+ return allHitList;
+ }
+
/**
* Returns the uncorrected x,y,z position of the cluster.
*/
@Override
- public double[] getPosition(){
- return this.rawPosition;
- }
+ public double[] getPosition() {
+ return this.rawPosition;
+ }
+
/**
* Do an external calculation of the raw energy and set it. Includes shared hit distribution.
*/
public void setRawEnergy(double rawEnergy){
- raw_energy = rawEnergy;
- }
+ raw_energy = rawEnergy;
+ }
+
/**
* Inputs the corrected position of the cluster, see HPS Note 2014-001.
*/
- public void setCorrPosition(double[] Position) {
- position = Position;
- }
+ public void setCorrPosition(double[] position) {
+ this.position = position;
+ }
+
/**
* Returns the corrected position of the cluster.
*/
public double[] getCorrPosition(){
- return this.position;
+ return this.position;
}
/**
@@ -126,8 +136,8 @@
* @return Corrected Energy
*/
private double enCorrection(int pdg, double rawEnergy) {
- switch (pdg) {
- case 11: // Particle is electron
+ switch(pdg) {
+ case 11: // Particle is electron
return energyCorrection(rawEnergy, ELECTRON_ENERGY_A, ELECTRON_ENERGY_B, ELECTRON_ENERGY_C);
case -11: //Particle is positron
return energyCorrection(rawEnergy, POSITRON_ENERGY_A, POSITRON_ENERGY_B, POSITRON_ENERGY_C);
@@ -136,7 +146,6 @@
default: //Unknown
return rawEnergy;
}
-
}
/**
@@ -147,10 +156,9 @@
* @return Corrected Energy
*/
private double energyCorrection(double rawEnergy, double varA, double varB, double varC){
- double corrEnergy = rawEnergy / (varA * rawEnergy + varB / (Math.sqrt(rawEnergy)) + varC);
- return corrEnergy;
- }
-
+ double corrEnergy = rawEnergy / (varA * rawEnergy + varB / (Math.sqrt(rawEnergy)) + varC);
+ return corrEnergy;
+ }
/**
* Calculates position correction based on cluster raw energy, x calculated position,
@@ -164,14 +172,14 @@
private double posCorrection(int pdg, double xPos, double rawEnergy) {
double xCl = xPos / 10.0;//convert to mm
double xCorr;
- switch (pdg) {
- case 11: //Particle is electron
+ switch(pdg) {
+ case 11: //Particle is electron
xCorr = positionCorrection(xCl, rawEnergy, ELECTRON_POS_A, ELECTRON_POS_B, ELECTRON_POS_C, ELECTRON_POS_D, ELECTRON_POS_E);
return xCorr * 10.0;
- case -11:// Particle is positron
+ case -11:// Particle is positron
xCorr = positionCorrection(xCl, rawEnergy, POSITRON_POS_A, POSITRON_POS_B, POSITRON_POS_C, POSITRON_POS_D, POSITRON_POS_E);
return xCorr * 10.0;
- case 22: // Particle is photon
+ case 22: // Particle is photon
xCorr = positionCorrection(xCl, rawEnergy, PHOTON_POS_A, PHOTON_POS_B, PHOTON_POS_C, PHOTON_POS_D, PHOTON_POS_E);
return xCorr * 10.0;
default: //Unknown
@@ -179,7 +187,6 @@
return xCorr * 10.0;
}
}
-
/**
* Calculates the position correction in cm using the raw energy and variables associated with the fit
@@ -194,10 +201,11 @@
* @param varE
* @return
*/
- private double positionCorrection(double xCl, double rawEnergy, double varA, double varB, double varC, double varD, double varE){
- double xCorr = xCl-(varA/Math.sqrt(rawEnergy) + varB )*xCl-
- (varC*rawEnergy + varD/Math.sqrt(rawEnergy) + varE);
- return xCorr;
+ private double positionCorrection(double xCl, double rawEnergy, double varA,
+ double varB, double varC, double varD, double varE) {
+ double xCorr = xCl - (varA / Math.sqrt(rawEnergy) + varB ) * xCl
+ - (varC * rawEnergy + varD / Math.sqrt(rawEnergy) + varE);
+ return xCorr;
}
private void recalculateForParticleID(int pid) {
@@ -214,9 +222,9 @@
}
public void setParticleID(int pid) {
- if (particleID!=pid){
+ if(particleID!=pid) {
particleID = pid;
recalculateForParticleID(pid);
}
}
-}
+}
|