]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONCalibParam2F.cxx
Make calibration default wise, remove the switch (Laurent & Christian)
[u/mrichter/AliRoot.git] / MUON / AliMUONCalibParam2F.cxx
index dbb2c52026afa2bc55541c9fa711774bbdc042d7..36d765266c0e1cee8f55abf021c1c39433817a10 100644 (file)
 #include "TMath.h"
 #include "TString.h"
 
+///
+/// \class AliMUONCalibParam2F
+/// \brief Implementation of AliMUONVCalibParam for pair of floats.
+///
+/// Handle the case of 2 floating point parameters per channel.
+/// Conceptually, this class is the equivalent of a vector or float pairs,
+/// but it is implemented using bare Float_t[] array.
+///
+/// \author Laurent Aphecetche
+
+/// \cond CLASSIMP
 ClassImp(AliMUONCalibParam2F)
+/// \endcond
 
 //_____________________________________________________________________________
 AliMUONCalibParam2F::AliMUONCalibParam2F() 
@@ -31,22 +43,20 @@ AliMUONCalibParam2F::AliMUONCalibParam2F()
   fN(0),
   fValues(0x0)
 {
-  //
-  // Default ctor.
-  // 
+/// Default constructor.
 }
 
 //_____________________________________________________________________________
 AliMUONCalibParam2F::AliMUONCalibParam2F(Int_t theSize, Int_t fillWithValue) 
 : AliMUONVCalibParam(),
   fSize(theSize),
-  fN(fSize*Dimension())
+  fN(fSize*Dimension()),
+  fValues(0x0)
 {
-  //
-  // Normal ctor, where theSize specifies the number of channels handled
-  // by this object, and fillWithValue the default value assigned to each
-  // channel.
-  //
+/// Normal constructor, where theSize specifies the number of channels handled
+/// by this object, and fillWithValue the default value assigned to each
+/// channel.
+
   if ( fN > 0 )
   {
     fValues = new Float_t[fN];
@@ -54,46 +64,64 @@ AliMUONCalibParam2F::AliMUONCalibParam2F(Int_t theSize, Int_t fillWithValue)
   }
 }
 
-//______________________________________________________________________________
-AliMUONCalibParam2F::AliMUONCalibParam2F(const AliMUONCalibParam2F& right) 
-  : AliMUONVCalibParam(right) 
-{  
-/// Protected copy constructor (not implemented)
 
-  AliFatal("Copy constructor not provided.");
+//_____________________________________________________________________________
+AliMUONCalibParam2F::AliMUONCalibParam2F(const AliMUONCalibParam2F& other) 
+: AliMUONVCalibParam(),
+fSize(0),
+fN(0),
+fValues(0x0)
+{
+/// Copy constructor.
+
+  other.CopyTo(*this);
+}
+
+//_____________________________________________________________________________
+AliMUONCalibParam2F&
+AliMUONCalibParam2F::operator=(const AliMUONCalibParam2F& other) 
+{
+/// Assignment operator
+
+  other.CopyTo(*this);
+  return *this;
 }
 
 //_____________________________________________________________________________
 AliMUONCalibParam2F::~AliMUONCalibParam2F()
 {
-  //
-  // dtor
-  //
+/// Destructor
+
   delete[] fValues;
 }
 
-//______________________________________________________________________________
-AliMUONCalibParam2F& 
-AliMUONCalibParam2F::operator=(const AliMUONCalibParam2F& right)
+//_____________________________________________________________________________
+void
+AliMUONCalibParam2F::CopyTo(AliMUONCalibParam2F& destination) const
 {
-/// Protected assignement operator (not implemented)
+/// Copy *this to destination
 
-  // check assignement to self
-  if (this == &right) return *this;
+  delete[] destination.fValues;
+  destination.fN = fN;
+  destination.fSize = fSize;
 
-  AliFatal("Assignement operator not provided.");
-    
-  return *this;  
-}    
+  if ( fN > 0 )
+  {
+    destination.fValues = new Float_t[fN];
+    for ( Int_t i = 0; i < fN; ++i )
+    {
+      destination.fValues[i] = fValues[i];
+    }
+  }
+}
 
 //_____________________________________________________________________________
 Int_t
 AliMUONCalibParam2F::Index(Int_t i, Int_t j) const
 {
-  //
-  // Compute the 1D index of the internal storage from the pair (i,j)
-  // Returns -1 if the (i,j) pair is invalid
-  //
+/// Compute the 1D index of the internal storage from the pair (i,j)
+/// Returns -1 if the (i,j) pair is invalid
+
   if ( i >= 0 && i < Size() && j >= 0 && j < Dimension() )
   {
     return i + Size()*j;
@@ -105,11 +133,10 @@ AliMUONCalibParam2F::Index(Int_t i, Int_t j) const
 void
 AliMUONCalibParam2F::Print(Option_t* opt) const
 {
-  //
-  // Output this object to stdout.
-  // If opt=="full", then all channels are printed, otherwise
-  // only the general characteristics are printed.
-  //
+/// Output this object to stdout.
+/// If opt=="full", then all channels are printed, otherwise
+/// only the general characteristics are printed.
+
   TString sopt(opt);
   sopt.ToUpper();
   cout << "AliMUONCalibParam2F - Size=" << Size()
@@ -128,9 +155,8 @@ AliMUONCalibParam2F::Print(Option_t* opt) const
 void
 AliMUONCalibParam2F::SetValueAsFloat(Int_t i, Int_t j, Float_t value)
 {
-  //
-  // Set one value as a float, after checking that the indices are correct.
-  //
+/// Set one value as a float, after checking that the indices are correct.
+
   Int_t ix = Index(i,j);
   
   if ( ix < 0 )
@@ -148,9 +174,8 @@ AliMUONCalibParam2F::SetValueAsFloat(Int_t i, Int_t j, Float_t value)
 void
 AliMUONCalibParam2F::SetValueAsInt(Int_t i, Int_t j, Int_t value)
 {
-  //
-  // Set one value as an int.
-  //
+/// Set one value as an int.
+
   SetValueAsFloat(i,j,static_cast<Float_t>(value));
 }
 
@@ -158,9 +183,8 @@ AliMUONCalibParam2F::SetValueAsInt(Int_t i, Int_t j, Int_t value)
 Float_t
 AliMUONCalibParam2F::ValueAsFloat(Int_t i, Int_t j) const
 {
-  //
-  // Return the value as a float (which it is), after checking indices.
-  //
+/// Return the value as a float (which it is), after checking indices.
+
   Int_t ix = Index(i,j);
   
   if ( ix < 0 )
@@ -179,9 +203,8 @@ AliMUONCalibParam2F::ValueAsFloat(Int_t i, Int_t j) const
 Int_t
 AliMUONCalibParam2F::ValueAsInt(Int_t i, Int_t j) const
 {
-  //
-  // Return the value as an int, by rounding the internal float value.
-  //
+/// Return the value as an int, by rounding the internal float value.
+
   Float_t v = ValueAsFloat(i,j);
   return TMath::Nint(v);
 }