hps-java/src/main/java/org/lcsim/hps/recon/tracking
diff -u -r1.16 -r1.17
--- HPSSVTCalibrationConstants.java 15 Aug 2012 02:54:33 -0000 1.16
+++ HPSSVTCalibrationConstants.java 28 Aug 2012 07:11:08 -0000 1.17
@@ -15,21 +15,26 @@
/**
*
* @author Mathew Graham <[log in to unmask]>
- * $Id: HPSSVTCalibrationConstants.java,v 1.16 2012/08/15 02:54:33 omoreno Exp $
+ * $Id: HPSSVTCalibrationConstants.java,v 1.17 2012/08/28 07:11:08 omoreno Exp $
*/
public class HPSSVTCalibrationConstants {
// TODO: Change all pairs such that FPGA is the fist value
// TODO: Change all map keys to type SiSensor?
- public static Map<Pair<Integer /* Hybrid */, Integer /* FPGA */>, double[] /* constants */> noiseMap
+ private static Map<Pair<Integer /* Hybrid */, Integer /* FPGA */>, double[] /* constants */> noiseMap
= new HashMap<Pair<Integer, Integer>, double[]>();
- public static Map<Pair<Integer /* Hybrid */, Integer /* FPGA */>, double[] /* constants */> pedestalMap
+ private static Map<Pair<Integer /* Hybrid */, Integer /* FPGA */>, double[] /* constants */> pedestalMap
= new HashMap<Pair<Integer, Integer>, double[]>();
- public static Map<Pair<Integer /* Hybrid */, Integer /* FPGA */>, double[] /* constants */> tpMap
+ private static Map<Pair<Integer /* Hybrid */, Integer /* FPGA */>, double[] /* constants */> tpMap
= new HashMap<Pair<Integer, Integer>, double[]>();
- public static Map<Pair<Integer /* Hybrid */, Integer /* FPGA */>, Set<Integer> /* Bad channels */> badChannelMap
+ private static Map<Pair<Integer /* Hybrid */, Integer /* FPGA */>, Set<Integer> /* Bad channels */> badChannelMap
= new HashMap<Pair<Integer, Integer>, Set<Integer>>();
+ private static Map<Pair<Integer /* Hybrid */, Integer /* FPGA */>, List<Double> /* channels */> gainMap
+ = new HashMap<Pair<Integer, Integer>, List<Double>>();
+ private static Map<Pair<Integer /* Hybrid */, Integer /* FPGA */>, List<Double> /* channels */> offsetMap
+ = new HashMap<Pair<Integer, Integer>, List<Double>>();
+
private static boolean pedestalLoaded = false;
private static boolean tpLoaded = false;
private static int totalBadChannels = 0;
@@ -47,6 +52,7 @@
public static void loadCalibrationConstants(Date date, int runNumber){
loadCalibrationConstants(date);
loadBadChannels(runNumber);
+ loadGain();
}
public static void loadCalibrationConstants(Date date) {
@@ -235,7 +241,7 @@
*
* @param reader : character stream of type Reader
*/
- public static void loadBadChannels(Reader reader){
+ private static void loadBadChannels(Reader reader){
BufferedReader badChannelReader = new BufferedReader(reader);
String line = null;
@@ -260,6 +266,44 @@
}
}
+ /**
+ *
+ */
+ private static void loadGain(){
+
+ System.out.println("Loading SVT gains ...");
+
+ ConditionsManager conditions = ConditionsManager.defaultInstance();
+ BufferedReader gainReader;
+
+ String filePath = "calibSVT/svt_default.gain";
+ String line = null;
+ try{
+ gainReader = new BufferedReader(conditions.getRawConditions(filePath).getReader());
+ while((line = gainReader.readLine()) != null){
+ // If the line is a comment, skip it
+ if(line.indexOf("#") != -1) continue;
+ StringTokenizer stringTok = new StringTokenizer(line);
+ while(stringTok.hasMoreTokens()){
+ int fpga = Integer.valueOf(stringTok.nextToken());
+ int hybrid = Integer.valueOf(stringTok.nextToken());
+ int channel = Integer.valueOf(stringTok.nextToken());
+ double gain = Double.valueOf(stringTok.nextToken());
+ double offset = Double.valueOf(stringTok.nextToken());
+ Pair<Integer, Integer> daqPair = new Pair<Integer, Integer>(hybrid, fpga);
+ if(!gainMap.containsKey(daqPair))
+ gainMap.put(daqPair, new ArrayList<Double>());
+ gainMap.get(daqPair).add(channel, gain);
+ if(!offsetMap.containsKey(daqPair))
+ offsetMap.put(daqPair, new ArrayList<Double>());
+ offsetMap.get(daqPair).add(channel, offset);
+ }
+ }
+ } catch(IOException exception){
+ throw new RuntimeException("Unable to load gains!", exception);
+ }
+ }
+
public static Double getNoise(SiSensor sensor, int channel) {
Pair<Integer, Integer> daqPair = SvtUtils.getInstance().getDaqPair(sensor);
double[] noises = noiseMap.get(daqPair);
@@ -290,6 +334,20 @@
}
}
+ public static Double getGain(SiSensor sensor, int channel){
+ Pair<Integer, Integer> daqPair = SvtUtils.getInstance().getDaqPair(sensor);
+ List<Double> gain = gainMap.get(daqPair);
+ if(gain == null) return null;
+ else return gain.get(channel);
+ }
+
+ public static Double getOffset(SiSensor sensor, int channel){
+ Pair<Integer, Integer> daqPair = SvtUtils.getInstance().getDaqPair(sensor);
+ List<Double> offset = offsetMap.get(daqPair);
+ if(offset == null) return null;
+ else return offset.get(channel);
+ }
+
public static ChannelConstants getChannelConstants(SiSensor sensor, int channel) {
ChannelConstants constants = new ChannelConstants();