RooLandau.cxx

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitModels                                                     *
00004  * @(#)root/roofit:$Id: RooLandau.cxx 24286 2008-06-16 15:47:04Z wouter $
00005  * Authors:                                                                  *
00006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
00007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
00008  *                                                                           *
00009  * Copyright (c) 2000-2005, Regents of the University of California          *
00010  *                          and Stanford University. All rights reserved.    *
00011  *                                                                           *
00012  * Redistribution and use in source and binary forms,                        *
00013  * with or without modification, are permitted according to the terms        *
00014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
00015  *****************************************************************************/
00016 
00017 //////////////////////////////////////////////////////////////////////////////
00018 //
00019 // BEGIN_HTML
00020 // Landau Distribution p.d.f
00021 // END_HTML
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 /*staticInitOK*/) 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 

Generated on Tue Jul 5 14:55:15 2011 for ROOT_528-00b_version by  doxygen 1.5.1