I used my code to calculate a value. (in main sub procedure)
cout<<LD(Ex-Eg)<<endl; // result is 2
cout<<F(Eg)<<endl; // result is 63.729
cout<<LD(Ex-Eg)*F(Eg)<<endl; //result must be 127.4 but my root give me value: 6.27e-322;
What wrong with my program? I used root 5.34/32 on window 7 64 bit.
I would advise to always use ACLiC anyway for several reasons: The compiler checks the validity of the code, it solves several limitations of the interpreter, it may prevent this kind of error, and it runs faster…
This is indeed a shocking serious bug in CINT (i.e. in ROOT 5).
Sometimes, the statement “if (E-Umin<=0) return 2;”, in the “double LD(double E)” function, instead of returning a “double precision” 2.0, returns an “integer” value 2 (or some another trash value).
In your case, you can overcome this bug using: [code]#include
double C = 1.e-2;
double LD(double E)
{
double a = 17.;
double Umin = 9. / (4. * a);
double U = E - Umin;
if (U > 0.0) return C * std::pow(U, -3./2.) * std::exp(2. * std::sqrt(a * U));
return 2.0;
}
double F(double E)
{
if (E > 0.0) return C * std::pow(E, 4.2);
return 0.0;
}[/code]
It is a terrible bug, but we don’t have the resources to keep both ROOT 6 and ROOT 5 properly maintained. For our Windows users that is extremely painful - but the right reaction is to accelerate the porting of ROOT 6, and that’s what we do.
Thank you very much for your answer. I used window therefore I cannot update to ROOT 6 at this moment.
I try to compile my code with ACLiC as Bellenot proposed. (.L oslo.C+) but I get error:
[quote]Info in TWinNTSystem::ACLiC: creating shared library D:\OneDrive\Espace de travail\00 - Duy Tan 2017\oslo method\oslo-
test\oslo_C.dll
’cl.exe’ is not recognized as an internal or external command,
operable program or batch file.
Error: external preprocessing failed. (0)
!!!Removing D:\OneDrive\Espace de travail\00 - Duy Tan 2017\oslo method\oslo-test\oslo_C_ACLiC_dict.cxx D:\OneDrive\Espa
ce de travail\00 - Duy Tan 2017\oslo method\oslo-test\oslo_C_ACLiC_dict.h !!!
Error: C:\root_v5.34.32\bin\rootcint: error loading headers…
Error in : Dictionary generation failed!
Info in : Invoking compiler to check macro’s validity[/quote]
Could you please show me how to solve my problem. I install root from installation file that I download on Root website.
Do you have Visual Studio installed on your machine? You need it to use ACLiC (to compile your code). If not, you have two options: Install it (the same version that the one used to build ROOT), or fix your code as Pepe Le Pew proposed.
Can I used VC13 instead of VC12 which is the same version as the one used to build root?
I found this information:
execute, prior to running root, the vsvars32.bat command (for visual studio)
But the last time, I only have VC15, therefore I can not find vsvars32.bat as the guide said. Now I’m trying with VC13. it is possible ? or I need to download exactly VC12?
You need exactly Visual Studio 2012 or Visual Studio 2013 (corresponding to vc11/vc12) and you cannot mix versions, meaning you can take any of those, but then use ROOT built with the exact same version…
[quote=“ngocanh8999”]I installed Visual Studio 13.
and root installer is: root_v5.34.32.win32.vc12.exe
Therefore, what I use is correct, right?[/quote]
If you mean “Visual Studio 2013”, then yes
BTW, why not the latest version (root_v5.34.36.win32.vc12.exe)?
I can compile using ACLiC now, but there is a lot of errors. It seems that code run with interpreter must be changed a lot to compile with ACLiC, right?
[quote]D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(13) : error C2065: ‘Emin’ : undeclared identifier
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(14) : error C2065: ‘Emax’ : undeclared identifier
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(15) : error C2065: ‘TH1D’ : undeclared identifier
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(15) : error C2065: ‘I_exp’ : undeclared identifier
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(15) : error C2061: syntax error : identifier ‘TH1D’
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(29) : error C2065: ‘I_exp’ : undeclared identifier
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(29) : error C2227: left of ‘->SetBinContent’ must point to cla
ss/struct/union/generic type
type is ‘unknown-type’
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(29) : error C2227: left of ‘->GetXaxis’ must point to class/st
ruct/union/generic type
type is ‘unknown-type’
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(29) : error C2227: left of ‘->FindBin’ must point to class/str
uct/union/generic type
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(29) : error C2227: left of ‘->GetBinContent’ must point to cla
ss/struct/union/generic type
type is ‘unknown-type’
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(30) : error C2065: ‘I_exp’ : undeclared identifier
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(30) : error C2227: left of ‘->SetBinError’ must point to class
/struct/union/generic type
type is ‘unknown-type’
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(30) : error C2227: left of ‘->GetXaxis’ must point to class/st
ruct/union/generic type
type is ‘unknown-type’
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(30) : error C2227: left of ‘->FindBin’ must point to class/str
uct/union/generic type
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(30) : error C2227: left of ‘->GetBinError’ must point to class
/struct/union/generic type
type is ‘unknown-type’
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(33) : error C2065: ‘I_exp’ : undeclared identifier
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(33) : error C2227: left of ‘->Draw’ must point to class/struct
/union/generic type
type is ‘unknown-type’
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(34) : error C2065: ‘I_exp’ : undeclared identifier
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(34) : error C2227: left of ‘->Draw’ must point to class/struct
/union/generic type
type is ‘unknown-type’
Error in : Compilation failed![/quote]
[quote=“bellenot”][quote=“ngocanh8999”]I installed Visual Studio 13.
and root installer is: root_v5.34.32.win32.vc12.exe
Therefore, what I use is correct, right?[/quote]
If you mean “Visual Studio 2013”, then yes
BTW, why not the latest version (root_v5.34.36.win32.vc12.exe)?[/quote]
For your question, I tried the newest root v5 few years ago, but it has a lot of crashes on my computer that I cannot understand, while everything work well with my current root version, therefor I still use it even it is not the newest version.
You can add the relevant environment variables to your system, see e.g. java.com/en/download/help/path.xml for how to do it. The relevant variables are at least PATH, INCLUDE and LIB. You can get the values by starting a Visual Studio command prompt and echoing their values.
Yes ROOT can fit a function of 100 parameters just fine. I have rarely ever seen a good case for this, though. And initializing the parameters is a work of art. I.e. are you really sure this is what you need?
root [4] .L igg.C+
Info in TWinNTSystem::ACLiC: creating shared library D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg_C.dll
2746433_cint.cxx
igg_C_ACLiC_dict.cxx
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(105) : error C2664: ‘Double_t fRSF(Double_t *,Double_t *)’ : c
annot convert argument 1 from ‘Double_t’ to ‘Double_t *’
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(105) : error C2664: ‘Double_t fLD(Double_t *,Double_t *)’ : ca
nnot convert argument 1 from ‘Double_t’ to ‘Double_t *’
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(111) : error C2664: ‘Double_t fRSF(Double_t *,Double_t *)’ : c
annot convert argument 1 from ‘Double_t’ to ‘Double_t *’
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(111) : error C2664: ‘Double_t fLD(Double_t *,Double_t *)’ : ca
nnot convert argument 1 from ‘Double_t’ to ‘Double_t *’
D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg\igg.C(112) : error C2664: ‘Double_t fLD(Double_t *,Double_t *)’ : ca
nnot convert argument 1 from ‘Double_t’ to ‘Double_t *’
Error in : Compilation failed!
I always do like this when I tried to fit with custom function, but this time, this errors happens.
Could you please propose me a solution to fix it? I don’t understand. My idea is to convert LD histogram to fLD, where as if x in the range of bin i, the value of fLD function will be Bin Content i of LD histogram. My way is to put LD bin content (i) to parameter(i) of the fLD.