HighLAND
SubDetId.hxx
1 #ifndef SubDetId_hxx_seen
2 #define SubDetId_hxx_seen
3 
4 #include "BasicTypes.hxx"
5 
6 class SubDetId {
7 
8  private:
9  /// Bit mask array to select different subdetectors and systems
10  const static unsigned long DetMask[28];
11 
12  /// Method to make detector bit masks
13  static unsigned long MakeMask(int msb, int lsb) {return (((1<<(((msb)-(lsb))+1))-1)<<(lsb));}
14 
15  /// Method to count the number of set bits in a given bit field
16  static int NumberOfSetBits(unsigned long v);
17 
18 
19  public:
20 
21  SubDetId(){};
22  ~SubDetId(){};
23 
24  /// Enumeration of all detector systems and subdetectors
25  enum SubDetEnum {
26  kFGD1 = 0,
27  kFGD2,
28  kTPC1,
29  kTPC2,
30  kTPC3,
31  kP0D,
32  kDSECAL,
33  kTopTECAL,
34  kBottomTECAL,
35  kLeftTECAL,
36  kRightTECAL,
37  kTopPECAL,
38  kBottomPECAL,
39  kLeftPECAL,
40  kRightPECAL,
41  kTopSMRD,
42  kBottomSMRD,
43  kLeftSMRD,
44  kRightSMRD,
45  kInvalidSubdetector,
46  kTPC,
47  kFGD,
48  kECAL,
49  kTECAL,
50  kPECAL,
51  kSMRD,
52  kTRACKER,
53  kInvalid
54  };
55 
56  /// Method to set a certain subdetector or subdetector system to used used
57  static void SetDetectorUsed(unsigned long &BitField, SubDetId::SubDetEnum det);
58 
59  /// Method to see if a certain subdetector or subdetector system is used
60  static bool GetDetectorUsed(unsigned long BitField, SubDetId::SubDetEnum det);
61 
62  static bool GetDetectorArrayUsed(unsigned long BitField, SubDetId::SubDetEnum dets[], int nDet);
63 
64  static bool GetDetectorUsed(unsigned long BitField, SubDetId_h det);
65  static bool GetDetectorArrayUsed(unsigned long BitField, SubDetId_h dets[], int nDet);
66 
67 
68  /// Returns the TPC number (TPC1 = 1, TPC2 = 2 etc.) of the track
69  /// Does not check whether track passed through more than one TPC, just returns the first TPC it finds (checking TPC2, TPC3 then TPC1)
70  static int GetTPC(unsigned long BitField);
71 
72  /// Method to set the detector system bits using the individual subdetector bits.
73  /// e.g. If SetDetectorUsed(BitField, SubDetId::kTPC1) had been called, this function
74  /// would call SetDetectorUsed(BitField, SubDetId::kTPC)
75  static void SetDetectorSystemFields(unsigned long &BitField);
76 
77  /// Method to count the number of Segments a given track has in a detector system
78  /// The DetMask bitfield masks are used to select the specified detector system
79  static int GetNSegmentsInDet(unsigned long BitFIeld, SubDetId::SubDetEnum det);
80 
81  /// Check whether a track only uses a specified subdetector or detector system
82  static bool TrackUsesOnlyDet(unsigned long BitFIeld, SubDetId::SubDetEnum det);
83 
84  /// Check if a detector enumeration refers to a TPC or not
85  static bool IsTPCDetector(SubDetId::SubDetEnum det);
86 
87  /// Check if a detector enumeration refers to a FGD or not
88  static bool IsFGDDetector(SubDetId::SubDetEnum det);
89 
90  /// Check if a detector enumeration refers to a SMRD or not
91  static bool IsSMRDDetector(SubDetId::SubDetEnum det);
92 
93  /// Check if a detector enumeration refers to a SMRDP0D or not
94  static bool IsP0DDetector(SubDetId::SubDetEnum det);
95 
96  /// Check if a detector enumeration refers to a ECAL or not
97  static bool IsECALDetector(SubDetId::SubDetEnum det);
98 
99  /// Check if a detector enumeration refers to a Tracker ECAL or not
100  static bool IsTECALDetector(SubDetId::SubDetEnum det);
101 
102  /// Check if a detector enumeration refers to a P0D ECAL or not
103  static bool IsPECALDetector(SubDetId::SubDetEnum det);
104 
105  /// Check if a detector bit field has a Tracker ECAL or not
106  static bool HasTECALDetector(unsigned long BitField);
107 
108  /// Check if a detector bit field has a P0D ECAL or not
109  static bool HasPECALDetector(unsigned long BitField);
110 
111  /// Check if a detector bit field has a SMRD or not
112  static bool HasSMRDDetector(unsigned long BitField);
113 
114  /// Get the single subdetector that this track is from
115  static SubDetId::SubDetEnum GetSubdetectorEnum(unsigned long BitField);
116 
117 };
118 #endif
119 
120 
static bool TrackUsesOnlyDet(unsigned long BitFIeld, SubDetId::SubDetEnum det)
Check whether a track only uses a specified subdetector or detector system.
Definition: SubDetId.cxx:117
static bool IsFGDDetector(SubDetId::SubDetEnum det)
Check if a detector enumeration refers to a FGD or not.
Definition: SubDetId.cxx:126
static bool HasPECALDetector(unsigned long BitField)
Check if a detector bit field has a P0D ECAL or not.
Definition: SubDetId.cxx:155
static int GetNSegmentsInDet(unsigned long BitFIeld, SubDetId::SubDetEnum det)
Definition: SubDetId.cxx:113
static bool IsP0DDetector(SubDetId::SubDetEnum det)
Check if a detector enumeration refers to a SMRDP0D or not.
Definition: SubDetId.cxx:146
static void SetDetectorSystemFields(unsigned long &BitField)
Definition: SubDetId.cxx:81
static bool GetDetectorUsed(unsigned long BitField, SubDetId::SubDetEnum det)
Method to see if a certain subdetector or subdetector system is used.
Definition: SubDetId.cxx:40
static bool IsPECALDetector(SubDetId::SubDetEnum det)
Check if a detector enumeration refers to a P0D ECAL or not.
Definition: SubDetId.cxx:138
static bool HasSMRDDetector(unsigned long BitField)
Check if a detector bit field has a SMRD or not.
Definition: SubDetId.cxx:160
static void SetDetectorUsed(unsigned long &BitField, SubDetId::SubDetEnum det)
Method to set a certain subdetector or subdetector system to used used.
Definition: SubDetId.cxx:36
static bool IsTPCDetector(SubDetId::SubDetEnum det)
Check if a detector enumeration refers to a TPC or not.
Definition: SubDetId.cxx:122
static bool IsECALDetector(SubDetId::SubDetEnum det)
Check if a detector enumeration refers to a ECAL or not.
Definition: SubDetId.cxx:130
SubDetEnum
Enumeration of all detector systems and subdetectors.
Definition: SubDetId.hxx:25
static SubDetId::SubDetEnum GetSubdetectorEnum(unsigned long BitField)
Get the single subdetector that this track is from.
Definition: SubDetId.cxx:165
static bool IsTECALDetector(SubDetId::SubDetEnum det)
Check if a detector enumeration refers to a Tracker ECAL or not.
Definition: SubDetId.cxx:134
static bool HasTECALDetector(unsigned long BitField)
Check if a detector bit field has a Tracker ECAL or not.
Definition: SubDetId.cxx:150
static int GetTPC(unsigned long BitField)
Definition: SubDetId.cxx:74
static bool IsSMRDDetector(SubDetId::SubDetEnum det)
Check if a detector enumeration refers to a SMRD or not.
Definition: SubDetId.cxx:142