9 #ifndef ThePEG_ACDCSampler_H
10 #define ThePEG_ACDCSampler_H
13 #include "ThePEG/Handlers/SamplerBase.h"
14 #include "ThePEG/ACDC/ACDCGen.h"
15 #include "ThePEG/Handlers/StandardEventHandler.h"
16 #include "ThePEG/Repository/RandomGenerator.h"
17 #include "ThePEG/Repository/UseRandom.h"
18 #include "ThePEG/Utilities/SimplePhaseSpace.xh"
203 struct ACDCStillCompensating:
public Exception {};
207 struct EventInitNoXSec:
public InitException {};
212 struct EventLoopException:
public Exception {};
240 struct BaseClassTrait<ACDCSampler,1>:
public ClassTraitsType {
250 struct ClassTraits<ACDCSampler>:
public ClassTraitsBase<ACDCSampler> {
254 static string className() {
return "ThePEG::ACDCSampler"; }
259 static string library() {
return "ACDCSampler.so"; }
275 struct ACDCFncTraits<
ThePEG::tStdEHPtr>:
public ACDCTraitsType {
277 typedef ThePEG::tStdEHPtr tStdEHPtr;
282 static inline double value(
const tStdEHPtr & eh,
const DVector & x) {
285 return eh->dSigDR(x)/nanobarn;
287 catch ( ThePEG::ImpossibleKinematics & v ) {
290 catch ( std::exception & e ) {
304 struct ACDCRandomTraits<
ThePEG::UseRandom>:
public ACDCTraitsType {
311 static inline double rnd(UseRandom *) {
return UseRandom::rnd(); }
316 static inline double rnd(UseRandom * r,
double xl,
double xu) {
317 return xl + (xu - xl)*rnd(r);
331 template <
typename InputIterator,
typename OutputIterator>
332 static inline void rnd(UseRandom * r,
333 InputIterator l, InputIterator lend,
334 InputIterator u, OutputIterator res) {
335 for ( ; l != lend; ++l ) *res++ = *l + (*u++ - *l)*rnd(r);
342 template <
typename OutputIterator>
343 static inline void rnd(UseRandom * r,
int D, OutputIterator res) {
344 for (
int d = 0;
d < D; ++
d ) *res++ = rnd(r);
350 static inline bool rndBool(UseRandom,
double x) {
351 return UseRandom::rndbool(x);
357 static inline bool rndBool(UseRandom *,
double x,
double y) {
358 return UseRandom::rndbool(x, y);
364 static inline long rndInt(UseRandom *,
long x) {
365 return UseRandom::irnd(x);
PersistentIStream is used to read persistent objects from a stream where they were previously written...
double theMargin
The factor controlling the loss of efficiency when compensating.
virtual ~ACDCSampler()
The destructor.
int theNTry
The number of points to use to find initial average.
A concreate implementation of ClassDescriptionBase describing a concrete class with persistent data...
PersistentOStream is used to write objects persistently to a stream from which they can be read in ag...
This UseRandom class keeps a static stack of RandomGenerator objects which can be used anywhere by an...
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
virtual CrossSection maxXSec() const
Return the overestimated integrated cross section.
This is the main namespace within which all identifiers in ThePEG are declared.
ACDCSampler(const ACDCSampler &x)
The copy constructor.
SamplerType theSampler
The actual sampler object.
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
ACDCSampler & operator=(const ACDCSampler &)
Private and non-existent assignment operator.
virtual void dofinish()
Finalize this object.
virtual IBPtr fullclone() const
Make a clone of this object, possibly modifying the cloned object to make it sane.
ACDCGenerator::ACDCGen< UseRandom, tStdEHPtr > SamplerType
Typedef the underlying ACDCGen class.
static string library()
The name of a file containing the dynamic library where the class T is implemented.
This is the base class for all phase space sampler classes to be used by the EventHandler class to sa...
RCPtr is a reference counted (smart) pointer.
virtual void rejectLast()
Reject the last chosen phase space point.
virtual CrossSection integratedXSec() const
Return the total integrated cross section determined from the Monte Carlo sampling so far...
Exception is the base class for all exceptions to be used in ThePEG.
static void Init()
The standard Init function used to initialize the interfaces.
virtual int lastBin() const
ACDCSampler is able to sample several different functions separately.
static ClassDescription< ACDCSampler > initACDCSampler
Describe a concrete class with persistent data.
virtual void initialize()
Initialize the the sampler, possibly doing presampling of the phase space.
virtual double generate()
Generarate a new phase space point and return a weight associated with it.
vector< double > DVector
A vector of doubles.
static string className()
Return the name of class T.
This template class allows the compiler to check calculations with physical quantities for dimensiona...
double theEps
The smallest possible division allowed.
int NthBase
The type of the BaseN'th base class (int means there are no further base classes).
virtual CrossSection integratedXSecErr() const
Return the error on the total integrated cross section determined from the Monte Carlo sampling so fa...
virtual IBPtr clone() const
Make a simple clone of this object.
ACDCSampler()
The default constructor.
static double value(const FncPtr &f, const DVector &x)
Call a function to be sampled by ACDCGen.
virtual void doinitrun()
Initialize this object.
The Units namespace contains the declaration of a number of classes for variables with dimension...
The namespace in which all ACDCGen classes are defined.
This class inherits from SampleBase and implements the Auto Compensating Divide-and-Conquer phase spa...
virtual double sumWeights() const
Return the sum of the weights returned by generate() so far (of the events that were not rejeted)...