3 /** @file AliFMDIndex.h
4 @author Christian Holm Christensen <cholm@nbi.dk>
5 @date Mon Mar 27 12:37:41 2006
6 @brief FMD detector coordinates
8 //___________________________________________________________________
10 // Class that holds an FMD index. That is, it holds the detector
11 // coordinates for a given strip:
13 // Variable | Type | Range | Description
14 // ---------+----------+---------+------------------
15 // detector | UShort_t | 1-3 | Detector number
16 // ring | Char_t | 'I'/'O' | Ring identifier
17 // sector | UShort_t | 0-39 | Sector number
18 // strip | UShort_t | 0-511 | Strip number
31 //____________________________________________________________________
32 /** @class AliFMDIndex AliFMDIndex.h <FMD/AliFMDIndex.h>
33 @brief FMD detector coordinates
42 @param o Object to copy from */
43 AliFMDIndex(const AliFMDIndex& o);
45 @param detector Detector
49 AliFMDIndex(UShort_t detector,
53 /** Assignment operator
54 @param o Object to assign from
55 @return Reference to this object */
56 AliFMDIndex& operator=(const AliFMDIndex& o);
57 /** Comparison operator
58 @param o Object to compare to
59 @return @c true if these refer to the same index */
60 bool operator==(const AliFMDIndex& o) const;
61 /** Comparison operator
62 @param o Object to compare to
63 @return @c true if this is smaller than @a o */
64 bool operator<(const AliFMDIndex& o) const;
66 virtual ~AliFMDIndex() {}
67 /** @return Detector # */
68 UShort_t Detector() const { return fDetector; }
69 /** @return Ring ID */
70 Char_t Ring() const { return fRing; }
71 /** @return sector # */
72 UShort_t Sector() const { return fSector; }
73 /** @return strip # */
74 UShort_t Strip() const { return fStrip; }
75 /** @param x Detector # */
76 void SetDetector(UShort_t x) { fHash = -1; fDetector = x; }
77 /** @param x Ring ID */
78 void SetRing(Char_t x) { fHash = -1; fRing = x; }
79 /** @param x sector # */
80 void SetSector(UShort_t x) { fHash = -1; fSector = x; }
81 /** @param x strip # */
82 void SetStrip(UShort_t x) { fHash = -1; fStrip = x; }
84 @param opt Not used */
85 virtual void Print(Option_t* opt="") const;
87 const char* Name() const;
90 UShort_t fDetector; // (Sub) Detector # (1,2, or 3)
91 Char_t fRing; // Ring ID ('I' or 'O')
92 UShort_t fSector; // Sector # (phi division)
93 UShort_t fStrip; // Strip # (radial division)
94 mutable TString fName; //! Cached name
95 mutable Int_t fHash; //! Cached hash value
96 ClassDef(AliFMDIndex, 1) // Base class for FMD digits
99 //____________________________________________________________________
100 class AliFMDObjIndex : public TObject, public AliFMDIndex
106 @param o Object to copy from */
107 AliFMDObjIndex(const AliFMDObjIndex& o) : TObject(o), AliFMDIndex(o) {}
108 /** Construct from a pure index
109 @param o Object to copy from */
110 explicit AliFMDObjIndex(const AliFMDIndex& o) : AliFMDIndex(o) {}
112 @param detector Detector
115 @param strip Strip */
116 AliFMDObjIndex(UShort_t detector,
120 : AliFMDIndex(detector, ring, sector, strip)
123 virtual ~AliFMDObjIndex() {}
124 AliFMDObjIndex& operator=(const AliFMDObjIndex& o)
126 if (&o == this) return *this;
127 AliFMDIndex::operator=(o);
131 virtual const char* GetName() const { return AliFMDIndex::Name(); }
132 /** sort compare for TCollection's
133 @param o Object to compare to
134 @return -1 if this is @e smaller than @a o, 0 if @e equal to
135 @a o, and 1 if this is @e larger than @a o */
136 virtual Int_t Compare(const TObject* o) const;
137 /** @return always true */
138 Bool_t IsSortable() const { return kTRUE; }
139 ClassDef(AliFMDObjIndex, 1) // Base class for FMD digits
142 //____________________________________________________________________
145 AliFMDIndex::operator==(const AliFMDIndex& o) const
147 return (o.Hash() == Hash());
150 //____________________________________________________________________
153 AliFMDIndex::operator<(const AliFMDIndex& rhs) const
155 return (Hash() < rhs.Hash());
159 //____________________________________________________________________
162 operator<(const AliFMDIndex& lhs, const AliFMDIndex& rhs)
164 return (lhs.Detector() < rhs.Detector() ? true :
165 (lhs.Ring() < rhs.Ring() ? true :
166 (lhs.Sector() < rhs.Sector() ? true :
167 (lhs.Strip() < rhs.Strip() ? true : false))));
171 //____________________________________________________________________