1 /**************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN. *
3 * All rights reserved. *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************/
18 //__________________________________________________________
20 // Map of per strip Float_t information
21 // the floats are indexed by the coordinates
23 // RING ID ('I' or 'O', any case)
28 // Created Mon Nov 8 12:51:51 2004 by Christian Holm Christensen
30 #include "AliFMDFloatMap.h" //ALIFMDFLOATMAP_H
32 class Printer : public AliFMDMap::ForOne
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,
43 if (d != 0) printf("\n");
44 printf("FMD%d", fOldD);
49 printf("\n %s ring", (r == 'I' ? "Inner" : "Outer"));
53 printf("\n Sector %2d", fOldS);
55 if (t % 4 == 0) printf("\n %3d-%3d ", t, t+3);
57 // if (t % 4 == 3) printf("\n");
61 Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, Int_t)
65 Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, UShort_t)
69 Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, Bool_t)
74 Printer(const Printer& p)
75 : AliFMDMap::ForOne(p),
81 Printer& operator=(const Printer&) { return *this; }
88 //__________________________________________________________
89 ClassImp(AliFMDFloatMap)
91 ; // This is here to keep Emacs for indenting the next line
94 //__________________________________________________________
95 AliFMDFloatMap::AliFMDFloatMap(const AliFMDMap& other)
97 fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
100 if (fTotal == 0) fTotal = 51200;
101 fData = new Float_t[fTotal];
103 if (!other.IsFloat()) return;
104 for (Int_t i = 0; i < fTotal; i++) fData[i] = other.AtAsFloat(i);
107 //__________________________________________________________
108 AliFMDFloatMap::AliFMDFloatMap(const AliFMDFloatMap& other)
109 : AliFMDMap(other.fMaxDetectors,
113 fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
116 if (fTotal == 0) fTotal = 51200;
117 fData = new Float_t[fTotal];
119 for (Int_t i = 0; i < fTotal; i++)
120 fData[i] = other.fData[i];
123 //__________________________________________________________
124 AliFMDFloatMap::AliFMDFloatMap()
134 //__________________________________________________________
135 AliFMDFloatMap::AliFMDFloatMap(Int_t maxDet,
139 : AliFMDMap(maxDet, maxRing, maxSec, maxStr),
140 fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
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
149 if (fTotal == 0) fTotal = 51200;
150 fData = new Float_t[fTotal];
154 //__________________________________________________________
156 AliFMDFloatMap::operator=(const AliFMDFloatMap& other)
158 // Assignment operator
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;
170 if (fTotal == 0) fTotal = 51200;
171 if (fData) delete [] fData;
172 fData = new Float_t[fTotal];
174 for (Int_t i = 0; i < fTotal; i++) fData[i] = other.fData[i];
180 //__________________________________________________________
182 AliFMDFloatMap::Reset(const Float_t& val)
185 for (Int_t i = 0; i < fTotal; i++) fData[i] = val;
188 //__________________________________________________________
190 AliFMDFloatMap::Print(Option_t* option) const
192 // Print contents of map
193 if (!option || option[0] == '\0') TObject::Print();
198 //__________________________________________________________
200 AliFMDFloatMap::operator()(UShort_t det,
211 // Returns appropriate data
212 return fData[CalcIndex(det, ring, sec, str)];
215 //__________________________________________________________
217 AliFMDFloatMap::operator()(UShort_t det,
228 // Returns appropriate data
229 return fData[CalcIndex(det, ring, sec, str)];
232 //__________________________________________________________