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 "AliMUONCalibParam1I.h"
21 #include "Riostream.h"
25 /// \class AliMUONCalibParam1I
27 /// This class is implementing the AliMUONVCalibParam interface.
29 /// It stores a given number of integers.
31 /// Those integers can also be retrieved as floats if really needed
32 /// (this is to comply with the base class).
34 /// You might consider just as it is, namely a C++ wrapper to
35 /// a plain int[] array.
37 /// \author Laurent Aphecetche
40 ClassImp(AliMUONCalibParam1I)
43 //_____________________________________________________________________________
44 AliMUONCalibParam1I::AliMUONCalibParam1I()
45 : AliMUONVCalibParam(),
49 /// Default constructor.
52 //_____________________________________________________________________________
53 AliMUONCalibParam1I::AliMUONCalibParam1I(Int_t theSize, Int_t fillWithValue)
54 : AliMUONVCalibParam(),
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 Int_t[fSize];
65 memset(fValues,fillWithValue,fSize*sizeof(Int_t));
69 //_____________________________________________________________________________
70 AliMUONCalibParam1I::AliMUONCalibParam1I(const AliMUONCalibParam1I& other)
71 : AliMUONVCalibParam(other),
80 //_____________________________________________________________________________
82 AliMUONCalibParam1I::operator=(const AliMUONCalibParam1I& other)
84 /// Assignment operator
86 AliMUONVCalibParam::operator=(other);
91 //_____________________________________________________________________________
92 AliMUONCalibParam1I::~AliMUONCalibParam1I()
99 //_____________________________________________________________________________
101 AliMUONCalibParam1I::CopyTo(AliMUONCalibParam1I& destination) const
103 /// Copy this into destination.
105 delete[] destination.fValues;
106 destination.fSize = fSize;
109 destination.fValues = new Int_t[fSize];
110 for ( Int_t i = 0; i < fSize; ++i )
112 destination.fValues[i] = fValues[i];
117 //_____________________________________________________________________________
119 AliMUONCalibParam1I::Print(Option_t* opt) const
121 /// Output this object to stdout.
122 /// If opt=="full", then all channels are printed, otherwise
123 /// only the general characteristics are printed.
127 cout << "AliMUONCalibParam1I - Size=" << Size()
128 << " Dimension=" << Dimension()
130 if ( sopt.Contains("FULL") )
132 for ( Int_t i = 0; i < Size(); ++i )
134 cout << setw(6) << ValueAsInt(i) << " , " << endl;
139 //_____________________________________________________________________________
141 AliMUONCalibParam1I::SetValueAsFloat(Int_t i, Int_t j, Float_t value)
143 /// Set the value as a float, which is casted to an int prior to storage.
145 SetValueAsInt(i,j,TMath::Nint(value));
148 //_____________________________________________________________________________
150 AliMUONCalibParam1I::SetValueAsInt(Int_t i, Int_t j, Int_t value)
152 /// Set the value for a given channel.
153 /// (i,j) are checked for correctness before use.
155 if ( j != 0 || i >= fSize || i < 0 )
157 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
158 i,j,Size()-1,Dimension()-1));
166 //_____________________________________________________________________________
168 AliMUONCalibParam1I::ValueAsFloat(Int_t i, Int_t j) const
170 /// Return one value as a float.
172 return 1.0*ValueAsInt(i,j);
175 //_____________________________________________________________________________
177 AliMUONCalibParam1I::ValueAsInt(Int_t i, Int_t j) const
179 /// Return one value as an integer, after checking that (i,j)
180 /// are valid indices.
182 if ( j != 0 || i >= fSize || i < 0 )
184 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
185 i,j,Size()-1,Dimension()-1));