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

PlexStripEndId.h

Go to the documentation of this file.
00001 
00002 // $Id: PlexStripEndId.h,v 1.28 2005/08/26 18:47:04 rhatcher Exp $
00003 //
00004 // PlexStripEndId
00005 //
00006 // PlexStripEndId encapsulates strip end encoding
00007 //
00008 // Author:  R. Hatcher 2000.05.03
00009 //
00011 
00012 #ifndef PLEXSTRIPENDID_H
00013 #define PLEXSTRIPENDID_H
00014 
00015 #include <iosfwd>
00016 
00017 #include "Plex/PlexPlaneId.h"
00018 #include "Plex/PlexScintMdlId.h"
00019 #include "Conventions/StripEnd.h"
00020 
00021 class PlexStripEndId;
00022 std::ostream& operator<<(std::ostream& os, const PlexStripEndId& p);
00023 
00024 class PlexStripEndId : public PlexPlaneId {
00025 
00026  public:
00027 
00028    PlexStripEndId();                        // necessary for streamer io
00029    PlexStripEndId(PlexPlaneId plnid,
00030                   UInt_t strip,
00031                   StripEnd::StripEnd_t end=StripEnd::kUnknown,
00032                   StripEnd::StripEnd_t subpart=StripEnd::kWhole);
00033    PlexStripEndId(Detector::Detector_t detector,
00034                   UInt_t plane, UInt_t strip,
00035                   StripEnd::StripEnd_t end=StripEnd::kUnknown,
00036                   StripEnd::StripEnd_t subpart=StripEnd::kWhole,
00037                   PlaneView::PlaneView_t view=PlaneView::kUnknown,
00038                   PlaneCoverage::PlaneCoverage_t cover=PlaneCoverage::kUnknown);
00039 
00040    virtual ~PlexStripEndId() { ; } // no owned data members
00041 
00042    // use these two with caution as they work on the rawest level
00043    explicit PlexStripEndId(const UInt_t encoded);
00044    inline UInt_t            GetEncoded() const { return fEncoded; }
00045 
00046    const char              *AsString(Option_t *option="") const;
00047 
00048    StripEnd::StripEnd_t     GetEnd() const;
00049    UShort_t                 GetStrip() const;
00050    StripEnd::StripEnd_t     GetSubPart() const;
00051 
00052    PlexStripEndId           GetOppositeSEId() const;
00053    PlexScintMdlId           GetScintMdlId() const;
00054    UShort_t                 GetStripInMdl() const;
00055 
00056    // Conversion to construction based notation
00057    // note: GetStripInMdl returns 1-based numbering that flip flops
00058    // depending on installation of the module
00059    UShort_t                 GetMapperStripInMdl() const;
00060    // GetManifoldF1 is only relevant for Far detector
00061    // (and CalDet -- but it may be wrong for that)
00062    StripEnd::StripEnd_t     GetManifoldF1() const;
00063 
00064    // build a useful int of known size for use in further NavKey creation
00065    // includes just the Plane and Strip #'s
00066    Int_t                    Build18BitPlnStripKey() const;
00067    static PlexStripEndId    Unbuild18BitPlnStripKey(Detector::Detector_t det, Int_t key);
00068 
00069    // compactified plane,strip,end (assuming only east/west ends)
00070    // packed tightly, not simple bit shifts
00071    // 18 bits or less (unless Far has more than 682 planes)
00072    Int_t                    BuildPlnStripEndKey() const;
00073    static PlexStripEndId    UnbuildPlnStripEndKey(Detector::Detector_t det, Int_t key);
00074 
00075    // uncompactified, but unencumbered w/ end and subpart
00076    // and still usable for creating a PlexStripEndId (sets whole for both)
00077    UInt_t                   GetUniqueStripEncodedValue() const;
00078 
00079    Bool_t                   IsSameStrip(const PlexStripEndId &other) const;
00080    Bool_t                   IsSameStripEnd(const PlexStripEndId &other) const;
00081    Bool_t                   IsOppositeStripEnd(const PlexStripEndId &other) const;
00082 
00083    virtual Bool_t           IsValid() const;
00084 
00085    void                     Print(Option_t *option="") const;
00086 
00087    void                     SetEnd(StripEnd::StripEnd_t end);
00088    void                     SetStrip(UInt_t strip);
00089    void                     SetSubPart(StripEnd::StripEnd_t subpart);
00090 
00091    friend Bool_t operator< (const PlexStripEndId &lhs, const PlexStripEndId &rhs);
00092    friend Bool_t operator<=(const PlexStripEndId &lhs, const PlexStripEndId &rhs);
00093    friend Bool_t operator==(const PlexStripEndId &lhs, const PlexStripEndId &rhs);
00094    friend Bool_t operator!=(const PlexStripEndId &lhs, const PlexStripEndId &rhs);
00095    friend Bool_t operator> (const PlexStripEndId &lhs, const PlexStripEndId &rhs);
00096    friend Bool_t operator>=(const PlexStripEndId &lhs, const PlexStripEndId &rhs);
00097 
00098  protected:
00099 
00100  private:
00101 
00102    // hide PlexPlaneId's version of this member function
00103    // as this doesn't make sense for a PlexStripEndId
00104    void                     SetIsSteel(Bool_t /* isSteel */) {;}
00105 
00106    ClassDef(PlexStripEndId,3)
00107 };
00108 
00109 #ifndef __CINT__
00110 //==========================================================================
00111 // Implementation details 
00112 //==========================================================================
00113 
00114 inline Bool_t operator< (const PlexStripEndId &lhs, const PlexStripEndId &rhs)
00115 { return lhs.fEncoded <  rhs.fEncoded; }
00116 
00117 inline Bool_t operator<=(const PlexStripEndId &lhs, const PlexStripEndId &rhs)
00118 { return lhs.fEncoded <= rhs.fEncoded; }
00119 
00120 inline Bool_t operator==(const PlexStripEndId &lhs, const PlexStripEndId &rhs)
00121 { return lhs.fEncoded == rhs.fEncoded; }
00122 
00123 inline Bool_t operator!=(const PlexStripEndId &lhs, const PlexStripEndId &rhs)
00124 { return lhs.fEncoded != rhs.fEncoded; }
00125 
00126 inline Bool_t operator> (const PlexStripEndId &lhs, const PlexStripEndId &rhs)
00127 { return lhs.fEncoded >  rhs.fEncoded; }
00128 
00129 inline Bool_t operator>=(const PlexStripEndId &lhs, const PlexStripEndId &rhs)
00130 { return lhs.fEncoded >= rhs.fEncoded; }
00131 
00132 inline PlexStripEndId::PlexStripEndId() { fEncoded = defaultPlexStripEndId; }
00133 inline PlexStripEndId::PlexStripEndId(const UInt_t encoded) 
00134 { fEncoded = encoded; }
00135 
00136 inline StripEnd::StripEnd_t PlexStripEndId::GetEnd() const
00137 {
00138    Int_t bitField = ( fEncoded & maskPlexIdEnd ) >> shftPlexIdEnd;
00139    return (StripEnd::StripEnd_t) bitField;
00140 }
00141 
00142 inline UShort_t PlexStripEndId::GetStrip() const
00143 {
00144    return ( fEncoded & maskPlexIdStrip ) >> shftPlexIdStrip;
00145 }
00146 
00147 inline StripEnd::StripEnd_t PlexStripEndId::GetSubPart() const
00148 {
00149    Int_t bitField = ( fEncoded & maskPlexIdSubPart ) >> shftPlexIdSubPart;
00150    return (StripEnd::StripEnd_t) bitField;
00151 }
00152 
00153 inline UInt_t PlexStripEndId::GetUniqueStripEncodedValue() const
00154 {
00155    // uncompactified, but unencumbered w/ end and subpart
00156    // and still usable for creating a PlexStripEndId (sets kWhole for both)
00157   
00158   return
00159     ( fEncoded & ~(maskPlexIdEnd|maskPlexIdSubPart) )                 |
00160     ( ( StripEnd::kWhole << shftPlexIdSubPart ) & maskPlexIdSubPart ) |
00161     ( ( StripEnd::kWhole << shftPlexIdEnd      ) & maskPlexIdEnd    ) ;
00162                  
00163 }
00164 
00165 inline void PlexStripEndId::SetEnd(StripEnd::StripEnd_t end)
00166 {
00167    fEncoded = ( fEncoded & ~maskPlexIdEnd ) | 
00168       ( ( end << shftPlexIdEnd ) & maskPlexIdEnd );
00169 }
00170 
00171 inline void PlexStripEndId::SetStrip(UInt_t strip)
00172 {
00173    fEncoded = ( fEncoded & ~maskPlexIdStrip ) | 
00174       ( ( strip << shftPlexIdStrip ) & maskPlexIdStrip );
00175 }
00176 
00177 inline void PlexStripEndId::SetSubPart(StripEnd::StripEnd_t subpart)
00178 {
00179    fEncoded = ( fEncoded & ~maskPlexIdSubPart ) | 
00180       ( ( subpart << shftPlexIdSubPart ) & maskPlexIdSubPart );
00181 }
00182 
00183 #endif /* __CINT__ */
00184 #endif // PLEXSTRIPENDID_H

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