]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDStripIndex.h
including extra debugging message
[u/mrichter/AliRoot.git] / FMD / AliFMDStripIndex.h
index cf9a3794f3f110290968c563e00c9cd99c96e697..41891cfcd6904c26e9b61d826370d6482c3caa2f 100644 (file)
@@ -1,3 +1,5 @@
+#ifndef ALIFMDSTRIPINDEX_H
+#define ALIFMDSTRIPINDEX_H
 /**************************************************************************
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  *                                                                        *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-//Struct to encode a strip address into one integer
-//developed by Christian Holm Christensen (cholm@nbi.dk).
-// The functions are static
-// to ensure applicability from anywhere. This is needed to smoothly store
-//strip addresses in track references.
+// Struct to encode a strip address into one integer
+// developed by Christian Holm Christensen (cholm@nbi.dk).
+// 
+// The functions are static to ensure applicability from
+// anywhere. This is needed to smoothly store strip addresses in track
+// references. 
+//
 // Added by Hans H. Dalsgaard (hans.dalsgaard@cern.ch) 
 
 
-struct AliFMDStripIndex
+class AliFMDStripIndex
 {
+public:
+  enum { 
+    // Mask of ID
+    kIdMask = 0x0007FFFF,
+    // Mask of energy 
+    kEMask  = 0xFFF80000,
+    // Offset of energy 
+    kEOffset = 19
+  };
+  /** 
+   * Constructor
+   * 
+   */  
+  AliFMDStripIndex() {}
+  /** 
+   * Destructor 
+   * 
+   */
+  virtual ~AliFMDStripIndex() {}
+  /** 
+   * Pack an identifier from detector coordinates
+   * 
+   * @param det  Detector
+   * @param rng  Ring
+   * @param sec  Sector
+   * @param str  Strip
+   * 
+   * @return Packed identifier 
+   */
   static UInt_t Pack(UShort_t det, Char_t rng, UShort_t sec, UShort_t str) 
   {
     UInt_t irg  = (rng == 'I' || rng == 'i' ? 0 : 1);
@@ -30,16 +63,31 @@ struct AliFMDStripIndex
                   ((sec & 0x03F) <<  9) | 
                   ((irg & 0x001) << 16) | 
                   ((det & 0x003) << 17));
-    return id;
+    return (id & kIdMask);
   }
+  /** 
+   * Unpack an identifier to detector coordinates
+   * 
+   * @param id   Identifier to unpack
+   * @param det  On return, the detector
+   * @param rng  On return, the ring
+   * @param sec  On return, the sector
+   * @param str  On return, the strip
+   */  
   static void Unpack(UInt_t id, 
-             UShort_t& det, Char_t& rng, UShort_t& sec, UShort_t& str)
+                    UShort_t& det, Char_t& rng, UShort_t& sec, UShort_t& str)
   {
-    str = ((id >>  0) & 0x1FF);
-    sec = ((id >>  9) & 0x03F);
-    rng = ((id >> 16) & 0x001) ? 'O' : 'I';
-    det = ((id >> 17) & 0x003);
+    UInt_t tmp = (kIdMask & id);
+    str = ((tmp >>  0) & 0x1FF);
+    sec = ((tmp >>  9) & 0x03F);
+    rng = ((tmp >> 16) & 0x001) ? 'O' : 'I';
+    det = ((tmp >> 17) & 0x003);
   }
-
-  ClassDef(AliFMDStripIndex,0)
+  ClassDef(AliFMDStripIndex,1)
 };
+#endif
+//
+// Local Variables:
+//   mode: C++
+// End:
+//