]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliFMDFloatMap.cxx
Changes for #80800 following bugs #80687: commit to trunk + port to the release ...
[u/mrichter/AliRoot.git] / STEER / AliFMDFloatMap.cxx
CommitLineData
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 31namespace {
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)
3e8dc06b 75 : AliFMDMap::ForOne(p),
76 fFormat(p.fFormat),
021f1396 77 fOldD(p.fOldD),
78 fOldR(p.fOldR),
79 fOldS(p.fOldS)
80 {}
81 Printer& operator=(const Printer&) { return *this; }
82 const char* fFormat;
83 UShort_t fOldD;
84 Char_t fOldR;
85 UShort_t fOldS;
86 };
87}
9da38871 88//__________________________________________________________
89ClassImp(AliFMDFloatMap)
90#if 0
91 ; // This is here to keep Emacs for indenting the next line
92#endif
021f1396 93
94//__________________________________________________________
95AliFMDFloatMap::AliFMDFloatMap(const AliFMDMap& other)
96 : AliFMDMap(other),
97 fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
98 fData(0)
99{
100 if (fTotal == 0) fTotal = 51200;
101 fData = new Float_t[fTotal];
102 // Copy constructor
103 if (!other.IsFloat()) return;
104 for (Int_t i = 0; i < fTotal; i++) fData[i] = other.AtAsFloat(i);
105}
106
9da38871 107//__________________________________________________________
108AliFMDFloatMap::AliFMDFloatMap(const AliFMDFloatMap& other)
109 : AliFMDMap(other.fMaxDetectors,
110 other.fMaxRings,
111 other.fMaxSectors,
112 other.fMaxStrips),
fe12e09c 113 fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
021f1396 114 fData(0)
9da38871 115{
021f1396 116 if (fTotal == 0) fTotal = 51200;
117 fData = new Float_t[fTotal];
9da38871 118 // Copy constructor
fe12e09c 119 for (Int_t i = 0; i < fTotal; i++)
9da38871 120 fData[i] = other.fData[i];
121}
122
021f1396 123//__________________________________________________________
124AliFMDFloatMap::AliFMDFloatMap()
125 : AliFMDMap(),
126 fTotal(0),
127 fData(0)
128{
129 // Constructor.
130 // Parameters:
131 // None
132}
133
9da38871 134//__________________________________________________________
fe12e09c 135AliFMDFloatMap::AliFMDFloatMap(Int_t maxDet,
136 Int_t maxRing,
137 Int_t maxSec,
138 Int_t maxStr)
9da38871 139 : AliFMDMap(maxDet, maxRing, maxSec, maxStr),
fe12e09c 140 fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
021f1396 141 fData(0)
9da38871 142{
143 // Constructor.
144 // Parameters:
145 // maxDet Maximum number of detectors
146 // maxRing Maximum number of rings per detector
147 // maxSec Maximum number of sectors per ring
148 // maxStr Maximum number of strips per sector
021f1396 149 if (fTotal == 0) fTotal = 51200;
150 fData = new Float_t[fTotal];
cd888a89 151 Reset(0);
9da38871 152}
153
154//__________________________________________________________
155AliFMDFloatMap&
156AliFMDFloatMap::operator=(const AliFMDFloatMap& other)
157{
158 // Assignment operator
cd888a89 159 if(&other != this){
a2fbb067 160 if(fMaxDetectors!= other.fMaxDetectors||
161 fMaxRings != other.fMaxRings||
162 fMaxSectors != other.fMaxSectors||
163 fMaxStrips != other.fMaxStrips){
164 // allocate new memory only if the array size is different....
165 fMaxDetectors = other.fMaxDetectors;
166 fMaxRings = other.fMaxRings;
167 fMaxSectors = other.fMaxSectors;
168 fMaxStrips = other.fMaxStrips;
169 fTotal = fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips;
021f1396 170 if (fTotal == 0) fTotal = 51200;
a2fbb067 171 if (fData) delete [] fData;
172 fData = new Float_t[fTotal];
173 }
cd888a89 174 for (Int_t i = 0; i < fTotal; i++) fData[i] = other.fData[i];
175 }
9da38871 176 return *this;
177}
178
021f1396 179
9da38871 180//__________________________________________________________
181void
182AliFMDFloatMap::Reset(const Float_t& val)
183{
184 // Reset map to val
fe12e09c 185 for (Int_t i = 0; i < fTotal; i++) fData[i] = val;
9da38871 186}
187
021f1396 188//__________________________________________________________
189void
190AliFMDFloatMap::Print(Option_t* option) const
191{
192 // Print contents of map
193 if (!option || option[0] == '\0') TObject::Print();
194 Printer p(option);
195 ForEach(p);
196 printf("\n");
197}
9da38871 198//__________________________________________________________
199Float_t&
200AliFMDFloatMap::operator()(UShort_t det,
201 Char_t ring,
202 UShort_t sec,
203 UShort_t str)
204{
205 // Get data
206 // Parameters:
207 // det Detector #
208 // ring Ring ID
209 // sec Sector #
210 // str Strip #
211 // Returns appropriate data
212 return fData[CalcIndex(det, ring, sec, str)];
213}
214
215//__________________________________________________________
216const Float_t&
217AliFMDFloatMap::operator()(UShort_t det,
218 Char_t ring,
219 UShort_t sec,
220 UShort_t str) const
221{
222 // Get data
223 // Parameters:
224 // det Detector #
225 // ring Ring ID
226 // sec Sector #
227 // str Strip #
228 // Returns appropriate data
229 return fData[CalcIndex(det, ring, sec, str)];
230}
231
232//__________________________________________________________
233//
234// EOF
235//
236