]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDMap.h
Added AliMpStringObjMap, AliMpDEIterator, AliMpDEManager, AliMpSegFactory
[u/mrichter/AliRoot.git] / FMD / AliFMDMap.h
index a96329277f1aa9c44f695992b6f7cc401473c390..2dba2c5529fd1ce8c20ab7d9cf2a471d4c23cfd3 100644 (file)
@@ -5,13 +5,67 @@
  *
  * See cxx source for full Copyright notice                               
  */
+#ifndef ROOT_TObject
+# include <TObject.h>
+#endif 
+//____________________________________________________________________
+//
+// Base class for caches of per-strip information.
+// This is used to index a strip. 
+// Data stored depends on derived class. 
+//
+class AliFMDMap : public TObject 
+{
+public:
+  enum { 
+    kMaxDetectors = 3, 
+    kMaxRings     = 2, 
+    kMaxSectors   = 40, 
+    kMaxStrips    = 512
+  };
+  AliFMDMap(size_t maxDet = kMaxDetectors, 
+           size_t maxRing= kMaxRings, 
+           size_t maxSec = kMaxSectors, 
+           size_t maxStr = kMaxStrips);
+  virtual ~AliFMDMap() {}
+  Int_t CheckIndex(size_t det, Char_t ring, size_t sec, size_t str) const;
+protected:
+  size_t CalcIndex(size_t det, Char_t ring, size_t sec, size_t str) const;
+  size_t fMaxDetectors;             // Maximum # of detectors
+  size_t fMaxRings;                 // Maximum # of rings
+  size_t fMaxSectors;               // Maximum # of sectors
+  size_t fMaxStrips;                // Maximum # of strips
+  ClassDef(AliFMDMap, 1) // Cache of per strip information
+};
+
+#ifdef  MAY_USE_TEMPLATES
 #ifndef __VECTOR__
 # include <vector>
 #endif 
-
+//____________________________________________________________________
+//
+// Class template for classes that cache per strip information.  
+// Access to the data goes via 
+//
+//   Type& AliFMDMap<Type>::operator()(size_t detector,
+//                                     Char_t ring, 
+//                                     size_t sector,
+//                                     size_t strip);
+// 
+// (as well as a const version of this member function). 
+// The elements can be reset to the default value by calling 
+// AliFMDMap<Type>::Clear().  This resets the values to `Type()'. 
+//
 template <typename Type> 
 class AliFMDMap : public TObject 
 {
+public:
+  AliFMDMap(size_t maxDet=3, size_t maxRing=2, size_t maxSec=40, 
+           size_t maxStr=512);
+  virtual ~AliFMDMap() {}
+  void Clear(const Type& val=Type());
+  Type& operator()(size_t det, Char_t ring, size_t sec, size_t str);
+  const Type& operator()(size_t det, Char_t ring, size_t sec, size_t str)const;
 private:
   typedef std::vector<Type> ValueVector; // Type of container
   ValueVector fValues;                   // Contained values
@@ -21,13 +75,6 @@ private:
   size_t      fMaxStrips;                // Maximum # of strips
   
   size_t CalcIndex(size_t det, Char_t ring, size_t sec, size_t str) const;
-public:
-  AliFMDMap(size_t maxDet=3, size_t maxRing=2, size_t maxSec=40, 
-           size_t maxStr=512);
-  virtual ~AliFMDMap() {}
-  void Clear();
-  Type& operator()(size_t det, Char_t ring, size_t sec, size_t str);
-  const Type& operator()(size_t det, Char_t ring, size_t sec, size_t str)const;
   ClassDef(AliFMDMap, 0); // Map of FMD index's to values 
 };
 
@@ -88,10 +135,10 @@ AliFMDMap<Type>::CalcIndex(size_t det, Char_t ring, size_t sec, size_t str) cons
 //____________________________________________________________________
 template <typename Type>
 inline void
-AliFMDMap<Type>::Clear() 
+AliFMDMap<Type>::Clear(const Type& val
 {
   // Resets stored values to the default value for that type 
-  for (size_t i = 0; i < fValues.size(); ++i) fValues[i] = Type();
+  for (size_t i = 0; i < fValues.size(); ++i) fValues[i] = val;
 }
 
 //____________________________________________________________________
@@ -112,7 +159,10 @@ AliFMDMap<Type>::operator()(size_t det, Char_t ring, size_t sec, size_t str)
 //____________________________________________________________________
 template <typename Type>
 inline const Type& 
-AliFMDMap<Type>::operator()(size_t det, Char_t ring, size_t sec, size_t str)const
+AliFMDMap<Type>::operator()(size_t det, 
+                           Char_t ring, 
+                           size_t sec, 
+                           size_t str) const
 {
   // Parameters: 
   //     det       Detector #
@@ -125,7 +175,14 @@ AliFMDMap<Type>::operator()(size_t det, Char_t ring, size_t sec, size_t str)cons
 }
 
 
+//____________________________________________________________________
+// 
+// Some specialisations 
+//
+typedef AliFMDMap<UShort_t> AliFMDAdcMap;
+typedef AliFMDMap<std::pair<Float_t, UShort_t> > AliFMDEdepMap;
 
+#endif
 #endif 
 //____________________________________________________________________
 //