]>
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 | ||
25 | ClassImp(AliMUONCalibParam1I) | |
26 | ||
27 | //_____________________________________________________________________________ | |
28 | AliMUONCalibParam1I::AliMUONCalibParam1I() | |
29 | : AliMUONVCalibParam(), | |
30 | fSize(0), | |
31 | fValues(0x0) | |
32 | { | |
33 | // | |
34 | // Default ctor. | |
35 | // | |
36 | } | |
37 | ||
38 | //_____________________________________________________________________________ | |
39 | AliMUONCalibParam1I::AliMUONCalibParam1I(Int_t theSize, Int_t fillWithValue) | |
40 | : AliMUONVCalibParam(), | |
41 | fSize(theSize) | |
42 | { | |
43 | // | |
44 | // Normal ctor, where theSize specifies the number of channels handled | |
45 | // by this object, and fillWithValue the default value assigned to each | |
46 | // channel. | |
47 | // | |
48 | if ( fSize > 0 ) | |
49 | { | |
50 | fValues = new Int_t[fSize]; | |
51 | memset(fValues,fillWithValue,fSize*sizeof(Int_t)); | |
52 | } | |
53 | } | |
54 | ||
884a73f1 | 55 | //______________________________________________________________________________ |
56 | AliMUONCalibParam1I::AliMUONCalibParam1I(const AliMUONCalibParam1I& right) | |
57 | : AliMUONVCalibParam(right) | |
58 | { | |
59 | /// Protected copy constructor (not implemented) | |
60 | ||
61 | AliFatal("Copy constructor not provided."); | |
62 | } | |
63 | ||
9369bbee | 64 | //_____________________________________________________________________________ |
65 | AliMUONCalibParam1I::~AliMUONCalibParam1I() | |
66 | { | |
67 | // | |
68 | // dtor. | |
69 | // | |
70 | delete[] fValues; | |
71 | } | |
72 | ||
884a73f1 | 73 | //______________________________________________________________________________ |
74 | AliMUONCalibParam1I& | |
75 | AliMUONCalibParam1I::operator=(const AliMUONCalibParam1I& right) | |
76 | { | |
77 | /// Protected assignement operator (not implemented) | |
78 | ||
79 | // check assignement to self | |
80 | if (this == &right) return *this; | |
81 | ||
82 | AliFatal("Assignement operator not provided."); | |
83 | ||
84 | return *this; | |
85 | } | |
86 | ||
9369bbee | 87 | //_____________________________________________________________________________ |
88 | void | |
89 | AliMUONCalibParam1I::Print(Option_t* opt) const | |
90 | { | |
91 | // | |
92 | // Output this object to stdout. | |
93 | // If opt=="full", then all channels are printed, otherwise | |
94 | // only the general characteristics are printed. | |
95 | // | |
96 | TString sopt(opt); | |
97 | sopt.ToUpper(); | |
98 | cout << "AliMUONCalibParam1I - Size=" << Size() | |
99 | << " Dimension=" << Dimension() | |
100 | << endl; | |
101 | if ( sopt.Contains("FULL") ) | |
102 | { | |
103 | for ( Int_t i = 0; i < Size(); ++i ) | |
104 | { | |
105 | cout << setw(6) << ValueAsInt(i) << " , " << endl; | |
106 | } | |
107 | } | |
108 | } | |
109 | ||
110 | //_____________________________________________________________________________ | |
111 | void | |
112 | AliMUONCalibParam1I::SetValueAsFloat(Int_t i, Int_t j, Float_t value) | |
113 | { | |
114 | // | |
115 | // Set the value as a float, which is casted to an int prior to storage. | |
116 | // | |
117 | SetValueAsInt(i,j,TMath::Nint(value)); | |
118 | } | |
119 | ||
120 | //_____________________________________________________________________________ | |
121 | void | |
122 | AliMUONCalibParam1I::SetValueAsInt(Int_t i, Int_t j, Int_t value) | |
123 | { | |
124 | // | |
125 | // Set the value for a given channel. | |
126 | // (i,j) are checked for correctness before use. | |
127 | // | |
128 | if ( j != 0 || i >= fSize || i < 0 ) | |
129 | { | |
130 | AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)", | |
131 | i,j,Size()-1,Dimension()-1)); | |
132 | } | |
133 | else | |
134 | { | |
135 | fValues[i]=value; | |
136 | } | |
137 | } | |
138 | ||
139 | //_____________________________________________________________________________ | |
140 | Float_t | |
141 | AliMUONCalibParam1I::ValueAsFloat(Int_t i, Int_t j) const | |
142 | { | |
143 | // | |
144 | // Return one value as a float. | |
145 | // | |
146 | return 1.0*ValueAsInt(i,j); | |
147 | } | |
148 | ||
149 | //_____________________________________________________________________________ | |
150 | Int_t | |
151 | AliMUONCalibParam1I::ValueAsInt(Int_t i, Int_t j) const | |
152 | { | |
153 | // | |
154 | // Return one value as an integer, after checking that (i,j) | |
155 | // are valid indices. | |
156 | // | |
157 | if ( j != 0 || i >= fSize || i < 0 ) | |
158 | { | |
159 | AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)", | |
160 | i,j,Size()-1,Dimension()-1)); | |
161 | return 0; | |
162 | } | |
163 | else | |
164 | { | |
165 | return fValues[i]; | |
166 | } | |
167 | } |