1 package org.lcsim.util.loop;
2
3 import java.io.InputStream;
4
5 import org.lcsim.conditions.ConditionsConverter;
6 import org.lcsim.conditions.ConditionsManager;
7 import org.lcsim.conditions.ConditionsManager.ConditionsSetNotFoundException;
8 import org.lcsim.conditions.RawConditions;
9 import org.lcsim.geometry.Detector;
10 import org.lcsim.geometry.GeometryReader;
11
12
13
14
15
16
17 public class DetectorConditionsConverter implements ConditionsConverter<Detector>
18 {
19 public Detector getData(ConditionsManager manager, String name)
20 {
21 RawConditions conditions = manager.getRawConditions(name);
22 try
23 {
24 InputStream in = conditions.getInputStream();
25 GeometryReader reader = new GeometryReader();
26 Detector detector = reader.read(in);
27
28 return detector;
29 }
30 catch (Exception x)
31 {
32 throw new ConditionsSetNotFoundException("Error reading detector condition item '"+name+"' for detector '"+manager.getDetector()+"'",x);
33 }
34 }
35
36 public Class<Detector> getType()
37 {
38 return Detector.class;
39 }
40 }