Bug fix
[u/mrichter/AliRoot.git] / FMD / AliFMDIndex.cxx
CommitLineData
55f0ce5b 1/**************************************************************************
2 * Copyright(c) 2004, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15/* $Id$ */
16/** @file AliFMDDigit.cxx
17 @author Christian Holm Christensen <cholm@nbi.dk>
18 @date Mon Mar 27 12:37:41 2006
19 @brief Digits for the FMD
20*/
21//////////////////////////////////////////////////////////////////////
22//
23// Class that holds an FMD index. That is, it holds the detector
24// coordinates for a given strip:
25//
26// Variable | Type | Range | Description
27// ---------+----------+---------+------------------
28// detector | UShort_t | 1-3 | Detector number
29// ring | Char_t | 'I'/'O' | Ring identifier
30// sector | UShort_t | 0-39 | Sector number
31// strip | UShort_t | 0-511 | Strip number
32//
33//////////////////////////////////////////////////////////////////////
34
35#include "AliFMDIndex.h" // ALIFMDINDEX_H
36#include "Riostream.h" // ROOT_Riostream
37#include <TString.h> // ROOT_TString
38#include <AliFMDMap.h>
39
40//====================================================================
41ClassImp(AliFMDIndex)
42#if 0
43 ; // This is here to keep Emacs from indenting the next line
44#endif
45
46//____________________________________________________________________
47AliFMDIndex::AliFMDIndex()
48 : fDetector(0),
49 fRing('\0'),
50 fSector(0),
51 fStrip(0),
b5ee4425 52 fName(""),
53 fHash(-1)
02a27b50 54{
55 // CTOR
56}
55f0ce5b 57
58//____________________________________________________________________
59AliFMDIndex::AliFMDIndex(const AliFMDIndex& o)
60 : fDetector(o.fDetector),
61 fRing(o.fRing),
62 fSector(o.fSector),
63 fStrip(o.fStrip),
b5ee4425 64 fName(""),
55f0ce5b 65 fHash(o.fHash)
66{
67 // Copy constructor
68}
69
70//____________________________________________________________________
71AliFMDIndex::AliFMDIndex(UShort_t detector,
72 Char_t ring,
73 UShort_t sector,
74 UShort_t strip)
75 : fDetector(detector),
76 fRing(ring),
77 fSector(sector),
78 fStrip(strip),
b5ee4425 79 fName(""),
55f0ce5b 80 fHash(-1)
81{
82 //
83 // Creates a base data digit object
84 //
85 // Parameters
86 //
87 // detector Detector # (1, 2, or 3)
88 // ring Ring ID ('I' or 'O')
89 // sector Sector # (For inner/outer rings: 0-19/0-39)
90 // strip Strip # (For inner/outer rings: 0-511/0-255)
91}
92
93//____________________________________________________________________
94AliFMDIndex&
95AliFMDIndex::operator=(const AliFMDIndex& o)
96{
97 // Assignment operator
98 fDetector = o.fDetector;
99 fRing = o.fRing;
100 fSector = o.fSector;
101 fStrip = o.fStrip;
102 fHash = o.fHash;
103 return *this;
104}
105
106//____________________________________________________________________
107Int_t
108AliFMDIndex::Hash() const
109{
02a27b50 110 // calculate hash value
55f0ce5b 111 if (fHash < 0) {
112 size_t ringi = (fRing == 'I' || fRing == 'i' ? 0 : 1);
113 fHash = (fStrip +
114 AliFMDMap::kMaxStrips *
115 (fSector + AliFMDMap::kMaxSectors *
116 (ringi + AliFMDMap::kMaxRings * (fDetector-1))));
117 }
118 return fHash;
119}
120
121
122//____________________________________________________________________
123void
124AliFMDIndex::Print(Option_t* /* option*/) const
125{
126 // Print digit to standard out
127 cout << Name() << flush;
128}
129
130//____________________________________________________________________
131const char*
132AliFMDIndex::Name() const
133{
02a27b50 134 // GEt the name of the index
55f0ce5b 135 if (fName.IsNull())
136 fName = Form("FMD%d%c[%2d,%3d]", fDetector, fRing, fSector, fStrip);
137 return fName.Data();
138}
139
140//====================================================================
141ClassImp(AliFMDObjIndex)
142#if 0
143 ; // This is here to keep Emacs from indenting the next line
144#endif
145
146//____________________________________________________________________
147Int_t
148AliFMDObjIndex::Compare(const TObject* o) const
149{
02a27b50 150 // Compare to another index
55f0ce5b 151 const AliFMDObjIndex* a = dynamic_cast<const AliFMDObjIndex*>(o);
152 if (!a) {
153 Fatal("Compare",
154 "trying to compare to something not a AliFMDObjIndex object, "
155 "but a %s object", o->ClassName());
156 return 0;
157 }
158 if (this->operator<(*a)) return -1;
159 if (this->operator==(*a)) return 0;
160 return 1;
161}
162
163//____________________________________________________________________
164//
165// EOF
166//