Print

Print


Commit in lcsim/src/org/lcsim/recon/muon on MAIN
BarrelCalSegmentFinder.java+80-881.20 -> 1.21
C. Milstene & T. Johnson-01-2006- To include the reconstructed tracks into Wired-
C. Milstene- 06-16-2006- include curling back low momenta tracks

lcsim/src/org/lcsim/recon/muon
BarrelCalSegmentFinder.java 1.20 -> 1.21
diff -u -r1.20 -r1.21
--- BarrelCalSegmentFinder.java	30 Jan 2006 21:58:51 -0000	1.20
+++ BarrelCalSegmentFinder.java	16 Jun 2006 20:42:39 -0000	1.21
@@ -20,6 +20,12 @@
 // 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 
+//                : 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
+// moved from stepperConditions to a StepperCondition.Class in util/step directory
+//
 public class BarrelCalSegmentFinder extends SegmentFinder
 {
     public BarrelCalSegmentFinder(Detector aDet, String subdetectorName)
@@ -32,10 +38,17 @@
 
         // Get the parameters that describe this detector component
         det = aDet;
+        String a_nam = det.getHeader().getDetectorName();
+        System.out.println("              DETECTOR "+a_nam);
         calsub = (CylindricalBarrelCalorimeter)det.getSubdetectors().get(subdetName);
 
-        /**
+        /** NEXT:to be done This will be part of new class StepperConditions.java located in
+         * util/step -with a fuction calculating dE/dx=f(p) Sternheimer getting all
+         * the materiel related business, radiation lenght interaction length
+         *
          * Get materials (of 1st layer only) from LayeredCalorimeter class.
+         * NEXT :to be changed by getting materiel information layer by layer
+         * when called by the stepper which will provide sunDetName and Layer number
          *
          * WARNING: This approach is prone to error, because the slices are
          * not guaranteed to be the same thickness in every layer.
@@ -75,14 +88,13 @@
 	    thetaNNCut = 0; // 2;
 	}
 
-
-	// 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)
+	//NEXT This will be read from- org.lcsim.geometry.compact.Detector
+	// <detector>/compact.xml for descriptions (under EcalBarrHits and
+	//similars)
+	// This is sidaug05 description (for all cal components)-from GL
  	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(sidaug05_tcmt);
 	  encoder = new IDEncoder(desc);
@@ -108,12 +120,12 @@
     {
         stpr    = inStpr;
         int nr = 0;					// layer counter
+        int nLayerStepped=0;       // curlback layers included
         double dr = (rmax - rmin)/nLayers;		// layer thickness
-        //double [] rint = new double[3];			// intersection coords.
         numLayersHit = 0;
        //  steplength = distance/xNumsteps used in the stepper --> therefore
        //  we choose the number ofsteps to be multiple of the distance
-        double xNumSteps;
+
         double r;
         // C.M. Dec-03- Tkparams to stepper
         double tmpxyz ; double tmpp;
@@ -121,120 +133,100 @@
         // UPDATE Phase-Space
         rpVect  = stpr.getNewRp();
 	    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[] field = det.getFieldMap().getField(rpVect); // C.M.-June-03
-	   // System.out.println("BField: ("+field[0]+", "+field[1]+", "+field[2]+")");
-	    BField = field[2];
-	    xNumSteps=Math.abs(r-stpr.partR());
-	    stepConditions = steprConditions(xNumSteps,BField,0.);
-	    System.out.println("Barrel Field before 1st stepper call "+BField);
-	    System.out.println("Barrel:stepcd="+stepConditions[0]+" "+stepConditions[1]+" "+stepConditions[2]);
+        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);
-	    System.out.println("Tracker r=" +r+" zmax="+zmax);
-	    System.out.println("Barrel:out of Tracker");
+	    System.out.println("Tracker r=" +r+" zmax="+zmax+"Barrel:out of Tracker");
 	    rpVect   = stpr.getNewRp();
-	    System.out.println("Stepper pos ENTRY of:("+subdetName+" "+rpVect[0]+"; "+rpVect[1]+"; "+rpVect[2]+"), r="+stpr.partR());
-	}
-
-
+        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))
         {
-	    System.out.println(" !!!=== rmin="+rmin+" r="+r);
+	    if(debug)System.out.println(" !!!=== rmin="+rmin+" r="+r);
 	    // Then air to r=rmin
-	    double[] field = det.getFieldMap().getField(rpVect);  // C.M.-June-03
-	    BField = field[2];
-            rpVect   = stpr.getNewRp();
-	    double d_EMHD = Math.abs(r-stpr.partR());
+        rpVect   = stpr.getNewRp();
+	    double d_EMHD = Math.abs(r-stpr.partR(rpVect));
+        stpr.setDTOF(rpVect,d_EMHD);
+        double dt_EMHD=stpr.getDTOF();
 	    System.out.println(" distance between calorimeters EM-HD "+d_EMHD);
-	    stepConditions = steprConditions((10*d_EMHD),BField,0.0);
+	    stepConditions = steprConditions(d_EMHD,BField,0.,dt_EMHD);
 	    stpr.tkSteps(r,zmax,stepConditions);
 	    rpVect  = stpr.getNewRp();
-	 System.out.println("swimOnly -Stepper pos ENTRY of:("+subdetName+" "+rpVect[0]+"; "+rpVect[1]+"; "+rpVect[2]+"), r="+stpr.partR());
-
+        // if(r<(rmin-dr))return; // does not enter HCAL
         }
-
-        xNumSteps = 10.*dr;
-        stepConditions = steprConditions(xNumSteps,BField,meanDEdxPerLay(subdetName));
-        //System.out.println("Barrel:MeanDEdxPerLay="+meanDEdxPerLay(subdetName));
+        System.out.println("Stepper pos ENTRY of:("+subdetName+" "+rpVect[0]+"; "+rpVect[1]+"; "+rpVect[2]+"), r="+stpr.partR(rpVect));
+        stpr.setDTOF(rpVect,dr);
+        double dt_r=stpr.getDTOF();
+        stepConditions = steprConditions(dr,BField,meanDEdxPerLay(subdetName),dt_r);
+        System.out.println("ENTRY CALOS Barrel:MeanDEdxPerLay="+meanDEdxPerLay(subdetName)+ subdetName);
         // 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
-
-	System.out.println("subdet="+subdetName+", sensormid="+rLayer0Mid);
+	    if(debug)System.out.println("subdet="+subdetName+", sensormid="+rLayer0Mid);
         r          = rLayer0Mid;
-
         stpr.tkSteps(r, zmax,stepConditions);
         rpVect  = stpr.getNewRp();
         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
-        while ((Math.abs(rpVect[2]) < zmax )&& (nr < nLayers))
+        nLayerStepped=0;
+        while ((Math.abs(rpVect[2]) <= zmax )&& (nr < nLayers))
         {
-           Hep3Vector v = new BasicHep3Vector(rpVect[0],rpVect[1],rpVect[2]);
-           hitPos.add(v);
-//-- replace with a more general way: findCellContainingXYZ.  GL051211
-            // Add cell to list
-//  	    System.out.println("BCSF.findSegment: ("+rpVect[0]+"; "+rpVect[1]+"; "+rpVect[2]+"), rho="+stpr.partR());
-
-//          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;
-	    else {
-	      r = rmin + nLayers * dr;
-	      System.out.println("Exit of "+subdetName+", r="+r);
-	    }	 // Go on to the next layer
-	    stpr.tkSteps(r, zmax,stepConditions);
-	    rpVect = stpr.getNewRp();
-	    nr++;
+          Hep3Vector v = new BasicHep3Vector(rpVect[0],rpVect[1],rpVect[2]);
+          hitPos.add(v);
+	      if(stpr.getStopTkELow()) break;
+
+            if(stpr.getCurlBack())
+            {
+               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);
+	     }	 // Go on to the next layer
+	       stpr.tkSteps(r, zmax,stepConditions);
+	       rpVect = stpr.getNewRp();
+           double dThk=(nr!=(nLayers-1))?dr:(dr+dr-(rLayer0Mid-rmin));
+           stepConditions = steprConditions(dThk,BField,meanDEdxPerLay(subdetName),dt_r);
+	      if(!stpr.getCurlBack())nr++;
+	      nLayerStepped++;
         }
         // Save number of layers track passed through
         numLayersHit = nr;
-
-	System.out.println("Stepper pos EXIT of:("+subdetName+" "+rpVect[0]+"; "+rpVect[1]+"; "+rpVect[2]+"), r="+stpr.partR());
+	    System.out.println("Stepper pos EXIT of:("+subdetName+" "+rpVect[0]+"; "+rpVect[1]+"; "+rpVect[2]+"), r="+stpr.partR(rpVect));
         rpVect= stpr.getNewRp();
-        if((nr==nLayers)|| (rpVect[2]>=zmax))
-        {
-           Hep3Vector v = new BasicHep3Vector(rpVect[0],rpVect[1],rpVect[2]);
-           hitPos.add(v);
+        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();
+	double rr=stpr.partR(rpVect);
        // Now match the cells on this list to calorimeter hits
-// 	System.out.println("Names: subdetName=<"+subdetName+">"
-// 			   +", EcalSubdetName="+ecalSubdetName
-// 			   +", HcalSubdetName="+hcalSubdetName);
-/*
         if(subdetName.equals(hcalSubdetName))  //C.M.-27Jan03
         {
-            //		HistogramFolder.setDefaultFolder("/HDCal");
+
 //  	    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");
             matchHitsFast(segm, dataMgr.getCollHitMap(ecalHitmapName) );
-            //		HistogramFolder.setDefaultFolder("..");		// C.M.-27Jan03- Folder
         }
- */
+
 
     }
 
@@ -330,10 +322,10 @@
         return(hitPos.size());
     }
     //----------------------------------------------------------C.M. Step Conditions
-    public double[] steprConditions(double theXNumSteps,double theField,double theMeanDEdx)
+    public double[] steprConditions(double dthick,double theField,double theMeanDEdx,double DTOF0)
     {
         return(new double[]
-        {theXNumSteps, theField,theMeanDEdx});
+        {dthick, theField,theMeanDEdx,DTOF0});
     }
     //--------------------------------------------C.M.- Get DE/dx per Calorimeter Layer
     protected double meanDEdxPerLay(String name)
@@ -352,7 +344,7 @@
             double e1      = tthk * (dedx.getDeDx(mat)/10);  // energy loss this material
 //            System.out.println("mat="+mat+", tth="+tthk+", e1="+e1);
 	    //System.out.println("matName="+mat+", thickness="+tthk+", dEdx="+dedx.getDeDx(mat));
-            matterDEdx    += e1;                       // sum energy loss per material
+              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);
@@ -462,7 +454,7 @@
     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;
@@ -480,7 +472,7 @@
     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[3];
+    protected double [] stepConditions = new double[4];
     protected Map<String, Double> materials;
     private int phiNNCut;
     private int thetaNNCut;
CVSspam 0.2.8