]>
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 "AliMUONCalibParam1I.h" | |
19 | ||
20 | #include "AliLog.h" | |
21 | #include "Riostream.h" | |
22 | #include "TMath.h" | |
23 | #include "TString.h" | |
24 | ||
5398f946 | 25 | /// \class AliMUONCalibParam1I |
26 | /// | |
9d5f6a64 | 27 | /// This class is implementing the AliMUONVCalibParam interface. |
28 | /// | |
29 | /// It stores a given number of integers. | |
30 | /// | |
31 | /// Those integers can also be retrieved as floats if really needed | |
32 | /// (this is to comply with the base class). | |
33 | /// | |
34 | /// You might consider just as it is, namely a C++ wrapper to | |
35 | /// a plain int[] array. | |
5398f946 | 36 | /// |
37 | /// \author Laurent Aphecetche | |
9d5f6a64 | 38 | |
5398f946 | 39 | /// \cond CLASSIMP |
9369bbee | 40 | ClassImp(AliMUONCalibParam1I) |
5398f946 | 41 | /// \endcond |
9369bbee | 42 | |
43 | //_____________________________________________________________________________ | |
44 | AliMUONCalibParam1I::AliMUONCalibParam1I() | |
45 | : AliMUONVCalibParam(), | |
46 | fSize(0), | |
47 | fValues(0x0) | |
48 | { | |
5398f946 | 49 | /// Default constructor. |
9369bbee | 50 | } |
51 | ||
52 | //_____________________________________________________________________________ | |
53 | AliMUONCalibParam1I::AliMUONCalibParam1I(Int_t theSize, Int_t fillWithValue) | |
54 | : AliMUONVCalibParam(), | |
ccea41d4 | 55 | fSize(theSize), |
56 | fValues(0x0) | |
9369bbee | 57 | { |
5398f946 | 58 | /// Normal constructor, where theSize specifies the number of channels handled |
59 | /// by this object, and fillWithValue the default value assigned to each | |
60 | /// channel. | |
61 | ||
9369bbee | 62 | if ( fSize > 0 ) |
63 | { | |
64 | fValues = new Int_t[fSize]; | |
0b9b125f | 65 | for ( Int_t i = 0; i < fSize; ++i ) |
66 | { | |
67 | fValues[i] = fillWithValue; | |
68 | } | |
9369bbee | 69 | } |
70 | } | |
71 | ||
9d5f6a64 | 72 | //_____________________________________________________________________________ |
73 | AliMUONCalibParam1I::AliMUONCalibParam1I(const AliMUONCalibParam1I& other) | |
74 | : AliMUONVCalibParam(other), | |
75 | fSize(0), | |
76 | fValues(0x0) | |
77 | { | |
5398f946 | 78 | /// Copy constructor |
79 | ||
9d5f6a64 | 80 | other.CopyTo(*this); |
81 | } | |
884a73f1 | 82 | |
9d5f6a64 | 83 | //_____________________________________________________________________________ |
84 | AliMUONCalibParam1I& | |
85 | AliMUONCalibParam1I::operator=(const AliMUONCalibParam1I& other) | |
86 | { | |
5398f946 | 87 | /// Assignment operator |
88 | ||
9d5f6a64 | 89 | AliMUONVCalibParam::operator=(other); |
90 | other.CopyTo(*this); | |
91 | return *this; | |
884a73f1 | 92 | } |
93 | ||
9369bbee | 94 | //_____________________________________________________________________________ |
95 | AliMUONCalibParam1I::~AliMUONCalibParam1I() | |
96 | { | |
5398f946 | 97 | /// Destructor. |
98 | ||
9369bbee | 99 | delete[] fValues; |
100 | } | |
101 | ||
9d5f6a64 | 102 | //_____________________________________________________________________________ |
103 | void | |
104 | AliMUONCalibParam1I::CopyTo(AliMUONCalibParam1I& destination) const | |
884a73f1 | 105 | { |
5398f946 | 106 | /// Copy this into destination. |
107 | ||
9d5f6a64 | 108 | delete[] destination.fValues; |
109 | destination.fSize = fSize; | |
110 | if ( fSize > 0 ) | |
111 | { | |
112 | destination.fValues = new Int_t[fSize]; | |
113 | for ( Int_t i = 0; i < fSize; ++i ) | |
114 | { | |
115 | destination.fValues[i] = fValues[i]; | |
116 | } | |
117 | } | |
118 | } | |
884a73f1 | 119 | |
9369bbee | 120 | //_____________________________________________________________________________ |
121 | void | |
122 | AliMUONCalibParam1I::Print(Option_t* opt) const | |
123 | { | |
5398f946 | 124 | /// Output this object to stdout. |
125 | /// If opt=="full", then all channels are printed, otherwise | |
126 | /// only the general characteristics are printed. | |
127 | ||
9369bbee | 128 | TString sopt(opt); |
129 | sopt.ToUpper(); | |
130 | cout << "AliMUONCalibParam1I - Size=" << Size() | |
131 | << " Dimension=" << Dimension() | |
132 | << endl; | |
133 | if ( sopt.Contains("FULL") ) | |
134 | { | |
135 | for ( Int_t i = 0; i < Size(); ++i ) | |
136 | { | |
137 | cout << setw(6) << ValueAsInt(i) << " , " << endl; | |
138 | } | |
139 | } | |
140 | } | |
141 | ||
142 | //_____________________________________________________________________________ | |
143 | void | |
144 | AliMUONCalibParam1I::SetValueAsFloat(Int_t i, Int_t j, Float_t value) | |
145 | { | |
5398f946 | 146 | /// Set the value as a float, which is casted to an int prior to storage. |
147 | ||
9369bbee | 148 | SetValueAsInt(i,j,TMath::Nint(value)); |
149 | } | |
150 | ||
151 | //_____________________________________________________________________________ | |
152 | void | |
153 | AliMUONCalibParam1I::SetValueAsInt(Int_t i, Int_t j, Int_t value) | |
154 | { | |
5398f946 | 155 | /// Set the value for a given channel. |
156 | /// (i,j) are checked for correctness before use. | |
157 | ||
9369bbee | 158 | if ( j != 0 || i >= fSize || i < 0 ) |
159 | { | |
160 | AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)", | |
161 | i,j,Size()-1,Dimension()-1)); | |
162 | } | |
163 | else | |
164 | { | |
165 | fValues[i]=value; | |
166 | } | |
167 | } | |
168 | ||
169 | //_____________________________________________________________________________ | |
170 | Float_t | |
171 | AliMUONCalibParam1I::ValueAsFloat(Int_t i, Int_t j) const | |
172 | { | |
5398f946 | 173 | /// Return one value as a float. |
174 | ||
9369bbee | 175 | return 1.0*ValueAsInt(i,j); |
176 | } | |
177 | ||
178 | //_____________________________________________________________________________ | |
179 | Int_t | |
180 | AliMUONCalibParam1I::ValueAsInt(Int_t i, Int_t j) const | |
181 | { | |
5398f946 | 182 | /// Return one value as an integer, after checking that (i,j) |
183 | /// are valid indices. | |
184 | ||
9369bbee | 185 | if ( j != 0 || i >= fSize || i < 0 ) |
186 | { | |
187 | AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)", | |
188 | i,j,Size()-1,Dimension()-1)); | |
189 | return 0; | |
190 | } | |
191 | else | |
192 | { | |
193 | return fValues[i]; | |
194 | } | |
195 | } |