1 package org.lcsim.recon.tracking.seedtracker.trackingdrivers.sidloi2;
2
3 import hep.physics.matrix.BasicMatrix;
4 import hep.physics.vec.BasicHep3Vector;
5 import hep.physics.vec.VecOp;
6
7 import java.util.List;
8
9 import org.lcsim.detector.IDetectorElement;
10 import org.lcsim.detector.IRotation3D;
11 import org.lcsim.detector.ITranslation3D;
12 import org.lcsim.detector.RotationPassiveXYZ;
13 import org.lcsim.detector.Transform3D;
14 import org.lcsim.detector.Translation3D;
15 import org.lcsim.detector.solids.IPolyhedron;
16 import org.lcsim.detector.solids.Polygon3D;
17 import org.lcsim.detector.tracker.silicon.ChargeCarrier;
18 import org.lcsim.detector.tracker.silicon.SiSensor;
19 import org.lcsim.detector.tracker.silicon.SiSensorElectrodes;
20 import org.lcsim.detector.tracker.silicon.SiStrips;
21 import org.lcsim.geometry.Detector;
22 import org.lcsim.geometry.compact.Subdetector;
23 import org.lcsim.geometry.subdetector.SiTrackerBarrel;
24 import org.lcsim.util.Driver;
25
26 public class SiTrackerBarrelSensorSetup extends Driver
27 {
28 String subdetectorName;
29
30 double readoutElectrodesPitch = 0.050;
31 double senseElectrodesPitch = 0.025;
32 double transferEfficiencies[] = {0.986,0.419};
33
34 public SiTrackerBarrelSensorSetup()
35 {}
36
37 public SiTrackerBarrelSensorSetup(String subdetectorName)
38 {
39 this.subdetectorName = subdetectorName;
40 }
41
42 public void setSubdetectorName(String subdetectorName)
43 {
44 this.subdetectorName = subdetectorName;
45 }
46
47 public void detectorChanged(Detector detector)
48 {
49 if (subdetectorName == null)
50 throw new RuntimeException("The subdetectorName was not set.");
51
52 Subdetector subdetector = detector.getSubdetector(subdetectorName);
53 if (subdetector instanceof SiTrackerBarrel)
54 setupSensorDetectorElements(subdetector);
55 else
56 throw new RuntimeException("The subdetector " + subdetectorName + " is not an instance of SiTrackerBarrel.");
57 }
58
59 public void setReadoutElectrodesPitch(double readoutElectrodesPitch)
60 {
61 this.readoutElectrodesPitch = readoutElectrodesPitch;
62 }
63
64 public void setSenseElectrodesPitch(double senseElectrodesPitch)
65 {
66 this.senseElectrodesPitch = senseElectrodesPitch;
67 }
68
69 public void setTransferEfficiencies(double transferEfficiencies[])
70 {
71 if (transferEfficiencies.length < 2)
72 {
73 throw new IllegalArgumentException("Not enough values in transferEfficiencies array.");
74 }
75 this.transferEfficiencies[0] = transferEfficiencies[0];
76 this.transferEfficiencies[1] = transferEfficiencies[1];
77 }
78
79 private void setupSensorDetectorElements(Subdetector subdet)
80 {
81 for ( IDetectorElement layer : subdet.getDetectorElement().getChildren() )
82 {
83 for ( IDetectorElement module : layer.getChildren() )
84 {
85 List<SiSensor> sensors = module.findDescendants(SiSensor.class);
86
87 if (sensors.size() == 0)
88 throw new RuntimeException("No sensors found in module " + module.getName() + ".");
89
90 SiSensor sensor = sensors.get(0);
91
92
93 IPolyhedron sensor_solid = (IPolyhedron)sensor.getGeometry().getLogicalVolume().getSolid();
94
95
96 Polygon3D top_side = sensor_solid.getFacesNormalTo(new BasicHep3Vector(0,0,1)).get(0);
97 Polygon3D bot_side = sensor_solid.getFacesNormalTo(new BasicHep3Vector(0,0,-1)).get(0);
98
99 sensor.setBiasSurface(ChargeCarrier.HOLE,top_side);
100 sensor.setBiasSurface(ChargeCarrier.ELECTRON,bot_side);
101
102
103 ITranslation3D electrodes_position = new Translation3D(VecOp.mult(-top_side.getDistance(),top_side.getNormal()));
104 IRotation3D electrodes_rotation = new RotationPassiveXYZ(0.0,0.0,0.0);
105 Transform3D electrodes_transform = new Transform3D(electrodes_position, electrodes_rotation);
106
107
108 SiSensorElectrodes readout_electrodes = new SiStrips(ChargeCarrier.HOLE,this.readoutElectrodesPitch,sensor,electrodes_transform);
109 SiSensorElectrodes sense_electrodes = new SiStrips(ChargeCarrier.HOLE,senseElectrodesPitch,(readout_electrodes.getNCells()*2-1),sensor,electrodes_transform);
110
111 sensor.setSenseElectrodes(sense_electrodes);
112 sensor.setReadoutElectrodes(readout_electrodes);
113
114 double[][] transferEfficienciesMatrix = { transferEfficiencies };
115 sensor.setTransferEfficiencies(ChargeCarrier.HOLE,new BasicMatrix(transferEfficienciesMatrix));
116 }
117 }
118 }
119 }