RooEfficiency.cxx

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitCore                                                       *
00004  * @(#)root/roofitcore:$Id: RooEfficiency.cxx 25184 2008-08-20 13:59:55Z 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 // RooEfficiency is a PDF helper class to fit efficiencies parameterized
00021 // by a supplied function F.
00022 // 
00023 // Given a dataset with a category C that determines if a given
00024 // event is accepted or rejected for the efficiency to be measured,
00025 // this class evaluates as F if C is 'accept' and as (1-F) if
00026 // C is 'reject'. Values of F below 0 and above 1 are clipped.
00027 // F may have an arbitrary number of dependents and parameters
00028 // END_HTML
00029 //
00030 
00031 #include "RooFit.h"
00032 
00033 #include "RooEfficiency.h"
00034 #include "RooEfficiency.h"
00035 #include "RooStreamParser.h"
00036 #include "RooArgList.h"
00037 
00038 ClassImp(RooEfficiency)
00039   ;
00040 
00041 
00042 //_____________________________________________________________________________
00043 RooEfficiency::RooEfficiency(const char *name, const char *title, const RooAbsReal& effFunc, const RooAbsCategory& cat, const char* sigCatName) :
00044   RooAbsPdf(name,title),
00045   _cat("cat","Signal/Background category",this,(RooAbsCategory&)cat),
00046   _effFunc("effFunc","Efficiency modeling function",this,(RooAbsReal&)effFunc),
00047   _sigCatName(sigCatName)
00048 {  
00049   // Construct an N+1 dimensional efficiency p.d.f from an N-dimensional efficiency
00050   // function and a category cat with two states (0,1) that indicate if a given
00051   // event should be counted as rejected or accepted respectively
00052 }
00053 
00054 
00055 
00056 //_____________________________________________________________________________
00057 RooEfficiency::RooEfficiency(const RooEfficiency& other, const char* name) : 
00058   RooAbsPdf(other, name),
00059   _cat("cat",this,other._cat),
00060   _effFunc("effFunc",this,other._effFunc),
00061   _sigCatName(other._sigCatName)
00062 {
00063   // Copy constructor
00064 }
00065 
00066 
00067 
00068 //_____________________________________________________________________________
00069 RooEfficiency::~RooEfficiency() 
00070 {
00071   // Destructor
00072 }
00073 
00074 
00075 
00076 //_____________________________________________________________________________
00077 Double_t RooEfficiency::evaluate() const
00078 {
00079   // Calculate the raw value of this p.d.f which is the effFunc
00080   // value if cat==1 and it is (1-effFunc) if cat==0
00081 
00082   Double_t effFuncVal = _effFunc ;
00083 
00084   // Truncate efficiency function in range 0.0-1.0
00085   if (_effFunc>1) {
00086     effFuncVal = 1.0 ;
00087   } else if (_effFunc<0) {
00088     effFuncVal = 0.0 ;
00089   }
00090 
00091   if (_cat.label() == _sigCatName) {
00092     // Accept case
00093     return effFuncVal ;
00094   } else {
00095     // Reject case
00096     return 1 - effFuncVal ;
00097   }
00098 }
00099 
00100 
00101 
00102 //_____________________________________________________________________________
00103 Int_t RooEfficiency::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* /*rangeName*/) const 
00104 {
00105   if (matchArgs(allVars,analVars,_cat)) return 1 ;
00106   return 0 ;
00107 }
00108 
00109 
00110 
00111 //_____________________________________________________________________________
00112 Double_t RooEfficiency::analyticalIntegral(Int_t code, const char* /*rangeName*/) const 
00113 {
00114   assert(code==1) ;
00115   return 1.0 ;
00116 }
00117 
00118 
00119 
00120 
00121 
00122 

Generated on Tue Jul 5 15:06:28 2011 for ROOT_528-00b_version by  doxygen 1.5.1