lcsim/src/org/lcsim/contrib/onoprien/tracking/digitization
diff -u -r1.1 -r1.2
--- DigitizationDriver.java 7 May 2007 19:02:42 -0000 1.1
+++ DigitizationDriver.java 10 May 2007 21:13:42 -0000 1.2
@@ -18,7 +18,7 @@
import org.lcsim.contrib.onoprien.tracking.hit.base.DigiTrackerHitComposite;
/**
- * Driver that handles conversion of {@link SimTrackerHit} objects collections
+ * Driver that handles conversion of {@link SimTrackerHit} objects collections
* found in a simulated event into a collection of {@link DigiTrackerHit}s.
*
* Lists of <tt>SimTrackerHits</tt> with names added through calls to {@link #addInputCollection(String)}
@@ -26,20 +26,20 @@
* lists found in the event will be processed.
*
* A mapping of {@link Sensor} objects to lists of created {@link DigiTrackerHit}s
- * will be added to the event after processing, with a name supplied through a call
+ * will be added to the event after processing, with a name supplied through a call
* to {@link #setOutputCollection(String)}.
*
- * {@link Digitizer} object that does the actual digitization has to be supplied
+ * {@link Digitizer} object that does the actual digitization has to be supplied
* in the constructor.
*
* @author D.Onoprienko
- * @version $Id: DigitizationDriver.java,v 1.1 2007/05/07 19:02:42 onoprien Exp $
+ * @version $Id: DigitizationDriver.java,v 1.2 2007/05/10 21:13:42 onoprien Exp $
*/
public class DigitizationDriver extends Driver {
-
+
// -- Constructors : ----------------------------------------------------------
-
- /**
+
+ /**
* Create digitization driver with the given <tt>Digitizer</tt> and the default
* distance cut of 200 microns.
*/
@@ -47,23 +47,23 @@
_digitizer = digitizer;
set("DISTANCE_CUT", 200.*Const.micrometer);
}
-
+
// -- Getters : ---------------------------------------------------------------
-
+
/** Set {@link Digitizer} object to be used by this driver. */
public Digitizer getDigitizer() {return _digitizer;}
-
+
// -- Setters : ---------------------------------------------------------------
-
+
/** Returns currently used {@link Digitizer} object. */
public void setDigitizer(Digitizer digitizer) {_digitizer = digitizer;}
-
+
/** Add a name of {@link SimTrackerHit} collection to be processed. */
public void addInputCollection(String name) {
if (_inListNames == null) _inListNames = new ArrayList<String>(5);
_inListNames.add(name);
}
-
+
/**
* Set the name for output map (<tt>HashMap<Sensor, ArrayList<DigiTrackerHit>></tt>)
* to be saved into the event.
@@ -71,13 +71,13 @@
public void setOutputCollection(String name) {
_outListName = name;
}
-
- /**
- * Set any <tt>double</tt> parameter.
+
+ /**
+ * Set any <tt>double</tt> parameter.
* The following parameters can be set with this method:<br>
* <tt>"DISTANCE_CUT"</tt> - Put <tt>SimTrackerHit</tt>s that are less than this
* distance apart and produced by the same <tt>MCParticle</tt>
- * into a group supplied in a single call to <tt>Digitizer</tt>.
+ * into a group supplied in a single call to <tt>Digitizer</tt>.
* Default: 200 microns.<br>
* @param name Name of parameter to be set (case is ignored).
* @param value Value to be assigned to the parameter.
@@ -94,7 +94,7 @@
}
// -- Processing event : ------------------------------------------------------
-
+
public void process(EventHeader event) {
// Process children if any
@@ -115,9 +115,11 @@
}
}
- // Create and fill output collection :
+ // Create output map :
HashMap<Sensor, ArrayList<DigiTrackerHit>> outMap = new HashMap<Sensor, ArrayList<DigiTrackerHit>>();
+
+ // Loop over input collectirons :
for (List<SimTrackerHit> hitList : collections) {
@@ -145,11 +147,11 @@
}
}
- // Call Digitizer for each group
-
+ // Call Digitizer for each group, add resulting digis to the output map
+
for (LinkedList<SimTrackerHit> group : groupList) {
List<DigiTrackerHit> digiGroup = _digitizer.digitize(group);
-
+
Sensor prevSensor = null;
ArrayList<DigiTrackerHit> digiList = null;
for (DigiTrackerHit digi : digiGroup) {
@@ -166,49 +168,52 @@
}
}
- // Combine and sort DigiTrackerHits in each list
-
- for (ArrayList<DigiTrackerHit> dList : outMap.values()) {
- Collections.sort(dList);
- DigiTrackerHit[] copy = dList.toArray(new DigiTrackerHit[dList.size()]);
- dList.clear();
- int previousChannel = -1;
- DigiTrackerHit previousHit = null;
- DigiTrackerHitComposite compHit = null;
- for (DigiTrackerHit hit : copy) {
- int channelID = hit.getChannel();
- if (channelID == previousChannel) {
- if (compHit == null) {
- compHit = new DigiTrackerHitComposite();
- compHit.addHit(previousHit);
- }
- compHit.addHit(hit);
+ } // end of loop over input collections
+
+ //System.out.println("Out map: keys "+ outMap.keySet().size() +" values "+ outMap.values().size());
+
+ // Combine and sort DigiTrackerHits in each list
+
+ for (ArrayList<DigiTrackerHit> dList : outMap.values()) {
+ Collections.sort(dList);
+ DigiTrackerHit[] copy = dList.toArray(new DigiTrackerHit[dList.size()]);
+ dList.clear();
+ int previousChannel = -1;
+ DigiTrackerHit previousHit = null;
+ DigiTrackerHitComposite compHit = null;
+ for (DigiTrackerHit hit : copy) {
+ int channelID = hit.getChannel();
+ if (channelID == previousChannel) {
+ if (compHit == null) {
+ compHit = new DigiTrackerHitComposite();
+ compHit.addHit(previousHit);
+ }
+ compHit.addHit(hit);
+ } else {
+ if (compHit == null) {
+ dList.add(previousHit);
} else {
- if (compHit == null) {
- dList.add(previousHit);
- } else {
- compHit.trimToSize();
- dList.add(compHit);
- compHit = null;
- }
+ compHit.trimToSize();
+ dList.add(compHit);
+ compHit = null;
}
- previousHit = hit;
- previousChannel = channelID;
}
- dList.trimToSize();
+ previousHit = hit;
+ previousChannel = channelID;
}
-
- // Put the map back into the event
-
- event.put(_outListName, outMap);
-
+ dList.trimToSize();
}
+
+ // Put the map back into the event
+
+ event.put(_outListName, outMap);
+
}
-
+
// -- Private parts : ---------------------------------------------------------
-
+
protected Digitizer _digitizer;
-
+
protected ArrayList<String> _inListNames;
protected String _outListName;
lcsim/src/org/lcsim/contrib/onoprien/tracking/digitization/digitizers
diff -u -r1.1 -r1.2
--- DigitizerSmear.java 7 May 2007 19:02:42 -0000 1.1
+++ DigitizerSmear.java 10 May 2007 21:13:42 -0000 1.2
@@ -24,7 +24,7 @@
* Creates one <tt>DigiTrackerHit</tt> per input <tt>SimTrackerHit</tt>.
*
* @author D.Onoprienko
- * @version $Id: DigitizerSmear.java,v 1.1 2007/05/07 19:02:42 onoprien Exp $
+ * @version $Id: DigitizerSmear.java,v 1.2 2007/05/10 21:13:42 onoprien Exp $
*/
public class DigitizerSmear implements Digitizer, ConditionsListener {
@@ -50,6 +50,8 @@
*/
public List<DigiTrackerHit> digitize(List<SimTrackerHit> hits) {
+ //System.out.println("call digitizer "+ hits.get(0).getSubdetector().getName() +" layer "+ hits.get(0).getLayer() +" hits "+ hits.size());
+
if (hits.isEmpty()) return new ArrayList<DigiTrackerHit>(1);
Sensor sensor = _segMan.getSensor(hits.get(0));
@@ -59,14 +61,13 @@
LinkedList<DigiTrackerHit> digiListTemp = new LinkedList<DigiTrackerHit>();
for (SimTrackerHit hit : hits) {
- digiListTemp.clear();
int channel = _segMan.getChannelID(sensor, hit);
if (channel < 1) break;
double time = hit.getTime();
double signal = hit.getdEdx()*hit.getPathLength();
digiListTemp.add(new DigiTrackerHitElemental(signal, time, sensor, channel, mcParticle));
}
-
+
// combine DigiTrackerHits with the same channel ID :
ArrayList<DigiTrackerHit> digiListFinal = new ArrayList<DigiTrackerHit>();
@@ -92,6 +93,7 @@
}
digiListFinal.trimToSize();
+ //System.out.println("Digitizer returns "+ digiListFinal.size() +" hits");
return digiListFinal;
}
lcsim/src/org/lcsim/contrib/onoprien/tracking/geom/sensortype
diff -u -r1.1 -r1.2
--- Cylinder.java 7 May 2007 19:02:42 -0000 1.1
+++ Cylinder.java 10 May 2007 21:13:42 -0000 1.2
@@ -11,7 +11,7 @@
* center of the cylinder.
*
* @author D.Onoprienko
- * @version $Id: Cylinder.java,v 1.1 2007/05/07 19:02:42 onoprien Exp $
+ * @version $Id: Cylinder.java,v 1.2 2007/05/10 21:13:42 onoprien Exp $
*/
public class Cylinder implements SensorType {
@@ -33,6 +33,7 @@
int nLength, int nPhi) {
_halfLength = length/2.;
_halfThick = thickness/2.;
+ _radius = radius;
_nDivV = nLength;
_nDivU = nPhi;
_pitch = TWOPI/_nDivU;
@@ -54,6 +55,7 @@
int nLength, double stripPitch) {
_halfLength = length/2.;
_halfThick = thickness/2.;
+ _radius = radius;
_nDivV = nLength;
_nDivU = (int) Math.round((TWOPI*radius)/stripPitch);
_pitch = TWOPI/_nDivU;
@@ -75,6 +77,7 @@
double stripLength, double stripPitch) {
_halfLength = length/2.;
_halfThick = thickness/2.;
+ _radius = radius;
_nDivV = (int) Math.round(length/stripLength);
_nDivU = (int) Math.round((TWOPI*radius)/stripPitch);
_pitch = TWOPI/_nDivU;
@@ -94,7 +97,9 @@
*/
public int getChannelID(Hep3Vector point) {
- if (Math.abs(point.z()) > _halfThick) return -1;
+ //System.out.println("Point: phi "+ point.x() +" z "+ point.y() +" r "+ point.z());
+
+ if (Math.abs(point.z()-_radius) > _halfThick) return -1;
double u = point.x();
double v = point.y();
@@ -145,6 +150,7 @@
protected double _halfLength;
protected double _halfThick;
+ protected double _radius;
protected double _pitch;
protected double _length;
lcsim/src/org/lcsim/contrib/onoprien/tracking/transform
diff -u -r1.1 -r1.2
--- CartesianToCylindrical.java 7 May 2007 19:02:44 -0000 1.1
+++ CartesianToCylindrical.java 10 May 2007 21:13:42 -0000 1.2
@@ -9,7 +9,7 @@
* (x,y,z) --> (phi,z,ro).
*
* @author D.Onoprienko
- * @version $Id: CartesianToCylindrical.java,v 1.1 2007/05/07 19:02:44 onoprien Exp $
+ * @version $Id: CartesianToCylindrical.java,v 1.2 2007/05/10 21:13:42 onoprien Exp $
*/
public class CartesianToCylindrical implements Transformation3D {
@@ -27,7 +27,7 @@
public Hep3Vector transformTo(Hep3Vector point) {
double x = point.x();
double y = point.y();
- return new BasicHep3Vector(Math.atan2(y,x), point.z(), Math.hypot(x,y));
+ return new BasicHep3Vector(Math.atan2(y,x) + Math.PI, point.z(), Math.hypot(x,y));
}
/**