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 "AliMUONCalibParamNF.h"
22 #include "Riostream.h"
26 //-----------------------------------------------------------------------------
27 /// \class AliMUONCalibParamNF
29 /// Handle the case of N floating point parameters per channel.
31 /// \author Laurent Aphecetche
32 //-----------------------------------------------------------------------------
35 ClassImp(AliMUONCalibParamNF)
38 //_____________________________________________________________________________
39 AliMUONCalibParamNF::AliMUONCalibParamNF()
40 : AliMUONVCalibParam(),
46 /// Default constructor.
49 //_____________________________________________________________________________
50 AliMUONCalibParamNF::AliMUONCalibParamNF(Int_t dimension, Int_t theSize,
52 Float_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 Float_t[fN];
66 for ( Int_t i = 0; i < fN; ++i )
68 fValues[i] = fillWithValue;
74 //_____________________________________________________________________________
75 AliMUONCalibParamNF::AliMUONCalibParamNF(const AliMUONCalibParamNF& other)
76 : AliMUONVCalibParam(),
87 //_____________________________________________________________________________
89 AliMUONCalibParamNF::operator=(const AliMUONCalibParamNF& other)
91 /// Assignment operator
97 //_____________________________________________________________________________
98 AliMUONCalibParamNF::~AliMUONCalibParamNF()
105 //_____________________________________________________________________________
107 AliMUONCalibParamNF::CopyTo(AliMUONCalibParamNF& destination) const
109 /// Copy *this to destination
111 const TObject& o = static_cast<const TObject&>(*this);
114 delete[] destination.fValues;
116 destination.fSize = fSize;
117 destination.fDimension = fDimension;
121 destination.fValues = new Float_t[fN];
122 for ( Int_t i = 0; i < fN; ++i )
124 destination.fValues[i] = fValues[i];
129 //_____________________________________________________________________________
131 AliMUONCalibParamNF::Index(Int_t i, Int_t j) const
133 /// Compute the 1D index of the internal storage from the pair (i,j)
134 /// Returns -1 if the (i,j) pair is invalid
136 if ( i >= 0 && i < Size() && j >= 0 && j < Dimension() )
138 return IndexFast(i,j);
143 //_____________________________________________________________________________
145 AliMUONCalibParamNF::IndexFast(Int_t i, Int_t j) const
147 /// Compute the 1D index of the internal storage from the pair (i,j)
152 //_____________________________________________________________________________
154 AliMUONCalibParamNF::Print(Option_t* opt) const
156 /// Output this object to stdout.
157 /// If opt=="full", then all channels are printed,
158 /// if opt=="mean#", only the mean and sigma value are printed for j-th dimension
159 /// otherwise only the general characteristics are printed.
163 cout << Form("AliMUONCalibParamNF Id=(%d,%d) Size=%d Dimension=%d",ID0(),
164 ID1(),Size(),Dimension()) << endl;
165 if ( sopt.Contains("FULL") )
167 for ( Int_t i = 0; i < Size(); ++i )
169 cout << Form("CH %3d",i);
170 for ( Int_t j = 0; j < Dimension(); ++j )
172 cout << Form(" %e",ValueAsFloat(i,j));
177 if ( sopt.Contains("MEAN") )
180 sscanf(sopt.Data(),"MEAN%d",&j);
187 for ( Int_t i = 0; i < Size(); ++i )
189 Float_t v = ValueAsFloat(i,j);
195 if ( n > 1 ) sigma = TMath::Sqrt( (v2-n*mean*mean)/(n-1) );
196 cout << Form(" Mean(j=%d)=%e Sigma(j=%d)=%e",j,mean,j,sigma) << endl;
201 //_____________________________________________________________________________
203 AliMUONCalibParamNF::SetValueAsFloat(Int_t i, Int_t j, Float_t value)
205 /// Set one value as a float, after checking that the indices are correct.
207 Int_t ix = Index(i,j);
211 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
212 i,j,Size()-1,Dimension()-1));
220 //_____________________________________________________________________________
222 AliMUONCalibParamNF::SetValueAsFloatFast(Int_t i, Int_t j, Float_t value)
224 /// Set one value as a float, w/o checking that the indices are correct.
226 fValues[IndexFast(i,j)] = value;
229 //_____________________________________________________________________________
231 AliMUONCalibParamNF::SetValueAsInt(Int_t i, Int_t j, Int_t value)
233 /// Set one value as an int.
235 SetValueAsFloat(i,j,static_cast<Float_t>(value));
238 //_____________________________________________________________________________
240 AliMUONCalibParamNF::SetValueAsIntFast(Int_t i, Int_t j, Int_t value)
242 /// Set one value as an int.
244 SetValueAsFloatFast(i,j,static_cast<Float_t>(value));
247 //_____________________________________________________________________________
249 AliMUONCalibParamNF::ValueAsFloat(Int_t i, Int_t j) const
251 /// Return the value as a float (which it is), after checking indices.
253 Int_t ix = Index(i,j);
257 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
258 i,j,Size()-1,Dimension()-1));
267 //_____________________________________________________________________________
269 AliMUONCalibParamNF::ValueAsFloatFast(Int_t i, Int_t j) const
271 /// Return the value as a float (which it is), after checking indices.
273 return fValues[IndexFast(i,j)];
276 //_____________________________________________________________________________
278 AliMUONCalibParamNF::ValueAsInt(Int_t i, Int_t j) const
280 /// Return the value as an int, by rounding the internal float value.
282 Float_t v = ValueAsFloat(i,j);
283 return TMath::Nint(v);
286 //_____________________________________________________________________________
288 AliMUONCalibParamNF::ValueAsIntFast(Int_t i, Int_t j) const
290 /// Return the value as an int, by rounding the internal float value.
292 Float_t v = ValueAsFloatFast(i,j);
293 return TMath::Nint(v);