66 */
77public class DetectorDescriptor implements Comparable <DetectorDescriptor > {
88
9- private DetectorType detectorType = DetectorType .UNDEFINED ;
9+ private DetectorType detectorType = DetectorType .UNDEFINED ;
1010 private Integer hw_CRATE = 0 ;
1111 private Integer hw_SLOT = 0 ;
1212 private Integer hw_CHANNEL = 0 ;
13-
13+
1414 private Integer dt_SECTOR = 0 ;
1515 private Integer dt_LAYER = 0 ;
1616 private Integer dt_COMPONENT = 0 ;
17-
18- private Integer dt_ORDER = 0 ; // This is the order in the bank
19- // defines ADCL,ADCR,TDCL,TDCR (1,2,3,4)
20-
21- public DetectorDescriptor (){
22-
23- }
24-
17+
18+ // FIXME: Is this correct?
19+ // This order in the bank defines ADCL,ADCR,TDCL,TDCR (1,2,3,4):
20+ private Integer dt_ORDER = 0 ;
21+
22+ public DetectorDescriptor () {}
23+
2524 public DetectorDescriptor (DetectorType type ){
2625 this .detectorType = type ;
2726 }
28-
27+
2928 public DetectorDescriptor (String name ){
3029 this .detectorType = DetectorType .getType (name );
3130 }
32-
31+
3332 public DetectorDescriptor getCopy (){
3433 DetectorDescriptor newDesc = new DetectorDescriptor (this .detectorType );
3534 newDesc .setCrateSlotChannel (this .getCrate (), this .getSlot (), this .getChannel ());
3635 newDesc .setSectorLayerComponent (this .getSector (), this .getLayer (), this .getComponent ());
37-
3836 return newDesc ;
3937 }
40-
38+
4139 public int getCrate (){ return this .hw_CRATE ;}
4240 public int getChannel () { return this .hw_CHANNEL ;}
4341 public int getComponent (){ return this .dt_COMPONENT ;}
@@ -49,25 +47,25 @@ public DetectorDescriptor getCopy(){
4947 public void setSector (int sector ){
5048 this .dt_SECTOR =sector ;
5149 }
52-
50+
5351 public void setOrder (int order ){
5452 this .dt_ORDER = order ;
5553 if (this .dt_ORDER <0 ||this .dt_ORDER >3 ){
5654 System .err .println ("----> error : detector descriptor order must be [1..4]" );
5755 this .dt_ORDER = 0 ;
5856 }
5957 }
60-
58+
6159 public int [] getCSC () {
6260 return new int []{hw_CRATE ,hw_SLOT ,hw_CHANNEL };
6361 }
6462
6563 public int [] getSLCO () {
6664 return new int []{dt_SECTOR ,dt_LAYER ,dt_COMPONENT ,dt_ORDER };
6765 }
68-
66+
6967 public DetectorType getType (){ return this .detectorType ;}
70-
68+
7169 public final void setType (DetectorType type ){
7270 this .detectorType = type ;
7371 }
@@ -88,19 +86,33 @@ public final void setSectorLayerComponent(int sector, int layer, int comp){
8886 this .dt_COMPONENT = comp ;
8987 }
9088
89+ public final void setSectorLayerComponentOrder (int sector , int layer , int comp , int order ) {
90+ this .dt_SECTOR = sector ;
91+ this .dt_LAYER = layer ;
92+ this .dt_COMPONENT = comp ;
93+ this .dt_ORDER = order ;
94+ }
95+
96+ public final void setSectorLayerComponentOrderType (int sector , int layer , int comp , int order , int type ) {
97+ this .dt_SECTOR = sector ;
98+ this .dt_LAYER = layer ;
99+ this .dt_COMPONENT = comp ;
100+ this .dt_ORDER = order ;
101+ this .detectorType = DetectorType .getType (type );
102+ }
103+
91104 public static int generateHashCode (int s , int l , int c ){
92105 return ((s <<24 )&0xFF000000 )|
93106 ((l <<16 )&0x00FF0000 )|(c &0x0000FFFF );
94107 }
95-
108+
96109 public int getHashCode (){
97110 int hash = ((this .dt_SECTOR <<24 )&0xFF000000 )|
98111 ((this .dt_LAYER <<16 )&0x00FF0000 )| ((this .dt_ORDER <<12 ) & 0x0000F000 ) |
99112 (this .dt_COMPONENT &0x00000FFF );
100113 return hash ;
101114 }
102-
103-
115+
104116 public void copy (DetectorDescriptor desc ){
105117 this .hw_SLOT = desc .hw_SLOT ;
106118 this .hw_CRATE = desc .hw_CRATE ;
@@ -110,16 +122,15 @@ public void copy(DetectorDescriptor desc){
110122 this .dt_LAYER = desc .dt_LAYER ;
111123 this .dt_COMPONENT = desc .dt_COMPONENT ;
112124 }
113-
125+
114126 public boolean compare (DetectorDescriptor desc ){
115127 if (this .detectorType .equals (desc .detectorType )&&
116128 this .dt_SECTOR .equals (desc .dt_SECTOR )&&
117129 this .dt_LAYER .equals (desc .dt_LAYER )&&
118130 this .dt_COMPONENT .equals (desc .dt_COMPONENT )) return true ;
119131 return false ;
120132 }
121-
122-
133+
123134 public static String getName (String base , int ... ids ){
124135 StringBuilder str = new StringBuilder ();
125136 str .append (base );
@@ -128,15 +139,15 @@ public static String getName(String base, int... ids){
128139 if (ids .length >2 ) str .append (String .format ("_C_%d" , ids [2 ]));
129140 return str .toString ();
130141 }
131-
142+
132143 public static String getTitle (String base , int ... ids ){
133144 StringBuilder str = new StringBuilder ();
134145 if (ids .length >0 ) str .append (String .format (" SECTOR %d" , ids [0 ]));
135146 if (ids .length >1 ) str .append (String .format (" LAYER %d" , ids [1 ]));
136147 if (ids .length >2 ) str .append (String .format (" UNIT %d" , ids [2 ]));
137148 return str .toString ();
138149 }
139-
150+
140151 @ Override
141152 public String toString (){
142153 return String .format ("D [%6s ] C/S/C [%4d %4d %4d ] S/L/C [%4d %4d %4d ] ORDER = %2d" ,
0 commit comments