An X-ray diffraction apparatus comprising: an X-ray source; a sample stage, for receiving a sample to be irradiated by X-rays from the X-ray source; a detector, arranged to receive X-rays diffracted from the sample; one or more readout circuits, coupled to the detector; and a detection processor, configured to process signals generated by the one or more readout circuits to count a number of photons arriving at the detector, wherein the detector comprises at least a first detector cell (142 7; 342 1) and a second detector cell (142 8; 342 2), each detector cell being configured to convert incoming X-ray photons into respective electrical pulses, wherein the one or more readout circuits are configured to receive the electrical pulses from the first and second detector cells and generate one or more readout signals for the detection processor, wherein the detection processor is configured to analyse, based on the one or more readout signals, a first pulse generated by the first detector cell and a second pulse generated by the second detector cell, comprising: if a time delay between the first pulse and the second pulse is less than a predetermined time threshold, determining that one of a charge sharing event and a coincident photon event has occurred, and characterized in that if an energy of each of the first pulse and the second pulse was above a first threshold (V L) and below a second threshold (V H), determining that a coincident photon event has occurred, and otherwise determining that a charge sharing event has occurred, the detection processor being further configured to count the coincident photon event as the arrival of an X-ray photon at each of the first and second detector cells, and to discount the charge sharing event. an X-ray source; a sample stage, for receiving a sample to be irradiated by X-rays from the X-ray source; a detector, arranged to receive X-rays diffracted from the sample; one or more readout circuits, coupled to the detector; and a detection processor, configured to process signals generated by the one or more readout circuits to count a number of photons arriving at the detector, wherein the detector comprises at least a first detector cell (142 7; 342 1) and a second detector cell (142 8; 342 2), each detector cell being configured to convert incoming X-ray photons into respective electrical pulses, wherein the one or more readout circuits are configured to receive the electrical pulses from the first and second detector cells and generate one or more readout signals for the detection processor, wherein the detection processor is configured to analyse, based on the one or more readout signals, a first pulse generated by the first detector cell and a second pulse generated by the second detector cell, comprising: if a time delay between the first pulse and the second pulse is less than a predetermined time threshold, determining that one of a charge sharing event and a coincident photon event has occurred, and characterized in that if an energy of each of the first pulse and the second pulse was above a first threshold (V L) and below a second threshold (V H), determining that a coincident photon event has occurred, and otherwise determining that a charge sharing event has occurred, if a time delay between the first pulse and the second pulse is less than a predetermined time threshold, determining that one of a charge sharing event and a coincident photon event has occurred, and characterized in that if an energy of each of the first pulse and the second pulse was above a first threshold (V L) and below a second threshold (V H), determining that a coincident photon event has occurred, and otherwise determining that a charge sharing event has occurred, the detection processor being further configured to count the coincident photon event as the arrival of an X-ray photon at each of the first and second detector cells, and to discount the charge sharing event.