]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONCalibParam1I.cxx
hardcoded detector position; bug in alignment pth fixed
[u/mrichter/AliRoot.git] / MUON / AliMUONCalibParam1I.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 "AliMUONCalibParam1I.h"
19
20#include "AliLog.h"
21#include "Riostream.h"
22#include "TMath.h"
23#include "TString.h"
24
5398f946 25/// \class AliMUONCalibParam1I
26///
9d5f6a64 27/// This class is implementing the AliMUONVCalibParam interface.
28///
29/// It stores a given number of integers.
30///
31/// Those integers can also be retrieved as floats if really needed
32/// (this is to comply with the base class).
33///
34/// You might consider just as it is, namely a C++ wrapper to
35/// a plain int[] array.
5398f946 36///
37/// \author Laurent Aphecetche
9d5f6a64 38
5398f946 39/// \cond CLASSIMP
9369bbee 40ClassImp(AliMUONCalibParam1I)
5398f946 41/// \endcond
9369bbee 42
43//_____________________________________________________________________________
44AliMUONCalibParam1I::AliMUONCalibParam1I()
45: AliMUONVCalibParam(),
46 fSize(0),
47 fValues(0x0)
48{
5398f946 49/// Default constructor.
9369bbee 50}
51
52//_____________________________________________________________________________
53AliMUONCalibParam1I::AliMUONCalibParam1I(Int_t theSize, Int_t fillWithValue)
54: AliMUONVCalibParam(),
ccea41d4 55 fSize(theSize),
56 fValues(0x0)
9369bbee 57{
5398f946 58/// Normal constructor, where theSize specifies the number of channels handled
59/// by this object, and fillWithValue the default value assigned to each
60/// channel.
61
9369bbee 62 if ( fSize > 0 )
63 {
64 fValues = new Int_t[fSize];
65 memset(fValues,fillWithValue,fSize*sizeof(Int_t));
66 }
67}
68
9d5f6a64 69//_____________________________________________________________________________
70AliMUONCalibParam1I::AliMUONCalibParam1I(const AliMUONCalibParam1I& other)
71: AliMUONVCalibParam(other),
72fSize(0),
73fValues(0x0)
74{
5398f946 75/// Copy constructor
76
9d5f6a64 77 other.CopyTo(*this);
78}
884a73f1 79
9d5f6a64 80//_____________________________________________________________________________
81AliMUONCalibParam1I&
82AliMUONCalibParam1I::operator=(const AliMUONCalibParam1I& other)
83{
5398f946 84/// Assignment operator
85
9d5f6a64 86 AliMUONVCalibParam::operator=(other);
87 other.CopyTo(*this);
88 return *this;
884a73f1 89}
90
9369bbee 91//_____________________________________________________________________________
92AliMUONCalibParam1I::~AliMUONCalibParam1I()
93{
5398f946 94/// Destructor.
95
9369bbee 96 delete[] fValues;
97}
98
9d5f6a64 99//_____________________________________________________________________________
100void
101AliMUONCalibParam1I::CopyTo(AliMUONCalibParam1I& destination) const
884a73f1 102{
5398f946 103/// Copy this into destination.
104
9d5f6a64 105 delete[] destination.fValues;
106 destination.fSize = fSize;
107 if ( fSize > 0 )
108 {
109 destination.fValues = new Int_t[fSize];
110 for ( Int_t i = 0; i < fSize; ++i )
111 {
112 destination.fValues[i] = fValues[i];
113 }
114 }
115}
884a73f1 116
9369bbee 117//_____________________________________________________________________________
118void
119AliMUONCalibParam1I::Print(Option_t* opt) const
120{
5398f946 121/// Output this object to stdout.
122/// If opt=="full", then all channels are printed, otherwise
123/// only the general characteristics are printed.
124
9369bbee 125 TString sopt(opt);
126 sopt.ToUpper();
127 cout << "AliMUONCalibParam1I - Size=" << Size()
128 << " Dimension=" << Dimension()
129 << endl;
130 if ( sopt.Contains("FULL") )
131 {
132 for ( Int_t i = 0; i < Size(); ++i )
133 {
134 cout << setw(6) << ValueAsInt(i) << " , " << endl;
135 }
136 }
137}
138
139//_____________________________________________________________________________
140void
141AliMUONCalibParam1I::SetValueAsFloat(Int_t i, Int_t j, Float_t value)
142{
5398f946 143/// Set the value as a float, which is casted to an int prior to storage.
144
9369bbee 145 SetValueAsInt(i,j,TMath::Nint(value));
146}
147
148//_____________________________________________________________________________
149void
150AliMUONCalibParam1I::SetValueAsInt(Int_t i, Int_t j, Int_t value)
151{
5398f946 152/// Set the value for a given channel.
153/// (i,j) are checked for correctness before use.
154
9369bbee 155 if ( j != 0 || i >= fSize || i < 0 )
156 {
157 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
158 i,j,Size()-1,Dimension()-1));
159 }
160 else
161 {
162 fValues[i]=value;
163 }
164}
165
166//_____________________________________________________________________________
167Float_t
168AliMUONCalibParam1I::ValueAsFloat(Int_t i, Int_t j) const
169{
5398f946 170/// Return one value as a float.
171
9369bbee 172 return 1.0*ValueAsInt(i,j);
173}
174
175//_____________________________________________________________________________
176Int_t
177AliMUONCalibParam1I::ValueAsInt(Int_t i, Int_t j) const
178{
5398f946 179/// Return one value as an integer, after checking that (i,j)
180/// are valid indices.
181
9369bbee 182 if ( j != 0 || i >= fSize || i < 0 )
183 {
184 AliError(Form("Invalid (i,j)=(%d,%d) max allowed is (%d,%d)",
185 i,j,Size()-1,Dimension()-1));
186 return 0;
187 }
188 else
189 {
190 return fValues[i];
191 }
192}