#include "TMath.h"
#include "TString.h"
-///
+//-----------------------------------------------------------------------------
/// \class AliMUONCalibParamNI
///
/// Handle the case of N integer parameters per channel.
/// and use the correct type.
///
/// \author Laurent Aphecetche
+//-----------------------------------------------------------------------------
/// \cond CLASSIMP
ClassImp(AliMUONCalibParamNI)
fValues(0x0)
{
/// Default constructor.
+ AliDebug(1,Form("this=%p default ctor",this));
}
//_____________________________________________________________________________
-AliMUONCalibParamNI::AliMUONCalibParamNI(Int_t dimension, Int_t theSize,
+AliMUONCalibParamNI::AliMUONCalibParamNI(Int_t dimension, Int_t theSize,
+ Int_t id0, Int_t id1,
Int_t fillWithValue, Int_t packingFactor)
-: AliMUONVCalibParam(),
+: AliMUONVCalibParam(id0,id1),
fDimension(dimension),
fSize(theSize),
fN(fSize*fDimension),
/// by this object, and fillWithValue the default value assigned to each
/// channel.
+// AliDebug(1,Form("this=%p dimension=%d theSize=%d fillWithValue=%d packingFactor=%d",
+// this,dimension,theSize,fillWithValue,packingFactor));
+
if ( fN > 0 )
{
fValues = new Int_t[fN];
{
/// Copy constructor.
+ AliDebug(1,Form("this=%p copy ctor",this));
other.CopyTo(*this);
}
{
/// Destructor
+ AliDebug(1,Form("this=%p",this));
delete[] fValues;
}
{
/// Copy *this to destination
+ const TObject& o = static_cast<const TObject&>(*this);
+ o.Copy(destination);
+
delete[] destination.fValues;
destination.fN = fN;
destination.fSize = fSize;
if ( i >= 0 && i < Size() && j >= 0 && j < Dimension() )
{
- return i + Size()*j;
+ return IndexFast(i,j);
}
return -1;
}
+//_____________________________________________________________________________
+Int_t
+AliMUONCalibParamNI::IndexFast(Int_t i, Int_t j) const
+{
+ /// Compute the 1D index of the internal storage from the pair (i,j)
+
+ return i + Size()*j;
+}
+
//_____________________________________________________________________________
void
AliMUONCalibParamNI::Print(Option_t* opt) const
TString sopt(opt);
sopt.ToUpper();
cout << "AliMUONCalibParamNI - Size=" << Size()
- << " Dimension=" << Dimension();
+ << " Dimension=" << Dimension()
+ << " Id=(" << ID0() << "," << ID1() << ")";
+
if ( IsPacked() )
{
cout << " Packing Factor=" << fPackingFactor;
{
Int_t m,c;
UnpackValue(v,m,c);
- cout << Form(" (%d,%d)",m,c);
+ cout << Form(" (%d,%d) (0x%x,0x%x)",m,c,m,c);
}
else
{
- cout << Form(" %d",v);
+ cout << Form(" %d (0x%x)",v,v);
}
}
cout << endl;
}
}
+//_____________________________________________________________________________
+void
+AliMUONCalibParamNI::SetValueAsIntFast(Int_t i, Int_t j, Int_t value)
+{
+ /// Set one value as a float, w/o checking that the indices are correct.
+
+ fValues[IndexFast(i,j)] = value;
+}
+
//_____________________________________________________________________________
void
AliMUONCalibParamNI::SetValueAsFloat(Int_t i, Int_t j, Float_t value)
SetValueAsInt(i,j,TMath::Nint(value));
}
+//_____________________________________________________________________________
+void
+AliMUONCalibParamNI::SetValueAsFloatFast(Int_t i, Int_t j, Float_t value)
+{
+ /// Set one value as an int.
+
+ AliWarning("Float will be rounded to be stored...");
+ SetValueAsIntFast(i,j,TMath::Nint(value));
+}
+
+
//_____________________________________________________________________________
Int_t
AliMUONCalibParamNI::ValueAsInt(Int_t i, Int_t j) const
}
}
+//_____________________________________________________________________________
+Int_t
+AliMUONCalibParamNI::ValueAsIntFast(Int_t i, Int_t j) const
+{
+ /// Return the value as an int (which it is), w/o checking indices.
+
+ return fValues[IndexFast(i,j)];
+}
+
//_____________________________________________________________________________
Float_t
AliMUONCalibParamNI::ValueAsFloat(Int_t i, Int_t j) const
return static_cast<Float_t>(ValueAsInt(i,j));
}
+//_____________________________________________________________________________
+Float_t
+AliMUONCalibParamNI::ValueAsFloatFast(Int_t i, Int_t j) const
+{
+ /// Return the value as a float
+ return static_cast<Float_t>(ValueAsIntFast(i,j));
+}
+
//_____________________________________________________________________________
Bool_t
AliMUONCalibParamNI::UnpackValue(Int_t value, Int_t& a, Int_t& b) const