00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #ifndef PLEXMUXBOXID_H
00013 #define PLEXMUXBOXID_H
00014
00015 #include <iosfwd>
00016
00017 #include "Conventions/Detector.h"
00018 #include "Conventions/ElecType.h"
00019
00020 class PlexMuxBoxId;
00021 std::ostream& operator<<(std::ostream& os, const PlexMuxBoxId& p);
00022
00023 class PlexMuxBoxId {
00024
00025 public:
00026
00027 PlexMuxBoxId();
00028 PlexMuxBoxId(const Detector::Detector_t detector,
00029 const ElecType::Elec_t electronics,
00030 Char_t eastwest, Char_t racklevel,
00031 UInt_t rackbay, UInt_t inrack);
00032
00033 PlexMuxBoxId(const PlexMuxBoxId& muxid);
00034 PlexMuxBoxId& operator=(const PlexMuxBoxId& muxid);
00035
00036
00037 virtual ~PlexMuxBoxId() { ; }
00038
00039
00040 explicit PlexMuxBoxId(const UInt_t encoded);
00041 inline UInt_t GetEncoded() const;
00042
00043 virtual const char *AsString(Option_t *option="") const;
00044
00045 Detector::Detector_t GetDetector() const;
00046 ElecType::Elec_t GetElecType() const;
00047 Char_t GetEastWest() const;
00048 Char_t GetRackLevel() const;
00049 UShort_t GetRackBay() const;
00050 UShort_t GetInRack() const;
00051
00052
00053 UInt_t GetNumericMuxBox() const;
00054
00055 Bool_t IsValid() const;
00056
00057 void Print(Option_t *option="") const;
00058
00059 void SetDetector(Detector::Detector_t detector);
00060 void SetElecType(ElecType::Elec_t elec);
00061 void SetEastWest(Char_t eastwest);
00062 void SetRackLevel(Char_t racklevel);
00063 void SetRackBay(UInt_t rackbay);
00064 void SetInRack(UInt_t inrack);
00065
00066 friend Bool_t operator< (const PlexMuxBoxId &lhs, const PlexMuxBoxId &rhs);
00067 friend Bool_t operator<=(const PlexMuxBoxId &lhs, const PlexMuxBoxId &rhs);
00068 friend Bool_t operator==(const PlexMuxBoxId &lhs, const PlexMuxBoxId &rhs);
00069 friend Bool_t operator!=(const PlexMuxBoxId &lhs, const PlexMuxBoxId &rhs);
00070 friend Bool_t operator> (const PlexMuxBoxId &lhs, const PlexMuxBoxId &rhs);
00071 friend Bool_t operator>=(const PlexMuxBoxId &lhs, const PlexMuxBoxId &rhs);
00072
00073 static UInt_t ConvertEncodedToVersion2(UInt_t encoded);
00074 void ConvertToVersion2() const;
00075
00076 protected:
00077
00078 UInt_t fEncoded;
00079
00080 private:
00081
00082 ClassDef(PlexMuxBoxId,2)
00083 };
00084
00085 #ifndef __CINT__
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 const UInt_t defaultMuxBoxId = 0;
00107
00108 const UInt_t maskPlexMuxVersion = 0x80000000;
00109 const UInt_t maskPlexMuxDetector = 0x70000000;
00110 const UInt_t shftPlexMuxDetector = 28;
00111 const UInt_t maskPlexMuxElecType = 0x0C000000;
00112 const UInt_t shftPlexMuxElecType = 26;
00113 const UInt_t maskPlexMuxEastWest = 0x03000000;
00114 const UInt_t shftPlexMuxEastWest = 24;
00115 const UInt_t maskPlexMuxLevel = 0x00C00000;
00116 const UInt_t shftPlexMuxLevel = 22;
00117 const UInt_t maskPlexMuxBay = 0x003E0000;
00118 const UInt_t shftPlexMuxBay = 17;
00119 const UInt_t maskPlexMuxInRack = 0x0001E000;
00120 const UInt_t shftPlexMuxInRack = 13;
00121
00122
00123 const UInt_t maskPlexMuxNumeric =
00124 maskPlexMuxEastWest|maskPlexMuxLevel|maskPlexMuxBay|maskPlexMuxInRack;
00125 const UInt_t shftPlexMuxNumeric = shftPlexMuxInRack;
00126
00127 const UInt_t zeroPlexMuxVersion = ~maskPlexMuxVersion;
00128 const UInt_t maskPlexMuxUsed = 0xFFFFE000;
00129 const UInt_t zeroPlexMuxUnused = maskPlexMuxUsed;
00130
00131
00132
00133 inline Bool_t operator< (const PlexMuxBoxId &lhs, const PlexMuxBoxId &rhs)
00134 { lhs.ConvertToVersion2(); rhs.ConvertToVersion2();
00135 return (lhs.fEncoded&zeroPlexMuxUnused) < (rhs.fEncoded&zeroPlexMuxUnused); }
00136
00137 inline Bool_t operator<=(const PlexMuxBoxId &lhs, const PlexMuxBoxId &rhs)
00138 { lhs.ConvertToVersion2(); rhs.ConvertToVersion2();
00139 return (lhs.fEncoded&zeroPlexMuxUnused) <= (rhs.fEncoded&zeroPlexMuxUnused); }
00140
00141 inline Bool_t operator==(const PlexMuxBoxId &lhs, const PlexMuxBoxId &rhs)
00142 { lhs.ConvertToVersion2(); rhs.ConvertToVersion2();
00143 return (lhs.fEncoded&zeroPlexMuxUnused) == (rhs.fEncoded&zeroPlexMuxUnused); }
00144
00145 inline Bool_t operator!=(const PlexMuxBoxId &lhs, const PlexMuxBoxId &rhs)
00146 { lhs.ConvertToVersion2(); rhs.ConvertToVersion2();
00147 return (lhs.fEncoded&zeroPlexMuxUnused) != (rhs.fEncoded&zeroPlexMuxUnused); }
00148
00149 inline Bool_t operator> (const PlexMuxBoxId &lhs, const PlexMuxBoxId &rhs)
00150 { lhs.ConvertToVersion2(); rhs.ConvertToVersion2();
00151 return (lhs.fEncoded&zeroPlexMuxUnused) > (rhs.fEncoded&zeroPlexMuxUnused); }
00152
00153 inline Bool_t operator>=(const PlexMuxBoxId &lhs, const PlexMuxBoxId &rhs)
00154 { lhs.ConvertToVersion2(); rhs.ConvertToVersion2();
00155 return (lhs.fEncoded&zeroPlexMuxUnused) >= (rhs.fEncoded&zeroPlexMuxUnused); }
00156
00157 inline UInt_t PlexMuxBoxId::GetEncoded() const
00158 { ConvertToVersion2(); return fEncoded&zeroPlexMuxUnused; }
00159
00160 inline Detector::Detector_t PlexMuxBoxId::GetDetector() const
00161 {
00162 ConvertToVersion2();
00163 Int_t bitField = ( fEncoded & maskPlexMuxDetector) >> shftPlexMuxDetector;
00164 return (Detector::Detector_t) bitField;
00165 }
00166
00167 inline ElecType::Elec_t PlexMuxBoxId::GetElecType() const
00168 {
00169 ConvertToVersion2();
00170 Int_t bitField = ( fEncoded & maskPlexMuxElecType ) >> shftPlexMuxElecType;
00171 return (ElecType::Elec_t) bitField;
00172 }
00173
00174 inline Char_t PlexMuxBoxId::GetEastWest() const
00175 {
00176 ConvertToVersion2();
00177 switch ( ( fEncoded & maskPlexMuxEastWest ) >> shftPlexMuxEastWest ) {
00178 case 1: return 'E';
00179 case 2: return 'W';
00180 default: return '?';
00181 }
00182 }
00183
00184 inline Char_t PlexMuxBoxId::GetRackLevel() const
00185 {
00186 ConvertToVersion2();
00187 switch ( ( fEncoded & maskPlexMuxLevel ) >> shftPlexMuxLevel ) {
00188 case 0: return 'L';
00189 case 1: return 'M';
00190 case 2: return 'U';
00191 default: return '?';
00192 }
00193 }
00194
00195 inline UShort_t PlexMuxBoxId::GetRackBay() const
00196 {
00197 ConvertToVersion2();
00198 return ( fEncoded & maskPlexMuxBay ) >> shftPlexMuxBay;
00199 }
00200
00201 inline UShort_t PlexMuxBoxId::GetInRack() const
00202 {
00203 ConvertToVersion2();
00204 return ( fEncoded & maskPlexMuxInRack ) >> shftPlexMuxInRack;
00205 }
00206
00207 inline UInt_t PlexMuxBoxId::GetNumericMuxBox() const
00208 {
00209 ConvertToVersion2();
00210 return ( fEncoded & maskPlexMuxNumeric ) >> shftPlexMuxNumeric;
00211 }
00212
00213 inline void PlexMuxBoxId::SetDetector(Detector::Detector_t detector)
00214 {
00215 ConvertToVersion2();
00216 fEncoded = ( fEncoded & ~maskPlexMuxDetector ) |
00217 ( ( detector << shftPlexMuxDetector ) & maskPlexMuxDetector );
00218 }
00219
00220 inline void PlexMuxBoxId::SetElecType(ElecType::Elec_t elec)
00221 {
00222 ConvertToVersion2();
00223 fEncoded = ( fEncoded & ~maskPlexMuxElecType ) |
00224 ( ( elec << shftPlexMuxElecType ) & maskPlexMuxElecType );
00225 }
00226
00227 inline void PlexMuxBoxId::SetEastWest(Char_t eastwest)
00228 {
00229 ConvertToVersion2();
00230 int iew = 0;
00231 switch (eastwest) {
00232 case 'e':
00233 case 'E':
00234 case '-':
00235 iew = 1;
00236 break;
00237 case 'w':
00238 case 'W':
00239 case '+':
00240 iew = 2;
00241 break;
00242 default:
00243 iew = 0;
00244 }
00245 fEncoded = ( fEncoded & ~maskPlexMuxEastWest ) |
00246 ( ( iew << shftPlexMuxEastWest ) & maskPlexMuxEastWest );
00247 }
00248
00249 inline void PlexMuxBoxId::SetRackLevel(Char_t racklevel)
00250 {
00251 ConvertToVersion2();
00252 int irl = 0;
00253 switch (racklevel) {
00254 case 'l':
00255 case 'L':
00256 case 'b':
00257 case 'B':
00258 irl = 0;
00259 break;
00260 case 'm':
00261 case 'M':
00262 irl = 1;
00263 break;
00264 case 't':
00265 case 'T':
00266 case 'u':
00267 case 'U':
00268 irl = 2;
00269 break;
00270 default:
00271 irl = 3;
00272 }
00273 fEncoded = ( fEncoded & ~maskPlexMuxLevel ) |
00274 ( ( irl << shftPlexMuxLevel ) & maskPlexMuxLevel );
00275 }
00276
00277 inline void PlexMuxBoxId::SetRackBay(UInt_t rackbay)
00278 {
00279 ConvertToVersion2();
00280 fEncoded = ( fEncoded & ~maskPlexMuxBay ) |
00281 ( ( rackbay << shftPlexMuxBay ) & maskPlexMuxBay );
00282 }
00283
00284 inline void PlexMuxBoxId::SetInRack(UInt_t inrack)
00285 {
00286 ConvertToVersion2();
00287 fEncoded = ( fEncoded & ~maskPlexMuxInRack ) |
00288 ( ( inrack << shftPlexMuxInRack ) & maskPlexMuxInRack );
00289 }
00290
00291 inline Bool_t PlexMuxBoxId::IsValid() const {
00292 return ( fEncoded & zeroPlexMuxVersion ) != defaultMuxBoxId;
00293 }
00294
00295 #endif
00296 #endif // PLEXMUXBOXID_H