3 /* Copyright(c) 1998-2000, ALICE Experiment at CERN, All rights
6 * See cxx source for full Copyright notice
13 //____________________________________________________________________
15 @brief Base class for caches of per-strip information.
17 This is used to index a strip. Data stored depends on derived
19 class AliFMDMap : public TObject
23 /** Default maximum detector number */
25 /** Default maximum number of rings */
27 /** Default maximum number of sectors */
29 /** Default maximum number of strips */
33 /** Number used for inner rings */
35 /** Number used for outer rings */
39 /** Number of strips in outer rings */
41 /** Number of strips in the inner rings */
45 /** Number of sectors in the inner rings */
47 /** Number of sectorts in the outer rings */
51 /** Base index for inner rings */
53 /** Base index for outer rings */
54 kBaseOuter = kNSectorInner * kNStripInner
57 /** Base for FMD1 index */
59 /** Base for FMD2 index */
60 kFMD2Base = kNSectorInner * kNStripInner,
61 /** Base for FMD3 index */
62 kFMD3Base = (kBaseOuter + kNSectorOuter * kNStripOuter + kFMD2Base)
65 * Class to do stuff on each element of a map in an efficient
74 * Called for each element considered a floating point number
76 * @param d Detector number
77 * @param r Ring identifier
78 * @param s Sector number
79 * @param t Strip number
80 * @param v Value (as a floating point number)
82 * @return Should return @c true on success, @c false otherwise
84 virtual Bool_t operator()(UShort_t d, Char_t r, UShort_t s, UShort_t t,
87 * Called for each element considered an integer
89 * @param d Detector number
90 * @param r Ring identifier
91 * @param s Sector number
92 * @param t Strip number
93 * @param v Value (as an integer)
95 * @return Should return @c true on success, @c false otherwise
97 virtual Bool_t operator()(UShort_t d, Char_t r, UShort_t s, UShort_t t,
100 * Called for each element considered an integer
102 * @param d Detector number
103 * @param r Ring identifier
104 * @param s Sector number
105 * @param t Strip number
106 * @param v Value (as an unsigned short integer)
108 * @return Should return @c true on success, @c false otherwise
110 virtual Bool_t operator()(UShort_t d, Char_t r, UShort_t s, UShort_t t,
113 * Called for each element considered an integer
115 * @param d Detector number
116 * @param r Ring identifier
117 * @param s Sector number
118 * @param t Strip number
119 * @param v Value (as a boolean)
121 * @return Should return @c true on success, @c false otherwise
123 virtual Bool_t operator()(UShort_t d, Char_t r, UShort_t s, UShort_t t,
130 * @param maxDet Maximum allowed detector number
131 * @param maxRing Maximum number of rings
132 * @param maxSec Maximum number of sectors
133 * @param maxStr Maximum number of strips
135 AliFMDMap(UShort_t maxDet = 0,
138 UShort_t maxStr = 0);
142 * @param other Object to construct from
144 AliFMDMap(const AliFMDMap& other);
146 virtual ~AliFMDMap() {}
147 /** @return Maximum detector number */
148 UShort_t MaxDetectors() const { return fMaxDetectors==0 ? 3 :fMaxDetectors;}
149 /** @return Maximum number of rings */
150 UShort_t MaxRings() const { return fMaxRings ==0 ? 2 :fMaxRings; }
151 /** @return Maximum number of sectors */
152 UShort_t MaxSectors() const { return fMaxSectors ==0 ? 40 :fMaxSectors; }
153 /** @return Maximum number of strip */
154 UShort_t MaxStrips() const { return fMaxStrips ==0 ? 512 :fMaxStrips; }
156 * Calculate the detector coordinates for a given index number
158 * @param idx Index to find cooresponding detector coordinates for
159 * @param det On return, contain the detector number
160 * @param ring On return, contain the ring identifier
161 * @param sec On return, contain the sector number
162 * @param str On return, contain the strip number
164 void CalcCoords(Int_t idx,
168 UShort_t& str) const;
170 * Calculate index and return
172 * @param det Detector number
173 * @param ring Ring identifier
174 * @param sec Sector number
175 * @param str Strip number
177 * @return Index (not checked)
179 Int_t CalcIndex(UShort_t det, Char_t ring,
180 UShort_t sec, UShort_t str) const;
182 * Calculate index and return
184 * @param det Detector number
185 * @param ring Ring identifier
186 * @param sec Sector number
187 * @param str Strip number
189 * @return Index or -1 if the coordinates are invalid
191 Int_t CheckIndex(UShort_t det, Char_t ring,
192 UShort_t sec, UShort_t str) const;
194 * Check if we need UShort_t hack
196 * @param file File this object was read from
198 void CheckNeedUShort(TFile* file);
200 * Right multiplication operator
202 * @param o Other map to multuiply with
204 * @return Reference to this object
206 AliFMDMap& operator*=(const AliFMDMap& o);
208 * Right division operator
210 * @param o Other map to divide with
212 * @return Reference to this object
214 AliFMDMap& operator/=(const AliFMDMap& o);
216 * Right addision operator
218 * @param o Other map to add to this
220 * @return Reference to this object
222 AliFMDMap& operator+=(const AliFMDMap& o);
224 * Right subtraction operator
226 * @param o Other map to substract from this
228 * @return Reference to this object
230 AliFMDMap& operator-=(const AliFMDMap& o);
232 * For each element of the map, call the user defined overloaded
233 * @c ForOne::operator()
235 * @param algo Algorithm to use
237 * @return @c true on success, @c false if for any element, @c
238 * algo(d,r,s,t,v) returns false.
240 virtual Bool_t ForEach(ForOne& algo) const;
242 * Get the total size of the internal array - that is the maximum
243 * index possible plus one.
245 * @return maximum index, plus 1
247 virtual Int_t MaxIndex() const = 0;
249 * Virtal function to get the value at index @a idx as a floating
253 * Even if the map is not floating point valued the
254 * sub-class can define this member function to allow non l-value
255 * usage of the data in the map. That is, if @c a is a floating
256 * point valued map, and @c b is not, then if the class @c B of @c b
257 * implements this member function, expression like
263 * multiplies each element of @c a (floating points) with each
264 * element of @c c according to the definition of @c B::AtAsFloat
265 * (@c const version).
267 * @param idx Index number
269 * @return Value at index as a floating point number
271 virtual Float_t AtAsFloat(Int_t idx) const;
273 * Virtal function to get the value at index @a idx as a floating
276 * This member function should only be defined if the map is a
277 * floating point valued, and can be assigned floating point valued
278 * values. That is, if the map's elements are anything but @c
279 * float then this member function should not be defined in the
280 * derived class. That will prevent expressions like
286 * where @c a is non-floating point valued, and @c b is floating
287 * point valued (only).
289 * @param idx Index number
291 * @return Value at index as a floating point number
293 virtual Float_t& AtAsFloat(Int_t idx);
295 * Virtal function to get the value at index @a idx as an integer
297 * @see Float_t AliFMDMap::AtAsFloat(Int_t) const
299 * @param idx Index number
301 * @return Value at index as an integer
303 virtual Int_t AtAsInt(Int_t idx) const;
305 * Virtal function to get the value at index @a idx as an integer
307 * @see Float_t& AliFMDMap::AtAsFloat(Int_t)
309 * @param idx Index number
311 * @return Value at index as an integer
313 virtual Int_t& AtAsInt(Int_t idx);
315 * Virtal function to get the value at index @a idx as an boolean
317 * @see Float_t AliFMDMap::AtAsFloat(Int_t) const
319 * @param idx Index number
321 * @return Value at index as a boolean
323 virtual UShort_t AtAsUShort(Int_t idx) const;
325 * Virtal function to get the value at index @a idx as an boolean
327 * @see Float_t& AliFMDMap::AtAsFloat(Int_t)
329 * @param idx Index number
331 * @return Value at index as a boolean
333 virtual UShort_t& AtAsUShort(Int_t idx);
335 * Virtal function to get the value at index @a idx as an unsigned
338 * @see Float_t AliFMDMap::AtAsFloat(Int_t) const
340 * @param idx Index number
342 * @return Value at index as an unsigned short integer
344 virtual Bool_t AtAsBool(Int_t idx) const;
346 * Virtal function to get the value at index @a idx as an unsigned
349 * @see Float_t& AliFMDMap::AtAsFloat(Int_t)
351 * @param idx Index number
353 * @return Value at index as an unsigned short integer
355 virtual Bool_t& AtAsBool(Int_t idx);
357 * Whether this map is floating point valued - that is, it can be
358 * assigned floating point valued values.
360 * @return @c true if the map is floating point valued
362 virtual Bool_t IsFloat() const { return kFALSE; }
364 * Whether this map is floating point valued or integer valued -
365 * that is, it can be assigned integer valued values
367 * @return @c true if the map is integer valued
369 virtual Bool_t IsInt() const { return kFALSE; }
371 * Whether this map is unsigned short integer valued - that is it
372 * can be assigned unsigned short integer values
374 * @return @c true if the map is unsigned short integer valued
376 virtual Bool_t IsUShort() const { return kFALSE; }
378 * Whether this map is boolean valued - that is it can be assigned
381 * @return @c true if the map is boolean valued
383 virtual Bool_t IsBool() const { return kFALSE; }
386 /** In case of version 2 of this class, this bit should be set. */
391 * Calculate, check, and return index for strip. If the index is
392 * invalid, -1 is returned
394 * This is only used when a full map is used, signalled by
397 * @param det Detector number
398 * @param ring Ring identifier
399 * @param sec Sector number
400 * @param str Strip number
402 * @return Unique index, or -1 in case of errors
404 Int_t Coords2Index(UShort_t det, Char_t ring,
405 UShort_t sec, UShort_t str) const;
407 * Calculate, check, and return index for strip. If the index is
408 * invalid, -1 is returned
410 * This is for back-ward compatibility and for when a map does not
411 * cover all of the FMD strips
413 * @param det Detector number
414 * @param ring Ring identifier
415 * @param sec Sector number
416 * @param str Strip number
418 * @return Unique index, or -1 in case of errors
420 Int_t Coords2IndexOld(UShort_t det, Char_t ring,
421 UShort_t sec, UShort_t str) const;
423 * Calculate the detector coordinates from an array index.
425 * This is used for backward compatibility and for when a map does not
426 * cover all of the FMD strips
428 * @param idx Index to convert
429 * @param det Detector number on return
430 * @param ring Ring identifier on return
431 * @param sec Sector number on return
432 * @param str Strip number on return
434 void Index2CoordsOld(Int_t idx,
438 UShort_t& str) const;
440 * Calculate the detector coordinates from an array index.
442 * This is used for a full map only, signalled by fMaxDetector = 0
444 * @param idx Index to convert
445 * @param det Detector number on return
446 * @param ring Ring identifier on return
447 * @param sec Sector number on return
448 * @param str Strip number on return
450 void Index2Coords(Int_t idx,
454 UShort_t& str) const;
455 UShort_t fMaxDetectors; // Maximum # of detectors
456 UShort_t fMaxRings; // Maximum # of rings
457 UShort_t fMaxSectors; // Maximum # of sectors
458 UShort_t fMaxStrips; // Maximum # of strips
460 ClassDef(AliFMDMap, 4) // Cache of per strip information
464 AliFMDMap::AtAsFloat(Int_t) const
469 AliFMDMap::AtAsFloat(Int_t)
475 AliFMDMap::AtAsInt(Int_t) const
480 AliFMDMap::AtAsInt(Int_t)
486 AliFMDMap::AtAsUShort(Int_t) const
491 AliFMDMap::AtAsUShort(Int_t)
497 AliFMDMap::AtAsBool(Int_t) const
502 AliFMDMap::AtAsBool(Int_t)
508 AliFMDMap::ForOne::operator()(UShort_t, Char_t, UShort_t, UShort_t, Float_t)
513 AliFMDMap::ForOne::operator()(UShort_t, Char_t, UShort_t, UShort_t, Int_t)
518 AliFMDMap::ForOne::operator()(UShort_t, Char_t, UShort_t, UShort_t, UShort_t)
523 AliFMDMap::ForOne::operator()(UShort_t, Char_t, UShort_t, UShort_t, Bool_t)
531 //____________________________________________________________________