Jpp  15.0.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Public Attributes | List of all members
JMARKOV::J3DhistGenerator Class Reference

Implementation of the JGenerator interface. More...

#include <JMarkovGenerator.hh>

Inheritance diagram for JMARKOV::J3DhistGenerator:
JMARKOV::JGenerator

Public Member Functions

 J3DhistGenerator (TH3 *_h)
 Constructor. More...
 
 ~J3DhistGenerator ()
 
JPosition3D getPosition ()
 Return a randomly generated position. More...
 
double getWeight (JPosition3D pos)
 return the weight (=probability density dP/dV) for the given position. More...
 

Public Attributes

TH3 * h
 

Detailed Description

Implementation of the JGenerator interface.

Generates positions uniformly by sampling from a histogram that represents the x,y,z distribution

Definition at line 656 of file JMarkovGenerator.hh.

Constructor & Destructor Documentation

JMARKOV::J3DhistGenerator::J3DhistGenerator ( TH3 *  _h)
inline

Constructor.

The histogram is cloned and automatically normalized.

Note: empty bins should always be avoided!

Definition at line 665 of file JMarkovGenerator.hh.

665  {
666  // copy histogram
667  h = (TH3*) _h->Clone( _h->GetName() ) ;
668  // normalize histogram
669  h->Scale( 1.0/h->Integral("width") ) ;
670  }
JMARKOV::J3DhistGenerator::~J3DhistGenerator ( )
inline

Definition at line 672 of file JMarkovGenerator.hh.

672  {
673  delete h ;
674  }

Member Function Documentation

JPosition3D JMARKOV::J3DhistGenerator::getPosition ( )
inlinevirtual

Return a randomly generated position.

Implements JMARKOV::JGenerator.

Definition at line 676 of file JMarkovGenerator.hh.

676  {
677  double x, y, z ;
678  h->GetRandom3(x,y,z) ;
679  return JPosition3D(x,y,z) ;
680  }
Data structure for position in three dimensions.
Definition: JPosition3D.hh:36
double JMARKOV::J3DhistGenerator::getWeight ( JPosition3D  pos)
inlinevirtual

return the weight (=probability density dP/dV) for the given position.

When the generator is properly normalized, the integral of this quantity over the whole space is 1.

Implements JMARKOV::JGenerator.

Definition at line 682 of file JMarkovGenerator.hh.

682  {
683  // return 0 outside histogram range
684  if( pos.getX()<h->GetXaxis()->GetXmin() || pos.getX()>=h->GetXaxis()->GetXmax() ) return 0.0 ;
685  if( pos.getY()<h->GetYaxis()->GetXmin() || pos.getY()>=h->GetYaxis()->GetXmax() ) return 0.0 ;
686  if( pos.getZ()<h->GetZaxis()->GetXmin() || pos.getZ()>=h->GetZaxis()->GetXmax() ) return 0.0 ;
687  // return weight
688  Int_t bin = h->FindBin( pos.getX(), pos.getY(), pos.getZ() ) ;
689  return h->GetBinContent(bin) ;
690  }
double getY() const
Get y position.
Definition: JVector3D.hh:104
double getX() const
Get x position.
Definition: JVector3D.hh:94
double getZ() const
Get z position.
Definition: JVector3D.hh:115

Member Data Documentation

TH3* JMARKOV::J3DhistGenerator::h

Definition at line 692 of file JMarkovGenerator.hh.


The documentation for this class was generated from the following file: