Export hit structure header
[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() {}
d015ecfe 124 AliFMDObjIndex& operator=(const AliFMDObjIndex& o)
125 {
126 if (&o == this) return *this;
127 AliFMDIndex::operator=(o);
128 return *this;
129 }
55f0ce5b 130 /** @return name */
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
140};
141
142//____________________________________________________________________
143inline
144bool
145AliFMDIndex::operator==(const AliFMDIndex& o) const
146{
147 return (o.Hash() == Hash());
148}
149
150//____________________________________________________________________
151inline
152bool
153AliFMDIndex::operator<(const AliFMDIndex& rhs) const
154{
155 return (Hash() < rhs.Hash());
156}
157
158#if 0
159//____________________________________________________________________
160inline
161bool
162operator<(const AliFMDIndex& lhs, const AliFMDIndex& rhs)
163{
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))));
168}
169#endif
170#endif
171//____________________________________________________________________
172//
173// Local Variables:
174// mode: C++
175// End:
176//
177//
178// EOF
179//