This is a backward incompatible change in AliRoot. The following methods have been...
[u/mrichter/AliRoot.git] / FMD / AliFMDIndex.h
CommitLineData
55f0ce5b 1#ifndef ALIFMDINDEX_H
2#define ALIFMDINDEX_H
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
7*/
8//___________________________________________________________________
9//
10// Class that holds an FMD index. That is, it holds the detector
11// coordinates for a given strip:
12//
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
19//
20#ifndef ROOT_Rtypes
21# include <Rtypes.h>
22#endif
23#ifndef ROOT_TObject
24# include <TObject.h>
25#endif
26#ifndef ROOT_TString
27# include <TString.h>
28#endif
29#include <iosfwd>
30
31//____________________________________________________________________
32/** @class AliFMDIndex AliFMDIndex.h <FMD/AliFMDIndex.h>
33 @brief FMD detector coordinates
34 @ingroup FMD_base
35 */
36class AliFMDIndex
37{
38public:
39 /** CTOR */
40 AliFMDIndex();
41 /** Copy CTOR
42 @param o Object to copy from */
43 AliFMDIndex(const AliFMDIndex& o);
44 /** Constrctor
45 @param detector Detector
46 @param ring Ring
47 @param sector Sector
48 @param strip Strip */
49 AliFMDIndex(UShort_t detector,
50 Char_t ring='\0',
51 UShort_t sector=0,
52 UShort_t strip=0);
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;
65 /** DTOR */
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; }
83 /** Print information
84 @param opt Not used */
85 virtual void Print(Option_t* opt="") const;
86 /** @return Name */
87 const char* Name() const;
88protected:
89 Int_t Hash() 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
97};
98
99//____________________________________________________________________
100class AliFMDObjIndex : public TObject, public AliFMDIndex
101{
102public:
103 /** CTOR */
104 AliFMDObjIndex() {}
105 /** Copy CTOR
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) {}
111 /** Constrctor
112 @param detector Detector
113 @param ring Ring
114 @param sector Sector
115 @param strip Strip */
116 AliFMDObjIndex(UShort_t detector,
117 Char_t ring='\0',
118 UShort_t sector=0,
119 UShort_t strip=0)
120 : AliFMDIndex(detector, ring, sector, strip)
121 {}
122 /** DTOR */
123 virtual ~AliFMDObjIndex() {}
124 /** @return name */
125 virtual const char* GetName() const { return AliFMDIndex::Name(); }
126 /** sort compare for TCollection's
127 @param o Object to compare to
128 @return -1 if this is @e smaller than @a o, 0 if @e equal to
129 @a o, and 1 if this is @e larger than @a o */
130 virtual Int_t Compare(const TObject* o) const;
131 /** @return always true */
132 Bool_t IsSortable() const { return kTRUE; }
133 ClassDef(AliFMDObjIndex, 1) // Base class for FMD digits
134};
135
136//____________________________________________________________________
137inline
138bool
139AliFMDIndex::operator==(const AliFMDIndex& o) const
140{
141 return (o.Hash() == Hash());
142}
143
144//____________________________________________________________________
145inline
146bool
147AliFMDIndex::operator<(const AliFMDIndex& rhs) const
148{
149 return (Hash() < rhs.Hash());
150}
151
152#if 0
153//____________________________________________________________________
154inline
155bool
156operator<(const AliFMDIndex& lhs, const AliFMDIndex& rhs)
157{
158 return (lhs.Detector() < rhs.Detector() ? true :
159 (lhs.Ring() < rhs.Ring() ? true :
160 (lhs.Sector() < rhs.Sector() ? true :
161 (lhs.Strip() < rhs.Strip() ? true : false))));
162}
163#endif
164#endif
165//____________________________________________________________________
166//
167// Local Variables:
168// mode: C++
169// End:
170//
171//
172// EOF
173//