Commit in lcsim/src/org/lcsim/recon/cluster/fixedcone on MAIN
FixedConeClusterDriver.java+38-2331.2 -> 1.3
Add a little more flexibility, leave the default the same

lcsim/src/org/lcsim/recon/cluster/fixedcone
FixedConeClusterDriver.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- FixedConeClusterDriver.java	18 Jul 2005 19:18:27 -0000	1.2
+++ FixedConeClusterDriver.java	18 Oct 2005 18:54:21 -0000	1.3
@@ -37,6 +37,9 @@
     private double _samplingFraction;
     private double[] _layerEnergy;
     private FixedConeClusterer _clusterer;
+    private String[] _collNames;
+    private boolean _doall;
+    private String _nameExt;
     
     CalorimeterIDDecoder _decoder;
     
@@ -57,6 +60,10 @@
         _seedEnergy = seed;
         _minEnergy = minE;
         _clusterer = new FixedConeClusterer(_radius, _seedEnergy, _minEnergy);
+        _doall = false;
+        _collNames = new String[1];
+        _collNames[0] = "EcalBarrHits";
+        _nameExt = "FixedConeClusters";
     }
     
     
@@ -67,252 +74,50 @@
      */
     protected void process(EventHeader event)
     {
-        List<CalorimeterHit> collection = event.get(CalorimeterHit.class,"EcalBarrHits");
-        _decoder = (CalorimeterIDDecoder) event.getMetaData(collection).getIDDecoder();
-//        System.out.println(_decoder);
-        List<BasicCluster> clusters = _clusterer.makeClusters(collection,_decoder);
-        
+      List<List<CalorimeterHit>> collections = event.get(CalorimeterHit.class);
+      for (List<CalorimeterHit> collection: collections)
+      {
         String name = event.getMetaData(collection).getName();
-        
-//        System.out.println("found "+clusters.size()+" clusters");
-        if (clusters.size() > 0) event.put(name+"FixedConeClusters",clusters);    
-    }
-    
-    /**
-     * Takes a list of CalorimeterHits, clusters them, and returns a list of
-     * CalorimeterClusters
-     *
-     * @param   in  A collection of CalorimeterHits
-     * @return  List of found CalorimeterClusters
-     */
- /*   
-    public List cluster(List<? extends CalorimeterHit> in, CalorimeterIDDecoder decoder)
-    {
-        List out = new ArrayList();
-        
-        double rsquared = _radius*_radius;
-        // sort the vector in descending energy for efficiency
-        // this starts with the highest energy seeds.
-        Collections.sort(in, new CalorimeterHitEsort());
-        
-        int nclus = 0;
-        int size = in.size();
-        boolean[] used = new boolean[size];
-        //   outer loop finds a seed
-        for(int i =0; i<size; ++i)
+        boolean doit = false;
+        if(_doall)
         {
-            if (!used[i])
-            {
-                CalorimeterHit p = in.get(i);
-                if (p.getEnergy()>_seedEnergy)
-                {
-                    decoder.setID(p.getCellID());
-                    double cellE = p.getEnergy();
-                    double px = cellE*Math.cos(decoder.getPhi())*Math.sin(decoder.getTheta());
-                    double py = cellE*Math.sin(decoder.getPhi())*Math.sin(decoder.getTheta());
-                    double pz = cellE*Math.cos(decoder.getTheta());
-                    Lorentz4Vector sum = new Momentum4Vector(px,py,pz,cellE);
-                    double phiseed=sum.phi();
-                    double thetaseed=sum.theta();
-                    
-                    // constituent cells
-                    List<CalorimeterHit> members = new ArrayList<CalorimeterHit>();
-                    members.add(p);
-                    // inner loop adds neighboring cells to seed
-                    
-                    for (int j = i+1; j<size; ++j)
-                    {
-                        //                        if (in.get(j)!=null)
-                        if(!used[j])
-                        {
-                            CalorimeterHit p2 = in.get(j);
-                            decoder.setID(p2.getCellID());
-                            double phi = decoder.getPhi();
-                            double theta=decoder.getTheta();
-                            double dphi=phi-phiseed;
-                            
-                            if(dphi<-PI) dphi+=TWOPI;
-                            if(dphi>PI) dphi-=TWOPI;
-                            double dtheta = theta-thetaseed;
-                            double R2=dphi*dphi+dtheta*dtheta;
-                            if(R2< rsquared)
-                            {
-                                //  particle within cone
-                                cellE = p2.getEnergy();
-                                px = cellE*Math.cos(decoder.getPhi())*Math.sin(decoder.getTheta());
-                                py = cellE*Math.sin(decoder.getPhi())*Math.sin(decoder.getTheta());
-                                pz = cellE*Math.cos(decoder.getTheta());
-                                sum.plusEquals(new Momentum4Vector(px, py, pz, cellE));
-                                members.add(p2);
-                                // tag this element so we don't reuse it
-                                used[j]=true;
-                                
-                                //   recalculate cone center
-                                phiseed=sum.phi();
-                                thetaseed=sum.theta();
-                            }
-                        }
-                    }// end of inner loop
-                    
-                    
-                    // if energy of cluster is large enough add it to the list
-                    if(sum.E()>_minEnergy)
-                    {
-                        //                   HitsCluster clus = new HitsCluster(decoder,sum,members,_numLayers,_samplingFraction);
-                        CalorimeterCluster clus = new CalorimeterCluster(decoder,sum, members,30,1.);
-                        for(CalorimeterHit hit : members)
-                        {
-                            clus.addHit(hit);
-                        }
-                        out.add(clus);
-                        nclus++;
-                    }
-                    
-                }
-            }// end of outer loop
+            doit = true;
         }
-        
-        if (nclus>1)
+        else
         {
-            // sort the clusters in descending energy
-            Collections.sort(out, new HitsClusterESort());
-            // loop over the found clusters and look for overlaps
-            // i.e distance between clusters is less than 2*R
-            for(int i=0; i<out.size();++i  )
+            for(int i=0;i<_collNames.length;i++)
             {
-                for(int j=i+1; j<out.size(); ++j)
+                if(name.compareTo(_collNames[i]) == 0)
                 {
-                    double dTheta = dTheta((CalorimeterCluster)out.get(i), (CalorimeterCluster)out.get(j));
-                    if (dTheta<2*_radius)
-                    {
-                        resolve((CalorimeterCluster)out.get(i), (CalorimeterCluster)out.get(j), decoder);
-                    }
+                    doit = true;
+                    break;
                 }
             }
         }
-        
-//        System.out.println("found "+out.size()+ " clusters");
-        return out;
-    }
-*/    
-    
-    /**
-     * Calculate the angle between two CalorimeterClusters
-     *
-     * @param   c1  First CalorimeterCluster
-     * @param   c2  Second CalorimeterCluster
-     * @return     The angle between the two clusters
-     */
-/*    
-    public double dTheta(CalorimeterCluster c1, CalorimeterCluster c2)
-    {
-        Lorentz4Vector v1 = c1.vector();
-        Lorentz4Vector v2 = c2.vector();
-        double costheta = (v1.vec3dot(v2))/(v1.p()*v2.p());
-        return Math.acos(costheta);
-    }
-*/    
-    /**
-     * Given two overlapping clusters, assign cells to nearest axis.
-     * The cluster axes are <em> not </em> iterated.
-     * Cluster quantities are recalculated after the split.
-     *
-     * @param   c1 First CalorimeterCluster
-     * @param   c2 Second CalorimeterCluster
-     */
-  /*  
-    public void resolve(CalorimeterCluster c1, CalorimeterCluster c2, CalorimeterIDDecoder decoder)
-    {
-        // do not recalculate cluster axis until all reshuffling is done
-        // do not want the cones to shift
-        // this behavior may change in the future
-        
-        Lorentz4Vector v1 = c1.vector();
-        double phi1 = v1.phi();
-        double theta1 = v1.theta();
-        Lorentz4Vector v2 = c2.vector();
-        double phi2 = v2.phi();
-        double theta2 = v2.theta();
-        List<CalorimeterHit> cells1 = c1.cells();
-        List<CalorimeterHit> cells2 = c2.cells();
-        int size2 = cells2.size();
-        
-        List<CalorimeterHit> tmp = new ArrayList<CalorimeterHit>();
-        // loop over cells in first cluster...
-        for(int i=0; i<cells1.size(); ++i)
-        {
-            CalorimeterHit p2 = (CalorimeterHit) cells1.get(i);
-            decoder.setID(p2.getCellID());
-            double phi = decoder.getPhi();
-            double theta = decoder.getTheta();
-            //distance to cluster 1
-            double dphi1=phi-phi1;
-            if(dphi1<-PI) dphi1+=TWOPI;
-            if(dphi1>PI) dphi1-=TWOPI;
-            double dtheta1 = theta-theta1;
-            double R1=dphi1*dphi1+(dtheta1)*(dtheta1);
-            // distance to cluster 2
-            double dphi2=phi-phi2;
-            if(dphi2<-PI) dphi2+=TWOPI;
-            if(dphi2>PI) dphi2-=TWOPI;
-            double dtheta2 = theta-theta2;
-            double R2=dphi2*dphi2+(dtheta2)*(dtheta2);
-            
-            if (R2<R1)
-            {
-                //add this cell to the vector of cells to remove
-                tmp.add(p2);
-            }
-        }
-        for(int i=0; i<tmp.size(); ++i)
+        if(doit)
         {
-            CalorimeterHit p2 = (CalorimeterHit) tmp.get(i);
-            // remove this cell from cluster1
-            cells1.remove(p2);
-            // add it to cluster2
-            cells2.add(p2);
-        }
-        tmp.clear();
-        // repeat for cluster 2
-        // only loop over cells in original cluster
-        for(int i=0; i<size2; ++i)
-        {
-            CalorimeterHit p2 = (CalorimeterHit) cells2.get(i);
-            decoder.setID(p2.getCellID());
-            double phi = decoder.getPhi();
-            double theta = decoder.getTheta();
-            //distance to cluster 1
-            double dphi1=phi-phi1;
-            if(dphi1<-PI) dphi1+=TWOPI;
-            if(dphi1>PI) dphi1-=TWOPI;
-            double dtheta1 = theta-theta1;
-            double R1=dphi1*dphi1+(dtheta1)*(dtheta1);
-            // distance to cluster 2
-            double dphi2=phi-phi2;
-            if(dphi2<-PI) dphi2+=TWOPI;
-            if(dphi2>PI) dphi2-=TWOPI;
-            double dtheta2 = theta-theta2;
-            double R2=dphi2*dphi2+(dtheta2)*(dtheta2);
-            
-            if (R1<R2)
-            {
-                //add this cell to the vector of cells to remove
-                tmp.add(p2);
-            }
-        }
-        for(int i=0; i<tmp.size(); ++i)
-        {
-            CalorimeterHit p2 = (CalorimeterHit) tmp.get(i);
-            // remove this cell from cluster2
-            cells2.remove(p2);
-            // add it to cluster1
-            cells1.add(p2);
+            _decoder = (CalorimeterIDDecoder) event.getMetaData(collection).getIDDecoder();
+//        System.out.println(_decoder);
+            List<BasicCluster> clusters = _clusterer.makeClusters(collection,_decoder);
+//        System.out.println("found "+clusters.size()+" clusters");
+            if (clusters.size() > 0) event.put(name+_nameExt,clusters);
         }
-        c1.calculateVec();
-        c2.calculateVec();
+      }
     }
-   */
     
+   public void setNameExt(String ext)
+   {
+       _nameExt = ext;
+   }
+   public void setCollectionNames(String[] names)
+   {
+       _collNames = names;
+       _doall = false;
+   }
+   public void setAll()
+   {
+       _doall = true;
+   }
     public String toString()
     {
         return "FixedConeClusterDriver with clusterer "+_clusterer;
CVSspam 0.2.8