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 "AliMUONCalibParam2F.h"
21 #include "Riostream.h"
26 /// \class AliMUONCalibParam2F
28 /// Handle the case of 2 floating point parameters per channel.
29 /// Conceptually, this class is the equivalent of a vector or float pairs,
30 /// but it is implemented using bare Float_t[] array.
32 /// \author Laurent Aphecetche
35 ClassImp(AliMUONCalibParam2F)
38 //_____________________________________________________________________________
39 AliMUONCalibParam2F::AliMUONCalibParam2F()
40 : AliMUONVCalibParam(),
45 /// Default constructor.
48 //_____________________________________________________________________________
49 AliMUONCalibParam2F::AliMUONCalibParam2F(Int_t theSize, Float_t fillWithValue)
50 : AliMUONVCalibParam(),
52 fN(fSize*Dimension()),
55 /// Normal constructor, where theSize specifies the number of channels handled
56 /// by this object, and fillWithValue the default value assigned to each
61 fValues = new Float_t[fN];
62 for ( Int_t i = 0; i < fN; ++i )
64 fValues[i] = fillWithValue;
70 //_____________________________________________________________________________
71 AliMUONCalibParam2F::AliMUONCalibParam2F(const AliMUONCalibParam2F& other)
72 : AliMUONVCalibParam(),
82 //_____________________________________________________________________________
84 AliMUONCalibParam2F::operator=(const AliMUONCalibParam2F& other)
86 /// Assignment operator
92 //_____________________________________________________________________________
93 AliMUONCalibParam2F::~AliMUONCalibParam2F()
100 //_____________________________________________________________________________
102 AliMUONCalibParam2F::CopyTo(AliMUONCalibParam2F& destination) const
104 /// Copy *this to destination
106 delete[] destination.fValues;
108 destination.fSize = fSize;
112 destination.fValues = new Float_t[fN];
113 for ( Int_t i = 0; i < fN; ++i )
115 destination.fValues[i] = fValues[i];
120 //_____________________________________________________________________________
122 AliMUONCalibParam2F::Index(Int_t i, Int_t j) const
124 /// Compute the 1D index of the internal storage from the pair (i,j)
125 /// Returns -1 if the (i,j) pair is invalid
127 if ( i >= 0 && i < Size() && j >= 0 && j < Dimension() )
134 //_____________________________________________________________________________
136 AliMUONCalibParam2F::Print(Option_t* opt) const
138 /// Output this object to stdout.
139 /// If opt=="full", then all channels are printed,
140 /// if opt=="mean", only the mean and sigma value are printed,
141 /// otherwise only the general characteristics are printed.
145 cout << "AliMUONCalibParam2F - Size=" << Size()
146 << " Dimension=" << Dimension();
147 if ( sopt.Contains("FULL") )
150 for ( Int_t i = 0; i < Size(); ++i )
152 cout << Form("CH %3d %e %e",i,ValueAsFloat(i,0),ValueAsFloat(i,1)) << endl;
155 if ( sopt.Contains("MEAN") )
162 for ( Int_t i = 0; i < Size(); ++i )
164 Float_t v = ValueAsFloat(i);
170 if ( n > 1 ) sigma = TMath::Sqrt( (v2-n*mean*mean)/(n-1) );
171 cout << Form(" Mean=%f Sigma=%f",mean,sigma) << endl;
176 //_____________________________________________________________________________
178 AliMUONCalibParam2F::SetValueAsFloat(Int_t i, Int_t j, Float_t value)
180 /// Set one value as a float, after checking that the indices are correct.
182 Int_t ix = Index(i,j);
186 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
187 i,j,Size()-1,Dimension()-1));
195 //_____________________________________________________________________________
197 AliMUONCalibParam2F::SetValueAsInt(Int_t i, Int_t j, Int_t value)
199 /// Set one value as an int.
201 SetValueAsFloat(i,j,static_cast<Float_t>(value));
204 //_____________________________________________________________________________
206 AliMUONCalibParam2F::ValueAsFloat(Int_t i, Int_t j) const
208 /// Return the value as a float (which it is), after checking indices.
210 Int_t ix = Index(i,j);
214 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
215 i,j,Size()-1,Dimension()-1));
224 //_____________________________________________________________________________
226 AliMUONCalibParam2F::ValueAsInt(Int_t i, Int_t j) const
228 /// Return the value as an int, by rounding the internal float value.
230 Float_t v = ValueAsFloat(i,j);
231 return TMath::Nint(v);