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 /// \class AliMUONCalibParam2F
27 /// \brief Implementation of AliMUONVCalibParam for pair of floats.
29 /// Handle the case of 2 floating point parameters per channel.
30 /// Conceptually, this class is the equivalent of a vector or float pairs,
31 /// but it is implemented using bare Float_t[] array.
33 /// \author Laurent Aphecetche
36 ClassImp(AliMUONCalibParam2F)
39 //_____________________________________________________________________________
40 AliMUONCalibParam2F::AliMUONCalibParam2F()
41 : AliMUONVCalibParam(),
46 /// Default constructor.
49 //_____________________________________________________________________________
50 AliMUONCalibParam2F::AliMUONCalibParam2F(Int_t theSize, Float_t fillWithValue)
51 : AliMUONVCalibParam(),
53 fN(fSize*Dimension()),
56 /// Normal constructor, where theSize specifies the number of channels handled
57 /// by this object, and fillWithValue the default value assigned to each
62 fValues = new Float_t[fN];
63 for ( Int_t i = 0; i < fN; ++i )
65 fValues[i] = fillWithValue;
71 //_____________________________________________________________________________
72 AliMUONCalibParam2F::AliMUONCalibParam2F(const AliMUONCalibParam2F& other)
73 : AliMUONVCalibParam(),
83 //_____________________________________________________________________________
85 AliMUONCalibParam2F::operator=(const AliMUONCalibParam2F& other)
87 /// Assignment operator
93 //_____________________________________________________________________________
94 AliMUONCalibParam2F::~AliMUONCalibParam2F()
101 //_____________________________________________________________________________
103 AliMUONCalibParam2F::CopyTo(AliMUONCalibParam2F& destination) const
105 /// Copy *this to destination
107 delete[] destination.fValues;
109 destination.fSize = fSize;
113 destination.fValues = new Float_t[fN];
114 for ( Int_t i = 0; i < fN; ++i )
116 destination.fValues[i] = fValues[i];
121 //_____________________________________________________________________________
123 AliMUONCalibParam2F::Index(Int_t i, Int_t j) const
125 /// Compute the 1D index of the internal storage from the pair (i,j)
126 /// Returns -1 if the (i,j) pair is invalid
128 if ( i >= 0 && i < Size() && j >= 0 && j < Dimension() )
135 //_____________________________________________________________________________
137 AliMUONCalibParam2F::Print(Option_t* opt) const
139 /// Output this object to stdout.
140 /// If opt=="full", then all channels are printed, otherwise
141 /// only the general characteristics are printed.
145 cout << "AliMUONCalibParam2F - Size=" << Size()
146 << " Dimension=" << Dimension()
148 if ( sopt.Contains("FULL") )
150 for ( Int_t i = 0; i < Size(); ++i )
152 cout << setw(6) << ValueAsFloat(i,0) << "," << ValueAsFloat(i,1) << endl;
157 //_____________________________________________________________________________
159 AliMUONCalibParam2F::SetValueAsFloat(Int_t i, Int_t j, Float_t value)
161 /// Set one value as a float, after checking that the indices are correct.
163 Int_t ix = Index(i,j);
167 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
168 i,j,Size()-1,Dimension()-1));
176 //_____________________________________________________________________________
178 AliMUONCalibParam2F::SetValueAsInt(Int_t i, Int_t j, Int_t value)
180 /// Set one value as an int.
182 SetValueAsFloat(i,j,static_cast<Float_t>(value));
185 //_____________________________________________________________________________
187 AliMUONCalibParam2F::ValueAsFloat(Int_t i, Int_t j) const
189 /// Return the value as a float (which it is), after checking indices.
191 Int_t ix = Index(i,j);
195 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
196 i,j,Size()-1,Dimension()-1));
205 //_____________________________________________________________________________
207 AliMUONCalibParam2F::ValueAsInt(Int_t i, Int_t j) const
209 /// Return the value as an int, by rounding the internal float value.
211 Float_t v = ValueAsFloat(i,j);
212 return TMath::Nint(v);