Commit in lcsim/src/org/lcsim/recon/muon on MAIN
BarrelCalSegmentFinder.java+97-791.10 -> 1.11
MuonCalSegmentFinder.java+26-131.3 -> 1.4
+123-92
2 modified files
GL: Preparing the ground for non-projective geometries

lcsim/src/org/lcsim/recon/muon
BarrelCalSegmentFinder.java 1.10 -> 1.11
diff -u -r1.10 -r1.11
--- BarrelCalSegmentFinder.java	10 Dec 2005 15:59:03 -0000	1.10
+++ BarrelCalSegmentFinder.java	12 Dec 2005 05:45:28 -0000	1.11
@@ -8,7 +8,7 @@
 import org.lcsim.geometry.Detector;
 import org.lcsim.geometry.FieldMap;
 import org.lcsim.geometry.subdetector.CylindricalBarrelCalorimeter;
-import org.lcsim.geometry.compact.Segmentation;
+import org.lcsim.geometry.segmentation.SegmentationBase;
 import org.lcsim.geometry.util.IDEncoder;
 import org.lcsim.geometry.segmentation.ProjectiveCylinder;
 import org.lcsim.geometry.util.IDDescriptor;
@@ -64,36 +64,35 @@
         nLayers = calsub.getLayering().getLayerCount();
 
 	dataMgr = CalHitMapMgr.getInstance();
-	segm = calsub.getReadout().getSegmentation();
+	segm = (SegmentationBase)calsub.getReadout().getSegmentation();
 
-	if( segm instanceof ProjectiveCylinder ) {
-	  ProjectiveCylinder projCal = (ProjectiveCylinder)segm;
-	  nPhi = projCal.getPhiBins();
-	  nTheta = projCal.getThetaBins();
-	  phiBinSize = 2*Math.PI/nPhi;
-	  thetaBinSize = Math.PI/nTheta;
-	  System.out.println("MY NAME IS "+subdetName+" rin="+rmin+" rout="+rmax+" zmax="+zmax+", phiBinSize="+phiBinSize+", thetaBinSize="+thetaBinSize);
+// 	if( segm instanceof ProjectiveCylinder ) {
+// 	  ProjectiveCylinder projCal = (ProjectiveCylinder)segm;
+// 	  nPhi = projCal.getPhiBins();
+// 	  nTheta = projCal.getThetaBins();
+// 	  phiBinSize = 2*Math.PI/nPhi;
+// 	  thetaBinSize = Math.PI/nTheta;
+// 	  System.out.println("MY NAME IS "+subdetName+" rin="+rmin+" rout="+rmax+" zmax="+zmax+", phiBinSize="+phiBinSize+", thetaBinSize="+thetaBinSize);
 	  // Set the nearest neighbor cuts to default values
-	  if(subdetName.equals(ecalSubdetName))
-	  {
+	if(subdetName.equals(ecalSubdetName)) {
             phiNNCut =2;
             thetaNNCut = 2;
-	  }
-	  else if(subdetName.equals(hcalSubdetName))
-	  {
+	}
+	else if(subdetName.equals(hcalSubdetName)) {
 	    phiNNCut =3;
 	    thetaNNCut = 3;
-	  }
 	}
+// 	}
 
 	// FIXME: This code is specific to SDJan03 - it would be nice to code
 	// this up independent of detector geometry - to be read from
 	// compact.xml or .lcdd
 	// Look up on <detector>/compact.xml for descriptions (under EcalBarrHits and similars)
 	// This is sidaug05 description (for all cal components)
-	String description = "layer:7,system:6,barrel:3,theta:32:11,phi:11";
+ 	String sidaug05_tcmt = "layer:7,system:6,barrel:3,phi:32:16,z:-16";
+	String sidaug05 = "layer:7,system:6,barrel:3,theta:32:11,phi:11";
 	try {
-	  IDDescriptor desc = new IDDescriptor(description);
+	  IDDescriptor desc = new IDDescriptor(sidaug05);
 	  encoder = new IDEncoder(desc);
 	}
 	catch(Exception e) {
@@ -107,6 +106,8 @@
 	if( subdetName.equals(muSubdetName) ) sys = 4;
 	encoder.setValue("system", sys);
 	encoder.setValue("barrel", 0);
+	// set system/barrel bits in Segmentation object
+	segm.setID(encoder.getID());
     }
 
     //----------------------------------!!!
@@ -176,22 +177,36 @@
 
         while ((Math.abs(rpVect[2]) < zmax )&& (nr < nLayers))
         {
-            // Add cell to list
+//-- replace with a more general way: findCellContainingXYZ.  GL051211
+// 	    int iphi = xyzToPhiBin(rpVect);
+// 	    int itheta = xyzToThetaBin(rpVect);
+// 	    encoder.setValue("layer", nr);
+// 	    encoder.setValue("theta", itheta);
+// 	    encoder.setValue("phi", iphi);
+// 	    long cellid = encoder.getID();
+//-------------------------------------------------------
 
-	    int iphi = xyzToPhiBin(rpVect);
-	    int itheta = xyzToThetaBin(rpVect);
+            // Add cell to list
 	    double xx = rpVect[0];
 	    double yy = rpVect[1];
+	    double zz = rpVect[2];
 	    double rho = Math.sqrt(xx*xx+yy*yy);
-// 	    System.out.println("matchHits: ("+rpVect[0]+"; "+rpVect[1]+"; "+rpVect[2]+"), rho="+rho);
 
-//             System.out.println(" CellID: layer="+nr+", iphi="+iphi+", itheta="+itheta);
-	    encoder.setValue("layer", nr);
-	    encoder.setValue("theta", itheta);
-	    encoder.setValue("phi", iphi);
-	    long cellid = encoder.getID();
- 	    System.out.println("adding to cellList: cellid="+MyTools.printID(cellid));
-	    cellList.add(cellid);
+ 	    System.out.println("BCSF.findSegment: ("+rpVect[0]+"; "+rpVect[1]+"; "+rpVect[2]+"), rho="+rho);
+
+//          System.out.println(" virtual cell: layer="+nr+", iphi="+iphi+", itheta="+itheta);
+
+	    // more general way
+	    long virtualID = segm.findCellContainingXYZ( rpVect );
+	    // this works for projective geometries only
+//  	    assert cellid == virtualID
+//  		: "*** virtual cell problem: "
+//  		+" cellID="+MyTools.printID(cellid)
+//  		+", virtualID="+MyTools.printID(virtualID);
+
+ 	    System.out.println("adding virtual hit: ID="
+			       +MyTools.printID(virtualID));
+	    cellList.add(virtualID);
 
 	    if(stpr.getStopTkELow()) break;
 	    if(nr!=(nLayers-1)) r = r + dr;
@@ -217,14 +232,14 @@
         if(subdetName.equals(hcalSubdetName))  //C.M.-27Jan03
         {
             //		HistogramFolder.setDefaultFolder("/HDCal");
-// 	    System.out.println("BCSF: Doing matchHits in HCal");
+ 	    System.out.println("BCSF: Doing matchHits in HCal");
             matchHitsFast(segm, dataMgr.getCollHitMap(hcalHitmapName) );
             //		HistogramFolder.setDefaultFolder("..");
         }
         else if(subdetName.equals(ecalSubdetName)) //
         {
             //		HistogramFolder.setDefaultFolder("/EMCal");
-// 	    System.out.println("BCSF: Doing matchHits in ECal");
+ 	    System.out.println("BCSF: Doing matchHits in ECal");
             matchHitsFast(segm, dataMgr.getCollHitMap(ecalHitmapName) );
             //		HistogramFolder.setDefaultFolder("..");		// C.M.-27Jan03- Folder
         }
@@ -274,32 +289,32 @@
     }
 
 
-    public int xyzToPhiBin(double[] r)
-    {
-        // Determine phi bin corresponding to this Cartesian coordinate
-
-        double phi;
-        int bin;
-        nc++;
-	double r1=r[1]/10; double r0=r[0]/10;
-        phi = Math.atan2(r1, r0);
-        if (phi < 0.) phi = phi + 2*Math.PI;
-        bin = (int)(phi/phiBinSize);
-        return(bin);
-    }
-
-    public int xyzToThetaBin(double[] r)
-    {
-        // Determine theta bin corresponding to this Cartesian coordinate
-        double rho, theta;
-        int bin;
-        double r1=r[1]/10; double r0=r[0]/10; double r2=r[2]/10;
-        rho = Math.sqrt(r0*r0 + r1*r1);
-        theta = Math.atan2(rho, r2);
-        if (theta < 0.) theta = theta + Math.PI;
-        bin = (int)(theta/thetaBinSize);
-        return(bin);
-    }
+//     public int xyzToPhiBin(double[] r)
+//     {
+//         // Determine phi bin corresponding to this Cartesian coordinate
+
+//         double phi;
+//         int bin;
+//         nc++;
+// 	double r1=r[1]/10; double r0=r[0]/10;
+//         phi = Math.atan2(r1, r0);
+//         if (phi < 0.) phi = phi + 2*Math.PI;
+//         bin = (int)(phi/phiBinSize);
+//         return(bin);
+//     }
+
+//     public int xyzToThetaBin(double[] r)
+//     {
+//         // Determine theta bin corresponding to this Cartesian coordinate
+//         double rho, theta;
+//         int bin;
+//         double r1=r[1]/10; double r0=r[0]/10; double r2=r[2]/10;
+//         rho = Math.sqrt(r0*r0 + r1*r1);
+//         theta = Math.atan2(rho, r2);
+//         if (theta < 0.) theta = theta + Math.PI;
+//         bin = (int)(theta/thetaBinSize);
+//         return(bin);
+//     }
 
 
     // The following two methods implement the CalorimeterHits interface
@@ -346,27 +361,29 @@
 
     //------------------------------------------------------
 
-    protected void matchHitsFast(Segmentation cell,
-				 Map<Long,SimCalorimeterHit> calHits)
+    protected void matchHitsFast(SegmentationBase cell,
+				 Map<Long,CalorimeterHit> calHits)
     {
 	this.matchHitsFast(cell, calHits, false);
     }
 
-    protected void matchHitsFast(Segmentation cell,
-				 Map<Long,SimCalorimeterHit> calHits,
+    protected void matchHitsFast(SegmentationBase cell,
+				 Map<Long,CalorimeterHit> calHits,
 				 boolean debug)
     {
       AIDA aida = AIDA.defaultInstance();
       int nhitsTotal = 0;
-      ProjectiveCylinder projCal = (ProjectiveCylinder)segm;
+//       ProjectiveCylinder projCal = (ProjectiveCylinder)segm;
       if(debug) System.out.println("matchhits: nhits = "+calHits.size());
       for( Long cellid : cellList ) {
-	if(segm instanceof ProjectiveCylinder) {
+// 	if(segm instanceof ProjectiveCylinder) {
 	  // check cell itself
-	  SimCalorimeterHit hit = calHits.get(cellid);
-	  projCal.setID(cellid);
-	  int ilay = projCal.getLayer();
+
+	  CalorimeterHit hit = calHits.get(cellid);
+	  segm.setID(cellid);
+	  int ilay = segm.getLayer();
 	  if(hit!=null) {
+	    // found real hit at virtual cell
 	    if(debug) System.out.println("matchHits: Adding hit: "+Long.toHexString(cellid));
 	     if(debug)
 		 {    
@@ -384,20 +401,22 @@
 	  }
 
 	  // now check for the neighbors
-	  projCal.setID(cellid);
-	  int iphi = projCal.getValue("phi");
-	  int ithe = projCal.getValue("theta");
-	  ilay = projCal.getLayer();
-	  long[] neighs = projCal.getNeighbourIDs(0, thetaNNCut, phiNNCut );
+	  segm.setID(cellid);
+	  int iphi = segm.getValue("phi");
+	  int ithe = segm.getValue("theta");
+	  ilay = segm.getLayer();
+	  long[] neighs = segm.getNeighbourIDs(0, thetaNNCut, phiNNCut );
+// 	  System.out.println("VirtualID="+MyTools.printID(cellid)
+// 			     +", #neighbors="+neighs.length+" "+thetaNNCut+" "+phiNNCut);
 	  for(int i=0; i<neighs.length; ++i) {
 	    hit = calHits.get(neighs[i]);
- 	    if(debug) System.out.println("neighb: cellid="+MyTools.printID(neighs[i])+", hit="+hit);
+//  	    if(debug) System.out.println("neighb: cellid="+MyTools.printID(neighs[i])+", hit="+hit);
 	    if(hit!=null) {
- 		if(debug) System.out.println("matchHits: Adding hit: "+Long.toHexString(cellid));
-		projCal.setID( neighs[i] );
-		int jphi = projCal.getValue("phi");
-		int jthe = projCal.getValue("theta");
-		int jlay = projCal.getLayer();
+ 		if(debug) System.out.println("matchHits: Adding hit: "+Long.toHexString(neighs[i]));
+		segm.setID( neighs[i] );
+		int jphi = segm.getValue("phi");
+		int jthe = segm.getValue("theta");
+		int jlay = segm.getLayer();
 		 if(debug)
 		 {    
 		      
@@ -415,7 +434,7 @@
 		nhitsTotal++;
 	    }
 	  }
-	}
+//  	}
       }
       if(debug) System.out.println("Total # hits: virtual="+cellList.size()
 				   +", real="+nhitsTotal);
@@ -423,7 +442,7 @@
 
 
     protected Detector det;
-    protected Segmentation segm;
+    protected SegmentationBase segm;
     protected IDEncoder encoder;
     protected CalHitMapMgr dataMgr;
     protected String ecalHitmapName = "EcalBarrHits";
@@ -454,4 +473,3 @@
     private int phiNNCut;
     private int thetaNNCut;
 }
-

lcsim/src/org/lcsim/recon/muon
MuonCalSegmentFinder.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- MuonCalSegmentFinder.java	6 Dec 2005 16:16:39 -0000	1.3
+++ MuonCalSegmentFinder.java	12 Dec 2005 05:45:28 -0000	1.4
@@ -12,7 +12,7 @@
 import org.lcsim.geometry.subdetector.MultiLayerTracker;
 import org.lcsim.geometry.layer.LayerStack;
 import org.lcsim.geometry.layer.LayerSlice;
-import org.lcsim.event.SimCalorimeterHit;
+import org.lcsim.event.CalorimeterHit;
 import org.lcsim.recon.cluster.density.MyTools;
 
 /**
@@ -197,16 +197,29 @@
 	System.out.println("Problem: rpVect2="+rpVect[2]+", zmax="+zmax+", nr="+nr);
         while (Math.abs(rpVect[2]) < zmax && nr < activLayers )
         {
-            // Add cell to list            
-	    int iphi = xyzToPhiBin(rpVect);
-	    int itheta = xyzToThetaBin(rpVect);
-	    System.out.println("Loop: ir="+nr+", itheta="+itheta+", iphi="+iphi);
-	    encoder.setValue("layer", nr);
-	    encoder.setValue("theta", itheta);
-	    encoder.setValue("phi", iphi);
-	    Long cellid = encoder.getID();
- 	    System.out.println("adding to cellList: cellid="+MyTools.printID(cellid));
-	    cellList.add(cellid);
+//             // Add cell to list            
+// 	    int iphi = xyzToPhiBin(rpVect);
+// 	    int itheta = xyzToThetaBin(rpVect);
+// 	    System.out.println("Loop: ir="+nr+", itheta="+itheta+", iphi="+iphi);
+// 	    encoder.setValue("layer", nr);
+// 	    encoder.setValue("theta", itheta);
+// 	    encoder.setValue("phi", iphi);
+// 	    Long cellid = encoder.getID();
+
+	    // more general way
+	    long virtualID = segm.findCellContainingXYZ( rpVect );
+	    // this works for projective geometries only
+// 	    assert cellid == virtualID
+// 		: "*** virtual cell problem: "
+// 		+" cellID="+MyTools.printID(cellid)
+// 		+", virtualID="+MyTools.printID(virtualID);
+
+ 	    System.out.println("adding virtual hit: cellid="
+			       +MyTools.printID(virtualID));
+	    cellList.add(virtualID);
+
+ 	    System.out.println("adding to cellList: cellid="+MyTools.printID(virtualID));
+	    cellList.add(virtualID);
 
 	    if(stpr.getStopTkELow())break; // C.M.
 	    // Go on to the next layer
@@ -227,9 +240,9 @@
         
         //		HistogramFolder.setDefaultFolder("/MUDet");		// C.M.-27Jan03- Folder
         
-        Map<Long,SimCalorimeterHit> muhits = dataMgr.getCollHitMap(muonName);
+        Map<Long,CalorimeterHit> muhits = dataMgr.getCollHitMap(muonName);
 	System.out.println("# muon hits: "+muhits.size());
-	matchHitsFast(segm, dataMgr.getCollHitMap(muonName), true );
+	matchHitsFast( segm, dataMgr.getCollHitMap(muonName), true );
         //		HistogramFolder.setDefaultFolder("..");			// C.M.-27Jan03- Folder
     }
    
CVSspam 0.2.8