View Javadoc

1   /*
2    * GridXYZ.java
3    *
4    * Created on May 27, 2005, 4:34 PM
5    */
6   
7   package org.lcsim.geometry.compact.converter.lcdd;
8   
9   import org.jdom.DataConversionException;
10  import org.jdom.JDOMException;
11  import org.jdom.Element;
12  import org.jdom.Attribute;
13  import org.lcsim.geometry.compact.converter.lcdd.util.Calorimeter;
14  
15  /**
16   *
17   * @author jeremym
18   */
19  public class GridXYZ extends LCDDSegmentation 
20  {
21  	private double gridSizeX;
22  	private double gridSizeY;
23  	private double gridSizeZ;
24  
25  	/** Creates a new instance of GridXYZ */
26  	public GridXYZ(Element node) throws DataConversionException, JDOMException 
27  	{
28  		super(node);
29  
30  		boolean gotOne = false;
31  
32  		Attribute attrib = node.getAttribute("gridSizeX");
33  
34  		if ( attrib != null )
35  		{
36  			gotOne = true;
37  			gridSizeX = attrib.getDoubleValue();
38  		}
39  		else
40  		{
41  			gridSizeX = 0;
42  		}
43  
44  		attrib = node.getAttribute("gridSizeY");
45  
46  		if ( attrib != null )
47  		{
48  			gotOne = true;
49  			gridSizeY = attrib.getDoubleValue();
50  		}
51  		else
52  		{
53  			gridSizeY = 0;
54  		}
55  
56  		attrib = node.getAttribute("gridSizeZ");
57  
58  		if ( attrib != null )
59  		{
60  			gotOne = true;
61  			gridSizeZ = attrib.getDoubleValue();
62  		}
63  		else
64  		{
65  			gridSizeZ = 0;
66  		}
67  
68  		if ( !gotOne )
69  		{
70  			throw new JDOMException("Missing one of required attributes gridSizeX / Y / Z.");
71  		}
72  	}
73  
74  	void setSegmentation(Calorimeter cal)
75  	{
76  		org.lcsim.geometry.compact.converter.lcdd.util.GridXYZ g =
77  			new org.lcsim.geometry.compact.converter.lcdd.util.GridXYZ();
78  
79  		g.setGridSizeX(gridSizeX);
80  		g.setGridSizeY(gridSizeY);
81  		g.setGridSizeZ(gridSizeZ);
82  
83  		cal.setSegmentation(g);
84  	}
85  
86  }