00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #ifndef PLEXPIXELSPOTID_H
00013 #define PLEXPIXELSPOTID_H
00014
00015 #include "PlexMuxBoxId.h"
00016
00017
00018
00019
00020
00021 class PlexPixelSpotId;
00022 std::ostream& operator<<(std::ostream& os, const PlexPixelSpotId& p);
00023
00024 class PlexPixelSpotId : public PlexMuxBoxId {
00025
00026 public:
00027
00028 PlexPixelSpotId();
00029 PlexPixelSpotId(Detector::Detector_t detector,
00030 ElecType::Elec_t electronics,
00031 Char_t eastwest, Char_t racklevel,
00032 UInt_t rackbay, UInt_t inrack,
00033 UInt_t tube, UInt_t pixel, UInt_t spot);
00034 PlexPixelSpotId(PlexMuxBoxId muxbox,
00035 UInt_t tube, UInt_t pixel, UInt_t spot);
00036
00037
00038 virtual ~PlexPixelSpotId();
00039
00040
00041 explicit PlexPixelSpotId(const UInt_t encoded);
00042 UInt_t GetEncoded() const;
00043
00044 const char *AsString(Option_t *option="") const;
00045
00046 UShort_t GetTube() const;
00047 UShort_t GetPixel() const;
00048 UShort_t GetSpot() const;
00049
00050 Bool_t IsValid() const;
00051 #ifdef ENABLE_PIXELSPOTID_ISNULL
00052 Bool_t IsNull() const;
00053 #endif
00054
00055
00056
00057 UInt_t GetUniquePmtEncodedValue() const;
00058 UInt_t GetUniquePixelEncodedValue() const;
00059
00060 void Print(Option_t *option="") const;
00061
00062 void SetTube(UInt_t tube);
00063 void SetPixel(UInt_t pixel);
00064 void SetSpot(UInt_t spot);
00065
00066 Bool_t IsSamePixel(const PlexPixelSpotId &other) const;
00067 Bool_t IsSameTube(const PlexPixelSpotId &other) const;
00068
00069 friend Bool_t operator< (const PlexPixelSpotId &lhs, const PlexPixelSpotId &rhs);
00070 friend Bool_t operator<=(const PlexPixelSpotId &lhs, const PlexPixelSpotId &rhs);
00071 friend Bool_t operator==(const PlexPixelSpotId &lhs, const PlexPixelSpotId &rhs);
00072 friend Bool_t operator!=(const PlexPixelSpotId &lhs, const PlexPixelSpotId &rhs);
00073 friend Bool_t operator> (const PlexPixelSpotId &lhs, const PlexPixelSpotId &rhs);
00074 friend Bool_t operator>=(const PlexPixelSpotId &lhs, const PlexPixelSpotId &rhs);
00075
00076 #ifdef ENABLE_PIXELSPOTID_ENCODEMUXBOX
00077 static Int_t EncodeMuxBox(Char_t eastwest, Char_t racklevel,
00078 Int_t rackbay, Int_t inrack);
00079
00080 static void DecodeMuxBox(Int_t muxbox, Char_t& eastwest, Char_t& racklevel,
00081 Int_t& rackbay, Int_t& inrack);
00082 #endif
00083
00084 private:
00085
00086 ClassDef(PlexPixelSpotId,3)
00087 };
00088
00089 #ifndef __CINT__
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 const UInt_t maskPlexSpotSpot = 0x0000000f;
00107 const UInt_t shftPlexSpotSpot = 0;
00108 const UInt_t maskPlexSpotPixel = 0x000007f0;
00109 const UInt_t shftPlexSpotPixel = 4;
00110 const UInt_t maskPlexSpotTube = 0x00001800;
00111 const UInt_t shftPlexSpotTube = 11;
00112
00113 const UInt_t zeroPlexSpotSpot = ~maskPlexSpotSpot;
00114 const UInt_t zeroPlexSpotPixelSpot = ~(maskPlexSpotPixel|maskPlexSpotSpot);
00115 const UInt_t zeroPlexSpotTubePixelSpot =
00116 ~(maskPlexSpotTube|maskPlexSpotPixel|maskPlexSpotSpot);
00117
00118
00119
00120 inline Bool_t operator< (const PlexPixelSpotId &lhs, const PlexPixelSpotId &rhs)
00121 { lhs.ConvertToVersion2(); rhs.ConvertToVersion2();
00122 return lhs.fEncoded < rhs.fEncoded; }
00123
00124 inline Bool_t operator<=(const PlexPixelSpotId &lhs, const PlexPixelSpotId &rhs)
00125 { lhs.ConvertToVersion2(); rhs.ConvertToVersion2();
00126 return lhs.fEncoded <= rhs.fEncoded; }
00127
00128 inline Bool_t operator==(const PlexPixelSpotId &lhs, const PlexPixelSpotId &rhs)
00129 { lhs.ConvertToVersion2(); rhs.ConvertToVersion2();
00130 return lhs.fEncoded == rhs.fEncoded; }
00131
00132 inline Bool_t operator!=(const PlexPixelSpotId &lhs, const PlexPixelSpotId &rhs)
00133 { lhs.ConvertToVersion2(); rhs.ConvertToVersion2();
00134 return lhs.fEncoded != rhs.fEncoded; }
00135
00136 inline Bool_t operator> (const PlexPixelSpotId &lhs, const PlexPixelSpotId &rhs)
00137 { lhs.ConvertToVersion2(); rhs.ConvertToVersion2();
00138 return lhs.fEncoded > rhs.fEncoded; }
00139
00140 inline Bool_t operator>=(const PlexPixelSpotId &lhs, const PlexPixelSpotId &rhs)
00141 { lhs.ConvertToVersion2(); rhs.ConvertToVersion2();
00142 return lhs.fEncoded >= rhs.fEncoded; }
00143
00144
00145 inline Bool_t PlexPixelSpotId::IsSamePixel(const PlexPixelSpotId &other) const
00146 { ConvertToVersion2(); other.ConvertToVersion2();
00147 return (fEncoded&zeroPlexSpotSpot) == (other.fEncoded&zeroPlexSpotSpot); }
00148
00149
00150
00151 inline Bool_t PlexPixelSpotId::IsSameTube(const PlexPixelSpotId &other) const
00152 { ConvertToVersion2(); other.ConvertToVersion2();
00153 return (fEncoded&zeroPlexSpotPixelSpot) ==
00154 (other.fEncoded&zeroPlexSpotPixelSpot); }
00155
00156 inline UInt_t PlexPixelSpotId::GetEncoded() const
00157 { ConvertToVersion2(); return fEncoded; }
00158
00159 inline UShort_t PlexPixelSpotId::GetTube() const
00160 {
00161 ConvertToVersion2();
00162 return (fEncoded & maskPlexSpotTube ) >> shftPlexSpotTube ;
00163 }
00164
00165 inline UShort_t PlexPixelSpotId::GetPixel() const
00166 {
00167 ConvertToVersion2();
00168 return (fEncoded & maskPlexSpotPixel ) >> shftPlexSpotPixel ;
00169 }
00170
00171 inline UShort_t PlexPixelSpotId::GetSpot() const
00172 {
00173 ConvertToVersion2();
00174 return (fEncoded & maskPlexSpotSpot ) >> shftPlexSpotSpot ;
00175 }
00176
00177 inline void PlexPixelSpotId::SetTube(UInt_t tube)
00178 {
00179 ConvertToVersion2();
00180 fEncoded = (fEncoded & ~maskPlexSpotTube) |
00181 ( ( tube << shftPlexSpotTube ) & maskPlexSpotTube );
00182 }
00183
00184 inline void PlexPixelSpotId::SetPixel(UInt_t pixel)
00185 {
00186 ConvertToVersion2();
00187 fEncoded = (fEncoded & ~maskPlexSpotPixel) |
00188 ( ( pixel << shftPlexSpotPixel ) & maskPlexSpotPixel );
00189 }
00190
00191 inline void PlexPixelSpotId::SetSpot(UInt_t spot)
00192 {
00193 ConvertToVersion2();
00194 fEncoded = (fEncoded & ~maskPlexSpotSpot) |
00195 ( ( spot << shftPlexSpotSpot ) & maskPlexSpotSpot );
00196 }
00197
00198
00199 inline Bool_t PlexPixelSpotId::IsValid() const
00200 {
00201
00202 return ( fEncoded & (zeroPlexMuxVersion&zeroPlexSpotTubePixelSpot) ) != defaultMuxBoxId;
00203 }
00204
00205 inline UInt_t PlexPixelSpotId::GetUniquePmtEncodedValue() const
00206 {
00207
00208 return fEncoded | maskPlexSpotSpot | maskPlexSpotPixel;
00209 }
00210
00211 inline UInt_t PlexPixelSpotId::GetUniquePixelEncodedValue() const
00212 {
00213
00214 return fEncoded | maskPlexSpotSpot;
00215 }
00216
00217 #endif
00218 #endif // PLEXPIXELSPOTID_H