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

RawBlockId.h

Go to the documentation of this file.
00001 
00002 // $Id: RawBlockId.h,v 1.12 2005/08/26 19:04:53 rhatcher Exp $
00003 //
00004 // RawBlockId
00005 //
00006 // RawBlockId encapsulates raw block-ids
00007 //
00008 // Author:  R. Hatcher 2001.04.12
00009 //
00011 
00012 #ifndef RAWBLOCKID_H
00013 #define RAWBLOCKID_H
00014 
00015 #include "Conventions/Detector.h"
00016 #include "Conventions/SimFlag.h"
00017 
00018 // make the RawBlockId cout'able
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    // use these two with caution as they work on the rawest level
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;  // encoded value
00058 
00059  private:
00060 
00061    ClassDef(RawBlockId,1)
00062 };
00063 
00064 #if !defined(__CINT__) || defined(__MAKECINT__)
00065 
00066 //==========================================================================
00067 // Implementation details 
00068 //==========================================================================
00069 //
00070 // The details of the encoding of RawBlockId are here in RawBlockId.h;
00071 // this is so that the compiler can inline the code.
00072 // Users should NOT rely on intimate knowledge of these details.
00073 //
00074 //    MSB                          LSB
00075 //     3         2         1         0
00076 //    10987654321098765432109876543210
00077 //    --xxCFNSMMMMMMMMMMMMMMMMmmmmmmmm
00078 //
00079 //         xx: compactSimFlag: {00=data, 01=fakedaqdata, 10=MC, 11=Reroot}
00080 //        CFN: Detector & 0x07 (CalDet,Far,Near bits)
00081 //          S: Source (0=DAQ, 1=DCS)
00082 //   MMMMMMMM: major block id
00083 //   mmmmmmmm: minor block id
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

Generated on Sat Nov 21 22:47:28 2009 for loon by  doxygen 1.3.9.1