Fixed some coding style violations.
[u/mrichter/AliRoot.git] / FMD / AliFMDMap.cxx
... / ...
CommitLineData
1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* $Id$ */
17
18//____________________________________________________________________
19//
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().
25//
26#include "AliFMDMap.h" // ALIFMDMAP_H
27#include "AliLog.h"
28
29//____________________________________________________________________
30ClassImp(AliFMDMap)
31#if 0
32 ; // This is here to keep Emacs for indenting the next line
33#endif
34
35//____________________________________________________________________
36AliFMDMap::AliFMDMap(size_t maxDet,
37 size_t maxRing,
38 size_t maxSec,
39 size_t maxStr)
40 : fMaxDetectors(maxDet),
41 fMaxRings(maxRing),
42 fMaxSectors(maxSec),
43 fMaxStrips(maxStr)
44{
45 // Construct a map
46 //
47 // Parameters:
48 // maxDet Maximum # of detectors
49 // maxRinf Maximum # of rings
50 // maxSec Maximum # of sectors
51 // maxStr Maximum # of strips
52}
53
54//____________________________________________________________________
55Int_t
56AliFMDMap::CheckIndex(size_t det, Char_t ring, size_t sec, size_t str) const
57{
58 // Check that the index supplied is OK. Returns true index, or -1
59 // on error.
60 size_t ringi = (ring == 'I' || ring == 'i' ? 0 : 1);
61 size_t idx =
62 (det + fMaxDetectors * (ringi + fMaxRings * (sec + fMaxSectors * str)));
63 if (idx >= fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips)
64 return -1;
65 return idx;
66}
67
68
69//____________________________________________________________________
70size_t
71AliFMDMap::CalcIndex(size_t det, Char_t ring, size_t sec, size_t str) const
72{
73 // Calculate index into storage from arguments.
74 //
75 // Parameters:
76 // det Detector #
77 // ring Ring ID
78 // sec Sector #
79 // str Strip #
80 //
81 // Returns appropriate index into storage
82 //
83 Int_t idx = CheckIndex(det, ring, sec, str);
84 if (idx < 0) {
85 size_t ringi = (ring == 'I' || ring == 'i' ? 0 : 1);
86 AliFatal(Form("CalcIndex", "Index (%d,'%c',%d,%d) out of bounds, "
87 "in particular the %s index ",
88 det, ring, sec, str,
89 (det >= fMaxDetectors ? "Detector" :
90 (ringi >= fMaxRings ? "Ring" :
91 (sec >= fMaxSectors ? "Sector" : "Strip")))));
92 return 0;
93 }
94 return size_t(idx);
95}
96
97
98//___________________________________________________________________
99//
100// EOF
101//