lcsim/src/org/lcsim/contrib/uiowa/MuonFinder
diff -u -r1.4 -r1.5
--- MuonFinder.java 4 Oct 2008 01:05:33 -0000 1.4
+++ MuonFinder.java 8 Oct 2008 20:06:41 -0000 1.5
@@ -19,7 +19,7 @@
import org.lcsim.recon.cluster.clumpfinder.*;
import org.lcsim.geometry.IDDecoder;
import org.lcsim.util.lcio.LCIOConstants;
-
+import org.lcsim.util.aida.AIDA;
/**
* Driver to find muon cluster and corresponding track.
*
@@ -30,7 +30,7 @@
*/
public class MuonFinder extends Driver{
-
+ protected AIDA aida = AIDA.defaultInstance();
protected String _outName;
protected String _tracklist;
protected String _outMap;
@@ -95,10 +95,14 @@
List<Cluster> muonmips = finder.createMIPMuDet(mudethits);
Map<Track,Set<Cluster>> outputmap = new HashMap<Track,Set<Cluster>>();
-
+ if(_debug){
+ System.out.println("muonmip size= " + muonmips.size()+" (should be 1 for signle sample)");
+ aida.cloud1D("muon/muon mip size").fill(muonmips.size());
+ }
for(Cluster mumip : muonmips){
if( mumip.getCalorimeterHits().size() > 1){
- Hep3Vector trackMuon = new BasicHep3Vector();
+ Hep3Vector muonpos0 = new BasicHep3Vector();
+ Hep3Vector muonpos1 = new BasicHep3Vector();
//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.
@@ -130,22 +134,17 @@
Collection<CalorimeterHit> hits0 = exam.get(exam.firstKey());
Collection<CalorimeterHit> hits1 = exam.get(exam.lastKey());
- Hep3Vector muonpos0 = getHitMeanPosition(hits0);
- Hep3Vector muonpos1 = getHitMeanPosition(hits1);
- trackMuon = VecOp.sub(muonpos1, muonpos0);
-
+ muonpos0 = getHitMeanPosition(hits0);
+ muonpos1 = getHitMeanPosition(hits1);
}else{
- 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);
- }
+ CalorimeterHit hit0 = mumip.getCalorimeterHits().get(0);
+ CalorimeterHit hit1 = mumip.getCalorimeterHits().get(mumip.getCalorimeterHits().size()-1);
+ muonpos0 = new BasicHep3Vector(hit0.getPosition());
+ muonpos1 = new BasicHep3Vector(hit1.getPosition());
}
+
+ Hep3Vector trackMuon = VecOp.sub(muonpos1, muonpos0);
Hep3Vector trackMuonUnit = VecOp.unit(trackMuon);
double bestmatch = -1;
@@ -162,18 +161,12 @@
Hep3Vector hitpos = new BasicHep3Vector();
Hep3Vector tangent = new BasicHep3Vector();
Hep3Vector tangentUnit = new BasicHep3Vector();
+ Hep3Vector firstlast = new BasicHep3Vector();
+ Hep3Vector firstlastUnit = new BasicHep3Vector();
if(calmip == null || result == null) {
- if(pT > 1){//use intercept point or IP to get tangent direction
- if( result != null){
- Hep3Vector interceptPoint = result.getInterceptPoint();
- tangent = result.getTangent(interceptPoint);
- tangentUnit = VecOp.unit(tangent);
- }else{
- tangent = track;
- tangentUnit = VecOp.unit(tangent);
- }
- }else { continue; } // don't want to use this track to match with cluster in Muon Det.
+ 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();
@@ -182,18 +175,30 @@
String subdetName = hit.getSubdetector().getName();
//Followings are required to take pion track out for muon candidate
boolean muon = subdetName.contains("HADBarrel") || (subdetName.contains("HADEndcap") && (layer > 29 && layer <40) );
- if(!(muon)) continue;
hitpos = new BasicHep3Vector(hit.getPosition());
+ if(!(muon)) continue;
tangent = result.getTangent(hitpos);
tangentUnit = VecOp.unit(tangent);
+ firstlast = VecOp.sub(muonpos0, hitpos);
+ firstlastUnit = VecOp.unit(firstlast);
} else {
if(_debug) System.out.println("Error: Has both mipcluster and extrapolation but no tangent");
continue;
}
- //look for angle between muon track and tangent vector
- double cos = VecOp.dot(tangentUnit, trackMuonUnit);
+
+ double cos0 = VecOp.dot(tangentUnit, trackMuonUnit);
+ double cos1 = VecOp.dot(tangentUnit, firstlastUnit);
+ double cos2 = VecOp.dot(trackMuonUnit, firstlastUnit);
+ double cos = (cos0 + cos1 + cos2)/3;
//find best matched track
- if( cos > bestmatch) {
+ if( cos > bestmatch ) {
+ if(_debug){
+ aida.cloud1D("muon/cos_tangent_muon").fill(cos0);
+ aida.cloud1D("muon/cos_tangent_firstlast").fill(cos1);
+ aida.cloud1D("muon/cos_muon_firstlast").fill(cos2);
+ aida.cloud1D("muon/combined cos").fill(cos);
+ System.out.println("cos0= " + cos0 + " cos1= " + cos1 + " cos2= " + cos2);
+ }
bestmatch = cos;
bestTrack = tr;
bestmipc = calmip;