View Javadoc

1   package org.lcsim.detector;
2   
3   import java.util.HashMap;
4   
5   import org.lcsim.detector.identifier.ExpandedIdentifier;
6   import org.lcsim.detector.identifier.IExpandedIdentifier;
7   import org.lcsim.detector.identifier.IIdentifier;
8   import org.lcsim.detector.identifier.IIdentifierDictionary;
9   import org.lcsim.detector.identifier.IdentifierHelper;
10  
11  /**
12   * <p>
13   * An {@link org.lcsim.detector.identifier.IIdentifierHelper} for decoding {@link org.lcsim.detector.identifier.IIdentifier}s
14   * from the top-level of the detector description.
15   * </p>
16   * 
17   * <p>
18   * This class uses the following fields from the ID description.
19   * <ul>
20   * <li><code>system</code> - The system number that uniquely identifies a subdetector.</li>
21   * <li><code>barrel</code> - A flag that indicates whether a subdetector is a barrel (0), endcap positive (1), or endcap negative (2).</li>
22   * <li><code>layer</code> - The layer number of a subcomponent (optional).</li>
23   * </ul>
24   * </p> 
25   * 
26   * <p>
27   * The system numbers can be set from a {@see SystemMap} which is a map of strings 
28   * to integer values for system.  These could be read from a compact description.
29   * </p>
30   * 
31   * <p>
32   * The basic method signatures are as follows.
33   * <ul>
34   * <li><code>int getASubdetectorValue()</code> - Get the system value of SomeSubdetector.
35   * <li><code>isASubdetector(IIdentifier i)</code> - Check if the id is of some subdetector type or it it has matching barrel flag. 
36   * <li><code>IIdentifier getASubdetectorId()</code> - Get the id for SomeSubdetector.
37   * <li><code>int getAFieldValue(IIdentifier i)</code> - Get a field value from an id.
38   * <li><code>boolean AFieldEquals(IIdentifier i, int x)</code> - Check if field from identifier equals the argument value.
39   * </ul>
40   * </p>
41   * 
42   * <p>
43   * Every DetectorIdentifierHelper is associated with a single subdetector, such as the Hcal Barrel.
44   * </p>
45   * 
46   * @author Jeremy McCormick <jeremym@slac.stanford.edu>
47   */
48  public class DetectorIdentifierHelper
49  extends IdentifierHelper
50  {	
51      // Invalid index.
52      public static final int invalidIndex=-1;
53  
54      // Index of system field in the IdentifierDictionary.  REQUIRED.
55      int systemIndex=invalidIndex;
56  
57      // Index of barrel field in the IdentifierDictionary.  REQUIRED.
58      int barrelIndex=invalidIndex;
59  
60      // Index of layer field in the IdentifierDictionary.  OPTIONAL.
61      int layerIndex=invalidIndex;
62  
63      // Barrel flag values following the LCSim conventions.
64      private final static int barrelValue=0;
65      private final static int endcapPositiveValue=1;
66      private final static int endcapNegativeValue=2;
67  
68      // Subsystem id values.  
69      // These are set via a SystemMap, to allow the values to be read
70      // from a compact detector description.  The default SystemMap is 
71      // created if none is supplied.
72      private int invalidSystemValue = -1;
73      private int unknownValue = invalidSystemValue;
74      private int vtxBarrelValue = invalidSystemValue;
75      private int vtxEndcapValue = invalidSystemValue;
76      private int sitBarrelValue = invalidSystemValue;
77      private int sitEndcapValue = invalidSystemValue;
78      private int sitForwardValue = invalidSystemValue;
79      private int tpcValue = invalidSystemValue;
80      private int ecalBarrelValue = invalidSystemValue;
81      private int ecalEndcapValue = invalidSystemValue;
82      private int hcalBarrelValue = invalidSystemValue;
83      private int hcalEndcapValue = invalidSystemValue;
84      private int muonBarrelValue = invalidSystemValue;
85      private int muonEndcapValue = invalidSystemValue;
86      private int ecalForwardValue = invalidSystemValue;
87      private int lumiValue = invalidSystemValue;	
88  
89      // Barrel or endcap ids.
90      IIdentifier barrelId;
91      IIdentifier endcapPositiveId;
92      IIdentifier endcapNegativeId;
93  
94      // Vertex detector ids.
95      IIdentifier vtxBarrelId;
96      IIdentifier vtxEndcapId;
97      IIdentifier vtxEndcapPositiveId;
98      IIdentifier vtxEndcapNegativeId;
99  
100     // Silicon tracker ids.
101     IIdentifier sitBarrelId;
102     IIdentifier sitEndcapId;
103     IIdentifier sitEndcapPositiveId;
104     IIdentifier sitEndcapNegativeId;
105 
106     // Forward silicon tracking.
107     IIdentifier sitForwardId;
108     IIdentifier sitForwardEndcapPositiveId;
109     IIdentifier sitForwardEndcapNegativeId;	
110 
111     // TPC id.
112     IIdentifier tpcId;
113 
114     // Ecal ids.
115     IIdentifier ecalBarrelId;
116     IIdentifier ecalEndcapId;
117     IIdentifier ecalEndcapPositiveId;
118     IIdentifier ecalEndcapNegativeId;
119 
120     // Hcal ids.
121     IIdentifier hcalBarrelId;
122     IIdentifier hcalEndcapId;
123     IIdentifier hcalEndcapPositiveId;
124     IIdentifier hcalEndcapNegativeId;
125 
126     // Muon ids.
127     IIdentifier muonBarrelId;
128     IIdentifier muonEndcapId;
129     IIdentifier muonEndcapPositiveId;
130     IIdentifier muonEndcapNegativeId;
131 
132     // Ecal forward ids.
133     IIdentifier ecalForwardId;
134     IIdentifier ecalForwardEndcapPositiveId;
135     IIdentifier ecalForwardEndcapNegativeId;
136 
137     // Luminosity monitor ids.
138     IIdentifier lumiId;
139     IIdentifier lumiEndcapPositiveId;
140     IIdentifier lumiEndcapNegativeId;
141     
142     private IDetectorElement subdetectorDetectorElement = null;
143     private int subdetectorSystemNumber = -1;
144     SubdetectorType subdetectorType;
145 
146     // LDC si tracking...
147     // inner = sit
148     // outer = set
149     // ftc = forward tracking chamber
150 
151     // FIXME: Add an hcalForward subsystem.
152 
153     public static class SystemMap 
154     extends HashMap<String,Integer>
155     {
156         public Integer put(String key, Integer value) 
157         {
158             if (containsKey(key))
159             {
160                 System.err.println("The field " + key + " was already set to <" + value + ">.  Ignored!");
161                 return -1;
162             }
163             else {
164                 return super.put(key, value);
165             }
166         }					
167     }
168 
169     private SystemMap defaultSystemMap;
170 
171     private SystemMap makeDefaultSystemMap()
172     {
173         if (defaultSystemMap == null)
174         {
175             defaultSystemMap = new SystemMap();
176 
177             SystemMap s = defaultSystemMap;
178 
179             s.put("unknown",0);
180             s.put("vtxBarrel",1);
181             s.put("vtxEndcap",2);
182             s.put("sitBarrel",3);
183             s.put("sitEndcap",4);
184             s.put("sitForward", 5);
185             s.put("tpc",6);
186             s.put("ecalBarrel",7);
187             s.put("ecalEndcap",8);
188             s.put("hcalBarrel",9);
189             s.put("hcalEndcap",10);
190             s.put("muonBarrel",11);
191             s.put("muonEndcap",12);
192             s.put("ecalForward",13);
193             s.put("lumi",14);
194         }
195         return defaultSystemMap;		
196     }	
197 
198     private void setSystemValues(SystemMap s)
199     {
200         if (s != null)
201         {
202             if (s.containsKey("unknown"))
203                 unknownValue = s.get("unknown");
204 
205             if (s.containsKey("vtxBarrel"))
206                 vtxBarrelValue = s.get("vtxBarrel");
207 
208             if (s.containsKey("vtxEndcap"))
209                 vtxEndcapValue = s.get("vtxEndcap");
210 
211             if (s.containsKey("sitBarrel"))
212                 sitBarrelValue = s.get("sitBarrel");
213 
214             if (s.containsKey("sitEndcap"))
215                 sitEndcapValue = s.get("sitEndcap");
216 
217             if (s.containsKey("sitForward"))
218                 sitForwardValue = s.get("sitForward");
219 
220             if (s.containsKey("tpc"))
221                 tpcValue = s.get("tpc");
222 
223             if (s.containsKey("ecalBarrel"))
224                 ecalBarrelValue = s.get("ecalBarrel");
225 
226             if (s.containsKey("ecalEndcap"))
227                 ecalEndcapValue = s.get("ecalEndcap");
228 
229             if (s.containsKey("hcalBarrel"))
230                 hcalBarrelValue = s.get("hcalBarrel");
231 
232             if (s.containsKey("hcalEndcap"))
233                 hcalEndcapValue = s.get("hcalEndcap");
234 
235             if (s.containsKey("muonBarrel"))
236                 muonBarrelValue = s.get("muonBarrel");
237 
238             if (s.containsKey("muonEndcap"))
239                 muonEndcapValue = s.get("muonEndcap");
240 
241             if (s.containsKey("ecalForward"))
242                 ecalForwardValue = s.get("ecalForward");
243 
244             if (s.containsKey("lumi"))
245                 lumiValue = s.get("lumi");
246         }
247     }
248 
249     private void setup(IIdentifierDictionary dict, SystemMap systemMap)
250     {
251         if (systemMap == null)
252             systemMap = makeDefaultSystemMap();
253 
254         setSystemValues(systemMap);
255 
256         systemIndex = dict.getFieldIndex("system");
257         barrelIndex = dict.getFieldIndex("barrel");
258 
259         // Optional layer field.
260         if (dict.hasField("layer"))
261             layerIndex = dict.getFieldIndex("layer");		
262 
263         barrelId         = makeBarrelId(barrelValue);
264         endcapPositiveId = makeBarrelId(endcapPositiveValue);
265         endcapNegativeId = makeBarrelId(endcapNegativeValue);
266 
267         vtxBarrelId         = makeSubsysId(vtxBarrelValue,barrelValue);
268         vtxEndcapPositiveId = makeSubsysId(vtxEndcapValue,endcapPositiveValue);
269         vtxEndcapNegativeId = makeSubsysId(vtxEndcapValue,endcapNegativeValue);
270 
271         sitBarrelId         = makeSubsysId(sitBarrelValue,barrelValue);
272         sitEndcapPositiveId = makeSubsysId(sitEndcapValue,endcapPositiveValue);
273         sitEndcapNegativeId = makeSubsysId(sitEndcapValue,endcapNegativeValue);
274 
275         sitForwardId               = makeSubsysId(sitForwardValue);
276         sitForwardEndcapPositiveId = makeSubsysId(sitForwardValue,endcapPositiveValue);
277         sitForwardEndcapNegativeId = makeSubsysId(sitForwardValue,endcapNegativeValue);
278 
279         tpcId = makeSubsysId(tpcValue);
280 
281         ecalBarrelId         = makeSubsysId(ecalBarrelValue,barrelValue);
282         ecalEndcapPositiveId = makeSubsysId(ecalEndcapValue,endcapPositiveValue);
283         ecalEndcapNegativeId = makeSubsysId(ecalEndcapValue,endcapNegativeValue);
284 
285         hcalBarrelId         = makeSubsysId(hcalBarrelValue,barrelValue);
286         hcalEndcapPositiveId = makeSubsysId(hcalEndcapValue,endcapPositiveValue);
287         hcalEndcapNegativeId = makeSubsysId(hcalEndcapValue,endcapNegativeValue);
288 
289         muonBarrelId         = makeSubsysId(muonBarrelValue,barrelValue);
290         muonEndcapPositiveId = makeSubsysId(muonEndcapValue,endcapPositiveValue);
291         muonEndcapNegativeId = makeSubsysId(muonEndcapValue,endcapNegativeValue);			
292 
293         ecalForwardId = makeSubsysId(ecalForwardValue);
294         ecalForwardEndcapPositiveId = makeSubsysId(ecalForwardValue, endcapPositiveValue);
295         ecalForwardEndcapNegativeId = makeSubsysId(ecalForwardValue, endcapNegativeValue);
296 
297         lumiId = makeSubsysId(lumiValue);
298         lumiEndcapPositiveId = makeSubsysId(lumiValue,endcapPositiveValue);
299         lumiEndcapNegativeId = makeSubsysId(lumiValue,endcapNegativeValue);		
300     }
301     
302     // Public ctor.
303     public DetectorIdentifierHelper(
304     		IDetectorElement subdetectorDetectorElement, 
305     		IIdentifierDictionary dict, 
306     		SystemMap systemMap)
307     {
308         super(dict);
309         try 
310         {
311             setup(dict,systemMap);
312         }
313         catch (Exception x)
314         {
315             throw new RuntimeException(x);
316         }
317         
318         // Make association to a subdetector's DetectorElement.
319         this.subdetectorDetectorElement = subdetectorDetectorElement;
320         
321         // Make assocation to a subdetector's system value.
322         this.subdetectorSystemNumber = this.getSystemValue(this.subdetectorDetectorElement.getIdentifier());
323         
324         subdetectorType = SubdetectorType.convert(subdetectorDetectorElement.getName());
325     }	
326 
327     private IIdentifier makeSubsysId(int system)
328     {		
329         // Check for invalid system id and replace with 0 to get a valid identifier.
330         if (system == this.invalidSystemValue)
331             system = 0;
332         IExpandedIdentifier expid = 
333             new ExpandedIdentifier(getIdentifierDictionary().getNumberOfFields());
334         expid.setValue(systemIndex, system);
335         IIdentifier id = pack(expid);
336         return id;
337     }
338 
339     private IIdentifier makeSubsysId(int system, int barrel)
340     {		
341         // Check for invalid system id and replace with 0 to get a valid identifier.
342         if (system == this.invalidSystemValue)
343             system = 0;
344         IExpandedIdentifier expid = 
345             new ExpandedIdentifier(getIdentifierDictionary().getNumberOfFields());
346         expid.setValue(systemIndex, system);
347         expid.setValue(barrelIndex, barrel);
348         IIdentifier id = pack(expid);
349         return id;
350     }	
351 
352     private IIdentifier makeBarrelId(int barrel)
353     {		
354         IExpandedIdentifier expid = 
355             new ExpandedIdentifier(getIdentifierDictionary().getNumberOfFields());
356         expid.setValue(barrelIndex, barrel);
357         IIdentifier id = pack(expid);
358         return id;
359     }	
360 
361     private boolean compareSystem(IIdentifier id, int system)
362     {
363         return unpack(id).getValue(systemIndex) == system;
364     }	
365 
366     public int getBarrelValue()
367     {
368         return barrelValue;
369     }
370 
371     public int getEndcapPositiveValue()
372     {
373         return endcapPositiveValue;
374     }
375 
376     public int getEndcapNegativeValue()
377     {
378         return endcapNegativeValue;
379     }
380 
381     public int getUnknownValue()
382     {
383         return unknownValue;
384     }
385 
386     public int getVtxBarrelValue()
387     {
388         return vtxBarrelValue;
389     }
390 
391     public int getVtxEndcapValue()
392     {
393         return vtxEndcapValue;
394     }	
395 
396     public int getSitForwardValue()
397     {
398         return sitForwardValue;
399     }
400 
401     public int getSitBarrelValue()
402     {
403         return sitBarrelValue;
404     }
405     public int getSitEndcapValue()
406     {
407         return sitEndcapValue;
408     }
409 
410     public int getEcalBarrelValue()
411     {
412         return ecalBarrelValue;
413     }
414     public int getEcalEndcapValue()
415     {
416         return ecalEndcapValue;
417     }		
418 
419     public IIdentifier getBarrelId()
420     {
421         return barrelId;
422     }
423 
424     public IIdentifier getEndcapPositiveId()
425     {
426         return endcapPositiveId;
427     }
428 
429     public IIdentifier getEndcapNegativeId()
430     {
431         return endcapNegativeId;
432     }    
433 
434     public IIdentifier getVtxBarrelId()
435     {
436         return vtxBarrelId;
437     }
438 
439     public IIdentifier getVtxEndcapId()
440     {
441         return vtxEndcapId;
442     }
443     public IIdentifier getVtxEndcapPositiveId()
444     {
445         return vtxEndcapPositiveId;
446     }
447 
448     public IIdentifier getVtxEndcapNegativeId()
449     {
450         return vtxEndcapNegativeId;
451     }   
452 
453     public IIdentifier getSitEndcapId()
454     {
455         return sitEndcapId;
456     }   
457     public IIdentifier getSitBarrelId()
458     {
459         return sitBarrelId;
460     }
461 
462     public IIdentifier getSitEndcapPositiveId()
463     {
464         return sitEndcapPositiveId;
465     }
466 
467     public IIdentifier getSitEndcapNegativeId()
468     {
469         return sitEndcapNegativeId;
470     }    
471 
472     public IIdentifier getSitForwardId()
473     {
474         return sitForwardId;
475     }
476 
477     public IIdentifier getSitForwardEndcapPositiveId()
478     {
479         return sitForwardEndcapPositiveId;
480     }
481 
482     public IIdentifier getSitForwardEndcapNegativeId()
483     {
484         return sitForwardEndcapNegativeId;
485     }
486 
487     public IIdentifier getTpcId()
488     {
489         return tpcId;
490     }    
491 
492     public IIdentifier getEcalEndcapId()
493     {
494         return ecalEndcapId;
495     }
496 
497     public IIdentifier getEcalBarrelId()
498     {
499         return ecalBarrelId;
500     }
501 
502     public IIdentifier getEcalEndcapNegativeId()
503     {
504         return ecalEndcapNegativeId;
505     }
506 
507     public IIdentifier getEcalEndcapPositiveId()    
508     {
509         return ecalEndcapPositiveId;
510     }    
511 
512     public IIdentifier getHcalBarrelId()
513     {
514         return hcalBarrelId;
515     }
516 
517     public IIdentifier getHcalEndcapNegativeId()
518     {
519         return hcalEndcapNegativeId;
520     }
521 
522     public IIdentifier getHcalEndcapPositiveId()
523     {
524         return hcalEndcapPositiveId;
525     }       
526 
527     public IIdentifier getMuonBarrelId()
528     {
529         return muonBarrelId;
530     }
531     public IIdentifier getMuonEndcapId()
532     {
533         return muonEndcapId;
534     }
535     public IIdentifier getMuonEndcapNegativeId()
536     {
537         return muonEndcapNegativeId;
538     }
539 
540     public IIdentifier getMuonEndcapPositiveId()
541     {
542         return muonEndcapPositiveId;
543     }       
544 
545     public IIdentifier getEcalForwardId()
546     {
547         return ecalForwardId;
548     }    
549 
550     public IIdentifier getEcalForwardEndcapPositiveId()
551     {
552         return ecalForwardEndcapPositiveId;
553     }
554 
555     public IIdentifier getEcalForwardEndcapNegativeId()
556     {
557         return ecalForwardEndcapNegativeId;
558     }
559 
560     public IIdentifier getLumiId()
561     {
562         return lumiId;
563     }
564 
565     public IIdentifier getLumiEndcapPositiveId()
566     {
567         return lumiEndcapPositiveId;
568     }
569 
570     public IIdentifier getLumiEndcapNegativeId()
571     {
572         return lumiEndcapNegativeId;
573     }    
574 
575     public boolean isBarrel(IIdentifier i)
576     {
577         return unpack(i).getValue(barrelIndex) == barrelValue;
578     }
579 
580     public boolean isEndcap(IIdentifier i)
581     {
582         return isEndcapPositive(i) || isEndcapNegative(i);
583     }
584 
585     public boolean isEndcapPositive(IIdentifier i)
586     {
587         return unpack(i).getValue(barrelIndex) == endcapPositiveValue;
588     }
589 
590     public boolean isEndcapNegative(IIdentifier i)
591     {
592         return unpack(i).getValue(barrelIndex) == endcapNegativeValue;
593     }    
594 
595     public boolean isTracker(IIdentifier i)
596     { 
597         return isVtx(i) || isTpc(i) || isSit(i) || isSitForward(i);
598     }
599 
600     public boolean isTrackerBarrel(IIdentifier i)
601     {
602         return isTracker(i) && isBarrel(i);
603     }
604 
605     public boolean isTrackerEndcap(IIdentifier i)
606     {
607         return isTracker(i) && isEndcap(i);
608     }
609 
610     public boolean isTrackerEndcapPositive(IIdentifier i)
611     {
612         return isTracker(i) && isEndcapPositive(i);
613     }
614 
615     public boolean isTrackerEndcapNegative(IIdentifier i)
616     {
617         return isTracker(i) && isEndcapNegative(i);
618     }            
619 
620     public boolean isCalorimeter(IIdentifier i)
621     {
622         return isEcal(i) || isHcal(i) || isMuon(i) || isEcalForward(i) || isLumi(i);
623     }
624 
625     public boolean isCalorimeterBarrel(IIdentifier i)
626     {
627         return isCalorimeter(i) && isBarrel(i);
628     }
629 
630     public boolean isCalorimeterEndcap(IIdentifier i)
631     {
632         return isCalorimeter(i) && isEndcap(i);
633     }
634 
635     public boolean isCalorimeterEndcapPositive(IIdentifier i)
636     {
637         return isCalorimeter(i) && isEndcapPositive(i);
638     }
639 
640     public boolean isCalorimeterEndcapNegative(IIdentifier i)
641     {
642         return isCalorimeter(i) && isEndcapNegative(i);
643     }
644 
645     public boolean isVtx(IIdentifier i)
646     {
647         return compareSystem(i,vtxBarrelValue) || compareSystem(i,vtxEndcapValue);
648     }
649 
650     public boolean isVtxBarrel(IIdentifier i)
651     {
652         return isVtx(i) && isBarrel(i);
653     }
654 
655     public boolean isVtxEndcap(IIdentifier i)
656     {
657         return compareSystem(i,vtxEndcapValue) && isEndcap(i);
658     }
659 
660     public boolean isVtxEndcapPositive(IIdentifier i)
661     {
662         return isVtx(i) && isEndcapPositive(i);
663     }
664 
665     public boolean isVtxEndcapNegative(IIdentifier i)
666     {
667         return isVtx(i) && isEndcapNegative(i);
668     }    
669 
670     public boolean isSit(IIdentifier i)
671     {
672         return compareSystem(i,sitBarrelValue) || compareSystem(i,sitEndcapValue);
673     }
674 
675     public boolean isSitBarrel(IIdentifier i)
676     {
677         return isSit(i) && isBarrel(i);
678     }
679 
680     public boolean isSitEndcap(IIdentifier i)
681     {
682         return isSit(i) && isEndcap(i);
683     }
684 
685     public boolean isSitEndcapPositive(IIdentifier i)
686     {
687         return isSit(i) && isEndcapPositive(i);
688     }
689 
690     public boolean isSitEndcapNegative(IIdentifier i)
691     {
692         return isSit(i) && isEndcapNegative(i);
693     }      
694 
695     public boolean isSitForward(IIdentifier i)
696     {
697         return compareSystem(i,sitForwardValue);
698     }
699 
700     public boolean isSitForwardEndcapNegative(IIdentifier i)
701     {
702         return isSitForward(i) && isEndcapNegative(i);
703     }
704 
705     public boolean isSitForwardEndcapPositive(IIdentifier i)
706     {
707         return isSitForward(i) && isEndcapPositive(i);
708     }
709 
710     public boolean isTpc(IIdentifier i)
711     {
712         return compareSystem(i,tpcValue);
713     }        
714 
715     public boolean isEcal(IIdentifier i)
716     {
717         return compareSystem(i,ecalBarrelValue) || compareSystem(i,ecalEndcapValue);
718     }
719 
720     public boolean isEcalBarrel(IIdentifier i)
721     {
722         return isEcal(i) && isBarrel(i);
723     }
724 
725     public boolean isEcalEndcap(IIdentifier i)
726     {
727         return isEcal(i) && isEndcap(i);
728     }
729 
730     public boolean isEcalEndcapPositive(IIdentifier i)
731     {
732         return isEcal(i) && isEndcapPositive(i);
733     }
734 
735     public boolean isEcalEndcapNegative(IIdentifier i)
736     {
737         return isEcal(i) && isEndcapNegative(i);
738     }            
739 
740     public boolean isHcal(IIdentifier i)
741     {
742         return compareSystem(i,hcalBarrelValue) || compareSystem(i,hcalEndcapValue);
743     }
744 
745     public boolean isHcalBarrel(IIdentifier i)
746     {
747         return isHcal(i) && isBarrel(i);
748     }
749 
750     public boolean isHcalEndcap(IIdentifier i)
751     {
752         return isHcal(i) && isEndcap(i);
753     }
754 
755     public boolean isHcalEndcapPositive(IIdentifier i)
756     {
757         return isHcal(i) && isEndcapPositive(i);
758     }
759 
760     public boolean isHcalEndcapNegative(IIdentifier i)
761     {
762         return isHcal(i) && isEndcapNegative(i);
763     }                
764 
765     public boolean isMuon(IIdentifier i)
766     {
767         return compareSystem(i,muonBarrelValue) || compareSystem(i,muonEndcapValue);
768     }
769 
770     public boolean isMuonBarrel(IIdentifier i)
771     {
772         return isMuon(i) && isBarrel(i);
773     }   
774 
775     public boolean isMuonEndcap(IIdentifier i)
776     {
777         return isMuon(i) && isEndcap(i);
778     }
779 
780     public boolean isMuonEndcapPositive(IIdentifier i)
781     {
782         return isMuon(i) && isEndcapPositive(i);
783     }
784 
785     public boolean isMuonEndcapNegative(IIdentifier i)
786     {
787         return isMuon(i) && isEndcapNegative(i);
788     }       
789 
790     public boolean isEcalForward(IIdentifier i)
791     {
792         return compareSystem(i,ecalForwardValue);
793     }
794 
795     public boolean isEcalForwardEndcapPositive(IIdentifier i)
796     {
797         return isEcalForward(i) && isEndcapPositive(i);
798     }
799 
800     public boolean isEcalForwardEndcapNegative(IIdentifier i)
801     {
802         return isEcalForward(i) && isEndcapNegative(i);
803     }       
804 
805     public boolean isLumi(IIdentifier i)
806     {
807         return compareSystem(i,lumiValue);
808     }        
809 
810     public boolean isLumiEndcapPositive(IIdentifier i)
811     {
812         return isLumi(i) && isEndcapPositive(i);
813     }
814 
815     public boolean isLumiEndcapNegative(IIdentifier i)
816     {
817         return isLumi(i) && isEndcapNegative(i);
818     }
819 
820     public int getSystemValue(IIdentifier i)
821     {
822         return unpack(i).getValue(systemIndex);
823     }
824 
825     public int getBarrelValue(IIdentifier i)
826     {
827         return unpack(i).getValue(barrelIndex);
828     }
829 
830     public int getLayerValue(IIdentifier i)
831     {
832         if (layerIndex == invalidIndex)
833             throw new RuntimeException("The layer number is not available, because " + getIdentifierDictionary().getName() + " does not have a layer field!");
834         return unpack(i).getValue(layerIndex);
835     }
836 
837     public boolean layerEquals(IIdentifier i, int layer)
838     {
839         return getLayerValue(i) == layer;
840     }
841 
842     public boolean systemEquals(IIdentifier i, int system)
843     {
844         return getSystemValue(i) == system;
845     }
846 
847     public boolean barrelEquals(IIdentifier i, int barrel)
848     {
849         return getBarrelValue(i) == barrel;
850     }
851 
852     public int getSystemIndex()
853     {
854         return systemIndex;
855     }
856 
857     public int getLayerIndex()
858     {
859         return layerIndex;
860     }
861 
862     public int getBarrelIndex()
863     {
864         return barrelIndex;
865     }
866 
867     public int getInvalidIndex()
868     {
869         return invalidIndex;
870     }
871     
872     public String getSubdetectorName()
873     {
874     	return subdetectorDetectorElement.getName();
875     }
876     
877     public int getSubdetectorSystemNumber()
878     {
879     	return subdetectorSystemNumber;
880     }
881     
882     public IDetectorElement getSubdetectorDetectorElement()
883     {
884     	return subdetectorDetectorElement;
885     }      
886     
887     public SubdetectorType getSubdetectorType()
888     {
889     	return subdetectorType;
890     }
891 }