]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONCalibParam2F.cxx
removing unneeded include
[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
27/// \brief Implementation of AliMUONVCalibParam for pair of floats.
9d5f6a64 28///
5398f946 29/// Handle the case of 2 floating point parameters per channel.
9d5f6a64 30/// Conceptually, this class is the equivalent of a vector or float pairs,
31/// but it is implemented using bare Float_t[] array.
32///
5398f946 33/// \author Laurent Aphecetche
9d5f6a64 34
5398f946 35/// \cond CLASSIMP
9369bbee 36ClassImp(AliMUONCalibParam2F)
5398f946 37/// \endcond
9369bbee 38
39//_____________________________________________________________________________
40AliMUONCalibParam2F::AliMUONCalibParam2F()
41: AliMUONVCalibParam(),
42 fSize(0),
43 fN(0),
44 fValues(0x0)
45{
5398f946 46/// Default constructor.
9369bbee 47}
48
49//_____________________________________________________________________________
cab93aff 50AliMUONCalibParam2F::AliMUONCalibParam2F(Int_t theSize, Float_t fillWithValue)
9369bbee 51: AliMUONVCalibParam(),
52 fSize(theSize),
ccea41d4 53 fN(fSize*Dimension()),
54 fValues(0x0)
9369bbee 55{
5398f946 56/// Normal constructor, where theSize specifies the number of channels handled
57/// by this object, and fillWithValue the default value assigned to each
58/// channel.
59
9369bbee 60 if ( fN > 0 )
61 {
62 fValues = new Float_t[fN];
cab93aff 63 for ( Int_t i = 0; i < fN; ++i )
64 {
65 fValues[i] = fillWithValue;
66 }
9369bbee 67 }
68}
69
884a73f1 70
9d5f6a64 71//_____________________________________________________________________________
72AliMUONCalibParam2F::AliMUONCalibParam2F(const AliMUONCalibParam2F& other)
73: AliMUONVCalibParam(),
74fSize(0),
75fN(0),
76fValues(0x0)
77{
5398f946 78/// Copy constructor.
79
9d5f6a64 80 other.CopyTo(*this);
81}
82
83//_____________________________________________________________________________
84AliMUONCalibParam2F&
85AliMUONCalibParam2F::operator=(const AliMUONCalibParam2F& other)
86{
5398f946 87/// Assignment operator
88
9d5f6a64 89 other.CopyTo(*this);
90 return *this;
884a73f1 91}
92
9369bbee 93//_____________________________________________________________________________
94AliMUONCalibParam2F::~AliMUONCalibParam2F()
95{
5398f946 96/// Destructor
97
9369bbee 98 delete[] fValues;
99}
100
9d5f6a64 101//_____________________________________________________________________________
102void
103AliMUONCalibParam2F::CopyTo(AliMUONCalibParam2F& destination) const
884a73f1 104{
5398f946 105/// Copy *this to destination
106
9d5f6a64 107 delete[] destination.fValues;
108 destination.fN = fN;
109 destination.fSize = fSize;
884a73f1 110
9d5f6a64 111 if ( fN > 0 )
112 {
113 destination.fValues = new Float_t[fN];
114 for ( Int_t i = 0; i < fN; ++i )
115 {
116 destination.fValues[i] = fValues[i];
117 }
118 }
119}
884a73f1 120
9369bbee 121//_____________________________________________________________________________
122Int_t
123AliMUONCalibParam2F::Index(Int_t i, Int_t j) const
124{
5398f946 125/// Compute the 1D index of the internal storage from the pair (i,j)
126/// Returns -1 if the (i,j) pair is invalid
127
9369bbee 128 if ( i >= 0 && i < Size() && j >= 0 && j < Dimension() )
129 {
130 return i + Size()*j;
131 }
132 return -1;
133}
134
135//_____________________________________________________________________________
136void
137AliMUONCalibParam2F::Print(Option_t* opt) const
138{
5398f946 139/// Output this object to stdout.
140/// If opt=="full", then all channels are printed, otherwise
141/// only the general characteristics are printed.
142
9369bbee 143 TString sopt(opt);
144 sopt.ToUpper();
145 cout << "AliMUONCalibParam2F - Size=" << Size()
146 << " Dimension=" << Dimension()
147 << endl;
148 if ( sopt.Contains("FULL") )
149 {
150 for ( Int_t i = 0; i < Size(); ++i )
151 {
152 cout << setw(6) << ValueAsFloat(i,0) << "," << ValueAsFloat(i,1) << endl;
153 }
154 }
155}
156
157//_____________________________________________________________________________
158void
159AliMUONCalibParam2F::SetValueAsFloat(Int_t i, Int_t j, Float_t value)
160{
5398f946 161/// Set one value as a float, after checking that the indices are correct.
162
9369bbee 163 Int_t ix = Index(i,j);
164
165 if ( ix < 0 )
166 {
167 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
168 i,j,Size()-1,Dimension()-1));
169 }
170 else
171 {
172 fValues[ix]=value;
173 }
174}
175
176//_____________________________________________________________________________
177void
178AliMUONCalibParam2F::SetValueAsInt(Int_t i, Int_t j, Int_t value)
179{
5398f946 180/// Set one value as an int.
181
9369bbee 182 SetValueAsFloat(i,j,static_cast<Float_t>(value));
183}
184
185//_____________________________________________________________________________
186Float_t
187AliMUONCalibParam2F::ValueAsFloat(Int_t i, Int_t j) const
188{
5398f946 189/// Return the value as a float (which it is), after checking indices.
190
9369bbee 191 Int_t ix = Index(i,j);
192
193 if ( ix < 0 )
194 {
195 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
196 i,j,Size()-1,Dimension()-1));
197 return 0.0;
198 }
199 else
200 {
201 return fValues[ix];
202 }
203}
204
205//_____________________________________________________________________________
206Int_t
207AliMUONCalibParam2F::ValueAsInt(Int_t i, Int_t j) const
208{
5398f946 209/// Return the value as an int, by rounding the internal float value.
210
9369bbee 211 Float_t v = ValueAsFloat(i,j);
212 return TMath::Nint(v);
213}