lcsim/src/org/lcsim/contrib/uiowa
diff -u -r1.24 -r1.25
--- ReclusterDTreeDriver.java 26 Jun 2008 19:15:05 -0000 1.24
+++ ReclusterDTreeDriver.java 27 Jun 2008 17:00:25 -0000 1.25
@@ -34,7 +34,7 @@
* in this package, which uses the implementation in
* org.lcsim.recon.cluster.directedtree developed by NIU).
*
- * @version $Id: ReclusterDTreeDriver.java,v 1.24 2008/06/26 19:15:05 mcharles Exp $
+ * @version $Id: ReclusterDTreeDriver.java,v 1.25 2008/06/27 17:00:25 mcharles Exp $
* @author Mat Charles <[log in to unmask]>
*/
@@ -358,6 +358,8 @@
List<Cluster> linkableClusters = new Vector<Cluster>();
List<Cluster> smallClustersToShare = new Vector<Cluster>();
List<Cluster> leftoverHitClustersToShare = new Vector<Cluster>();
+ List<Cluster> leftoverHitClustersToShareECAL = new Vector<Cluster>();
+ List<Cluster> leftoverHitClustersToShareHCAL = new Vector<Cluster>();
List<Cluster> leftoverHitClustersAllowedInShowers = new Vector<Cluster>();
linkableClusters.addAll(mips);
linkableClusters.addAll(modifiedPhotonClusters);
@@ -369,7 +371,29 @@
} else if (clus.getCalorimeterHits().size() < 3) {
smallClustersToShare.add(clus);
} else {
- leftoverHitClustersToShare.add(clus);
+ // Any structure?
+ Cluster tree = treeOfSharedCluster.get(clus);
+ List<Cluster> targetsInThisTree = targetsInTree.get(tree);
+ if (targetsInThisTree.size() > 0) {
+ // These "leftover hit clusters" can include a LOT of halo hits from
+ // inside a DTree... need to break them into bite-sized pieces for
+ // the sharing algorithm
+ for (CalorimeterHit hit : clus.getCalorimeterHits()) {
+ BasicCluster tmpClus = new BasicCluster();
+ tmpClus.addHit(hit);
+ treeOfSharedCluster.put(tmpClus, tree);
+ leftoverHitClustersToShare.add(tmpClus);
+ boolean hitECAL = (allHitsEcalBarrel.contains(hit) || allHitsEcalEndcap.contains(hit));
+ if (hitECAL) {
+ leftoverHitClustersToShareECAL.add(tmpClus);
+ } else {
+ leftoverHitClustersToShareHCAL.add(tmpClus);
+ }
+ }
+ } else {
+ // No structure
+ smallClustersToShare.add(clus); // TEST
+ }
}
}
smallClustersToShare.addAll(photonFragments);
@@ -434,11 +458,78 @@
sharedSmallDTreeClusters.createShares(linkableClusters);
sharedSmallDTreeClusters.rebuildHints();
allSharedClusters.add(sharedSmallDTreeClusters);
- DTreeClusterSharingAlgorithm dTreeSharingAlg = new DTreeClusterSharingAlgorithm(treeOfSharedCluster, targetsInTree, 20.0, 150.0);
- SharedClusterGroup sharedLeftoverHitClusters = new SharedClusterGroup(leftoverHitClustersToShare, dTreeSharingAlg);
- sharedLeftoverHitClusters.createShares(linkableClusters);
- sharedLeftoverHitClusters.rebuildHints();
- allSharedClusters.add(sharedLeftoverHitClusters);
+ DTreeClusterSharingAlgorithm dTreeSharingAlgECAL = new DTreeClusterSharingAlgorithm(treeOfSharedCluster, targetsInTree, 20.0, 150.0);
+ DTreeClusterSharingAlgorithm dTreeSharingAlgHCAL = new DTreeClusterSharingAlgorithm(treeOfSharedCluster, targetsInTree, 50.0, 200.0);
+ SharedClusterGroup sharedLeftoverHitClustersECAL = new SharedClusterGroup(leftoverHitClustersToShareECAL, dTreeSharingAlgECAL);
+ SharedClusterGroup sharedLeftoverHitClustersHCAL = new SharedClusterGroup(leftoverHitClustersToShareHCAL, dTreeSharingAlgHCAL);
+ sharedLeftoverHitClustersECAL.createShares(linkableClusters);
+ sharedLeftoverHitClustersECAL.rebuildHints();
+ sharedLeftoverHitClustersHCAL.createShares(linkableClusters);
+ sharedLeftoverHitClustersHCAL.rebuildHints();
+ allSharedClusters.add(sharedLeftoverHitClustersECAL);
+ allSharedClusters.add(sharedLeftoverHitClustersHCAL);
+
+ // DEBUG
+ if (false) {
+ for (Cluster dTreeClus : dTreeClusters) {
+ List<Cluster> subClustersECAL = new Vector<Cluster>();
+ for (Cluster subClus : leftoverHitClustersToShareECAL) {
+ if (treeOfSharedCluster.get(subClus) == dTreeClus) {
+ subClustersECAL.add(subClus);
+ }
+ }
+ List<Cluster> subClustersHCAL = new Vector<Cluster>();
+ for (Cluster subClus : leftoverHitClustersToShareHCAL) {
+ if (treeOfSharedCluster.get(subClus) == dTreeClus) {
+ subClustersHCAL.add(subClus);
+ }
+ }
+ System.out.println("DTree cluster with "+dTreeClus.getCalorimeterHits().size()+" hits contains "+subClustersECAL.size()+" shared sub-clusters in the ECAL and "+subClustersHCAL.size()+" shared sub-clusters in the HCAL");
+ List<Cluster> targetsInThisTree = targetsInTree.get(dTreeClus);
+ if (targetsInThisTree.size()==0) {
+ // No targets -- not interesting here
+ continue;
+ }
+ SharedClusterGroup tmpSharedHits;
+ if (subClustersECAL.size()==0 && subClustersHCAL.size()==0) {
+ // No hits
+ continue;
+ } else if (subClustersECAL.size()==0 && subClustersHCAL.size()> 0) {
+ tmpSharedHits = new SharedClusterGroup(subClustersHCAL, dTreeSharingAlgHCAL);
+ } else if (subClustersECAL.size()> 0 && subClustersHCAL.size()==0) {
+ tmpSharedHits = new SharedClusterGroup(subClustersECAL, dTreeSharingAlgECAL);
+ } else {
+ throw new AssertionError("Mixed cluster");
+ }
+
+ tmpSharedHits.createShares(linkableClusters);
+ tmpSharedHits.rebuildHints();
+ Set<Cluster> targets = tmpSharedHits.findTargets();
+ for (Cluster target : targetsInThisTree) {
+ List<SharedCluster> contrib = null;
+ if (targets.contains(target)) {
+ contrib = tmpSharedHits.findContributingSharedClusters(target);
+ }
+ MCParticle domPartOfTarget = quoteDominantParticle(target);
+ double sumWeights = 0.0;
+ double sumWeightsTM = 0.0;
+ if (contrib != null) {
+ for (SharedCluster subClus : contrib) {
+ MCParticle domPartOfSubClus = quoteDominantParticle(subClus.getCluster());
+ Double weight = subClus.getNormalizedWeight(target);
+ if (weight != null) {
+ sumWeights += weight;
+ double distance = proximity(subClus.getCluster(), target);
+ double rawWeight = subClus.getRawWeight(target);
+ if (domPartOfTarget == domPartOfSubClus) { sumWeightsTM += weight; }
+ System.out.println("DEBUG: PROX="+distance+" => RAW WEIGHT "+rawWeight+" (truth="+domPartOfSubClus.getPDGID()+" with p="+domPartOfSubClus.getMomentum().magnitude()+")");
+ }
+ }
+ }
+ System.out.println(" -> Target with "+target.getCalorimeterHits().size()+" has "+sumWeights+" weight of shared hits of which "+sumWeightsTM+" truth-matched (truth="+domPartOfTarget.getPDGID()+" with p="+domPartOfTarget.getMomentum().magnitude()+")");
+ }
+ }
+ }
// Iterate to build clusters:
for (int iIter=0; iIter<10; iIter++) {