]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONCalibParam2F.cxx
Corrected Doxygen warnings:
[u/mrichter/AliRoot.git] / MUON / AliMUONCalibParam2F.cxx
CommitLineData
9369bbee 1/**************************************************************************
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
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**************************************************************************/
15
16// $Id$
17
18#include "AliMUONCalibParam2F.h"
19
20#include "AliLog.h"
21#include "Riostream.h"
22#include "TMath.h"
23#include "TString.h"
24
9d5f6a64 25///
5398f946 26/// \class AliMUONCalibParam2F
9d5f6a64 27///
5398f946 28/// Handle the case of 2 floating point parameters per channel.
9d5f6a64 29/// Conceptually, this class is the equivalent of a vector or float pairs,
30/// but it is implemented using bare Float_t[] array.
31///
5398f946 32/// \author Laurent Aphecetche
9d5f6a64 33
5398f946 34/// \cond CLASSIMP
9369bbee 35ClassImp(AliMUONCalibParam2F)
5398f946 36/// \endcond
9369bbee 37
38//_____________________________________________________________________________
39AliMUONCalibParam2F::AliMUONCalibParam2F()
40: AliMUONVCalibParam(),
41 fSize(0),
42 fN(0),
43 fValues(0x0)
44{
5398f946 45/// Default constructor.
9369bbee 46}
47
48//_____________________________________________________________________________
cab93aff 49AliMUONCalibParam2F::AliMUONCalibParam2F(Int_t theSize, Float_t fillWithValue)
9369bbee 50: AliMUONVCalibParam(),
51 fSize(theSize),
ccea41d4 52 fN(fSize*Dimension()),
53 fValues(0x0)
9369bbee 54{
5398f946 55/// Normal constructor, where theSize specifies the number of channels handled
56/// by this object, and fillWithValue the default value assigned to each
57/// channel.
58
9369bbee 59 if ( fN > 0 )
60 {
61 fValues = new Float_t[fN];
cab93aff 62 for ( Int_t i = 0; i < fN; ++i )
63 {
64 fValues[i] = fillWithValue;
65 }
9369bbee 66 }
67}
68
884a73f1 69
9d5f6a64 70//_____________________________________________________________________________
71AliMUONCalibParam2F::AliMUONCalibParam2F(const AliMUONCalibParam2F& other)
72: AliMUONVCalibParam(),
73fSize(0),
74fN(0),
75fValues(0x0)
76{
5398f946 77/// Copy constructor.
78
9d5f6a64 79 other.CopyTo(*this);
80}
81
82//_____________________________________________________________________________
83AliMUONCalibParam2F&
84AliMUONCalibParam2F::operator=(const AliMUONCalibParam2F& other)
85{
5398f946 86/// Assignment operator
87
9d5f6a64 88 other.CopyTo(*this);
89 return *this;
884a73f1 90}
91
9369bbee 92//_____________________________________________________________________________
93AliMUONCalibParam2F::~AliMUONCalibParam2F()
94{
5398f946 95/// Destructor
96
9369bbee 97 delete[] fValues;
98}
99
9d5f6a64 100//_____________________________________________________________________________
101void
102AliMUONCalibParam2F::CopyTo(AliMUONCalibParam2F& destination) const
884a73f1 103{
5398f946 104/// Copy *this to destination
105
9d5f6a64 106 delete[] destination.fValues;
107 destination.fN = fN;
108 destination.fSize = fSize;
884a73f1 109
9d5f6a64 110 if ( fN > 0 )
111 {
112 destination.fValues = new Float_t[fN];
113 for ( Int_t i = 0; i < fN; ++i )
114 {
115 destination.fValues[i] = fValues[i];
116 }
117 }
118}
884a73f1 119
9369bbee 120//_____________________________________________________________________________
121Int_t
122AliMUONCalibParam2F::Index(Int_t i, Int_t j) const
123{
5398f946 124/// Compute the 1D index of the internal storage from the pair (i,j)
125/// Returns -1 if the (i,j) pair is invalid
126
9369bbee 127 if ( i >= 0 && i < Size() && j >= 0 && j < Dimension() )
128 {
129 return i + Size()*j;
130 }
131 return -1;
132}
133
134//_____________________________________________________________________________
135void
136AliMUONCalibParam2F::Print(Option_t* opt) const
137{
5398f946 138/// Output this object to stdout.
156464c8 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.
5398f946 142
9369bbee 143 TString sopt(opt);
144 sopt.ToUpper();
145 cout << "AliMUONCalibParam2F - Size=" << Size()
156464c8 146 << " Dimension=" << Dimension();
9369bbee 147 if ( sopt.Contains("FULL") )
148 {
156464c8 149 cout << endl;
9369bbee 150 for ( Int_t i = 0; i < Size(); ++i )
151 {
156464c8 152 cout << Form("CH %3d %e %e",i,ValueAsFloat(i,0),ValueAsFloat(i,1)) << endl;
9369bbee 153 }
154 }
156464c8 155 if ( sopt.Contains("MEAN") )
156 {
157 Float_t mean(0);
158 Float_t v2(0);
159
4a46082d 160 Int_t n = Size();
156464c8 161
162 for ( Int_t i = 0; i < Size(); ++i )
163 {
164 Float_t v = ValueAsFloat(i);
165 mean += v;
166 v2 += v*v;
167 }
4a46082d 168 mean /= n;
156464c8 169 float sigma = 0;
4a46082d 170 if ( n > 1 ) sigma = TMath::Sqrt( (v2-n*mean*mean)/(n-1) );
156464c8 171 cout << Form(" Mean=%f Sigma=%f",mean,sigma) << endl;
172 }
173
9369bbee 174}
175
176//_____________________________________________________________________________
177void
178AliMUONCalibParam2F::SetValueAsFloat(Int_t i, Int_t j, Float_t value)
179{
5398f946 180/// Set one value as a float, after checking that the indices are correct.
181
9369bbee 182 Int_t ix = Index(i,j);
183
184 if ( ix < 0 )
185 {
186 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
187 i,j,Size()-1,Dimension()-1));
188 }
189 else
190 {
191 fValues[ix]=value;
192 }
193}
194
195//_____________________________________________________________________________
196void
197AliMUONCalibParam2F::SetValueAsInt(Int_t i, Int_t j, Int_t value)
198{
5398f946 199/// Set one value as an int.
200
9369bbee 201 SetValueAsFloat(i,j,static_cast<Float_t>(value));
202}
203
204//_____________________________________________________________________________
205Float_t
206AliMUONCalibParam2F::ValueAsFloat(Int_t i, Int_t j) const
207{
5398f946 208/// Return the value as a float (which it is), after checking indices.
209
9369bbee 210 Int_t ix = Index(i,j);
211
212 if ( ix < 0 )
213 {
214 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
215 i,j,Size()-1,Dimension()-1));
216 return 0.0;
217 }
218 else
219 {
220 return fValues[ix];
221 }
222}
223
224//_____________________________________________________________________________
225Int_t
226AliMUONCalibParam2F::ValueAsInt(Int_t i, Int_t j) const
227{
5398f946 228/// Return the value as an int, by rounding the internal float value.
229
9369bbee 230 Float_t v = ValueAsFloat(i,j);
231 return TMath::Nint(v);
232}