TMinuit: Minimizing Integer Parameters (Look Up Table Indices)

ROOT Version: 6.24
Platform: Linux
Compiler: Unsure

I am trying to use TMinuit to fit data to a model that I already pre-calculated using a lookup table. I start off by reading my lookup table to a five dimensional array, where three of the indices are parameters that I want to fit and the other two are used to give data points for the fitting.

I tried reproducing the code here: https ://root.cern/doc/v610/Ifit_8C_source .html (It would not let me post a link because I am a new user), but replaced the func Function with a call to my five dimensional array. I tried changing the parameter types to integers in all cases that they are mentioned in the code, but it would not work and gave me this error:

error: cannot initialize a parameter of type 'void (*)(Int_t &, Double_t *, Double_t &, Double_t *, Int_t)' (aka 'void (*)(int &, double *, double &, double *, int)') with an lvalue of type 'void (Int_t &, Double_t *, Double_t &, Int_t *, Int_t)' (aka 'void (int &, double *, double &, int *, int)'): type mismatch at 4th parameter ('Double_t *' (aka 'double *') vs 'Int_t *' (aka 'int *'))

This is clearly because the function only allows for doubles and not integers

I then tried to just make them doubles, and as expected it crashed root, giving me the following error message:

===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00007fb90df05c3a in __GI___wait4 (pid=746446, stat_loc=stat_loc
entry=0x7ffcf1240de8, options=options
entry=0, usage=usage
entry=0x0) at ../sysdeps/unix/sysv/linux/wait4.c:27
#1  0x00007fb90df05bfb in __GI___waitpid (pid=<optimized out>, stat_loc=stat_loc
entry=0x7ffcf1240de8, options=options
entry=0) at waitpid.c:38
#2  0x00007fb90de74f67 in do_system (line=<optimized out>) at ../sysdeps/posix/system.c:172
#3  0x00007fb90e56116e in TUnixSystem::StackTrace() () from /home/belzer/root/lib/libCore.so.6.24
#4  0x00007fb90e55dfe5 in TUnixSystem::DispatchSignals(ESignals) () from /home/belzer/root/lib/libCore.so.6.24
#5  <signal handler called>
#6  0x00007fb90e212cc0 in ?? ()
#7  0x00000000f12439f0 in ?? ()
#8  0x0000000300000000 in ?? ()
#9  0x00007fb90dbf83f3 in ?? ()
#10 0x0000000000000002 in ?? ()
#11 0x00000000000007ff in ?? ()
#12 0x00007ffcf12439f0 in ?? ()
#13 0x00007fb8f5fe0898 in ?? () from /home/REDACTED/root/lib/libMinuit.so.6.24.02
#14 0x00007ffcf1243bc0 in ?? ()
#15 0x00007fb90dbf83f3 in ?? ()
#16 0x00007fb90deaef9a in __vsnprintf_internal (string=0x7ffcf1243a30 "\220<$\361\374\177", maxlen=<optimized out>, format=0x7 <error: Cannot access memory at address 0x7>, args=0x7fb8f5fe1c3f, mode_flags=2114700544) at vsnprintf.c:114
#17 0x0000000000000000 in ?? ()
===========================================================


The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum https://root.cern.ch/forum
Only if you are really convinced it is a bug in ROOT then please submit a
report at https://root.cern.ch/bugs Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#6  0x00007fb90e212cc0 in ?? ()
#7  0x00000000f12439f0 in ?? ()
#8  0x0000000300000000 in ?? ()
#9  0x00007fb90dbf83f3 in ?? ()
#10 0x0000000000000002 in ?? ()
#11 0x00000000000007ff in ?? ()
#12 0x00007ffcf12439f0 in ?? ()
#13 0x00007fb8f5fe0898 in ?? () from /home/REDACTED/root/lib/libMinuit.so.6.24.02
#14 0x00007ffcf1243bc0 in ?? ()
#15 0x00007fb90dbf83f3 in ?? ()
#16 0x00007fb90deaef9a in __vsnprintf_internal (string=0x7ffcf1243a30 "220<$361374177", maxlen=<optimized out>, format=0x7 <error: Cannot access memory at address 0x7>, args=0x7fb8f5fe1c3f, mode_flags=2114700544) at vsnprintf.c:114
#17 0x0000000000000000 in ?? ()
===========================================================

I think it is giving me an error because a double is going into an index.

Any help on how I can use Minuit to minimize integers would be greatly appreciated. I would prefer to not have to calculate the entire function each time as it is very computationally expensive to do so.

Welcome to the ROOT Forum! Maybe @moneta can take a look

1 Like

Have a look at this

1 Like

Thank you! I was able to get it working by making the values that I wanted to minimize doubles and then rewriting them to a new int variable using the round() function.

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