X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FAliMUONCalibParamNI.cxx;h=644975dea4b4f5d14dd488cca31b382134598827;hb=8acd5e6001d451de4da3c0a67c3ab89e3cee2207;hp=562a1642717b2f4689f5e5c7166593e736c3d141;hpb=96fea1fd67cd0ddda50c144996b088f1aba9da99;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUONCalibParamNI.cxx b/MUON/AliMUONCalibParamNI.cxx index 562a1642717..644975dea4b 100644 --- a/MUON/AliMUONCalibParamNI.cxx +++ b/MUON/AliMUONCalibParamNI.cxx @@ -23,7 +23,7 @@ #include "TMath.h" #include "TString.h" -/// +//----------------------------------------------------------------------------- /// \class AliMUONCalibParamNI /// /// Handle the case of N integer parameters per channel. @@ -35,6 +35,7 @@ /// and use the correct type. /// /// \author Laurent Aphecetche +//----------------------------------------------------------------------------- /// \cond CLASSIMP ClassImp(AliMUONCalibParamNI) @@ -50,12 +51,14 @@ AliMUONCalibParamNI::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), @@ -66,6 +69,9 @@ AliMUONCalibParamNI::AliMUONCalibParamNI(Int_t dimension, Int_t theSize, /// 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]; @@ -88,6 +94,7 @@ fValues(0x0) { /// Copy constructor. + AliDebug(1,Form("this=%p copy ctor",this)); other.CopyTo(*this); } @@ -106,6 +113,7 @@ AliMUONCalibParamNI::~AliMUONCalibParamNI() { /// Destructor + AliDebug(1,Form("this=%p",this)); delete[] fValues; } @@ -115,6 +123,9 @@ AliMUONCalibParamNI::CopyTo(AliMUONCalibParamNI& destination) const { /// Copy *this to destination + const TObject& o = static_cast(*this); + o.Copy(destination); + delete[] destination.fValues; destination.fN = fN; destination.fSize = fSize; @@ -140,11 +151,20 @@ AliMUONCalibParamNI::Index(Int_t i, Int_t j) const 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 @@ -157,7 +177,9 @@ 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; @@ -176,11 +198,11 @@ AliMUONCalibParamNI::Print(Option_t* opt) const { 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; @@ -229,6 +251,15 @@ AliMUONCalibParamNI::SetValueAsInt(Int_t i, Int_t j, Int_t value) } } +//_____________________________________________________________________________ +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) @@ -239,6 +270,17 @@ 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 @@ -259,6 +301,15 @@ 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 @@ -267,6 +318,14 @@ AliMUONCalibParamNI::ValueAsFloat(Int_t i, Int_t j) const return static_cast(ValueAsInt(i,j)); } +//_____________________________________________________________________________ +Float_t +AliMUONCalibParamNI::ValueAsFloatFast(Int_t i, Int_t j) const +{ + /// Return the value as a float + return static_cast(ValueAsIntFast(i,j)); +} + //_____________________________________________________________________________ Bool_t AliMUONCalibParamNI::UnpackValue(Int_t value, Int_t& a, Int_t& b) const