]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Coding conventions
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 17 Mar 2006 16:50:41 +0000 (16:50 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 17 Mar 2006 16:50:41 +0000 (16:50 +0000)
(Laurent)

MUON/AliMUON2DMap.cxx
MUON/AliMUON2DMap.h
MUON/AliMUONCalibParam1I.cxx
MUON/AliMUONCalibParam1I.h
MUON/AliMUONCalibParam2F.cxx
MUON/AliMUONCalibParam2F.h
MUON/AliMUONConstants.cxx
MUON/AliMUONV2DStore.cxx
MUON/AliMUONV2DStore.h

index 2988a0aa250336ea4d8cae154415fd0b1cb60dbe..97af9b357f98d3303bf08a212246280ddb640681 100644 (file)
 #include "AliLog.h"
 #include "AliMpExMap.h"
 
-#include <cassert>
+/// 
+/// Basic implementation of AliMUONV2DStore container using
+/// AliMpExMap internally.
+/// What we store is a "double" map : an AliMpExMap of AliMpExMaps
+///
 
 ClassImp(AliMUON2DMap)
 
@@ -32,13 +36,20 @@ AliMUON2DMap::AliMUON2DMap() : AliMUONV2DStore(), fMap(new AliMpExMap(true))
   //
 }
 
-//______________________________________________________________________________
-AliMUON2DMap::AliMUON2DMap(const AliMUON2DMap& right) 
-  : AliMUONV2DStore(right) 
-{  
-/// Protected copy constructor (not implemented)
+//_____________________________________________________________________________
+AliMUON2DMap::AliMUON2DMap(const AliMUON2DMap& other)
+: AliMUONV2DStore(),
+fMap(0x0)
+{
+  other.CopyTo(*this);
+}
 
-  AliFatal("Copy constructor not provided.");
+//_____________________________________________________________________________
+AliMUON2DMap&
+AliMUON2DMap::operator=(const AliMUON2DMap& other)
+{
+  other.CopyTo(*this);
+  return *this;
 }
 
 //_____________________________________________________________________________
@@ -50,19 +61,15 @@ AliMUON2DMap::~AliMUON2DMap()
   delete fMap;
 }
 
-//______________________________________________________________________________
-AliMUON2DMap& 
-AliMUON2DMap::operator=(const AliMUON2DMap& right)
+//_____________________________________________________________________________
+void
+AliMUON2DMap::CopyTo(AliMUON2DMap&) const
 {
-/// Protected assignement operator (not implemented)
-
-  // check assignement to self
-  if (this == &right) return *this;
-
-  AliFatal("Assignement operator not provided.");
-    
-  return *this;  
-}    
+  // 
+  // Copy this into dest.
+  //
+  AliFatal("Implement me if needed");
+}
 
 //_____________________________________________________________________________
 TObject* 
@@ -106,7 +113,6 @@ AliMUON2DMap::Set(Int_t i, Int_t j, TObject* object, Bool_t replace)
     AliMpExMap* m = new AliMpExMap(true);
     fMap->Add(i,m);
     o = fMap->GetValue(i);
-    assert(m==o);
   }
   AliMpExMap* m = dynamic_cast<AliMpExMap*>(o);
   if (!m) AliFatal(Form("fMap[%d] not of the expected type",i));
index eedd197c3e496cc4bf81a57851b70055ccf7d4f5..b2e6c5c123c41c654c7a59be01d9a221d0a15876 100644 (file)
@@ -20,22 +20,24 @@ class AliMpExMap;
 class AliMUON2DMap : public AliMUONV2DStore
 {
 public:
-  AliMUON2DMap();
+  AliMUON2DMap();  
   virtual ~AliMUON2DMap();
 
   virtual TObject* Get(Int_t i, Int_t j) const;
-  virtual Bool_t Set(Int_t i, Int_t j, TObject*, Bool_t replace);
+  virtual Bool_t Set(Int_t i, Int_t j, TObject* object, Bool_t replace);
   virtual Bool_t IsOwner() const { return kTRUE; }
 
   virtual void Print(Option_t* opt="") const;
 
 protected:
-  AliMUON2DMap(const AliMUON2DMap& right);
-  AliMUON2DMap&  operator = (const AliMUON2DMap& right);
-     
+  AliMUON2DMap(const AliMUON2DMap& other);
+  AliMUON2DMap&  operator = (const AliMUON2DMap& other);
+
+private:
+    void CopyTo(AliMUON2DMap& destination) const;
   
 private:
-  AliMpExMap* fMap;
+  AliMpExMap* fMap; // Our internal map (an AliMpExMap of AliMpExMaps)
   
   ClassDef(AliMUON2DMap,1) // A 2D container
 };
index b02d84087f6518160d686f0a6dde8edc4731a475..9456cf5970200e06a7146af90c9e9f97e6c9ad1c 100644 (file)
 #include "TMath.h"
 #include "TString.h"
 
+/// This class is implementing the AliMUONVCalibParam interface.
+/// 
+/// It stores a given number of integers.
+/// 
+/// Those integers can also be retrieved as floats if really needed 
+/// (this is to comply with the base class).
+/// 
+/// You might consider just as it is, namely a C++ wrapper to 
+/// a plain int[] array.
+
 ClassImp(AliMUONCalibParam1I)
 
 //_____________________________________________________________________________
@@ -52,13 +62,28 @@ AliMUONCalibParam1I::AliMUONCalibParam1I(Int_t theSize, Int_t fillWithValue)
   }
 }
 
-//______________________________________________________________________________
-AliMUONCalibParam1I::AliMUONCalibParam1I(const AliMUONCalibParam1I& right) 
-  : AliMUONVCalibParam(right) 
-{  
-/// Protected copy constructor (not implemented)
+//_____________________________________________________________________________
+AliMUONCalibParam1I::AliMUONCalibParam1I(const AliMUONCalibParam1I& other) 
+: AliMUONVCalibParam(other),
+fSize(0),
+fValues(0x0)
+{
+  //
+  // Copy ctor
+  //
+  other.CopyTo(*this);
+}
 
-  AliFatal("Copy constructor not provided.");
+//_____________________________________________________________________________
+AliMUONCalibParam1I&
+AliMUONCalibParam1I::operator=(const AliMUONCalibParam1I& other) 
+{
+  //
+  // Assignment operator
+  //
+  AliMUONVCalibParam::operator=(other);
+  other.CopyTo(*this);
+  return *this;
 }
 
 //_____________________________________________________________________________
@@ -70,19 +95,24 @@ AliMUONCalibParam1I::~AliMUONCalibParam1I()
   delete[] fValues;
 }
 
-//______________________________________________________________________________
-AliMUONCalibParam1I& 
-AliMUONCalibParam1I::operator=(const AliMUONCalibParam1I& right)
+//_____________________________________________________________________________
+void
+AliMUONCalibParam1I::CopyTo(AliMUONCalibParam1I& destination) const
 {
-/// Protected assignement operator (not implemented)
-
-  // check assignement to self
-  if (this == &right) return *this;
-
-  AliFatal("Assignement operator not provided.");
-    
-  return *this;  
-}    
+  //
+  // Copy this into destination.
+  //
+  delete[] destination.fValues;
+  destination.fSize = fSize;
+  if ( fSize > 0 )
+  {
+    destination.fValues = new Int_t[fSize];
+    for ( Int_t i = 0; i < fSize; ++i )
+    {
+      destination.fValues[i] = fValues[i];
+    }
+  }
+}
 
 //_____________________________________________________________________________
 void
index 3affb00744da6fe73339680cd267ccff443ae5d2..d9a2194f67e837975b78fa34fbe452dcbc910ada 100644 (file)
@@ -23,26 +23,39 @@ class AliMUONCalibParam1I : public AliMUONVCalibParam
 public:
   AliMUONCalibParam1I();
   AliMUONCalibParam1I(Int_t theSize, Int_t fillWithValue=0);
+  AliMUONCalibParam1I(const AliMUONCalibParam1I& other);
+  AliMUONCalibParam1I& operator=(const AliMUONCalibParam1I& other);
   virtual ~AliMUONCalibParam1I();
 
+  /// The dimension of this object is 1, i.e. it's a vector.
   virtual Int_t Dimension() const { return 1; }
   
   virtual void Print(Option_t* opt="") const;
   
+  /** Set the value located at i (j must be zero).
+    * Note that the internal structure store ints, so the float is rounded
+    * prior to be stored
+    */
   virtual void SetValueAsFloat(Int_t i, Int_t j, Float_t value);
+  
+  /// Set the value located at i (j must be zero), as an int.
   virtual void SetValueAsInt(Int_t i, Int_t j, Int_t value);
   
+  /// The number of values we hold.
   virtual Int_t Size() const { return fSize; }
 
+  /// Retrieve the value located at i (j must remain zero), as a float.
   virtual Float_t ValueAsFloat(Int_t i, Int_t j=0) const;
+  
+  /// Retrieve the value located at i (j must remain zero).
   virtual Int_t ValueAsInt(Int_t i, Int_t j=0) const;
 
- protected:
-  AliMUONCalibParam1I(const AliMUONCalibParam1I& right);
-  AliMUONCalibParam1I&  operator = (const AliMUONCalibParam1I& right);
- private:
-  Int_t fSize;
+private:
+  /// Copy *this to destination (used by copy ctor and operator=).
+  void CopyTo(AliMUONCalibParam1I& destination) const;
+  
+private:
+  Int_t fSize; // The number of values we hold
   Int_t* fValues; //[fSize]
   
   ClassDef(AliMUONCalibParam1I,1) // Container for calibration parameters
index dbb2c52026afa2bc55541c9fa711774bbdc042d7..4f4f8f7ba20b427598c2370becef63247ac18b87 100644 (file)
 #include "TMath.h"
 #include "TString.h"
 
+///
+/// Implementation of AliMUONVCalibParam for pair of floats.
+///
+/// Conceptually, this class is the equivalent of a vector or float pairs,
+/// but it is implemented using bare Float_t[] array.
+///
+
 ClassImp(AliMUONCalibParam2F)
 
 //_____________________________________________________________________________
@@ -54,13 +61,23 @@ 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)
+{
+  other.CopyTo(*this);
+}
+
+//_____________________________________________________________________________
+AliMUONCalibParam2F&
+AliMUONCalibParam2F::operator=(const AliMUONCalibParam2F& other) 
+{
+  other.CopyTo(*this);
+  return *this;
 }
 
 //_____________________________________________________________________________
@@ -72,19 +89,26 @@ AliMUONCalibParam2F::~AliMUONCalibParam2F()
   delete[] fValues;
 }
 
-//______________________________________________________________________________
-AliMUONCalibParam2F& 
-AliMUONCalibParam2F::operator=(const AliMUONCalibParam2F& right)
+//_____________________________________________________________________________
+void
+AliMUONCalibParam2F::CopyTo(AliMUONCalibParam2F& destination) const
 {
-/// Protected assignement operator (not implemented)
-
-  // check assignement to self
-  if (this == &right) return *this;
+  //
+  // Copy *this to destination
+  //
+  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
index b8b5c980add36fc640e6f3c0bfa7522129537bb4..eab4e09af5417137dc1faa864fe3b09967093b25 100644 (file)
@@ -24,6 +24,9 @@ class AliMUONCalibParam2F : public AliMUONVCalibParam
 public:
   AliMUONCalibParam2F();
   AliMUONCalibParam2F(Int_t theSize, Int_t fillWithValue=0);
+  AliMUONCalibParam2F(const AliMUONCalibParam2F& other);
+  AliMUONCalibParam2F& operator=(const AliMUONCalibParam2F& other);
+  
   virtual ~AliMUONCalibParam2F();
 
   virtual Int_t Dimension() const { return 2; }
@@ -37,17 +40,14 @@ public:
 
   virtual Float_t ValueAsFloat(Int_t i, Int_t j=0) const;
   virtual Int_t ValueAsInt(Int_t i, Int_t j=0) const;
-
-protected:
-  AliMUONCalibParam2F(const AliMUONCalibParam2F& right);
-  AliMUONCalibParam2F&  operator = (const AliMUONCalibParam2F& right);
      
 private:
+  void CopyTo(AliMUONCalibParam2F& destination) const;
   Int_t Index(Int_t i, Int_t j) const;  
     
 private:
-  Int_t fSize;
-  Int_t fN;
+  Int_t fSize; // The number of float pair we hold
+  Int_t fN; // The total number of floats we hold (2*fSize)
   Float_t* fValues; //[fN]
   
   ClassDef(AliMUONCalibParam2F,1) // Container for calibration parameters
index d08f7a412b459949ddb39c7e615496b69f2b11a1..19bcd5d19058e87bb9dd87d737a73e876ed69b03 100644 (file)
 
 #include "AliMUONConstants.h"
 
-#include <TMath.h>
+#include "TMath.h"
+
+///
+/// This class holds various constants to be used in many places,
+/// such as the number of tracking and trigger chambers, 
+/// some geometrical constants (to build the initial geometry for simulation)
+/// and mathieson distribution default values.
+/// Those constants should as much as possible replace hard-coded values
+/// which are to be considered strictly illegal in the MUON code (or any code,
+/// by the way).
+///
 
 Int_t   AliMUONConstants::fgNCh = 14;
 Int_t   AliMUONConstants::fgNTrackingCh = 10;
index e2c04ab1edcb3af94aaf21f8075fe866e86686b5..7ca595d42063960c0cba044c78babd01aa6fb40c 100644 (file)
 
 #include "AliMUONV2DStore.h"
 
+///
+/// Defines an interface equivalent to a 2D array of TObject, indexed
+/// by a pair of integers (somehow a matrix, 
+/// except that indices are not necessarily sequential).
+/// 
+/// It's extremely simple and hopefully allow many implementations.
+/// It also makes the object ownership self-evident.
+///
+
 ClassImp(AliMUONV2DStore)
 
+//_____________________________________________________________________________
+AliMUONV2DStore::AliMUONV2DStore()
+{
+}
+
 //_____________________________________________________________________________
 AliMUONV2DStore::~AliMUONV2DStore()
 {
index 00647491366b02f332333b875748f4c48032d9b2..18d83f1f0bd20af2191823be4da38457510a82ab 100644 (file)
@@ -19,6 +19,7 @@
 class AliMUONV2DStore : public TObject
 {
 public:
+  AliMUONV2DStore();
   virtual ~AliMUONV2DStore();
   
   /// Return the object stored at (i,j).