00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012
00013 #ifndef RAWCHANNELID_H
00014 #define RAWCHANNELID_H
00015
00016 #include "Conventions/Detector.h"
00017 #include "Conventions/ElecType.h"
00018
00019
00020 #include <iosfwd>
00021
00022 class RawChannelId;
00023 std::ostream& operator<<(std::ostream& os, const RawChannelId& rcid);
00024
00025 class RawChannelId {
00026
00027 public:
00028
00029 RawChannelId();
00030
00031 #define RAWCHANNELID_NEW_CTOR 1 // new ctors drop pedmode,commonmode flags
00032
00033
00034 RawChannelId(Detector::Detector_t detector, ElecType::Elec_t etype,
00035 UInt_t crate, UInt_t chadd);
00036
00037
00038
00039 RawChannelId(Detector::Detector_t detector, ElecType::Elec_t etype,
00040 UInt_t crate, UInt_t geoaddr,
00041 UInt_t masterChan, UInt_t minderChan);
00042
00043
00044 RawChannelId(Detector::Detector_t detector, ElecType::Elec_t etype,
00045 UInt_t crate, UInt_t varc, UInt_t vmm,
00046 UInt_t adcsel, UInt_t vachip, UInt_t vachan);
00047
00048
00049 RawChannelId(Detector::Detector_t detector,
00050 UInt_t crateinfo,UInt_t chadd);
00051
00052
00053 virtual ~RawChannelId() { ; }
00054
00055
00056 RawChannelId(const UInt_t encoded);
00057 inline UInt_t GetEncoded() const { return fEncoded; }
00058
00059 const char *AsString(Option_t *option="") const;
00060
00061 Detector::Detector_t GetDetector() const;
00062 ElecType::Elec_t GetElecType() const;
00063 Bool_t GetPedMode() const;
00064 Bool_t GetSparsMode() const;
00065 Bool_t GetCommonMode() const;
00066 UShort_t GetCrate() const;
00067 UShort_t GetChAdd() const;
00068
00069
00070 UShort_t GetGeographicAddress() const;
00071 UShort_t GetMasterChannel() const;
00072 UShort_t GetMinderChannel() const;
00073
00074 UShort_t GetMaster() const {return GetGeographicAddress();}
00075 UShort_t GetMinder() const {return GetMasterChannel();}
00076 UShort_t GetMenu() const {return GetMinderChannel();}
00077
00078
00079 UShort_t GetVarcId() const;
00080 UShort_t GetVfb() const;
00081 UShort_t GetVmm() const;
00082 UShort_t GetVaAdcSel() const;
00083 UShort_t GetVaChip() const;
00084 UShort_t GetVaChannel() const;
00085
00086 virtual void Print(Option_t *option="") const;
00087 virtual std::ostream& FormatToOStream(std::ostream& os,
00088 Option_t *option="") const;
00089
00090
00091 Bool_t IsSameChannel(const RawChannelId &other) const;
00092 Bool_t IsSameCrate(const RawChannelId &other) const;
00093
00094 Bool_t IsSameVAChip(const RawChannelId &other) const;
00095 Bool_t IsSameVfb(const RawChannelId &other) const;
00096
00097 Bool_t IsSameMinder(const RawChannelId &other) const;
00098
00099
00100 friend Bool_t operator< (const RawChannelId &lhs, const RawChannelId &rhs);
00101 friend Bool_t operator==(const RawChannelId &lhs, const RawChannelId &rhs);
00102 friend Bool_t operator!=(const RawChannelId &lhs, const RawChannelId &rhs);
00103
00104 Bool_t IsNull() const;
00105
00106 void SetDetector(Detector::Detector_t detector);
00107 void SetElecType(ElecType::Elec_t etype);
00108 void SetPedMode(Bool_t pedmode);
00109 void SetSparsMode(Bool_t sparsmode);
00110 void SetCommonMode(Bool_t commonmode);
00111 void SetModeBits(Bool_t commonmode, Bool_t sparsmode, Bool_t pedmode);
00112 void ClearModeBits();
00113 void SetCrate(UInt_t crate);
00114 void SetChAdd(UInt_t chadd);
00115
00116
00117 void SetGeographicAddress(UInt_t geoaddr);
00118 void SetMasterChannel(UInt_t master);
00119 void SetMinderChannel(UInt_t minder);
00120
00121
00122 void SetVarcId(UInt_t varc);
00123 void SetVmm(UInt_t vmm);
00124 void SetVaAdcSel(UInt_t adcsel);
00125 void SetVaChip(UInt_t vachip);
00126 void SetVaChannel(UInt_t vachan);
00127
00128
00129
00130 static Int_t CalcChAdd(UInt_t geo, UInt_t master, UInt_t minder);
00131 static Int_t CalcChAdd(UInt_t varcid, UInt_t vmm, UInt_t adcsel,
00132 UInt_t vachip, UInt_t vachan);
00133 static void DecompChAdd(UInt_t chadd, UInt_t& geo,
00134 UInt_t& master, UInt_t& minder);
00135 static void DecompChAdd(UInt_t chadd, UInt_t& varcid, UInt_t& vmm,
00136 UInt_t& adcsel, UInt_t& vachip, UInt_t& vachan);
00137
00138 protected:
00139
00140 void Init(Detector::Detector_t detector, ElecType::Elec_t etype,
00141 UInt_t crate, UInt_t chadd);
00142
00143 Bool_t CheckElecType(ElecType::Elec_t etype, const char* from = "");
00144
00145 static UInt_t ConvertEncodedToVersion2(UInt_t encoded);
00146 void ConvertToVersion2(Bool_t inStreamerRead=false) const;
00147
00148 UInt_t fEncoded;
00149
00150 private:
00151
00152 ClassDef(RawChannelId,2)
00153 };
00154
00155
00156
00157 inline Bool_t operator< (const RawChannelId &lhs, const RawChannelId &rhs)
00158 {
00159 lhs.ConvertToVersion2(); rhs.ConvertToVersion2();
00160 return lhs.fEncoded < rhs.fEncoded;
00161 }
00162
00163 inline Bool_t operator==(const RawChannelId &lhs, const RawChannelId &rhs)
00164 {
00165 lhs.ConvertToVersion2(); rhs.ConvertToVersion2();
00166 return lhs.fEncoded == rhs.fEncoded;
00167 }
00168
00169 inline Bool_t operator!=(const RawChannelId &lhs, const RawChannelId &rhs)
00170 {
00171 lhs.ConvertToVersion2(); rhs.ConvertToVersion2();
00172 return lhs.fEncoded != rhs.fEncoded;
00173 }
00174
00175 const UInt_t defaultRawChannelId = 0;
00176
00177 inline RawChannelId::RawChannelId() : fEncoded(defaultRawChannelId) { ; }
00178 inline RawChannelId::RawChannelId(UInt_t encoded) : fEncoded(encoded) { ; }
00179
00180 #endif // RAWCHANNELID_H