R3BRootGroup / R3BRoot

Framework for Simulations and Data Analysis of R3B Experiment
https://github.com/R3BRootGroup/R3BRoot/wiki
GNU General Public License v3.0
18 stars 102 forks source link

Proposal for reimplementing the TofD calibration #1075

Open klenze opened 4 weeks ago

klenze commented 4 weeks ago

Dear all, while I currently have other priorities in my life than R3BRoot, I could not help but overhear a few of my colleagues working with TofD Cal2Hit and I have a few suggestions to make.

Background: TofD is one of the detectors which is harder to calibrate than some others. While the gamma calibration of CALIFA will fit comfortably on a beer mat, the TofD calibration involves a lot of different stages. This is just a fact of life, detectors sometimes are complex and sometimes easy to calibrate.

R3BRoot code to obtain calibration parameters is -- in my experience -- not remotely as well structured as it should be.

For CALIFA, this is not a big problem because the PhD student who has to calibrate it can either figure out to run it (it is a single stage process) or just rewrite it from the scratch -- find two peaks, fit two gaussians, write a linear interpolation (been there, done that).

For TofD, there is the fine time calibration, the time offset calibration (with or without LOS), determining v_eff (to get the position from time), the ToT calibration, determining the attenuation (to get the position from ToT) and finally doing the smiley correction to get the charge calibration correct. (Or so I figure, I am not a TofD expert.) In the best case, this will require four passes and three different runs, I guess.

I suggest that the collaboration decides to rewrite the code to obtain the calibration for TofD (details below). This has the potential to halve the time a new PhD student requires to obtain a calibration.


(From my understanding, both NeuLAND and TofD use TAMEX cards and their fine time calibration is equivalent, so I am puzzled why we would have two Tasks to read them from UCESB and two Tasks apply the fine time calibration, instead of just single classes TAMEXSource and TAMEXMapped2Cal, but that is not my main point, which is the Cal2Hit.)

My proposal is the following:

As an alternative to one big piece of code generating all the histograms, suitable histograms could also be generated by various pyROOT scripts from the tree before the fitting stages where they are required instead of all at one place. Advantage: Large hist-filling classes are commonly utterly unreadable. Disadvantages: more wrapper code duplication (could be outsourced to another file, though), no access to histograms of previous stages for the run of the current stage.

Any replacement should accomplish at least the following:

CCFPED (Ceterum censeo FairParam esse delendam).

[^1]: Filling a large number of different-quantity histograms commonly messy. In place A, you declare all the pointers, in place B, you instantiate all the THxY classes in a mess of for loops and Format() macros, in place C, you actually fill data in the histograms, in place D, you write them all out to file and (optionally, for all I care) in place E, you delete them again. I once had a proof of concept code where you instantiated one wrapper class per histogram type, specifying what quantities you want to plot (via one to three variadic lambdas) and in what ranges. Some clever code would figure out over which sets of data to iterate based on the types of Data pointers used in the lambda expressions for the various axis. And you could specify based on what values stacks of histograms should be created. As all the lambdas and ranges were passed as template parameters, they could be inlined. I think I accepted the cost of one virtual call per histogram type and event and put the histogram types in a vector rather than a stack of types. [^2] Most fun I had with C++. Of course, after #771, I saw that I had irreconcilable differences with the R3BRoot maintainers and transitioned to the main DAQ.

[^2]: There would still be a cost for looping through the histograms once per histogram-type, and having to calculate quantities (such as WRTSCalifa-WRTSMain repeatedly). Of course, runtime per event is rather irrelevant, in any case. If a new PhD student has to calibrate the TofD, the computation costs are a rounding error compared to their salary.