lcsim/src/org/lcsim/contrib/uiowa
diff -u -r1.12 -r1.13
--- MIPReassignmentAlgorithm.java 12 Aug 2008 23:04:38 -0000 1.12
+++ MIPReassignmentAlgorithm.java 13 Aug 2008 00:40:38 -0000 1.13
@@ -93,7 +93,6 @@
}
Hep3Vector last0pos = new BasicHep3Vector();
- Hep3Vector last1pos = new BasicHep3Vector();
Hep3Vector tangent = new BasicHep3Vector(); //extrapolated direction
Hep3Vector P = new BasicHep3Vector(tr.getMomentum());
@@ -104,7 +103,22 @@
last0pos = m_extrap.performExtrapolation(tr);
if (last0pos != null) {
tangent = m_extrap.getTangent(last0pos,tr); //tangent obtained using extrapolated track.
- }
+ } else {
+ // Track didn't reach calorimeter
+ if (newmip.getCalorimeterHits().size()>=2) {
+ // 2+ hits => use last two hits to get position & direction
+ Hep3Vector last1pos = new BasicHep3Vector(newmip.getCalorimeterHits().get(newmip.getCalorimeterHits().size()-2).getPosition());
+ last0pos = new BasicHep3Vector(newmip.getCalorimeterHits().get(newmip.getCalorimeterHits().size()-1).getPosition());
+ tangent = VecOp.sub(last0pos, last1pos);
+ } else if (newmip.getCalorimeterHits().size()==1) {
+ Hep3Vector last1pos = new BasicHep3Vector(0,0,0);
+ last0pos = new BasicHep3Vector(newmip.getCalorimeterHits().get(newmip.getCalorimeterHits().size()-1).getPosition());
+ tangent = VecOp.sub(last0pos, last1pos);
+ } else {
+ // We don't have any information on the track position or intercept at all
+ return null;
+ }
+ }
}else{ //There is a mip attached to track.
for(int i=0; i<2 ; i++){
CalorimeterHit hit = newmip.getCalorimeterHits().get(newmip.getCalorimeterHits().size()-1-i);
@@ -117,7 +131,7 @@
lastTwoPositions.add(v);
}
last0pos = lastTwoPositions.get(0);
- last1pos = lastTwoPositions.get(1);
+ Hep3Vector last1pos = lastTwoPositions.get(1);
//Chose one
boolean usingExtrap = true;
if(usingExtrap) tangent = m_extrap.getTangent(last0pos, tr); //tangent obtained using extrapoltated track
@@ -126,7 +140,7 @@
Hep3Vector tangentUnit = VecOp.unit(tangent);
Hep3Vector temp = VecOp.mult(800,tangentUnit);
- //going back 500 mm or 800 mm back to get the last1pos
+ //going back 500 mm or 800 mm back to get the cone start point
Hep3Vector imgpos = VecOp.sub(last0pos,temp);
Hep3Vector clusterPosition = new BasicHep3Vector(clus.getPosition());
Hep3Vector displacement = VecOp.sub(clusterPosition, imgpos);