lcsim/src/org/lcsim/contrib/uiowa/MuonFinder
diff -u -r1.2 -r1.3
--- MuonFinder.java 30 Sep 2008 01:11:56 -0000 1.2
+++ MuonFinder.java 3 Oct 2008 19:05:47 -0000 1.3
@@ -36,9 +36,9 @@
protected String _outMap;
protected String _inMu;
protected String _inCal;
- protected double _bestmatch = 0.8;
+ protected double _bestmatch = 0.9;
protected boolean _debug = false;
-
+ protected boolean _useFirstTwoLayer = true;
EventHeader m_event;
protected HelixExtrapolator m_findCluster = new org.lcsim.recon.pfa.identifier.LocalHelixExtrapolator();
@@ -86,9 +86,10 @@
List<Cluster> muonClusters = new Vector<Cluster>();
List<Track> muonTracks = new Vector<Track>();
- //create mip cluster separately in Calorimetry and Muon detector.
- //mip in CAL has track matched and muon mip in Muon detector is standalone.
- //In the future, the muon mip will be replace with standalone muon track.
+ //Create mip cluster separately in Calorimetry and Muon detector.
+ //Mip in CAL has track matched
+ //But Mip in Muon detector is standalone.
+ //In the future, the muon Mip will be replace with standalone muon track.
MipTrackMap finder = new MipTrackMap(m_findCluster);
Map<Track,BasicCluster> mipmap = finder.createCalMIPMap(calhits, trackList);
List<Cluster> muonmips = finder.createMIPMuDet(mudethits);
@@ -97,18 +98,43 @@
for(Cluster mumip : muonmips){
if( mumip.getCalorimeterHits().size() > 1){
- CalorimeterHit muonhit1 = mumip.getCalorimeterHits().get(mumip.getCalorimeterHits().size()-1);
- CalorimeterHit muonhit0 = mumip.getCalorimeterHits().get(0);
- Hep3Vector muonpos1 = new BasicHep3Vector(muonhit1.getPosition());
- Hep3Vector muonpos0 = new BasicHep3Vector(muonhit0.getPosition());
Hep3Vector trackMuon = new BasicHep3Vector();
- if(muonpos0.magnitude() > muonpos1.magnitude()){
- trackMuon = VecOp.sub(muonpos0, muonpos1);
+ //Muon detector has 20cm iron between 2 layers. The direction is not affected by the segmentation.
+ //Trying to use first two layers to identify direction intead of using first and last hit.
+ //In endcap, track curves so it will bring wrong direction if we use first and last hit.
+ //First two layers will give better direction.
+ if(_useFirstTwoLayer){
+ CalorimeterHit muonhit0 = mumip.getCalorimeterHits().get(0);
+ Hep3Vector muonpos0 = new BasicHep3Vector(muonhit0.getPosition());
+ Hep3Vector muonpos1 = new BasicHep3Vector();
+ System.out.println("muonhit0= " + muonpos0.magnitude());
+ int prelayer = -1 ;
+ for(CalorimeterHit h : mumip.getCalorimeterHits()){
+ IDDecoder id = h.getIDDecoder();
+ id.setID(h.getCellID());
+ int layer = id.getLayer();
+ System.out.println("layer = " + layer);
+ if(prelayer != layer && prelayer != -1){
+ muonpos1 = new BasicHep3Vector(h.getPosition());
+ System.out.println("muonhit1= " + muonpos1.magnitude());
+ trackMuon = VecOp.sub(muonpos1, muonpos0);
+ break;
+ }
+ prelayer = layer;
+ }
}else{
- trackMuon = VecOp.sub(muonpos1, muonpos0);
+ CalorimeterHit muonhit1 = mumip.getCalorimeterHits().get(mumip.getCalorimeterHits().size()-1);
+ CalorimeterHit muonhit0 = mumip.getCalorimeterHits().get(0);
+ Hep3Vector muonpos1 = new BasicHep3Vector(muonhit1.getPosition());
+ Hep3Vector muonpos0 = new BasicHep3Vector(muonhit0.getPosition());
+ if(muonpos0.magnitude() > muonpos1.magnitude()){
+ trackMuon = VecOp.sub(muonpos0, muonpos1);
+ }else{
+ trackMuon = VecOp.sub(muonpos1, muonpos0);
+ }
}
Hep3Vector trackMuonUnit = VecOp.unit(trackMuon);
-
+
double bestmatch = -1;
Track bestTrack = null;
Cluster bestmipc = null;
@@ -142,9 +168,8 @@
int layer = id.getLayer();
String subdetName = hit.getSubdetector().getName();
//Followings are required to take pion track out for muon candidate
- boolean muon1 = subdetName.contains("HADBarrel") || subdetName.contains("HADEndcap");
- boolean muon2 = (layer > 29 && layer <40) ;
- if(!(muon1 && muon2)) continue;
+ boolean muon = subdetName.contains("HADBarrel") || (subdetName.contains("HADEndcap") && (layer > 29 && layer <40) );
+ if(!(muon)) continue;
hitpos = new BasicHep3Vector(hit.getPosition());
tangent = result.getTangent(hitpos);
tangentUnit = VecOp.unit(tangent);
@@ -170,7 +195,12 @@
if( bestmipc != null && bestmipc.getCalorimeterHits().size() > 0 ) c.add(bestmipc);
}
c.add(mumip);
- }else { if(_debug) System.out.println("Warning: This cluster in MuDet has no track matched!");}
+ }else {
+ if(_debug) {
+ System.out.println("Warning: This cluster in MuDet has no track matched!");
+ System.out.println("best match= " + bestmatch);
+ }
+ }
}else { if(_debug) System.out.println ("Warning: This muon mip has 0 number of hits!");}
}