00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #ifndef RAWBLOCKID_H
00013 #define RAWBLOCKID_H
00014
00015 #include "Conventions/Detector.h"
00016 #include "Conventions/SimFlag.h"
00017
00018
00019 #include <iosfwd>
00020
00021 class RawBlockId;
00022 std::ostream& operator<<(std::ostream& os, const RawBlockId& rbid);
00023
00024 class RawBlockId {
00025
00026 public:
00027
00028 RawBlockId();
00029 RawBlockId(Int_t major, Int_t minor, Bool_t isDCS,
00030 Detector::Detector_t detector,
00031 SimFlag::SimFlag_t simflag);
00032
00033 virtual ~RawBlockId();
00034
00035
00036 RawBlockId(const Int_t encoded);
00037 inline Int_t GetEncoded() const;
00038
00039 const Char_t *AsString(Option_t *option="") const;
00040
00041 Int_t GetMajor() const;
00042 const Char_t *GetMajorAsString() const;
00043 Int_t GetMinor() const;
00044 Bool_t IsDCS() const;
00045 Detector::Detector_t GetDetector() const;
00046 SimFlag::SimFlag_t GetSimFlag() const;
00047
00048 void Print(Option_t *option="") const;
00049 virtual std::ostream& FormatToOStream(std::ostream& os,
00050 Option_t *option="") const;
00051
00052 friend Bool_t operator==(const RawBlockId &lhs, const RawBlockId &rhs);
00053 friend Bool_t operator!=(const RawBlockId &lhs, const RawBlockId &rhs);
00054
00055 protected:
00056
00057 Int_t fEncoded;
00058
00059 private:
00060
00061 ClassDef(RawBlockId,1)
00062 };
00063
00064 #if !defined(__CINT__) || defined(__MAKECINT__)
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 const Int_t defaultRawBlockId = 0;
00086
00087 const Int_t shiftRawBlkIdMinor = 0;
00088 const Int_t shiftRawBlkIdMajor = 8;
00089 const Int_t shiftRawBlkIdIsDCS = 24;
00090 const Int_t shiftRawBlkIdDetector = 25;
00091 const Int_t shiftRawBlkIdCSimFlag = 28;
00092
00093 const Int_t maskRawBlkIdMinor = 0x000000ff;
00094 const Int_t maskRawBlkIdMajor = 0x00ffff00;
00095 const Int_t maskRawBlkIdIsDCS = 0x01000000;
00096 const Int_t maskRawBlkIdDetector = 0x0e000000;
00097 const Int_t maskRawBlkIdCSimFlag = 0x30000000;
00098
00099
00100
00101 inline Bool_t operator==(const RawBlockId &lhs, const RawBlockId &rhs)
00102 { return (lhs.fEncoded) == (rhs.fEncoded); }
00103
00104 inline Bool_t operator!=(const RawBlockId &lhs, const RawBlockId &rhs)
00105 { return (lhs.fEncoded) != (rhs.fEncoded); }
00106
00107 inline RawBlockId::RawBlockId() : fEncoded(defaultRawBlockId) { ; }
00108 inline RawBlockId::~RawBlockId() { ; }
00109
00110 inline RawBlockId::RawBlockId(const Int_t encoded) : fEncoded(encoded) { ; }
00111 inline Int_t RawBlockId::GetEncoded() const
00112 { return fEncoded; }
00113
00114 inline Int_t RawBlockId::GetMajor() const
00115 { return (fEncoded & maskRawBlkIdMajor) >> shiftRawBlkIdMajor; }
00116
00117 inline Int_t RawBlockId::GetMinor() const
00118 { return (fEncoded & maskRawBlkIdMinor) >> shiftRawBlkIdMinor; }
00119
00120 inline Bool_t RawBlockId::IsDCS() const
00121 {
00122 return (fEncoded & maskRawBlkIdIsDCS) >> shiftRawBlkIdIsDCS;
00123 }
00124
00125 inline Detector::Detector_t RawBlockId::GetDetector() const
00126 {
00127 Int_t bitField = (fEncoded & maskRawBlkIdDetector) >> shiftRawBlkIdDetector;
00128 return (Detector::Detector_t) bitField;
00129 }
00130
00131 inline SimFlag::SimFlag_t RawBlockId::GetSimFlag() const
00132 {
00133 Int_t bitField = (fEncoded & maskRawBlkIdCSimFlag) >> shiftRawBlkIdCSimFlag;
00134 return SimFlag::Expand(bitField);
00135 }
00136 #endif // !__CINT__
00137
00138 #endif // RAWBLOCKID_H