1 package org.lcsim.geometry.compact.converter;
2
3 import java.util.ArrayList;
4
5 import org.jdom.DataConversionException;
6 import org.jdom.Element;
7 import org.jdom.JDOMException;
8
9
10
11 public class SiTrackerModuleParameters
12 extends ArrayList<SiTrackerModuleComponentParameters>
13 {
14 double thickness=0.;
15 String name;
16 double dimensions[] = new double[3];
17 String vis;
18
19 public SiTrackerModuleParameters(Element element)
20 {
21 name = element.getAttributeValue("name");
22
23 if (element.getAttribute("vis") != null)
24 this.vis = element.getAttribute("vis").getValue();
25
26 int cntr=0;
27 for (Object o : element.getChildren("module_component"))
28 {
29 try {
30
31 Element e = (Element)o;
32
33 double thickness = e.getAttribute("thickness").getDoubleValue();
34
35 String materialName = e.getAttributeValue("material");
36
37 boolean sensitive = false;
38 if (e.getAttribute("sensitive") != null)
39 sensitive = e.getAttribute("sensitive").getBooleanValue();
40 String componentVis = null;
41 if (e.getAttribute("vis") != null)
42 componentVis = e.getAttribute("vis").getValue();
43 add(new SiTrackerModuleComponentParameters(thickness, materialName, cntr, sensitive, componentVis));
44 }
45 catch (JDOMException x)
46 {
47 throw new RuntimeException(x);
48 }
49 ++cntr;
50 }
51
52
53 if (element.getChild("trd") != null)
54 {
55 Element trd = element.getChild("trd");
56 try
57 {
58 dimensions[0] = trd.getAttribute("x1").getDoubleValue();
59 dimensions[1] = trd.getAttribute("x2").getDoubleValue();
60 dimensions[2] = trd.getAttribute("z").getDoubleValue();
61 }
62 catch (DataConversionException x)
63 {
64 throw new RuntimeException(x);
65 }
66 }
67
68 calculateThickness();
69 }
70
71 public void calculateThickness()
72 {
73 thickness = 0.;
74 for (SiTrackerModuleComponentParameters p : this)
75 {
76 thickness += p.getThickness();
77 }
78 }
79
80 public double getThickness()
81 {
82 return thickness;
83 }
84
85 public String getName()
86 {
87 return name;
88 }
89
90 public double getDimension(int i)
91 {
92 if (i > (dimensions.length - 1) || i < 0)
93 throw new RuntimeException("Invalid dimensions index: " + i);
94 return dimensions[i];
95 }
96
97 public String getVis()
98 {
99 return vis;
100 }
101 }