A reconfigurable CMOS sensor for tracking, pre-shower and digital electromagnetic calorimetry