ROOT logo
/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitModels                                                     *
 *    File: $Id: RooGaussModel.h,v 1.21 2007/05/11 09:13:07 verkerke Exp $
 * Authors:                                                                  *
 *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
 *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
 *                                                                           *
 * Copyright (c) 2000-2005, Regents of the University of California          *
 *                          and Stanford University. All rights reserved.    *
 *                                                                           *
 * Redistribution and use in source and binary forms,                        *
 * with or without modification, are permitted according to the terms        *
 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
 *****************************************************************************/
#ifndef ROO_GAUSS_MODEL
#define ROO_GAUSS_MODEL

#include "RooResolutionModel.h"
#include "RooRealProxy.h"
#include "RooComplex.h"
#include "RooMath.h"

class RooGaussModel : public RooResolutionModel {
public:

  enum RooGaussBasis { noBasis=0, expBasisMinus= 1, expBasisSum= 2, expBasisPlus= 3,
                                  sinBasisMinus=11, sinBasisSum=12, sinBasisPlus=13,
                                  cosBasisMinus=21, cosBasisSum=22, cosBasisPlus=23,
                                                                    linBasisPlus=33,
                                                                   quadBasisPlus=43, 
				  coshBasisMinus=51,coshBasisSum=52,coshBasisPlus=53,
 	  			  sinhBasisMinus=61,sinhBasisSum=62,sinhBasisPlus=63};
  enum BasisType { none=0, expBasis=1, sinBasis=2, cosBasis=3,
		   linBasis=4, quadBasis=5, coshBasis=6, sinhBasis=7 } ;
  enum BasisSign { Both=0, Plus=+1, Minus=-1 } ;

  // Constructors, assignment etc
  inline RooGaussModel() { }
  RooGaussModel(const char *name, const char *title, RooRealVar& x, 
		RooAbsReal& mean, RooAbsReal& sigma) ; 
  RooGaussModel(const char *name, const char *title, RooRealVar& x, 
		RooAbsReal& mean, RooAbsReal& sigma, RooAbsReal& msSF) ; 
  RooGaussModel(const char *name, const char *title, RooRealVar& x, 
		RooAbsReal& mean, RooAbsReal& sigma, RooAbsReal& meanSF, RooAbsReal& sigmaSF) ; 
  RooGaussModel(const RooGaussModel& other, const char* name=0);
  virtual TObject* clone(const char* newname) const { return new RooGaussModel(*this,newname) ; }
  virtual ~RooGaussModel();
  
  virtual Int_t basisCode(const char* name) const ;
  virtual Int_t getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* rangeName=0) const ;
  virtual Double_t analyticalIntegral(Int_t code, const char* rangeName) const ;

  Int_t getGenerator(const RooArgSet& directVars, RooArgSet &generateVars, Bool_t staticInitOK=kTRUE) const;
  void generateEvent(Int_t code);

  void advertiseFlatScaleFactorIntegral(Bool_t flag) { _flatSFInt = flag ; }

  void advertiseAymptoticIntegral(Bool_t flag) { _asympInt = flag ; }  // added FMV,07/24/03

protected:

  virtual Double_t evaluate() const ;
  RooComplex evalCerfApprox(Double_t swt, Double_t u, Double_t c) const ;

  // Calculate exp(-u^2) cwerf(swt*c + i(u+c)), taking care of numerical instabilities
  inline RooComplex evalCerf(Double_t swt, Double_t u, Double_t c) const {
    RooComplex z(swt*c,u+c);
    return (z.im()>-4.0) ? RooMath::FastComplexErrFunc(z)*exp(-u*u) : evalCerfApprox(swt,u,c) ;
  }
    
  // Calculate Re(exp(-u^2) cwerf(swt*c + i(u+c))), taking care of numerical instabilities
  inline Double_t evalCerfRe(Double_t swt, Double_t u, Double_t c) const {
    RooComplex z(swt*c,u+c);
    return (z.im()>-4.0) ? RooMath::FastComplexErrFuncRe(z)*exp(-u*u) : evalCerfApprox(swt,u,c).re() ;
  }
  
  // Calculate Im(exp(-u^2) cwerf(swt*c + i(u+c))), taking care of numerical instabilities
  inline Double_t evalCerfIm(Double_t swt, Double_t u, Double_t c) const {
    RooComplex z(swt*c,u+c);
    return (z.im()>-4.0) ? RooMath::FastComplexErrFuncIm(z)*exp(-u*u) : evalCerfApprox(swt,u,c).im() ;
  }

  // Calculate Re(exp(-u^2) cwerf(i(u+c)))
  // added FMV, 08/17/03
  inline Double_t evalCerfRe(Double_t u, Double_t c) const {
    return exp(u*2*c+c*c) * RooMath::erfc(u+c);
  }

  // Calculate common normalization factors 
  // added FMV,07/24/03
  RooComplex evalCerfInt(Double_t sign, Double_t wt, Double_t tau, Double_t umin, Double_t umax, Double_t c) const ;
  Double_t evalCerfInt(Double_t sign, Double_t tau, Double_t umin, Double_t umax, Double_t c) const ;

  Bool_t _flatSFInt ;

  Bool_t _asympInt ;  // added FMV,07/24/03
  
  RooRealProxy mean ;
  RooRealProxy sigma ;
  RooRealProxy msf ;
  RooRealProxy ssf ;

  ClassDef(RooGaussModel,1) // Gaussian Resolution Model
};

#endif









 RooGaussModel.h:1
 RooGaussModel.h:2
 RooGaussModel.h:3
 RooGaussModel.h:4
 RooGaussModel.h:5
 RooGaussModel.h:6
 RooGaussModel.h:7
 RooGaussModel.h:8
 RooGaussModel.h:9
 RooGaussModel.h:10
 RooGaussModel.h:11
 RooGaussModel.h:12
 RooGaussModel.h:13
 RooGaussModel.h:14
 RooGaussModel.h:15
 RooGaussModel.h:16
 RooGaussModel.h:17
 RooGaussModel.h:18
 RooGaussModel.h:19
 RooGaussModel.h:20
 RooGaussModel.h:21
 RooGaussModel.h:22
 RooGaussModel.h:23
 RooGaussModel.h:24
 RooGaussModel.h:25
 RooGaussModel.h:26
 RooGaussModel.h:27
 RooGaussModel.h:28
 RooGaussModel.h:29
 RooGaussModel.h:30
 RooGaussModel.h:31
 RooGaussModel.h:32
 RooGaussModel.h:33
 RooGaussModel.h:34
 RooGaussModel.h:35
 RooGaussModel.h:36
 RooGaussModel.h:37
 RooGaussModel.h:38
 RooGaussModel.h:39
 RooGaussModel.h:40
 RooGaussModel.h:41
 RooGaussModel.h:42
 RooGaussModel.h:43
 RooGaussModel.h:44
 RooGaussModel.h:45
 RooGaussModel.h:46
 RooGaussModel.h:47
 RooGaussModel.h:48
 RooGaussModel.h:49
 RooGaussModel.h:50
 RooGaussModel.h:51
 RooGaussModel.h:52
 RooGaussModel.h:53
 RooGaussModel.h:54
 RooGaussModel.h:55
 RooGaussModel.h:56
 RooGaussModel.h:57
 RooGaussModel.h:58
 RooGaussModel.h:59
 RooGaussModel.h:60
 RooGaussModel.h:61
 RooGaussModel.h:62
 RooGaussModel.h:63
 RooGaussModel.h:64
 RooGaussModel.h:65
 RooGaussModel.h:66
 RooGaussModel.h:67
 RooGaussModel.h:68
 RooGaussModel.h:69
 RooGaussModel.h:70
 RooGaussModel.h:71
 RooGaussModel.h:72
 RooGaussModel.h:73
 RooGaussModel.h:74
 RooGaussModel.h:75
 RooGaussModel.h:76
 RooGaussModel.h:77
 RooGaussModel.h:78
 RooGaussModel.h:79
 RooGaussModel.h:80
 RooGaussModel.h:81
 RooGaussModel.h:82
 RooGaussModel.h:83
 RooGaussModel.h:84
 RooGaussModel.h:85
 RooGaussModel.h:86
 RooGaussModel.h:87
 RooGaussModel.h:88
 RooGaussModel.h:89
 RooGaussModel.h:90
 RooGaussModel.h:91
 RooGaussModel.h:92
 RooGaussModel.h:93
 RooGaussModel.h:94
 RooGaussModel.h:95
 RooGaussModel.h:96
 RooGaussModel.h:97
 RooGaussModel.h:98
 RooGaussModel.h:99
 RooGaussModel.h:100
 RooGaussModel.h:101
 RooGaussModel.h:102
 RooGaussModel.h:103
 RooGaussModel.h:104
 RooGaussModel.h:105
 RooGaussModel.h:106
 RooGaussModel.h:107
 RooGaussModel.h:108
 RooGaussModel.h:109
 RooGaussModel.h:110
 RooGaussModel.h:111
 RooGaussModel.h:112
 RooGaussModel.h:113
 RooGaussModel.h:114
 RooGaussModel.h:115
 RooGaussModel.h:116