Author: [log in to unmask]
Date: Thu Aug 20 06:59:58 2015
New Revision: 3376
Log:
adding reader for new style gains file
Modified:
java/branches/ecal-branch-442/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java
Modified: java/branches/ecal-branch-442/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java
=============================================================================
--- java/branches/ecal-branch-442/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java (original)
+++ java/branches/ecal-branch-442/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java Thu Aug 20 06:59:58 2015
@@ -99,7 +99,58 @@
e.printStackTrace();
}
}
-
+
+ /**
+ * Read in a text file that has successive multiplicative factors on the
+ * original gain values. Number of columns is 2+N, where N is the number
+ * of iterations that have been done so far. The net multiplicative factor
+ * is the product of all columns after the first two. If there's only
+ * two columns, the net multiplicative factor will be 1.
+ *
+ * channel_id originalGain [multiplicativeGain1 [multiplicativeGain2] ... ]
+ */
+ private Map<Integer,Double> gainFileGains2 = new HashMap<Integer,Double>();
+ public String gainFileName2 = null;
+ private void readGainFile2()
+ {
+ gainFileGains.clear();
+ System.out.println("Reading ECal Gain Factors from: "+gainFileName);
+ File file = new File(gainFileName);
+ try {
+ FileReader reader = new FileReader(file);
+ char[] chars = new char[(int) file.length()];
+ reader.read(chars);
+ String content = new String(chars);
+ reader.close();
+ String lines[]=content.split("\n");
+ int nlines = 0;
+ for (String line : lines) {
+ String columns[] = line.split(" ");
+ if (nlines++ > 0) {
+ if (columns.length < 2) {
+ System.err.println("Insufficient columns in ECal Gain File.");
+ System.exit(2);
+ }
+ double gain=1;
+ for (int ii=2; ii<columns.length; ii++) {
+ gain *= Double.valueOf(columns[ii]);
+ }
+ final int channelid = Integer.valueOf(columns[0]);
+ if (gainFileGains2.containsKey(channelid)) {
+ System.err.println("Duplicate Entries in ECal Gain File.");
+ System.exit(2);
+ }
+ gainFileGains2.put(channelid,gain);
+ }
+ }
+ if (nlines != 442+1) {
+ System.err.println("Invalid Gain File.");
+ System.exit(3);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
@Override
public void detectorChanged(Detector detector) {
|