]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/AliFMDIndex.cxx
Updates (N. Bastid)
[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),
52 fHash(-1)
02a27b50 53{
54 // CTOR
55}
55f0ce5b 56
57//____________________________________________________________________
58AliFMDIndex::AliFMDIndex(const AliFMDIndex& o)
59 : fDetector(o.fDetector),
60 fRing(o.fRing),
61 fSector(o.fSector),
62 fStrip(o.fStrip),
63 fHash(o.fHash)
64{
65 // Copy constructor
66}
67
68//____________________________________________________________________
69AliFMDIndex::AliFMDIndex(UShort_t detector,
70 Char_t ring,
71 UShort_t sector,
72 UShort_t strip)
73 : fDetector(detector),
74 fRing(ring),
75 fSector(sector),
76 fStrip(strip),
77 fHash(-1)
78{
79 //
80 // Creates a base data digit object
81 //
82 // Parameters
83 //
84 // detector Detector # (1, 2, or 3)
85 // ring Ring ID ('I' or 'O')
86 // sector Sector # (For inner/outer rings: 0-19/0-39)
87 // strip Strip # (For inner/outer rings: 0-511/0-255)
88}
89
90//____________________________________________________________________
91AliFMDIndex&
92AliFMDIndex::operator=(const AliFMDIndex& o)
93{
94 // Assignment operator
95 fDetector = o.fDetector;
96 fRing = o.fRing;
97 fSector = o.fSector;
98 fStrip = o.fStrip;
99 fHash = o.fHash;
100 return *this;
101}
102
103//____________________________________________________________________
104Int_t
105AliFMDIndex::Hash() const
106{
02a27b50 107 // calculate hash value
55f0ce5b 108 if (fHash < 0) {
109 size_t ringi = (fRing == 'I' || fRing == 'i' ? 0 : 1);
110 fHash = (fStrip +
111 AliFMDMap::kMaxStrips *
112 (fSector + AliFMDMap::kMaxSectors *
113 (ringi + AliFMDMap::kMaxRings * (fDetector-1))));
114 }
115 return fHash;
116}
117
118
119//____________________________________________________________________
120void
121AliFMDIndex::Print(Option_t* /* option*/) const
122{
123 // Print digit to standard out
124 cout << Name() << flush;
125}
126
127//____________________________________________________________________
128const char*
129AliFMDIndex::Name() const
130{
02a27b50 131 // GEt the name of the index
55f0ce5b 132 if (fName.IsNull())
133 fName = Form("FMD%d%c[%2d,%3d]", fDetector, fRing, fSector, fStrip);
134 return fName.Data();
135}
136
137//====================================================================
138ClassImp(AliFMDObjIndex)
139#if 0
140 ; // This is here to keep Emacs from indenting the next line
141#endif
142
143//____________________________________________________________________
144Int_t
145AliFMDObjIndex::Compare(const TObject* o) const
146{
02a27b50 147 // Compare to another index
55f0ce5b 148 const AliFMDObjIndex* a = dynamic_cast<const AliFMDObjIndex*>(o);
149 if (!a) {
150 Fatal("Compare",
151 "trying to compare to something not a AliFMDObjIndex object, "
152 "but a %s object", o->ClassName());
153 return 0;
154 }
155 if (this->operator<(*a)) return -1;
156 if (this->operator==(*a)) return 0;
157 return 1;
158}
159
160//____________________________________________________________________
161//
162// EOF
163//