]>
Commit | Line | Data |
---|---|---|
9369bbee | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | // $Id$ | |
17 | ||
18 | #include "AliMUONCalibParam2F.h" | |
19 | ||
20 | #include "AliLog.h" | |
21 | #include "Riostream.h" | |
22 | #include "TMath.h" | |
23 | #include "TString.h" | |
24 | ||
25 | ClassImp(AliMUONCalibParam2F) | |
26 | ||
27 | //_____________________________________________________________________________ | |
28 | AliMUONCalibParam2F::AliMUONCalibParam2F() | |
29 | : AliMUONVCalibParam(), | |
30 | fSize(0), | |
31 | fN(0), | |
32 | fValues(0x0) | |
33 | { | |
34 | // | |
35 | // Default ctor. | |
36 | // | |
37 | } | |
38 | ||
39 | //_____________________________________________________________________________ | |
40 | AliMUONCalibParam2F::AliMUONCalibParam2F(Int_t theSize, Int_t fillWithValue) | |
41 | : AliMUONVCalibParam(), | |
42 | fSize(theSize), | |
43 | fN(fSize*Dimension()) | |
44 | { | |
45 | // | |
46 | // Normal ctor, where theSize specifies the number of channels handled | |
47 | // by this object, and fillWithValue the default value assigned to each | |
48 | // channel. | |
49 | // | |
50 | if ( fN > 0 ) | |
51 | { | |
52 | fValues = new Float_t[fN]; | |
53 | memset(fValues,fillWithValue,fN*sizeof(Float_t)); | |
54 | } | |
55 | } | |
56 | ||
884a73f1 | 57 | //______________________________________________________________________________ |
58 | AliMUONCalibParam2F::AliMUONCalibParam2F(const AliMUONCalibParam2F& right) | |
59 | : AliMUONVCalibParam(right) | |
60 | { | |
61 | /// Protected copy constructor (not implemented) | |
62 | ||
63 | AliFatal("Copy constructor not provided."); | |
64 | } | |
65 | ||
9369bbee | 66 | //_____________________________________________________________________________ |
67 | AliMUONCalibParam2F::~AliMUONCalibParam2F() | |
68 | { | |
69 | // | |
70 | // dtor | |
71 | // | |
72 | delete[] fValues; | |
73 | } | |
74 | ||
884a73f1 | 75 | //______________________________________________________________________________ |
76 | AliMUONCalibParam2F& | |
77 | AliMUONCalibParam2F::operator=(const AliMUONCalibParam2F& right) | |
78 | { | |
79 | /// Protected assignement operator (not implemented) | |
80 | ||
81 | // check assignement to self | |
82 | if (this == &right) return *this; | |
83 | ||
84 | AliFatal("Assignement operator not provided."); | |
85 | ||
86 | return *this; | |
87 | } | |
88 | ||
9369bbee | 89 | //_____________________________________________________________________________ |
90 | Int_t | |
91 | AliMUONCalibParam2F::Index(Int_t i, Int_t j) const | |
92 | { | |
93 | // | |
94 | // Compute the 1D index of the internal storage from the pair (i,j) | |
95 | // Returns -1 if the (i,j) pair is invalid | |
96 | // | |
97 | if ( i >= 0 && i < Size() && j >= 0 && j < Dimension() ) | |
98 | { | |
99 | return i + Size()*j; | |
100 | } | |
101 | return -1; | |
102 | } | |
103 | ||
104 | //_____________________________________________________________________________ | |
105 | void | |
106 | AliMUONCalibParam2F::Print(Option_t* opt) const | |
107 | { | |
108 | // | |
109 | // Output this object to stdout. | |
110 | // If opt=="full", then all channels are printed, otherwise | |
111 | // only the general characteristics are printed. | |
112 | // | |
113 | TString sopt(opt); | |
114 | sopt.ToUpper(); | |
115 | cout << "AliMUONCalibParam2F - Size=" << Size() | |
116 | << " Dimension=" << Dimension() | |
117 | << endl; | |
118 | if ( sopt.Contains("FULL") ) | |
119 | { | |
120 | for ( Int_t i = 0; i < Size(); ++i ) | |
121 | { | |
122 | cout << setw(6) << ValueAsFloat(i,0) << "," << ValueAsFloat(i,1) << endl; | |
123 | } | |
124 | } | |
125 | } | |
126 | ||
127 | //_____________________________________________________________________________ | |
128 | void | |
129 | AliMUONCalibParam2F::SetValueAsFloat(Int_t i, Int_t j, Float_t value) | |
130 | { | |
131 | // | |
132 | // Set one value as a float, after checking that the indices are correct. | |
133 | // | |
134 | Int_t ix = Index(i,j); | |
135 | ||
136 | if ( ix < 0 ) | |
137 | { | |
138 | AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)", | |
139 | i,j,Size()-1,Dimension()-1)); | |
140 | } | |
141 | else | |
142 | { | |
143 | fValues[ix]=value; | |
144 | } | |
145 | } | |
146 | ||
147 | //_____________________________________________________________________________ | |
148 | void | |
149 | AliMUONCalibParam2F::SetValueAsInt(Int_t i, Int_t j, Int_t value) | |
150 | { | |
151 | // | |
152 | // Set one value as an int. | |
153 | // | |
154 | SetValueAsFloat(i,j,static_cast<Float_t>(value)); | |
155 | } | |
156 | ||
157 | //_____________________________________________________________________________ | |
158 | Float_t | |
159 | AliMUONCalibParam2F::ValueAsFloat(Int_t i, Int_t j) const | |
160 | { | |
161 | // | |
162 | // Return the value as a float (which it is), after checking indices. | |
163 | // | |
164 | Int_t ix = Index(i,j); | |
165 | ||
166 | if ( ix < 0 ) | |
167 | { | |
168 | AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)", | |
169 | i,j,Size()-1,Dimension()-1)); | |
170 | return 0.0; | |
171 | } | |
172 | else | |
173 | { | |
174 | return fValues[ix]; | |
175 | } | |
176 | } | |
177 | ||
178 | //_____________________________________________________________________________ | |
179 | Int_t | |
180 | AliMUONCalibParam2F::ValueAsInt(Int_t i, Int_t j) const | |
181 | { | |
182 | // | |
183 | // Return the value as an int, by rounding the internal float value. | |
184 | // | |
185 | Float_t v = ValueAsFloat(i,j); | |
186 | return TMath::Nint(v); | |
187 | } |