Vindaar / TimepixAnalysis

Contains code related to calibration and analysis of Timepix based detector + CAST related code
MIT License
19 stars 6 forks source link

CDL cuts should not be hardcoded #46

Open Vindaar opened 3 years ago

Vindaar commented 3 years ago

Originally it seemed like a decent idea to hardcode the cuts used for the CDL to generate the reference spectra. Certainly for the 2014/15 case, because those cannot change anymore. They are just a fixed reference.

Given how different fits can change these values easily however, it seems ridiculous and is a lot of work to update those values always an changes to the fits.

New cuts are generated by running the cdl_spectrum_creation tool on a fully reconstructed H5 file of the CDL datasets, as for example:

cdl_spectrum_creation CDL_2019_reco.h5 --dumpAccurate

which will generate a fitparameters_accurate_<timestamp>.txt file, such as: https://github.com/Vindaar/TimepixAnalysis/blob/master/resources/archive/fitparams_accurate_1600446157.txt

From here one has to pick the main peaks of the charge fits (those with highest amplitude essentially) and take the mean gmu and sigma gs. Those can be inserted here: https://github.com/Vindaar/TimepixAnalysis/blob/master/Analysis/ingrid/private/cdl_cuts.nim#L122-L149 for each of the target + filter combinations. Note that the energy ranges are from lowest to highest (index 0 is C with 0.6 kV, 7 is Ni with 15 kV).

The code automatically calculates the the correct minimum and maximum value for the cut. However, instead of hardcoding the fit results, this should be done in a more flexible way!

Think about it! There is a mini script here:

https://github.com/Vindaar/TimepixAnalysis/blob/master/Tools/calcCdlCutsFromFitParams.nim

which calculates those values also based on a given fit parameter text file.

We could maybe add something to our config.toml file - an option to hand a path to a good fit parameter file and then read that at run time. The "currently correct file" could be stored in some place in the repository maybe.