Print

Print


Commit in lcsim/src/org/lcsim/recon/muon on MAIN
BarrelCalSegmentFinder.java+384-3621.23 -> 1.24
Updated SamplexmlClass Methods to improve functionality-Judith Odili - 08/09/06

lcsim/src/org/lcsim/recon/muon
BarrelCalSegmentFinder.java 1.23 -> 1.24
diff -u -r1.23 -r1.24
--- BarrelCalSegmentFinder.java	13 Jul 2006 23:35:30 -0000	1.23
+++ BarrelCalSegmentFinder.java	9 Aug 2006 22:46:59 -0000	1.24
@@ -19,25 +19,25 @@
 import org.lcsim.geometry.layer.*;
 import org.lcsim.geometry.Layered;
 /**
- @author Rich Markeloff, 
- Modified by Caroline Milstene - January-02-04 - To include the electromagnetic calorimeter
- and to include the loss of energy by the De/Dx and the effect of the magnetic field by using
- stepper - January-05. 
- 
- New modifications by Judith Odili - 06/22/06 - For the lcsim format - 
- To read the detector information directly from the \
- Compact.xml file by calling the Samplexmlclass methods
- 
- New modifications by Judith Odili and Caroline Milstene - 07/13/06 - 
- Modified so the Stepper information get read 
- directly from StepConditions class.
+ * @author Rich Markeloff,
+ * Modified by Caroline Milstene - January-02-04 - To include the electromagnetic calorimeter
+ * and to include the loss of energy by the De/Dx and the effect of the magnetic field by using
+ * stepper - January-05.
+ *
+ * New modifications by Judith Odili - 06/22/06 - For the lcsim format -
+ * To read the detector information directly from the \
+ * Compact.xml file by calling the Samplexmlclass methods
+ *
+ * New modifications by Judith Odili and Caroline Milstene - 07/13/06 -
+ * Modified so the Stepper information get read
+ * directly from StepConditions class.
  */
 // Muon Segment Finder for barrel calorimeter
 // Modified to include the EM Calorimeter- C.Milstene
 // Modified to use the Stepper.class in org.lcsim.util.step,
 // whenever the Swimmer class was used and in between
 // elements as well- C. Milstene-January-02-04
-// NEXT to be done: finish to debugg at 2GeV/c 
+// NEXT to be done: finish to debugg at 2GeV/c
 //                : apply to higher energy singles
 // NEXT to be done: call stepper with subdetetorName and detector layer info
 // to calculate the number of steps within the stepper- material conditions
@@ -45,46 +45,51 @@
 //
 public class BarrelCalSegmentFinder extends SegmentFinder
 {
-    public BarrelCalSegmentFinder(Detector aDet, String subdetectorName)
-    {
-
-        AIDA aida = AIDA.defaultInstance();
-
-	if(dedx==null) dedx = DeDx.instance();
-	subdetName = subdetectorName;
-
-        // Get the parameters that describe this detector component
-        det = aDet;
-        String a_nam = det.getHeader().getDetectorName();
-        calsub = (CylindricalBarrelCalorimeter)det.getSubdetectors().get(subdetName);
-
-       
-        Layering layers = ((Layered) calsub).getLayering();
-       
-        rmin = calsub.getInnerRadius();
-        rmax = calsub.getOuterRadius();
-        zmax = calsub.getZMax();
-        nLayers = layers.getLayerCount();
-	rLayer0Mid = calsub.getLayering().getDistanceToLayerSensorMid(0);
-
-	dataMgr = CalHitMapMgr.getInstance();
-	segm = (SegmentationBase)calsub.getReadout().getSegmentation();
-	  // Set the nearest neighbor cuts to default values
-	if(subdetName.equals(ecalSubdetName)) {
-            phiNNCut   = 2; // 2;
-            thetaNNCut = 2; // 2;
-	}
-	else if(subdetName.equals(hcalSubdetName)) {
-	    phiNNCut   = 0; // 3;
-	    thetaNNCut = 0; // 2;
-	}
-
-	
-        //The purpose of this statement is to specify the xml file the data should be read from
-        String filename = "C:\\work\\LCDetectors\\detectors\\" + a_nam +"\\compact.xml";
+   public BarrelCalSegmentFinder(Detector aDet, String subdetectorName)
+   {
+      
+      AIDA aida = AIDA.defaultInstance();
+      
+      if(dedx==null) dedx = DeDx.instance();
+      subdetName = subdetectorName;
+      
+      // Get the parameters that describe this detector component
+      det = aDet;
+      String a_nam = det.getHeader().getDetectorName();
+      calsub = (CylindricalBarrelCalorimeter)det.getSubdetectors().get(subdetName);
+      
+      
+      Layering layers = ((Layered) calsub).getLayering();
+      
+      rmin = calsub.getInnerRadius();
+      rmax = calsub.getOuterRadius();
+      zmax = calsub.getZMax();
+      nLayers = layers.getLayerCount();
+      rLayer0Mid = calsub.getLayering().getDistanceToLayerSensorMid(0);
+      
+      dataMgr = CalHitMapMgr.getInstance();
+      segm = (SegmentationBase)calsub.getReadout().getSegmentation();
+      // Set the nearest neighbor cuts to default values
+      if(subdetName.equals(ecalSubdetName))
+      {
+         phiNNCut   = 2; // 2;
+         thetaNNCut = 2; // 2;
+      }
+      else if(subdetName.equals(hcalSubdetName))
+      {
+         phiNNCut   = 3; // 3;
+         thetaNNCut = 2; // 2;
+      }
+      
+      
+      //The purpose of this statement is to specify the xml file the data should be read from
+      String filename = "C:\\work\\LCDetectors\\detectors\\" + a_nam +"\\compact.xml";
         File f = new File(filename);
    	xmlReader.declarefile(f);
-        String readoutseg = xmlReader.getReadoutId(subdetName);
+        xmlReader.SystemInfo(subdetName);
+        String readoutseg = xmlReader.getReadoutID();
+        System.out.println(" BCF: Readoutseg ===" + readoutseg);
+       
 	try {
 	  IDDescriptor desc = new IDDescriptor(readoutseg);
           encoder = new IDEncoder(desc);
@@ -95,180 +100,181 @@
 	// Set system and barrel/endcap values
 	int sys = 0;
 	if(debug)System.out.println("BCSF constructor: subdetName="+subdetName);
-        sys = xmlReader.getSubdetId(subdetName);
+        sys = xmlReader.getSystemID();
         encoder.setValue("system", sys);
 	encoder.setValue("barrel", 0);
-	// set system/barrel bits in Segmentation object
-	segm.setID(encoder.getID());
-        
-    }
-
-    //----------------------------------!!!
-    public void findSegment(EventHeader event, TrackStepper inStpr)
-    //----------------------------------!!!
-    {
-        stpr    = inStpr;
-        int nr = 0;					// layer counter
-        int nLayerStepped=0;       // curlback layers included
-        double dr = (rmax - rmin)/nLayers;		// layer thickness
-        numLayersHit = 0;
-       
-
-        double r;
-        // C.M. Dec-03- Tkparams to stepper
-        double tmpxyz ; double tmpp;
-        String materialName;
-        r=rmin;
-        // UPDATE Phase-Space
-        rpVect  = stpr.getNewRp();
-	if(debug) System.out.println("findSegment: subd="+subdetName);
-        if(stpr.getStopTkELow())return;
-        double[] field = det.getFieldMap().getField(rpVect); // C.M.-June-03
-	    BField = field[2];
-        if(subdetName.equals(ecalSubdetName))
-        {
-        // Then do the Tracker up to r=rmin
-        double dTracker=(r-stpr.partR(rpVect));
-        stpr.setDTOF(rpVect,dTracker);
-        double dtTracker=stpr.getDTOF();
-	    //stepConditions = steprConditions(dTracker,BField,0.,dtTracker);
-	    //stpr.tkSteps( r, zmax,stepConditions);
-          materialName = "Air";
-           stpr.tkSteps( r, zmax,det, materialName );
-	    if(debug)System.out.println("Tracker r=" +r+" zmax="+zmax+"Barrel:out of Tracker");
-	    rpVect   = stpr.getNewRp();
-        if(debug)System.out.println(" CHECK NOW at Exit of Tracker rmin="+rmin+" dr="+dr) ;
-        if(r<(rmin-dr))return; // does not enter ECAL
-        }
-        if(subdetName.equals(hcalSubdetName))
-        {
-	    if(debug)System.out.println(" !!!=== rmin="+rmin+" r="+r);
-	    // Then air to r=rmin
-        rpVect   = stpr.getNewRp();
-	    double d_EMHD = Math.abs(r-stpr.partR(rpVect));
-        stpr.setDTOF(rpVect,d_EMHD);
-        double dt_EMHD=stpr.getDTOF();
-	    if(debug)System.out.println(" distance between calorimeters EM-HD "+d_EMHD);
-	    //stepConditions = steprConditions(d_EMHD,BField,0.,dt_EMHD);
-	    //stpr.tkSteps(r,zmax,stepConditions);
-            materialName = "Air";
-           stpr.tkSteps( r, zmax,det, materialName );
-	    rpVect  = stpr.getNewRp();
-        // if(r<(rmin-dr))return; // does not enter HCAL
-        }
-        if(debug)System.out.println("Stepper pos ENTRY of:("+subdetName+" "+rpVect[0]+"; "+rpVect[1]+"; "+rpVect[2]+"), r="+stpr.partR(rpVect));
-        
-        // 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
-	    if(debug)System.out.println("subdet="+subdetName+", sensormid="+rLayer0Mid);
-        r    = rLayer0Mid;
+      // set system/barrel bits in Segmentation object
+      segm.setID(encoder.getID());
+      
+   }
+   
+   //----------------------------------!!!
+   public void findSegment(EventHeader event, TrackStepper inStpr)
+   //----------------------------------!!!
+   {
+      stpr    = inStpr;
+      int nr = 0;					// layer counter
+      int nLayerStepped=0;       // curlback layers included
+      double dr = (rmax - rmin)/nLayers;		// layer thickness
+      numLayersHit = 0;
+      
+      
+      double r;
+      // C.M. Dec-03- Tkparams to stepper
+      double tmpxyz ; double tmpp;
+      String materialName;
+      r=rmin;
+      // UPDATE Phase-Space
+      rpVect  = stpr.getNewRp();
+      if(debug) System.out.println("findSegment: subd="+subdetName);
+      if(stpr.getStopTkELow())return;
+      double[] field = det.getFieldMap().getField(rpVect); // C.M.-June-03
+      BField = field[2];
+      if(subdetName.equals(ecalSubdetName))
+      {
+         // Then do the Tracker up to r=rmin
+         double dTracker=(r-stpr.partR(rpVect));
+         //stepConditions = steprConditions(dTracker,BField,0.,dtTracker);
+         //stpr.tkSteps( r, zmax,stepConditions);
+         materialName = "Air";
+         stpr.tkSteps( r, zmax,det, materialName );
+         if(debug)System.out.println("Tracker r=" +r+" zmax="+zmax+"Barrel:out of Tracker");
+         rpVect   = stpr.getNewRp();
+         if(debug)System.out.println(" CHECK NOW at Exit of Tracker rmin="+rmin+" dr="+dr) ;
+         if(r<(rmin-dr))return; // does not enter ECAL
+      }
+      if(subdetName.equals(hcalSubdetName))
+      {
+         if(debug)System.out.println(" !!!=== rmin="+rmin+" r="+r);
+         // Then air to r=rmin
+         rpVect   = stpr.getNewRp();
+         double d_EMHD = Math.abs(r-stpr.partR(rpVect));
+         stpr.setDTOF(rpVect,d_EMHD);
+         double dt_EMHD=stpr.getDTOF();
+         if(debug)System.out.println(" distance between calorimeters EM-HD "+d_EMHD);
+         materialName = "Air";
+         stpr.tkSteps( r, zmax,det, materialName );
+         rpVect  = stpr.getNewRp();
+         // if(r<(rmin-dr))return; // does not enter HCAL
+      }
+      if(debug)System.out.println("Stepper pos ENTRY of:("+subdetName+" "+rpVect[0]+"; "+rpVect[1]+"; "+rpVect[2]+"), r="+stpr.partR(rpVect));
+      
+      // 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
+      if(debug)System.out.println("subdet="+subdetName+", sensormid="+rLayer0Mid);
+      r    = rLayer0Mid;
+      stpr.tkSteps(r, zmax,det, subdetName, nr);
+      rpVect  = stpr.getNewRp();
+      if(debug)System.out.println(subdetName+" !!!!!! 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
+      nLayerStepped=0;
+      while ((Math.abs(rpVect[2]) <= zmax )&& (nr < nLayers))
+      {
+         Hep3Vector v = new BasicHep3Vector(rpVect[0],rpVect[1],rpVect[2]);
+         hitPos.add(v);
+         long virtualID = segm.findCellContainingXYZ( rpVect );
+         cellList.add(virtualID);
+         if(stpr.getStopTkELow()) break;
+         
+         if(stpr.getCurlBack())
+         {
+            if(debug)System.out.println("!!!BCF:CURLINGBACK old r="+r+" New r="+(r-dr));
+            r=r-dr   ;
+         }
+         else if(nr!=(nLayers-1)) r = r + dr;
+         else
+         {
+            r = rmin + nLayers * dr;
+            if(debug)System.out.println("BCF: AT Exit of "+subdetName+", r="+r);
+         }
+         
          stpr.tkSteps(r, zmax,det, subdetName, nr);
-        rpVect  = stpr.getNewRp();
-        if(debug)System.out.println(subdetName+" !!!!!! 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
-        nLayerStepped=0;
-        while ((Math.abs(rpVect[2]) <= zmax )&& (nr < nLayers))
-        {
-          Hep3Vector v = new BasicHep3Vector(rpVect[0],rpVect[1],rpVect[2]);
-          hitPos.add(v);
-	      if(stpr.getStopTkELow()) break;
-
-            if(stpr.getCurlBack())
-            {
-                if(debug)System.out.println("!!!BCF:CURLINGBACK old r="+r+" New r="+(r-dr));
-             r=r-dr   ;
-            } else if(nr!=(nLayers-1)) r = r + dr;
-	      else {
-	       r = rmin + nLayers * dr;
-	       if(debug)System.out.println("BCF: AT Exit of "+subdetName+", r="+r);
-	     }
-	      
-            stpr.tkSteps(r, zmax,det, subdetName, nr);
-	       rpVect = stpr.getNewRp();
-          // double dThk=(nr!=(nLayers-1))?dr:(dr+dr-(rLayer0Mid-rmin));
-           
-              if(!stpr.getCurlBack())nr++;
-	      nLayerStepped++;
-        }//End of : Go on to the next layer
-        // Save number of layers track passed through
-        numLayersHit = nr;
-	     if(debug)System.out.println("Stepper pos EXIT of:("+subdetName+" "+rpVect[0]+"; "+rpVect[1]+"; "+rpVect[2]+"), r="+stpr.partR(rpVect));
-        rpVect= stpr.getNewRp();
-        if((rpVect[2]>=zmax)||stpr.getStopTkELow())
-        {// Record Last Layer and Info at Break
+         rpVect = stpr.getNewRp();
+         // double dThk=(nr!=(nLayers-1))?dr:(dr+dr-(rLayer0Mid-rmin));
+         
+         if(!stpr.getCurlBack())nr++;
+         nLayerStepped++;
+      }//End of : Go on to the next layer
+      // Save number of layers track passed through
+      numLayersHit = nr;
+      if(debug)System.out.println("Stepper pos EXIT of:("+subdetName+" "+rpVect[0]+"; "+rpVect[1]+"; "+rpVect[2]+"), r="+stpr.partR(rpVect));
+      rpVect= stpr.getNewRp();
+      if((rpVect[2]>=zmax)||stpr.getStopTkELow())
+      {// Record Last Layer and Info at Break
          Hep3Vector v =new BasicHep3Vector(rpVect[0],rpVect[1],rpVect[2]);
          hitPos.add(v);
-        }
-
-	double rr=stpr.partR(rpVect);
-       // Now match the cells on this list to calorimeter hits
-        if(subdetName.equals(hcalSubdetName))  //C.M.-27Jan03
-        {
-
-//  	    System.out.println("BCSF: Doing matchHits in HCal");
-            matchHitsFast(segm, dataMgr.getCollHitMap(hcalHitmapName) );
-
-        }
-        else if(subdetName.equals(ecalSubdetName)) //
-        {
-//  	    System.out.println("BCSF: Doing matchHits in ECal");
-            matchHitsFast(segm, dataMgr.getCollHitMap(ecalHitmapName) );
-        }
-
-
-    }
-
-    public void reset()
-    {
-        // Erase lists of hits and cells
-        hitList.removeAllElements();
-        cellList.removeAllElements();
-
-    }
-
-    public void setPhiNNCut(int cut)
-    {
-
-        // Set the number of nearest neighbors cut in phi. Cells
-        // with abs(phi_track - phi_cell) <=  cut will be added
-        // to the list
-
-        phiNNCut = cut;
-    }
-
-    public void setThetaNNCut(int cut)
-    {
-
-        // Set the number of nearest neighbors cut in theta. Cells
-        // with abs(theta_track - theta_cell) <=  cut will be added
-        // to the list
-
-        thetaNNCut = cut;
-    }
-
-    public double[] getNNCuts()
-    {
-        // Return the number of nearest neighbors cuts in phi and theta
-
-        return(new double[]
-        {phiNNCut, thetaNNCut});
-    }
-
-    public int getNLayersHit()
-    {
-        // Return the number of layers the track passed through
-
-        return(numLayersHit);
-    }
-
-
+      }
+      
+      double rr=stpr.partR(rpVect);
+      // Now match the cells on this list to calorimeter hits
+      if(subdetName.equals(hcalSubdetName))  //C.M.-27Jan03
+      {
+         
+  	 if (debug) System.out.println("BCSF: Doing matchHits in HCal");
+         matchHitsFast(segm, dataMgr.getCollHitMap(hcalHitmapName) );
+         
+      }
+      else if(subdetName.equals(ecalSubdetName)) //
+      {
+  	 if (debug) System.out.println("BCSF: Doing matchHits in ECal");
+         matchHitsFast(segm, dataMgr.getCollHitMap(ecalHitmapName) );
+      }
+      
+      event.put(subdetName+"FoundHits",foundHits);
+   }
+   
+   public void reset()
+   {
+      // Erase lists of hits and cells
+      hitList.removeAllElements();
+      cellList.removeAllElements();
+      
+   }
+    
+   
+   public void setPhiNNCut(int cut)
+   {
+      
+      // Set the number of nearest neighbors cut in phi. Cells
+      // with abs(phi_track - phi_cell) <=  cut will be added
+      // to the list
+      
+      phiNNCut = cut;
+   }
+   
+   public void setThetaNNCut(int cut)
+   {
+      
+      // Set the number of nearest neighbors cut in theta. Cells
+      // with abs(theta_track - theta_cell) <=  cut will be added
+      // to the list
+      
+      thetaNNCut = cut;
+   }
+   
+   public double[] getNNCuts()
+   {
+      // Return the number of nearest neighbors cuts in phi and theta
+      
+      return(new double[]
+      {phiNNCut, thetaNNCut});
+   }
+   
+   public int getNLayersHit()
+   {
+      // Return the number of layers the track passed through
+      
+      return(numLayersHit);
+   }
+   
+   
 //     public int xyzToPhiBin(double[] r)
 //     {
 //         // Determine phi bin corresponding to this Cartesian coordinate
-
+   
 //         double phi;
 //         int bin;
 //         nc++;
@@ -278,7 +284,7 @@
 //         bin = (int)(phi/phiBinSize);
 //         return(bin);
 //     }
-
+   
 //     public int xyzToThetaBin(double[] r)
 //     {
 //         // Determine theta bin corresponding to this Cartesian coordinate
@@ -291,159 +297,175 @@
 //         bin = (int)(theta/thetaBinSize);
 //         return(bin);
 //     }
-
-
-    // The following two methods implement the CalorimeterHits interface
-
-    public Enumeration getHits()
-    {
-        return(hitList.elements());
-    }
-    public Enumeration getHitsPos()
-    {
-        return(hitPos.elements());
-    }
-
-    public int getNHits()
-    {
-        return(hitList.size());
-    }
-    public int getNHitsPos()
-    {
-        return(hitPos.size());
-    }
-    //----------------------------------------------------------C.M. Step Conditions
-    public double[] steprConditions(double dthick,double theField,double theMeanDEdx,double DTOF0)
-    {
-        return(new double[]
-        {dthick, theField,theMeanDEdx,DTOF0});
-    }
-    //--------------------------------------------C.M.- Get DE/dx per Calorimeter Layer
-    
    
-
-    protected void matchHitsFast(SegmentationBase cell,
-				 Map<Long,CalorimeterHit> calHits)
-    {
-	this.matchHitsFast(cell, calHits, false);
-    }
-
-    protected void matchHitsFast(SegmentationBase cell,
-				 Map<Long,CalorimeterHit> calHits,
-				 boolean debug)
-    {
-       if(debug)System.out.println("Segm:::: "  + cell);
-        AIDA aida = AIDA.defaultInstance();
+   
+   // The following two methods implement the CalorimeterHits interface
+   
+   public Enumeration getHits()
+   {
+      return(hitList.elements());
+   }
+   public Enumeration getHitsPos()
+   {
+      return(hitPos.elements());
+   }
+   
+   public int getNHits()
+   {
+      return(hitList.size());
+   }
+   public int getNHitsPos()
+   {
+      return(hitPos.size());
+   }
+   //----------------------------------------------------------C.M. Step Conditions
+   public double[] steprConditions(double dthick,double theField,double theMeanDEdx,double DTOF0)
+   {
+      return(new double[]
+      {dthick, theField,theMeanDEdx,DTOF0});
+   }
+   //--------------------------------------------C.M.- Get DE/dx per Calorimeter Layer
+   
+   
+   
+   protected void matchHitsFast(SegmentationBase cell,
+           Map<Long,CalorimeterHit> calHits)
+   {
+      this.matchHitsFast(cell, calHits, false);
+   }
+   
+   protected void matchHitsFast(SegmentationBase cell,
+           Map<Long,CalorimeterHit> calHits,
+           boolean debug)
+   {
+      if(debug)System.out.println("Segm:::: "  + cell);
+      AIDA aida = AIDA.defaultInstance();
       int nhitsTotal = 0;
 //       ProjectiveCylinder projCal = (ProjectiveCylinder)segm;
       if(debug) System.out.println("matchhits: nhits = "+calHits.size());
-      for( Long cellid : cellList ) {
+      for( Long cellid : cellList )
+      {
 // 	if(segm instanceof ProjectiveCylinder) {
-	  // check cell itself
-
-	  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) {
-		double dall=0.;
-		for(int j=0;j<nLayers;j=j+4)
-		{
-		    if(ilay==j)
-		    {
-		        aida.cloud1D(subdetName+" dphi layer "+ilay).fill(dall);
-		        aida.cloud1D(subdetName+" dtheta layer "+ilay).fill(dall);
-		    }
-		}
-	    }
-	    hitList.add(hit);
-	    nhitsTotal++;
-	  }
-
-	  // now check for the neighbors
-	  segm.setID(cellid);
-	  int iphi = segm.getValue("phi");
-	  int ithe = -99999;
-	  try {
-  	    ithe = segm.getValue("theta");
-	  }
-	  catch(NullPointerException x) {
+         // check cell itself
+         
+         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)
+            {
+               double dall=0.;
+               for(int j=0;j<nLayers;j=j+4)
+               {
+                  if(ilay==j)
+                  {
+                     aida.cloud1D(subdetName+" dphi layer "+ilay).fill(dall);
+                     aida.cloud1D(subdetName+" dtheta layer "+ilay).fill(dall);
+                  }
+               }
+            }
+            foundHits.add(new BasicHep3Vector(segm.getX(),segm.getY(),segm.getZ()));
+            hitList.add(hit);
+            nhitsTotal++;
+         }
+         
+         // now check for the neighbors
+         segm.setID(cellid);
+         int iphi = segm.getValue("phi");
+         int ithe = -99999;
+         try
+         {
+            //ithe = segm.getValue("theta");
+            ithe = segm.getValue("z");
+         }
+         catch(IllegalArgumentException x)
+         {
             ithe = segm.getValue("z");
-	  }
-	  ilay = segm.getLayer();
-	  long[] neighs = segm.getNeighbourIDs(0, thetaNNCut, phiNNCut );
+         }
+         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]);
+         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(hit!=null) {
- 		if(debug) System.out.println("matchHits: Adding hit: "+Long.toHexString(neighs[i]));
-		segm.setID( neighs[i] );
-// 		int jphi = segm.getValue("phi");
-// 		int jthe = 0;
-// 		try {
-// 		    jthe = segm.getValue("theta");
-// 		}
-// 		catch(NullPointerException x) {
-// 		    jthe = segm.getValue("z");
-// 		}
-// 		int jlay = segm.getLayer();
-// 		// if(debug)
-// 		 //{
-// 		       for(int j=0;j<nLayers;j=j+4)
-// 		       {
-// 		        if(ilay==j)
-// 			{
-// 		        aida.cloud1D(subdetName+" dphi layer "+ilay).fill(jphi-iphi);
-// 		        aida.cloud1D(subdetName+" dtheta layer "+ilay).fill(jthe-ithe);
-// 		        }
-// 		       }
-// 		// }
-		hitList.add(hit);
-		nhitsTotal++;
-	    }
-	  }
-//  	}
+            if(hit!=null)
+            {
+               if(debug) System.out.println("matchHits: Adding hit: "+Long.toHexString(neighs[i]));
+               segm.setID( neighs[i] );
+               int jphi = segm.getValue("phi");
+               int jthe = 0;
+               try
+               {
+                  //jthe = segm.getValue("theta");
+                   jthe = segm.getValue("z");
+               }
+               catch(IllegalArgumentException x)
+               {
+                  jthe = segm.getValue("z");
+               }
+               
+               int jlay = segm.getLayer();
+               if(debug)
+               {
+                  for(int j=0;j<nLayers;j=j+4)
+                  {
+                     if(ilay==j)
+                     {
+                        aida.cloud1D(subdetName+" dphi layer "+ilay).fill(jphi-iphi);
+                        aida.cloud1D(subdetName+" dtheta layer "+ilay).fill(jthe-ithe);
+                     }
+                  }
+               }
+               foundHits.add(new BasicHep3Vector(segm.getX(),segm.getY(),segm.getZ()));
+               hitList.add(hit);
+               nhitsTotal++;
+            }
+         }
       }
+//  	}
       if(debug) System.out.println("Total # hits: virtual="+cellList.size()
-				   +", real="+nhitsTotal);
-    }
-
-
-    protected Detector det;
-    protected CylindricalBarrelCalorimeter calsub;
-    protected SegmentationBase segm;
-    protected IDEncoder encoder;
-    protected CalHitMapMgr dataMgr;
-    protected String ecalHitmapName = "EcalBarrHits";
-    protected String hcalHitmapName = "HcalBarrHits";
-    protected String ecalSubdetName = "EMBarrel";
-    protected String hcalSubdetName = "HADBarrel";
-    protected String muSubdetName = "MuonBarrel";
-    protected boolean debug = false;
-    protected int nc=0;
-    protected double BField ;// C.M.-Jan03
-    protected DeDx dedx;
-    protected double []rpVect       = new double[8] ;         // C.M.-4-Vector
-    protected String subdetName;      // C.M.-Jan03
-    protected double rmin;
-    protected double rLayer0Mid, totalthickness;
-    protected double rmax;
-    protected double zmax;
-    protected int nLayers;
-    protected int nPhi;
-    protected int nTheta;
-    protected double phiBinSize;
-    protected double thetaBinSize;
-    protected int numLayersHit;
-    protected Vector<Long> cellList = new Vector<Long>(); // list of cell indices
-    protected TrackStepper stpr     = new TrackStepper(); //C.M.-Stepper Instance
-    protected double [] stepConditions = new double[4];
-    protected Map<String, Double> materials;
-    public static Samplexmlclass xmlReader = new Samplexmlclass();
-    private int phiNNCut;
-    private int thetaNNCut;
+      +", real="+nhitsTotal);
+   }
+   
+   
+   protected Detector det;
+   protected CylindricalBarrelCalorimeter calsub;
+   protected SegmentationBase segm;
+   protected IDEncoder encoder;
+   protected CalHitMapMgr dataMgr;
+   protected String ecalHitmapName = "EcalBarrHits";
+   protected String hcalHitmapName = "HcalBarrHits";
+   protected String ecalSubdetName = "EMBarrel";
+   protected String hcalSubdetName = "HADBarrel";
+   protected String muSubdetName = "MuonBarrel";
+   protected boolean debug = true;
+   protected int nc=0;
+   protected double BField ;// C.M.-Jan03
+   protected DeDx dedx;
+   protected double []rpVect       = new double[8] ;         // C.M.-4-Vector
+   protected String subdetName;      // C.M.-Jan03
+   protected double rmin;
+   protected double rLayer0Mid, totalthickness;
+   protected double rmax;
+   protected double zmax;
+   protected int nLayers;
+   protected int nPhi;
+   protected int nTheta;
+   protected double phiBinSize;
+   protected double thetaBinSize;
+   protected int numLayersHit;
+   protected Vector<Long> cellList = new Vector<Long>(); // list of cell indices
+   protected TrackStepper stpr     = new TrackStepper(); //C.M.-Stepper Instance
+   protected double [] stepConditions = new double[4];
+   protected Map<String, Double> materials;
+   public static Samplexmlclass xmlReader = new Samplexmlclass();
+   private int phiNNCut;
+   private int thetaNNCut;
+   private List<Hep3Vector> foundHits = new ArrayList<Hep3Vector>();
 }
CVSspam 0.2.8