Error linking to CLHEP lib "header declared but not def

Hello,

I have created the little program pasted at the bottom to test that I understand how to use the gaussian random number generator included in CLHEP.

I include the libraries like this
root [22] .include /home/walaron/CLHEP_1.9.2.2/include

But then I get the following error:

root [23] .x gausSpreadTest.C
Error: RanluxEngine() header declared but not defined gausSpreadTest.C:9:
*** Interpreter error recovered ***

HELP!!! What am I doing wrong?

Thanks,

Kenny


{

#include “/home/walaron/CLHEP_1.9.2.2/include/CLHEP/Random/RandGauss.h”
#include “/home/walaron/CLHEP_1.9.2.2/include/CLHEP/Random/RanluxEngine.h”

long seed = 123456789;// would be better to read from an option file so you dont have
//to recompile every time you want to change it for a different run.
RanluxEngine randomEngine(seed,4); //Only call once at the start of code to initialise
double mean1 = 0.1;
double stdDev1 = 0.03;
double mean2 = 0.6;
double stdDev2 = 0.01;

TH1F h(“h”,“h”,100,0,1);

TH1F h2(“h2”,“h2”,100,0,1);

for(int i=0;i<10000;i++) {
double randNum1 = CLHEP::RandGauss::shoot(&randomEngine,mean1,stdDev1);
double randNum2 = CLHEP::RandGauss::shoot(&randomEngine,mean2,stdDev2);

h.Fill(randNum1);
h2.Fill(randNum1);

//do stuff with randNum1 and randNum2…
}

It looks to me that you are missing the CINT dictionary for CLHEP. You should run in compile mode with ACLIC.

But, any special reason you need the generator from CLHEP ?
I remind you now in ROOT we included also RunLux (TRandom1) and some
main generators from GSL in libMathMore, see:

seal.web.cern.ch/seal/MathLibs/5 … andom.html

Best Regards,

Lorenzo

Thanks,

So there exists fuctionality that I can almost directly copy the code I posted with new equivalent functions for the shoot method I would use in CLHEP?

Cheers,

Kenny

Using the Ranlux engine in ROOT (TRandom1) you would need to do :

{
#include "TRandom1.h" 


long seed = 123456789;// would be better to read from an option file so you dont have 
//to recompile every time you want to change it for a different run. 
TRandom1 randomEngine(seed,4); //Only call once at the start of code to initialise 
double mean1 = 0.1; 
double stdDev1 = 0.03; 
double mean2 = 0.6; 
double stdDev2 = 0.01; 

TH1F h("h","h",100,0,1); 

TH1F h2("h2","h2",100,0,1); 



for(int i=0;i<10000;i++) { 

    double randNum1 = randomEngine.Gaus(mean1,stdDev1);
    double randNum2 = randomEngine.Gaus(mean2,stdDev2); 


    //do stuff with randNum1 and randNum2....... 

    h.Fill(randNum1); 
    h2.Fill(randNum2); 

}

}

[quote=“moneta”]Using the Ranlux engine in ROOT (TRandom1) you would need to do :
[/quote]

I would advice against using TRandom1; use TRandom3 instead:
root.cern.ch/phpBB2/viewtopic.php?t=3205

The thread you mentioned refer to TRandom, not TRandom1.

TRandom1 is based on the RANLUX generator of Luscher, which is the only generator with mathematically proven random properties.

The disavantage is that is much slower than TRandom3 ( approximatly a factor of 5 ).

[quote=“moneta”]The thread you mentioned refer to TRandom, not TRandom1.

TRandom1 is based on the RANLUX generator of Luscher, which is the only generator with mathematically proven random properties.

The disavantage is that is much slower than TRandom3 ( approximatly a factor of 5 ).[/quote]

You are correct. (I’m still using mostly root 4.02 which does not have TRandom1, so I didn’t know about it). Those worried about speed should consider TRandom{2,3}; just avoid TRandom.

Cheers,
Charles

see section “Improvements in the Random Numbers” in the 5.12 Release Notes at:
root.cern.ch/root/Version512.news.html

Rene

[quote=“brun”]see section “Improvements in the Random Numbers” in the 5.12 Release Notes at:
root.cern.ch/root/Version512.news.html
[/quote]

What version of root changed gRandom from TRandom to TRandom3?

Thanks,
Charles

As indicated in the Version512 Release Notes. See also Development notes

root.cern.ch/root/html/examples/V5.12.txt.html

[code]2006-05-04 15:03 brun

* base/src/TROOT.cxx:
In the TROOT constructor, the default random number generator (gRandom)
is set to TRandom3 instead of TRandom.[/code]

Rene