]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDMap.cxx
Fix bug in energy deposition, and add some stuff for calibrations
[u/mrichter/AliRoot.git] / FMD / AliFMDMap.cxx
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 //
21 //
22 #include "AliFMDMap.h"          // ALIFMDMAP_H
23
24 //____________________________________________________________________
25 ClassImp(AliFMDMap)
26 #if 0
27   ; // This is here to keep Emacs for indenting the next line
28 #endif
29
30 //____________________________________________________________________
31 AliFMDMap::AliFMDMap(size_t maxDet, 
32                      size_t maxRing, 
33                      size_t maxSec, 
34                      size_t maxStr)
35   : fMaxDetectors(maxDet), 
36     fMaxRings(maxRing), 
37     fMaxSectors(maxSec), 
38     fMaxStrips(maxStr)
39 {
40   // Construct a map
41   //
42   // Parameters:
43   //     maxDet       Maximum # of detectors
44   //     maxRinf      Maximum # of rings
45   //     maxSec       Maximum # of sectors
46   //     maxStr       Maximum # of strips
47 }
48
49 //____________________________________________________________________
50 Int_t 
51 AliFMDMap::CheckIndex(size_t det, Char_t ring, size_t sec, size_t str) const
52 {
53   // Check that the index supplied is OK.   Returns true index, or -1
54   // on error. 
55   size_t ringi = (ring == 'I' ||  ring == 'i' ? 0 : 1);
56   size_t idx = 
57     (det + fMaxDetectors * (ringi + fMaxRings * (sec + fMaxSectors * str)));
58   if (idx >= fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips) 
59     return -1;
60   return idx;
61 }
62
63     
64 //____________________________________________________________________
65 size_t 
66 AliFMDMap::CalcIndex(size_t det, Char_t ring, size_t sec, size_t str) const
67 {
68   // Calculate index into storage from arguments. 
69   // 
70   // Parameters: 
71   //     det       Detector #
72   //     ring      Ring ID
73   //     sec       Sector # 
74   //     str       Strip # 
75   //
76   // Returns appropriate index into storage 
77   //
78   Int_t idx = CheckIndex(det, ring, sec, str);
79   if (idx < 0) {
80     size_t ringi = (ring == 'I' ||  ring == 'i' ? 0 : 1);
81     Fatal("CalcIndex", "Index (%d,'%c',%d,%d) out of bounds, "
82           "in particular the %s index ", 
83           det, ring, sec, str, 
84           (det >= fMaxDetectors ? "Detector" : 
85            (ringi >= fMaxRings ? "Ring" : 
86             (sec >= fMaxSectors ? "Sector" : "Strip"))));
87     return 0;
88   }
89   return size_t(idx);
90 }
91
92
93 //___________________________________________________________________
94 //
95 // EOF
96 //