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

RawChannelId.h

Go to the documentation of this file.
00001 
00002 // $Id: RawChannelId.h,v 1.31 2005/08/26 19:04:53 rhatcher Exp $
00003 // 
00004 // RawChannelId 
00005 // 
00006 // RawChannelId is the base class for a channel # of a raw digit
00007 // ElecType::Elec_t either kQIE or kVA (Viking data)
00008 //
00009 // Author:  R. Hatcher 2000.04.19
00010 //
00012 
00013 #ifndef RAWCHANNELID_H
00014 #define RAWCHANNELID_H
00015 
00016 #include "Conventions/Detector.h"
00017 #include "Conventions/ElecType.h"
00018 
00019 // make the RawChannelId cout'able
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    // ctor from ChAdd
00034    RawChannelId(Detector::Detector_t detector, ElecType::Elec_t etype,
00035                          UInt_t crate, UInt_t chadd);
00036 
00037    // ctor from QIE components
00038    // note GeoAddr==Master  MasterCh=Minder  MinderCh=Menu
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    // ctor from VA components
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    // ctor from CrateId (w/ mode bits) & ChAdd
00049    RawChannelId(Detector::Detector_t detector, 
00050                          UInt_t crateinfo,UInt_t chadd);
00051 
00052    // non-virtual dtor would be okay, but ClassDef brings in virtualness
00053    virtual ~RawChannelId() { ; } // no owned data members
00054 
00055    // use these two with caution as they work on the rawest level
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    // if ElecType == kQIE
00070    UShort_t                 GetGeographicAddress() const;
00071    UShort_t                 GetMasterChannel() const;
00072    UShort_t                 GetMinderChannel() const;
00073    // alternatives
00074    UShort_t                 GetMaster() const {return GetGeographicAddress();}
00075    UShort_t                 GetMinder() const {return GetMasterChannel();}
00076    UShort_t                 GetMenu() const   {return GetMinderChannel();}
00077 
00078    // if ElecType == kVA
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    /* these tests do NOT include ped/sparse/common mode components */
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    /* these comparisons include ped/common mode components */
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    // if ElecType == kQIE
00117    void SetGeographicAddress(UInt_t geoaddr);
00118    void SetMasterChannel(UInt_t master);
00119    void SetMinderChannel(UInt_t minder);
00120 
00121    // if ElecType == kVA
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    // static methods for (de)constructing ChAdd (to/)from components 
00129    // for both QIE and VA electronics
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; // logical const
00147 
00148    UInt_t    fEncoded;  // encoded value
00149 
00150  private:
00151 
00152    ClassDef(RawChannelId,2)  // detector,electronics,crate,chanAddr
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

Generated on Fri Mar 28 15:38:28 2008 for loon by  doxygen 1.3.9.1