hlawan:
LEDpattern = (LEDpattern | maskCup4); // maskCup4 is B11000000
The code above does a bitwise OR to set bits in a variable, where the bits are defined by a bitmask.
The code to clear them is much less obvious to understand, but surprisingly simple:
LEDpattern = (LEDpattern & ~maskCup4); // maskCup4 is B11000000
The ~ (tilde) operator gives you the bitwise inverse of the mask ("ones' complement") i.e. it inverts each bit. In this example it would give you B00111111.
The & (bitwise AND) operator then clears the bits which are zero in ~maskCup4. The result in this case is that it clears the top two bits and leaves the other bits unchanged.
Other options open to you are to use the Arduino function bitWrite(), bitSet(), bitClear() which let you read and update individual bits in a value without having to think about bitmasks. In this case where you seem to be dealing with multiple bits at the same time, the bitmasking approach you're using would produce more compact code.