Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

PlexPixelSpotId.h

Go to the documentation of this file.
00001 
00002 // $Id: PlexPixelSpotId.h,v 1.17 2005/08/26 18:47:03 rhatcher Exp $
00003 //
00004 // PlexPixelSpotId
00005 //
00006 // PlexPixelSpotId encapsulates mux/tube/pixel/spot number encoding
00007 //
00008 // Author:  R. Hatcher 2001.06.26
00009 //
00011 
00012 #ifndef PLEXPIXELSPOTID_H
00013 #define PLEXPIXELSPOTID_H
00014 
00015 #include "PlexMuxBoxId.h"
00016 
00017 // for now include obsolete methods
00018 //#define ENABLE_PIXELSPOTID_ISNULL
00019 //#define ENABLE_PIXELSPOTID_ENCODEMUXBOX
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();                        // necessary for streamer io
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    // non-virtual dtor would be okay, but ClassDef brings in virtualness
00038    virtual ~PlexPixelSpotId();
00039 
00040    // use these two with caution as they work on the rawest level
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    // uncompactified, but unencumbered w/ spot, +pixel 
00056    // (set unused bits on to avoid spot=0 --> broken fiber convention)
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 // Implementation details 
00092 //==========================================================================
00093 //
00094 // The details of the encoding of PlexPixelSpotId are here in 
00095 // PlexPixelSpotId.h; this is so that the compiler can inline the code
00096 // Users should NOT rely on intimate knowledge of these details.
00097 //
00098 //    MSB                          LSB
00099 //     3         2         1         0
00100 //    10987654321098765432109876543210
00101 //    ddddeemmmmmmmmmmmmttppppppppssss  old pixel spot id
00102 //    vdddeeWELLBBBBBIIIIttpppppppssss  new pixel spot id
00103 //    77776666555544443333222211110000
00104 //
00105 
00106 const UInt_t maskPlexSpotSpot        = 0x0000000f;  // 0:15 0=broken
00107 const UInt_t shftPlexSpotSpot        = 0;
00108 const UInt_t maskPlexSpotPixel       = 0x000007f0;  // 0:127
00109 const UInt_t shftPlexSpotPixel       = 4;
00110 const UInt_t maskPlexSpotTube        = 0x00001800;  // 0:3
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 // Determine if "this" and "other" are the same pixel (ignoring "spot" info)
00145 inline Bool_t PlexPixelSpotId::IsSamePixel(const PlexPixelSpotId &other) const
00146 { ConvertToVersion2(); other.ConvertToVersion2();
00147   return (fEncoded&zeroPlexSpotSpot) == (other.fEncoded&zeroPlexSpotSpot); }
00148 
00149 // Determine if "this" and "other" are the same tube 
00150 // (ignoring "pxiel+spot" info)
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   // test whether this is the nonsensical default value
00202   return ( fEncoded & (zeroPlexMuxVersion&zeroPlexSpotTubePixelSpot) ) != defaultMuxBoxId;
00203 }
00204 
00205 inline UInt_t PlexPixelSpotId::GetUniquePmtEncodedValue() const
00206 {
00207   // uncompatified, but unique for a PMT independent of pixel/spot
00208   return fEncoded | maskPlexSpotSpot | maskPlexSpotPixel;
00209 }
00210 
00211 inline UInt_t PlexPixelSpotId::GetUniquePixelEncodedValue() const
00212 {
00213   // uncompatified, but unique for a PMT independent of spot
00214   return fEncoded | maskPlexSpotSpot;
00215 }
00216 
00217 #endif /* __CINT__ */
00218 #endif // PLEXPIXELSPOTID_H

Generated on Mon Feb 15 11:07:22 2010 for loon by  doxygen 1.3.9.1