]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/ESD/AliFMDFloatMap.cxx
Number of sigma pedestal cut increased to 4
[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 namespace {
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) 
75       : AliFMDMap::ForOne(p),
76         fFormat(p.fFormat), 
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 }
88 //__________________________________________________________
89 ClassImp(AliFMDFloatMap)
90 #if 0
91   ; // This is here to keep Emacs for indenting the next line
92 #endif
93
94 //__________________________________________________________
95 AliFMDFloatMap::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
107 //__________________________________________________________
108 AliFMDFloatMap::AliFMDFloatMap(const AliFMDFloatMap& other)
109   : AliFMDMap(other.fMaxDetectors,
110               other.fMaxRings,
111               other.fMaxSectors,
112               other.fMaxStrips),
113     fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
114     fData(0)
115 {
116   if (fTotal == 0) fTotal = 51200;
117   fData = new Float_t[fTotal];
118   // Copy constructor
119   for (Int_t i = 0; i < fTotal; i++)
120     fData[i] = other.fData[i];
121 }
122
123 //__________________________________________________________
124 AliFMDFloatMap::AliFMDFloatMap()
125   : AliFMDMap(),
126     fTotal(0),
127     fData(0)
128 {
129   // Constructor.
130   // Parameters:
131   //    None
132 }
133
134 //__________________________________________________________
135 AliFMDFloatMap::AliFMDFloatMap(Int_t maxDet,
136                                Int_t maxRing,
137                                Int_t maxSec,
138                                Int_t maxStr)
139   : AliFMDMap(maxDet, maxRing, maxSec, maxStr),
140     fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
141     fData(0)
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
149   if (fTotal == 0) fTotal = 51200;
150   fData = new Float_t[fTotal];
151   Reset(0);
152 }
153
154 //__________________________________________________________
155 AliFMDFloatMap&
156 AliFMDFloatMap::operator=(const AliFMDFloatMap& other)
157 {
158   // Assignment operator 
159   if(&other != this){
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];
173     }
174     for (Int_t i = 0; i < fTotal; i++) fData[i] = other.fData[i];
175   }
176   return *this;
177 }
178
179
180 //__________________________________________________________
181 void
182 AliFMDFloatMap::Reset(const Float_t& val)
183 {
184   // Reset map to val
185   for (Int_t i = 0; i < fTotal; i++) fData[i] = val;
186 }
187
188 //__________________________________________________________
189 void
190 AliFMDFloatMap::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 }
198 //__________________________________________________________
199 Float_t&
200 AliFMDFloatMap::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 //__________________________________________________________
216 const Float_t&
217 AliFMDFloatMap::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