1 #ifndef ALIHLTMUONCOREREGIONOFINTEREST_H
2 #define ALIHLTMUONCOREREGIONOFINTEREST_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
8 ////////////////////////////////////////////////////////////////////////////////
10 // Author: Artur Szostak
11 // Email: artur@alice.phy.uct.ac.za | artursz@iafrica.com
13 // The region of interest object is used to encode/decode and work with boundary
14 // box type regions of interest. The 32 bit ROI codes are used to communicate
15 // regions of interest between different parts of the dHLT system. This is more
16 // efficient than sending 20 byte long region of interest objects.
18 ////////////////////////////////////////////////////////////////////////////////
20 #include "AliHLTMUONBasicTypes.h"
21 #include "AliHLTMUONUtils.h"
22 #include "AliHLTMUONCoreCluster.h"
25 typedef UInt AliHLTMUONCoreROI;
29 kInvalidROI = 0xFFFFFFFF
33 /* Identification numbers specifying the tracking chambers of the dimuon
36 enum AliHLTMUONCoreChamberID
52 class AliHLTMUONCoreRegionOfInterest
56 AliHLTMUONCoreRegionOfInterest()
57 : fChamber(kChamber1), fLeft(0.0), fRight(0.0), fBottom(0.0), fTop(0.0)
60 fLeft = fRight = fBottom = fTop = 0.0;
63 /* This constructor decodes the ROI bit pattern into a region of
66 AliHLTMUONCoreRegionOfInterest(const AliHLTMUONCoreROI& code)
67 : fChamber(kChamber1), fLeft(0.0), fRight(0.0), fBottom(0.0), fTop(0.0)
72 /* Creates a region of interest around the given point for the
75 AliHLTMUONCoreRegionOfInterest(
76 const AliHLTMUONCoreClusterPoint& point0,
77 AliHLTMUONCoreChamberID chamber0
79 : fChamber(kChamber1), fLeft(0.0), fRight(0.0), fBottom(0.0), fTop(0.0)
81 CreateToContain(point0, chamber0);
84 /* Creates a region of interest around all the given points and for the
87 AliHLTMUONCoreRegionOfInterest(
88 const AliHLTMUONCoreClusterPoint* points0, UInt count0,
89 AliHLTMUONCoreChamberID chamber0
91 : fChamber(kChamber1), fLeft(0.0), fRight(0.0), fBottom(0.0), fTop(0.0)
93 CreateToContain(points0, count0, chamber0);
96 /* Creates a region of interest with the specified boundaries and for
97 the specified chamber.
99 AliHLTMUONCoreRegionOfInterest(
100 Float left, Float right, Float bottom, Float top,
101 AliHLTMUONCoreChamberID chamber
104 /* Checks if the point is contained in this region of interest.
106 bool Contains(const AliHLTMUONCoreClusterPoint& point) const;
108 /* Checks if the point is contained in this region of interest and the
109 chamber number corresponds to this region object.
112 const AliHLTMUONCoreClusterPoint& point,
113 AliHLTMUONCoreChamberID chamber
116 /* Checks if the specified region of interest is contained in this
117 region of interest object.
119 bool Contains(const AliHLTMUONCoreRegionOfInterest& roi) const;
121 /* Creates a region of interest around the given point for the
124 void CreateToContain(
125 const AliHLTMUONCoreClusterPoint& point,
126 AliHLTMUONCoreChamberID chamber
129 /* Extends the region of interest to contain the specified point.
131 void ExpandToContain(const AliHLTMUONCoreClusterPoint& point);
133 /* Creates a region of interest around all the given points and for the
136 void CreateToContain(
137 const AliHLTMUONCoreClusterPoint* points, UInt count,
138 AliHLTMUONCoreChamberID chamber
141 /* Checks if the region of interest is within the boundaries imposed on
142 the specific chamber plane. This boundary is aproximately the square
143 box around the chamber's detection region.
147 /* Encodes the region of interest into a 32 bit code.
149 AliHLTMUONCoreROI Encode() const;
151 /* Encodes the region of interest into a 32 bit code, and returns the
152 hierarchal level the region was encoded at and the left and right
153 grid coordinate of the bottom left corner of the region boundary box.
155 AliHLTMUONCoreROI Encode(UChar& level, UInt& l, UInt& b) const;
157 /* Decodes a 32 bit region of interest code into this region of interest
160 void Decode(AliHLTMUONCoreROI code);
162 /* Decodes the chamber number of the region of interest 32 bit code.
164 static AliHLTMUONCoreChamberID DecodeChamber(AliHLTMUONCoreROI code);
166 /* Decodes the 32 bit region of interest code into the chamber number,
167 hierarchal level, left and right grid coordinates of the region
171 AliHLTMUONCoreROI code, AliHLTMUONCoreChamberID& chamber,
172 UChar& level, UInt& l, UInt& b
175 /* Returns the chamber number of the region of interest.
177 AliHLTMUONCoreChamberID Chamber() const { return fChamber; };
179 /* Returns the left hand boundary of the region of interest.
181 Float Left() const { return fLeft; };
183 /* Returns the right hand boundary of the region of interest.
185 Float Right() const { return fRight; };
187 /* Returns the bottom boundary of the region of interest.
189 Float Bottom() const { return fBottom; };
191 /* Returns the top boundary of the region of interest.
193 Float Top() const { return fTop; };
196 /* Typecast operator for implicit typecasing to 32 bit ROI codes.
198 operator AliHLTMUONCoreROI () const { return Encode(); };
203 /* Converts the internal region of interest boundary box, which is
204 specified in as floats, into a regular integer grid.
205 l = left boundary, r = right boundary, b = bottom boundary,
208 inline void ConvertToGrid(UInt& l, UInt& r, UInt& b, UInt& t) const;
210 /* Performs the inverse conversion of the method ConvertToGrid.
211 That is converts from a regular integer grid back to the internal
212 floating point boundary box specification.
214 inline void ConvertBackFromGrid(register UInt l, register UInt r, register UInt b, register UInt t);
216 /* Internal method for decoding 32 bit region codes. This method is
217 called by the Decode methods.
219 static void DecodeBits(
220 AliHLTMUONCoreROI code, AliHLTMUONCoreChamberID& chamber,
221 UChar& colevel, UInt& l, UInt& b
224 enum {kNumberOfTrackingChambers = 10}; // Number of tracking chambers.
226 // Boundary box scale numbers for each chamber. These are the boundary
227 // boxes around the chambers detection surface.
228 static Float fgPlaneScale[kNumberOfTrackingChambers]; // scale numbers.
230 static UInt fgIndexOffsets[13]; // Offset numbers used in the encoding and decoding process.
233 AliHLTMUONCoreChamberID fChamber; // Specifies the chamber the region of interest is on.
234 Float fLeft; // Left boundary of boundary box.
235 Float fRight; // Right boundary of boundary box.
236 Float fBottom; // Bottom boundary of boundary box.
237 Float fTop; // Top boundary of boundary box.
241 //-----------------------------------------------------------------------------
245 inline AliHLTMUONCoreRegionOfInterest::AliHLTMUONCoreRegionOfInterest(
246 Float left, Float right, Float bottom, Float top,
247 AliHLTMUONCoreChamberID chamber
249 : fChamber(kChamber1), fLeft(0.0), fRight(0.0), fBottom(0.0), fTop(0.0)
251 // Creates a region of interest with the specified boundaries and for
252 // the specified chamber.
254 Assert( 0 <= chamber && chamber < (AliHLTMUONCoreChamberID)kNumberOfTrackingChambers );
263 inline bool AliHLTMUONCoreRegionOfInterest::Contains(const AliHLTMUONCoreClusterPoint& point) const
265 // Checks if the point is contained in this region of interest.
267 return fLeft <= point.X()
268 && point.X() <= fRight
269 && fBottom <= point.Y()
270 && point.Y() <= fTop;
274 inline bool AliHLTMUONCoreRegionOfInterest::Contains(
275 const AliHLTMUONCoreClusterPoint& point,
276 AliHLTMUONCoreChamberID chamber
279 // Checks if the point is contained in this region of interest and the
280 // chamber number corresponds to this region object.
282 return fLeft <= point.X()
283 && point.X() <= fRight
284 && fBottom <= point.Y()
286 && fChamber == chamber;
290 inline bool AliHLTMUONCoreRegionOfInterest::Contains(
291 const AliHLTMUONCoreRegionOfInterest& roi
294 // Checks if the specified region of interest is contained in this
295 // region of interest object.
297 return fChamber == roi.fChamber
298 && fLeft <= roi.fLeft
299 && fRight >= roi.fRight
300 && fBottom <= roi.fBottom
305 #endif // ALIHLTMUONCOREREGIONOFINTEREST_H