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