Print

Print


Commit in lcsim/src/org/lcsim/recon/vertexing/pixsim on MAIN
FastAnalogElectronics.java+15-41.1 -> 1.2
PixilatedSensor.java+23-131.5 -> 1.6
PixilatedSensorManager.java+233-761.8 -> 1.9
SiSingleColElossTab.java+101.1 -> 1.2
TrackSegmentSimulation.java+21.2 -> 1.3
+283-93
5 modified files
Removed runtime exception for "hit belongs to unknown sensor" and added option for provided fixed resolution for hit covariance matrix instead of trying to calculate it from some obscure parameters of the cluster

lcsim/src/org/lcsim/recon/vertexing/pixsim
FastAnalogElectronics.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- FastAnalogElectronics.java	10 Feb 2011 22:29:51 -0000	1.1
+++ FastAnalogElectronics.java	8 Mar 2011 19:16:01 -0000	1.2
@@ -101,6 +101,7 @@
       dtf = dt;
       first = false;
       if(dt < 0.1e-10) System.out.println("Time bin in charge train is too small! :"+dt);
+//      System.out.println("Time bin is: "+dtf+" clock period is "+clock_period);
      }
      if(Math.abs(1. - dtf/dt) > 1.e-6)
      {
@@ -210,8 +211,11 @@
       }
      } 
      boolean fired = false;
-     int act_thr = (int) (pixel_threshold * adc_scale + noise_level * rnd.nextGaussian());
+     double nshft = noise_level * rnd.nextGaussian(); 
+     int act_thr = (int) (pixel_threshold * adc_scale + nshft);
      int asig = 0;
+     double sig = 0.;
+     double tsig = 0.;
      int[] chacc = ari.getCharge();
      for(int j=0; j<chacc.length; j++)
      {
@@ -233,10 +237,12 @@
        }
       }
       asig+=chacc[j];
+      sig = (double) asig; 
       if(!fired && (asig >= act_thr))
       {
        fired=true;
-       tf = strtri + j*dtf+dtf*((double)(act_thr-asig+chacc[j])/(double)chacc[j]);
+       tsig=sig-nshft;
+       tf = strtri + j*dtf+dtf*(((double)act_thr-sig+(double)chacc[j])/(double)chacc[j]);
        if(buf<n_buffers)
        {
         int tstm = (int) Math.floor(tf/clock_period);
@@ -247,8 +253,13 @@
        }  
       }
      } // end for(int j=0; j<chacc.length; j++)
-     double sig = (double) asig + noise_level * rnd.nextGaussian(); 
-     if(buf > 0) aadc[buf-1] = (int) (Math.floor(sig/adc_scale));
+     if(buf > 0)
+     {
+      sig-=nshft; 
+      if(sig < 0.) sig=0.; 
+      aadc[buf-1] = (int) (Math.floor(sig/adc_scale));
+      if(aadc[buf-1] > adc_saturation) aadc[buf-1]=adc_saturation;
+     } 
     } // for(int i=0; i<narsts; i++)
     }
     for(int i=0; i<buf; i++)

lcsim/src/org/lcsim/recon/vertexing/pixsim
PixilatedSensor.java 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- PixilatedSensor.java	10 Feb 2011 22:30:32 -0000	1.5
+++ PixilatedSensor.java	8 Mar 2011 19:16:01 -0000	1.6
@@ -22,7 +22,10 @@
   boolean debug = false;
   public boolean ddebug = false;
   int clust_thresh = 8;
-  int t_window = 1; 
+  int t_window = 1;
+  private boolean use_fixed_resol = false;
+  private double res_pfrx = 0.3;
+  private double res_pfry = 0.3;   
   static PixSimConstants cons = PixSimConstants.instance();
   static final double oneovsqrt12 = 0.2886751;
   public static final double bunch_period = cons.BunchInterval;
@@ -155,6 +158,10 @@
   {
    covm.calibrate(this,stat,fname);
   }
+  
+  public void useFixedResolution(boolean yes) { use_fixed_resol=yes; }
+
+  public void setFixedResolution(double rfrx, double rfry) { res_pfrx= rfrx; res_pfry=rfry; }
 
   private void setBoundaries()
   {
@@ -664,19 +671,22 @@
     pos[0]=glpos.x();
     pos[1]=glpos.y();
     pos[2]=glpos.z(); 
-    double[] er = covm.calculateErrors(pcl,this);
-    double xx = 0.;
-    double yy = 0.;
-    if(row_orient == RowOrientation.ALONGX)
-    {
-     xx=er[0]*(pszx*pszx);
-     yy=er[1]*(pszy*pszy);
-    }
-    if(row_orient == RowOrientation.ALONGY)
+    double xx = res_pfrx * pszx * res_pfrx * pszx;
+    double yy = res_pfry * pszy * res_pfry * pszy;
+    if(!use_fixed_resol)
     {
-     yy=er[0]*(pszy*pszy);
-     xx=er[1]*(pszx*pszx);
-    }
+     double[] er = covm.calculateErrors(pcl,this);
+     if(row_orient == RowOrientation.ALONGX)
+     {
+      xx=er[0]*(pszx*pszx);
+      yy=er[1]*(pszy*pszy);
+     }
+     if(row_orient == RowOrientation.ALONGY)
+     {
+      yy=er[0]*(pszy*pszy);
+      xx=er[1]*(pszx*pszx);
+     }
+    } 
     SymmetricMatrix cm = new SymmetricMatrix(3);
     cm.setElement(0,0,xx);
     cm.setElement(1,1,yy);

lcsim/src/org/lcsim/recon/vertexing/pixsim
PixilatedSensorManager.java 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- PixilatedSensorManager.java	4 Mar 2011 02:30:10 -0000	1.8
+++ PixilatedSensorManager.java	8 Mar 2011 19:16:01 -0000	1.9
@@ -11,6 +11,7 @@
 import hep.physics.vec.VecOp;
 import hep.physics.vec.BasicHep3Vector;
 import org.lcsim.detector.solids.*;
+import java.io.*;
 import java.text.*;
 import java.util.*;
 import java.lang.RuntimeException;
@@ -22,11 +23,12 @@
  * for each event (only sensors which have hits in them are created)
  *
  * @author Nick Sinev
- * @version $Id: PixilatedSensorManager.java,v 1.8 2011/03/04 02:30:10 sinev Exp $
+ * @version $Id: PixilatedSensorManager.java,v 1.9 2011/03/08 19:16:01 sinev Exp $
  */
 
 public class PixilatedSensorManager extends Driver
 {
+ private static int dbg_lvl = 0;
  private static boolean doHist = true;
  boolean cal_res_bar = false;
  boolean cal_res_ec = false;
@@ -34,7 +36,14 @@
  boolean read_rest_ec=true;
  boolean incl_el_noise = false;
  boolean ready = false;
- boolean digital = false;  
+ boolean digital = false;
+ boolean fixed_res_barr = false;
+ boolean fixed_res_ec = false;
+ double fr_resx_barr = 0.3;
+ double fr_resy_barr = 0.3;
+ double fr_resx_ec = 0.3;
+ double fr_resy_ec = 0.3;  
+ private static String logfile_nam = null;
  static PixSimConstants cons = PixSimConstants.instance();
  static final int MAXHTSPEV = 100000;
  static IlcOption ilcopt = IlcOption.NOMINAL;
@@ -46,6 +55,8 @@
  private static double thr_to_noise_ratio = 5.;
  private static double adc_scale_bar = 25.;
  private static double adc_scale_ec = 25.;
+ private static int adc_satur_bar = 255;
+ private static int adc_satur_ec = 255;
  private static double pixdx=0.02;
  private static double pixdy=0.02;
  private static double pixdz=0.02;
@@ -203,30 +214,30 @@
  };
 
  private static String[] opt_rtab_name_ec_pl=
- {"CCD_20x20x20_B5_res_ec.dat",
-  "Chronopix_20x20x20_hr_B5_res_ec.dat",
-  "CPCCD_20x20x20_B5_res_ec.dat",
-  "Chronopix_20x20x16_hr_B5_res_ec.dat",
-  "ShortColCCD_20x20x20_B5_res_ec.dat",
-  "Chronopix_12x12x20hr_B5_res_ec.dat",
-  "Chronopix_16x16x20hr_B5_res_ec.dat",
-  "Chronopix_8x8x12hr_B5_res_ec.dat",
-  "Chronopix_12x12x12hr_B5_res_ec.dat",
-  "chronopix_16x16x12hr_B5_res_ec.dat"
+ {"CCD_20x20x20_B5_res_EC.dat",
+  "Chronopix_20x20x20_hr_B5_res_EC.dat",
+  "CPCCD_20x20x20_B5_res_EC.dat",
+  "Chronopix_20x20x16_hr_B5_res_EC.dat",
+  "ShortColCCD_20x20x20_B5_res_EC.dat",
+  "Chronopix_12x12x20hr_B5_res_EC.dat",
+  "Chronopix_16x16x20hr_B5_res_EC.dat",
+  "Chronopix_8x8x12hr_B5_res_EC.dat",
+  "Chronopix_12x12x12hr_B5_res_EC.dat",
+  "chronopix_16x16x12hr_B5_res_EC.dat"
  };
 
  private static String[] opt_rtab_name_ec_mi = 
- {"CCD_20x20x20_B5_res_ec.dat",
-  "Chronopix_20x20x20_B5_res_ec.dat",
-  "CPCCD_20x20x20_B5_res_ec.dat",
-  "Chronopix_20x20x16_hr_B5_res_ec.dat",
-  "ShortColCCD_20x20x20_B5_res_ec.dat",
-  "Chronopix_12x12x20hr_B5_res_ec.dat",
-  "Chronopix_16x16x20hr_B5_res_ec.dat",
-  "Chronopix_8x8x12hr_B5_res_ec.dat",
-  "Chronopix_12x12x12hr_B5_res_ec.dat",
-  "chronopix_16x16x12hr_B5_res_ec.dat",
-  "mimosa18_B5_res_ec.dat"
+ {"CCD_20x20x20_B5_res_EC.dat",
+  "Chronopix_20x20x20_B5_res_EC.dat",
+  "CPCCD_20x20x20_B5_res_EC.dat",
+  "Chronopix_20x20x16_hr_B5_res_EC.dat",
+  "ShortColCCD_20x20x20_B5_res_EC.dat",
+  "Chronopix_12x12x20hr_B5_res_EC.dat",
+  "Chronopix_16x16x20hr_B5_res_EC.dat",
+  "Chronopix_8x8x12hr_B5_res_EC.dat",
+  "Chronopix_12x12x12hr_B5_res_EC.dat",
+  "chronopix_16x16x12hr_B5_res_EC.dat",
+  "mimosa18_B5_res_EC.dat"
  };
  
 
@@ -316,7 +327,36 @@
   colledx=cedx;
   colledy=cedy;
   chdep=chd;
- } 
+ }
+ 
+ public void setDebugLevel(int level) { dbg_lvl=level; }
+
+ public void useFixedResolution(boolean yes) { fixed_res_barr = yes; fixed_res_ec = yes; }
+
+ public void useFixedResolutionBarrel(boolean yes) { fixed_res_barr = yes; }
+
+ public void useFixedResolutionEndcap(boolean yes) { fixed_res_ec = yes; }
+
+ public void setFixedResolution(double resx, double resy) 
+ {
+  fr_resx_barr = resx;
+  fr_resx_ec = resx;
+  fr_resy_barr = resy;
+  fr_resy_ec = resy;
+ }
+
+ public void setFixedResolutionBarrel(double resx, double resy) 
+ {
+  fr_resx_barr = resx;
+  fr_resy_barr = resy;
+ }
+
+ public void setFixedResolutionEndcap(double resx, double resy) 
+ {
+  fr_resx_ec = resx;
+  fr_resy_ec = resy;
+ }
+
 
  public void includeElectronicsNoiseHits(boolean yes) { incl_el_noise=yes; }
 
@@ -338,6 +378,10 @@
 
  public void setADCscale(double scale) { adc_scale_bar = scale; adc_scale_ec=scale;}
 
+ public void setADCsaturation(int val) { adc_satur_bar = val; adc_satur_ec=val;}
+
+ public void setADCsaturation(int valb, int vale) { adc_satur_bar = valb; adc_satur_ec=vale;}
+
  public void setADCscaleEndcap(double scale) { adc_scale_ec=scale;}
 
  public void setADCscaleBarrel(double scale) { adc_scale_bar = scale; }
@@ -358,6 +402,8 @@
 
  public void setMinDeltaEEnergy(double e) { TrackSegmentSimulation.MINDELTAE=e; }
 
+ public void setLogfile(String name) { logfile_nam=name; }
+
  public void setLorentzCorrection(Hep3Vector cvb, Hep3Vector cvep, Hep3Vector cvem)
  {
   if(cvb != null ) Lor_corr_b.setV(cvb.x(),cvb.y(),cvb.z());
@@ -473,6 +519,73 @@
    return psecml;
  }
 
+ public void recordSet(String ofnam)
+ {
+  File cache = new File(ofnam);
+  try
+  { 
+   cache.createNewFile();
+   FileWriter ofw = new FileWriter(cache);
+   Date date = new Date();
+   DateFormat daf = new SimpleDateFormat();
+   ofw.write("// File was written on : "+daf.format(date)+"\r\n");
+   ofw.write("Pixel dimensions: "+pixdx+" "+pixdy+" "+pixdz+"\r\n"); 
+   ofw.write("Collection well dimensions: "+colledx+" "+colledy+" "+chdep+"\r\n"); 
+  ofw.write("Ilc option: "+ilcopt);
+  if(option != -1) ofw.write(" sensor option: "+sensopt+"\r\n");
+  else ofw.write("sensor option: undefined"+"\r\n");
+  if(digital) ofw.write("Electronics has digital readout \r\n");
+  if(incl_el_noise) ofw.write("Fake hits created by electronics noise are processed \r\n");
+  if(!incl_el_noise) ofw.write("Fake hits created by electronics noise are discarded \r\n");
+  ofw.write("Barrel electronics is: "+bar_el.getName()+"\r\n");
+  ofw.write("ADC scale for it is: "+bar_el.getADCScale()+"\r\n");
+  ofw.write("ADC saturation for barrel is: "+adc_satur_bar+"\r\n");
+  ofw.write("Noise level is: "+bar_el.getNoiseLevel()+"\r\n");
+  ofw.write("Lorentz corr. barrel x: "+Lor_corr_b.x()+" y: "+Lor_corr_b.y()+" z: "+Lor_corr_b.z()+"\r\n");
+  ofw.write("Endcap+ electronics is: "+ecp_el.getName()+"\r\n");
+  ofw.write("ADC scale for it is: "+ecp_el.getADCScale()+"\r\n");
+  ofw.write("ADC saturation is: "+adc_satur_ec+"\r\n");
+  ofw.write("Noise level is: "+ecp_el.getNoiseLevel()+"\r\n");
+  ofw.write("Lorentz corr. endcap+ x: "+Lor_corr_ep.x()+" y: "+Lor_corr_ep.y()+" z: "+Lor_corr_ep.z()+"\r\n");
+  ofw.write("Endcap- electronics is: "+ecm_el.getName()+"\r\n");
+  ofw.write("ADC scale for it is: "+ecm_el.getADCScale()+"\r\n");
+  ofw.write("ADC saturation is: "+adc_satur_ec+"\r\n");
+  ofw.write("Noise level is: "+ecm_el.getNoiseLevel()+"\r\n");
+  ofw.write("Lorentz corr. endcap- x: "+Lor_corr_em.x()+" y: "+Lor_corr_ep.y()+" z: "+Lor_corr_ep.z()+"\r\n");
+  ofw.write("pixel threshold for barrel: "+pixel_thr_barr+"\r\n");
+  ofw.write("pixel threshold for ec: "+pixel_thr_ec+"\r\n");
+  ofw.write("cluster threshold for barrel: "+cluster_thr_barr+"\r\n");
+  ofw.write("cluster threshold for ec: "+cluster_thr_ec+"\r\n");
+  if(use_prop_tab_barrel)
+  {
+   if(prop_tab_barrel_local)
+   {
+    ofw.write("Barrel propagator uses table read from file "+bar_prop_tname+" in your local directory"+"\r\n");
+   }
+   else
+   {
+    if(det != null)
+    ofw.write("Barrel propagator uses table read from file "+bar_prop_tname+" read from "
+     +det.getName()+" detector data base"+"\r\n");
+    else
+    ofw.write("Barrel propagator uses table read from file "+bar_prop_tname+
+     " read from not yet known data base"+"\r\n");
+   }
+  } 
+
+   ofw.flush();
+   ofw.close();
+  }
+  catch(IOException e)
+  {
+   System.out.println("IOException caught: "+e.getMessage());
+  }
+  finally
+  {
+  }
+ }
+
+
  public void printSettings()
  {
   System.out.print("Ilc option: "+ilcopt);
@@ -521,7 +634,7 @@
    {
     IPixelSensorElectronics el = new CCDElectronics();
     el.includeElectronicNoiseHits(incl_el_noise);
-    el.setADCScale(25.);
+    el.setADCScale(adc_scale_bar);
     el.setNoiseLevel(enoise);
     el.setADCSaturation(255);
     el.setBunchesPerClock(bc_per_cl); // 30  is about maximum clock image speed (100 KHz) for classic CCD - asuming 50MHz speed in R register
@@ -544,7 +657,7 @@
      bar_el = new CCDElectronics();
      bar_el.setADCScale(adc_scale_bar);
      bar_el.setNoiseLevel(enoise);
-     bar_el.setADCSaturation(255);
+     bar_el.setADCSaturation(adc_satur_bar);
      bar_el.setPixelThreshold(pixel_thr_barr);
      bar_el.includeElectronicNoiseHits(incl_el_noise);
      if(bc_per_cl != 0) bar_el.setBunchesPerClock(bc_per_cl);
@@ -588,9 +701,9 @@
    {
     IPixelSensorElectronics el = new CCDElectronics();
     el.includeElectronicNoiseHits(incl_el_noise);
-    el.setADCScale(25.);
+    el.setADCScale(adc_scale_bar);
     el.setNoiseLevel(enoise);
-    el.setADCSaturation(255);
+    el.setADCSaturation(adc_satur_bar);
     el.useCorrelatedDoubleSampling(true);
     el.setPixelThreshold(4);
     if(cl_per_bc != 0) el.setClocksPerBunch(cl_per_bc); // 50 MHz image clock speed in column parallel CCD 
@@ -607,7 +720,7 @@
      bar_el = new FastAnalogElectronics(ilcopt);
      bar_el.setADCScale(adc_scale_bar);
      bar_el.setNoiseLevel(enoise);
-     bar_el.setADCSaturation(255);
+     bar_el.setADCSaturation(adc_satur_bar);
      bar_el.setPixelThreshold(pixel_thr_barr);
      bar_el.includeElectronicNoiseHits(incl_el_noise);
      if(bc_per_cl != 0) bar_el.setBunchesPerClock(bc_per_cl);
@@ -733,7 +846,6 @@
   {
    firstcall=false;
    setup();
-
    vxbrels.clear();
    vxecpels.clear();
    vxecmels.clear();
@@ -741,11 +853,13 @@
    {
     if(prop_tab_barrel_local) 
     {
-     if(bcpr.useTable(bar_prop_tname)) System.out.println("Using table for barrel sensor carrier propagator");
+     if(bcpr.useTable(bar_prop_tname)) 
+      if(dbg_lvl > 0) System.out.println("Using table for barrel sensor carrier propagator");
     }
     else
     {
-     if(bcpr.useTable(bar_prop_tname,det)) System.out.println("Using table for barrel sensor carrier propagator");
+     if(bcpr.useTable(bar_prop_tname,det))
+     if(dbg_lvl > 0) System.out.println("Using table for barrel sensor carrier propagator");
     }
     tabfld = extractFieldFromName(bar_prop_tname);
     double[] pos = {0,0,0};
@@ -756,20 +870,22 @@
       ("Detector field "+field[2]+" does not correspond to propagators field: "+tabfld+" Tesla\n"); 
      throw new RuntimeException("Detector and table fields mismatch");
     }
-
    }    
    if(use_prop_tab_ec_pl)
    {
-    if(ec_bar_same_prop) System.out.println("Carrier propagator for barrel and ec sensors is the same");
+    if(ec_bar_same_prop)
+     if(dbg_lvl > 0) System.out.println("Carrier propagator for barrel and ec sensors is the same");
     if(!ec_bar_same_prop)
     {
      if(prop_tab_ec_pl_local)
      {
-      if(ecppr.useTable(ec_pl_prop_tname)) System.out.println("Using table for ec pl sensor carrier propagator");
+      if(ecppr.useTable(ec_pl_prop_tname)) 
+       if(dbg_lvl > 0) System.out.println("Using table for ec pl sensor carrier propagator");
      }
      else
      {
-      if(ecppr.useTable(ec_pl_prop_tname,det)) System.out.println("Using table for ec pl sensor carrier propagator");
+      if(ecppr.useTable(ec_pl_prop_tname,det)) 
+       if(dbg_lvl > 0) System.out.println("Using table for ec pl sensor carrier propagator");
      }
     } 
    }
@@ -780,11 +896,13 @@
     {  
      if(prop_tab_ec_mi_local)
      {
-      if(ecmpr.useTable(ec_mi_prop_tname)) System.out.println("Using table for ec mi sensor carrier propagator");
+      if(ecmpr.useTable(ec_mi_prop_tname)) 
+       if(dbg_lvl > 0) System.out.println("Using table for ec mi sensor carrier propagator");
      }
      else
      {
-      if(ecmpr.useTable(ec_mi_prop_tname,det)) System.out.println("Using table for ec mi sensor carrier propagator");
+      if(ecmpr.useTable(ec_mi_prop_tname,det)) 
+       if(dbg_lvl > 0) System.out.println("Using table for ec mi sensor carrier propagator");
      }
     }
    }
@@ -810,7 +928,7 @@
        children= parent[0].getChildren();
        nchldrn[0] = children.size();
 
-      if(name.indexOf("Barrel") !=-1)
+      if(name.indexOf("Bar") !=-1)
       {
        while((lvl > -1) && (tot<2000) && (ind[lvl] <= nchldrn[lvl]))
        {
@@ -862,11 +980,11 @@
         {
          lvl--;
          name = child.getName();
-//         System.out.println("found encap element with name: "+name);
-         if(((name.indexOf("reflected") == -1) || (name.indexOf("positive") != -1)) 
+         if(dbg_lvl > 1) System.out.println("found encap element with name: "+name);
+         if(((name.indexOf("reflected") == -1) || (name.indexOf("pos") != -1)) 
            && (name.indexOf("negative") == -1))
            vxecpels.add(child);
-         if((name.indexOf("reflected") != -1) || (name.indexOf("negative") != -1))
+         if((name.indexOf("reflected") != -1) || (name.indexOf("neg") != -1))
           vxecmels.add(child);
          ind[lvl]++;
         }
@@ -875,9 +993,10 @@
      } // end of if((name.indexOf("Vtx")!=-1) || (name.indexOf("Vertex") != -1))
     } // end of for(IDetectorElement chld:chlds)
    } // end of if(tde != null)
+   if(dbg_lvl > 0) 
    System.out.println("Detector contains "+vxbrels.size()+" barrel vertex and "+vxecpels.size()+" endcap detector elements");
    int nbe = 0;
-   if(read_rest_bar)
+   if(read_rest_bar && !fixed_res_barr)
    { 
     if(res_tab_barrel_local) eeb.readTable(rtab_name_bar);
     else eeb.readTable(rtab_name_bar,det);
@@ -886,11 +1005,13 @@
    {
     PixilatedSensor pse = new PixilatedSensor(de,bcpr,false);
     pse.setElectronics(bar_el);
+    pse.useFixedResolution(fixed_res_barr);
+    if(fixed_res_barr) pse.setFixedResolution(fr_resx_barr,fr_resy_barr);
     pse.setErrorEstimate(eeb);
     pse.setClusterThreshold(cluster_thr_barr);
     pse.setTimeWindow(time_window);  
     pse.setLorentzCorrection(Lor_corr_b);  
-    if(nbe==0 && cal_res_bar)
+    if(nbe==0 && cal_res_bar && !fixed_res_barr)
     { 
      eeb.setTableParameters(11,11,11,0.,1.5,0.,1.5,1.5,6.5);
      pse.calibrateErrorEstimate(calibr_stat_b,rtab_name_bar);
@@ -899,7 +1020,7 @@
     psbrl.add(pse);
    }
    int nbc = 0;     
-   if(read_rest_ec)
+   if(read_rest_ec && !fixed_res_ec)
    {
     if(res_tab_ec_pl_local) eeep.readTable(rtab_name_ec_pl);
     else eeep.readTable(rtab_name_ec_pl,det);
@@ -908,11 +1029,13 @@
    {
     PixilatedSensor pse = new PixilatedSensor(de,ecppr,true); 
     pse.setElectronics(ecp_el);
+    pse.useFixedResolution(fixed_res_ec);
+    if(fixed_res_ec) pse.setFixedResolution(fr_resx_ec,fr_resy_ec);
     pse.setErrorEstimate(eeep);
     pse.setClusterThreshold(cluster_thr_ec);
     pse.setTimeWindow(time_window);  
     pse.setLorentzCorrection(Lor_corr_ep);  
-    if(nbc==0 && cal_res_ec)
+    if(nbc==0 && cal_res_ec && !fixed_res_ec)
     {
      eeep.setTableParameters(11,11,11,0.,1.5,0.,1.5,1.5,6.5);
      pse.calibrateErrorEstimate(calibr_stat_ep,rtab_name_ec_pl);
@@ -932,6 +1055,8 @@
     PixilatedSensor pse = new PixilatedSensor(de,ecmpr,true); 
     pse.setElectronics(ecm_el);
     pse.setErrorEstimate(eeem);
+    pse.useFixedResolution(fixed_res_ec);
+    if(fixed_res_ec) pse.setFixedResolution(fr_resx_ec,fr_resy_ec);
     pse.setClusterThreshold(cluster_thr_ec);  
     pse.setTimeWindow(time_window);  
     pse.setLorentzCorrection(Lor_corr_em);
@@ -949,7 +1074,7 @@
     nbcm++; 
     psecml.add(pse);
    }
-   System.out.println("Created: "+nbe+" barrel pixilated sensors and "+nbc+" EC positive and "+nbcm+" EC negative pixilated sensors");     
+   if(dbg_lvl > 0) System.out.println("Created: "+nbe+" barrel pixilated sensors and "+nbc+" EC positive and "+nbcm+" EC negative pixilated sensors");     
   } // end of if(firstcall)
   if(!ready) return;
   if(doHist) startime =  System.currentTimeMillis();
@@ -974,19 +1099,20 @@
   String ehcname=null;
   if(evhits != null)
   {
-//   System.out.println("Event has  "+evhits.size()+" SimTrackerHit collections: ");
+   if(dbg_lvl > 1) System.out.println("Event has  "+evhits.size()+" SimTrackerHit collections: ");
    for(List<SimTrackerHit> sdhits:evhits)
    {
     EventHeader.LCMetaData md = event.getMetaData(sdhits);
     String cname = md.getName();
-//    System.out.println("Collection name: "+cname);
+    if(dbg_lvl > 1) System.out.println("Collection name: "+cname);
     if((cname.indexOf("Vtx")!=-1)||(cname.indexOf("Vertex") != -1))
     {
-     if(cname.indexOf("Barrel")!=-1) bhcname=cname;
+     if(cname.indexOf("Barr")!=-1) bhcname=cname;
      if(cname.indexOf("Endcap")!=-1) ehcname=cname;
     }
    }
-//  System.out.println("Vertex barrel sim hit collection name is: "+bhcname+" and for encap it is: "+ehcname);
+  if(dbg_lvl > 1) 
+   System.out.println("Vertex barrel sim hit collection name is: "+bhcname+" and for encap it is: "+ehcname);
   }
   int asshts = 0;
   int nprints = 0; 
@@ -995,7 +1121,7 @@
    if(bhcname != null)
    {
     List<SimTrackerHit> vxbhts = event.get(SimTrackerHit.class,bhcname);
-//    System.out.println("SimTrackerHit collection size for barrel: "+vxbhts.size());
+    if(dbg_lvl > 1) System.out.println("SimTrackerHit collection size for barrel: "+vxbhts.size());
     for(SimTrackerHit hit:vxbhts)
     {
      double[] hpnt = hit.getPoint();    
@@ -1004,9 +1130,14 @@
      for(IDetectorElement vtxp:vxbrels)
      {
       IDetectorElement de = vtxp.findDetectorElement(vhitp);
-      if(de !=null) hitde=de;
+      if(de != null) hitde=de;
      }
-     if(hitde == null) System.out.println("Could not find sensor for hit: "+vhitp.x()+" "+vhitp.y()+" "+vhitp.z());
+     if(hitde == null)
+     { 
+      System.out.println("Could not find sensor for hit: "+vhitp.x()+" "+vhitp.y()+" "+vhitp.z());
+//      throw new RuntimeException("Hit belongs to unknown sensor!");
+     } 
+     boolean foundmatch = false;
      if((hitde != null) && (asshts<MAXHTSPEV))
      {
       asshts++;  
@@ -1015,17 +1146,25 @@
       if(assign_bc) t+=phys_time;
       SimPixelHit spht= new SimPixelHit(hit,t);
       hts.addHit(hit);
+      
       for(PixilatedSensor psen:psbrl)
       {
-       if((psen.getParent() !=null) && (psen.getParent() == hitde)) psen.addSimPixelHit(spht);
+       if((psen.getParent() !=null) && (psen.getParent() == hitde))
+       { 
+        psen.addSimPixelHit(spht);
+        if(dbg_lvl > 1) System.out.println("Added SimPixelHit to "+hitde.getName());
+        foundmatch = true;
+       }
       }
+      if(!foundmatch)
+       System.out.println("Could not find sensor for detector element "+hitde.getName());
      }
     }
    }
    if(ehcname != null)
    {
     List<SimTrackerHit> vxehts = event.get(SimTrackerHit.class,ehcname);
-//    System.out.println("SimTrackerHit collection size for endcap: "+vxehts.size());
+    if(dbg_lvl > 1) System.out.println("SimTrackerHit collection size for endcap: "+vxehts.size());
     for(SimTrackerHit hit:vxehts)
     {
      double[] hpnt = hit.getPoint();    
@@ -1038,7 +1177,11 @@
        IDetectorElement de = vtxp.findDetectorElement(vhitp);
        if(de !=null) hitde=de;
       }
-      if(hitde == null) System.out.println("Could not find sensor for hit: "+vhitp.x()+" "+vhitp.y()+" "+vhitp.z());
+      if(hitde == null)
+      { 
+       System.out.println("Could not find sensor for hit: "+vhitp.x()+" "+vhitp.y()+" "+vhitp.z());
+//       throw new RuntimeException("Hit belongs to unknown sensor!");
+      }
       if((hitde != null) && (asshts < MAXHTSPEV))
       {
        boolean isbox = false;
@@ -1082,7 +1225,11 @@
        IDetectorElement de = vtxp.findDetectorElement(vhitp);
        if(de !=null) hitde=de;
       }
-      if(hitde == null) System.out.println("Could not find sensor for hit: "+vhitp.x()+" "+vhitp.y()+" "+vhitp.z());
+      if(hitde == null)
+      { 
+       System.out.println("Could not find sensor for hit: "+vhitp.x()+" "+vhitp.y()+" "+vhitp.z());
+//       throw new RuntimeException("Hit belongs to unknown sensor!");
+      }
       if((hitde != null) && (asshts < MAXHTSPEV))
       {
        asshts++;  
@@ -1099,32 +1246,39 @@
      }
     }
    } 
-//   System.out.println("Total number of assigned vertex hits: "+asshts);
+   if(dbg_lvl > 1) System.out.println("Total number of assigned vertex hits: "+asshts);
   } // end if(evhits != null)
   List<TrackerHit> ebhits = new ArrayList<TrackerHit>();
   List<TrackerHit> eehits = new ArrayList<TrackerHit>();
   List<RawTrackerHit> rawhits = new ArrayList<RawTrackerHit>();
   int tnrawhpe = 0;  // total number of raw hits, including noise hits
-  int nmprbs=0; 
+  int nmprbs=0;
+  int nabthts=0; 
   for(PixilatedSensor psn:psbrl)
   {
    if((psn.getHits().size() > 0) || incl_el_noise)
    {
-//   System.out.println("Processing barrel sensor "+nmprbs+" total number of raw hits so far "+tnrawhpe);  
-   psn.processEvent(phys_bc);
-   IDetectorElement de = psn.getParent();
-   IReadout ro = de.getReadout();
-   if(doHist) tnrawhpe+=(psn.getRawHits()).size();
-   List<TrackerHit> sthts = ro.getHits(TrackerHit.class);
-   for(TrackerHit ht:sthts)
-   {
-    ebhits.add(ht);
-    rawhits.addAll(ht.getRawHits()); 
-   }
+    if(dbg_lvl > 1)
+    {
+     System.out.println("Processing barrel sensor "+nmprbs+" total number of raw hits so far "+tnrawhpe);
+     System.out.println("Sensor name is: "+psn.getParent().getName()+" and it has "+
+     psn.getHits().size()+" hits");
+    }  
+    psn.processEvent(phys_bc);
+    IDetectorElement de = psn.getParent();
+    IReadout ro = de.getReadout();
+    tnrawhpe+=(psn.getRawHits()).size();
+    List<TrackerHit> sthts = ro.getHits(TrackerHit.class);
+    nabthts+=sthts.size();
+    for(TrackerHit ht:sthts)
+    {
+     ebhits.add(ht);
+     rawhits.addAll(ht.getRawHits()); 
+    }
    }
    nmprbs++;
   }
-//  System.out.println("Barrel hits processed!");
+  if(dbg_lvl > 1) System.out.println("Barrel hits processed! Added "+nabthts+" TrackerHits");
   for(PixilatedSensor psn:psecpl)
   {
    if((psn.getHits().size() > 0) || incl_el_noise)
@@ -1141,7 +1295,7 @@
    }
    }
   } 
-//  System.out.println("Endcap plus hits processed!");
+  if(dbg_lvl > 1) System.out.println("Endcap plus hits processed!");
   for(PixilatedSensor psn:psecml)
   {
    if((psn.getHits().size() > 0) || incl_el_noise)
@@ -1158,10 +1312,13 @@
    }
    }
   } 
-//  System.out.println("Endcap minus hits processed!");
-//  System.out.println("Adding "+ebhits.size()+" hits to RecVtxBarrHits collection");
+  if(dbg_lvl > 1)
+  { 
+    System.out.println("Endcap minus hits processed!");
+    System.out.println("Adding "+ebhits.size()+" hits to RecVtxBarrHits collection");
+  }
   event.put("RecVtxBarrHits",ebhits,TrackerHit.class,0);  
-//  System.out.println("Adding "+eehits.size()+" hits to RecVtxEndcapHits collection");
+  if(dbg_lvl > 1)  System.out.println("Adding "+eehits.size()+" hits to RecVtxEndcapHits collection");
   event.put("RecVtxEndcapHits",eehits,TrackerHit.class,0);
 //  event.put("RecVtxRawHits",rawhits,RawTrackerHit.class,(1 << LCIOConstants.RTHBIT_HITS));
   event.put("RecVtxRawHits",rawhits,RawTrackerHit.class,0);

lcsim/src/org/lcsim/recon/vertexing/pixsim
SiSingleColElossTab.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- SiSingleColElossTab.java	9 Dec 2008 23:36:34 -0000	1.1
+++ SiSingleColElossTab.java	8 Mar 2011 19:16:01 -0000	1.2
@@ -1,5 +1,15 @@
 package org.lcsim.recon.vertexing.pixsim;
 
+/*---------------------------------------------
+! This table was obtained using code written by
+! H.Bichsel for SLAC
+! Minimum energy loss in this table is 1.8 eV,
+! and left column is the ln of lower bin limit/1.8,
+! while right column gives the probability of energy
+! loss within bin limits (cross section in some unknown
+! units).
+------------------------------------------------*/
+
 public class SiSingleColElossTab
 {
 

lcsim/src/org/lcsim/recon/vertexing/pixsim
TrackSegmentSimulation.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- TrackSegmentSimulation.java	10 Feb 2011 22:30:32 -0000	1.2
+++ TrackSegmentSimulation.java	8 Mar 2011 19:16:01 -0000	1.3
@@ -55,6 +55,8 @@
 
     public void setTimeBin(double tb) { dt=tb; }
 
+    public void setNumberOfBins(int nb) { nbins=nb; }
+
     public void useFastBlobSimulation(boolean yes) { fast_cloud = yes; }
 
     public void simulateSegment(Hep3Vector startp, Hep3Vector endp, short bc)
CVSspam 0.2.8