Line data Source code
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
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 : //
27 : //
28 : // Created Mon Nov 8 12:51:51 2004 by Christian Holm Christensen
29 : //
30 : #include "AliFMDFloatMap.h" //ALIFMDFLOATMAP_H
31 : //__________________________________________________________
32 172 : ClassImp(AliFMDFloatMap)
33 : #if 0
34 : ; // This is here to keep Emacs for indenting the next line
35 : #endif
36 :
37 : //__________________________________________________________
38 : AliFMDFloatMap::AliFMDFloatMap(const AliFMDMap& other)
39 0 : : AliFMDMap(other),
40 0 : fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
41 0 : fData(0)
42 0 : {
43 0 : if (fTotal == 0) fTotal = 51200;
44 0 : fData = new Float_t[fTotal];
45 : // Copy constructor
46 0 : if (!other.IsFloat()) return;
47 0 : for (Int_t i = 0; i < fTotal; i++) fData[i] = other.AtAsFloat(i);
48 0 : }
49 :
50 : //__________________________________________________________
51 : AliFMDFloatMap::AliFMDFloatMap(const AliFMDFloatMap& other)
52 0 : : AliFMDMap(other.fMaxDetectors,
53 0 : other.fMaxRings,
54 0 : other.fMaxSectors,
55 0 : other.fMaxStrips),
56 0 : fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
57 0 : fData(0)
58 0 : {
59 0 : if (fTotal == 0) fTotal = 51200;
60 0 : fData = new Float_t[fTotal];
61 : // Copy constructor
62 0 : for (Int_t i = 0; i < fTotal; i++)
63 0 : fData[i] = other.fData[i];
64 0 : }
65 :
66 : //__________________________________________________________
67 : AliFMDFloatMap::AliFMDFloatMap()
68 12 : : AliFMDMap(),
69 12 : fTotal(0),
70 12 : fData(0)
71 60 : {
72 : // Constructor.
73 : // Parameters:
74 : // None
75 24 : }
76 :
77 : //__________________________________________________________
78 : AliFMDFloatMap::AliFMDFloatMap(Int_t maxDet,
79 : Int_t maxRing,
80 : Int_t maxSec,
81 : Int_t maxStr)
82 49 : : AliFMDMap(maxDet, maxRing, maxSec, maxStr),
83 49 : fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
84 49 : fData(0)
85 245 : {
86 : // Constructor.
87 : // Parameters:
88 : // maxDet Maximum number of detectors
89 : // maxRing Maximum number of rings per detector
90 : // maxSec Maximum number of sectors per ring
91 : // maxStr Maximum number of strips per sector
92 78 : if (fTotal == 0) fTotal = 51200;
93 98 : fData = new Float_t[fTotal];
94 49 : Reset(0);
95 98 : }
96 :
97 : //__________________________________________________________
98 : AliFMDFloatMap&
99 : AliFMDFloatMap::operator=(const AliFMDFloatMap& other)
100 : {
101 : // Assignment operator
102 40 : if(&other != this){
103 38 : if(fMaxDetectors!= other.fMaxDetectors||
104 18 : fMaxRings != other.fMaxRings||
105 18 : fMaxSectors != other.fMaxSectors||
106 18 : fMaxStrips != other.fMaxStrips){
107 : // allocate new memory only if the array size is different....
108 2 : fMaxDetectors = other.fMaxDetectors;
109 2 : fMaxRings = other.fMaxRings;
110 2 : fMaxSectors = other.fMaxSectors;
111 2 : fMaxStrips = other.fMaxStrips;
112 2 : fTotal = fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips;
113 2 : if (fTotal == 0) fTotal = 51200;
114 6 : if (fData) delete [] fData;
115 2 : fData = new Float_t[fTotal];
116 2 : }
117 1372200 : for (Int_t i = 0; i < fTotal; i++) fData[i] = other.fData[i];
118 20 : }
119 20 : return *this;
120 : }
121 :
122 :
123 : //__________________________________________________________
124 : void
125 : AliFMDFloatMap::Reset(const Float_t& val)
126 : {
127 : // Reset map to val
128 10901924 : for (Int_t i = 0; i < fTotal; i++) fData[i] = val;
129 140 : }
130 :
131 : //__________________________________________________________
132 : Float_t&
133 : AliFMDFloatMap::operator()(UShort_t det,
134 : Char_t ring,
135 : UShort_t sec,
136 : UShort_t str)
137 : {
138 : // Get data
139 : // Parameters:
140 : // det Detector #
141 : // ring Ring ID
142 : // sec Sector #
143 : // str Strip #
144 : // Returns appropriate data
145 8418602 : return fData[CalcIndex(det, ring, sec, str)];
146 : }
147 :
148 : //__________________________________________________________
149 : const Float_t&
150 : AliFMDFloatMap::operator()(UShort_t det,
151 : Char_t ring,
152 : UShort_t sec,
153 : UShort_t str) const
154 : {
155 : // Get data
156 : // Parameters:
157 : // det Detector #
158 : // ring Ring ID
159 : // sec Sector #
160 : // str Strip #
161 : // Returns appropriate data
162 2490368 : return fData[CalcIndex(det, ring, sec, str)];
163 : }
164 :
165 : //__________________________________________________________
166 : //
167 : // EOF
168 : //
169 :
|