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 "AliMUONCalibParamND.h"
22 #include "Riostream.h"
27 /// \class AliMUONCalibParamND
29 /// Handle the case of N floating point (double precision) parameters per channel.
31 /// \author Laurent Aphecetche
34 ClassImp(AliMUONCalibParamND)
37 //_____________________________________________________________________________
38 AliMUONCalibParamND::AliMUONCalibParamND()
39 : AliMUONVCalibParam(),
45 /// Default constructor.
48 //_____________________________________________________________________________
49 AliMUONCalibParamND::AliMUONCalibParamND(Int_t dimension, Int_t theSize,
51 Double_t fillWithValue)
52 : AliMUONVCalibParam(id0,id1),
53 fDimension(dimension),
58 /// Normal constructor, where theSize specifies the number of channels handled
59 /// by this object, and fillWithValue the default value assigned to each
64 fValues = new Double_t[fN];
65 for ( Int_t i = 0; i < fN; ++i )
67 fValues[i] = fillWithValue;
73 //_____________________________________________________________________________
74 AliMUONCalibParamND::AliMUONCalibParamND(const AliMUONCalibParamND& other)
75 : AliMUONVCalibParam(),
86 //_____________________________________________________________________________
88 AliMUONCalibParamND::operator=(const AliMUONCalibParamND& other)
90 /// Assignment operator
96 //_____________________________________________________________________________
97 AliMUONCalibParamND::~AliMUONCalibParamND()
104 //_____________________________________________________________________________
106 AliMUONCalibParamND::CopyTo(AliMUONCalibParamND& destination) const
108 /// Copy *this to destination
110 delete[] destination.fValues;
112 destination.fSize = fSize;
113 destination.fDimension = fDimension;
117 destination.fValues = new Double_t[fN];
118 for ( Int_t i = 0; i < fN; ++i )
120 destination.fValues[i] = fValues[i];
125 //_____________________________________________________________________________
127 AliMUONCalibParamND::Index(Int_t i, Int_t j) const
129 /// Compute the 1D index of the internal storage from the pair (i,j)
130 /// Returns -1 if the (i,j) pair is invalid
132 if ( i >= 0 && i < Size() && j >= 0 && j < Dimension() )
139 //_____________________________________________________________________________
141 AliMUONCalibParamND::Print(Option_t* opt) const
143 /// Output this object to stdout.
144 /// If opt=="full", then all channels are printed,
145 /// if opt=="mean#", only the mean and sigma value are printed for j-th dimension
146 /// otherwise only the general characteristics are printed.
150 cout << Form("AliMUONCalibParamND Id=(%d,%d) Size=%d Dimension=%d",ID0(),
151 ID1(),Size(),Dimension()) << endl;
152 if ( sopt.Contains("FULL") )
154 for ( Int_t i = 0; i < Size(); ++i )
156 cout << Form("CH %3d",i);
157 for ( Int_t j = 0; j < Dimension(); ++j )
159 cout << Form(" %g",ValueAsDouble(i,j));
164 if ( sopt.Contains("MEAN") )
167 sscanf(sopt.Data(),"MEAN%d",&j);
174 for ( Int_t i = 0; i < Size(); ++i )
176 Float_t v = ValueAsDouble(i,j);
182 if ( n > 1 ) sigma = TMath::Sqrt( (v2-n*mean*mean)/(n-1) );
183 cout << Form(" Mean(j=%d)=%g Sigma(j=%d)=%g",j,mean,j,sigma) << endl;
188 //_____________________________________________________________________________
190 AliMUONCalibParamND::SetValueAsDouble(Int_t i, Int_t j, Double_t value)
192 /// Set one value as a double, after checking that the indices are correct.
194 Int_t ix = Index(i,j);
198 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
199 i,j,Size()-1,Dimension()-1));
208 //_____________________________________________________________________________
210 AliMUONCalibParamND::SetValueAsFloat(Int_t i, Int_t j, Float_t value)
212 /// Set one value as a float, after checking that the indices are correct.
213 SetValueAsDouble(i,j,static_cast<Double_t>(value));
216 //_____________________________________________________________________________
218 AliMUONCalibParamND::SetValueAsInt(Int_t i, Int_t j, Int_t value)
220 /// Set one value as an int.
222 SetValueAsFloat(i,j,static_cast<Float_t>(value));
225 //_____________________________________________________________________________
227 AliMUONCalibParamND::ValueAsDouble(Int_t i, Int_t j) const
229 /// Return the value as a double (which it is), after checking indices.
231 Int_t ix = Index(i,j);
235 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
236 i,j,Size()-1,Dimension()-1));
245 //_____________________________________________________________________________
247 AliMUONCalibParamND::ValueAsFloat(Int_t i, Int_t j) const
249 /// Return the value as a float
250 return static_cast<Float_t>(ValueAsDouble(i,j));
253 //_____________________________________________________________________________
255 AliMUONCalibParamND::ValueAsInt(Int_t i, Int_t j) const
257 /// Return the value as an int, by rounding the internal float value.
259 Float_t v = ValueAsFloat(i,j);
260 return TMath::Nint(v);