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"
26 //-----------------------------------------------------------------------------
27 /// \class AliMUONCalibParamND
29 /// Handle the case of N floating point (double precision) parameters per channel.
31 /// \author Laurent Aphecetche
32 //-----------------------------------------------------------------------------
35 ClassImp(AliMUONCalibParamND)
38 //_____________________________________________________________________________
39 AliMUONCalibParamND::AliMUONCalibParamND()
40 : AliMUONVCalibParam(),
46 /// Default constructor.
49 //_____________________________________________________________________________
50 AliMUONCalibParamND::AliMUONCalibParamND(Int_t dimension, Int_t theSize,
52 Double_t fillWithValue)
53 : AliMUONVCalibParam(id0,id1),
54 fDimension(dimension),
59 /// Normal constructor, where theSize specifies the number of channels handled
60 /// by this object, and fillWithValue the default value assigned to each
65 fValues = new Double_t[fN];
66 for ( Int_t i = 0; i < fN; ++i )
68 fValues[i] = fillWithValue;
74 //_____________________________________________________________________________
75 AliMUONCalibParamND::AliMUONCalibParamND(const AliMUONCalibParamND& other)
76 : AliMUONVCalibParam(),
87 //_____________________________________________________________________________
89 AliMUONCalibParamND::operator=(const AliMUONCalibParamND& other)
91 /// Assignment operator
97 //_____________________________________________________________________________
98 AliMUONCalibParamND::~AliMUONCalibParamND()
105 //_____________________________________________________________________________
107 AliMUONCalibParamND::CopyTo(AliMUONCalibParamND& destination) const
109 /// Copy *this to destination
111 delete[] destination.fValues;
113 destination.fSize = fSize;
114 destination.fDimension = fDimension;
118 destination.fValues = new Double_t[fN];
119 for ( Int_t i = 0; i < fN; ++i )
121 destination.fValues[i] = fValues[i];
126 //_____________________________________________________________________________
128 AliMUONCalibParamND::Index(Int_t i, Int_t j) const
130 /// Compute the 1D index of the internal storage from the pair (i,j)
131 /// Returns -1 if the (i,j) pair is invalid
133 if ( i >= 0 && i < Size() && j >= 0 && j < Dimension() )
140 //_____________________________________________________________________________
142 AliMUONCalibParamND::Print(Option_t* opt) const
144 /// Output this object to stdout.
145 /// If opt=="full", then all channels are printed,
146 /// if opt=="mean#", only the mean and sigma value are printed for j-th dimension
147 /// otherwise only the general characteristics are printed.
151 cout << Form("AliMUONCalibParamND Id=(%d,%d) Size=%d Dimension=%d",ID0(),
152 ID1(),Size(),Dimension()) << endl;
153 if ( sopt.Contains("FULL") )
155 for ( Int_t i = 0; i < Size(); ++i )
157 cout << Form("CH %3d",i);
158 for ( Int_t j = 0; j < Dimension(); ++j )
160 cout << Form(" %g",ValueAsDouble(i,j));
165 if ( sopt.Contains("MEAN") )
168 sscanf(sopt.Data(),"MEAN%d",&j);
175 for ( Int_t i = 0; i < Size(); ++i )
177 Float_t v = ValueAsDouble(i,j);
183 if ( n > 1 ) sigma = TMath::Sqrt( (v2-n*mean*mean)/(n-1) );
184 cout << Form(" Mean(j=%d)=%g Sigma(j=%d)=%g",j,mean,j,sigma) << endl;
189 //_____________________________________________________________________________
191 AliMUONCalibParamND::SetValueAsDouble(Int_t i, Int_t j, Double_t value)
193 /// Set one value as a double, after checking that the indices are correct.
195 Int_t ix = Index(i,j);
199 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
200 i,j,Size()-1,Dimension()-1));
209 //_____________________________________________________________________________
211 AliMUONCalibParamND::SetValueAsFloat(Int_t i, Int_t j, Float_t value)
213 /// Set one value as a float, after checking that the indices are correct.
214 SetValueAsDouble(i,j,static_cast<Double_t>(value));
217 //_____________________________________________________________________________
219 AliMUONCalibParamND::SetValueAsInt(Int_t i, Int_t j, Int_t value)
221 /// Set one value as an int.
223 SetValueAsFloat(i,j,static_cast<Float_t>(value));
226 //_____________________________________________________________________________
228 AliMUONCalibParamND::ValueAsDouble(Int_t i, Int_t j) const
230 /// Return the value as a double (which it is), after checking indices.
232 Int_t ix = Index(i,j);
236 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
237 i,j,Size()-1,Dimension()-1));
246 //_____________________________________________________________________________
248 AliMUONCalibParamND::ValueAsFloat(Int_t i, Int_t j) const
250 /// Return the value as a float
251 return static_cast<Float_t>(ValueAsDouble(i,j));
254 //_____________________________________________________________________________
256 AliMUONCalibParamND::ValueAsInt(Int_t i, Int_t j) const
258 /// Return the value as an int, by rounding the internal float value.
260 Float_t v = ValueAsFloat(i,j);
261 return TMath::Nint(v);