lcsim/src/org/lcsim/contrib/onoprien/crux
diff -u -r1.2 -r1.3
--- CruxConfig.java 2 Dec 2008 23:56:07 -0000 1.2
+++ CruxConfig.java 5 Dec 2008 00:05:30 -0000 1.3
@@ -3,9 +3,6 @@
import java.util.*;
import hep.physics.vec.Hep3Vector;
-import org.lcsim.contrib.onoprien.crux.geom.CalLayer;
-import org.lcsim.contrib.onoprien.crux.geom.CalModule;
-import org.lcsim.contrib.onoprien.crux.infrastructure.*;
import org.lcsim.detector.IDetectorElement;
import org.lcsim.detector.IDetectorElementVisitor;
import org.lcsim.event.CalorimeterHit;
@@ -23,6 +20,9 @@
import org.lcsim.contrib.onoprien.util.swim.ZCylinder;
import org.lcsim.contrib.onoprien.crux.geom.CalGeometryConfig;
+import org.lcsim.contrib.onoprien.crux.geom.CalLayer;
+import org.lcsim.contrib.onoprien.crux.geom.CalModule;
+import org.lcsim.contrib.onoprien.crux.infrastructure.*;
import static org.lcsim.contrib.onoprien.crux.geom.CalModule.Attribute.*;
@@ -45,15 +45,14 @@
* </ul>
*
* @author D. Onoprienko
- * @version $Id: CruxConfig.java,v 1.2 2008/12/02 23:56:07 onoprien Exp $
+ * @version $Id: CruxConfig.java,v 1.3 2008/12/05 00:05:30 onoprien Exp $
*/
public class CruxConfig implements JobEventListener, CalGeometryConfig {
// -- Constructors : ----------------------------------------------------------
- protected CruxConfig(CruxManager cruxMan) {
+ public CruxConfig() {
- _cruxMan = cruxMan;
JobManager.defaultInstance().addListener(this);
digiHitColNamesConstruct();
@@ -230,6 +229,4 @@
// -- Private parts : ---------------------------------------------------------
- protected CruxManager _cruxMan;
-
}
lcsim/src/org/lcsim/contrib/onoprien/crux/auxdrivers
diff -u -r1.3 -r1.4
--- HitMapFilterDriver.java 2 Dec 2008 23:56:08 -0000 1.3
+++ HitMapFilterDriver.java 5 Dec 2008 00:05:30 -0000 1.4
@@ -25,7 +25,7 @@
* used by the filter to look up hits by their <tt>CellID</tt>.
*
* @author D. Onoprienko
- * @version $Id: HitMapFilterDriver.java,v 1.3 2008/12/02 23:56:08 onoprien Exp $
+ * @version $Id: HitMapFilterDriver.java,v 1.4 2008/12/05 00:05:30 onoprien Exp $
*/
public class HitMapFilterDriver extends Driver {
@@ -54,12 +54,13 @@
* <tt>Map<Long,CalorimeterHit></tt> or <tt>Collection<CalorimeterHit></tt>.
* Several collections can be excluded either by calling this method several times,
* or by providing several names in a single call.</dd>
- * <dt>"OUTPUT"</dt> <dd>The first value is the {@link CruxHitFilter} object to be used for
- * filtering the input collection. If <tt>null</tt>, no filtering will be applied.<br>
- * The second value is the name under which the output resulting from this filter's
- * application should be saved into the event record.<br>
+ * <dt>"OUTPUT"</dt> <dd>The first value is the name under which the output collection should
+ * be saved into the event record.<br> The second value is the {@link CruxHitFilter} object
+ * to be used for filtering - only hits that pass the filter will be added to this
+ * output collection. If <tt>null</tt>, no filtering will be applied.<br>
* The third value is either "MAP" or "LIST", depending on whether the output
* should be a {@link CruxHitMap} or an <tt>ArrayList<CalorimeterHit></tt>.<br>
+ * Filter and output type arguments can be omitted (no filtering and "MAP" output are assumed).<br>
* Several output collections can be created, each with its own filter, by calling
* this method repeatedly.</dd>
* <dt>"ID_TO_HIT_MAP"</dt> <dd>Name of the map (of type <tt>Map<Long,CalorimeterHit></tt>)
@@ -86,27 +87,21 @@
}
_excludeNames.trimToSize();
} else if (name.equalsIgnoreCase("OUTPUT")) {
- if (values.length != 3) throw new IllegalArgumentException(ERR_INV + name);
- int nOut = _outNames.length;
- CruxHitFilter[] tempFilters = new CruxHitFilter[nOut+1];
- String[] tempNames = new String[nOut+1];
- boolean[] tempMap = new boolean[nOut+1];
- System.arraycopy(_filters, 0, tempFilters, 0, nOut);
- System.arraycopy(_outNames, 0, tempNames, 0, nOut);
- System.arraycopy(_isMap, 0, tempMap, 0, nOut);
- tempFilters[nOut] = (values[0] == null) ? null : (CruxHitFilter) values[0];
- tempNames[nOut] = (String) values[1];
- String isMap = (String) values[2];
- if (isMap.equalsIgnoreCase("MAP")) {
- tempMap[nOut] = true;
- } else if (isMap.equalsIgnoreCase("LIST")) {
- tempMap[nOut] = false;
+ if (values.length > 3 || values.length < 1) throw new IllegalArgumentException(ERR_INV + name);
+ _outNames.add((String)(values[0]));
+ if (values.length > 1) {
+ _filters.add((CruxHitFilter)(values[1]));
} else {
- throw new IllegalArgumentException("Output type should be either MAP or LIST");
+ _filters.add(null);
}
- _filters = tempFilters;
- _outNames = tempNames;
- _isMap = tempMap;
+ if (values.length > 2) {
+ _isMap.add((Boolean)(values[2]));
+ } else {
+ _isMap.add(true);
+ }
+ _outNames.trimToSize();
+ _filters.trimToSize();
+ _isMap.trimToSize();
} else if (name.equalsIgnoreCase("ID_TO_HIT_MAP")) {
_defMapName = (String) value;
} else {
@@ -126,7 +121,7 @@
// Create lists for output collections
- int nOut = _filters.length;
+ int nOut = _filters.size();
if (nOut == 0) {
log("No output collections specified", Level.WARNING);
return;
@@ -139,7 +134,7 @@
Map<Long, CalorimeterHit> defMap = (_defMapName == null) ? null : (Map<Long, CalorimeterHit>) event.get(_defMapName);
if (defMap != null) {
for (int i=0; i<nOut; i++) {
- CruxHitFilter filter = _filters[i];
+ CruxHitFilter filter = _filters.get(i);
if (filter != null) filter.setHitMap(defMap);
}
}
@@ -197,7 +192,7 @@
for (CalorimeterHit hit : inCol) {
if (excludeSet == null || (! excludeSet.contains(hit))) {
for (int out=0; out<nOut; out++) {
- CruxHitFilter filter = _filters[out];
+ CruxHitFilter filter = _filters.get(out);
boolean accept = (filter == null) ? true : filter.pass(hit);
if (accept) outSets.get(out).add(hit);
}
@@ -207,15 +202,15 @@
// Save output collections
- for (int out=0; out<_filters.length; out++) {
- CruxHitFilter filter = _filters[out];
+ for (int out=0; out<_filters.size(); out++) {
+ CruxHitFilter filter = _filters.get(out);
if (filter != null) filter.setHitMap(null);
HashSet<CalorimeterHit> outSet = outSets.get(out);
Object old = null;
try {
- old = event.get(_outNames[out]);
+ old = event.get(_outNames.get(out));
} catch (IllegalArgumentException x) {}
- if (_isMap[out]) {
+ if (_isMap.get(out)) {
CruxHitMap outMap;
if (old == null) {
outMap = new CruxHitMap( (int) (1.5 * outSet.size()) );
@@ -232,7 +227,7 @@
}
}
outMap.add(outSet);
- event.put(_outNames[out], outMap);
+ event.put(_outNames.get(out), outMap);
} else {
if (old != null) {
try {
@@ -243,7 +238,7 @@
}
}
ArrayList<CalorimeterHit> outputList = new ArrayList<CalorimeterHit>(outSet);
- event.put(_outNames[out], outputList, CalorimeterHit.class, 0);
+ event.put(_outNames.get(out), outputList, CalorimeterHit.class, 0);
}
}
@@ -252,15 +247,15 @@
// -- Private parts : ---------------------------------------------------------
- protected ArrayList<String> _inNames = new ArrayList<String>(1);
+ private ArrayList<String> _inNames = new ArrayList<String>(1);
- protected ArrayList<String> _excludeNames = new ArrayList<String>(0);
+ private ArrayList<String> _excludeNames = new ArrayList<String>(0);
- protected CruxHitFilter[] _filters = new CruxHitFilter[0];
- protected String[] _outNames = new String[0];
- protected boolean[] _isMap = new boolean[0];
+ private ArrayList<CruxHitFilter> _filters = new ArrayList<CruxHitFilter>(0);
+ private ArrayList<String> _outNames = new ArrayList<String>(0);
+ private ArrayList<Boolean> _isMap = new ArrayList<Boolean>(0);
- protected String _defMapName;
+ private String _defMapName;
private String _err1 = "Requested output type is inconsistent with identically named existing collection";
}
lcsim/src/org/lcsim/contrib/onoprien/crux/geom
diff -u -r1.1 -r1.2
--- CalModule.java 25 Nov 2008 21:17:00 -0000 1.1
+++ CalModule.java 5 Dec 2008 00:05:30 -0000 1.2
@@ -8,9 +8,8 @@
/**
* Class to represent a part of the calorimeter.
*
- *
* @author D. Onoprienko
- * @version $Id: CalModule.java,v 1.1 2008/11/25 21:17:00 onoprien Exp $
+ * @version $Id: CalModule.java,v 1.2 2008/12/05 00:05:30 onoprien Exp $
*/
public class CalModule {
@@ -32,14 +31,17 @@
// -- Getters : ---------------------------------------------------------------
+ /** Returns module ID - unique within the detector. */
public int getID() {
return _id;
}
+ /** Returns module name - unique within the detector. */
public String getName() {
return _name;
}
+ /** Returns set of attributes associated with this module. */
public EnumSet<Attribute> getAttributes() {
return _attributes;
}
@@ -76,10 +78,17 @@
return _sdName;
}
+ /** Returns an unmodifiable list of layer objects in this module. */
public List<CalLayer> getLayers() {
return Collections.unmodifiableList(_layers);
}
+
+ /**
+ * Look up layer object in this module by its ordinal number.
+ * Layers in a module are numbered from 0, from inside to outside.
+ * Throws <tt>IndexOutOfBoundsException</tt> if the specified layer ordinal is out of bounds.
+ */
public CalLayer getLayerByOrdinal(int ordinal) {
try {
return _layers.get(ordinal);
@@ -88,11 +97,21 @@
}
}
+ /**
+ * Look up layer object in this module by its layer number as reported by {@link IDDecoder}.
+ * Throws <tt>IndexOutOfBoundsException</tt> if there is no layer with the specified
+ * number in this module.
+ */
public CalLayer getLayerByNumber(int layerNumber) {
int ordinal = layerNumber - _layers.get(0).getLayerNumber();
return getLayerByOrdinal(ordinal);
}
+ /**
+ * Look up layer object in this module by its layer ID.
+ * Throws <tt>IndexOutOfBoundsException</tt> if the layer with the specified ID
+ * does not belong to this module.
+ */
public CalLayer getLayerByID(int layerID) {
int ordinal = layerID - _layers.get(0).getLayerID();
return getLayerByOrdinal(ordinal);