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
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include "RooFit.h"
00040 #include "Riostream.h"
00041
00042 #include "RooExtendPdf.h"
00043 #include "RooExtendPdf.h"
00044 #include "RooArgList.h"
00045 #include "RooRealVar.h"
00046 #include "RooFormulaVar.h"
00047 #include "RooNameReg.h"
00048 #include "RooMsgService.h"
00049
00050
00051
00052 ClassImp(RooExtendPdf)
00053 ;
00054
00055
00056 RooExtendPdf::RooExtendPdf() : _rangeName(0)
00057 {
00058
00059 }
00060
00061 RooExtendPdf::RooExtendPdf(const char *name, const char *title, const RooAbsPdf& pdf,
00062 const RooAbsReal& norm, const char* rangeName) :
00063 RooAbsPdf(name,title),
00064 _pdf("pdf","PDF",this,(RooAbsReal&)pdf),
00065 _n("n","Normalization",this,(RooAbsReal&)norm),
00066 _rangeName(RooNameReg::ptr(rangeName))
00067 {
00068
00069
00070
00071 # // the number of events in the given range
00072
00073
00074 setUnit(_pdf.arg().getUnit()) ;
00075 setPlotLabel(_pdf.arg().getPlotLabel()) ;
00076 }
00077
00078
00079
00080 RooExtendPdf::RooExtendPdf(const RooExtendPdf& other, const char* name) :
00081 RooAbsPdf(other,name),
00082 _pdf("pdf",this,other._pdf),
00083 _n("n",this,other._n),
00084 _rangeName(other._rangeName)
00085 {
00086
00087 }
00088
00089
00090 RooExtendPdf::~RooExtendPdf()
00091 {
00092
00093
00094 }
00095
00096
00097
00098 Double_t RooExtendPdf::expectedEvents(const RooArgSet* nset) const
00099 {
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109 RooAbsPdf& pdf = (RooAbsPdf&)_pdf.arg() ;
00110
00111 if (_rangeName && (!nset || nset->getSize()==0)) {
00112 coutW(InputArguments) << "RooExtendPdf::expectedEvents(" << GetName() << ") WARNING: RooExtendPdf needs non-null normalization set to calculate fraction in range "
00113 << _rangeName << ". Results may be nonsensical" << endl ;
00114 }
00115
00116 Double_t nExp = _n ;
00117
00118
00119 if (_rangeName) {
00120
00121 globalSelectComp(kTRUE) ;
00122 Double_t fracInt = pdf.getNormObj(nset,nset,_rangeName)->getVal() ;
00123 globalSelectComp(kFALSE) ;
00124
00125
00126 if ( fracInt == 0. || _n == 0.) {
00127 coutW(Eval) << "RooExtendPdf(" << GetName() << ") WARNING: nExpected = " << _n << " / "
00128 << fracInt << " for nset = " << (nset?*nset:RooArgSet()) << endl ;
00129 }
00130
00131 nExp /= fracInt ;
00132
00133
00134
00135
00136 }
00137
00138
00139 if (pdf.canBeExtended()) nExp *= pdf.expectedEvents(nset) ;
00140
00141 return nExp ;
00142 }
00143
00144
00145