RooDecay.cxx

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitModels                                                     *
00004  * @(#)root/roofit:$Id: RooDecay.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 // Single or double sided decay function that can be analytically convolved
00021 // with any RooResolutionModel implementation
00022 // END_HTML
00023 //
00024 
00025 #include "RooFit.h"
00026 
00027 #include "Riostream.h"
00028 #include "Riostream.h"
00029 #include "RooDecay.h"
00030 #include "RooRealVar.h"
00031 #include "RooRandom.h"
00032 
00033 ClassImp(RooDecay) 
00034 ;
00035 
00036 
00037 
00038 //_____________________________________________________________________________
00039 RooDecay::RooDecay(const char *name, const char *title, 
00040                    RooRealVar& t, RooAbsReal& tau, 
00041                    const RooResolutionModel& model, DecayType type) :
00042   RooAbsAnaConvPdf(name,title,model,t), 
00043   _t("t","time",this,t),
00044   _tau("tau","decay time",this,tau),
00045   _type(type)
00046 {
00047   // Constructor
00048   switch(type) {
00049   case SingleSided:
00050     _basisExp = declareBasis("exp(-@0/@1)",tau) ;
00051     break ;
00052   case Flipped:
00053     _basisExp = declareBasis("exp(@0/@1)",tau) ;
00054     break ;
00055   case DoubleSided:
00056     _basisExp = declareBasis("exp(-abs(@0)/@1)",tau) ;
00057     break ;
00058   }
00059 }
00060 
00061 
00062 
00063 //_____________________________________________________________________________
00064 RooDecay::RooDecay(const RooDecay& other, const char* name) : 
00065   RooAbsAnaConvPdf(other,name), 
00066   _t("t",this,other._t),
00067   _tau("tau",this,other._tau),
00068   _type(other._type),
00069   _basisExp(other._basisExp)
00070 {
00071   // Copy constructor
00072 }
00073 
00074 
00075 
00076 //_____________________________________________________________________________
00077 RooDecay::~RooDecay()
00078 {
00079   // Destructor
00080 }
00081 
00082 
00083 
00084 //_____________________________________________________________________________
00085 Double_t RooDecay::coefficient(Int_t /*basisIndex*/) const 
00086 {
00087   return 1 ;
00088 }
00089 
00090 
00091 
00092 //_____________________________________________________________________________
00093 Int_t RooDecay::getGenerator(const RooArgSet& directVars, RooArgSet &generateVars, Bool_t /*staticInitOK*/) const
00094 {
00095   if (matchArgs(directVars,generateVars,_t)) return 1 ;  
00096   return 0 ;
00097 }
00098 
00099 
00100 
00101 //_____________________________________________________________________________
00102 void RooDecay::generateEvent(Int_t code)
00103 {
00104   assert(code==1) ;
00105 
00106   // Generate delta-t dependent
00107   while(1) {
00108     Double_t rand = RooRandom::uniform() ;
00109     Double_t tval(0) ;
00110 
00111     switch(_type) {
00112     case SingleSided:
00113       tval = -_tau*log(rand);
00114       break ;
00115     case Flipped:
00116       tval= +_tau*log(rand);
00117       break ;
00118     case DoubleSided:
00119       tval = (rand<=0.5) ? -_tau*log(2*rand) : +_tau*log(2*(rand-0.5)) ;
00120       break ;
00121     }
00122     
00123     if (tval<_t.max() && tval>_t.min()) {
00124       _t = tval ;
00125       break ;
00126     }
00127   }  
00128 }

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