lcsim/sandbox/RobKutschke/TKNHits
diff -u -r1.7 -r1.8
--- ReadTKNRawHitsDriverV1.java 17 Nov 2007 00:36:00 -0000 1.7
+++ ReadTKNRawHitsDriverV1.java 20 Nov 2007 20:21:45 -0000 1.8
@@ -34,6 +34,7 @@
import org.lcsim.detector.DetectorIdentifierHelper;
import org.lcsim.contrib.SiStripSim.Kpix;
+import org.lcsim.contrib.SiStripSim.ReadoutChip;
import org.lcsim.detector.driver.SimTrackerHitIdentifierReadoutDriver;
import org.lcsim.contrib.RobKutschke.TKNHits.TKNRawHitsDriverV1;
@@ -51,9 +52,9 @@
* one of many possible organizations.
*
*@author $Author: kutschke $
- *@version $Id: ReadTKNRawHitsDriverV1.java,v 1.7 2007/11/17 00:36:00 kutschke Exp $
+ *@version $Id: ReadTKNRawHitsDriverV1.java,v 1.8 2007/11/20 20:21:45 kutschke Exp $
*
- * Date $Date: 2007/11/17 00:36:00 $
+ * Date $Date: 2007/11/20 20:21:45 $
*
* Notes:
*
@@ -104,6 +105,10 @@
// Printout limit control.
private int nprint = 0;
+ // Object that can interpret raw data to return charge, noise etc.
+ // Someday this will be (sub)detector dependent.
+ ReadoutChip readout = new Kpix();
+
/**
* Constructor:
* Add the necessary sub-drivers using super.
@@ -152,7 +157,7 @@
}
// Container to organize RawTrackerHits on each sensor.
- Map<SiSensor,Map<Integer,RawTrackerHit>> sensormap = new HashMap<SiSensor,Map<Integer,RawTrackerHit>>();
+ Map<SiSensor,Map<Integer,RawTrackerHit>> sensorhits = new HashMap<SiSensor,Map<Integer,RawTrackerHit>>();
// Loop over the raw hits.
for ( RawTrackerHit raw : rawhits ){
@@ -165,14 +170,17 @@
// See note 7.
SiTrackerIdentifierHelper helper = (SiTrackerIdentifierHelper)de.getIdentifierHelper();
+ // The pattern of strips or pixels is encoded within this class. See note 2.
+ SiSensorElectrodes electrode = sensor.getReadoutElectrodes(ChargeCarrier.HOLE);
+
// Hit strip.
int strip = helper.getStripValue(raw.getIdentifier());
// Get the charge on the strip in units of electrons.
- double charge = getChargeFromKPix( raw );
+ double charge = readout.decodeCharge(raw);
- // The pattern of strips or pixels is encoded within this class. See note 2.
- SiSensorElectrodes electrode = sensor.getReadoutElectrodes(ChargeCarrier.HOLE);
+ // The expected noise level on this strip, in units of electrons.
+ double noise = readout.getChannel(strip).computeNoise(electrode.getCapacitance(strip));
// Convert the strip number to positions in local and global coord.
Hep3Vector local = electrode.getCellPosition(strip);
@@ -234,6 +242,10 @@
aida.cloud1D("Strip number").fill(strip);
aida.cloud1D("Reconstructed local position (mm)").fill(meas_reco);
aida.histogram1D("Number of parent SimTrackerHits",30,0.,30.).fill(sims.size());
+ aida.cloud1D("Expected Noise",-1).fill(noise);
+ if ( noise > 0. ){
+ aida.cloud1D("Signal to Noise Ratio",-1).fill(charge/noise);
+ }
// The time field is not yet filled in; it is always zero.
aida.cloud1D("Time").fill(raw.getTime());
@@ -244,10 +256,10 @@
}
// Add this hit to the per sensor map. See note 6.
- Map<Integer,RawTrackerHit> rawmap = sensormap.get(sensor);
+ Map<Integer,RawTrackerHit> rawmap = sensorhits.get(sensor);
if ( rawmap == null ){
rawmap = new TreeMap<Integer,RawTrackerHit>();
- sensormap.put(sensor,rawmap);
+ sensorhits.put(sensor,rawmap);
}
if ( rawmap.get(strip) == null ){
rawmap.put(strip,raw);
@@ -261,15 +273,15 @@
} // loop over rawhits
// Inspect the organized collection.
- for ( SiSensor sensor: sensormap.keySet() ){
+ for ( SiSensor sensor: sensorhits.keySet() ){
// Histogram of the number of hits per sensor.
- aida.cloud1D("Hits per sensor").fill(sensormap.get(sensor).size());
+ aida.cloud1D("Hits per sensor").fill(sensorhits.get(sensor).size());
if ( nprint < 6 ){
// Hits on this sensor.
- Map<Integer,RawTrackerHit> rawmap = sensormap.get(sensor);
+ Map<Integer,RawTrackerHit> rawmap = sensorhits.get(sensor);
// This traverses strips in ascending order or strip number.
for ( Integer i : rawmap.keySet() ){
@@ -371,29 +383,4 @@
}
return tracker;
}
-
- /**
- *
- * Use the Kpix code to compute the charge on a strip, specified as
- * a RawTrackerHit. Tim says that this complexity will eventualy be wrapped
- * up so that users do not need to see it.
- *
- * For Kpix chips, the short[] return of getADCValues() is not actually an array
- * of adc values; it contains chip state information that includes the adc value
- * plus additional information.
- *
- * @return Charge on the strip in units of electrons.
- *
- */
- private double getChargeFromKPix( RawTrackerHit raw){
-
- short adc = raw.getADCValues()[1];
- Kpix.ControlRegisters control_registers =
- Kpix.ControlRegisters.decoded(raw.getADCValues()[0]);
- Kpix.KpixChannel.ReadoutRegisters readout_registers =
- Kpix.KpixChannel.ReadoutRegisters.decoded(raw.getADCValues()[1]);
- double charge = Kpix.computeCharge(readout_registers, control_registers);
- return charge;
- }
-
}