Problem with calibrated energy histogtram

I have Energy histogram with 8k channels and need to calibrate it. I am doing this with a macro but the output calibrated histogram has dips at fixed channel difference. In some cases, there are spikes in the calibrated histogram. I have found one article suggesting to use “(float) rand()/(float) RAND_MAX)” but that doesn’t work. Problem in histogram calibration
Attachments:

  1. Macro I am using named Digitizer.cpp
  2. The raw root file has name DataF_CH2.root
  3. The output file I created has name OutputCH2_0.root

_ROOT Version:6.22/06
_Platform:Ububtu 20.04 LTS
Compiler: Not Provided


OutputCH2_0.root (9.5 KB)
Digitizer.cpp (1.2 KB)

Hi,

do you mind making your input file publicly available to anyone without us needing to ask for access to it in the Google-Drive webform?

As to your issue, my first guess would be that it has to do with the fact that your Energy is an unsigned short. But I’d like to see your DataF_CH2.root to make sure.

I have updated the link in the original topic. The input file can be assessed now.

Thanks Chetan, I managed to access your file.

Looking at your EnergyCal_S histogram from OutputCH2_0.root, I do see the dips. For example:

There are no entries between 260 and 262. Let’s take a look at the code that fills this histogram:

EnergyCal_S->Fill(3.589*Energy -35.546 + (float) rand()/(float) RAND_MAX);

What should be the value of Energy so that the entire expression inside the Fill() was within 260 < calibrated energy < 262? Clearly, it can’t be greater than Energy=83, because even with this Energy=83 you get 3.589×83−35.546+X (where 0<X<1), which is 262.3 at the very least (when X=0). Also, it can’t be smaller than Energy=82, because even with this Energy=82 you get 3.589×82−35.546+X, which is 259.8 at the most (when X=1). So in order to land between 259.8 and 262.3 you need your Energy to be between 82 and 83 (excluding both these values). But it is impossible as Energy is an unsigned short. So this bin is empty, and so are many others.

EnergyCal_S->Fill(3.589 * (Energy + gRandom->Rndm()) - 35.546);

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.