View Javadoc

1   package org.lcsim.recon.tracking.digitization.sisim.config;
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.SiPixels;
19  import org.lcsim.detector.tracker.silicon.SiSensor;
20  import org.lcsim.detector.tracker.silicon.SiSensorElectrodes;
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 SiVertexBarrelSensorSetup extends Driver
27  {
28  	String subdetectorName;
29  	
30      // Sets pixel size to x=0.05 and y=0.25 (mm)
31  	double readoutPitchX = 0.05;
32  	double readoutPitchY = 0.25;
33  	double sensePitchX = 0.05;
34  	double sensePitchY = 0.25;
35  	double transferEfficiency = 1.0;
36  
37  	public SiVertexBarrelSensorSetup()
38  	{}
39  	
40  	public SiVertexBarrelSensorSetup(String subdetectorName)
41  	{
42  		this.subdetectorName = subdetectorName;
43  	}
44  	
45  	public void setSubdetectorName(String subdetectorName)
46  	{
47  		this.subdetectorName = subdetectorName;
48  	}
49  	
50  	public void detectorChanged(Detector detector)
51  	{
52  		if (subdetectorName == null)
53  			throw new RuntimeException("The subdetectorName was not set.");
54  		
55  		Subdetector subdetector = detector.getSubdetector(subdetectorName);
56  		if (subdetector instanceof SiTrackerBarrel)
57  			setupSensorDetectorElements(subdetector);
58  		else
59  			throw new RuntimeException("The subdetector " + subdetectorName + " is not an instance of SiTrackerBarrel.");
60  	}
61  	
62  	public void setReadoutPitchX(double x)
63  	{
64  		this.readoutPitchX = x;
65  	}
66  	
67  	public void setReadoutPitchY(double y)
68  	{
69  		this.readoutPitchY = y;
70  	}
71  	
72  	public void setSensePitchX(double x)
73  	{
74  		this.sensePitchX = x;
75  	}
76  	
77  	public void setSensePitchY(double y)
78  	{
79  		this.sensePitchY = y;
80  	}
81  	
82  	public void setTransferEfficiency(double t)
83  	{
84  		this.transferEfficiency = t;
85  	}
86  	
87  	private void setupSensorDetectorElements(Subdetector subdet)
88  	{		
89  		for ( IDetectorElement layer : subdet.getDetectorElement().getChildren() )
90  		{
91  			for ( IDetectorElement module : layer.getChildren() )
92  			{
93  					List<SiSensor> sensors = module.findDescendants(SiSensor.class);
94  
95  					if (sensors.size() == 0)
96  						throw new RuntimeException("No sensors found in module " + module.getName() + ".");
97  
98  					SiSensor sensor = sensors.get(0);
99  					IPolyhedron sensor_solid = (IPolyhedron) sensor.getGeometry().getLogicalVolume().getSolid();
100 					
101                     Polygon3D top_side = sensor_solid.getFacesNormalTo(new BasicHep3Vector(0, 0, 1)).get(0);
102                     Polygon3D bot_side = sensor_solid.getFacesNormalTo(new BasicHep3Vector(0, 0, -1)).get(0);
103                    
104                     // collect electrons on the top side
105                     sensor.setBiasSurface(ChargeCarrier.HOLE, bot_side);
106                     sensor.setBiasSurface(ChargeCarrier.ELECTRON, top_side);
107 
108                     // Add sense and readout electrodes
109                     ITranslation3D electrodes_position = new Translation3D(VecOp.mult(-top_side.getDistance(), top_side.getNormal()));  // translate to p_side
110                     IRotation3D electrodes_rotation = new RotationPassiveXYZ(0.0, 0.0, 0.0);                     
111                     // no rotation (global x-y = local x-y for axial strips)
112 
113                     Transform3D electrodes_transform = new Transform3D(electrodes_position, electrodes_rotation);
114 
115                     //  Define the pixel electrodes...collecting holes;
116                     SiSensorElectrodes readout_electrodes = new SiPixels(ChargeCarrier.ELECTRON, this.readoutPitchX, this.readoutPitchY, sensor, electrodes_transform);
117                     SiSensorElectrodes sense_electrodes = new SiPixels(ChargeCarrier.ELECTRON, this.sensePitchX, this.sensePitchY, sensor, electrodes_transform);
118 
119                     //  Tell the sensor about the electrodes
120                     sensor.setSenseElectrodes(sense_electrodes);
121                     sensor.setReadoutElectrodes(readout_electrodes);
122 
123                     //  Define the transfer efficiency from sense electrodes to readout electrodes
124                     //  For pixels, we do a direct transfer of charge from sense electrodes to readout electrodes
125                     double[][] transfer_efficiencies = {{this.transferEfficiency}};
126                     sensor.setTransferEfficiencies(ChargeCarrier.ELECTRON, new BasicMatrix(transfer_efficiencies));
127 			}
128 		}
129 	}
130 }