Commit in lcsim/sandbox/NickSinev/Examples on MAIN
ChronoPixFieldMove.java+39-191.2 -> 1.3
TCADReadSaveExample.java+4-41.2 -> 1.3
TrackingWithPixSimTest.java+114-481.2 -> 1.3
+157-71
3 modified files
small changes

lcsim/sandbox/NickSinev/Examples
ChronoPixFieldMove.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- ChronoPixFieldMove.java	29 Dec 2010 22:26:56 -0000	1.2
+++ ChronoPixFieldMove.java	10 Feb 2011 22:32:16 -0000	1.3
@@ -17,13 +17,15 @@
      double cesz = 1.5;  // half of charge collection electrode
      double psz = 20.;
      double ethick=20.; 
-     int nzplanes = 80; 
+     int nzplanes = 80;
+     int nxstps = 800;
+     int nym = 8; 
      double zs=17.; 
      double[] efield = new double[3];
 
      TCADFieldMap Efield = new TCADFieldMap();
 //     String fname = "C:\\org_lcsim_cvstop\\lcsim\\sandbox\\NickSinev\\Examples\\thick3d_8_hr_33_emap_coarse.txt";
-     String fname = "thick3d_20hr_2V_emap.txt";
+     String fname = "thick3d_20hr_3V_emap.txt";
      boolean map_found = Efield.readMap(fname);
      if(!map_found)
      {  
@@ -68,36 +70,38 @@
     pcf.setReflectors(reflectors);
 
     CarrierPropagator cpr = new CarrierPropagator(pcf);
-    cpr.setDiffusionSteps(0.0003);
-    cpr.setDriftSteps(0.0001); 
+    cpr.setDiffusionSteps(0.0001);
+    cpr.setDriftSteps(0.00005); 
     cpr.setTrace(true);
 /*
      If we want to clearly see electric field flood lines (direction of charge movement) ,
      we can turn off charge diffusion simulation. This is not realistic (unless temerature
      is zero Kelvin), but give us clear view of electric field.
 */
-    cpr.setIgnoreDiffusion(true);
+//    cpr.setIgnoreDiffusion(true);
 
      TransportState stat = new TransportState();
      TransportStatus status;
 
       IAnalysisFactory af = IAnalysisFactory.create();
-      ITree tree=af.createTreeFactory().create("C:\\analysis\\Chronopix\\thick_hr_charge_move_nodiff.aida","xml",false,true);
+      ITree tree=af.createTreeFactory().create("C:\\analysis\\Chronopix\\thick_hr_charge_move.aida","xml",false,true);
       IHistogramFactory hf = af.createHistogramFactory(tree);
        nzplanes = 80;
        zs = ethick-2.;     // distance from the surface of highly dopped layer next to substrate (in microns)
-      IHistogram2D hxz = hf.createHistogram2D("movement of charge",400,-20.,5.,192,0.,ethick);
-      IHistogram2D hfld = hf.createHistogram2D("Abs value of E-field",200,-20.,5.,2*nzplanes,0.,ethick);
+      IHistogram2D hxz = hf.createHistogram2D("movement of charge",nxstps,-20.,5.,nym*nzplanes,0.,ethick);
+      IHistogram2D hfld = hf.createHistogram2D("Abs value of E-field",nxstps,-20.,5.,nym*nzplanes,0.,ethick);
+      IHistogram1D hfldz = hf.createHistogram1D("Z-comp of e-field at x=0,y=0",2*nzplanes,0.,ethick);
  
     for(int n=0; n<40; n++)
     {
       System.out.println("Track # "+n);
       int k = n;
-      if(n>19) k=n-20;
+      if(n>25) k=n-26;
      double ym = 0.;                       // xm,ym,zm - coordinates in microns
-     double xm =-18.87 + 1.137* k;
+ //    double xm =-18.87 + 1.137* k;
+     double xm =-16.596 + 1.137* k;
      double zm = zs;
-     if(n>19) zm = 3.;
+     if(n>25) zm = 3.;
      double xc=0.001*xm;       
      double yc=0.001*ym;
      double zc=0.001*zm;
@@ -118,23 +122,38 @@
        int npit = track.size();
        System.out.println("trace has "+npit+" points");
        int j=0;
+       boolean fpo=true;
+       int l=0;
+       double xpr=0.;
+       double zpr=0.; 
        for(Hep3Vector point:track)
        {
-        xm=1000.*point.x();
-        ym=1000.*point.y();
-        zm=1000.*point.z();
-       hxz.fill(xm,zm);
+        if(!fpo)
+       {
+        for(l=0; l<5; l++)
+        {
+         xm=xpr + (1000.*point.x()-xpr)*0.2*l;
+         ym=1000.*point.y();
+         zm=zpr + (1000.*point.z()-zpr)*0.2*l;
+        hxz.fill(xm,zm);
+        }
+       }
+        xpr=1000.*point.x();
+        zpr=1000.*point.z();
+        fpo=false;
        }
      }
     }
     double[] epos = new double[3];
-     for(int i=0; i<200; i++)
+    double xds= 25./nxstps;
+     double zds = ethick/(nym*nzplanes);
+     for(int i=0; i<nxstps; i++)
      {
       double y = 0.;
-      double x = -20.+0.125*i+0.0625;
-      for(int j=0; j<2*nzplanes; j++)
+      double x = -20.+xds*i+0.5*xds;
+      for(int j=0; j<nym*nzplanes; j++)
       {
-       double z = 0.125*j + 0.0625;
+       double z = zds*j + 0.5*zds;
        epos[0]=0.001*x;
        epos[1]=0.001*y;
        epos[2]=0.001*z;
@@ -143,6 +162,7 @@
        Efield.getField(epos,efield);
        double E = Math.sqrt(efield[0]*efield[0]+efield[1]*efield[1]+efield[2]*efield[2]);
        hfld.fill(x,z,E);
+       if(i==160) hfldz.fill(z,efield[2]);
       }
      }
     IPlotterFactory pf = af.createPlotterFactory();

lcsim/sandbox/NickSinev/Examples
TCADReadSaveExample.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- TCADReadSaveExample.java	29 Dec 2010 22:26:56 -0000	1.2
+++ TCADReadSaveExample.java	10 Feb 2011 22:32:16 -0000	1.3
@@ -32,7 +32,7 @@
 *   and I need them to translate from TCAD to pixel coordinate system
 */
     double psizexy =0.02;
-    double psizez=0.02;
+    double psizez=0.012;
 /*
 *   Now we need to define coordinate transformation from TCAD into
 *   PixSim convention. By default, TCAD uses Y axis as the axis directed from
@@ -72,18 +72,18 @@
 *   And, of course, we need to tell everybody where to find TCAD data
 *   the name of mesh file:
 */
-    String mname = "c:\\Tcad\\thick3d_20hr_msh.grd";
+    String mname = "c:\\Tcad\\dpw20x20x12hr_msh.grd";
 
 /*   The name of dessis output file:
  */
-    String dname  =   "c:\\Tcad\\thick3d_20hr_2V_des.dat";
+    String dname  =   "c:\\Tcad\\dpw20x20x12hr_3V_des.dat";
 
 /*   And the name for new file, which will be created, and where
 *    transformed map, on regular grid, will be saved:
 *    (I gave it extension txt not to have problems with putting it into CVS.It is really ASCII file,
 *     as all TCAD outputs also).
 */
-     String oname = "thick3d_20hr_2V_emap.txt";
+     String oname = "dpw20x20x12hr_3V_emap.txt";
 
 /*
 *    We may want to choose weight function for interpolation,

lcsim/sandbox/NickSinev/Examples
TrackingWithPixSimTest.java 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- TrackingWithPixSimTest.java	29 Dec 2010 23:37:05 -0000	1.2
+++ TrackingWithPixSimTest.java	10 Feb 2011 22:32:16 -0000	1.3
@@ -5,63 +5,88 @@
 import org.lcsim.recon.vertexing.pixsim.*;
 import org.lcsim.recon.tracking.seedtracker.trackingdrivers.clic_sid.MainTrackingDriver;
 import java.util.*;
-import org.lcsim.util.aida.AIDA;
+import java.io.*;
+//import org.lcsim.util.aida.AIDA;
 import hep.aida.*;
 import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.BasicHep3Vector;
 
 public class TrackingWithPixSimTest extends Driver
 {
    int evnum = 0;
-    AIDA aida = AIDA.defaultInstance();
-    ITree tree = aida.tree();
+   int maxev=4990;
+   PixilatedSensorManager psm=null;
+//    AIDA aida = AIDA.defaultInstance();
+//    ITree tree = aida.tree();
+     ITree tree = null;
+//    IHistogramFactory hf = af.createHistogramFactory(tree);
+    IHistogram1D hnhptr = null;
+    IHistogram1D hnmchpe = null;
+    IHistogram1D hlthr = null;
+    IHistogram1D hltmcr = null;
+    IHistogram1D hnarh = null;
+    IHistogram1D hspzr = null;
+    IHistogram1D hsprpr = null;
+    IHistogram1D hd0res = null;
+    IHistogram1D hz0res = null;
+    IHistogram1D hdptopt = null;
+    IHistogram1D hcptstm = null;
+    IHistogram1D hsptstm = null;
+    IHistogram1D hcpam = null;
+    IHistogram1D hppam = null;
+     IHistogram2D htsvamc = null;
+     IHistogram2D htsvamn = null;
 
-    IAnalysisFactory af = IAnalysisFactory.create();
-    IHistogramFactory hf = af.createHistogramFactory(tree);
-    IHistogram1D hnhptr = hf.createHistogram1D("Number of hits linked to track",40,0,40);
-    IHistogram1D hnmchpe = hf.createHistogram1D("Number of hits linked to MC particle in event",40,0,40);
-    IHistogram1D hlthr = hf.createHistogram1D("Hit pos. radius of linked to track hits",240,0,1200.);
-    IHistogram1D hltmcr = hf.createHistogram1D("Hit pos. radius of linked to MC particle hits",240,0,1200.);
-    IHistogram2D hlthxy = hf.createHistogram2D("Hit pos. xy of linked to track hits",250,0.,250.,250,0.,250.);
-    IHistogram2D hltmcxy = hf.createHistogram2D("Hit pos. xy of linked to MC particle hits",250,0.,250.,250,0.,250.);
-    IHistogram2D hlthvxy = hf.createHistogram2D("Hit pos. xy of linked to track hits in VTX",160,0.,80.,160,0.,80.);
-    IHistogram2D hltmcvxy = hf.createHistogram2D("Hit pos. xy of linked to MC particle hits in VTX",160,0.,80.,160,0.,80.);
-    IHistogram1D hnarh = hf.createHistogram1D("Number of row hits associated with VTX hit",20,0,20);
-    IHistogram1D hspzr = hf.createHistogram1D("z residual of reconstructed  VTX hit",100,-25.,25.);
-    IHistogram1D hsprpr = hf.createHistogram1D("rphi residual of reconstructed  VTX hit",150,-25.,50.);
-    IHistogram1D hd0res = hf.createHistogram1D("reconstructed track d0 residual, microns",100,-25.,25.);
-    IHistogram1D hz0res = hf.createHistogram1D("reconstructed track z0 residual, microns",100,-25.,25.);
-    IHistogram1D hdptopt = hf.createHistogram1D("reconstructed track deltaPt over Pt",100,-0.02,0.02);
-//    IHistogram2D hrptvspt = hf.createHistogram2D("recon track relative Pt error vs Pt",100,0.,10.,50,-0.02,0.02);
-//    IHistogram2D hrd0vspt = hf.createHistogram2D("recon track d0 (u) vs Pt",100,0.,10.,50,-25,25);
-    IHistogram2D hcovrp = hf.createHistogram2D("rphi cov.matr. error estimate vs res. for  VTX hit",50,0.,25.,50,0.,5.);
-    IHistogram2D hcovz = hf.createHistogram2D("z cov.matr. error estimate vs res. for  VTX hit",50,0.,25.,50,0.,5.);
-    IHistogram1D hcptstm = hf.createHistogram1D("time stamp of central pixel in beam crossing intervals",50,0,200);
-    IHistogram1D hsptstm = hf.createHistogram1D("time stamp of over pixels in cluster in beam crossing intervals",100,0,400);
-
-   public TrackingWithPixSimTest()
+   public TrackingWithPixSimTest() throws IOException
    {
-      // this constructor will build PixilatedSensorManager with sensor option Chronopis 20x20x20 u and use of propagator tables
+     IAnalysisFactory af = IAnalysisFactory.create();
+     tree=af.createTreeFactory().create("C:\\analysis\\CLIC\\hr20x20x16_ana_nl10_tw20_muTh120_100G.aida","xml",false,true);
+     IHistogramFactory hf = af.createHistogramFactory(tree);
+     hnhptr = hf.createHistogram1D("Number of hits linked to track",40,0,40);
+     hnmchpe = hf.createHistogram1D("Number of hits linked to MC particle in event",40,0,40);
+     hlthr = hf.createHistogram1D("Hit pos. radius of linked to track hits",240,0,1200.);
+     hltmcr = hf.createHistogram1D("Hit pos. radius of linked to MC particle hits",240,0,1200.);
+     htsvamc = hf.createHistogram2D("Hit time stamp vs ampl for central pixel",255,0.,255.,100,0.,100.);
+     htsvamn = hf.createHistogram2D("Hit time stamp vs ampl for periferial pixels",255,0.,255.,100,0.,100.);
+//     IHistogram2D hltmcxy = hf.createHistogram2D("Hit pos. xy of linked to MC particle hits",250,0.,250.,250,0.,250.);
+//     IHistogram2D hlthvxy = hf.createHistogram2D("Hit pos. xy of linked to track hits in VTX",160,0.,80.,160,0.,80.);
+//     IHistogram2D hltmcvxy = hf.createHistogram2D("Hit pos. xy of linked to MC particle hits in VTX",160,0.,80.,160,0.,80.);
+     hnarh = hf.createHistogram1D("Number of row hits associated with VTX hit",20,0,20);
+     hspzr = hf.createHistogram1D("z residual of reconstructed  VTX hit",100,-25.,25.);
+     hsprpr = hf.createHistogram1D("rphi residual of reconstructed  VTX hit",100,-25.,25.);
+     hd0res = hf.createHistogram1D("reconstructed track d0 residual, microns",100,-25.,25.);
+     hz0res = hf.createHistogram1D("reconstructed track z0 residual, microns",100,-25.,25.);
+     hdptopt = hf.createHistogram1D("reconstructed track deltaPt over Pt",100,-0.02,0.02);
+//     IHistogram2D hcovrp = hf.createHistogram2D("rphi cov.matr. error estimate vs res. for  VTX hit",50,0.,25.,50,0.,5.);
+//     IHistogram2D hcovz = hf.createHistogram2D("z cov.matr. error estimate vs res. for  VTX hit",50,0.,25.,50,0.,5.);
+     hcptstm = hf.createHistogram1D("time stamp of central pixel in beam crossing intervals",100,0,100);
+     hsptstm = hf.createHistogram1D("time stamp of other pixels in cluster in beam crossing intervals",100,0,400);
+     hcpam = hf.createHistogram1D("Signal amplitude in central pixel",255,0,255.);
+     hppam = hf.createHistogram1D("Signal amplitude in periferial pixel",255,0,255.);
+
+      // this constructor will build PixilatedSensorManager with sensor option Chronopix 20x20x16 u and use of propagator tables
       // instead of following track of each charge carrier in the sensor
-        PixilatedSensorManager psm = new PixilatedSensorManager(SensorOption.Chrono20x20x20,true);
+        psm = new PixilatedSensorManager(SensorOption.Chrono20x20x16,true);
 
       // available options are NOMINAL, SHORT_INT, LONG_INT or CLIC
         psm.setIlcOption(IlcOption.CLIC);
       
       // if option is CLIC we can set time window for accepting clusters. It is set in beam crossings (which is 0.5 ns for CLIC)
       // and it works only with digiital readout (when chronopix electronics is used). By default for CLIC it is set to 50
-       psm.setTimeWindow(30);
+       psm.setTimeWindow(20);
 
-        psm.setNoiseLevel(25.);
+        psm.setNoiseLevel(10.);
 
        // setting digital readout true or false will assign correct electronics for hit processing
-        psm.setDigitalReadout(true);
+        psm.setDigitalReadout(false);
 
       // these settings are relevant only if we are using analog readout. They are ignored if readout is digital
+       psm.setADCscale(10.);
        psm.setPixelThreshold(3);
-       psm.setClusterThreshold(6);
+       psm.setClusterThreshold(10);
 
-     // and this  setting only make difference if electronics has analog readout .   
-      psm.setThresholdToNoiseRatio(4.5);
+     // and this  setting only make difference if electronics has digital readout .   
+      psm.setThresholdToNoiseRatio(5.0);
       // including elrctronic noise hits may increase event processing time by orders of magnitude (depending on noise level and
       // pixel threshold). So, unless we are interested in the ability of our software to handle huge number of hits, it is
       // better to keep this option off (set it to false)
@@ -70,31 +95,44 @@
       // we can use pixsim package with any detector, not only clic_sid. To be independent on the fact that detector conditions files
       // may not have propagator tables for given type of sensors, we can set local option for tables, which will allow us
       // to read tables not from LCdetectors/detectors/detector_name database, but from local file     
-        psm.useLocalPropagatorTables(false);
+        psm.useLocalPropagatorTables(true);
+        psm.usePropagatorTables("Chronopix_20x20x16_hr_B5_Br_3V_propagator.dat","Chronopix_20x20x20_hr_B5_EC_propagator.dat");
+
 
       // and the same for resolution tables 
-        psm.useLocalResolutionTables(false);
+        psm.useLocalResolutionTables(true);
+
+     // if my propagator table is done for pixel dimensions different from one of the sensor options, I
+     // need to set pixel dimensions according to propagator dimensions
+     psm.setDimensions(0.02,0.02,0.016,0.004,0.004,0.002);
+
+      BasicHep3Vector lc = new BasicHep3Vector(0.00436,-0.00043,0.);
+      psm.setLorentzCorrection(lc,null,null);
 
       // if we defined new sensor configuration and have used CarrierPropagatorMakeTable program to generate propagator tables,
       // it is easy to build resolution tables, it can be done within pixilated sensor manager
       // Second argument - number of tracks for each bin of tanlam, tanalpha and sigtonoise. With 1000 it will take about 10 minutes
       // to build tables with more or less satisfactory precision. 
 
-//        psm.calibrateBarrelResolution(true,1000,"Chronopix_20x20x20_hr_B5_res_bar.dat");  
-//        psm.calibrateEndcapResolution(true,1000,"Chronopix_20x20x20_hr_B5_res_EC.dat","Chronopix_20x20x20_hr_res_EC.dat");
+        psm.calibrateBarrelResolution(false,1000,"Chronopix_20x20x16_hr_B5_res_bar.dat");  
+        psm.calibrateEndcapResolution(false,1000,"Chronopix_20x20x16_hr_B5_res_EC.dat","Chronopix_20x20x20_hr_res_EC.dat");
   
     add(new MainTrackingDriver(psm));
    }
 
    public void process(EventHeader event) 
    {
+    if(evnum < maxev)
+    {
     if(evnum%10 == 0) System.out.println("Processing event: "+evnum);
+    if((evnum == 1) && (psm != null)) psm.printSettings();
     super.process(event);
      List<List<TrackerHit>> evthits = event.get(TrackerHit.class);
      List<List<HelicalTrackHit>> helhits = event.get(HelicalTrackHit.class);
      List<List<Track>> trks = event.get(Track.class);
      int nmclnk=0;
      short[] tstmp = new short[100];
+     short[] psamp = new short[100];  
      if(evthits != null)
      {
  //     System.out.println("Event has  "+evthits.size()+" TrackerHit collections: ");
@@ -118,7 +156,11 @@
             short[] adv = rht.getADCValues();
             if(adv.length == 3)
             {
-             if(narh<100) tstmp[narh]=adv[2];
+             if(narh<100)
+             {
+               tstmp[narh]=adv[2];
+               psamp[narh]=adv[0];
+             }
             } 
             narh++;
             List<SimTrackerHit> simhits = rht.getSimTrackerHits();
@@ -150,8 +192,8 @@
          if(rad < 1.) rad=1.;
          double tl=Math.abs(hpos[2])/rad;
          if(tl < 0.9) hltmcr.fill(rad);
-         if((hpos[0] > 0.) && (hpos[1] > 0.) && (tl < 0.9) && (rad < 250.)) hltmcxy.fill(hpos[0],hpos[1]);
-         if((hpos[0] > 0.) && (hpos[1] > 0.) && (tl < 0.9) && (rad < 80.)) hltmcvxy.fill(hpos[0],hpos[1]);
+ //        if((hpos[0] > 0.) && (hpos[1] > 0.) && (tl < 0.9) && (rad < 250.)) hltmcxy.fill(hpos[0],hpos[1]);
+ //        if((hpos[0] > 0.) && (hpos[1] > 0.) && (tl < 0.9) && (rad < 80.)) hltmcvxy.fill(hpos[0],hpos[1]);
          if((tl<1.0) && (rad < 80.))
           {
            hnarh.fill(narh);
@@ -172,8 +214,17 @@
            if(mintsi!=-1)
            {
             hcptstm.fill(mintst);
+            htsvamc.fill(psamp[mintsi],tstmp[mintsi]);
+            hcpam.fill(psamp[mintsi]);
             for(i=0; i<narh; i++)
-             if(i != mintsi) hsptstm.fill(tstmp[i]);
+            {
+             if(i != mintsi)
+             { 
+              hsptstm.fill(tstmp[i]);
+              htsvamn.fill(psamp[i],tstmp[i]);
+              hppam.fill(psamp[i]);
+             }
+            } 
            }
            double dz=(hpos[2]-mchco[2])*1000.;
            double phh = Math.atan2(hpos[1],hpos[0]);
@@ -185,8 +236,8 @@
            drp*=1000.;
            hsprpr.fill(drp);
            hspzr.fill(dz);
-           hcovrp.fill(Math.abs(drp),rperr);
-           hcovz.fill(Math.abs(dz),zerr);
+ //          hcovrp.fill(Math.abs(drp),rperr);
+ //          hcovz.fill(Math.abs(dz),zerr);
           } 
          }
        }
@@ -221,8 +272,8 @@
          if(rad < 1.) rad=1.;
          double tl=Math.abs(hpos[2])/rad;
          if(tl < 0.9) hlthr.fill(rad);
-         if((hpos[0] > 0.) && (hpos[1] > 0.) && (tl < 1.) && (rad < 250.)) hlthxy.fill(hpos[0],hpos[1]);
-         if((hpos[0] > 0.) && (hpos[1] > 0.) && (tl < 1.) && (rad < 80.)) hlthvxy.fill(hpos[0],hpos[1]);
+//         if((hpos[0] > 0.) && (hpos[1] > 0.) && (tl < 1.) && (rad < 250.)) hlthxy.fill(hpos[0],hpos[1]);
+//         if((hpos[0] > 0.) && (hpos[1] > 0.) && (tl < 1.) && (rad < 80.)) hlthvxy.fill(hpos[0],hpos[1]);
          List<RawTrackerHit> rhits = tht.getRawHits();
          for(RawTrackerHit rht:rhits)
          {
@@ -252,7 +303,22 @@
       }
      }
     }
-    evnum++;
    }
+   if((tree!= null) && (evnum==maxev))
+   {
+    try
+    {
+     tree.commit();
+    }
+    catch(IOException e)
+    {
+     System.out.println("Unable to record aida file!");
+    }
+    finally
+    {
+    }
+   }
+   evnum++;
+  }
 
 }
\ No newline at end of file
CVSspam 0.2.8