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"
27 /// \class AliMUONCalibParamNF
29 /// Handle the case of N floating point parameters per channel.
31 /// \author Laurent Aphecetche
34 ClassImp(AliMUONCalibParamNF)
37 //_____________________________________________________________________________
38 AliMUONCalibParamNF::AliMUONCalibParamNF()
39 : AliMUONVCalibParam(),
45 /// Default constructor.
48 //_____________________________________________________________________________
49 AliMUONCalibParamNF::AliMUONCalibParamNF(Int_t dimension, Int_t theSize, Float_t fillWithValue)
50 : AliMUONVCalibParam(),
51 fDimension(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 AliMUONCalibParamNF::AliMUONCalibParamNF(const AliMUONCalibParamNF& other)
73 : AliMUONVCalibParam(),
84 //_____________________________________________________________________________
86 AliMUONCalibParamNF::operator=(const AliMUONCalibParamNF& other)
88 /// Assignment operator
94 //_____________________________________________________________________________
95 AliMUONCalibParamNF::~AliMUONCalibParamNF()
102 //_____________________________________________________________________________
104 AliMUONCalibParamNF::CopyTo(AliMUONCalibParamNF& destination) const
106 /// Copy *this to destination
108 delete[] destination.fValues;
110 destination.fSize = fSize;
111 destination.fDimension = fDimension;
115 destination.fValues = new Float_t[fN];
116 for ( Int_t i = 0; i < fN; ++i )
118 destination.fValues[i] = fValues[i];
123 //_____________________________________________________________________________
125 AliMUONCalibParamNF::Index(Int_t i, Int_t j) const
127 /// Compute the 1D index of the internal storage from the pair (i,j)
128 /// Returns -1 if the (i,j) pair is invalid
130 if ( i >= 0 && i < Size() && j >= 0 && j < Dimension() )
137 //_____________________________________________________________________________
139 AliMUONCalibParamNF::Print(Option_t* opt) const
141 /// Output this object to stdout.
142 /// If opt=="full", then all channels are printed,
143 /// if opt=="mean#", only the mean and sigma value are printed for j-th dimension
144 /// otherwise only the general characteristics are printed.
148 cout << "AliMUONCalibParamNF - Size=" << Size()
149 << " Dimension=" << Dimension() << endl;
150 if ( sopt.Contains("FULL") )
152 for ( Int_t i = 0; i < Size(); ++i )
154 cout << Form("CH %3d",i);
155 for ( Int_t j = 0; j < Dimension(); ++j )
157 cout << Form(" %e",ValueAsFloat(i,j));
162 if ( sopt.Contains("MEAN") )
165 sscanf(sopt.Data(),"MEAN%d",&j);
172 for ( Int_t i = 0; i < Size(); ++i )
174 Float_t v = ValueAsFloat(i,j);
180 if ( n > 1 ) sigma = TMath::Sqrt( (v2-n*mean*mean)/(n-1) );
181 cout << Form(" Mean(j=%d)=%e Sigma(j=%d)=%e",j,mean,j,sigma) << endl;
186 //_____________________________________________________________________________
188 AliMUONCalibParamNF::SetValueAsFloat(Int_t i, Int_t j, Float_t value)
190 /// Set one value as a float, after checking that the indices are correct.
192 Int_t ix = Index(i,j);
196 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
197 i,j,Size()-1,Dimension()-1));
205 //_____________________________________________________________________________
207 AliMUONCalibParamNF::SetValueAsInt(Int_t i, Int_t j, Int_t value)
209 /// Set one value as an int.
211 SetValueAsFloat(i,j,static_cast<Float_t>(value));
214 //_____________________________________________________________________________
216 AliMUONCalibParamNF::ValueAsFloat(Int_t i, Int_t j) const
218 /// Return the value as a float (which it is), after checking indices.
220 Int_t ix = Index(i,j);
224 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
225 i,j,Size()-1,Dimension()-1));
234 //_____________________________________________________________________________
236 AliMUONCalibParamNF::ValueAsInt(Int_t i, Int_t j) const
238 /// Return the value as an int, by rounding the internal float value.
240 Float_t v = ValueAsFloat(i,j);
241 return TMath::Nint(v);