View Javadoc

1   package org.lcsim.detector;
2   
3   public class SubdetectorType 
4   {
5   	SystemType systemType = SystemType.UNKNOWN;
6   	BarrelType barrelType = BarrelType.UNKNOWN;
7   	GenericType genericType = GenericType.UNKNOWN;
8   	
9   	SubdetectorType(SystemType systemType, BarrelType barrelType)
10  	{
11  		this.systemType = systemType;
12  		this.barrelType = barrelType;
13  		if (systemType == SystemType.VERTEX_DETECTOR || systemType == SystemType.SILICON_TRACKER || systemType == SystemType.TPC)
14  			genericType = GenericType.TRACKER;
15  		else if (systemType == SystemType.ECAL || systemType == SystemType.HCAL || systemType == SystemType.MUON || systemType == SystemType.FORWARD)
16  			genericType = GenericType.CALORIMETER;
17  	}
18  	
19  	public enum GenericType
20  	{
21  		TRACKER,
22  		CALORIMETER,
23  		UNKNOWN
24  	}
25  		
26  	public enum SystemType
27  	{
28  		VERTEX_DETECTOR,
29  	    SILICON_TRACKER,
30  	    TPC,
31  	    ECAL,
32  	    HCAL,
33  	    MUON,
34  	    FORWARD,
35  	    UNKNOWN
36  	}
37  		
38  	public enum BarrelType
39  	{
40  		BARREL,
41  		ENDCAP,
42  		UNKNOWN
43  	}
44  		
45  	public SystemType getSystemType()
46  	{
47  		return systemType;
48  	}
49  	
50  	public BarrelType getBarrelType()
51  	{
52  		return barrelType;
53  	}
54  	
55  	public GenericType getGenericType()
56  	{
57  		return genericType;
58  	}
59  	
60  	/** 
61  	 * FIXME: This is rather fragile as it depends on names in the compact description 
62  	 * which may not follow these conventions.
63  	 */ 
64  	public static SubdetectorType convert(String subdetectorName)
65  	{
66  		SystemType system = SystemType.UNKNOWN;
67  		BarrelType barrel = BarrelType.UNKNOWN;
68  				
69  		if (subdetectorName.contains("endcap"))
70  			barrel = BarrelType.ENDCAP;
71  		else if (subdetectorName.contains("barrel"))
72  			barrel = BarrelType.BARREL;
73  		
74  		if (subdetectorName.startsWith("vtx") || subdetectorName.startsWith("vertex"))
75  			system = SystemType.VERTEX_DETECTOR;		
76  		else if (subdetectorName.contains("tracker"))
77  			system = SystemType.SILICON_TRACKER;
78  		else if (subdetectorName.startsWith("tpc"))
79  			system = SystemType.TPC;
80  		else if (subdetectorName.startsWith("ecal") || subdetectorName.startsWith("em"))
81  			system = SystemType.ECAL;
82  		else if (subdetectorName.startsWith("hcal") || subdetectorName.startsWith("had"))
83  			system = SystemType.HCAL;
84  		else if (subdetectorName.startsWith("muon"))
85  			system = SystemType.MUON;
86  		else if (subdetectorName.contains("forward") || subdetectorName.startsWith("lumi"))
87  			system = SystemType.FORWARD;		
88  						
89  		return new SubdetectorType(system, barrel);
90  	}
91  }