ROOT  6.06/09
Reference Guide
RooDecay.cxx
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitModels *
4  * @(#)root/roofit:$Id$
5  * Authors: *
6  * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7  * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8  * *
9  * Copyright (c) 2000-2005, Regents of the University of California *
10  * and Stanford University. All rights reserved. *
11  * *
12  * Redistribution and use in source and binary forms, *
13  * with or without modification, are permitted according to the terms *
14  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15  *****************************************************************************/
16 
17 //////////////////////////////////////////////////////////////////////////////
18 //
19 // BEGIN_HTML
20 // Single or double sided decay function that can be analytically convolved
21 // with any RooResolutionModel implementation
22 // END_HTML
23 //
24 
25 #include "RooFit.h"
26 
27 #include "Riostream.h"
28 #include "Riostream.h"
29 #include "RooDecay.h"
30 #include "RooRealVar.h"
31 #include "RooRandom.h"
32 
33 #include "TError.h"
34 
35 using namespace std;
36 
38 ;
39 
40 
41 
42 ////////////////////////////////////////////////////////////////////////////////
43 /// Constructor
44 
45 RooDecay::RooDecay(const char *name, const char *title,
46  RooRealVar& t, RooAbsReal& tau,
47  const RooResolutionModel& model, DecayType type) :
48  RooAbsAnaConvPdf(name,title,model,t),
49  _t("t","time",this,t),
50  _tau("tau","decay time",this,tau),
51  _type(type)
52 {
53  switch(type) {
54  case SingleSided:
55  _basisExp = declareBasis("exp(-@0/@1)",tau) ;
56  break ;
57  case Flipped:
58  _basisExp = declareBasis("exp(@0/@1)",tau) ;
59  break ;
60  case DoubleSided:
61  _basisExp = declareBasis("exp(-abs(@0)/@1)",tau) ;
62  break ;
63  }
64 }
65 
66 
67 
68 ////////////////////////////////////////////////////////////////////////////////
69 /// Copy constructor
70 
71 RooDecay::RooDecay(const RooDecay& other, const char* name) :
72  RooAbsAnaConvPdf(other,name),
73  _t("t",this,other._t),
74  _tau("tau",this,other._tau),
75  _type(other._type),
76  _basisExp(other._basisExp)
77 {
78 }
79 
80 
81 
82 ////////////////////////////////////////////////////////////////////////////////
83 /// Destructor
84 
86 {
87 }
88 
89 
90 
91 ////////////////////////////////////////////////////////////////////////////////
92 
93 Double_t RooDecay::coefficient(Int_t /*basisIndex*/) const
94 {
95  return 1 ;
96 }
97 
98 
99 
100 ////////////////////////////////////////////////////////////////////////////////
101 
102 Int_t RooDecay::getGenerator(const RooArgSet& directVars, RooArgSet &generateVars, Bool_t /*staticInitOK*/) const
103 {
104  if (matchArgs(directVars,generateVars,_t)) return 1 ;
105  return 0 ;
106 }
107 
108 
109 
110 ////////////////////////////////////////////////////////////////////////////////
111 
113 {
114  R__ASSERT(code==1) ;
115 
116  // Generate delta-t dependent
117  while(1) {
118  Double_t rand = RooRandom::uniform() ;
119  Double_t tval(0) ;
120 
121  switch(_type) {
122  case SingleSided:
123  tval = -_tau*log(rand);
124  break ;
125  case Flipped:
126  tval= +_tau*log(rand);
127  break ;
128  case DoubleSided:
129  tval = (rand<=0.5) ? -_tau*log(2*rand) : +_tau*log(2*(rand-0.5)) ;
130  break ;
131  }
132 
133  if (tval<_t.max() && tval>_t.min()) {
134  _t = tval ;
135  break ;
136  }
137  }
138 }
RooRealProxy _tau
Definition: RooDecay.h:43
virtual ~RooDecay()
Destructor.
Definition: RooDecay.cxx:85
RooRealProxy _t
Definition: RooDecay.h:42
RooDecay()
Definition: RooDecay.h:28
#define R__ASSERT(e)
Definition: TError.h:98
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
STL namespace.
Int_t getGenerator(const RooArgSet &directVars, RooArgSet &generateVars, Bool_t staticInitOK=kTRUE) const
Load generatedVars with the subset of directVars that we can generate events for, and return a code t...
Definition: RooDecay.cxx:102
Int_t _basisExp
Definition: RooDecay.h:45
static Double_t uniform(TRandom *generator=randomGenerator())
Return a number uniformly distributed from (0,1)
Definition: RooRandom.cxx:83
double Double_t
Definition: RtypesCore.h:55
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
int type
Definition: TGX11.cxx:120
Int_t declareBasis(const char *expression, const RooArgList &params)
Declare a basis function for use in this physics model.
void generateEvent(Int_t code)
Interface for generation of anan event using the algorithm corresponding to the specified code...
Definition: RooDecay.cxx:112
DecayType _type
Definition: RooDecay.h:44
#define name(a, b)
Definition: linkTestLib0.cpp:5
ClassImp(RooDecay)
Double_t min(const char *rname=0) const
Definition: RooRealProxy.h:56
virtual Double_t coefficient(Int_t basisIndex) const
Definition: RooDecay.cxx:93
Bool_t matchArgs(const RooArgSet &allDeps, RooArgSet &numDeps, const RooArgProxy &a) const
Utility function for use in getAnalyticalIntegral().
Double_t max(const char *rname=0) const
Definition: RooRealProxy.h:57
double log(double)