janmayer / hdtv

Nuclear Spectrum Analysis Tool
GNU General Public License v2.0
17 stars 9 forks source link

Using hdtv for coincidence analysis #30

Closed g3beam closed 1 year ago

g3beam commented 1 year ago

To whom it concerns,

When trying to analyze the labr_labr matrix, I keep receiving the error message below.

"unconventional binning detected. Converting and trying to create calibration using a polynomial of order 4 ..."

The script is interchangeable between both matrices and works fine when analyzing the labr_hpge matrix. The files are processed via ROOT before using hdtv analyze in further detail. By chance, could someone point me in the right direction to fix this error?

Regards,

Xavier James

u-eff-gee commented 1 year ago

Hi Xavier,

Thanks for posting your question.

First of all, I'd like to say that it would be helpful if you could explain more precisely what matrices and scripts you are referring to. Maybe provide a minimum working example. For the moment, I will attempt to make an educated guess because I know roughly what you are working on.

In general, the message you quoted is not necessarily a problem, it is just a warning. Internally, when loading a histogram in the ROOT format, hdtv checks for so-called "primitive binning" (difference between the maximum and minimum x value corresponds to the number of bins, see here

https://github.com/janmayer/hdtv/blob/ef626f2a348dbb7912b0197c31a6e8c10a8d4587/hdtv/histogram.py#L42

i.e. bin number N should cover the x-value range from N-1 to N. With histograms that are created by external scripts, this may not always be the case. A very common issue here is that bin number N covers a range that is symmetric around an integer x value, i.e. N-0.5 to N+0.5. In this case, the conversion to a hdtv-style primitive binning is trivial. On the other hand, if the calibration of your input spectrum is highly nonlinear or the x values are not even monotonously increasing, the loaded spectrum may look very different from what you viewed in ROOT.

There are many reasons why hdtv would print this warning message for one spectrum, but not the other. Maybe one of them has a calibration, and the other doesn't?

If the spectrum you loaded into hdtv looks like the one you viewed in ROOT, everything is probably alright. To be absolutely sure, you could try to perform the same fit using ROOT's fit interface and hdtv and check whether they agree.

Best, Udo

g3beam commented 1 year ago

Hi Udo,

The process I have been taking when analyzing the gated spectrum is first done via ROOT to gate at specified energies. From there, I set the matrix file ,name, and parameters for the gate and two background gate limits. The script is then loaded to be viewed on ROOT and hdtv to analyze the gated coincidences.

Below is a sample of the script and images of what I have been encountering when trying to analyzing labr_labr for 64Ni. The first image was when I was loading the coincidence script and just an error in ROOT that was fixed. Last image is a gated spectrum for the first 2+ state at 1345 keV which is currently recalibrated at 1327 keV (the 511 keV peak was shifted to 506 keV). Using the following gated formula via hdtv to find the coincidences: Gate - 1/2(background1 +background2).

I am currently looking at the binning between labr_labr and labr_hpge as you have advised.

Ni64_gate.txt Screenshot from 2023-01-27 11-21-28 Screenshot from 2023-02-17 11-56-00

Regards,

Xavier

u-eff-gee commented 1 year ago

Hi Xavier,

If the code in the screenshot (which is not identical to the code in the text file) was used to generate the spectra that are shown in the hdtv screenshot, then it seems to me that you are not "Using hdtv for coincidence analysis" as the title of your issue implies. Your description corroborates that. hdtv also has coincidence-matrix analysis capabilities of its own (https://github.com/janmayer/hdtv/blob/master/doc/guide/hdtv.rst#matrix-interface). At the beginning, I thought that that was what you were referring to. It looks like you are analyzing 1D spectra that are the output from a ROOT script.

I can see nothing that is obviously wrong with the spectra you sent. The plot of the labr_hpge matrix is showing a 1D spectrum in red which you did not mention. A labr_labr matrix is not shown. The three 1D spectra look okay to me. They appear to have the usual Gaussian/Poissonian fluctuations (although that is a little hard to judge with a logarithmic y axis) and a satisfactory lineshape. You are mentioning many experiment-specific pieces of information in your description, but not all of them seem to be related to your original issue with the unconventional binning. For example, I am not sure what you mean by:

The first image was when I was loading the coincidence script and just an error in ROOT that was fixed.

From Ni64_gate*.cpp, it is not possible to address the binning issue, because the binnings of gate, background_gate_1, and background_gate_2 all depend on the 2D histogram matrix whose properties are unknown.

I am currently looking at the binning between labr_labr and labr_hpge as you have advised.

Yes, that will help us figure out why the warning about "unconventional binning" is printed.

Please let me know if I got anything wrong here. There are several assumptions in my answer.

Best, Udo

op3 commented 1 year ago

Dear Xavier,

your matrix has a non-trivial binning (which for hdtv means anything else than bins with a width of 1, with the first bin centered at 0). The message that you see only means that hdtv is converting the binning of your matrix to its internal representation. This can safely be ignored in your case. This would only be a problem if you had a binning that can not be represented by a polynomial of order 4 (which is not the case).

I have to close this issue now, because this is not a support forum.

Best, Oliver