]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONVCalibParam.cxx
Coverity fix
[u/mrichter/AliRoot.git] / MUON / AliMUONVCalibParam.cxx
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 "AliMUONVCalibParam.h"
19
20 #include "AliLog.h"
21
22 //-----------------------------------------------------------------------------
23 /// \class AliMUONVCalibParam
24 ///  
25 /// Defines an interface for a calibration container object.
26 ///
27 /// Note that a VCalibParam object is identified by a pair (id0,id1), 
28 /// where each member of the pair is a 16 bits word, so that id0 and id1
29 /// can be packed into a single 32 bits word.
30 ///
31 /// id1 might be left to zero if not required (e.g. for calibparam which 
32 /// can be identified by a single integer)
33 ///
34 /// Note that the ValueAsXXX methods have 2 versions : with or without bound
35 /// checking. The latter is to be used in e.g. loops, where you know for
36 /// sure the indices are ok, in order to gain some time.
37 ///
38 /// \author Laurent Aphecetche, Subatech
39 //-----------------------------------------------------------------------------
40
41 /// \cond CLASSIMP
42 ClassImp(AliMUONVCalibParam)
43 /// \endcond
44
45 //_____________________________________________________________________________
46 AliMUONVCalibParam::AliMUONVCalibParam() : TObject()
47 {
48   ///  Default constructor
49 }
50
51 //_____________________________________________________________________________
52 AliMUONVCalibParam::AliMUONVCalibParam(Int_t id0, Int_t id1) : TObject()
53 {
54   ///  constructor for 2D
55   SetUniqueID(BuildUniqueID(id0,id1));
56 }
57
58 //_____________________________________________________________________________
59 AliMUONVCalibParam::~AliMUONVCalibParam()
60 {
61 /// Destructor.
62 }
63
64 //_____________________________________________________________________________
65 UInt_t
66 AliMUONVCalibParam::BuildUniqueID(Int_t id0, Int_t id1)
67 {
68   /// Build a single index from the pair (id0,id1)
69   return ( id0 | ( id1 << 16 ) );
70 }
71
72 //_____________________________________________________________________________
73 void
74 AliMUONVCalibParam::DecodeUniqueID(UInt_t uniqueID, Int_t& id0, Int_t& id1)
75 {
76   /// Convert single integer into a pair (i,j)
77   id0 = ID0(uniqueID);
78   id1 = ID1(uniqueID);
79 }
80
81 //_____________________________________________________________________________
82 Int_t
83 AliMUONVCalibParam::ID0(UInt_t uniqueID)
84 {
85   /// Extract id0 from uniqueID
86   return uniqueID & 0xFFFF;
87 }
88
89 //_____________________________________________________________________________
90 Int_t
91 AliMUONVCalibParam::ID0() const
92 {
93   /// Extract first identifier
94   return ID0(GetUniqueID());
95 }
96
97 //_____________________________________________________________________________
98 Int_t
99 AliMUONVCalibParam::ID1(UInt_t uniqueID)
100 {
101   /// Extract id1 from uniqueID
102   return ( uniqueID & 0xFFFF0000 ) >> 16;
103 }
104
105 //_____________________________________________________________________________
106 Int_t
107 AliMUONVCalibParam::ID1() const
108 {
109   /// Extract second identifier
110   return ID1(GetUniqueID());
111 }
112
113 //_____________________________________________________________________________
114 const char* 
115 AliMUONVCalibParam::GetName() const
116 {
117   /// Build a name for this object
118   return Form("I=%d,J=%d",ID0(),ID1());
119 }
120
121 //_____________________________________________________________________________
122 void 
123 AliMUONVCalibParam::SetValueAsDouble(Int_t, Int_t, Double_t)
124 {
125   /// By default, this one does not exist
126   AliFatal("Not implemented");
127 }
128
129 //_____________________________________________________________________________
130 void 
131 AliMUONVCalibParam::SetValueAsDoubleFast(Int_t, Int_t, Double_t)
132 {
133   /// By default, this one does not exist
134   AliFatal("Not implemented");
135 }
136
137 //_____________________________________________________________________________
138 Double_t 
139 AliMUONVCalibParam::ValueAsDouble(Int_t , Int_t ) const
140 {
141   /// By default, this one does not exist
142   AliFatal("Not implemented");
143   return 0;
144 }
145
146 //_____________________________________________________________________________
147 Double_t 
148 AliMUONVCalibParam::ValueAsDoubleFast(Int_t , Int_t ) const
149 {
150   /// By default, this one does not exist
151   AliFatal("Not implemented");
152   return 0;
153 }
154
155 //_____________________________________________________________________________
156 Int_t 
157 AliMUONVCalibParam::Compare(const TObject* object) const
158 {
159   /// Compare AliMUONVCalibParam objects, trying to get as complete an order as possible.
160   /// We sort by ID0, then by ID1
161   ///
162   const AliMUONVCalibParam* param = static_cast<const AliMUONVCalibParam*>(object);
163   
164   if ( ID0() == param->ID0() )
165   {
166     if ( ID1() == param->ID1() )
167     {
168       return 0;
169     }
170     else
171       return (ID1() >= param->ID1()) ? 1 : -1;
172   }
173   else
174     return ( ID0() >= param->ID0()) ? 1 : -1;
175 }
176
177