lcsim/src/org/lcsim/recon/vertexing/pixsim
diff -u -r1.6 -r1.7
--- PixilatedSensorManager.java 3 Feb 2011 20:11:45 -0000 1.6
+++ PixilatedSensorManager.java 10 Feb 2011 22:30:32 -0000 1.7
@@ -21,7 +21,7 @@
* for each event (only sensors which have hits in them are created)
*
* @author Nick Sinev
- * @version $Id: PixilatedSensorManager.java,v 1.6 2011/02/03 20:11:45 jeremy Exp $
+ * @version $Id: PixilatedSensorManager.java,v 1.7 2011/02/10 22:30:32 sinev Exp $
*/
public class PixilatedSensorManager extends Driver
@@ -36,11 +36,23 @@
boolean digital = false;
static PixSimConstants cons = PixSimConstants.instance();
static final int MAXHTSPEV = 100000;
- static IlcOption ilcopt = IlcOption.NOMINAL;
- private static final double bunch_period = cons.BunchInterval;
+ static IlcOption ilcopt = IlcOption.NOMINAL;
+ static SensorOption sensopt = SensorOption.ClassicCCD;
+ static BasicHep3Vector Lor_corr_b = new BasicHep3Vector(0.,0.,0.);
+ static BasicHep3Vector Lor_corr_ep = new BasicHep3Vector(0.,0.,0.);
+ static BasicHep3Vector Lor_corr_em = new BasicHep3Vector(0.,0.,0.);
+ private static double bunch_period = cons.BunchInterval;
private static double thr_to_noise_ratio = 5.;
private static double adc_scale_bar = 25.;
private static double adc_scale_ec = 25.;
+ private static double pixdx=0.02;
+ private static double pixdy=0.02;
+ private static double pixdz=0.02;
+ private static double colledx=0.02;
+ private static double colledy=0.02;
+ private static double chdep=0.002;
+ private static int bc_per_cl = 30;
+ private static int cl_per_bc = 0;
private static int phys_bc = 0;
private static int time_window = 1;
private static int cluster_thr_barr = 8;
@@ -112,15 +124,21 @@
private static int[] opt_pixel_thr_barr = {4,3,4,1,1,1,1,1,1,4};
private static int[] opt_cluster_thr_ec = {8,6,8,1,1,1,1,1,1,8};
private static int[] opt_pixel_thr_ec = {4,3,4,1,1,1,1,1,1,4};
- private static double[] opt_lor_cor_b_x = {0.001,0.0065,0.001,0.001,0.0005,0.0005,0.0005,0.0003,0.0003,0.0003};
- private static double[] opt_lor_cor_b_y = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
- private static double[] opt_lor_cor_b_z = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
- private static double[] opt_lor_cor_ep_x = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
- private static double[] opt_lor_cor_ep_y = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
- private static double[] opt_lor_cor_ep_z = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
- private static double[] opt_lor_cor_em_x = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
- private static double[] opt_lor_cor_em_y = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
- private static double[] opt_lor_cor_em_z = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
+ private static int[] opt_bc_per_cl_n = {30,1,0,1,1,1,1,1,1,1};
+ private static int[] opt_cl_per_bc_n = {0,0,16,0,0,0,0,0,0,0};
+ private static int[] opt_bc_per_cl_c = {312,1,40,1,1,1,1,1,1,1};
+ private static int[] opt_cl_per_bc_c = {0,0,0,0,0,0,0,0,0,0};
+ private static int[] opt_tw_n = {1,1,1,1,1,1,1,1,1,1};
+ private static int[] opt_tw_c = {312,50,40,50,1,1,1,1,1,1};
+ private static double[] opt_Lor_corr_b_x = {0.001,0.0065,0.001,0.001,0.0005,0.0005,0.0005,0.0003,0.0003,0.0003};
+ private static double[] opt_Lor_corr_b_y = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
+ private static double[] opt_Lor_corr_b_z = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
+ private static double[] opt_Lor_corr_ep_x = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
+ private static double[] opt_Lor_corr_ep_y = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
+ private static double[] opt_Lor_corr_ep_z = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
+ private static double[] opt_Lor_corr_em_x = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
+ private static double[] opt_Lor_corr_em_y = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
+ private static double[] opt_Lor_corr_em_z = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
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 = {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};
@@ -135,7 +153,7 @@
{"CCD_20x20x20_B5_propagator.dat",
"Chronopix_20x20x20_hr_B5_Barr_propagator.dat",
"CCD_20x20x20_B5_propagator.dat",
- "CCD_20x20x20_B5_propagator.dat",
+ "Chronopix_20x20x16_B5_propagator.dat",
"Chronopix_8x8x20hr_B5_Barr_propagator.dat",
"Chronopix_12x12x20hr_B5_Barr_propagator.dat",
"Chronopix_16x16x20hr_B5_Barr_propagator.dat",
@@ -148,7 +166,7 @@
{"CCD_20x20x20_B5_EC_propagator.dat",
"Chronopix_20x20x20_hr_B5_EC_propagator.dat",
"CCD_20x20x20_B5_EC_propagator.dat",
- "CCD_20x20x20_B5_EC_propagator.dat",
+ "Chronopix_20x20x16_B5_EC_propagator.dat",
"Chronopix_8x8x20_B5_EC_propagator.dat",
"Chronopix_12x12x20_B5_EC_propagator.dat",
"Chronopix_16x16x20_B5_EC_propagator.dat",
@@ -159,9 +177,9 @@
private static String[] opt_ec_mi_prop_tname =
{"CCD_20x20x20_B5_EC_propagator.dat",
+ "Chronopix_20x20x20_B5_EC_propagator.dat",
"CCD_20x20x20_B5_EC_propagator.dat",
- "CCD_20x20x20_B5_EC_propagator.dat",
- "CCD_20x20x20_B5_EC_propagator.dat",
+ "Chronopix_20x20x16_B5_EC_propagator.dat",
"Chronopix_8x8x20_B5_EC_propagator.dat",
"Chronopix_12x12x20_B5_EC_propagator.dat",
"Chronopix_16x16x20_B5_EC_propagator.dat",
@@ -174,8 +192,8 @@
{"CCD_20x20x20_B5_res_bar.dat",
"Chronopix_20x20x20_hr_B5_res_bar.dat",
"CPCCD_20x20x20_B5_res_bar.dat",
+ "Chronopix_20x20x16_hr_B5_res_bar.dat",
"ShortColCCD_20x20x20_B5_res_bar.dat",
- "Chronopix_8x8x20hr_B5_res_bar.dat",
"Chronopix_12x12x20hr_B5_res_bar.dat",
"Chronopix_16x16x20hr_B5_res_bar.dat",
"Chronopix_8x8x12hr_B5_res_bar.dat",
@@ -187,8 +205,8 @@
{"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_8x8x20hr_B5_res_ec.dat",
"Chronopix_12x12x20hr_B5_res_ec.dat",
"Chronopix_16x16x20hr_B5_res_ec.dat",
"Chronopix_8x8x12hr_B5_res_ec.dat",
@@ -200,8 +218,8 @@
{"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_8x8x20hr_B5_res_ec.dat",
"Chronopix_12x12x20hr_B5_res_ec.dat",
"Chronopix_16x16x20hr_B5_res_ec.dat",
"Chronopix_8x8x12hr_B5_res_ec.dat",
@@ -260,11 +278,18 @@
public PixilatedSensorManager(SensorOption opt, boolean usetable)
{
+ this(IlcOption.NOMINAL,opt,usetable);
+ }
+
+ public PixilatedSensorManager(IlcOption iopt, SensorOption opt, boolean usetable)
+ {
+ ilcopt = iopt;
+ sensopt = opt;
if(opt == SensorOption.ClassicCCD) option = 0;
if(opt == SensorOption.Chrono20x20x20) option = 1;
if(opt == SensorOption.CPCCD) option = 2;
- if(opt == SensorOption.ShortColumnCCD) option = 3;
- if(opt == SensorOption.Chrono8x8x20) option = 4;
+ if(opt == SensorOption.Chrono20x20x16) option = 3;
+ if(opt == SensorOption.ShortColumnCCD) option = 4;
if(opt == SensorOption.Chrono12x12x20) option = 5;
if(opt == SensorOption.Chrono16x16x20) option = 6;
if(opt == SensorOption.Chrono8x8x12) option = 7;
@@ -278,9 +303,19 @@
// Setters
- public void setIlcOption(IlcOption opt) { ilcopt = opt; if(opt==IlcOption.CLIC) time_window=50; }
+ public void setIlcOption(IlcOption opt) { ilcopt = opt; setOptionVariables(); }
- public void setTimeWindow(int tw) { time_window=tw; }
+ public void setTimeWindow(int tw) { time_window=tw; }
+
+ public void setDimensions(double dx, double dy, double dz, double cedx, double cedy, double chd)
+ {
+ pixdx=dx;
+ pixdy=dy;
+ pixdz=dz;
+ colledx=cedx;
+ colledy=cedy;
+ chdep=chd;
+ }
public void includeElectronicsNoiseHits(boolean yes) { incl_el_noise=yes; }
@@ -318,6 +353,17 @@
public void setEndcapMinusElectronics(IPixelSensorElectronics el) { ecm_el=el; }
+ public void setMaxDeltaEEnergy(double e) { TrackSegmentSimulation.MAXDELTAE=e; }
+
+ public void setMinDeltaEEnergy(double e) { TrackSegmentSimulation.MINDELTAE=e; }
+
+ public void setLorentzCorrection(Hep3Vector cvb, Hep3Vector cvep, Hep3Vector cvem)
+ {
+ if(cvb != null ) Lor_corr_b.setV(cvb.x(),cvb.y(),cvb.z());
+ if(cvep != null ) Lor_corr_ep.setV(cvep.x(),cvep.y(),cvep.z());
+ if(cvem != null ) Lor_corr_em.setV(cvem.x(),cvem.y(),cvem.z());
+ }
+
public void useLocalPropagatorTables(boolean local)
{
prop_tab_barrel_local = local;
@@ -338,7 +384,7 @@
calibr_stat_b = stat;
rtab_name_bar = fname;
cal_res_bar=yes;
- read_rest_bar=false;
+ read_rest_bar=!yes;
}
public void calibrateEndcapResolution(boolean yes,int stat, String fnamepl, String fnamemi)
@@ -348,7 +394,7 @@
rtab_name_ec_pl = fnamepl;
rtab_name_ec_mi = fnamemi;
cal_res_ec=yes;
- read_rest_ec=false;
+ read_rest_ec=!yes;
}
public void calibrateEndcapResolution(boolean yes,int stat, String fname)
@@ -358,7 +404,7 @@
rtab_name_ec_pl = fname;
rtab_name_ec_mi = fname;
cal_res_ec=yes;
- read_rest_ec=false;
+ read_rest_ec=!yes;
if(!ec_pl_ec_mi_same_prop)
System.out.println("Warning!Propagators for plus and minus ec are different! Can't use same resolution table!");
}
@@ -426,6 +472,43 @@
return psecml;
}
+ public void printSettings()
+ {
+ System.out.print("Ilc option: "+ilcopt);
+ if(option != -1) System.out.println(" sensor option: "+sensopt);
+ else System.out.println("sensor option: undefined");
+ if(digital) System.out.println("Electronics has digital readout");
+ if(incl_el_noise) System.out.println("Fake hits created by electronics noise are processed");
+ if(!incl_el_noise) System.out.println("Fake hits created by electronics noise are discarded");
+ System.out.println("Barrel electronics is: "+bar_el.getName());
+ System.out.println("ADC scale for it is: "+bar_el.getADCScale());
+ System.out.println("Noise level is: "+bar_el.getNoiseLevel());
+ System.out.println("Lorentz corr. barrel x: "+Lor_corr_b.x()+" y: "+Lor_corr_b.y()+" z: "+Lor_corr_b.z());
+ System.out.println("Endcap+ electronics is: "+ecp_el.getName());
+ System.out.println("ADC scale for it is: "+ecp_el.getADCScale());
+ System.out.println("Noise level is: "+ecp_el.getNoiseLevel());
+ System.out.println("Lorentz corr. endcap+ x: "+Lor_corr_ep.x()+" y: "+Lor_corr_ep.y()+" z: "+Lor_corr_ep.z());
+ System.out.println("Endcap- electronics is: "+ecm_el.getName());
+ System.out.println("ADC scale for it is: "+ecm_el.getADCScale());
+ System.out.println("Noise level is: "+ecm_el.getNoiseLevel());
+ System.out.println("Lorentz corr. endcap- x: "+Lor_corr_em.x()+" y: "+Lor_corr_ep.y()+" z: "+Lor_corr_ep.z());
+ if(use_prop_tab_barrel)
+ {
+ if(prop_tab_barrel_local)
+ {
+ System.out.println("Barrel propagator uses table read from file "+bar_prop_tname+" in your local directory");
+ }
+ else
+ {
+ if(det != null)
+ System.out.println("Barrel propagator uses table read from file "+bar_prop_tname+" read from "
+ +det.getName()+" detector data base");
+ else
+ System.out.println("Barrel propagator uses table read from file "+bar_prop_tname+
+ " read from not yet known data base");
+ }
+ }
+ }
@@ -440,10 +523,10 @@
el.setADCScale(25.);
el.setNoiseLevel(enoise);
el.setADCSaturation(255);
- el.setBunchesPerClock(30); // this is about maximum clock image speed (100 KHz) for classic CCD - asuming 50MHz speed in R register
+ el.setBunchesPerClock(bc_per_cl); // 30 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);
+ el.setPixelThreshold(pixel_thr_barr);
bar_el = el;
ecp_el = el;
ecm_el = el;
@@ -455,43 +538,42 @@
}
if(option == 1)
{
- IPixelSensorElectronics el=null;
- if(!digital) el = new CCDElectronics();
- if(digital) el = new ChronoPixelElectronics(ilcopt);
- el.includeElectronicNoiseHits(incl_el_noise);
- if(digital)
- {
- el.setADCScale(enoise*thr_to_noise_ratio);
- el.setNoiseLevel(enoise);
- el.setADCSaturation(1);
- el.useCorrelatedDoubleSampling(false);
- }
- if(!digital)
- {
- el.setNoiseLevel(enoise);
- el.setADCSaturation(255);
- el.useCorrelatedDoubleSampling(true);
- }
- el.setBunchesPerClock(1);
- el.useCorrelatedDoubleSampling(false);
- bar_el = el;
- ecp_el = el;
- ecm_el = el;
if(!digital)
{
+ bar_el = new CCDElectronics();
bar_el.setADCScale(adc_scale_bar);
+ bar_el.setNoiseLevel(enoise);
+ bar_el.setADCSaturation(255);
bar_el.setPixelThreshold(pixel_thr_barr);
- ecp_el.setADCScale(adc_scale_ec);
- ecm_el.setADCScale(adc_scale_ec);
- ecp_el.setPixelThreshold(pixel_thr_ec);
- ecm_el.setPixelThreshold(pixel_thr_ec);
- opt_lor_cor_b_x[option]=0.00556;
+ bar_el.includeElectronicNoiseHits(incl_el_noise);
+ if(bc_per_cl != 0) bar_el.setBunchesPerClock(bc_per_cl);
+ else bar_el.setClocksPerBunch(cl_per_bc);
+ bar_el.useCorrelatedDoubleSampling(false);
+ if((pixel_thr_barr==pixel_thr_ec) && (Math.abs(adc_scale_bar-adc_scale_ec) < 0.01))
+ {
+ ecp_el = bar_el;
+ ecm_el = bar_el;
+ }
+ else
+ {
+ ecp_el = new CCDElectronics();
+ ecp_el.setADCScale(adc_scale_ec);
+ ecp_el.setPixelThreshold(pixel_thr_ec);
+ ecp_el.includeElectronicNoiseHits(incl_el_noise);
+ ecm_el=ecp_el;
+ }
+// opt_Lor_corr_b_x[option]=0.00556;
}
if(digital)
{
+ bar_el = new ChronoPixelElectronics(ilcopt);
bar_el.setPixelThreshold(1);
- ecp_el.setPixelThreshold(1);
- ecm_el.setPixelThreshold(1);
+ bar_el.setADCScale(enoise*thr_to_noise_ratio);
+ bar_el.setNoiseLevel(enoise);
+ bar_el.setADCSaturation(1);
+ bar_el.includeElectronicNoiseHits(incl_el_noise);
+ ecp_el=bar_el;
+ ecm_el=bar_el;
cluster_thr_barr=1;
cluster_thr_ec=1;
}
@@ -510,17 +592,96 @@
el.setADCSaturation(255);
el.useCorrelatedDoubleSampling(true);
el.setPixelThreshold(4);
- el.setClocksPerBunch(16); // 50 MHz image clock speed in column parallel CCD
+ if(cl_per_bc != 0) el.setClocksPerBunch(cl_per_bc); // 50 MHz image clock speed in column parallel CCD
+ else el.setBunchesPerClock(bc_per_cl);
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(option == 3)
+ {
+ if(!digital)
+ {
+ bar_el = new FastAnalogElectronics(ilcopt);
+ bar_el.setADCScale(adc_scale_bar);
+ bar_el.setNoiseLevel(enoise);
+ bar_el.setADCSaturation(255);
+ bar_el.setPixelThreshold(pixel_thr_barr);
+ bar_el.includeElectronicNoiseHits(incl_el_noise);
+ if(bc_per_cl != 0) bar_el.setBunchesPerClock(bc_per_cl);
+ else bar_el.setClocksPerBunch(cl_per_bc);
+ bar_el.useCorrelatedDoubleSampling(false);
+ if((pixel_thr_barr==pixel_thr_ec) && (Math.abs(adc_scale_bar-adc_scale_ec) < 0.01))
+ {
+ ecp_el = bar_el;
+ ecm_el = bar_el;
+ }
+ else
+ {
+ ecp_el = new FastAnalogElectronics(ilcopt);
+ ecp_el.setADCScale(adc_scale_ec);
+ ecp_el.setPixelThreshold(pixel_thr_ec);
+ ecp_el.includeElectronicNoiseHits(incl_el_noise);
+ ecm_el=ecp_el;
+ }
+// opt_Lor_corr_b_x[option]=0.00556;
+ }
+ if(digital)
+ {
+ bar_el = new ChronoPixelElectronics(ilcopt);
+ bar_el.setPixelThreshold(1);
+ bar_el.setADCScale(enoise*thr_to_noise_ratio);
+ bar_el.setNoiseLevel(enoise);
+ bar_el.setADCSaturation(1);
+ bar_el.includeElectronicNoiseHits(incl_el_noise);
+ ecp_el=bar_el;
+ ecm_el=bar_el;
+ cluster_thr_barr=1;
+ cluster_thr_ec=1;
+ }
+ bpcf = new PixelConfiguration(pixdx,pixdy,pixdz);
+ List<SensorRegion> collectors = new ArrayList<SensorRegion>();
+ List<SensorRegion> absorbers = new ArrayList<SensorRegion>();
+ List<SensorRegion> reflectors = new ArrayList<SensorRegion>();
+ SensorRegion ce = new SensorRegion();
+ ce.setBox(0.,0.,0.,colledx,colledy,chdep);
+ collectors.add(ce);
+ SensorRegion refl = new SensorRegion();
+ refl.setBoxLimits(-pixdx/2.,pixdx/2.,-pixdy/2.,pixdy/2.,pixdz-chdep,pixdz+chdep);
+ reflectors.add(refl);
+ SensorRegion ab = new SensorRegion();
+ ab.setBoxLimits(-pixdx/2.,pixdx/2.,-pixdy/2.,pixdy/2.,-chdep/2.,chdep/2.);
+ absorbers.add(ab);
+ bpcf.setCollectors(collectors);
+ bpcf.setAbsorbers(absorbers);
+ bpcf.setReflectors(reflectors);
+
+ bcpr = new CarrierPropagator(bpcf);
+ eppcf = new PixelConfiguration();
+ ecppr = new CarrierPropagator(eppcf);
+ ecmpr = ecppr;
+ ready = true;
+ }
+
+ if(option > 3) System.out.println("This sensor option is not implemented yet! ");
}
private void setOptionVariables()
{
+ if(ilcopt==IlcOption.SHORT_INT)
+ {
+ bunch_period = cons.BunchIntervalA;
+ }
+ if(ilcopt==IlcOption.LONG_INT)
+ {
+ bunch_period = cons.BunchIntervalB;
+ }
+ if(ilcopt==IlcOption.CLIC)
+ {
+ bunch_period = cons.BunchIntervalC;
+ time_window = 50;
+ }
if(option == -1) return;
prop_tab_barrel_local = opt_prop_tab_barrel_local[option];
prop_tab_ec_pl_local = opt_prop_tab_ec_pl_local[option];
@@ -539,6 +700,21 @@
pixel_thr_barr = opt_pixel_thr_barr[option];
pixel_thr_ec = opt_pixel_thr_ec[option];
digital = is_digital[option];
+ Lor_corr_b.setV(opt_Lor_corr_b_x[option],opt_Lor_corr_b_y[option],opt_Lor_corr_b_z[option]);
+ Lor_corr_ep.setV(opt_Lor_corr_ep_x[option],opt_Lor_corr_ep_y[option],opt_Lor_corr_ep_z[option]);
+ Lor_corr_em.setV(opt_Lor_corr_em_x[option],opt_Lor_corr_em_y[option],opt_Lor_corr_em_z[option]);
+ if(ilcopt != IlcOption.CLIC)
+ {
+ bc_per_cl = opt_bc_per_cl_n[option];
+ cl_per_bc = opt_cl_per_bc_n[option];
+ time_window = opt_tw_n[option];
+ }
+ if(ilcopt == IlcOption.CLIC)
+ {
+ bc_per_cl = opt_bc_per_cl_c[option];
+ cl_per_bc = opt_cl_per_bc_c[option];
+ time_window = opt_tw_c[option];
+ }
}
// driver process function
@@ -693,7 +869,6 @@
if(res_tab_barrel_local) eeb.readTable(rtab_name_bar);
else eeb.readTable(rtab_name_bar,det);
}
- BasicHep3Vector Lor_corr = new BasicHep3Vector(0.,0.,0.);
for(IDetectorElement de:vxbrels)
{
PixilatedSensor pse = new PixilatedSensor(de,bcpr,false);
@@ -701,8 +876,7 @@
pse.setErrorEstimate(eeb);
pse.setClusterThreshold(cluster_thr_barr);
pse.setTimeWindow(time_window);
- Lor_corr.setV(opt_lor_cor_b_x[option],opt_lor_cor_b_y[option],opt_lor_cor_b_z[option]);
- pse.setLorentzCorrection(Lor_corr);
+ pse.setLorentzCorrection(Lor_corr_b);
if(nbe==0 && cal_res_bar)
{
eeb.setTableParameters(11,11,11,0.,1.5,0.,1.5,1.5,6.5);
@@ -724,8 +898,7 @@
pse.setErrorEstimate(eeep);
pse.setClusterThreshold(cluster_thr_ec);
pse.setTimeWindow(time_window);
- Lor_corr.setV(opt_lor_cor_ep_x[option],opt_lor_cor_ep_y[option],opt_lor_cor_ep_z[option]);
- pse.setLorentzCorrection(Lor_corr);
+ pse.setLorentzCorrection(Lor_corr_ep);
if(nbc==0 && cal_res_ec)
{
eeep.setTableParameters(11,11,11,0.,1.5,0.,1.5,1.5,6.5);
@@ -748,8 +921,7 @@
pse.setErrorEstimate(eeem);
pse.setClusterThreshold(cluster_thr_ec);
pse.setTimeWindow(time_window);
- Lor_corr.setV(opt_lor_cor_em_x[option],opt_lor_cor_em_y[option],opt_lor_cor_em_z[option]);
- pse.setLorentzCorrection(Lor_corr);
+ pse.setLorentzCorrection(Lor_corr_em);
if(!ec_pl_ec_mi_same_prop)
{
if(!read_rest_ec)
@@ -919,9 +1091,13 @@
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 hirs, including noise hits
+ int tnrawhpe = 0; // total number of raw hits, including noise hits
+ int nmprbs=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();
@@ -932,10 +1108,14 @@
ebhits.add(ht);
rawhits.addAll(ht.getRawHits());
}
+ }
+ nmprbs++;
}
// System.out.println("Barrel hits processed!");
for(PixilatedSensor psn:psecpl)
{
+ if((psn.getHits().size() > 0) || incl_el_noise)
+ {
psn.processEvent(phys_bc);
IDetectorElement de = psn.getParent();
IReadout ro = de.getReadout();
@@ -946,10 +1126,13 @@
eehits.add(ht);
rawhits.addAll(ht.getRawHits());
}
+ }
}
// System.out.println("Endcap plus hits processed!");
for(PixilatedSensor psn:psecml)
{
+ if((psn.getHits().size() > 0) || incl_el_noise)
+ {
psn.processEvent(phys_bc);
IDetectorElement de = psn.getParent();
IReadout ro = de.getReadout();
@@ -960,6 +1143,7 @@
eehits.add(ht);
rawhits.addAll(ht.getRawHits());
}
+ }
}
// System.out.println("Endcap minus hits processed!");
// System.out.println("Adding "+ebhits.size()+" hits to RecVtxBarrHits collection");
lcsim/src/org/lcsim/recon/vertexing/pixsim
diff -u -r1.1 -r1.2
--- TabulatedFieldMap.java 9 Dec 2008 23:36:34 -0000 1.1
+++ TabulatedFieldMap.java 10 Feb 2011 22:30:32 -0000 1.2
@@ -13,30 +13,41 @@
* @author Nick Sinev
*/
-public class TabulatedFieldMap implements NamedFieldMap
+public class TabulatedFieldMap implements NamedFieldMap
{
- String name = null;
+ SpecialTextFileReader freader = SpecialTextFileReader.instance();
+ String name = "unnamed";
boolean initialized = false;
- double[][][] fx = null;
- double[][][] fy = null;
- double[][][] fz = null;
+ boolean do_interp = true;
+ double[][][] gfldx = null;
+ double[][][] gfldy = null;
+ double[][][] gfldz = null;
BasicHep3Vector field = new BasicHep3Vector(0.,0.,0.);
- int nx=0;
- int ny=0;
- int nz=0;
- double stx = 0.;
- double sty = 0.;
- double stz = 0.;
- double x0 = 0.;
- double y0 = 0.;
- double z0 = 0.;
+ int gpnx=0;
+ int gpny=0;
+ int gpnz=0;
+ double grdstx = 0.;
+ double grdsty = 0.;
+ double grdstz = 0.;
+ double gx0 = 0.;
+ double gy0 = 0.;
+ double gz0 = 0.;
+ double xmin = 0.;
+ double ymin = 0.;
+ double zmin = 0.;
+ double xmax = 0.;
+ double ymax = 0.;
+ double zmax = 0.;
+ boolean map_read = false;
+ int dbg_lvl=0;
+ final double tcad_dtol = 1.E-16;
public TabulatedFieldMap()
{
}
- public TabulatedFieldMap(String path)
+ public TabulatedFieldMap(String path) throws IOException
{
File cache;
cache = new File(path);
@@ -56,28 +67,35 @@
if(cache.exists())
{
name=cache.getName();
- readMap(cache);
+ initialized=readMap(cache);
}
}
}
}
- public void readMap(File file)
+/**
+* Set wether to do interpolation for field value.
+* @param yes - <code>boolean</code> flag. If this flag set to false, the returned field value
+* will be taken directly from nearest grid point. In that case field as function
+* of coordinates will not be a smooth function.
+*
+*/
+ public void setDoInterpolation( boolean yes)
{
- String rstr;
- int indx = 0;
- int indy = 0;
- int indz = 0;
- double mszx = 0.;
- double mszy = 0.;
- double mszz = 0.;
- double[] rdvals = new double[5];
- int[] rivals = new int[5];
- int nv;
+ do_interp=yes;
+ }
+
+ public boolean readMap(File cache) throws IOException
+ {
+ if(cache.exists())
+ {
+ String rstr=null;
+ BufferedReader r=null;
+ System.out.println("Found field map file "+cache.getAbsolutePath());
FileInputStream fins = null;
try
{
- fins = new FileInputStream(file);
+ fins = new FileInputStream(cache);
}
catch(FileNotFoundException e)
{
@@ -87,32 +105,194 @@
}
if(fins != null)
{
- BufferedReader r = new BufferedReader(new InputStreamReader(fins));
- rstr=readNextNonCommentLine(r);
- if(rstr !=null)
+ r = new BufferedReader(new InputStreamReader(fins));
+ if((rstr = freader.readNextNonCommentLine(r)) != null)
{
- nv = getDoubleValues(rstr,rdvals);
- if(nv!=3) System.out.println("Error in field file header! number of pixel dimensions != 3");
- if(nv==3)
+ String[] tokens = rstr.split("\\s+");
+ int ntp = tokens.length;
+ if(ntp < 3)
+ {
+ System.out.println("Error in table header. Number of grid indexes less than 3");
+ map_read=false;
+ return map_read;
+ }
+ int[] tpar = new int[ntp];
+ int np=0;
+ for(int i=0; i<ntp; i++)
{
- mszx=rdvals[0];
- mszy=rdvals[1];
- mszz=rdvals[2];
+ try
+ {
+ int ival = Integer.parseInt(tokens[i]);
+ tpar[np]=ival;
+ np++;
+ }
+ catch(NumberFormatException e)
+ {
+ System.out.println("Error in table header - integer values are not integer");
+ map_read=false;
+ return map_read;
+ }
+ finally
+ {
+ }
}
+ gpnx=tpar[0];
+ gpny=tpar[1];
+ gpnz=tpar[2];
+ int tnsmp=gpnx*gpny*gpnz;
+ if(dbg_lvl > 0) System.out.println(
+ "Table made from "+tnsmp+" samples = "+gpnx+" x "+gpny+" x "+gpnz+" space pnts");
}
- rstr=readNextNonCommentLine(r);
- if(rstr !=null)
+ gfldx = new double[gpnx][gpny][gpnz];
+ gfldy = new double[gpnx][gpny][gpnz];
+ gfldz = new double[gpnx][gpny][gpnz];
+ if((rstr = freader.readNextNonCommentLine(r)) != null)
{
- nv = getIntValues(rstr,rivals);
- if(nv!=3) System.out.println("Error in field file header! number of grid dimensions != 3");
- if(nv==3)
+ String[] tokens = rstr.split("\\s+");
+ int ntp = tokens.length;
+ if(ntp < 6)
+ {
+ System.out.println("Error in table header. Number of recorded limits < 6");
+ map_read = false;
+ return map_read;
+ }
+ double[] tpar = new double[ntp];
+ int np=0;
+ for(int i=0; i<ntp; i++)
{
- nx=rivals[0];
- ny=rivals[1];
- nz=rivals[2];
+ try
+ {
+ double dval = Double.parseDouble(tokens[i]);
+ tpar[np]=dval;
+ np++;
+ }
+ catch(NumberFormatException e)
+ {
+ System.out.println("Error in table header - wrong format for limits");
+ map_read=false;
+ return map_read;
+ }
+ finally
+ {
+ }
}
- }
+ gx0=tpar[0];
+ gy0=tpar[1];
+ gz0=tpar[2];
+ grdstx=tpar[3];
+ grdsty=tpar[4];
+ grdstz=tpar[5];
+// if(dbg_lvl > 0) System.out.println("x0 "+gx0+" y0 "+gy0+" z0 "+gz0+" stx "+grdstx+" sty "+grdsty+" stz "+grdstz);
+ xmin = gx0;
+ ymin = gy0;
+ zmin = gz0;
+ xmax = xmin + grdstx*(gpnx-1);
+ ymax = ymin + grdsty*(gpny-1);
+ zmax = zmin + grdstz*(gpnz-1);
+ }
+ boolean done = false;
+ int ix=0;
+ int iy=0;
+ int iz=0;
+ int np=0;
+ while(((rstr = freader.readNextNonCommentLine(r)) != null)&& (!done))
+ {
+ String[] tokens = rstr.split("\\s+");
+ int ntp = tokens.length;
+ if(ntp < 3) System.out.println("Error in table format: expected 3 values in line, read: "+ntp);
+ np=0;
+ for(int i=0; i<ntp; i++)
+ {
+ try
+ {
+ double val = Double.parseDouble(tokens[i]);
+ if(np==0) gfldx[ix][iy][iz]=val;
+ if(np==1) gfldy[ix][iy][iz]=val;
+ if(np==2) gfldz[ix][iy][iz]=val;
+ if(np>2)
+ {
+ System.out.println("Error in file records format: more than 3 values in one line");
+ map_read = false;
+ return map_read;
+ }
+ np++;
+ if(np>2) iz++;
+ if(iz == gpnz)
+ {
+ iz=0;
+ iy++;
+ if(iy == gpny)
+ {
+ iy=0;
+ ix++;
+ if(ix == gpnx) { done=true; map_read=true; }
+ }
+ }
+ }
+ catch(NumberFormatException e)
+ {
+ System.out.println("Error in file records format: values are not double ");
+ map_read=false;
+ return map_read;
+ }
+ finally
+ {
+ }
+ } // end of for loop
+ } // end of while loop
+ } // end of if(fins!=null) clouse
+ } // end of if(cashe.exist()) clouse
+// if(dbg_lvl > 1) System.out.println("First fx values: "+gfldx[0][0][0]+" "+gfldx[0][0][1]+" "+gfldx[0][0][2]);
+ return map_read;
+ } // end of function readMap()
+
+/**
+* Read back limits of area where field was defined
+* (useful after reading map with unknown limits)
+* Returns spatial limits of mapped area in the form
+* of 6-dimensional double array:
+* xmin,xmax,ymin,ymax,zmin,zmax
+* @return <code>double[]</code> array of map limits
+*
+*/
+ public double[] getMapLimits()
+ {
+ double[] limits = new double[6];
+ limits[0]=xmin;
+ limits[1]=xmax;
+ limits[2]=ymin;
+ limits[3]=ymax;
+ limits[4]=zmin;
+ limits[5]=zmax;
+ return limits;
+ }
+/*
+ private int getDoublesFromString(String str, double[] buf)
+ {
+ int blen = buf.length;
+ int nv = 0;
+ int inofb = str.indexOf("}");
+ String clstr =str;
+ if(inofb !=-1) clstr = str.substring(0,inofb);
+ String[] tokens = clstr.split("\\s+");
+ int ntp = tokens.length;
+ for(int i=0; i<ntp; i++)
+ {
+ try
+ {
+ double dval = Double.parseDouble(tokens[i]);
+ if(nv<blen)
+ buf[nv]=dval;
+ nv++;
+ }
+ catch(NumberFormatException e)
+ {
}
+ finally
+ {
+ }
+ }
+ return nv;
}
private int getDoubleValues(String rstr, double[] values)
@@ -158,18 +338,17 @@
}
return vtn;
}
-
+*/
public String getName() { return name; }
- /** Get the field magnitude and direction at a particular point.
- * @param position The position at which the field is requested
- * @param b The field (the object is passed by reference and set to the correct field)
- */
+/**
+* Get the field magnitude and direction at a particular point.
+* @param position <code>double[]</code> The position at which the field is requested
+* @param b <code>double[]</code> Array to put result (field) in
+*/
public void getField(double[] position, double[] b)
{
- b[0]=field.x();
- b[1]=field.y();
- b[2]=field.z();
+ getInterpolation(position,b);
}
/**
@@ -195,11 +374,14 @@
*/
public Hep3Vector getField(Hep3Vector position, BasicHep3Vector fld)
{
+ double[] pos=position.v();
if(fld == null)
{
fld = new BasicHep3Vector(0.,0.,0.);
}
- fld.setV(field.x(),field.y(),field.z());
+ double[] b=new double[3];
+ getField(pos,b);
+ fld.setV(b[0],b[1],b[2]);
return fld;
}
/**
@@ -254,6 +436,71 @@
{
}
return readstr;
+ }
+
+ private void getInterpolation(double[] position, double[] b)
+ {
+ b[0]=0.;
+ b[1]=0.;
+ b[2]=0.;
+ double x = position[0]+tcad_dtol;
+ double y = position[1]+tcad_dtol;
+ double z = position[2]+tcad_dtol;
+ if((x<xmin-grdstx/2.) || (x>xmax+grdstx/2.) || (y<ymin-grdsty/2.) || (y>ymax+grdsty/2.) || (z<zmin-grdstz/2.) || (z>zmax+grdstz/2.)) return;
+ if(!initialized) return;
+ int xi = (int) Math.floor((x-gx0)/grdstx);
+ int yi = (int) Math.floor((y-gy0)/grdsty);
+ int zi = (int) Math.floor((z-gz0)/grdstz);
+ double ddx = x-gx0 - grdstx*xi;
+ double ddy = y-gy0 - grdsty*yi;
+ double ddz = z-gz0 - grdstz*zi;
+ while(xi<0) xi+=(gpnx-1);
+ while(yi<0) yi+=(gpny-1);
+ while(zi<0) zi+=(gpnz-1);
+ while(xi>gpnx-2) xi-=(gpnx-1);
+ while(yi>gpny-2) yi-=(gpny-1);
+ while(zi>gpnz-2) zi-=(gpnz-1);
+ if(!do_interp)
+ {
+ b[0]=gfldx[xi][yi][zi];
+ b[1]=gfldy[xi][yi][zi];
+ b[2]=gfldz[xi][yi][zi];
+ return;
}
+ double qx = ddx/grdstx;
+ double qy = ddy/grdsty;
+ double qz = ddz/grdstz;
+ double px = 1.-qx;
+ double py = 1.-qy;
+ double pz = 1.-qz;
+ double fx0=gfldx[xi][yi][zi];
+ double fy0=gfldy[xi][yi][zi];
+ double fz0=gfldz[xi][yi][zi];
+ double fx1=gfldx[xi+1][yi][zi];
+ double fy1=gfldy[xi+1][yi][zi];
+ double fz1=gfldz[xi+1][yi][zi];
+ double fx2=gfldx[xi][yi+1][zi];
+ double fy2=gfldy[xi][yi+1][zi];
+ double fz2=gfldz[xi][yi+1][zi];
+ double fx3=gfldx[xi+1][yi+1][zi];
+ double fy3=gfldy[xi+1][yi+1][zi];
+ double fz3=gfldz[xi+1][yi+1][zi];
+ double fx4=gfldx[xi][yi][zi+1];
+ double fy4=gfldy[xi][yi][zi+1];
+ double fz4=gfldz[xi][yi][zi+1];
+ double fx5=gfldx[xi+1][yi][zi+1];
+ double fy5=gfldy[xi+1][yi][zi+1];
+ double fz5=gfldz[xi+1][yi][zi+1];
+ double fx6=gfldx[xi][yi+1][zi+1];
+ double fy6=gfldy[xi][yi+1][zi+1];
+ double fz6=gfldz[xi][yi+1][zi+1];
+ double fx7=gfldx[xi+1][yi+1][zi+1];
+ double fy7=gfldy[xi+1][yi+1][zi+1];
+ double fz7=gfldz[xi+1][yi+1][zi+1];
+ b[0] = ((fx0*px+fx1*qx)*py+(fx2*px+fx3*qx)*qy)*pz+((fx4*px+fx5*qx)*py+(fx6*px+fx7*qx)*qy)*qz;
+ b[1] = ((fy0*px+fy1*qx)*py+(fy2*px+fy3*qx)*qy)*pz+((fy4*px+fy5*qx)*py+(fy6*px+fy7*qx)*qy)*qz;
+ b[2] = ((fz0*px+fz1*qx)*py+(fz2*px+fz3*qx)*qy)*pz+((fz4*px+fz5*qx)*py+(fz6*px+fz7*qx)*qy)*qz;
+ return;
+ }
}