hps-java/src/main/java/org/lcsim/hps/users/omoreno
diff -u -r1.2 -r1.3
--- SvtQA.java 27 Jul 2012 19:02:07 -0000 1.2
+++ SvtQA.java 28 Jul 2012 01:27:49 -0000 1.3
@@ -38,7 +38,7 @@
* SVT Quality Assurance Driver
*
* @author Omar Moreno <[log in to unmask]>
- * @version $Id: SvtQA.java,v 1.2 2012/07/27 19:02:07 omoreno Exp $
+ * @version $Id: SvtQA.java,v 1.3 2012/07/28 01:27:49 omoreno Exp $
*/
public class SvtQA extends Driver {
@@ -468,50 +468,30 @@
System.out.println("Total Bad Channels: " + HPSSVTCalibrationConstants.getTotalBadChannels() + "\n");
if(enableOccupancy){
- System.out.println("%===================================================================% \n");
for(SiSensor sensor : SvtUtils.getInstance().getSensors()){
+ System.out.println("%===================================================================%");
System.out.println(SvtUtils.getInstance().getDescription(sensor) + " Bad Channels");
- Pair<Integer, Integer> daqPair = SvtUtils.getInstance().getDaqPair(sensor);
+ System.out.println("%===================================================================%");
for(int index = 0; index < 640; index++){
- double occupancy = sensorToOccupancy.get(SvtUtils.getInstance().getDescription(sensor))[index]/totalNumberEvents;
- double leftNeighborOccupancy = 0;
- double rightNeighborOccupancy = 0;
- double leftDiff = 0;
- double rightDiff = 0;
- if(index != 0){
- leftNeighborOccupancy = sensorToOccupancy.get(SvtUtils.getInstance().getDescription(sensor))[index - 1]/totalNumberEvents;
- leftDiff = Math.abs(leftNeighborOccupancy - occupancy)/leftNeighborOccupancy;
- }
- if(index != 639){
- rightNeighborOccupancy = sensorToOccupancy.get(SvtUtils.getInstance().getDescription(sensor))[index + 1]/totalNumberEvents;
- rightDiff = Math.abs(rightNeighborOccupancy - occupancy)/rightNeighborOccupancy;
- }
- if(occupancy > maxOccupancy){
- System.out.println(" Channel: " + index + " FPGA: " + daqPair.getSecondElement() + " Hybrid: " + daqPair.getFirstElement() + " Occupancy: " + occupancy);
- } else if( leftDiff > maxOccupancyVariation || rightDiff > maxOccupancyVariation){
- System.out.println(" Channel: " + index + " FPGA: " + daqPair.getSecondElement() + " Hybrid: " + daqPair.getFirstElement()
- + " Left Difference: " + leftDiff + " Right Difference: " + rightDiff);
+ // Check is the channel can be considered bad
+ this.checkChannel(sensor, index);
}
}
- }
System.out.println("%===================================================================% \n");
}
if(enableStereoHitOccupancy){
- System.out.println("%===================================================================% \n");
for(SiSensor sensor : SvtUtils.getInstance().getSensors()){
+ System.out.println("%===================================================================% \n");
System.out.println(SvtUtils.getInstance().getDescription(sensor) + " Bad Channels");
- Pair<Integer, Integer> daqPair = SvtUtils.getInstance().getDaqPair(sensor);
+ System.out.println("%===================================================================% \n");
for(int index = 0; index < 640; index++){
- double occupancy = sensorToStereoOccupancy.get(SvtUtils.getInstance().getDescription(sensor))[index]/totalNumberEvents;
- occupancy *= 1000;
- if(occupancy == 0){
- System.out.println(" Channel: " + index + " FPGA: " + daqPair.getSecondElement() + " Hybrid: " + daqPair.getFirstElement() + " Occupancy: " + occupancy);
- }
+ // Check is the channel can be considered bad
+ this.checkChannel(sensor, index);
}
+ System.out.println("%===================================================================% \n");
}
- System.out.println("%===================================================================% \n");
}
if(outputFile != null){
@@ -522,4 +502,52 @@
}
}
}
+
+ public double getOccupancy(SiSensor sensor, int channel){
+ if(!enableOccupancy) throw new RuntimeException("Occupancy calculation was not enabled!");
+ return sensorToOccupancy.get(SvtUtils.getInstance().getDescription(sensor))[channel]/totalNumberEvents;
+ }
+
+ public void checkChannel(SiSensor sensor, int channel){
+ if(!enableOccupancy) throw new RuntimeException("Occupancy calculation was not enabled!");
+
+ if(HPSSVTCalibrationConstants.isBadChannel(sensor, channel)) return;
+
+ // Find the occupancy of the current channel
+ double currentChannelOccu = this.getOccupancy(sensor, channel);
+
+ // If the channel exceeds the maximum allowable occupancy, then it's a bad channel
+ if(currentChannelOccu > maxOccupancy){
+ System.out.println("Channel " + channel + ": Occupancy " + currentChannelOccu + " -- Exceeds maximum");
+ return;
+ }
+
+ // Find the occupancy of the neighboring channels
+ if(channel == 0){
+ double rNeighborOccu = this.getOccupancy(sensor, channel+1);
+ if(rNeighborOccu == 0 || HPSSVTCalibrationConstants.isBadChannel(sensor, channel+1)) return;
+ double rOccuDiff = Math.abs(rNeighborOccu - currentChannelOccu)/rNeighborOccu;
+ if(rOccuDiff >= maxOccupancyVariation)
+ System.out.println("Channel " + channel + ": Channel Variation exceeds maximum -- RVar: " + rOccuDiff);
+ } else if(channel == 638){
+ double lNeighborOccu = this.getOccupancy(sensor, channel-1);
+ if(lNeighborOccu == 0 || HPSSVTCalibrationConstants.isBadChannel(sensor, channel-1)) return;
+ double lOccuDiff = Math.abs(lNeighborOccu - currentChannelOccu)/lNeighborOccu;
+ if(lOccuDiff >= maxOccupancyVariation)
+ System.out.println("Channel " + channel + ": Channel Variation exceeds maximum -- LVar: " + lOccuDiff);
+ } else if (channel == 639){
+ return;
+ }
+ else {
+ double rNeighborOccu = this.getOccupancy(sensor, channel+1);
+ double lNeighborOccu = this.getOccupancy(sensor, channel-1);
+ if(rNeighborOccu == 0 || HPSSVTCalibrationConstants.isBadChannel(sensor, channel+1)
+ || lNeighborOccu == 0 || HPSSVTCalibrationConstants.isBadChannel(sensor, channel-1)) return;
+ double rOccuDiff = Math.abs(rNeighborOccu - currentChannelOccu)/rNeighborOccu;
+ double lOccuDiff = Math.abs(lNeighborOccu - currentChannelOccu)/lNeighborOccu;
+ if(rOccuDiff >= maxOccupancyVariation && lOccuDiff >= maxOccupancyVariation){
+ System.out.println("Channel " + channel + ": Channel Variation exceeds maximum -- LVar: " + lOccuDiff + " RVar: " + rOccuDiff);
+ }
+ }
+ }
}