00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #ifndef PLEXPINDIODEID_H
00013 #define PLEXPINDIODEID_H
00014
00015 #include "PlexMuxBoxId.h"
00016
00017
00018
00019
00020
00021 class PlexPinDiodeId;
00022 std::ostream& operator<<(std::ostream& os, const PlexPinDiodeId& p);
00023
00024 class PlexPinDiodeId : public PlexMuxBoxId {
00025
00026 public:
00027
00028 PlexPinDiodeId();
00029 PlexPinDiodeId(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 inbox, UInt_t gain);
00034 PlexPinDiodeId(PlexMuxBoxId muxbox,
00035 UInt_t inbox, UInt_t gain);
00036
00037
00038 virtual ~PlexPinDiodeId();
00039
00040
00041 explicit PlexPinDiodeId(const UInt_t encoded);
00042 inline UInt_t GetEncoded() const;
00043
00044 const char *AsString(Option_t *option="") const;
00045
00046 UShort_t GetInBox() const;
00047 UShort_t GetGain() const;
00048
00049 Bool_t IsHighGain() const { return GetGain()==0; }
00050 Bool_t IsLowGain() const { return GetGain()==1; }
00051
00052 Bool_t IsValid() const;
00053 #ifdef ENABLE_PINDIODEID_ISNULL
00054 Bool_t IsNull() const;
00055 #endif
00056
00057 void Print(Option_t *option="") const;
00058
00059 void SetInBox(UInt_t inbox);
00060 void SetGain(UInt_t gain);
00061
00062 friend Bool_t operator< (const PlexPinDiodeId &lhs, const PlexPinDiodeId &rhs);
00063 friend Bool_t operator<=(const PlexPinDiodeId &lhs, const PlexPinDiodeId &rhs);
00064 friend Bool_t operator==(const PlexPinDiodeId &lhs, const PlexPinDiodeId &rhs);
00065 friend Bool_t operator!=(const PlexPinDiodeId &lhs, const PlexPinDiodeId &rhs);
00066 friend Bool_t operator> (const PlexPinDiodeId &lhs, const PlexPinDiodeId &rhs);
00067 friend Bool_t operator>=(const PlexPinDiodeId &lhs, const PlexPinDiodeId &rhs);
00068
00069 #ifdef ENABLE_PINDIODEID_ENCODEMUXBOX
00070 static Int_t EncodeMuxBox(Char_t eastwest, Char_t racklevel,
00071 Int_t rackbay, Int_t inrack);
00072
00073 static void DecodeMuxBox(Int_t muxbox, Char_t& eastwest, Char_t& racklevel,
00074 Int_t& rackbay, Int_t& inrack);
00075 #endif
00076
00077 private:
00078
00079 ClassDef(PlexPinDiodeId,3)
00080 };
00081
00082 #ifndef __CINT__
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 const UInt_t maskPlexPinGain = 0x00000001;
00099 const UInt_t shftPlexPinGain = 0;
00100 const UInt_t maskPlexPinInBox = 0x000001FE;
00101 const UInt_t shftPlexPinInBox = 1;
00102
00103 const UInt_t zeroPlexPinGain = ~maskPlexPinGain;
00104 const UInt_t zeroPlexPinInBoxGain = ~(maskPlexPinInBox|maskPlexPinGain);
00105
00106
00107
00108 inline Bool_t operator< (const PlexPinDiodeId &lhs, const PlexPinDiodeId &rhs)
00109 { lhs.ConvertToVersion2(); rhs.ConvertToVersion2();
00110 return lhs.fEncoded < rhs.fEncoded; }
00111
00112 inline Bool_t operator<=(const PlexPinDiodeId &lhs, const PlexPinDiodeId &rhs)
00113 { lhs.ConvertToVersion2(); rhs.ConvertToVersion2();
00114 return lhs.fEncoded <= rhs.fEncoded; }
00115
00116 inline Bool_t operator==(const PlexPinDiodeId &lhs, const PlexPinDiodeId &rhs)
00117 { lhs.ConvertToVersion2(); rhs.ConvertToVersion2();
00118 return lhs.fEncoded == rhs.fEncoded; }
00119
00120 inline Bool_t operator!=(const PlexPinDiodeId &lhs, const PlexPinDiodeId &rhs)
00121 { lhs.ConvertToVersion2(); rhs.ConvertToVersion2();
00122 return lhs.fEncoded != rhs.fEncoded; }
00123
00124 inline Bool_t operator> (const PlexPinDiodeId &lhs, const PlexPinDiodeId &rhs)
00125 { lhs.ConvertToVersion2(); rhs.ConvertToVersion2();
00126 return lhs.fEncoded > rhs.fEncoded; }
00127
00128 inline Bool_t operator>=(const PlexPinDiodeId &lhs, const PlexPinDiodeId &rhs)
00129 { lhs.ConvertToVersion2(); rhs.ConvertToVersion2();
00130 return lhs.fEncoded >= rhs.fEncoded; }
00131
00132 inline UInt_t PlexPinDiodeId::GetEncoded() const
00133 { ConvertToVersion2(); return fEncoded; }
00134
00135 inline UShort_t PlexPinDiodeId::GetInBox() const
00136 {
00137 ConvertToVersion2();
00138 return (fEncoded & maskPlexPinInBox ) >> shftPlexPinInBox;
00139 }
00140
00141 inline UShort_t PlexPinDiodeId::GetGain() const
00142 {
00143 ConvertToVersion2();
00144 return (fEncoded & maskPlexPinGain ) >> shftPlexPinGain;
00145 }
00146
00147 inline void PlexPinDiodeId::SetInBox(UInt_t inbox)
00148 {
00149 ConvertToVersion2();
00150 fEncoded = (fEncoded & ~maskPlexPinInBox) |
00151 ( ( inbox << shftPlexPinInBox ) & maskPlexPinInBox );
00152 }
00153
00154 inline void PlexPinDiodeId::SetGain(UInt_t gain)
00155 {
00156 ConvertToVersion2();
00157 fEncoded = (fEncoded & ~maskPlexPinGain) |
00158 ( ( gain << shftPlexPinGain ) & maskPlexPinGain );
00159 }
00160
00161 inline Bool_t PlexPinDiodeId::IsValid() const
00162 {
00163
00164 return ( fEncoded & zeroPlexMuxVersion ) != defaultMuxBoxId;
00165
00166 }
00167
00168 #endif
00169 #endif // PLEXPINDIODEID_H