Commit in hps-java/src/main/java/org/lcsim/hps/recon/ecal on MAIN | |||
HPSFADCTriggerDriver.java | +350 | -346 | 1.4 -> 1.5 |
tweak end-of-run information from HPSFADCTriggerDriver
diff -u -r1.4 -r1.5 --- HPSFADCTriggerDriver.java 3 Apr 2012 17:02:35 -0000 1.4 +++ HPSFADCTriggerDriver.java 29 Apr 2012 02:10:51 -0000 1.5 @@ -15,354 +15,358 @@
* * @author Omar Moreno <[log in to unmask]> * @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSFADCTriggerDriver.java,v 1.4 2012/04/03 17:02:35 meeg Exp $
+ * @version $Id: HPSFADCTriggerDriver.java,v 1.5 2012/04/29 02:10:51 meeg Exp $
*/ public class HPSFADCTriggerDriver extends HPSTriggerDriver {
- // A list to contain all cluster pairs in an event - List<HPSEcalCluster[]> clusterPairs; - int nTriggers; - int totalEvents; - private double clusterEnergyHigh = 1.85; // GeV - private double clusterEnergyLow = .1; // GeV - private double energySumThreshold = 2.2; // GeV - private double energyDifferenceThreshold = 1.5; // GeV - private double maxCoplanarityAngle = 35; // degrees - double crystalX = (13.3 + 16.0) / 2; - double crystalY = (13.3 + 16.0) / 2; - double beamGap = 20.0; - int oppositeQuadrantCount; - int clusterEnergyCount; - int energySumCount; - int energyDifferenceCount; - int energyDistanceCount; - int coplanarityCount; - int nonuniqueTriggerCount; - - public HPSFADCTriggerDriver() { - clusterPairs = new LinkedList<HPSEcalCluster[]>(); - } - - @Override - public void startOfData() { - super.startOfData(); - - oppositeQuadrantCount = 0; - clusterEnergyCount = 0; - energySumCount = 0; - energyDifferenceCount = 0; - energyDistanceCount = 0; - coplanarityCount = 0; - nonuniqueTriggerCount = 0; - } - - public boolean testTrigger(List<HPSEcalCluster> clusters) { - boolean trigger = false; - - getClusterPairs(clusters); - - //--- Apply Trigger Cuts ---// - - // Iterate through all cluster pairs present in the event. If at least - // one of the cluster pairs satisfies all of the trigger conditions, - // a trigger signal is sent to all other detectors. - for (HPSEcalCluster[] clusterPair : clusterPairs) { - - if (outputStream != null) { - outputStream.printf("Event %d: cluster pair (energy %f in quadrant %d, energy %f in quadrant %d)\n", - ClockSingleton.getClock(), - clusterPair[0].getEnergy(), getECalQuadrant(clusterPair[0]), - clusterPair[1].getEnergy(), getECalQuadrant(clusterPair[1])); - } - - // Require that the event have at least two clusters in opposite - // quadrants - if (!oppositeQuadrantsCut(clusterPair)) { - if (outputStream != null) { - outputStream.println("Failed opposite quadrant cut"); - } - continue; - } - oppositeQuadrantCount++; - - - // Require the componets of a cluster pair to have an energy in - // the range of 100 MeV to 1.85 GeV - if (!clusterECut(clusterPair)) { - if (outputStream != null) { - outputStream.println("Failed cluster energy cut"); - } - continue; - } - clusterEnergyCount++; - - // Require the sum of the energies of the components of the - // cluster pair to be less than the - // (Beam Energy)*(Sampling Fraction) ( 2 GeV for the Test Run ) - if (!energySum(clusterPair)) { - if (outputStream != null) { - outputStream.println("Failed energy sum cut"); - } - continue; - } - energySumCount++; - - // Require the difference in energy of the components of the - // cluster pair to be less than 1.5 GeV - if (!energyDifference(clusterPair)) { - if (outputStream != null) { - outputStream.println("Failed energy difference cut"); - } - continue; - } - energyDifferenceCount++; - - // Apply a low energy cluster vs. distance cut of the form - // E_low + .0032 GeV/mm < .8 GeV - if (!energyDistanceCut(clusterPair)) { - if (outputStream != null) { - outputStream.println("Failed energy-distance cut"); - } - continue; - } - energyDistanceCount++; - - // Require that the two clusters are coplanar with the beam within - // 35 degrees - if (!coplanarityCut(clusterPair)) { - if (outputStream != null) { - outputStream.println("Failed coplanarity cut"); - } - continue; - } - coplanarityCount++; - - - // If all cuts are pased, we have a trigger - if (outputStream != null) { - outputStream.println("Passed all cuts"); - } - nonuniqueTriggerCount++; - trigger = true; - } - return trigger; - } - - @Override - public void endOfData() { - if (outputStream != null) { - outputStream.printf("Number of cluster pairs after successive trigger conditions:\n"); - outputStream.printf("Opposite quadrants: %d\n", oppositeQuadrantCount); - outputStream.printf("Cluster energy: %d\n", clusterEnergyCount); - outputStream.printf("Energy sum: %d\n", energySumCount); - outputStream.printf("Energy difference: %d\n", energyDifferenceCount); - outputStream.printf("Energy-distance cut: %d\n", energyDistanceCount); - outputStream.printf("Coplanarity: %d\n", coplanarityCount); - outputStream.printf("Final count of passing cluster pairs: %d\n", nonuniqueTriggerCount); - outputStream.printf("Trigger count: %d\n", numTriggers); - outputStream.close(); - } - System.out.printf("Number of cluster pairs after successive trigger conditions:\n"); - System.out.printf("Opposite quadrants: %d\n", oppositeQuadrantCount); - System.out.printf("Cluster energy: %d\n", clusterEnergyCount); - System.out.printf("Energy sum: %d\n", energySumCount); - System.out.printf("Energy difference: %d\n", energyDifferenceCount); - System.out.printf("Energy-distance cut: %d\n", energyDistanceCount); - 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(); - } - - /** - * Get a list of all unique cluster pairs in the event - * - * @param ecalClusters : List of ECal clusters - * @return true if there are any cluster pairs - */ - public boolean getClusterPairs(List<HPSEcalCluster> ecalClusters) { - // Create a list which will hold all neighboring cluster to the cluster - // of interest - List< HPSEcalCluster> ecalClusterNeighbors = new LinkedList< HPSEcalCluster>(); - ecalClusterNeighbors.addAll(ecalClusters); - - // Clear the list of cluster pairs - clusterPairs.clear(); - - for (HPSEcalCluster ecalCluster : ecalClusters) { - // Create a list of neighbors to the cluster of interest - ecalClusterNeighbors.remove(ecalCluster); - - // Loop over all neigboring clusters and check to see if there is - // any which lie in opposing quadrants to the cluster of interest. - // If so, add them to the list of cluster pairs - for (HPSEcalCluster ecalClusterNeighbor : ecalClusterNeighbors) { - HPSEcalCluster[] clusterPair = {ecalCluster, ecalClusterNeighbor}; - clusterPairs.add(clusterPair); - } - } - - return !clusterPairs.isEmpty(); - } - - /** - * Checks if the ECal clusters making up a cluster pair lie in opposite quadrants - * - * @param clusterPair : pair of clusters - * @return true if opposite quadrants, false otherwise - */ - public boolean oppositeQuadrantsCut(HPSEcalCluster[] clusterPair) { - int quad1 = getECalQuadrant(clusterPair[0]); - int quad2 = getECalQuadrant(clusterPair[1]); - - //if clusters are in the same quadrant, they're not opposite quadrants - if (quad1 == quad2) { - return false; - } //opposite pairs of quadrants are either both even (2 and 4) or both off (1 and 3) - else { - return ((quad1 & 1) == (quad2 & 1)); - } - } - - /** - * Returns the quadrant which contains the ECal cluster - * - * @param ecalCluster : ECal cluster - * @return Quadrant number - */ - public int getECalQuadrant(HPSEcalCluster ecalCluster) { - dec.setID(ecalCluster.getSeedHit().getCellID()); - int ix = dec.getValue("ix"); - int iy = dec.getValue("iy"); - if (ix > 0) { - if (iy > 0) { - return 1; - } else { - return 4; - } - } else { - if (iy > 0) { - return 2; - } else { - return 3; - } - } - } - - /** - * Checks if the ECal clusters making up a cluster pair lie above the low - * energy threshold and below the high energy threshold - * - * @param clusterPair : pair of clusters - * @return true if a pair is found, false otherwise - */ - public boolean clusterECut(HPSEcalCluster[] clusterPair) { - return (clusterPair[0].getEnergy() < clusterEnergyHigh - && clusterPair[1].getEnergy() < clusterEnergyHigh - && clusterPair[0].getEnergy() > clusterEnergyLow - && clusterPair[1].getEnergy() > clusterEnergyLow); - } - - /** - * Checks if the sum of the energies of ECal clusters making up a cluster - * pair is below an energy sum threshold - * - * @param clusterPair : pair of clusters - * @return true if a pair is found, false otherwise - */ - public boolean energySum(Cluster[] clusterPair) { - double clusterESum = clusterPair[0].getEnergy() - + clusterPair[1].getEnergy(); - return (clusterESum < energySumThreshold); - } - - /** - * Checks if the energy difference between the ECal clusters making up - * a cluster pair is below an energy difference threshold - * - * @param clusterPair : pair of clusters - * @return true if pair is found, false otherwise - */ - public boolean energyDifference(HPSEcalCluster[] clusterPair) { - double clusterEDifference = Math.abs(clusterPair[0].getEnergy() - - clusterPair[1].getEnergy()); - - return (clusterEDifference < energyDifferenceThreshold); - } - - /** - * Require that the distance from the beam of the lowest energy cluster - * in a cluster pair satisfies the following - * E_low + d_b*.0032 GeV/mm < .8 GeV - * - * @param clusterPair : pair of clusters - * @return true if pair is found, false otherwise - */ - public boolean energyDistanceCut(HPSEcalCluster[] clusterPair) { - HPSEcalCluster lowEnergyCluster; - - // Obtain the lowest energy cluster - if (clusterPair[0].getEnergy() < clusterPair[1].getEnergy()) { - lowEnergyCluster = clusterPair[0]; - } else { - lowEnergyCluster = clusterPair[1]; - } - - double lowEClusterPosition[] = hitPosition(lowEnergyCluster.getSeedHit()); - // Calculate its position - double lowEClusterDistance = Math.sqrt(Math.pow(lowEClusterPosition[0], 2) - + Math.pow(lowEClusterPosition[1], 2)); - - double clusterDistvsE = lowEnergyCluster.getEnergy() + lowEClusterDistance * (0.0032); - - if (clusterDistvsE > .8 /* GeV */) { - return true; - } - - return false; - } - - /** - * Checks if a cluster pair is coplanar to the beam within a given - * angle - * - * @param clusterPair : pair of clusters - * @return true if pair is found, false otherwise - */ - public boolean coplanarityCut(HPSEcalCluster[] clusterPair) { - double cluster1Position[] = hitPosition(clusterPair[0].getSeedHit()); - double cluster2Position[] = hitPosition(clusterPair[1].getSeedHit()); - // Find the distance of both clusters from the origin - double cluster1Dist = Math.sqrt(Math.pow(cluster1Position[0], 2) - + Math.pow(cluster1Position[1], 2)); - double cluster2Dist = Math.sqrt(Math.pow(cluster2Position[0], 2) - + Math.pow(cluster2Position[1], 2)); - - // Calculate the dot product between the distance vectors of - // each cluster in the cluster pair - double clusterDot = cluster1Position[0] * cluster2Position[0] - + cluster1Position[1] * cluster2Position[1]; - - // Find the angle between clusters in the pair - double cosphi = clusterDot / (cluster1Dist * cluster2Dist); - double phi = Math.toDegrees(Math.acos(cosphi)); - - return ((180 - phi) < maxCoplanarityAngle); - } - - /** - * Finds position of an ECal hit using the crystal ID - * @param hit : ECal hit - * @return [x,y] of crystal center in units of mm - */ - public double[] hitPosition(CalorimeterHit hit) { - dec.setID(hit.getCellID()); - int ix = dec.getValue("ix"); - int iy = dec.getValue("iy"); - double position[] = new double[2]; - position[0] = crystalX * ix; - position[1] = crystalY * iy + beamGap * Math.signum(iy);
+ // A list to contain all cluster pairs in an event + List<HPSEcalCluster[]> clusterPairs; + int nTriggers; + int totalEvents; + private double clusterEnergyHigh = 1.85; // GeV + private double clusterEnergyLow = .1; // GeV + private double energySumThreshold = 2.2; // GeV + private double energyDifferenceThreshold = 1.5; // GeV + private double maxCoplanarityAngle = 35; // degrees + double crystalX = (13.3 + 16.0) / 2; + double crystalY = (13.3 + 16.0) / 2; + double beamGap = 20.0; + int oppositeQuadrantCount; + int clusterEnergyCount; + int energySumCount; + int energyDifferenceCount; + int energyDistanceCount; + int coplanarityCount; + int deadtimelessTriggerCount; + + public HPSFADCTriggerDriver() { + clusterPairs = new LinkedList<HPSEcalCluster[]>(); + } + + @Override + public void startOfData() { + super.startOfData(); + + oppositeQuadrantCount = 0; + clusterEnergyCount = 0; + energySumCount = 0; + energyDifferenceCount = 0; + energyDistanceCount = 0; + coplanarityCount = 0; + deadtimelessTriggerCount = 0; + } + + public boolean testTrigger(List<HPSEcalCluster> clusters) { + boolean trigger = false; + + getClusterPairs(clusters); + + //--- Apply Trigger Cuts ---// + + // Iterate through all cluster pairs present in the event. If at least + // one of the cluster pairs satisfies all of the trigger conditions, + // a trigger signal is sent to all other detectors. + for (HPSEcalCluster[] clusterPair : clusterPairs) { + + if (outputStream != null) { + outputStream.printf("Event %d: cluster pair (energy %f in quadrant %d, energy %f in quadrant %d)\n", + ClockSingleton.getClock(), + clusterPair[0].getEnergy(), getECalQuadrant(clusterPair[0]), + clusterPair[1].getEnergy(), getECalQuadrant(clusterPair[1])); + } + + // Require that the event have at least two clusters in opposite + // quadrants + if (!oppositeQuadrantsCut(clusterPair)) { + if (outputStream != null) { + outputStream.println("Failed opposite quadrant cut"); + } + continue; + } + oppositeQuadrantCount++; + + + // Require the componets of a cluster pair to have an energy in + // the range of 100 MeV to 1.85 GeV + if (!clusterECut(clusterPair)) { + if (outputStream != null) { + outputStream.println("Failed cluster energy cut"); + } + continue; + } + clusterEnergyCount++; + + // Require the sum of the energies of the components of the + // cluster pair to be less than the + // (Beam Energy)*(Sampling Fraction) ( 2 GeV for the Test Run ) + if (!energySum(clusterPair)) { + if (outputStream != null) { + outputStream.println("Failed energy sum cut"); + } + continue; + } + energySumCount++; + + // Require the difference in energy of the components of the + // cluster pair to be less than 1.5 GeV + if (!energyDifference(clusterPair)) { + if (outputStream != null) { + outputStream.println("Failed energy difference cut"); + } + continue; + } + energyDifferenceCount++; + + // Apply a low energy cluster vs. distance cut of the form + // E_low + .0032 GeV/mm < .8 GeV + if (!energyDistanceCut(clusterPair)) { + if (outputStream != null) { + outputStream.println("Failed energy-distance cut"); + } + continue; + } + energyDistanceCount++; + + // Require that the two clusters are coplanar with the beam within + // 35 degrees + if (!coplanarityCut(clusterPair)) { + if (outputStream != null) { + outputStream.println("Failed coplanarity cut"); + } + continue; + } + coplanarityCount++; + + + // If all cuts are pased, we have a trigger + if (outputStream != null) { + outputStream.println("Passed all cuts"); + } + trigger = true; + } + deadtimelessTriggerCount++; + return trigger; + } + + @Override + public void endOfData() { + if (outputStream != null) { + outputStream.printf("Number of cluster pairs after successive trigger conditions:\n"); + outputStream.printf("Opposite quadrants: %d\n", oppositeQuadrantCount); + outputStream.printf("Cluster energy: %d\n", clusterEnergyCount); + outputStream.printf("Energy sum: %d\n", energySumCount); + outputStream.printf("Energy difference: %d\n", energyDifferenceCount); + outputStream.printf("Energy-distance cut: %d\n", energyDistanceCount); + outputStream.printf("Coplanarity: %d\n", coplanarityCount); + outputStream.printf("Trigger count without dead time: %d\n", deadtimelessTriggerCount); + outputStream.printf("Trigger count: %d\n", numTriggers); + outputStream.close(); + } + System.out.printf("Number of cluster pairs after successive trigger conditions:\n"); + System.out.printf("Opposite quadrants: %d\n", oppositeQuadrantCount); + System.out.printf("Cluster energy: %d\n", clusterEnergyCount); + System.out.printf("Energy sum: %d\n", energySumCount); + System.out.printf("Energy difference: %d\n", energyDifferenceCount); + System.out.printf("Energy-distance cut: %d\n", energyDistanceCount); + System.out.printf("Coplanarity: %d\n", coplanarityCount); + System.out.printf("Trigger count without dead time: %d\n", deadtimelessTriggerCount); + System.out.printf("Trigger count: %d\n", numTriggers); + super.endOfData(); + } + + /** + * Get a list of all unique cluster pairs in the event + * + * @param ecalClusters : List of ECal clusters + * @return true if there are any cluster pairs + */ + public boolean getClusterPairs(List<HPSEcalCluster> ecalClusters) { + // Create a list which will hold all neighboring cluster to the cluster + // of interest + List< HPSEcalCluster> ecalClusterNeighbors = new LinkedList< HPSEcalCluster>(); + ecalClusterNeighbors.addAll(ecalClusters); + + // Clear the list of cluster pairs + clusterPairs.clear(); + + for (HPSEcalCluster ecalCluster : ecalClusters) { + // Create a list of neighbors to the cluster of interest + ecalClusterNeighbors.remove(ecalCluster); + + // Loop over all neigboring clusters and check to see if there is + // any which lie in opposing quadrants to the cluster of interest. + // If so, add them to the list of cluster pairs + for (HPSEcalCluster ecalClusterNeighbor : ecalClusterNeighbors) { + HPSEcalCluster[] clusterPair = {ecalCluster, ecalClusterNeighbor}; + clusterPairs.add(clusterPair); + } + } + + return !clusterPairs.isEmpty(); + } + + /** + * Checks if the ECal clusters making up a cluster pair lie in opposite + * quadrants + * + * @param clusterPair : pair of clusters + * @return true if opposite quadrants, false otherwise + */ + public boolean oppositeQuadrantsCut(HPSEcalCluster[] clusterPair) { + int quad1 = getECalQuadrant(clusterPair[0]); + int quad2 = getECalQuadrant(clusterPair[1]); + + //if clusters are in the same quadrant, they're not opposite quadrants + if (quad1 == quad2) { + return false; + } //opposite pairs of quadrants are either both even (2 and 4) or both off (1 and 3) + else { + return ((quad1 & 1) == (quad2 & 1)); + } + } + + /** + * Returns the quadrant which contains the ECal cluster + * + * @param ecalCluster : ECal cluster + * @return Quadrant number + */ + public int getECalQuadrant(HPSEcalCluster ecalCluster) { + dec.setID(ecalCluster.getSeedHit().getCellID()); + int ix = dec.getValue("ix"); + int iy = dec.getValue("iy"); + if (ix > 0) { + if (iy > 0) { + return 1; + } else { + return 4; + } + } else { + if (iy > 0) { + return 2; + } else { + return 3; + } + } + } + + /** + * Checks if the ECal clusters making up a cluster pair lie above the low + * energy threshold and below the high energy threshold + * + * @param clusterPair : pair of clusters + * @return true if a pair is found, false otherwise + */ + public boolean clusterECut(HPSEcalCluster[] clusterPair) { + return (clusterPair[0].getEnergy() < clusterEnergyHigh + && clusterPair[1].getEnergy() < clusterEnergyHigh + && clusterPair[0].getEnergy() > clusterEnergyLow + && clusterPair[1].getEnergy() > clusterEnergyLow); + } + + /** + * Checks if the sum of the energies of ECal clusters making up a cluster + * pair is below an energy sum threshold + * + * @param clusterPair : pair of clusters + * @return true if a pair is found, false otherwise + */ + public boolean energySum(Cluster[] clusterPair) { + double clusterESum = clusterPair[0].getEnergy() + + clusterPair[1].getEnergy(); + return (clusterESum < energySumThreshold); + } + + /** + * Checks if the energy difference between the ECal clusters making up a + * cluster pair is below an energy difference threshold + * + * @param clusterPair : pair of clusters + * @return true if pair is found, false otherwise + */ + public boolean energyDifference(HPSEcalCluster[] clusterPair) { + double clusterEDifference = Math.abs(clusterPair[0].getEnergy() + - clusterPair[1].getEnergy()); + + return (clusterEDifference < energyDifferenceThreshold); + } + + /** + * Require that the distance from the beam of the lowest energy cluster in a + * cluster pair satisfies the following E_low + d_b*.0032 GeV/mm < .8 GeV + * + + * + * @param clusterPair : pair of clusters + * @return true if pair is found, false otherwise + */ + public boolean energyDistanceCut(HPSEcalCluster[] clusterPair) { + HPSEcalCluster lowEnergyCluster; + + // Obtain the lowest energy cluster + if (clusterPair[0].getEnergy() < clusterPair[1].getEnergy()) { + lowEnergyCluster = clusterPair[0]; + } else { + lowEnergyCluster = clusterPair[1]; + } + + double lowEClusterPosition[] = hitPosition(lowEnergyCluster.getSeedHit()); + // Calculate its position + double lowEClusterDistance = Math.sqrt(Math.pow(lowEClusterPosition[0], 2) + + Math.pow(lowEClusterPosition[1], 2)); + + double clusterDistvsE = lowEnergyCluster.getEnergy() + lowEClusterDistance * (0.0032); + + if (clusterDistvsE > .8 /* + * GeV + */) { + return true; + } + + return false; + } + + /** + * Checks if a cluster pair is coplanar to the beam within a given angle + * + * @param clusterPair : pair of clusters + * @return true if pair is found, false otherwise + */ + public boolean coplanarityCut(HPSEcalCluster[] clusterPair) { + double cluster1Position[] = hitPosition(clusterPair[0].getSeedHit()); + double cluster2Position[] = hitPosition(clusterPair[1].getSeedHit()); + // Find the distance of both clusters from the origin + double cluster1Dist = Math.sqrt(Math.pow(cluster1Position[0], 2) + + Math.pow(cluster1Position[1], 2)); + double cluster2Dist = Math.sqrt(Math.pow(cluster2Position[0], 2) + + Math.pow(cluster2Position[1], 2)); + + // Calculate the dot product between the distance vectors of + // each cluster in the cluster pair + double clusterDot = cluster1Position[0] * cluster2Position[0] + + cluster1Position[1] * cluster2Position[1]; + + // Find the angle between clusters in the pair + double cosphi = clusterDot / (cluster1Dist * cluster2Dist); + double phi = Math.toDegrees(Math.acos(cosphi)); + + return ((180 - phi) < maxCoplanarityAngle); + } + + /** + * Finds position of an ECal hit using the crystal ID + * + * @param hit : ECal hit + * @return [x,y] of crystal center in units of mm + */ + public double[] hitPosition(CalorimeterHit hit) { + dec.setID(hit.getCellID()); + int ix = dec.getValue("ix"); + int iy = dec.getValue("iy"); + double position[] = new double[2]; + position[0] = crystalX * ix; + position[1] = crystalY * iy + beamGap * Math.signum(iy);
- return position; - }
+ return position; + }
}
\ No newline at end of file
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