Print

Print


Commit in lcsim/sandbox/NickSinev/PixSim on MAIN
CarrierPropagator.java+3-31.3 -> 1.4
ErrorEstimate.java+64-41.1 -> 1.2
PixilatedSensorManager.java+115-891.1 -> 1.2
SiliconEloss.java+3-31.2 -> 1.3
+185-99
4 modified files
Got rid of excessive diagnostic printouts. Enabled use of tables from detector file.

lcsim/sandbox/NickSinev/PixSim
CarrierPropagator.java 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- CarrierPropagator.java	27 Jun 2008 23:38:32 -0000	1.3
+++ CarrierPropagator.java	30 Jun 2008 18:55:05 -0000	1.4
@@ -314,7 +314,7 @@
      BufferedReader reader = null;
      if(path != null)
      {
-      System.out.println("Found: "+path.getAbsolutePath());
+//      System.out.println("Found: "+path.getAbsolutePath());
       ZipFile zipf = null;
       try { zipf = new ZipFile(path);} catch(Exception e) {} finally {}
       Enumeration<?extends ZipEntry>  zcont = zipf.entries();
@@ -322,10 +322,10 @@
       while(zcont.hasMoreElements())
       {
        ZipEntry ze = (ZipEntry) zcont.nextElement();
-       System.out.println("Entry name: "+ze.getName());
+//       System.out.println("Entry name: "+ze.getName());
        if(ze.getName().equals(enam))
        {
-        System.out.println("Found table");
+        System.out.println("Found table "+enam+" in detector "+dname+" configuration zip file");
         ztab = ze;
        }
       }

lcsim/sandbox/NickSinev/PixSim
ErrorEstimate.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- ErrorEstimate.java	27 Jun 2008 23:38:32 -0000	1.1
+++ ErrorEstimate.java	30 Jun 2008 18:55:05 -0000	1.2
@@ -7,8 +7,12 @@
 import org.lcsim.detector.solids.*;
 import java.text.*;
 import java.io.*;
+import java.net.*;
 import javax.management.*;
 import java.lang.management.*;
+import org.lcsim.geometry.Detector;
+import java.util.zip.*;
+import org.lcsim.util.cache.*;
 
 
 /**
@@ -29,6 +33,7 @@
    double tama = 1.;
    double nfactmin = 2.2;
    double nfactmax = 7.2; 
+   boolean tab_read=false;
    DecimalFormat df = new DecimalFormat();
    double[][][] sigmasr = new double[ntlbns][ntabns][nnobns];
 
@@ -54,7 +59,7 @@
 
     public boolean readTable(String fnam)
     {
-     boolean tab_read=false;
+     tab_read=false;
      String cacheDir = System.getProperty("user.home");
      File cachedir = new File(cacheDir);
  
@@ -92,6 +97,61 @@
      return tab_read;
     }  // end of function readTable(String n)
 
+    public boolean readTable(String nam, Detector det)
+    {
+     String dname = det.getName();
+     tab_read = false;
+     String dfname = "/detectors/"+dname+".zip";
+     String enam = "PixilatedSensorTables/"+nam;
+     URL url = null;
+     try
+     { 
+      url = new URL("http","www.lcsim.org",dfname);
+     }
+     catch(MalformedURLException e)
+     {
+     }
+     finally
+     {
+     }
+     FileCache ucache = null;
+     try {ucache = new FileCache();} catch(IOException e) {} finally{}
+     File lroot = new File(ucache.getCacheRoot(),".lcsim");
+     File lrootc = new File(lroot,"cache");
+     FileCache fcache = null; 
+     if(lrootc != null){ try {fcache =  new FileCache(lrootc);} catch(IOException e) {} finally{} }
+     File path = null; 
+     if(url != null) { try{ path = fcache.getCachedFile(url); } catch(IOException e){} finally {} }
+     BufferedReader reader = null;
+     if(path != null)
+     {
+//      System.out.println("Found: "+path.getAbsolutePath());
+      ZipFile zipf = null;
+      try { zipf = new ZipFile(path);} catch(Exception e) {} finally {}
+      Enumeration<?extends ZipEntry>  zcont = zipf.entries();
+      ZipEntry ztab = null;
+      while(zcont.hasMoreElements())
+      {
+       ZipEntry ze = (ZipEntry) zcont.nextElement();
+//       System.out.println("Entry name: "+ze.getName());
+       if(ze.getName().equals(enam))
+       {
+        System.out.println("Found table "+enam+" in detector "+dname+" configuration zip file");
+        ztab = ze;
+       }
+      }
+      if(ztab != null)
+      {
+       InputStream tinps = null;
+       try { tinps = zipf.getInputStream(ztab);} catch(IOException e) {} finally {} 
+       if(tinps != null) reader = new BufferedReader(new InputStreamReader(tinps));
+      }
+     }
+     if(reader != null) tab_read = readTable(reader);
+     return tab_read;
+    }  
+
+
     public boolean readTable(BufferedReader r)
     {
      int[] tpar = new int[10];
@@ -104,8 +164,8 @@
      nnobns=tpar[3];
      sigmasr = new double[ntlbns][ntabns][nnobns];
      sigmasc = new double[ntlbns][ntabns][nnobns];
-     System.out.println(
-       "Table made from "+cal_stat+" samples in each of "+ntlbns+" tlbns x "+ntabns+" tabns x "+nnobns+" noice bins");  
+//     System.out.println(
+//       "Table made from "+cal_stat+" samples in each of "+ntlbns+" tlbns x "+ntabns+" tabns x "+nnobns+" noise bins");  
      ntp=freader.readLineOfDouble(r,dpar);
      if(ntp != 6) System.out.println("Error in table header, double values");
      tlmi=dpar[0];
@@ -114,7 +174,7 @@
      tama=dpar[3];
      nfactmin=dpar[4];
      nfactmax=dpar[5];
-     System.out.println("Tl min-max "+tlmi+" - "+tlma+" Ta min-max " +tami+" - "+tama+" nise fact min-max "+nfactmin+" - "+nfactmax);
+//     System.out.println("Tl min-max "+tlmi+" - "+tlma+" Ta min-max " +tami+" - "+tama+" noise fact min-max "+nfactmin+" - "+nfactmax);
      for(int i=0; i<ntlbns; i++)
      {
       for(int j=0; j<ntabns; j++)

lcsim/sandbox/NickSinev/PixSim
PixilatedSensorManager.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- PixilatedSensorManager.java	27 Jun 2008 23:38:32 -0000	1.1
+++ PixilatedSensorManager.java	30 Jun 2008 18:55:05 -0000	1.2
@@ -19,7 +19,7 @@
  * for each event (only sensors which have hits in them are created)
  *
  * @author Nick Sinev
- * @version $Id: PixilatedSensorManager.java,v 1.1 2008/06/27 23:38:32 sinev Exp $
+ * @version $Id: PixilatedSensorManager.java,v 1.2 2008/06/30 18:55:05 sinev Exp $
  */
 
 public class PixilatedSensorManager extends Driver
@@ -28,7 +28,8 @@
  boolean cal_res_ec = false;
  boolean read_rest_bar=true;
  boolean read_rest_ec=true;
- boolean incl_el_noise = false; 
+ boolean incl_el_noise = false;
+ boolean ready = false; 
  static PixSimConstants cons = PixSimConstants.instance();
  static final int MAXHTSPEV = 10000;
  private static final double bunch_period = cons.BunchInterval;
@@ -94,11 +95,11 @@
  private static int[] opt_cluster_thr_barr = {8,8,8,1,1,1,1,1,1,8};
  private static int[] opt_cluster_thr_ec =  {8,8,8,1,1,1,1,1,1,8};
  private static boolean[] opt_prop_tab_barrel_local = {false,false,false,true,true,true,true,true,true,true};
- private static boolean[] opt_prop_tab_ec_pl_local = {true,true,true,true,true,true,true,true,true,true};
- private static boolean[] opt_prop_tab_ec_mi_local = {true,true,true,true,true,true,true,true,true,true};
- private static boolean[] opt_res_tab_barrel_local = {true,true,true,true,true,true,true,true,true,true};
- private static boolean[] opt_res_tab_ec_pl_local = {true,true,true,true,true,true,true,true,true,true};
- private static boolean[] opt_res_tab_ec_mi_local = {true,true,true,true,true,true,true,true,true,true};
+ private static boolean[] opt_prop_tab_ec_pl_local = {false,false,false,true,true,true,true,true,true,true};
+ private static boolean[] opt_prop_tab_ec_mi_local = {false,false,false,true,true,true,true,true,true,true};
+ private static boolean[] opt_res_tab_barrel_local = {false,false,false,true,true,true,true,true,true,true};
+ private static boolean[] opt_res_tab_ec_pl_local = {false,false,false,true,true,true,true,true,true,true};
+ private static boolean[] opt_res_tab_ec_mi_local = {false,false,false,true,true,true,true,true,true,true};
  private static boolean[] opt_ec_bar_same_prop = {false,false,false,false,false,false,false,false,false,false};
  private static boolean[] opt_ec_pl_ec_mi_same_prop = {true,true,true,true,true,true,true,true,true,true};
 
@@ -230,78 +231,62 @@
 
  public PixilatedSensorManager(SensorOption opt, boolean usetable)
  {
-  if(opt == SensorOption.ClassicCCD)
+  if(opt == SensorOption.ClassicCCD) option = 0;
+  if(opt == SensorOption.CPCCD) option = 1;
+  if(opt == SensorOption.ShortColumnCCD) option = 2;
+  if(opt == SensorOption.Chrono8x8x20) option = 3;
+  if(opt == SensorOption.Chrono12x12x20) option = 4;
+  if(opt == SensorOption.Chrono16x16x20) option = 5;
+  if(opt == SensorOption.Chrono8x8x12) option = 6; 
+  if(opt == SensorOption.Chrono12x12x12) option = 7; 
+  if(opt == SensorOption.Chrono16x16x12) option = 8;
+  if(opt == SensorOption.Mimosa) option = 9;
+  use_prop_tab_barrel = usetable;
+  use_prop_tab_ec_pl = usetable;
+  use_prop_tab_ec_mi = usetable;
+ }
+ 
+  private void setup()
   {
-   option = 0;
-   setOptionVariables();
-   IPixelSensorElectronics el = new CCDElectronics();
-   el.includeElectronicNoiseHits(incl_el_noise);
-   el.setADCScale(25.);
-   el.setNoiseLevel(50.);
-   el.setADCSaturation(255);
-   el.setBunchesPerClock(30); // this is about maximum clock image speed (100 KHz) for classic CCD - asuming 50MHz speed in R register
+   if(option == 0)
+   {
+    setOptionVariables();
+    IPixelSensorElectronics el = new CCDElectronics();
+    el.includeElectronicNoiseHits(incl_el_noise);
+    el.setADCScale(25.);
+    el.setNoiseLevel(50.);
+    el.setADCSaturation(255);
+    el.setBunchesPerClock(30); // this is about maximum clock image speed (100 KHz) for classic CCD - asuming 50MHz speed in R register
                               // for VXD3 CCD we would set this value to 300 (10 KHz image clock and 5 MHz R register speed)
-   el.useCorrelatedDoubleSampling(true);
-   el.setPixelThreshold(4);
-   bar_el = el;
-   ecp_el = el;
-   ecm_el = el;
-   bpcf = new PixelConfiguration();
-   bcpr = new CarrierPropagator(bpcf);
-   ecppr = new CarrierPropagator(bpcf);
-   ecmpr = ecppr;     
-  }
-  if(opt == SensorOption.CPCCD)
-  {
-   option = 1;
-   setOptionVariables();
-   IPixelSensorElectronics el = new CCDElectronics();
-   el.setADCScale(25.);
-   el.setNoiseLevel(50.);
-   el.setADCSaturation(255);
-   el.useCorrelatedDoubleSampling(true);
-   el.setPixelThreshold(4);
-   el.setClocksPerBunch(16); // 50 MHz image clock speed in column parallel CCD 
-   bar_el = el;
-   ecp_el = el;
-   ecm_el = el;
-  }
-  if(opt == SensorOption.ShortColumnCCD)
-  {
-   option = 2;
+    el.useCorrelatedDoubleSampling(true);
+    el.setPixelThreshold(4);
+    bar_el = el;
+    ecp_el = el;
+    ecm_el = el;
+    bpcf = new PixelConfiguration();
+    bcpr = new CarrierPropagator(bpcf);
+    ecppr = new CarrierPropagator(bpcf);
+    ecmpr = ecppr;
+    ready = true;     
+   }
+   if(option == 1)
+   {
+    setOptionVariables();
+    IPixelSensorElectronics el = new CCDElectronics();
+    el.includeElectronicNoiseHits(incl_el_noise);
+    el.setADCScale(25.);
+    el.setNoiseLevel(50.);
+    el.setADCSaturation(255);
+    el.useCorrelatedDoubleSampling(true);
+    el.setPixelThreshold(4);
+    el.setClocksPerBunch(16); // 50 MHz image clock speed in column parallel CCD 
+    bar_el = el;
+    ecp_el = el;
+    ecm_el = el;
+    ready = true;
+   }
+   if(option > 1) System.out.println("This sensor option is not implemented yet! ");
   }
-  if(opt == SensorOption.Chrono8x8x20)
-  {
-   option = 3;
-  } 
-  if(opt == SensorOption.Chrono12x12x20)
-  {
-   option = 4;
-  } 
-  if(opt == SensorOption.Chrono16x16x20)
-  {
-   option = 5;
-  } 
-  if(opt == SensorOption.Chrono8x8x12)
-  {
-   option = 6;
-  } 
-  if(opt == SensorOption.Chrono12x12x12)
-  {
-   option = 7;
-  } 
-  if(opt == SensorOption.Chrono16x16x12)
-  {
-   option = 8;
-  } 
-  if(opt == SensorOption.Mimosa)
-  {
-   option = 9;
-  } 
-   use_prop_tab_barrel = usetable;
-   use_prop_tab_ec_pl = usetable;
-   use_prop_tab_ec_mi = usetable;
- }
 
  private void setOptionVariables()
  {
@@ -322,6 +307,8 @@
   cluster_thr_ec = opt_cluster_thr_ec[option];
  }
 
+ public void includeElectronicsNoise(boolean yes) { incl_el_noise=yes; }
+
  public List<IDetectorElement> getBarrelDetectorElements()
  {
    return vxbrels;
@@ -436,40 +423,62 @@
   if(firstcall)
   {
    firstcall=false;
+   setup();
    vxbrels.clear();
    vxecpels.clear();
    vxecmels.clear();
    if(use_prop_tab_barrel)
    {
-    if(bcpr.useTable(bar_prop_tname,det)) System.out.println("Using table for barrel sensor carrier propagator");
+    if(prop_tab_barrel_local) 
+    {
+     if(bcpr.useTable(bar_prop_tname)) 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(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(ecppr.useTable(ec_pl_prop_tname)) System.out.println("Using table for ec pl sensor carrier propagator");
+     if(prop_tab_ec_pl_local)
+     {
+      if(ecppr.useTable(ec_pl_prop_tname)) 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(use_prop_tab_ec_mi)
    {
     if(!ec_pl_ec_mi_same_prop)
     {  
-     if(ecmpr.useTable(ec_mi_prop_tname)) System.out.println("Using table for ec mi sensor carrier propagator");
+     if(prop_tab_ec_mi_local)
+     {
+      if(ecmpr.useTable(ec_mi_prop_tname)) 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");
+     }
     }
    }
    IDetectorElement tde = det.getDetectorElement();
    if(tde != null)
    {
-    System.out.println("Detector elements: ");
+//    System.out.println("Detector elements: ");
     List<IDetectorElement> chlds= (List<IDetectorElement>) tde.getChildren();
     for(IDetectorElement chld:chlds)
     {
      String name = chld.getName();
-     System.out.println(name);
+//     System.out.println(name);
      if((name.indexOf("Vtx")!=-1) || (name.indexOf("Vertex") != -1))
      {
-      System.out.println(" processing "+name);
+//      System.out.println(" processing "+name);
       if(name.indexOf("Barrel") !=-1)
       {
        if(!chld.hasChildren()) vxbrels.add(chld);
@@ -512,10 +521,10 @@
       } 
       if(name.indexOf("Endcap") !=-1)
       {
-       System.out.println("It is endcap!");
+//       System.out.println("It is endcap!");
        if(!chld.hasChildren())
        {
-        System.out.println("It does not have children!");
+//        System.out.println("It does not have children!");
         if(name.indexOf("positive") != -1)
          vxecpels.add(chld);
         if(name.indexOf("negative") != -1)
@@ -529,7 +538,7 @@
          if(!chld1.hasChildren())
          {
           name = chld1.getName();
-          System.out.println("  "+name); 
+//          System.out.println("  "+name); 
           if(name.indexOf("positive") != -1)
            vxecpels.add(chld1);
           if(name.indexOf("negative") != -1)
@@ -543,7 +552,7 @@
            if(!chld2.hasChildren())
            {
             name = chld2.getName();
-            System.out.println("    "+name); 
+//            System.out.println("    "+name); 
             if(name.indexOf("positive") != -1)
              vxecpels.add(chld2);
             if(name.indexOf("negative") != -1)
@@ -589,9 +598,13 @@
      } // end of if((name.indexOf("Vtx")!=-1) || (name.indexOf("Vertex") != -1))
     } // end of for(IDetectorElement chld:chlds)
    } // end of if(tde != null)
-   System.out.println("Detector contains "+vxbrels.size()+" barrel vertex and "+vxecpels.size()+" endcap detector elements");
+//   System.out.println("Detector contains "+vxbrels.size()+" barrel vertex and "+vxecpels.size()+" endcap detector elements");
    int nbe = 0;
-   if(read_rest_bar) eeb.readTable(rtab_name_bar);
+   if(read_rest_bar)
+   { 
+    if(res_tab_barrel_local) eeb.readTable(rtab_name_bar);
+    else eeb.readTable(rtab_name_bar,det);
+   } 
    for(IDetectorElement de:vxbrels)
    {
     PixilatedSensor pse = new PixilatedSensor(de,bcpr,false);
@@ -602,7 +615,11 @@
     psbrl.add(pse);
    }
    int nbc = 0;     
-   if(read_rest_ec) eeep.readTable(rtab_name_ec_pl);
+   if(read_rest_ec)
+   {
+    if(res_tab_ec_pl_local) eeep.readTable(rtab_name_ec_pl);
+    else eeep.readTable(rtab_name_ec_pl,det);
+   }
    for(IDetectorElement de:vxecpels)
    {
     PixilatedSensor pse = new PixilatedSensor(de,ecppr,true); 
@@ -616,6 +633,14 @@
    int nbcm = 0;     
    if((read_rest_ec)&&(!ec_pl_ec_mi_same_prop))  eeem.readTable(rtab_name_ec_mi);
    if(ec_pl_ec_mi_same_prop) eeem=eeep;
+   else
+   {
+    if(read_rest_ec)
+    {
+     if(res_tab_ec_mi_local) eeem.readTable(rtab_name_ec_mi);
+     else eeem.readTable(rtab_name_ec_mi,det);
+    }
+   }
    for(IDetectorElement de:vxecmels)
    {
     PixilatedSensor pse = new PixilatedSensor(de,ecmpr,true); 
@@ -630,6 +655,7 @@
     psecml.add(pse);
    }     
   } // end of if(firstcall)
+  if(!ready) return;
   for(IDetectorElement de:vxbrels)
   {
    if(de.hasReadout()) { IReadout ro = de.getReadout(); ro.clear(); }

lcsim/sandbox/NickSinev/PixSim
SiliconEloss.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- SiliconEloss.java	27 Mar 2008 20:44:23 -0000	1.2
+++ SiliconEloss.java	30 Jun 2008 18:55:05 -0000	1.3
@@ -39,12 +39,12 @@
      _xval[i]=row[0];
      yval[i]=row[1];
     }
-    System.out.println("Last read y value was: "+yval[NPNTS-1]);
-    System.out.println("Last read x value was: "+_xval[NPNTS-1]);
+//    System.out.println("Last read y value was: "+yval[NPNTS-1]);
+//    System.out.println("Last read x value was: "+_xval[NPNTS-1]);
     double lastx = Math.log(maxsingloss/1.8);
     vpnts = 0;
     for(int i=0; i<NPNTS; i++) if(_xval[i]<lastx) vpnts=i+1;
-    System.out.println("using single collision table of "+vpnts+" length");
+//    System.out.println("using single collision table of "+vpnts+" length");
     _yint = new double[NPNTS];
     _yint[0]=yval[0];
     for(int i=1; i<NPNTS; i++)
CVSspam 0.2.8