lcsim/src/org/lcsim/digisim
diff -u -r1.5 -r1.6
--- CellSelector.java 28 Jun 2005 21:55:35 -0000 1.5
+++ CellSelector.java 5 Jul 2005 06:51:10 -0000 1.6
@@ -3,6 +3,7 @@
import org.lcsim.event.SimCalorimeterHit;
import org.lcsim.event.EventHeader;
import org.lcsim.geometry.Detector;
+import java.util.Map;
import java.util.List;
import java.util.Random;
@@ -21,7 +22,7 @@
* any cell in a given subdetector.
*
* @author Guilherme Lima
- * @version $Id: CellSelector.java,v 1.5 2005/06/28 21:55:35 lima Exp $
+ * @version $Id: CellSelector.java,v 1.6 2005/07/05 06:51:10 lima Exp $
*/
public class CellSelector
{
@@ -160,6 +161,7 @@
int ntheta = proj.getThetaBins();
double zmin = cal.getZMin();
double zmax = cal.getZMax();
+// System.out.println("In z: "+zmin+" "+zmax+" "+nphi+" "+ntheta);
_numCells = 0;
for(int i=0; i<_nlayers; ++i) {
@@ -170,9 +172,12 @@
_minLongitBins[i] = (int)Math.floor(ntheta*thetamin/Math.PI);
_maxLongitBins[i] = (int)Math.floor(ntheta*thetamax/Math.PI)+1;
_maxTransvBins[i] = nphi-1;
- _numCells += nphi * (_maxLongitBins[i]-_minLongitBins[i]+1);
-// System.out.println("for i="+i+", itheta in range: ["
-// +_minLongitBins[i]+" to "+_maxLongitBins[i]+"]");
+ int nth = _maxLongitBins[i] - _minLongitBins[i] + 1;
+ _numCells += nphi * nth;
+// System.out.println("layer="+i+", ithe in ["
+// +_minLongitBins[i]+" to "+_maxLongitBins[i]+"]"
+// +", iphi in [0 to "+_maxTransvBins[i]+"], add "
+// +(nphi*nth)+" --> "+_numCells);
}
}
@@ -183,12 +188,12 @@
double zmin = cal.getZMin();
double zmax = cal.getZMax();
int numz = (int)Math.floor((zmax-zmin)/delz);
- System.out.println("In z: "+zmin+" "+zmax+" "+delz+" "+numz);
+// System.out.println("In z: "+zmin+" "+zmax+" "+delz+" "+numz);
for(int i=0; i<_nlayers; ++i) {
// assume indices run from 0
- _minLongitBins[i] = 0;
- _maxLongitBins[i] = numz-1;
+ _minLongitBins[i] = (int)Math.floor(-numz/2);
+ _maxLongitBins[i] = (int)Math.floor((numz-1)/2);
double radius = cal.getDistanceToLayerSensorMid(i);
double delphi = nonproj.computeDeltaPhiForLayer(i);
@@ -196,10 +201,43 @@
int numphi = _maxTransvBins[i]+1;
_numCells += numphi * numz;
-// System.out.println("for i="+i+", iz in ["
-// +_minLongitBins[i]+" to "+_maxLongitBins[i]+"]"
-// +", iphi in [0 to "+_maxTransvBins[i]+"], add "
-// +(numphi*numz)+" cells-> "+_numCells);
+// System.out.println("for i="+i+", iz in ["
+// +_minLongitBins[i]+" to "+_maxLongitBins[i]+"]"
+// +", iphi in [0 to "+_maxTransvBins[i]+"], add "
+// +(numphi*numz)+" cells-> "+_numCells);
+ }
+ }
+
+ /** Check calorimeter hit positions, by comparing LCIO-stored
+ * positions to calculated positions (based on CellID)
+ */
+ public void checkHitPositions() {
+ if(_calsub==null) setupGeometry();
+ // Loop over all temp hits to create raw hits
+ final Map<Long,SimCalorimeterHit> simHits
+ = CalHitMapMgr.getInstance().getCollHitMap( _collName );
+ if(simHits.size()==0) {
+ System.out.println("size=0");
+ return;
+ }
+ for( SimCalorimeterHit ihit : simHits.values() ) {
+ _segm.setID( ihit.getCellID() );
+ double[] pos1 = _segm.getPosition();
+ double[] pos2 = ihit.getPosition();
+ double r1 = Math.sqrt(pos1[0]*pos1[0]+pos1[1]*pos1[1]);
+ double r2 = Math.sqrt(pos2[0]*pos2[0]+pos2[1]*pos2[1]);
+ double layer = _segm.getLayer();
+ double maxrat = Math.abs((r2-r1)/r1*1000000);
+ System.out.println("chkPos: id=<"+ Long.toHexString(ihit.getCellID())
+ +">, x=<"+pos1[0]+" "+pos2[0]
+ +">, y=<"+pos1[1]+" "+pos2[1]
+ +">, z=<"+pos1[2]+" "+pos2[2]
+ +">, r="+r1+" "+r2+", (r2-r1)/r1 (ppm)="+((r2-r1)/r1*1000000)
+ +", layer="+layer+"\n");
+ if(_maxrat<maxrat) {
+ System.out.println("maxrat: "+_maxrat+" --> "+maxrat);
+ _maxrat = maxrat;
+ }
}
}
@@ -236,4 +274,7 @@
/** Random number generator */
private Random _random = new Random();
+
+ /** temporary: max discrepancy ratio */
+ private double _maxrat = -1.;
}