Commit in lcsim/src/org/lcsim/recon/cluster/muonfinder on MAIN
MuonFinder.java+22-291.3 -> 1.4
put patched version into the main code

lcsim/src/org/lcsim/recon/cluster/muonfinder
MuonFinder.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- MuonFinder.java	12 Dec 2008 21:26:17 -0000	1.3
+++ MuonFinder.java	19 Dec 2008 21:08:20 -0000	1.4
@@ -40,7 +40,7 @@
  * it is required to find good quality mip cluster in muon detector.
  *
  * @author [log in to unmask]
- * @version $Id: MuonFinder.java,v 1.3 2008/12/12 21:26:17 jeremy Exp $
+ * @version $Id: MuonFinder.java,v 1.4 2008/12/19 21:08:20 tjkim Exp $
  */
 
 public class MuonFinder extends Driver{
@@ -122,6 +122,7 @@
             System.out.println("Muon mip size= " + muonmips.size()+" (should be 1 for signle sample)");
         }
         for(Cluster mumip : muonmips){
+            if(_debug) System.out.println("Candidate Muon");
             if( mumip.getCalorimeterHits().size() > 1){
                 Hep3Vector muonpos0 = new BasicHep3Vector();
                 Hep3Vector muonpos1 = new BasicHep3Vector();  
@@ -173,6 +174,7 @@
                 Track bestTrack = null;
                 Cluster bestmipc = null;
                 for(Track tr : trackList){
+                    if(_debug) System.out.println("  Candidate Track");
                     Hep3Vector track = (new BasicHep3Vector(tr.getMomentum()));
                     double p = track.magnitude();
                     double pT = Math.sqrt(track.x()*track.x() + track.y()*track.y());
@@ -182,23 +184,14 @@
                     Cluster calmip = mipmap.get(tr);
                     Hep3Vector last = new BasicHep3Vector();
                     Hep3Vector lastUnit = new BasicHep3Vector();
-                    Hep3Vector hitpos = new BasicHep3Vector();
                     Hep3Vector lastpoint = new BasicHep3Vector();
                                                                     
                     boolean muon = false;
                     int isolated = 0;                                                          
-                    if(calmip == null || result == null) {
-                       if(_debug) System.out.println("Null mip or extrapolation");
-                       continue;
-                    }else if(calmip.getCalorimeterHits().size() > 0){
-                        CalorimeterHit hit = calmip.getCalorimeterHits().get(calmip.getCalorimeterHits().size()-1);
-                        IDDecoder id = hit.getIDDecoder();
-                        id.setID(hit.getCellID());
-                        int layer = id.getLayer();
-                        String subdetName = hit.getSubdetector().getName();
-                        //Followings are required to take pion track out for muon candidate
-                        muon = subdetName.contains("HADBarrel") || (subdetName.contains("HADEndcap")  && (layer > 29) );
-                        hitpos = new BasicHep3Vector(hit.getPosition());
+                    if(result == null) {
+                        if(_debug) System.out.println("    DEBUG: Null mip or extrapolation");
+                        continue;
+                    }else{
                         //Using extrapolated track
                         int lastLayerBarrel = getLastLayer("HADBarrel");
                         int lastLayerEndcap = getLastLayer("HADEndcap");
@@ -234,7 +227,6 @@
                                 }
                             }
                             if(tpoint == null) {
-                                if(_debug) System.out.println("Null extrapolated track point");
                                 hasLastPoint = false;
                                 break;
                             } 
@@ -255,27 +247,27 @@
                                 lastUnit = VecOp.unit(last);
                             }
                             double rpos = Math.sqrt(tpoint.x()*tpoint.x() + tpoint.y()*tpoint.y());
-                            if(_debug) System.out.println("Extrapolated track at " + endingLayer + " : r= "+rpos+" z= "+tpoint.z() + " hit= " + count );
+                            //if(_debug) System.out.println("Extrapolated track at " + endingLayer + " : r= "+rpos+" z= "+tpoint.z() + " hit= " + count );
                             if(endingLayer == 0){
                                 endingLayer = 40;
                                 isBarrel = false;
                             }
                             if(count > 0 && count < 3) isolated++;
                         }
-                        if(!hasLastPoint) continue;
-                    } else {
-                        if(_debug) System.out.println("Error: Has both mipcluster and extrapolation but no tangent");
-                        continue;
-                    }
+                        if(!hasLastPoint) {
+                            if(_debug) System.out.println("    DEBUG: Null extrapolated track last point");
+                            continue;
+                        }
+                    } 
 
                     //Require last position or 7 isolated layer in last 10 layers obtained by extrapolated track. 
                     //This helps remove pion which is showering in CAL and also take the MIP which is contaminated by
                     //other shower so it stopped in the middle of CAL.
-                    if(!(muon || (isolated > 6) )) continue;
-		    if (!muon) { 
+                    //if(!(muon || (isolated > 6) )) continue;
+		    //if (!muon) { 
 			// Skip these cases to avoid pion contamination.
-			continue; 
-		    }
+	            //    continue; 
+		    //}
                     Hep3Vector link = VecOp.sub(muonpos0, lastpoint);
                     Hep3Vector linkUnit = VecOp.unit(link);
                     double cos0 = VecOp.dot(lastUnit, MuonUnit);
@@ -292,7 +284,8 @@
                         bestmatch = cos;
                         bestTrack = tr;
                         bestmipc = calmip;
-                    }
+                        System.out.println("    DEBUG: This is possible MUON Track!");
+                    }else { if(_debug) System.out.println("    DEBUG: This is NOT possible muon Track!"); }
                 }
                 if(bestmatch > _bestmatch){
                     Set<Cluster> c = outputmap.get(bestTrack);
@@ -303,13 +296,13 @@
                         if( bestmipc != null && bestmipc.getCalorimeterHits().size() > 0 ) c.add(bestmipc);
                     }
                     c.add(mumip);
+                    if(_debug) System.out.println("DEBUG: Found one track for this muon mip");
                 }else { 
                     if(_debug) {
-                        System.out.println("Warning: This cluster in MuDet has no track matched!");
-                        System.out.println("best match= " + bestmatch);
+                        System.out.println("DEBUG: This cluster in MuDet has no track matched!" + " due to " + bestmatch);
                     }
                 }
-            }else { if(_debug) System.out.println ("Warning: This muon mip has 0 number of hits!");}
+            }else { if(_debug) System.out.println ("DEBUG: This muon mip has 0 number of hits!");}
         }
 
         List<CalorimeterHit> muonclustershits= new Vector<CalorimeterHit>(); 
CVSspam 0.2.8