I am not the GUI expert and @bellenot can surely help you better than me. I see you are on windows and therefore using ROOT 5. But I tried anyway to run your program using ROOT 6 on Mac and I get the following errors. Some seems to be real C++ mistakes:
root [0]
Processing peakprogram.C...
In file included from input_line_10:1:
/Users/couet/Downloads/peakprogram.C:118:24: error: cannot initialize a parameter of type 'EButtonState' with an rvalue of type
'int'
bt_tscfit->SetState(1);
^
/Users/couet/git/roottrunk-bin/include/TGButton.h:315:41: note: passing argument to parameter 'state' here
virtual void SetState(EButtonState state, Bool_t emit = kFALSE);
^
In file included from input_line_10:1:
/Users/couet/Downloads/peakprogram.C:225:9: error: use of undeclared identifier 'loadspe'
hspe = loadspe(bt_spe_name->GetText());
^
/Users/couet/Downloads/peakprogram.C:226:16: error: assigning to 'TH1F *' from incompatible type 'TObject *'
hspe1 = hspe->Clone();
~~~~~~^~~~~~~
/Users/couet/Downloads/peakprogram.C:257:15: error: assigning to 'TH1F *' from incompatible type 'TObject *'
hfit = hspe->Clone();
~~~~~~^~~~~~~
/Users/couet/Downloads/peakprogram.C:327:19: error: out-of-line definition of 'DoFit' does not match any declaration in
'MyMainFrame'
void MyMainFrame::DoFit()
^~~~~
/Users/couet/Downloads/peakprogram.C:391:15: error: assigning to 'Double_t *' (aka 'double *') from incompatible type
'const Double_t *' (aka 'const double *')
upar = ffit->GetParErrors();
~~~~~~^~~~~~~~~~~~~~
/Users/couet/Downloads/peakprogram.C:394:48: warning: format specifies type 'int' but the argument has type 'Double_t' (aka 'double')
[-Wformat]
printf("Fitting Range: %i *********** %i \n",bt_left2->GetNumber(),bt_r...
~~ ^~~~~~~~~~~~~~~~~~~~~
%f
/Users/couet/Downloads/peakprogram.C:394:70: warning: format specifies type 'int' but the argument has type 'Double_t' (aka 'double')
[-Wformat]
...%i *********** %i \n",bt_left2->GetNumber(),bt_right2->GetNumber());
~~ ^~~~~~~~~~~~~~~~~~~~~~
%f
/Users/couet/Downloads/peakprogram.C:417:22: error: cannot initialize a parameter of type 'EButtonState' with an rvalue of type
'int'
bt_tscfit->SetState(0);
^
/Users/couet/git/roottrunk-bin/include/TGButton.h:315:41: note: passing argument to parameter 'state' here
virtual void SetState(EButtonState state, Bool_t emit = kFALSE);
^
In file included from input_line_10:1:
/Users/couet/Downloads/peakprogram.C:418:37: error: cannot initialize a parameter of type 'EButtonState' with an rvalue of type
'int'
if (s1=="tsc") bt_tscfit->SetState(1);
^
/Users/couet/git/roottrunk-bin/include/TGButton.h:315:41: note: passing argument to parameter 'state' here
virtual void SetState(EButtonState state, Bool_t emit = kFALSE);
^
root [1]
I run this program on Root 5 without any errors or warning. The errors that you get may come from the different between Root versions. Sometime ROOT updates the type of function’s arguments, then it create errors.
For example, I use Search in TSpectrum with double_t as argument, it works well on ROOT 6, but not in ROOT 5, because we need to use float_t in ROOT 5.
Yes I know. ROOT 5 less strict than ROOT 6 regarding C++. I would suggest you run your macro (with ROOT 5) using AClic. Adding a “+” after the “C” when you run the macro:
root > .x peakprogram.C+
You will then benefit from a true C++ compiler and see possible C++ errors in your code.
Ops, a lot of errors when I try to run with AClic.
root [0] .x peakprogram.C+
Info in <TWinNTSystem::ACLiC>: creating shared library D:\Dropbox\BUREAU\00 - n2g\Peak_Area\peakprog
ram_C.dll
2839646_cint.cxx
Error: Symbol TGTextEntry is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\peak
program.C(29)
Error: Symbol bt_spe_name is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\peak
program.C(29)
Error: Symbol TGNumberEntry is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\pe
akprogram.C(31)
Error: Symbol bt_left is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\peakprog
ram.C(31)
Error: Symbol TGNumberEntry is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\pe
akprogram.C(32)
Error: Symbol bt_right is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\peakpro
gram.C(32)
Error: Symbol TGNumberEntry is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\pe
akprogram.C(33)
Error: Symbol bt_left2 is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\peakpro
gram.C(33)
Error: Symbol TGNumberEntry is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\pe
akprogram.C(34)
Error: Symbol bt_right2 is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\peakpr
ogram.C(34)
Error: Symbol TGTextEntry is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\peak
program.C(39)
Error: Symbol bt_peak_pos is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\peak
program.C(39)
Error: Symbol TGTextEntry is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\peak
program.C(40)
Error: Symbol bt_sig_par is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\peakp
rogram.C(40)
Error: Symbol TGNumberEntry is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\pe
akprogram.C(41)
Error: Symbol bt_Esum is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\peakprog
ram.C(41)
Error: Symbol TGNumberEntry is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\pe
akprogram.C(42)
Error: Symbol bt_bkg_deg is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\peakp
rogram.C(42)
Error: Symbol TGNumberEntry is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\pe
akprogram.C(43)
Error: Symbol bt_ini_sig is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\peakp
rogram.C(43)
Error: Symbol TGTextEntry is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\peak
program.C(44)
Error: Symbol bt_roi_name is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\peak
program.C(44)
Error: Symbol TGLabel is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\peakprog
ram.C(48)
Error: Symbol coordinate is not defined in current scope D:\Dropbox\BUREAU\00 - n2g\Peak_Area\peakp
rogram.C(48)
Warning: Error occurred during reading source files
Warning: Error occurred during dictionary source generation
!!!Removing D:\Dropbox\BUREAU\00 - n2g\Peak_Area\peakprogram_C_ACLiC_dict.cxx D:\Dropbox\BUREAU\00 -
n2g\Peak_Area\peakprogram_C_ACLiC_dict.h !!!
Error: C:\root_v5.34.32\bin\rootcint: error loading headers...
Error in <ACLiC>: Dictionary generation failed!
Info in <ACLiC>: Invoking compiler to check macro's validity
Error: Function peakprogram() is not defined in current scope (0)
*** Interpreter error recovered ***
root [1]
I did this and a lot of others errors, including: Function peakprogram() is not defined in current scope. So programming with AClic is much different from interpret ROOT.
Well, this is then another incompatibility between ROOT 5.x a 6.x.
BTW. I “fixed” obvious problems reported by the compiler only so, there may still be things which are not “kosher”. I “fixed” the “upar” problem now, too (see the modified source code in my previous post).
I fit in many ranges, so I would like that after each fit, the program pause, so I can see the fit. In order to continue, I can press any key.
For this purpose, I use system(“pause”)
if (bt_range_by_range->IsOn()) system("pause"); //Line 507.
However, the program works unstable, that means sometime it stop and update the fitting canvas, but sometimes it stop but does not update the fitting canvas.
In order to test my program, you only need to put all the above files in a folder, change “test.txt” to “test.roi” (because I can not upload .roi file), compile, and press Auto_cal button. (right side)
I tried to use the following script, and the program works better but somehow a little bit unstable. I don’t understand.
TCanvas *fCanvas = fEcanvas2->GetCanvas();
fCanvas->cd(); fCanvas->Modified(); fCanvas->Update(); gSystem->ProcessEvents();
cout<<“Press any key to continue”<<endl;
cin.get();
By the way, I would be very glad if there is a solution, in which I can zoom the histogram during the pause time. It seems that the fitting line is not well drawn. See fig1 (without zooming) and fig2 (zooming).