]>
Commit | Line | Data |
---|---|---|
9da38871 | 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" | |
c05d076f | 28 | //#include <TClass.h> |
29 | //#include <TBuffer.h> | |
30 | #include <TFile.h> | |
31 | #include <TList.h> | |
32 | #include <TStreamerInfo.h> | |
9da38871 | 33 | |
34 | //____________________________________________________________________ | |
35 | ClassImp(AliFMDMap) | |
36 | #if 0 | |
37 | ; // This is here to keep Emacs for indenting the next line | |
38 | #endif | |
39 | ||
40 | //____________________________________________________________________ | |
9eeb02aa | 41 | AliFMDMap::AliFMDMap(UShort_t maxDet, |
42 | UShort_t maxRing, | |
43 | UShort_t maxSec, | |
44 | UShort_t maxStr) | |
9da38871 | 45 | : fMaxDetectors(maxDet), |
46 | fMaxRings(maxRing), | |
47 | fMaxSectors(maxSec), | |
48 | fMaxStrips(maxStr) | |
49 | { | |
50 | // Construct a map | |
51 | // | |
52 | // Parameters: | |
53 | // maxDet Maximum # of detectors | |
54 | // maxRinf Maximum # of rings | |
55 | // maxSec Maximum # of sectors | |
56 | // maxStr Maximum # of strips | |
c05d076f | 57 | SetBit(kNeedUShort, kFALSE); |
9da38871 | 58 | } |
59 | ||
c05d076f | 60 | //____________________________________________________________________ |
61 | void | |
62 | AliFMDMap::CheckNeedUShort(TFile* file) | |
63 | { | |
64 | if (!file) return; | |
e03121ec | 65 | TObject* o = file->GetStreamerInfoList()->FindObject("AliFMDMap"); |
c05d076f | 66 | if (!o) return; |
67 | TStreamerInfo* info = static_cast<TStreamerInfo*>(o); | |
68 | if (info->GetClassVersion() == 2) SetBit(kNeedUShort); | |
69 | } | |
9da38871 | 70 | //____________________________________________________________________ |
71 | Int_t | |
9eeb02aa | 72 | AliFMDMap::CheckIndex(UShort_t det, Char_t ring, UShort_t sec, UShort_t str) const |
9da38871 | 73 | { |
74 | // Check that the index supplied is OK. Returns true index, or -1 | |
75 | // on error. | |
ac07a8f5 | 76 | if (det < 1) return -1; |
9eeb02aa | 77 | UShort_t ringi = (ring == 'I' || ring == 'i' ? 0 : 1); |
c05d076f | 78 | Int_t idx = |
9da38871 | 79 | (str + fMaxStrips * (sec + fMaxSectors * (ringi + fMaxRings * (det-1)))); |
c05d076f | 80 | if (TestBit(kNeedUShort)) idx = UShort_t(idx); |
81 | if (idx < 0 || idx >= fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips) | |
82 | return -1; | |
9da38871 | 83 | return idx; |
84 | } | |
85 | ||
86 | ||
87 | //____________________________________________________________________ | |
5664d15a | 88 | Int_t |
9eeb02aa | 89 | AliFMDMap::CalcIndex(UShort_t det, Char_t ring, UShort_t sec, UShort_t str) const |
9da38871 | 90 | { |
91 | // Calculate index into storage from arguments. | |
92 | // | |
93 | // Parameters: | |
94 | // det Detector # | |
95 | // ring Ring ID | |
96 | // sec Sector # | |
97 | // str Strip # | |
98 | // | |
99 | // Returns appropriate index into storage | |
100 | // | |
101 | Int_t idx = CheckIndex(det, ring, sec, str); | |
102 | if (idx < 0) { | |
9eeb02aa | 103 | UShort_t ringi = (ring == 'I' || ring == 'i' ? 0 : 1); |
9da38871 | 104 | AliFatal(Form("Index (%d,'%c',%d,%d) out of bounds, " |
105 | "in particular the %s index ", | |
106 | det, ring, sec, str, | |
107 | (det > fMaxDetectors ? "Detector" : | |
108 | (ringi >= fMaxRings ? "Ring" : | |
109 | (sec >= fMaxSectors ? "Sector" : "Strip"))))); | |
110 | return 0; | |
111 | } | |
5664d15a | 112 | return idx; |
9da38871 | 113 | } |
114 | ||
c05d076f | 115 | #if 0 |
116 | //___________________________________________________________________ | |
117 | void AliFMDMap::Streamer(TBuffer &R__b) | |
118 | { | |
119 | // Stream an object of class AliFMDMap. | |
120 | // This is overridden so that we can know the version of the object | |
121 | // that we are reading in. In this way, we can fix problems that | |
122 | // might occur in the class. | |
123 | if (R__b.IsReading()) { | |
124 | // read the class version from the buffer | |
125 | UInt_t R__s, R__c; | |
126 | Version_t version = R__b.ReadVersion(&R__s, &R__c, this->Class()); | |
127 | TFile *file = (TFile*)R__b.GetParent(); | |
128 | if (file && file->GetVersion() < 30000) version = -1; | |
129 | AliFMDMap::Class()->ReadBuffer(R__b, this, version, R__s, R__c); | |
130 | if (version == 2) SetBit(kNeedUShort); | |
131 | } else { | |
132 | AliFMDMap::Class()->WriteBuffer(R__b, this); | |
133 | } | |
134 | } | |
135 | #endif | |
9da38871 | 136 | |
137 | //___________________________________________________________________ | |
138 | // | |
139 | // EOF | |
140 | // |