Commit in GeomConverter/src/org/lcsim/detector/tracker/silicon on MAIN | |||
HpsSiSensor.java | +309 | added 1.1 |
add new SVT sensor class for HPS
diff -N HpsSiSensor.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HpsSiSensor.java 10 Oct 2013 01:42:28 -0000 1.1 @@ -0,0 +1,309 @@
+package org.lcsim.detector.tracker.silicon; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.lcsim.detector.IDetectorElement; +import org.lcsim.detector.identifier.IExpandedIdentifier; +import org.lcsim.detector.identifier.IIdentifier; +import org.lcsim.detector.identifier.IIdentifierHelper; + +/** + * This class extends {@link SiSensor} with HPS-specific functionality. Since there are + * a large number of extra parameters that would need to be included in a fully + * qualified class constructor, public setters are used instead. + * @author Jeremy McCormick <[log in to unmask]> + */ +public class HpsSiSensor extends SiSensor { + + // Sensor setup information. + int fpga; + int hybrid; + int layer; + int nchannels; + boolean top; + boolean axial; + + // Time variable conditions data. + Map<Integer,Double> pedestalMap = new HashMap<Integer,Double>(); + Map<Integer,Double> noiseMap = new HashMap<Integer,Double>(); + Map<Integer,Double> offsetMap = new HashMap<Integer,Double>(); + Map<Integer,Double> t0Map = new HashMap<Integer,Double>(); + Map<Integer,Double[]> pulseParameterMap = new HashMap<Integer,Double[]>(); + Set<Integer> badChannels = new HashSet<Integer>(); + + private static final boolean debug = true; + + /** + * This class constructor matches that of <code>SiSensor</code>. + * @param sensorid The sensor ID. + * @param name The name of the sensor. + * @param parent The parent DetectorElement. + * @param support The physical support path. + * @param id The identifier of the sensor. + */ + public HpsSiSensor( + int sensorid, + String name, + IDetectorElement parent, + String support, + IIdentifier id) + { + super(sensorid, name, parent, support, id); + if (debug) + System.out.println("created HpsSiSensor: " + name); + } + + /** + * Get whether this sensor is in a top layer. + * @return True if sensor is in top layer; false if not. + */ + public boolean isTopLayer() { + return top; + } + + /** + * Get whether this sensor is in a bottom layer. + * @return True if sensor is in bottom layer; false if not. + */ + public boolean isBottomLayer() { + return top == false; + } + + /** + * Get whether this sensor is axial. + * @return True if sensor is axial; false if not. + */ + public boolean isAxial() { + return axial; + } + + /** + * Get the pedestal for the given channel. + * @param channel The channel number. + * @return The pedestal value for the channel or null if not set. + */ + public Double getPedestal(int channel) { + return pedestalMap.get(channel); + } + + /** + * Get the noise for the given channel. + * @param channel The channel number. + * @return The noise value for the channel or null if not set. + */ + public Double getNoise(int channel) { + return noiseMap.get(channel); + } + + /** + * Get the time offset for the given channel. + * @param channel The channel number. + * @return The time offset for the channel or null if not set. + */ + public Double getTimeOffset(int channel) { + return offsetMap.get(channel); + } + + /** + * Get the t0 value for the given channel. + * @param channel The channel number. + * @return The t0 value for the channel or null if not set. + */ + public Double getT0(int channel) { + return t0Map.get(channel); + } + + /** + * Get the pulse parameters for the given channel. + * @param channel The channel number. + * @return The pulse parameters for the channel. + */ + public Double[] getPulseParameters(int channel) { + return pulseParameterMap.get(channel); + } + + /** + * Get whether the given channel is bad or not. + * @param channel The channel number. + * @return True if channel is bad; false if not. + */ + public boolean isBadChannel(int channel) { + return badChannels.contains(channel); + } + + /** + * Get the total number of channels in the sensor. + * @return The total number of channels in the sensor. + */ + public int getNumberOfChannels() { + return nchannels; + } + + /** + * Get whether the given channel number if valid. + * @param channel The channel number. + * @return True if channel number is valid; false if not. + */ + public boolean isValidChannel(int channel) { + return channel >= 0 && channel < nchannels; + } + + /** + * Get the FPGA number of the sensor. + * @return The FPGA number of the sensor. + */ + public int getFpgaNumber() { + return fpga; + } + + /** + * Get the hybrid number of the sensor. + * @return The hybrid number of the sensor. + */ + public int getHybridNumber() { + return hybrid; + } + + /** + * Get the layer number of the sensor. + * @return The layer number of the sensor. + */ + public int getLayerNumber() { + return layer; + } + + /** + * Create an identifier for a channel. + * @param channel The channel number. + * @return The identifier for the channel. + */ + public long makeChannelId(int channel) { + IIdentifierHelper helper = getIdentifierHelper(); + IIdentifier id = getIdentifier(); + IExpandedIdentifier expId = helper.unpack(id); + int idx = helper.getIdentifierDictionary().getFieldIndex("channel"); + expId.setValue(idx, channel); + return helper.pack(expId).getValue(); + } + + /** + * Set this sensor as being in the top layer or not. + * If this is set to false, then it is assumed to be in the bottom layer. + * @param top The top layer setting. + */ + public void setTopLayer(boolean top) { + this.top = top; + } + + /** + * Set whether or not this sensor is axial. + * @param axial The axial setting. + */ + public void setAxial(boolean axial) { + this.axial = axial; + } + + /** + * Set the pedestal value for the given channel. + * @param channel The channel number. + * @param pedestal The pedestal value. + */ + public void setPedestal(int channel, double pedestal) { + pedestalMap.put(channel, pedestal); + } + + /** + * Set the noise value for the given channel. + * @param channel The channel number. + * @param noise The noise value. + */ + public void setNoise(int channel, double noise) { + noiseMap.put(channel, noise); + } + + /** + * Set the time offset for the given channel. + * @param channel The channel number. + * @param offset The offset value. + */ + public void setTimeOffset(int channel, double offset) { + offsetMap.put(channel, offset); + } + + /** + * Set the t0 value for the given channel. + * @param channel The channel number. + * @param t0 The t0 value. + */ + public void setT0(int channel, double t0) { + t0Map.put(channel, t0); + } + + /** + * Set the pulse parameters for the given channel. + * @param channel The channel number. + * @param pulseParameters The pulse parameters array (should be length 4). + */ + public void setPulseParameters(int channel, Double[] pulseParameters) { + if (pulseParameters.length != 4) + throw new IllegalArgumentException("PulseParameters is wrong length: " + pulseParameters.length); + pulseParameterMap.put(channel, pulseParameters); + } + + /** + * Flag the given channel as bad. + * @param channel The channel number. + */ + public void setBadChannel(int channel) { + badChannels.add(channel); + } + + /** + * Set the number of channels in this sensor. + * @param nchannels The number of channels in the sensor. + */ + public void setNumberOfChannels(int nchannels) { + this.nchannels = nchannels; + } + + /** + * Set the FPGA number of the sensor. + * @param fpga The FPGA number. + */ + public void setFpgaNumber(int fpga) { + this.fpga = fpga; + } + + /** + * Set the hybrid number of the sensor. + * @param hybrid The hybrid number. + */ + public void setHybridNumber(int hybrid) { + this.hybrid = hybrid; + } + + /** + * Set the layer number of the sensor. + * @param layer The layer number. + */ + public void setLayerNumber(int layer) { + this.layer = layer; + } + + /** + * Reset the time dependent conditions of this sensor. + * This does NOT reset the sensor setup information, which is + * assumed to be fixed once set. + */ + public void reset() { + pedestalMap.clear(); + noiseMap.clear(); + offsetMap.clear(); + t0Map.clear(); + pulseParameterMap.clear(); + badChannels.clear(); + } +}
\ 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