00001 /***************************************************************************** 00002 * Project: RooFit * 00003 * Package: RooFitCore * 00004 * @(#)root/roofitcore:$Id: RooPullVar.cxx 24285 2008-06-16 15:05:15Z 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 // Class RooPullVar represents the pull of measurement w.r.t to true value 00021 // using the measurement value and its error. Both the true value and 00022 // the measured value (with error) are taken from two user supplied 00023 // RooRealVars. If an asymmetric error is defined on a given measurement the proper 00024 // side of that asymmetric error will be used 00025 // END_HTML 00026 // 00027 00028 #include "RooFit.h" 00029 00030 #include "Riostream.h" 00031 #include "Riostream.h" 00032 #include <math.h> 00033 00034 #include "RooPullVar.h" 00035 #include "RooAbsReal.h" 00036 #include "RooRealVar.h" 00037 00038 ClassImp(RooPullVar) 00039 ; 00040 00041 00042 //_____________________________________________________________________________ 00043 RooPullVar::RooPullVar() 00044 { 00045 // Default constructor 00046 } 00047 00048 00049 00050 //_____________________________________________________________________________ 00051 RooPullVar::RooPullVar(const char* name, const char* title, RooRealVar& meas, RooAbsReal& truth) : 00052 RooAbsReal(name, title), 00053 _meas("meas","Measurement",this,meas), 00054 _true("true","Truth",this,truth) 00055 { 00056 // Construct RooAbsReal representing the pull of a RooRealVar 'meas' providing the 00057 // measured value and its error and a RooAbsReal 'truth' providing the true value 00058 } 00059 00060 00061 00062 00063 00064 //_____________________________________________________________________________ 00065 RooPullVar::RooPullVar(const RooPullVar& other, const char* name) : 00066 RooAbsReal(other, name), 00067 _meas("meas",this,other._meas), 00068 _true("true",this,other._true) 00069 { 00070 // Copy constructor 00071 } 00072 00073 00074 00075 //_____________________________________________________________________________ 00076 RooPullVar::~RooPullVar() 00077 { 00078 // Destructor 00079 } 00080 00081 00082 00083 //_____________________________________________________________________________ 00084 Double_t RooPullVar::evaluate() const 00085 { 00086 // Calculate pull. Use asymmetric error if defined in measurement, 00087 // otherwise use symmetric error. If measurement has no error 00088 // return zero. 00089 00090 const RooRealVar& meas = static_cast<const RooRealVar&>(_meas.arg()) ; 00091 if (meas.hasAsymError()) { 00092 Double_t delta = _meas-_true ; 00093 if (delta<0) { 00094 return delta/meas.getAsymErrorHi() ; 00095 } else { 00096 return -delta/meas.getAsymErrorLo() ; 00097 } 00098 } else if (meas.hasError()) { 00099 return (_meas-_true)/meas.getError() ; 00100 } else { 00101 return 0 ; 00102 } 00103 } 00104 00105