00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "TMath.h"
00025 #include "RooFit.h"
00026
00027 #include "RooLandau.h"
00028 #include "RooLandau.h"
00029 #include "RooRandom.h"
00030
00031 ClassImp(RooLandau)
00032
00033
00034
00035 RooLandau::RooLandau(const char *name, const char *title, RooAbsReal& _x, RooAbsReal& _mean, RooAbsReal& _sigma) :
00036 RooAbsPdf(name,title),
00037 x("x","Dependent",this,_x),
00038 mean("mean","Mean",this,_mean),
00039 sigma("sigma","Width",this,_sigma)
00040 {
00041 }
00042
00043
00044
00045 RooLandau::RooLandau(const RooLandau& other, const char* name) :
00046 RooAbsPdf(other,name),
00047 x("x",this,other.x),
00048 mean("mean",this,other.mean),
00049 sigma("sigma",this,other.sigma)
00050 {
00051 }
00052
00053
00054
00055 Double_t RooLandau::evaluate() const
00056 {
00057 return TMath::Landau(x, mean, sigma);
00058 }
00059
00060
00061
00062 Int_t RooLandau::getGenerator(const RooArgSet& directVars, RooArgSet &generateVars, Bool_t ) const
00063 {
00064 if (matchArgs(directVars,generateVars,x)) return 1 ;
00065 return 0 ;
00066 }
00067
00068
00069
00070 void RooLandau::generateEvent(Int_t code)
00071 {
00072 assert(code==1) ;
00073 Double_t xgen ;
00074 while(1) {
00075 xgen = RooRandom::randomGenerator()->Landau(mean,sigma);
00076 if (xgen<x.max() && xgen>x.min()) {
00077 x = xgen ;
00078 break;
00079 }
00080 }
00081 return;
00082 }
00083
00084