hps-java/src/main/java/org/lcsim/hps/monitoring/ecal
diff -u -r1.3 -r1.4
--- EcalDaqPlots.java 2 May 2012 00:39:40 -0000 1.3
+++ EcalDaqPlots.java 2 May 2012 14:55:52 -0000 1.4
@@ -27,6 +27,7 @@
private AIDA aida;
private Detector detector;
private List<IHistogram1D> plots;
+ private static final short[] slots = {10, 13, 9, 14, 8, 15, 7, 16, 6, 17, 5, 18, 4, 19};
public EcalDaqPlots() {
}
@@ -71,7 +72,7 @@
for (int i = 0; i < 14; i++) { // slot
for (int j = 1; j < 3; j++) { // crate
//System.out.println("creating plot: " + "ECAL: Crate " + j + "; Slot " + i + " in region " + region);
- IHistogram1D hist = aida.histogram1D("ECAL: Crate " + j + "; Slot " + i, 16, 0, 16);
+ IHistogram1D hist = aida.histogram1D("ECAL: Crate " + j + "; Slot " + slots[i], 16, 0, 16);
plots.add(hist);
plotter.region(region).plot(hist);
JASHist jhist = ((PlotterRegion) plotter.region(region)).getPlot();
hps-java/src/main/java/org/lcsim/hps/evio
diff -u -r1.9 -r1.10
--- ECalEvioReader.java 2 May 2012 13:20:41 -0000 1.9
+++ ECalEvioReader.java 2 May 2012 14:55:52 -0000 1.10
@@ -17,7 +17,7 @@
/**
*
* @author Sho Uemura <[log in to unmask]>
- * @version $Id: ECalEvioReader.java,v 1.9 2012/05/02 13:20:41 meeg Exp $
+ * @version $Id: ECalEvioReader.java,v 1.10 2012/05/02 14:55:52 meeg Exp $
*/
public class ECalEvioReader extends EvioReader {
// Names of subdetectors.
@@ -123,9 +123,6 @@
for (int i = 0; i < nSamples; i++) {
adcValues[i] = cdata.getShort();
}
-// if (debug) {
-// System.out.println(" pulseTime=" + pulseTime + "; pulseIntegral=" + pulseIntegral);
-// }
hits.add(new BaseRawTrackerHit(id, 0, adcValues));
}
} catch (IndexOutOfBoundsException e) {
@@ -148,34 +145,37 @@
}
}
- int crate = bankTag;
- short slot = cdata.getByte();
- int trigger = cdata.getInt();
- long timestamp = cdata.getLong();
- int nchannels = cdata.getNValue();
- if (debug) {
- System.out.println("slot#=" + slot + "; trigger=" + trigger + "; timestamp=" + timestamp + "; nchannels=" + nchannels);
- }
- for (int j = 0; j < nchannels; j++) {
- short channel = cdata.getByte();
- int npulses = cdata.getNValue();
- if (debug) {
- System.out.println(" channel=" + channel + "; npulses=" + npulses);
- }
- long daqID = HPSEcalConditions.getDaqID(crate, slot, channel);
- Long id = HPSEcalConditions.daqToPhysicalID(daqID);
-
- for (int k = 0; k < npulses; k++) {
- short pulseNum = cdata.getByte();
- int sampleCount = cdata.getNValue();
- short[] adcValues = new short[sampleCount];
- for (int i = 0; i < sampleCount; i++) {
- adcValues[i] = cdata.getShort();
- }
-// if (debug) {
-// System.out.println(" pulseTime=" + pulseTime + "; pulseIntegral=" + pulseIntegral);
-// }
- hits.add(new BaseRawTrackerHit(id, pulseNum, adcValues));
+ while (true) {
+ try {
+ int crate = bankTag;
+ short slot = cdata.getByte();
+ int trigger = cdata.getInt();
+ long timestamp = cdata.getLong();
+ int nchannels = cdata.getNValue();
+ if (debug) {
+ System.out.println("slot#=" + slot + "; trigger=" + trigger + "; timestamp=" + timestamp + "; nchannels=" + nchannels);
+ }
+ for (int j = 0; j < nchannels; j++) {
+ short channel = cdata.getByte();
+ int npulses = cdata.getNValue();
+ if (debug) {
+ System.out.println(" channel=" + channel + "; npulses=" + npulses);
+ }
+ long daqID = HPSEcalConditions.getDaqID(crate, slot, channel);
+ Long id = HPSEcalConditions.daqToPhysicalID(daqID);
+
+ for (int k = 0; k < npulses; k++) {
+ short pulseNum = cdata.getByte();
+ int sampleCount = cdata.getNValue();
+ short[] adcValues = new short[sampleCount];
+ for (int i = 0; i < sampleCount; i++) {
+ adcValues[i] = cdata.getShort();
+ }
+ hits.add(new BaseRawTrackerHit(id, pulseNum, adcValues));
+ }
+ }
+ } catch (IndexOutOfBoundsException e) {
+ break;
}
}
return hits;
@@ -194,30 +194,36 @@
}
}
- int crate = bankTag;
- short slot = cdata.getByte();
- int trigger = cdata.getInt();
- long timestamp = cdata.getLong();
- int nchannels = cdata.getNValue();
- if (debug) {
- System.out.println("slot#=" + slot + "; trigger=" + trigger + "; timestamp=" + timestamp + "; nchannels=" + nchannels);
- }
- for (int j = 0; j < nchannels; j++) {
- short channel = cdata.getByte();
- int npulses = cdata.getNValue();
- if (debug) {
- System.out.println(" channel=" + channel + "; npulses=" + npulses);
- }
- long daqID = HPSEcalConditions.getDaqID(crate, slot, channel);
- Long id = HPSEcalConditions.daqToPhysicalID(daqID);
-
- for (int k = 0; k < npulses; k++) {
- short pulseTime = cdata.getShort();
- int pulseIntegral = cdata.getInt();
+ while (true) {
+ try {
+ int crate = bankTag;
+ short slot = cdata.getByte();
+ int trigger = cdata.getInt();
+ long timestamp = cdata.getLong();
+ int nchannels = cdata.getNValue();
if (debug) {
- System.out.println(" pulseTime=" + pulseTime + "; pulseIntegral=" + pulseIntegral);
+ System.out.println("slot#=" + slot + "; trigger=" + trigger + "; timestamp=" + timestamp + "; nchannels=" + nchannels);
}
- hits.add(new BaseRawCalorimeterHit(id, pulseIntegral, pulseTime));
+ for (int j = 0; j < nchannels; j++) {
+ short channel = cdata.getByte();
+ int npulses = cdata.getNValue();
+ if (debug) {
+ System.out.println(" channel=" + channel + "; npulses=" + npulses);
+ }
+ long daqID = HPSEcalConditions.getDaqID(crate, slot, channel);
+ Long id = HPSEcalConditions.daqToPhysicalID(daqID);
+
+ for (int k = 0; k < npulses; k++) {
+ short pulseTime = cdata.getShort();
+ int pulseIntegral = cdata.getInt();
+ if (debug) {
+ System.out.println(" pulseTime=" + pulseTime + "; pulseIntegral=" + pulseIntegral);
+ }
+ hits.add(new BaseRawCalorimeterHit(id, pulseIntegral, pulseTime));
+ }
+ }
+ } catch (IndexOutOfBoundsException e) {
+ break;
}
}
return hits;
hps-java/src/main/java/org/lcsim/hps/recon/ecal
diff -u -r1.1 -r1.2
--- HPSEcalConditions.java 2 May 2012 00:39:40 -0000 1.1
+++ HPSEcalConditions.java 2 May 2012 14:55:52 -0000 1.2
@@ -4,17 +4,17 @@
import org.lcsim.geometry.Subdetector;
import java.io.IOException;
import java.io.Reader;
-import java.io.StreamTokenizer;
import java.util.HashMap;
import java.util.StringTokenizer;
import org.lcsim.conditions.ConditionsManager;
-import org.lcsim.geometry.util.IDEncoder;
-import static org.lcsim.hps.evio.EventConstants.ECAL_LAYER;
+import org.lcsim.detector.identifier.ExpandedIdentifier;
+import org.lcsim.detector.identifier.IExpandedIdentifier;
+import org.lcsim.detector.identifier.IIdentifierHelper;
/**
*
* @author meeg
- * @version $Id: HPSEcalConditions.java,v 1.1 2012/05/02 00:39:40 meeg Exp $
+ * @version $Id: HPSEcalConditions.java,v 1.2 2012/05/02 14:55:52 meeg Exp $
*/
public class HPSEcalConditions {
@@ -26,7 +26,7 @@
private static HashMap<Long, Integer> daqToPedestalMap = new HashMap<Long, Integer>();
private static HashMap<Long, Double> daqToNoiseMap = new HashMap<Long, Double>();
private static boolean pedestalsLoaded = false;
-
+
private HPSEcalConditions() {
}
@@ -42,9 +42,9 @@
ConditionsManager conditions = ConditionsManager.defaultInstance();
try {
Reader pedestalsReader = conditions.getRawConditions("calibECal/fadc01.ped").getReader();
- loadPedestals(pedestalsReader,1);
+ loadPedestals(pedestalsReader, 1);
pedestalsReader = conditions.getRawConditions("calibECal/fadc02.ped").getReader();
- loadPedestals(pedestalsReader,2);
+ loadPedestals(pedestalsReader, 2);
} catch (IOException e) {
throw new RuntimeException("couldn't get pedestals file", e);
}
@@ -71,7 +71,7 @@
StringTokenizer lineTok = new StringTokenizer(line);
if (lineTok.countTokens() != 0) {
- if (lineTok.countTokens() != 5) {
+ if (lineTok.countTokens() != 4) {
throw new RuntimeException("Invalid line in pedestals file: " + line);
} else {
short slot = Short.valueOf(lineTok.nextToken());
@@ -88,47 +88,51 @@
public static void fillDaqCellMap(Subdetector ecal) {
System.out.println("reading DAQ map");
-
- IDEncoder enc = new IDEncoder(ecal.getIDDecoder().getIDDescription());
- enc.setValue("system", ecal.getSystemID());
- enc.setValue("layer", ECAL_LAYER);
+
+ IIdentifierHelper helper = ecal.getDetectorElement().getIdentifierHelper();
+ IExpandedIdentifier expId = new ExpandedIdentifier(helper.getIdentifierDictionary().getNumberOfFields());
+ expId.setValue(helper.getFieldIndex("system"), ecal.getSystemID());
ConditionsManager conditions = ConditionsManager.defaultInstance();
- StreamTokenizer tok = null;
+ BufferedReader bufferedPedestals;
try {
- tok = new StreamTokenizer(conditions.getRawConditions("daqmap/ecal.txt").getReader());
+ bufferedPedestals = new BufferedReader(conditions.getRawConditions("daqmap/ecal.txt").getReader());
} catch (IOException e) {
throw new RuntimeException("couldn't get DAQ map from conditions manager", e);
}
- tok.commentChar('#');
- tok.eolIsSignificant(false);
- tok.parseNumbers();
- try {
- while (tok.nextToken() != StreamTokenizer.TT_EOF) {
- tok.pushBack();
- int x = (int) getNumber(tok);
- int y = (int) getNumber(tok);
- enc.setValue("ix", x);
- enc.setValue("iy", y);
- int crate = (int) getNumber(tok);
- short slot = (short) getNumber(tok);
- short channel = (short) getNumber(tok);
- addMapEntry(enc.getID(), getDaqID(crate, slot, channel));
-// System.out.printf("x = %d, y = %d, crate = %d, slot = %d, channel = %d\n", x, y, crate, slot, channel);
-// System.out.printf("physicalID = %d, daqID = %d\n",enc.getID(), getDaqID(crate, slot, channel));
+ String line;
+ while (true) {
+ try {
+ line = bufferedPedestals.readLine();
+ } catch (IOException e) {
+ throw new RuntimeException("couldn't parse ECal DAQ map", e);
}
- } catch (IOException e) {
- throw new RuntimeException("couldn't parse DAQ map", e);
- }
- mapLoaded = true;
- }
+ if (line == null) {
+ break;
+ }
+
+ if (line.indexOf("#") != -1) {
+ line = line.substring(0, line.indexOf("#"));
+ }
+
+ StringTokenizer lineTok = new StringTokenizer(line);
- private static double getNumber(StreamTokenizer tok) throws IOException {
- if (tok.nextToken() == StreamTokenizer.TT_NUMBER) {
- return tok.nval;
- } else {
- throw new IOException("expected an int from DAQ map, instead got " + tok);
+ if (lineTok.countTokens() != 0) {
+ if (lineTok.countTokens() != 5) {
+ throw new RuntimeException("Invalid line in ECal DAQ map: " + line);
+ } else {
+ int x = Integer.valueOf(lineTok.nextToken());
+ int y = Integer.valueOf(lineTok.nextToken());
+ expId.setValue(helper.getFieldIndex("ix"), x);
+ expId.setValue(helper.getFieldIndex("iy"), y);
+ int crate = Integer.valueOf(lineTok.nextToken());
+ short slot = Short.valueOf(lineTok.nextToken());
+ short channel = Short.valueOf(lineTok.nextToken());
+ addMapEntry(helper.pack(expId).getValue(), getDaqID(crate, slot, channel));
+ }
+ }
}
+ mapLoaded = true;
}
private static void addMapEntry(long physicalID, long daqID) {