ComputationalRadiationPhysics / jungfrau-photoncounter

Conversion of Jungfrau pixel detector data to photon count rate
GNU General Public License v3.0
2 stars 2 forks source link

Conversion Algorithm #30

Closed TheFl0w closed 7 years ago

TheFl0w commented 7 years ago

The conversion algorithm to get the number of photons you are using in the example program seems to be different from the algorithm you show in the pdf. I think the wrong pedestal maps are used in step 2, and the energy and number of photons is calculated in a completely different way. Is the algorithm in the pdf the correct one? Also, gain stages are encoded as {0, 1, 3}. Is this correct?

From my understanding:

PDF version

  1. Mask out the digital gain bits to get the raw ADC data and identify the employed gain stage.
  2. Offset (pedestal) correction:
    • Corrected charge for gain stage G0: adcpc = adc - pedestals16_G0[i];
    • Corrected charge for gain stage G1: adcpc = pedestals16_G1[i] - adc;
    • Corrected charge for gain stage G2: adcpc = pedestals16_G2[i] - adc;
  3. Calibration:
    • Calibrated energy for gain stage G0: energy = adcpc * mapsObjectGain->g0VALs[i];
    • Calibrated energy for gain stage G1: energy = adcpc * mapsObjectGain->g1VALs[i];
    • Calibrated energy for gain stage G2: energy = adcpc * mapsObjectGain->g2VALs[i];
  4. Transform the calibrated energy to number of photons
    • Number of photons: nop = energy / beamE;

Code version

  1. Mask out the digital gain bits to get the raw ADC data and identify the employed gain stage.
  2. Offset (pedestal) correction:
    • Corrected charge for gain stage G0: adcpc = adc - pedestals16_G0[i];
    • Corrected charge for gain stage G1: adcpc = pedestals16_G1[i] - adc;
    • Corrected charge for gain stage G2: adcpc = pedestals16_G1[i] - adc;
  3. Calibration:
    • Calibrated energy for gain stage G0: energy = (adc - pedestals16_G0[i]) / mapsObjectGain->g0VALs[i];
    • Calibrated energy for gain stage G1: energy = (-1)*(pedestals16_G1[i] - adc) / mapsObjectGain->g1VALs[i];
    • Calibrated energy for gain stage G2: energy = (-1)*(pedestals16_G2[i] - adc) / mapsObjectGain->g2VALs[i];
  4. Transform the calibrated energy to number of photons
    • Number of photons: nop = (energy + beamE / 2) / beamE;
sredford commented 7 years ago

In this case you should follow the code over the pdf. 1 and 2 agree. 3: it's just a question of how the gain is defined in the maps, but the way it is at the moment you need to divide by the gain. 4: it should be nop = (energy + (beamE/2.))/beamE. The reason that this is different between code and pdf is just to ensure that when it's cast to an int it is rounded, not floored.