ROOT logo
/**************************************************************************
 * Copyright(c) 2004, ALICE Experiment at CERN, All rights reserved. *
 *                                                                        *
 * Author: The ALICE Off-line Project.                                    *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its   *
 * documentation strictly for non-commercial purposes is hereby granted   *
 * without fee, provided that the above copyright notice appears in all   *
 * copies and that both the copyright notice and this permission notice   *
 * appear in the supporting documentation. The authors make no claims     *
 * about the suitability of this software for any purpose. It is          *
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/
/* $Id$ */
/** @file    AliFMDDigit.cxx
    @author  Christian Holm Christensen <cholm@nbi.dk>
    @date    Mon Mar 27 12:37:41 2006
    @brief   Digits for the FMD 
*/
//////////////////////////////////////////////////////////////////////
//
//  Class that holds an FMD index.  That is, it holds the detector
//  coordinates for a given strip:
//
//     Variable | Type     | Range   | Description
//     ---------+----------+---------+------------------
//     detector | UShort_t | 1-3     | Detector number 
//     ring     | Char_t   | 'I'/'O' | Ring identifier 
//     sector   | UShort_t | 0-39    | Sector number
//     strip    | UShort_t | 0-511   | Strip number
//
//////////////////////////////////////////////////////////////////////

#include "AliFMDIndex.h"	// ALIFMDINDEX_H
#include "Riostream.h"		// ROOT_Riostream
#include <TString.h>            // ROOT_TString
#include <AliFMDMap.h>

//====================================================================
using std::cout;
using std::flush;
ClassImp(AliFMDIndex)
#if 0
  ; // This is here to keep Emacs from indenting the next line
#endif

//____________________________________________________________________
AliFMDIndex::AliFMDIndex()
  : fDetector(0), 
    fRing('\0'), 
    fSector(0), 
    fStrip(0), 
    fName(""),
    fHash(-1) 
{
  // CTOR
}

//____________________________________________________________________
AliFMDIndex::AliFMDIndex(const AliFMDIndex& o)
  : fDetector(o.fDetector), 
    fRing(o.fRing), 
    fSector(o.fSector), 
    fStrip(o.fStrip), 
    fName(""),
    fHash(o.fHash)
{
  // Copy constructor 
}

//____________________________________________________________________
AliFMDIndex::AliFMDIndex(UShort_t detector, 
			 Char_t   ring, 
			 UShort_t sector, 
			 UShort_t strip)
  : fDetector(detector), 
    fRing(ring), 
    fSector(sector), 
    fStrip(strip), 
    fName(""),
    fHash(-1)
{
  //
  // Creates a base data digit object
  //
  // Parameters 
  //
  //    detector  Detector # (1, 2, or 3)                      
  //    ring	  Ring ID ('I' or 'O')
  //    sector	  Sector # (For inner/outer rings: 0-19/0-39)
  //    strip	  Strip # (For inner/outer rings: 0-511/0-255)
}

//____________________________________________________________________
AliFMDIndex& 
AliFMDIndex::operator=(const AliFMDIndex& o)
{
  // Assignment operator 
  if (&o == this) return *this; 
  fDetector = o.fDetector;
  fRing     = o.fRing;
  fSector   = o.fSector;
  fStrip    = o.fStrip;
  fHash     = o.fHash;
  return *this;
}

//____________________________________________________________________
Int_t
AliFMDIndex::Hash() const 
{
  // calculate hash value 
  if (fHash < 0) {
    size_t ringi = (fRing == 'I' ||  fRing == 'i' ? 0 : 1);
    fHash = (fStrip + 
	     AliFMDMap::kMaxStrips * 
	     (fSector + AliFMDMap::kMaxSectors * 
	      (ringi + AliFMDMap::kMaxRings * (fDetector-1))));
  }
  return fHash;
}


//____________________________________________________________________
void
AliFMDIndex::Print(Option_t* /* option*/) const 
{
  // Print digit to standard out 
  cout << Name() << flush;
}

//____________________________________________________________________
const char*
AliFMDIndex::Name() const 
{ 
  // GEt the name of the index 
  if (fName.IsNull()) 
    fName = Form("FMD%d%c[%2d,%3d]", fDetector, fRing, fSector, fStrip);
  return fName.Data();
}

//====================================================================
ClassImp(AliFMDObjIndex)
#if 0
  ; // This is here to keep Emacs from indenting the next line
#endif

//____________________________________________________________________
Int_t 
AliFMDObjIndex::Compare(const TObject* o) const
{
  // Compare to another index 
  const AliFMDObjIndex* a = dynamic_cast<const AliFMDObjIndex*>(o);
  if (!a) {
    Fatal("Compare", 
	  "trying to compare to something not a AliFMDObjIndex object, "
	  "but a %s object", o->ClassName());
    return 0;
  }
  if (this->operator<(*a)) return -1;
  if (this->operator==(*a)) return 0;
  return 1;
}

//____________________________________________________________________
//
// EOF
//
 AliFMDIndex.cxx:1
 AliFMDIndex.cxx:2
 AliFMDIndex.cxx:3
 AliFMDIndex.cxx:4
 AliFMDIndex.cxx:5
 AliFMDIndex.cxx:6
 AliFMDIndex.cxx:7
 AliFMDIndex.cxx:8
 AliFMDIndex.cxx:9
 AliFMDIndex.cxx:10
 AliFMDIndex.cxx:11
 AliFMDIndex.cxx:12
 AliFMDIndex.cxx:13
 AliFMDIndex.cxx:14
 AliFMDIndex.cxx:15
 AliFMDIndex.cxx:16
 AliFMDIndex.cxx:17
 AliFMDIndex.cxx:18
 AliFMDIndex.cxx:19
 AliFMDIndex.cxx:20
 AliFMDIndex.cxx:21
 AliFMDIndex.cxx:22
 AliFMDIndex.cxx:23
 AliFMDIndex.cxx:24
 AliFMDIndex.cxx:25
 AliFMDIndex.cxx:26
 AliFMDIndex.cxx:27
 AliFMDIndex.cxx:28
 AliFMDIndex.cxx:29
 AliFMDIndex.cxx:30
 AliFMDIndex.cxx:31
 AliFMDIndex.cxx:32
 AliFMDIndex.cxx:33
 AliFMDIndex.cxx:34
 AliFMDIndex.cxx:35
 AliFMDIndex.cxx:36
 AliFMDIndex.cxx:37
 AliFMDIndex.cxx:38
 AliFMDIndex.cxx:39
 AliFMDIndex.cxx:40
 AliFMDIndex.cxx:41
 AliFMDIndex.cxx:42
 AliFMDIndex.cxx:43
 AliFMDIndex.cxx:44
 AliFMDIndex.cxx:45
 AliFMDIndex.cxx:46
 AliFMDIndex.cxx:47
 AliFMDIndex.cxx:48
 AliFMDIndex.cxx:49
 AliFMDIndex.cxx:50
 AliFMDIndex.cxx:51
 AliFMDIndex.cxx:52
 AliFMDIndex.cxx:53
 AliFMDIndex.cxx:54
 AliFMDIndex.cxx:55
 AliFMDIndex.cxx:56
 AliFMDIndex.cxx:57
 AliFMDIndex.cxx:58
 AliFMDIndex.cxx:59
 AliFMDIndex.cxx:60
 AliFMDIndex.cxx:61
 AliFMDIndex.cxx:62
 AliFMDIndex.cxx:63
 AliFMDIndex.cxx:64
 AliFMDIndex.cxx:65
 AliFMDIndex.cxx:66
 AliFMDIndex.cxx:67
 AliFMDIndex.cxx:68
 AliFMDIndex.cxx:69
 AliFMDIndex.cxx:70
 AliFMDIndex.cxx:71
 AliFMDIndex.cxx:72
 AliFMDIndex.cxx:73
 AliFMDIndex.cxx:74
 AliFMDIndex.cxx:75
 AliFMDIndex.cxx:76
 AliFMDIndex.cxx:77
 AliFMDIndex.cxx:78
 AliFMDIndex.cxx:79
 AliFMDIndex.cxx:80
 AliFMDIndex.cxx:81
 AliFMDIndex.cxx:82
 AliFMDIndex.cxx:83
 AliFMDIndex.cxx:84
 AliFMDIndex.cxx:85
 AliFMDIndex.cxx:86
 AliFMDIndex.cxx:87
 AliFMDIndex.cxx:88
 AliFMDIndex.cxx:89
 AliFMDIndex.cxx:90
 AliFMDIndex.cxx:91
 AliFMDIndex.cxx:92
 AliFMDIndex.cxx:93
 AliFMDIndex.cxx:94
 AliFMDIndex.cxx:95
 AliFMDIndex.cxx:96
 AliFMDIndex.cxx:97
 AliFMDIndex.cxx:98
 AliFMDIndex.cxx:99
 AliFMDIndex.cxx:100
 AliFMDIndex.cxx:101
 AliFMDIndex.cxx:102
 AliFMDIndex.cxx:103
 AliFMDIndex.cxx:104
 AliFMDIndex.cxx:105
 AliFMDIndex.cxx:106
 AliFMDIndex.cxx:107
 AliFMDIndex.cxx:108
 AliFMDIndex.cxx:109
 AliFMDIndex.cxx:110
 AliFMDIndex.cxx:111
 AliFMDIndex.cxx:112
 AliFMDIndex.cxx:113
 AliFMDIndex.cxx:114
 AliFMDIndex.cxx:115
 AliFMDIndex.cxx:116
 AliFMDIndex.cxx:117
 AliFMDIndex.cxx:118
 AliFMDIndex.cxx:119
 AliFMDIndex.cxx:120
 AliFMDIndex.cxx:121
 AliFMDIndex.cxx:122
 AliFMDIndex.cxx:123
 AliFMDIndex.cxx:124
 AliFMDIndex.cxx:125
 AliFMDIndex.cxx:126
 AliFMDIndex.cxx:127
 AliFMDIndex.cxx:128
 AliFMDIndex.cxx:129
 AliFMDIndex.cxx:130
 AliFMDIndex.cxx:131
 AliFMDIndex.cxx:132
 AliFMDIndex.cxx:133
 AliFMDIndex.cxx:134
 AliFMDIndex.cxx:135
 AliFMDIndex.cxx:136
 AliFMDIndex.cxx:137
 AliFMDIndex.cxx:138
 AliFMDIndex.cxx:139
 AliFMDIndex.cxx:140
 AliFMDIndex.cxx:141
 AliFMDIndex.cxx:142
 AliFMDIndex.cxx:143
 AliFMDIndex.cxx:144
 AliFMDIndex.cxx:145
 AliFMDIndex.cxx:146
 AliFMDIndex.cxx:147
 AliFMDIndex.cxx:148
 AliFMDIndex.cxx:149
 AliFMDIndex.cxx:150
 AliFMDIndex.cxx:151
 AliFMDIndex.cxx:152
 AliFMDIndex.cxx:153
 AliFMDIndex.cxx:154
 AliFMDIndex.cxx:155
 AliFMDIndex.cxx:156
 AliFMDIndex.cxx:157
 AliFMDIndex.cxx:158
 AliFMDIndex.cxx:159
 AliFMDIndex.cxx:160
 AliFMDIndex.cxx:161
 AliFMDIndex.cxx:162
 AliFMDIndex.cxx:163
 AliFMDIndex.cxx:164
 AliFMDIndex.cxx:165
 AliFMDIndex.cxx:166
 AliFMDIndex.cxx:167
 AliFMDIndex.cxx:168
 AliFMDIndex.cxx:169