00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
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
00072 }
00073
00074
00075
00076
00077 RooDecay::~RooDecay()
00078 {
00079
00080 }
00081
00082
00083
00084
00085 Double_t RooDecay::coefficient(Int_t ) const
00086 {
00087 return 1 ;
00088 }
00089
00090
00091
00092
00093 Int_t RooDecay::getGenerator(const RooArgSet& directVars, RooArgSet &generateVars, Bool_t ) 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
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 }