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)
80 Printer& operator=(const Printer&) { return *this; }
87 //__________________________________________________________
88 ClassImp(AliFMDFloatMap)
90 ; // This is here to keep Emacs for indenting the next line
93 //__________________________________________________________
94 AliFMDFloatMap::AliFMDFloatMap(const AliFMDMap& other)
96 fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
99 if (fTotal == 0) fTotal = 51200;
100 fData = new Float_t[fTotal];
102 if (!other.IsFloat()) return;
103 for (Int_t i = 0; i < fTotal; i++) fData[i] = other.AtAsFloat(i);
106 //__________________________________________________________
107 AliFMDFloatMap::AliFMDFloatMap(const AliFMDFloatMap& other)
108 : AliFMDMap(other.fMaxDetectors,
112 fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
115 if (fTotal == 0) fTotal = 51200;
116 fData = new Float_t[fTotal];
118 for (Int_t i = 0; i < fTotal; i++)
119 fData[i] = other.fData[i];
122 //__________________________________________________________
123 AliFMDFloatMap::AliFMDFloatMap()
133 //__________________________________________________________
134 AliFMDFloatMap::AliFMDFloatMap(Int_t maxDet,
138 : AliFMDMap(maxDet, maxRing, maxSec, maxStr),
139 fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
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
148 if (fTotal == 0) fTotal = 51200;
149 fData = new Float_t[fTotal];
153 //__________________________________________________________
155 AliFMDFloatMap::operator=(const AliFMDFloatMap& other)
157 // Assignment operator
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;
169 if (fTotal == 0) fTotal = 51200;
170 if (fData) delete [] fData;
171 fData = new Float_t[fTotal];
173 for (Int_t i = 0; i < fTotal; i++) fData[i] = other.fData[i];
179 //__________________________________________________________
181 AliFMDFloatMap::Reset(const Float_t& val)
184 for (Int_t i = 0; i < fTotal; i++) fData[i] = val;
187 //__________________________________________________________
189 AliFMDFloatMap::Print(Option_t* option) const
191 // Print contents of map
192 if (!option || option[0] == '\0') TObject::Print();
197 //__________________________________________________________
199 AliFMDFloatMap::operator()(UShort_t det,
210 // Returns appropriate data
211 return fData[CalcIndex(det, ring, sec, str)];
214 //__________________________________________________________
216 AliFMDFloatMap::operator()(UShort_t det,
227 // Returns appropriate data
228 return fData[CalcIndex(det, ring, sec, str)];
231 //__________________________________________________________