Print

Print


Commit in lcsim/src/org/lcsim/recon/cluster/util on MAIN
BasicCluster.java+34-551.4 -> 1.5
Update to use new CalorimeterHit functionality

lcsim/src/org/lcsim/recon/cluster/util
BasicCluster.java 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- BasicCluster.java	2 Aug 2005 17:18:04 -0000	1.4
+++ BasicCluster.java	3 Aug 2005 17:36:24 -0000	1.5
@@ -6,6 +6,7 @@
 import org.lcsim.event.CalorimeterHit;
 import org.lcsim.event.Cluster;
 import org.lcsim.geometry.compact.Subdetector;
+import org.lcsim.geometry.IDDecoder;
 
 
 /**
@@ -20,10 +21,10 @@
     protected List<Subdetector> detectors = new ArrayList<Subdetector>();
     public double raw_energy;
     public double corrected_energy;
-    protected List<Double> subdetector_raw_energies = new ArrayList<Double>();
-    protected List<Double> subdetector_corrected_energies = new ArrayList<Double>();
+    protected double[] subdetector_raw_energies = new double[30];
+    protected double[] subdetector_corrected_energies = new double[30];
     protected List<Double> hit_energies = new ArrayList<Double>();
-    protected ClusterPropertyCalculator cluster_property_calculator = new DefaultClusterPropertyCalculator();
+    protected ClusterPropertyCalculator cluster_property_calculator = new TensorClusterPropertyCalculator();
     protected boolean needsPropertyCalculation = true;
     protected double[] position;
     protected double[] positionError;
@@ -38,31 +39,17 @@
     public void addHit(CalorimeterHit hit)
     {
         hits.add(hit);
-        raw_energy += hit.getRawEnergy();
-                /*
-                 Subdetector d = hit.getSubdetector();
-                 int detector_index = detectors.indexOf(d);
-                 if(detector_index <0)
-                 {
-                 detectors.add(d);
-                 detector_index = detectors.indexOf(d);
-                 subdetector_raw_energies.add(0.);
-                 subdetector_corrected_energies.add(0.);
-                 }
-                 double sampling_fraction = d.getSamplingFraction();
-                 */
-        int detector_index = 0;
-        double sampling_fraction = 1.;
-        if(subdetector_raw_energies.size() < 1)
-        {
-            subdetector_raw_energies.add(0.);
-            subdetector_corrected_energies.add(0.);
-        }
-        double hce = hit.getRawEnergy()/sampling_fraction;
-        corrected_energy += hce;
+		double hre = hit.getRawEnergy();
+		raw_energy += hre;
+		double hce = hit.getCorrectedEnergy();
+		corrected_energy += hce;
+		IDDecoder idc = hit.getIDDecoder();
+		idc.setID(hit.getCellID());
+		int detector_index = idc.getValue("system");
+		if((detector_index > 29 )|(detector_index < 0))detector_index = 0;
         hit_energies.add(hce);
-        subdetector_raw_energies.set(detector_index,subdetector_raw_energies.get(detector_index) + hit.getRawEnergy());
-        subdetector_corrected_energies.set(detector_index,subdetector_corrected_energies.get(detector_index) + hce);
+        subdetector_raw_energies[detector_index] += hre;
+        subdetector_corrected_energies[detector_index] += hce;
         needsPropertyCalculation = true;
     }
     
@@ -73,27 +60,18 @@
     {
         int indx = hits.indexOf(hit);
         hits.remove(hit);
-        raw_energy -= hit.getRawEnergy();
-                /*
-                 Subdetector d = hit.getSubdetector();
-                 int detector_index = detectors.indexOf(d);
-                 if(detector_index <0)
-                 {
-                 detectors.add(d);
-                 detector_index = detectors.indexOf(d);
-                 subdetector_raw_energies.add(0.);
-                 subdetector_corrected_energies.add(0.);
-                 }
-                 double sampling_fraction = d.getSamplingFraction();
-                 */
-        int detector_index = 0;
-        double sampling_fraction = 1.;
-        double hce = hit.getRawEnergy()/sampling_fraction;
-        corrected_energy -= hce;
+		double hre = hit.getRawEnergy();
+		raw_energy -= hre;
+		double hce = hit.getCorrectedEnergy();
+		corrected_energy -= hce;
         hit_energies.remove(indx);
-        subdetector_raw_energies.set(detector_index,subdetector_raw_energies.get(detector_index) - hit.getRawEnergy());
-        subdetector_corrected_energies.set(detector_index,subdetector_corrected_energies.get(detector_index) - hce);
-        needsPropertyCalculation = true;
+		IDDecoder idc = hit.getIDDecoder();
+		idc.setID(hit.getCellID());
+		int detector_index = idc.getValue("system");
+		if((detector_index > 20 )|(detector_index < 0))detector_index = 0;
+		subdetector_raw_energies[detector_index] -= hre;
+		subdetector_corrected_energies[detector_index] -= hce;
+		needsPropertyCalculation = true;
     }
     /**
      * Add a Cluster to the cluster
@@ -113,11 +91,17 @@
         else
         {
             corrected_energy += cluster.getEnergy();
+			if(cluster instanceof BasicCluster)
+			{
+				BasicCluster bcl = (BasicCluster) cluster;
+				raw_energy += bcl.getRawEnergy();
+			}
             double[] sde = cluster.getSubdetectorEnergies();
             for(int i=0;i<sde.length;i++)
             {
-                subdetector_corrected_energies.set(i,subdetector_corrected_energies.get(i) + sde[i]);
-            }
+				subdetector_corrected_energies[i] += sde[i];
+				subdetector_raw_energies[i] += sde[i];
+			}
         }
     }
     
@@ -237,12 +221,7 @@
      */
     public double[] getSubdetectorEnergies()
     {
-        double[] sdearray = new double[subdetector_corrected_energies.size()];
-        for(int i=0;i<subdetector_corrected_energies.size();i++)
-        {
-            sdearray[i] = subdetector_corrected_energies.get(i);
-        }
-        return sdearray;
+        return subdetector_corrected_energies;
     }
     
     /**
CVSspam 0.2.8