1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //____________________________________________________________________
20 // Base class for caches of per-strip information.
21 // This is used to index a strip.
22 // Data stored depends on derived class.
23 // This class provides some common infra-structure.
24 // Derived classes sould define Reset, and operator().
26 #include "AliFMDMap.h" // ALIFMDMAP_H
29 //____________________________________________________________________
32 ; // This is here to keep Emacs for indenting the next line
35 //____________________________________________________________________
36 AliFMDMap::AliFMDMap(UShort_t maxDet,
40 : fMaxDetectors(maxDet),
48 // maxDet Maximum # of detectors
49 // maxRinf Maximum # of rings
50 // maxSec Maximum # of sectors
51 // maxStr Maximum # of strips
54 //____________________________________________________________________
56 AliFMDMap::CheckIndex(UShort_t det, Char_t ring, UShort_t sec, UShort_t str) const
58 // Check that the index supplied is OK. Returns true index, or -1
60 if (det < 1) return -1;
61 UShort_t ringi = (ring == 'I' || ring == 'i' ? 0 : 1);
63 (str + fMaxStrips * (sec + fMaxSectors * (ringi + fMaxRings * (det-1))));
64 if (idx >= fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips) return -1;
69 //____________________________________________________________________
71 AliFMDMap::CalcIndex(UShort_t det, Char_t ring, UShort_t sec, UShort_t str) const
73 // Calculate index into storage from arguments.
81 // Returns appropriate index into storage
83 Int_t idx = CheckIndex(det, ring, sec, str);
85 UShort_t ringi = (ring == 'I' || ring == 'i' ? 0 : 1);
86 AliFatal(Form("Index (%d,'%c',%d,%d) out of bounds, "
87 "in particular the %s index ",
89 (det > fMaxDetectors ? "Detector" :
90 (ringi >= fMaxRings ? "Ring" :
91 (sec >= fMaxSectors ? "Sector" : "Strip")))));
98 //___________________________________________________________________