Changeset 19639 for trunk/Mars/mbase


Ignore:
Timestamp:
09/15/19 14:23:22 (5 years ago)
Author:
tbretz
Message:
Added a random function to simulate a gaussian shape with long tails which do not extend over pi/2
Location:
trunk/Mars/mbase
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/mbase/MMath.cc

    r17161 r19639  
    901901}
    902902
     903// --------------------------------------------------------------------------
     904//
     905// Returns an exponential distribution
     906//
     907// -tau*log(x)  with x=[0;1[ and y=[0;1[
     908//
    903909Double_t MMath::RndmExp(Double_t tau)
    904910{
    905     // returns an exponential deviate.
    906     //
    907     //          exp( -t/tau )
    908 
    909911    const Double_t x = gRandom->Rndm(); // uniform on ] 0, 1 ]
    910912
    911913    return -tau * TMath::Log(x);       // convert to exponential distribution
    912914}
     915
     916// --------------------------------------------------------------------------
     917//
     918// Returns a distribution according to
     919//
     920//  atanh((y+1)/x*sigma) with x and y [-1;1] and x^2+y^2=1
     921//
     922Double_t MMath::RndmPSF(Double_t sigma)
     923{
     924    double x, y;
     925    gRandom->Circle(x, y, 1);
     926    return TMath::ATanH((y+1)/x*sigma);
     927}
  • trunk/Mars/mbase/MMath.h

    r17161 r19639  
    9191
    9292    Double_t RndmExp(Double_t tau);
     93    Double_t RndmPSF(Double_t sigma=1);
    9394}
    9495
Note: See TracChangeset for help on using the changeset viewer.