]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/ESD/AliFMDFloatMap.cxx
Update timestamp for new data points simulation
[u/mrichter/AliRoot.git] / STEER / ESD / AliFMDFloatMap.cxx
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 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   : AliFMDMap(other),
40     fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
41     fData(0)
42 {
43   if (fTotal == 0) fTotal = 51200;
44   fData = new Float_t[fTotal];
45   // Copy constructor
46   if (!other.IsFloat()) return;
47   for (Int_t i = 0; i < fTotal; i++) fData[i] = other.AtAsFloat(i);
48 }
49
50 //__________________________________________________________
51 AliFMDFloatMap::AliFMDFloatMap(const AliFMDFloatMap& other)
52   : AliFMDMap(other.fMaxDetectors,
53               other.fMaxRings,
54               other.fMaxSectors,
55               other.fMaxStrips),
56     fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
57     fData(0)
58 {
59   if (fTotal == 0) fTotal = 51200;
60   fData = new Float_t[fTotal];
61   // Copy constructor
62   for (Int_t i = 0; i < fTotal; i++)
63     fData[i] = other.fData[i];
64 }
65
66 //__________________________________________________________
67 AliFMDFloatMap::AliFMDFloatMap()
68   : AliFMDMap(),
69     fTotal(0),
70     fData(0)
71 {
72   // Constructor.
73   // Parameters:
74   //    None
75 }
76
77 //__________________________________________________________
78 AliFMDFloatMap::AliFMDFloatMap(Int_t maxDet,
79                                Int_t maxRing,
80                                Int_t maxSec,
81                                Int_t maxStr)
82   : AliFMDMap(maxDet, maxRing, maxSec, maxStr),
83     fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
84     fData(0)
85 {
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   if (fTotal == 0) fTotal = 51200;
93   fData = new Float_t[fTotal];
94   Reset(0);
95 }
96
97 //__________________________________________________________
98 AliFMDFloatMap&
99 AliFMDFloatMap::operator=(const AliFMDFloatMap& other)
100 {
101   // Assignment operator 
102   if(&other != this){
103     if(fMaxDetectors!= other.fMaxDetectors||
104        fMaxRings    != other.fMaxRings||
105        fMaxSectors  != other.fMaxSectors||
106        fMaxStrips   != other.fMaxStrips){
107       // allocate new memory only if the array size is different....
108       fMaxDetectors = other.fMaxDetectors;
109       fMaxRings     = other.fMaxRings;
110       fMaxSectors   = other.fMaxSectors;
111       fMaxStrips    = other.fMaxStrips;
112       fTotal        = fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips;
113       if (fTotal == 0) fTotal = 51200;
114       if (fData) delete [] fData;
115       fData = new Float_t[fTotal];
116     }
117     for (Int_t i = 0; i < fTotal; i++) fData[i] = other.fData[i];
118   }
119   return *this;
120 }
121
122
123 //__________________________________________________________
124 void
125 AliFMDFloatMap::Reset(const Float_t& val)
126 {
127   // Reset map to val
128   for (Int_t i = 0; i < fTotal; i++) fData[i] = val;
129 }
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   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   return fData[CalcIndex(det, ring, sec, str)];
163 }
164
165 //__________________________________________________________
166 // 
167 // EOF
168 // 
169