Commit in lcsim/src/org/lcsim/recon/muon on MAIN
BarrelCalSegmentFinder.java+44-271.6 -> 1.7
CM: Changes to the new geometry- new units

lcsim/src/org/lcsim/recon/muon
BarrelCalSegmentFinder.java 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- BarrelCalSegmentFinder.java	18 Jul 2005 18:09:37 -0000	1.6
+++ BarrelCalSegmentFinder.java	31 Oct 2005 22:31:14 -0000	1.7
@@ -12,7 +12,7 @@
 import org.lcsim.recon.muon.*;
 import org.lcsim.geometry.Detector;
 import org.lcsim.geometry.FieldMap;
-import org.lcsim.geometry.subdetector.CylindricalCalorimeter;
+import org.lcsim.geometry.subdetector.CylindricalBarrelCalorimeter;
 import org.lcsim.geometry.compact.Segmentation;
 import org.lcsim.geometry.util.IDEncoder;
 import org.lcsim.geometry.segmentation.ProjectiveCylinder;
@@ -37,7 +37,7 @@
 
         // Get the parameters that describe this detector component
         det = aDet;
-        CylindricalCalorimeter calsub = (CylindricalCalorimeter)det.getSubdetectors().get(name);
+        CylindricalBarrelCalorimeter calsub = (CylindricalBarrelCalorimeter)det.getSubdetectors().get(name);
 	
         /** 
          * Get materials (of 1st layer only) from LayeredCalorimeter class. 
@@ -68,7 +68,7 @@
 	  phiBinSize = 2*Math.PI/nPhi;
 	  thetaBinSize = Math.PI/nTheta;
 	  aname = name;                   //  C.M.-June-03
-	  System.out.println("aname="+aname);
+	  System.out.println("MY NAME IS "+aname+" rin="+rmin+" rout="+rmax+" zmax="+zmax);
 	  // Set the nearest neighbor cuts to default values
 	  if(aname.equals(EcalName))
 	  {
@@ -116,33 +116,41 @@
         // C.M. Dec-03- Tkparams to stepper
         double tmpxyz ; double tmpp;
         r=rmin;
-        if(aname.equals(EcalName))
+	System.out.println(aname);
+        if(aname.equals("EMBarrel"))
         {
+	     rpVect  = stpr.getNewRp();
             // Then do the Tracker up to r=rmin
 	    double[] pos = new double[]{rmin, 0.0, 0.0};
 	    double[] field = det.getFieldMap().getField(pos); // C.M.-June-03
 	    System.out.println("BField: ("+field[0]+", "+field[1]+", "+field[2]+")");
 	    BField = field[2];
             stepConditions = steprConditions(200.,BField,0.);
+	    System.out.println("Barrel Field before 1st stepper call "+BField);
+            System.out.println("Barrel:stepcd="+stepConditions[0]+" "+stepConditions[1]+" "+stepConditions[2]);
             stpr.tkSteps( r, zmax,stepConditions);
-        }
+	    System.out.println("Tracker r=" +r+" zmax="+zmax);
+	    System.out.println("Barrel:out of Tracker");
+	}
         
-        if(aname.equals(HcalName))
+        if(aname.equals("HADBarrel"))
         {
+	    // Then air to r=rmin
 	    double[] pos = new double[]{rmin, 0.0, 0.0};
 	    double[] field = det.getFieldMap().getField(pos);  // C.M.-June-03
 	    BField = field[2];
-
-            // first 9.2 cm of Carbon from EM to r=rmin=2.8
-            stepConditions = steprConditions(10.,BField,0.036424);
-            stpr.tkSteps((r-2.8),zmax,stepConditions);
-            
-            // Then air to r=rmin
-            stepConditions = steprConditions(28.,BField,0.);
-            stpr.tkSteps(r,zmax,stepConditions);
+            rpVect   = stpr.getNewRp();
+	    double rnow= Math.abs(Math.sqrt(rpVect[0]*rpVect[0]+rpVect[1]));
+	    double d_EMHD = Math.abs(r-rnow);
+	    System.out.println(" distance between calorimeters EM-HD "+d_EMHD);
+            stepConditions = steprConditions((10*d_EMHD),BField,0.0);
+            stpr.tkSteps(r,zmax,stepConditions);  
         }
+	
+	rpVect  = stpr.getNewRp();
         xNumSteps = 10.;
         stepConditions = steprConditions(xNumSteps,BField,meanDEdxPerLay(aname));
+	System.out.println("Barrel:MeanDEdxPerLay="+meanDEdxPerLay(aname));
         // Forms a muon segment by looking for calorimeter hits that match
         // cells which the track passes through
         // Begin by finding intersection of track with innermost layer
@@ -150,37 +158,40 @@
         r          = rmin+0.5*dr;
         
         stpr.tkSteps(r, zmax,stepConditions);
-        rstep   = stpr.getRAfterStep();
-        
+        rpVect  = stpr.getNewRp();
+        System.out.println(aname+" !!!!!! rmin="+rmin);
         // Get intersections with successive layers as long as track is
         // within the detector, and create a list of the cells that
         // the track passes through
         
-        while ((Math.abs(rstep[2]) < zmax )&& (nr < nLayers))
+        while ((Math.abs(rpVect[2]) < zmax )&& (nr < nLayers))
         {
             // Add cell to list
             
-	    int iphi = xyzToPhiBin(rstep);
-	    int itheta = xyzToThetaBin(rstep);
+	    int iphi = xyzToPhiBin(rpVect);
+	    int itheta = xyzToThetaBin(rpVect);
 	    encoder.setValue("layer", nr);
 	    encoder.setValue("theta", itheta);
 	    encoder.setValue("phi", iphi);
 	    Long cellid = encoder.getID();
 	    cellList.add(cellid);
-
+            
 	    if(stpr.getStopTkELow()) break;
 	    if(nr!=(nLayers-1)) r = r + dr;
 	    else {
               r=r+0.5*dr;
 	    }	 // Go on to the next layer
 	    stpr.tkSteps(r, zmax,stepConditions);
-	    rstep  = stpr.getRAfterStep();
+	    rpVect = stpr.getNewRp();
 	    nr++;
                 
         }
         // Save number of layers track passed through
         numLayersHit = nr;
         rpVect= stpr.getNewRp();
+	double rr=stpr.partR();
+	if((Math.abs(rpVect[2])<=zmax-0.1)|| (rr>=rmax+0.1))
+	   stpr.resetAtZmax(); // reset for next sub-detector
         
         
         // Now match the cells on this list to calorimeter hits
@@ -250,7 +261,8 @@
         double phi;
         int bin;
         nc++;
-        phi = Math.atan2(r[1], r[0]);
+	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);
@@ -261,9 +273,9 @@
         // Determine theta bin corresponding to this Cartesian coordinate
         double rho, theta;
         int bin;
-        
-        rho = Math.sqrt(r[0]*r[0] + r[1]*r[1]);
-        theta = Math.atan2(rho, r[2]);
+        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);
@@ -293,16 +305,21 @@
 //         String compoundMaterial = name+"_Material";
         double matterDEdx=0.;
 //         MaterialList emml = (MaterialList) det.get(name+"_Material");
+         int i=0;
         for( String mat : materials.keySet() )
         {
 //             Material emmat = emml.getMaterial(i);
 //             String mat     = emml.getName();
 //             double tthk    = emml.getThickness();
+             i++;
             double tthk    = materials.get(mat).doubleValue();
-            double e1      = tthk * dedx.getDeDx(mat);  // energy loss this material
-// 	    System.out.println("matName="+mat+", thickness="+tthk+", dEdx="+e1);
+            double e1      = tthk * (dedx.getDeDx(mat)/10);  // energy loss this material
+	    //System.out.println("matName="+mat+", thickness="+tthk+", dEdx="+dedx.getDeDx(mat));
             matterDEdx    += e1;                       // sum energy loss per material
+	    //System.out.println(" DedxPerMateriel (GeV/cm) ="+dedx.getDeDx(mat)+" thickness(mm)="+tthk+ " element="+i);
         }
+	    System.out.println(" MeanDedxPerLay (GeV) ="+matterDEdx);
+
         return matterDEdx ;
     }
     
CVSspam 0.2.8