Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
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.
 
 ~J3DhistGenerator ()
 
JPosition3D getPosition ()
 Return a randomly generated position.
 
double getWeight (JPosition3D pos)
 return the weight (=probability density dP/dV) for the given position.
 

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 672 of file JMarkovGenerator.hh.

Constructor & Destructor Documentation

◆ J3DhistGenerator()

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

Constructor.

The histogram is cloned and automatically normalized.

Note: empty bins should always be avoided!

Definition at line 681 of file JMarkovGenerator.hh.

681 {
682 // copy histogram
683 h = (TH3*) _h->Clone( _h->GetName() ) ;
684 // normalize histogram
685 h->Scale( 1.0/h->Integral("width") ) ;
686 }

◆ ~J3DhistGenerator()

JMARKOV::J3DhistGenerator::~J3DhistGenerator ( )
inline

Definition at line 688 of file JMarkovGenerator.hh.

688 {
689 delete h ;
690 }

Member Function Documentation

◆ getPosition()

JPosition3D JMARKOV::J3DhistGenerator::getPosition ( )
inlinevirtual

Return a randomly generated position.

Implements JMARKOV::JGenerator.

Definition at line 692 of file JMarkovGenerator.hh.

692 {
693 double x, y, z ;
694 h->GetRandom3(x,y,z) ;
695 return JPosition3D(x,y,z) ;
696 }

◆ getWeight()

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 698 of file JMarkovGenerator.hh.

698 {
699 // return 0 outside histogram range
700 if( pos.getX()<h->GetXaxis()->GetXmin() || pos.getX()>=h->GetXaxis()->GetXmax() ) return 0.0 ;
701 if( pos.getY()<h->GetYaxis()->GetXmin() || pos.getY()>=h->GetYaxis()->GetXmax() ) return 0.0 ;
702 if( pos.getZ()<h->GetZaxis()->GetXmin() || pos.getZ()>=h->GetZaxis()->GetXmax() ) return 0.0 ;
703 // return weight
704 Int_t bin = h->FindBin( pos.getX(), pos.getY(), pos.getZ() ) ;
705 return h->GetBinContent(bin) ;
706 }

Member Data Documentation

◆ h

TH3* JMARKOV::J3DhistGenerator::h

Definition at line 708 of file JMarkovGenerator.hh.


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