CLHEP issueshttps://gitlab.cern.ch/CLHEP/CLHEP/-/issues2023-08-23T20:44:58+02:00https://gitlab.cern.ch/CLHEP/CLHEP/-/issues/4Make HepRandomEngine std conformant (improvement)2023-08-23T20:44:58+02:00Vincenzo InnocenteMake HepRandomEngine std conformant (improvement)I suggest to make HepRandomEngine interface conformant to std::random.
as example I coded this simple wrapper
```
#include <cstdint>
#include <limits>
#include <cstring>
#include "CLHEP/Random/RandomEngine.h"
// a wrapper to make a He...I suggest to make HepRandomEngine interface conformant to std::random.
as example I coded this simple wrapper
```
#include <cstdint>
#include <limits>
#include <cstring>
#include "CLHEP/Random/RandomEngine.h"
// a wrapper to make a HepRandomEngine std conformant
class CLHEP2STDRandom {
public:
using result_type = uint64_t;
CLHEP2STDRandom(CLHEP::HepRandomEngine & engine) : m_engine(engine) {}
// MixMax is limited to 61 bits (and will reimplement operator() to return getNext() )
static constexpr result_type u61 = std::numeric_limits<result_type>::max() >> (64-61);
// to be overridden by those who generate uint64_t natively...
virtual result_type operator()() {
uint64_t u1 = uint32_t(*this);
uint64_t u2 = uint32_t(*this);;
u1 <<=32;
return u1 | u2;
}
static constexpr result_type min() { return 0; } // actually 1??
static constexpr result_type max() { return u61; }
private:
CLHEP::HepRandomEngine & m_engine;
};
```
There are of course two limitations:
1) It assumes all CLHEP generators to have at least 53 bits of "entropy"
2) Cannot "export" more than 53 bits with the current interface of HepRandomEngine
Lifting these limitations making all CLHEP generators able to provide a guaranteed number of random bits larger than 53 would be of course ideal.https://gitlab.cern.ch/CLHEP/CLHEP/-/issues/1problem with linking clhep-libraries with g++2018-01-24T19:57:53+01:00Mathias Wagnerproblem with linking clhep-libraries with g++**Operating system:**
CentOS Linux release 7.4.1708 (Core)
**Problem description:**
I experienced a problem with ``clhep-config --libs`` and ``clhep-config --include``. I wrote a very simple test example of a c++-code that basically do...**Operating system:**
CentOS Linux release 7.4.1708 (Core)
**Problem description:**
I experienced a problem with ``clhep-config --libs`` and ``clhep-config --include``. I wrote a very simple test example of a c++-code that basically does nothing. When I wanted to compile the code with loading the clhep-libraries (still without using any of its functionality in the code), I got the following error message:
Input: `g++ -std=c++11 $(clhep-config --libs) -o test.exe test.cc`
Error: `/usr/bin/ld: cannot find -lCLHEP-2.4.0.1
collect2: error: ld returned 1 exit status`
**Finding the solution:**
When I look at the output of `clhep-config --libs` yielding `-L"/localhome/wagner/Tools/clhep/install/lib" -lCLHEP-2.4.0.1`, and insert this instead everything works:
Input: `g++ -std=c++11 -L"/localhome/wagner/Tools/clhep/install/lib" -lCLHEP-2.4.0.1 -o test.exe test.cc`
When looking at both expressions with `echo`, the difference is that the quotation marks (") in the first case are still present, while they are gone in the second version.
**Working solution:**
Open the ``clhep-config`` file and go to the line
`` --libs)
echo -L\"${libdir}\" -lCLHEP-2.4.0.1 ``
And remove both `\"`:
`` --libs)
echo -L${libdir} -lCLHEP-2.4.0.1 ``
**Same solution for `clhep-config --include`**
Also remove the quotation marks in line:
` --include)
echo -I\"${includedir}\"`
**Working code:**
After these changes the following line worked without errors (now also including some CLHEP-classes inside the test-code):
`g++ -std=c++11 $(clhep-config --libs) $(clhep-config --include) -o test.exe test.cc`