]>
Commit | Line | Data |
---|---|---|
9da38871 | 1 | /************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN. * | |
3 | * All rights reserved. * | |
4 | * * | |
5 | * Author: The ALICE Off-line Project. * | |
6 | * Contributors are mentioned in the code where appropriate. * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this * | |
9 | * software and its documentation strictly for non-commercial * | |
10 | * purposes is hereby granted without fee, provided that the * | |
11 | * above copyright notice appears in all copies and that both * | |
12 | * the copyright notice and this permission notice appear in * | |
13 | * the supporting documentation. The authors make no claims * | |
14 | * about the suitability of this software for any purpose. It * | |
15 | * is provided "as is" without express or implied warranty. * | |
16 | **************************************************************/ | |
17 | /* $Id$ */ | |
18 | //__________________________________________________________ | |
19 | // | |
20 | // Map of per strip Float_t information | |
6169f936 | 21 | // the floats are indexed by the coordinates |
22 | // DETECTOR # (1-3) | |
23 | // RING ID ('I' or 'O', any case) | |
24 | // SECTOR # (0-39) | |
25 | // STRIP # (0-511) | |
26 | // | |
9da38871 | 27 | // |
28 | // Created Mon Nov 8 12:51:51 2004 by Christian Holm Christensen | |
29 | // | |
30 | #include "AliFMDFloatMap.h" //ALIFMDFLOATMAP_H | |
021f1396 | 31 | namespace { |
32 | class Printer : public AliFMDMap::ForOne | |
33 | { | |
34 | public: | |
35 | Printer(const char* format) | |
36 | : fFormat(format), fOldD(0), fOldR('-'), fOldS(1024) {} | |
37 | Bool_t operator()(UShort_t d, Char_t r, UShort_t s, UShort_t t, | |
38 | Float_t m) | |
39 | { | |
40 | if (d != fOldD) { | |
41 | fOldD = d; | |
42 | fOldR = '-'; | |
43 | if (d != 0) printf("\n"); | |
44 | printf("FMD%d", fOldD); | |
45 | } | |
46 | if (r != fOldR) { | |
47 | fOldR = r; | |
48 | fOldS = 1024; | |
49 | printf("\n %s ring", (r == 'I' ? "Inner" : "Outer")); | |
50 | } | |
51 | if (s != fOldS) { | |
52 | fOldS = s; | |
53 | printf("\n Sector %2d", fOldS); | |
54 | } | |
55 | if (t % 4 == 0) printf("\n %3d-%3d ", t, t+3); | |
56 | printf(fFormat, m); | |
57 | // if (t % 4 == 3) printf("\n"); | |
58 | ||
59 | return kTRUE; | |
60 | } | |
61 | Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, Int_t) | |
62 | { | |
63 | return kTRUE; | |
64 | } | |
65 | Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, UShort_t) | |
66 | { | |
67 | return kTRUE; | |
68 | } | |
69 | Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, Bool_t) | |
70 | { | |
71 | return kTRUE; | |
72 | } | |
73 | private: | |
74 | Printer(const Printer& p) | |
75 | : fFormat(p.fFormat), | |
76 | fOldD(p.fOldD), | |
77 | fOldR(p.fOldR), | |
78 | fOldS(p.fOldS) | |
79 | {} | |
80 | Printer& operator=(const Printer&) { return *this; } | |
81 | const char* fFormat; | |
82 | UShort_t fOldD; | |
83 | Char_t fOldR; | |
84 | UShort_t fOldS; | |
85 | }; | |
86 | } | |
9da38871 | 87 | //__________________________________________________________ |
88 | ClassImp(AliFMDFloatMap) | |
89 | #if 0 | |
90 | ; // This is here to keep Emacs for indenting the next line | |
91 | #endif | |
021f1396 | 92 | |
93 | //__________________________________________________________ | |
94 | AliFMDFloatMap::AliFMDFloatMap(const AliFMDMap& other) | |
95 | : AliFMDMap(other), | |
96 | fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips), | |
97 | fData(0) | |
98 | { | |
99 | if (fTotal == 0) fTotal = 51200; | |
100 | fData = new Float_t[fTotal]; | |
101 | // Copy constructor | |
102 | if (!other.IsFloat()) return; | |
103 | for (Int_t i = 0; i < fTotal; i++) fData[i] = other.AtAsFloat(i); | |
104 | } | |
105 | ||
9da38871 | 106 | //__________________________________________________________ |
107 | AliFMDFloatMap::AliFMDFloatMap(const AliFMDFloatMap& other) | |
108 | : AliFMDMap(other.fMaxDetectors, | |
109 | other.fMaxRings, | |
110 | other.fMaxSectors, | |
111 | other.fMaxStrips), | |
fe12e09c | 112 | fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips), |
021f1396 | 113 | fData(0) |
9da38871 | 114 | { |
021f1396 | 115 | if (fTotal == 0) fTotal = 51200; |
116 | fData = new Float_t[fTotal]; | |
9da38871 | 117 | // Copy constructor |
fe12e09c | 118 | for (Int_t i = 0; i < fTotal; i++) |
9da38871 | 119 | fData[i] = other.fData[i]; |
120 | } | |
121 | ||
021f1396 | 122 | //__________________________________________________________ |
123 | AliFMDFloatMap::AliFMDFloatMap() | |
124 | : AliFMDMap(), | |
125 | fTotal(0), | |
126 | fData(0) | |
127 | { | |
128 | // Constructor. | |
129 | // Parameters: | |
130 | // None | |
131 | } | |
132 | ||
9da38871 | 133 | //__________________________________________________________ |
fe12e09c | 134 | AliFMDFloatMap::AliFMDFloatMap(Int_t maxDet, |
135 | Int_t maxRing, | |
136 | Int_t maxSec, | |
137 | Int_t maxStr) | |
9da38871 | 138 | : AliFMDMap(maxDet, maxRing, maxSec, maxStr), |
fe12e09c | 139 | fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips), |
021f1396 | 140 | fData(0) |
9da38871 | 141 | { |
142 | // Constructor. | |
143 | // Parameters: | |
144 | // maxDet Maximum number of detectors | |
145 | // maxRing Maximum number of rings per detector | |
146 | // maxSec Maximum number of sectors per ring | |
147 | // maxStr Maximum number of strips per sector | |
021f1396 | 148 | if (fTotal == 0) fTotal = 51200; |
149 | fData = new Float_t[fTotal]; | |
cd888a89 | 150 | Reset(0); |
9da38871 | 151 | } |
152 | ||
153 | //__________________________________________________________ | |
154 | AliFMDFloatMap& | |
155 | AliFMDFloatMap::operator=(const AliFMDFloatMap& other) | |
156 | { | |
157 | // Assignment operator | |
cd888a89 | 158 | if(&other != this){ |
a2fbb067 | 159 | if(fMaxDetectors!= other.fMaxDetectors|| |
160 | fMaxRings != other.fMaxRings|| | |
161 | fMaxSectors != other.fMaxSectors|| | |
162 | fMaxStrips != other.fMaxStrips){ | |
163 | // allocate new memory only if the array size is different.... | |
164 | fMaxDetectors = other.fMaxDetectors; | |
165 | fMaxRings = other.fMaxRings; | |
166 | fMaxSectors = other.fMaxSectors; | |
167 | fMaxStrips = other.fMaxStrips; | |
168 | fTotal = fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips; | |
021f1396 | 169 | if (fTotal == 0) fTotal = 51200; |
a2fbb067 | 170 | if (fData) delete [] fData; |
171 | fData = new Float_t[fTotal]; | |
172 | } | |
cd888a89 | 173 | for (Int_t i = 0; i < fTotal; i++) fData[i] = other.fData[i]; |
174 | } | |
9da38871 | 175 | return *this; |
176 | } | |
177 | ||
021f1396 | 178 | |
9da38871 | 179 | //__________________________________________________________ |
180 | void | |
181 | AliFMDFloatMap::Reset(const Float_t& val) | |
182 | { | |
183 | // Reset map to val | |
fe12e09c | 184 | for (Int_t i = 0; i < fTotal; i++) fData[i] = val; |
9da38871 | 185 | } |
186 | ||
021f1396 | 187 | //__________________________________________________________ |
188 | void | |
189 | AliFMDFloatMap::Print(Option_t* option) const | |
190 | { | |
191 | // Print contents of map | |
192 | if (!option || option[0] == '\0') TObject::Print(); | |
193 | Printer p(option); | |
194 | ForEach(p); | |
195 | printf("\n"); | |
196 | } | |
9da38871 | 197 | //__________________________________________________________ |
198 | Float_t& | |
199 | AliFMDFloatMap::operator()(UShort_t det, | |
200 | Char_t ring, | |
201 | UShort_t sec, | |
202 | UShort_t str) | |
203 | { | |
204 | // Get data | |
205 | // Parameters: | |
206 | // det Detector # | |
207 | // ring Ring ID | |
208 | // sec Sector # | |
209 | // str Strip # | |
210 | // Returns appropriate data | |
211 | return fData[CalcIndex(det, ring, sec, str)]; | |
212 | } | |
213 | ||
214 | //__________________________________________________________ | |
215 | const Float_t& | |
216 | AliFMDFloatMap::operator()(UShort_t det, | |
217 | Char_t ring, | |
218 | UShort_t sec, | |
219 | UShort_t str) const | |
220 | { | |
221 | // Get data | |
222 | // Parameters: | |
223 | // det Detector # | |
224 | // ring Ring ID | |
225 | // sec Sector # | |
226 | // str Strip # | |
227 | // Returns appropriate data | |
228 | return fData[CalcIndex(det, ring, sec, str)]; | |
229 | } | |
230 | ||
231 | //__________________________________________________________ | |
232 | // | |
233 | // EOF | |
234 | // | |
235 |