lcsim/src/org/lcsim/digisim
diff -u -r1.3 -r1.4
--- CellSelector.java 10 Jun 2005 01:15:31 -0000 1.3
+++ CellSelector.java 27 Jun 2005 21:45:32 -0000 1.4
@@ -9,7 +9,7 @@
import org.lcsim.geometry.IDDecoder;
import org.lcsim.geometry.subdetector.CylindricalCalorimeter;
import org.lcsim.geometry.compact.Subdetector;
-import org.lcsim.geometry.compact.Segmentation;
+import org.lcsim.geometry.segmentation.SegmentationImpl;
import org.lcsim.geometry.segmentation.ProjectiveCylinder;
import org.lcsim.geometry.segmentation.NonprojectiveCylinder;
@@ -21,7 +21,7 @@
* any cell in a given subdetector.
*
* @author Guilherme Lima
- * @version $Id: CellSelector.java,v 1.3 2005/06/10 01:15:31 jeremy Exp $
+ * @version $Id: CellSelector.java,v 1.4 2005/06/27 21:45:32 lima Exp $
*/
public class CellSelector
{
@@ -36,7 +36,7 @@
CalHitMapMgr aux = CalHitMapMgr.getInstance();
_evt = aux.getEvent();
_calsub = aux.getSubdetector( _collName );
- _segm = _calsub.getReadout().getSegmentation();
+ _segm = (SegmentationImpl)_calsub.getReadout().getSegmentation();
try {
// IDDescriptor desc = new IDDescriptor(description);
@@ -50,9 +50,11 @@
if( _calsub instanceof CylindricalCalorimeter ) {
// This for cylindrical calorimeters
CylindricalCalorimeter cal = (CylindricalCalorimeter)_calsub;
- System.out.println("_calsub="+_calsub.getName()
- +": a CylindricalCalorimeter, zMax="+cal.getZMax()
- +", nlayers="+cal.getLayerCount());
+ if(_debug) {
+ System.out.println("_calsub="+_calsub.getName()
+ +": a CylindricalCalorimeter, zMax="+cal.getZMax()
+ +", nlayers="+cal.getLayerCount());
+ }
_nlayers = cal.getLayerCount();
double zmin = cal.getZMin();
@@ -60,18 +62,24 @@
if( _segm instanceof ProjectiveCylinder ) {
// Here for projective cylinder
- System.out.println("_segm is a ProjectiveCylinder");
+ if(_debug) {
+ System.out.println("_segm is a ProjectiveCylinder");
+ }
ProjectiveCylinder proj = (ProjectiveCylinder)_segm;
- _nphi = proj.getPhiBins();
+ int nphi = proj.getPhiBins();
int ntheta = proj.getThetaBins();
+ _maxPhiBins = new int[_nlayers];
_maxThetaBins = new int[_nlayers];
_minThetaBins = new int[_nlayers];
+ _numCells = 0;
for(int i=0; i<_nlayers; ++i) {
double thetamin = Math.PI/2 + Math.atan2(zmin, cal.getDistanceToLayerSensorMid(i));
double thetamax = Math.PI/2 + Math.atan2(zmax, cal.getDistanceToLayerSensorMid(i));
_minThetaBins[i] = (int)(ntheta*thetamin/Math.PI);
_maxThetaBins[i] = (int)(ntheta*thetamax/Math.PI);
+ _maxPhiBins[i] = nphi;
+ _numCells += nphi * (_maxThetaBins[i]-_minThetaBins[i]+1);
// System.out.println("for i="+i+", itheta in range: ["
// +_minThetaBins[i]+" to "+_maxThetaBins[i]+"]");
}
@@ -84,13 +92,15 @@
// double delphi = nonproj.getGridSizePhi();
// double delz = nonproj.getGridSizeZ();
+// _maxPhiBins = new int[_nlayers];
// _maxThetaBins = new int[_nlayers];
// _minThetaBins = new int[_nlayers];
// for(int i=0; i<_nlayers; ++i) {
// double thetamin = Math.PI/2 + Math.atan2(zmin, cal.getRadiusForLayer(i));
// double thetamax = Math.PI/2 + Math.atan2(zmax, cal.getRadiusForLayer(i));
-// _minThetaBins[i] = (int)(ntheta*thetamin/Math.PI);
-// _maxThetaBins[i] = (int)(ntheta*thetamax/Math.PI);
+// _minThetaBins[i] = ???(int)(ntheta*thetamin/Math.PI);
+// _maxThetaBins[i] = ???(int)(ntheta*thetamax/Math.PI);
+// _maxPhiBins[i] = ???(int)(ntheta*thetamax/Math.PI);
// // System.out.println("for i="+i+", itheta in range: ["
// // +_minThetaBins[i]+" to "+_maxThetaBins[i]+"]");
// }
@@ -117,7 +127,7 @@
if( _segm instanceof ProjectiveCylinder ) {
// This for cylindrical projective calorimeters
int ilayer = (int)(_nlayers * _random.nextDouble());
- int iphi = (int)(_nphi * _random.nextDouble());
+ int iphi = (int)(_maxPhiBins[ilayer] * _random.nextDouble());
int nThetaInLayer = _maxThetaBins[ilayer]-_minThetaBins[ilayer]+1;
int ithe = (int)(nThetaInLayer*_random.nextDouble() + _minThetaBins[ilayer]);
// System.out.println("ilay="+ilayer+", ithe="+ithe+", iphi="+iphi);
@@ -160,8 +170,24 @@
return _encoder.getID();
}
+ public SegmentationImpl getSegmentation() {
+ if(_calsub==null) setupGeometry();
+ return _segm;
+ }
+
+ public IDEncoder getIDEncoder() {
+ if(_calsub==null) setupGeometry();
+ return _encoder;
+ }
+
+ public int getCellCount() {
+ return _numCells;
+ }
+
//=== FIELDS ===
+ /** debugging flag */
+ private boolean _debug = false;
/** Collection name */
private String _collName;
/** Event header */
@@ -169,7 +195,7 @@
/** Subdetector */
private Subdetector _calsub;
/** Segmentation */
- private Segmentation _segm;
+ private SegmentationImpl _segm;
/** ID encoder */
private IDEncoder _encoder;
/** system number to be used in hit encoding */
@@ -179,14 +205,15 @@
/** calorimeter layers */
private int _nlayers;
- private int _nphi;
/** Max phiBins per layer */
- private int _maxPhiBins;
+ private int[] _maxPhiBins;
/** Min thetaBins per layer */
private int[] _minThetaBins;
/** Max thetaBins per layer */
private int[] _maxThetaBins;
+ /** Total number of cells */
+ private int _numCells;
/** Random number generator */
private Random _random = new Random();