1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliMUONCalibParam2F.h"
21 #include "Riostream.h"
26 /// Implementation of AliMUONVCalibParam for pair of floats.
28 /// Conceptually, this class is the equivalent of a vector or float pairs,
29 /// but it is implemented using bare Float_t[] array.
32 ClassImp(AliMUONCalibParam2F)
34 //_____________________________________________________________________________
35 AliMUONCalibParam2F::AliMUONCalibParam2F()
36 : AliMUONVCalibParam(),
46 //_____________________________________________________________________________
47 AliMUONCalibParam2F::AliMUONCalibParam2F(Int_t theSize, Int_t fillWithValue)
48 : AliMUONVCalibParam(),
53 // Normal ctor, where theSize specifies the number of channels handled
54 // by this object, and fillWithValue the default value assigned to each
59 fValues = new Float_t[fN];
60 memset(fValues,fillWithValue,fN*sizeof(Float_t));
65 //_____________________________________________________________________________
66 AliMUONCalibParam2F::AliMUONCalibParam2F(const AliMUONCalibParam2F& other)
67 : AliMUONVCalibParam(),
75 //_____________________________________________________________________________
77 AliMUONCalibParam2F::operator=(const AliMUONCalibParam2F& other)
83 //_____________________________________________________________________________
84 AliMUONCalibParam2F::~AliMUONCalibParam2F()
92 //_____________________________________________________________________________
94 AliMUONCalibParam2F::CopyTo(AliMUONCalibParam2F& destination) const
97 // Copy *this to destination
99 delete[] destination.fValues;
101 destination.fSize = fSize;
105 destination.fValues = new Float_t[fN];
106 for ( Int_t i = 0; i < fN; ++i )
108 destination.fValues[i] = fValues[i];
113 //_____________________________________________________________________________
115 AliMUONCalibParam2F::Index(Int_t i, Int_t j) const
118 // Compute the 1D index of the internal storage from the pair (i,j)
119 // Returns -1 if the (i,j) pair is invalid
121 if ( i >= 0 && i < Size() && j >= 0 && j < Dimension() )
128 //_____________________________________________________________________________
130 AliMUONCalibParam2F::Print(Option_t* opt) const
133 // Output this object to stdout.
134 // If opt=="full", then all channels are printed, otherwise
135 // only the general characteristics are printed.
139 cout << "AliMUONCalibParam2F - Size=" << Size()
140 << " Dimension=" << Dimension()
142 if ( sopt.Contains("FULL") )
144 for ( Int_t i = 0; i < Size(); ++i )
146 cout << setw(6) << ValueAsFloat(i,0) << "," << ValueAsFloat(i,1) << endl;
151 //_____________________________________________________________________________
153 AliMUONCalibParam2F::SetValueAsFloat(Int_t i, Int_t j, Float_t value)
156 // Set one value as a float, after checking that the indices are correct.
158 Int_t ix = Index(i,j);
162 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
163 i,j,Size()-1,Dimension()-1));
171 //_____________________________________________________________________________
173 AliMUONCalibParam2F::SetValueAsInt(Int_t i, Int_t j, Int_t value)
176 // Set one value as an int.
178 SetValueAsFloat(i,j,static_cast<Float_t>(value));
181 //_____________________________________________________________________________
183 AliMUONCalibParam2F::ValueAsFloat(Int_t i, Int_t j) const
186 // Return the value as a float (which it is), after checking indices.
188 Int_t ix = Index(i,j);
192 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
193 i,j,Size()-1,Dimension()-1));
202 //_____________________________________________________________________________
204 AliMUONCalibParam2F::ValueAsInt(Int_t i, Int_t j) const
207 // Return the value as an int, by rounding the internal float value.
209 Float_t v = ValueAsFloat(i,j);
210 return TMath::Nint(v);