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,
51 Float_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 Float_t[fN];
65 for ( Int_t i = 0; i < fN; ++i )
67 fValues[i] = fillWithValue;
73 //_____________________________________________________________________________
74 AliMUONCalibParamNF::AliMUONCalibParamNF(const AliMUONCalibParamNF& other)
75 : AliMUONVCalibParam(),
86 //_____________________________________________________________________________
88 AliMUONCalibParamNF::operator=(const AliMUONCalibParamNF& other)
90 /// Assignment operator
96 //_____________________________________________________________________________
97 AliMUONCalibParamNF::~AliMUONCalibParamNF()
104 //_____________________________________________________________________________
106 AliMUONCalibParamNF::CopyTo(AliMUONCalibParamNF& destination) const
108 /// Copy *this to destination
110 const TObject& o = static_cast<const TObject&>(*this);
113 delete[] destination.fValues;
115 destination.fSize = fSize;
116 destination.fDimension = fDimension;
120 destination.fValues = new Float_t[fN];
121 for ( Int_t i = 0; i < fN; ++i )
123 destination.fValues[i] = fValues[i];
128 //_____________________________________________________________________________
130 AliMUONCalibParamNF::Index(Int_t i, Int_t j) const
132 /// Compute the 1D index of the internal storage from the pair (i,j)
133 /// Returns -1 if the (i,j) pair is invalid
135 if ( i >= 0 && i < Size() && j >= 0 && j < Dimension() )
142 //_____________________________________________________________________________
144 AliMUONCalibParamNF::Print(Option_t* opt) const
146 /// Output this object to stdout.
147 /// If opt=="full", then all channels are printed,
148 /// if opt=="mean#", only the mean and sigma value are printed for j-th dimension
149 /// otherwise only the general characteristics are printed.
153 cout << Form("AliMUONCalibParamNF Id=(%d,%d) Size=%d Dimension=%d",ID0(),
154 ID1(),Size(),Dimension()) << endl;
155 if ( sopt.Contains("FULL") )
157 for ( Int_t i = 0; i < Size(); ++i )
159 cout << Form("CH %3d",i);
160 for ( Int_t j = 0; j < Dimension(); ++j )
162 cout << Form(" %e",ValueAsFloat(i,j));
167 if ( sopt.Contains("MEAN") )
170 sscanf(sopt.Data(),"MEAN%d",&j);
177 for ( Int_t i = 0; i < Size(); ++i )
179 Float_t v = ValueAsFloat(i,j);
185 if ( n > 1 ) sigma = TMath::Sqrt( (v2-n*mean*mean)/(n-1) );
186 cout << Form(" Mean(j=%d)=%e Sigma(j=%d)=%e",j,mean,j,sigma) << endl;
191 //_____________________________________________________________________________
193 AliMUONCalibParamNF::SetValueAsFloat(Int_t i, Int_t j, Float_t value)
195 /// Set one value as a float, after checking that the indices are correct.
197 Int_t ix = Index(i,j);
201 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
202 i,j,Size()-1,Dimension()-1));
210 //_____________________________________________________________________________
212 AliMUONCalibParamNF::SetValueAsInt(Int_t i, Int_t j, Int_t value)
214 /// Set one value as an int.
216 SetValueAsFloat(i,j,static_cast<Float_t>(value));
219 //_____________________________________________________________________________
221 AliMUONCalibParamNF::ValueAsFloat(Int_t i, Int_t j) const
223 /// Return the value as a float (which it is), after checking indices.
225 Int_t ix = Index(i,j);
229 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
230 i,j,Size()-1,Dimension()-1));
239 //_____________________________________________________________________________
241 AliMUONCalibParamNF::ValueAsInt(Int_t i, Int_t j) const
243 /// Return the value as an int, by rounding the internal float value.
245 Float_t v = ValueAsFloat(i,j);
246 return TMath::Nint(v);