IPP Object Catalog Bit Masks

The IPP pipeline stores some information about object in the FLAGS value in the CMF file. These values represent "bit masks", not standard integer values. That is, individual bits within the value have meaning, rather than the value itself. The bit masks for CMF files are defined in

source:trunk/psModules/src/objects/pmSourceMasks.h

(that link takes you to the current version of the flags at any point in time; maybe we need to link to the flags for a tagged version of IPP once there is once for run3, e.g.)

If I were in charge of the Transient Classification Server and only wanted to consider objects that were single PSF-like, I might use the following bitmasks to denote bad and good objects:

badbitmask = PM_SOURCE_MODE_FAIL + PM_SOURCE_MODE_POOR + PM_SOURCE_MODE_SATSTAR + 
PM_SOURCE_MODE_BLEND + PM_SOURCE_MODE_EXTERNAL + PM_SOURCE_MODE_BADPSF + PM_SOURCE_MODE_DEFECT + 
PM_SOURCE_MODE_SATURATED + PM_SOURCE_MODE_CR_LIMIT + PM_SOURCE_MODE_EXT_LIMIT

goodbitmask = PM_SOURCE_MODE_PSFMODEL + PM_SOURCE_MODE_FITTED

Intro to Bit Masks

[Paul Price] For an introduction to this idea, see: http://en.wikipedia.org/wiki/Bitmask

A real quick example may also help. Let's say I want to encode some boolean values about food. Below I list some food characteristics, and their mask value in binary and decimal:

DELICIOUS	0001 => 1
SPICY		0010 => 2
CHEAP		0100 => 4
MEAT		1000 => 8

Now, some typical dishes might be:

Lobster		MEAT => 1000 => 8
Chicken salad	CHEAP | MEAT => 1100 => 12
Chicken curry	DELICIOUS | SPICY | CHEAP | MEAT => 1111 => 15
Tofu curry	SPICY | CHEAP => 0110 => 6
Spaghetti	DELICIOUS | CHEAP => 0101 => 5

Here, the pipe ("|") between symbols means a bitwise OR operation on the mask values (i.e., do an OR for each bit).

Now, with such a list, say I want to find something to eat tonight. I'm in the mood for something spicy, so I go down the list, looking for lines that have the SPICY bit set. This is done using the "&" (bitwise AND) operation --- look for values for which "value & SPICY" is true. In this case, it could be either chicken curry (value 15) or tofu curry (value 6). Despite the fact that the values are very different, they both have the appropriate bit set, so they both match the filter.