lcsim/sandbox/NickSinev/PixSim
diff -u -r1.1 -r1.2
--- CCDChargeSpreadComputer.java 10 Aug 2007 21:23:06 -0000 1.1
+++ CCDChargeSpreadComputer.java 10 Aug 2007 23:27:20 -0000 1.2
@@ -1,5 +1,8 @@
package org.lcsim.mc.PixSim;
import org.lcsim.mc.CCDSim.LorentzAngle;
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.VecOp;
+import hep.physics.vec.BasicHep3Vector;
/**
@@ -8,7 +11,7 @@
* travels here in the electric and magnetic field
*
* @author sinev
- * @version $Id: CCDChargeSpreadComputer.java,v 1.1 2007/08/10 21:23:06 sinev Exp $
+ * @version $Id: CCDChargeSpreadComputer.java,v 1.2 2007/08/10 23:27:20 sinev Exp $
*/
public class CCDChargeSpreadComputer implements ChargeSpreadComputer
{
@@ -29,7 +32,6 @@
private double dthick = 4.;
private double celszx = 1.;
private double celszy = 1.;
- private CCDSpecifications specs = null;
private double q = -1.;
private int ctyp = 0;
private final double[] Aref = {0.765,-0.14};
@@ -77,7 +79,7 @@
*
*/
- public void setSensor( CCDSpecifications sp)
+ public void setSensor( PixelatedSensorSpecs sp)
{
athick = sp.getActiveThickness();
dthick = sp.getDepletedThickness();
@@ -113,7 +115,7 @@
{
if(celszx*celszy > sigd*sigd)
{
- if((Math.abs(dx) < 0.5*celszx))&&(Math.abs(dy) < 0.5*celszy))
+ if((Math.abs(dx) < 0.5*celszx) && (Math.abs(dy) < 0.5*celszy))
chd = 1./(celszx*celszy);
}
else
@@ -143,7 +145,7 @@
return chd;
}
- private double[] calculateCentroid(x,y,z)
+ private double[] calculateCentroid(double x, double y, double z)
{
double[] centr = new double[2];
double lof = 0.;
@@ -160,8 +162,9 @@
{
if(q > 0.) ctyp=1;
Lorentz = VecOp.cross(Bfield,Efield);
- if(Efield.mag() > 1.) Beff = Lorentz.mag()/Efield.mag();
- lorentzangle = q*la.getLorentzAngle(Beff,Efield.mag(),temp,ctyp);
+ double ef = Math.sqrt(Efield.x()*Efield.x()+Efield.y()*Efield.y()+Efield.z()*Efield.z());
+ if(ef > 1.) Beff = Math.sqrt(Lorentz.x()*Lorentz.x()+Lorentz.y()*Lorentz.y()+Lorentz.z()*Lorentz.z())/ef;
+ lorentzangle = q*la.getLorentzAngle(Beff,ef,temp,ctyp);
}
}
lcsim/sandbox/NickSinev/PixSim
diff -u -r1.1 -r1.2
--- CCDSpecifications.java 10 Aug 2007 21:23:06 -0000 1.1
+++ CCDSpecifications.java 10 Aug 2007 23:27:20 -0000 1.2
@@ -5,7 +5,7 @@
* Specifications defined by this class: epitaxial layer depth (thicknes), depleted layer depth
* pixel size in x direction and pixel size in y direction. Everything in micrometers
* @author Sinev U of Oregon; [log in to unmask] ; SLAC x2970
- * @version $Id: CCDSpecifications.java,v 1.1 2007/08/10 21:23:06 sinev Exp $
+ * @version $Id: CCDSpecifications.java,v 1.2 2007/08/10 23:27:20 sinev Exp $
*/
public class CCDSpecifications implements PixelatedSensorSpecs
{
@@ -15,7 +15,7 @@
public final int PSIZEYOF = 1;
public final int THICKNESSOF = 2;
public final int DEPLTHICKNESSOF = 3;
- public final int OPTEMERATUREOF = 4;
+ public final int OPTEMPERATUREOF = 4;
public final int VOLTAGEOF = 5;
private double[] senspecs = new double[NSSPECS];
private static CCDSpecifications theSpec;
@@ -76,7 +76,7 @@
*
*/
- public double getPixelSizeX()
+ public double getPixelSizeY()
{
return senspecs[PSIZEYOF];
}
@@ -120,5 +120,5 @@
{
return senspecs[VOLTAGEOF];
}
-
+}
\ No newline at end of file
lcsim/sandbox/NickSinev/PixSim
diff -u -r1.1 -r1.2
--- ChargeSpreadComputer.java 10 Aug 2007 21:23:06 -0000 1.1
+++ ChargeSpreadComputer.java 10 Aug 2007 23:27:20 -0000 1.2
@@ -1,5 +1,5 @@
package org.lcsim.mc.PixSim;
-import org.lcsim.mc.CCDSim.LorentzVector;
+import hep.physics.vec.Hep3Vector;
/**
* A general interface for accessing software,
@@ -13,7 +13,7 @@
* Different types of sensors may have completely different objects, implementing
* this interface.
* @author sinev
- * @version $Id: ChargeSpreadComputer.java,v 1.1 2007/08/10 21:23:06 sinev Exp $
+ * @version $Id: ChargeSpreadComputer.java,v 1.2 2007/08/10 23:27:20 sinev Exp $
*/
public interface ChargeSpreadComputer
{
@@ -33,7 +33,7 @@
*
*/
- public void setBfield( double B);
+ public void setBfield( Hep3Vector B);
/**
* Setting the sensor parameters by providing Sensor Specifications
@@ -41,4 +41,9 @@
*/
public void setSensor( PixelatedSensorSpecs sp);
+
+ public void setCellSizeX(double csx);
+
+ public void setCellSizeY(double csy);
+
}
lcsim/sandbox/NickSinev/PixSim
diff -u -r1.1 -r1.2
--- ChargeSpreadTable.java 10 Aug 2007 21:23:06 -0000 1.1
+++ ChargeSpreadTable.java 10 Aug 2007 23:27:20 -0000 1.2
@@ -1,5 +1,9 @@
package org.lcsim.mc.PixSim;
import java.util.*;
+import java.io.*;
+import java.text.*;
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.BasicHep3Vector;
/**
* A program which provides fractions of the charge, generated at
@@ -14,7 +18,7 @@
* Modifications: August 3, 2007 - C programs created <BR>
* @author sinev U of Oregon, SLAC. x2970 <BR>
*
- * @version $Id: ChargeSpreadTable.java,v 1.1 2007/08/10 21:23:06 sinev Exp $
+ * @version $Id: ChargeSpreadTable.java,v 1.2 2007/08/10 23:27:20 sinev Exp $
*
*/
@@ -22,21 +26,20 @@
{
private boolean debug = false;
private boolean table_created = false;
- private SensorSpec specs = null;
+ private PixelatedSensorSpecs specs = null;
private int NDepths = 20;
private int NSPntsX = 20;
private int NSPntsY = 20;
private int NPixelsX = 11;
private int NPixelsY = 11;
- private double _Bfield = 5.;
- private double _bv = 10.;
+ private Hep3Vector _Bfield = new BasicHep3Vector(0.,5.,0.);
+ private double _bV = 10.;
private static float[][][][][] _table = null;
- private string _sname = "ccd_classic";
- private string _suffix = "";
- PixelatedSensorSpecs specs;
+ private String _sname = "ccd_classic";
+ private String _suffix = "";
ChargeSpreadComputer chscomp=null;
FileWriter ofw = null;
- DigitalFormat df = new DigitalFormat();
+ DecimalFormat df = new DecimalFormat();
/**
* Default constructor. Create table for default sensor type,
@@ -57,7 +60,7 @@
CreateTable();
}
- public ChargeSpreadTable(String sensor, String suffix);
+ public ChargeSpreadTable(String sensor, String suffix)
{
_sname = sensor;
_suffix = suffix;
@@ -89,9 +92,9 @@
- public void setBField(double B)
+ public void setBField(Hep3Vector B)
{
- _Bfield = B;
+ ((BasicHep3Vector) _Bfield).setV(B.x(),B.y(),B.z());
}
public void setBiasVolt(double V)
@@ -108,7 +111,7 @@
if(_sname.compareTo("ccd_classic") == 0)
{
- specs = CCDSpecifications.instanse();
+ specs = CCDSpecifications.instance();
chscomp = new CCDChargeSpreadComputer();
chscomp.setBfield(_Bfield);
chscomp.setSensor(specs);
@@ -128,31 +131,45 @@
File cache = new File(home,fname);
if(cache.exists())
{
+ String rstr=null;
+ BufferedReader r=null;
table_created = true;
System.out.println("Found ChargeSpreadTable file "+cache.getAbsolutePath());
boolean pmatch = true;
- FileInputStream fins = new FileInputStream(cache);
- BufferedReader r = new BufferedReader(new InputStreamReader(fins));
- String rstr;
- if((rstr = readNextNonCommentLine(r)) != null)
+ FileInputStream fins = null;
+ try
+ {
+ fins = new FileInputStream(cache);
+ }
+ catch(FileNotFoundException e)
{
- String[] tokens = rstr.split("\\s+");
- int ntp = tokens.length;
- _tabDimPar = new int[ntp];
- for(int i=0; i<ntp; i++)
+ }
+ finally
+ {
+ }
+ if(fins != null)
+ {
+ r = new BufferedReader(new InputStreamReader(fins));
+ if((rstr = readNextNonCommentLine(r)) != null)
{
- try
- {
- int ival = Integer.parseInt(tokens[i],10);
- System.out.println("Read: "+ival);
- _tabDimPar[i]=ival;
- }
- catch(NumberFormatException e)
- {
- System.out.println("string: "+tokens[i]+" cannot be parsed to int!");
- }
- finally
+ String[] tokens = rstr.split("\\s+");
+ int ntp = tokens.length;
+ _tabDimPar = new int[ntp];
+ for(int i=0; i<ntp; i++)
{
+ try
+ {
+ int ival = Integer.parseInt(tokens[i],10);
+ System.out.println("Read: "+ival);
+ _tabDimPar[i]=ival;
+ }
+ catch(NumberFormatException e)
+ {
+ System.out.println("string: "+tokens[i]+" cannot be parsed to int!");
+ }
+ finally
+ {
+ }
}
}
}
@@ -262,10 +279,10 @@
else
{
System.out.println("Table file does not exist. Creating new table");
- cache.createNewFile();
- df.setFractionDigits(6);
+ df.setMaximumFractionDigits(6);
try
{
+ cache.createNewFile();
ofw = new FileWriter(cache);
ofw.write("// Charge Spread Table for sensor "+_sname+_suffix+"\n");
Date date = new Date();
@@ -283,7 +300,7 @@
double yps = senspcs[1];
double thickn = senspcs[2];
double dx = xps/NSPntsX;
- double dy = yps/NSPntsy;
+ double dy = yps/NSPntsY;
double dz = thickn/NDepths;
double xd = 0.;
double yd = 0.;
@@ -329,7 +346,7 @@
for(int j=0; j<nip; j++)
{
ys = j*dyi + dyi/2 - yps/2 + yof;
- for int k=0; k<nip; k++)
+ for(int k=0; k<nip; k++)
{
xs = k*dxi+dxi/2-xps/2+xof;
schf = schf + chscomp.getChargeFractionAt(xs,ys,xd,yd,zd);
@@ -379,33 +396,44 @@
private String readNextNonCommentLine(BufferedReader r)
{
boolean comfl = false;
- String readstr = r.readLine();
- if(readstr != null)
- {
- if(readstr.contains("/*")) comfl = true;
- while(comfl)
+ String readstr = null;
+ try
+ {
+ readstr = r.readLine();
+ if(readstr != null)
{
- readstr = r.readLine();
- if(readstr.contains("*/") comfl=false;
- if(!comfl) readstr = r.readLine();
- }
- if(readstr!= null)
- {
- int cind = readstr.indexOf("//");
- while (cind != -1)
+ if(readstr.contains("/*")) comfl = true;
+ while(comfl)
{
- if(cind > 0)
- {
- String clstr = readstr.substring(0,cind-1);
- readstr = clstr;
- }
- if(cind == 0)
+ readstr = r.readLine();
+ if(readstr.contains("*/")) comfl=false;
+ if(!comfl) readstr = r.readLine();
+ }
+ if(readstr!= null)
+ {
+ int cind = readstr.indexOf("//");
+ while (cind != -1)
{
- readstr = r.readLine();
- cind = readstr.indexOf("//");
- }
- }
- }
+ if(cind > 0)
+ {
+ String clstr = readstr.substring(0,cind-1);
+ readstr = clstr;
+ }
+ if(cind == 0)
+ {
+ readstr = r.readLine();
+ cind = readstr.indexOf("//");
+ }
+ }
+ }
+ }
+ }
+ catch(IOException e)
+ {
+ System.out.println("readNextNonCommentLine(): IOException caught: "+e.getMessage());
+ }
+ finally
+ {
}
return readstr;
}