Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
RooPullVar.cxx
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * @(#)root/roofitcore:$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 \file RooPullVar.cxx
19 \class RooPullVar
20 \ingroup Roofitcore
21 
22 RooPullVar represents the pull of a measurement w.r.t. the true value
23 using the measurement and its error. Both the true value and
24 the measured value (with error) are taken from two user-supplied
25 RooRealVars. If the measured parameter has an asymmetric error, the proper
26 side of that error will be used:
27 \f[
28  \mathrm{Pull}_x = \frac{x_\mathrm{meas}-x_\mathrm{true}}{\Delta_x}
29 \f]
30 **/
31 
32 #include "RooFit.h"
33 
34 #include "Riostream.h"
35 #include "Riostream.h"
36 #include <math.h>
37 
38 #include "RooPullVar.h"
39 #include "RooAbsReal.h"
40 #include "RooRealVar.h"
41 
42 using namespace std;
43 
44 ClassImp(RooPullVar);
45 ;
46 
47 
48 ////////////////////////////////////////////////////////////////////////////////
49 /// Default constructor
50 
51 RooPullVar::RooPullVar()
52 {
53 }
54 
55 
56 
57 ////////////////////////////////////////////////////////////////////////////////
58 /// Construct the pull of the RooRealVar 'meas'.
59 ///
60 /// \param[in] name Name of the pull variable.
61 /// \param[in] title The title (for plotting).
62 /// \param[in] meas The measurement. This variable needs to have an error.
63 /// \param[in] truth The true value.
64 RooPullVar::RooPullVar(const char* name, const char* title, RooRealVar& meas, RooAbsReal& truth) :
65  RooAbsReal(name, title),
66  _meas("meas","Measurement",this,meas),
67  _true("true","Truth",this,truth)
68 {
69 }
70 
71 
72 
73 
74 
75 ////////////////////////////////////////////////////////////////////////////////
76 /// Copy constructor
77 
78 RooPullVar::RooPullVar(const RooPullVar& other, const char* name) :
79  RooAbsReal(other, name),
80  _meas("meas",this,other._meas),
81  _true("true",this,other._true)
82 {
83 }
84 
85 
86 
87 ////////////////////////////////////////////////////////////////////////////////
88 /// Destructor
89 
90 RooPullVar::~RooPullVar()
91 {
92 }
93 
94 
95 
96 ////////////////////////////////////////////////////////////////////////////////
97 /// Calculate pull. Use asymmetric error if defined in measurement,
98 /// otherwise use symmetric error. If measurement has no error
99 /// return zero.
100 
101 Double_t RooPullVar::evaluate() const
102 {
103  const auto& meas = _meas.arg();
104  if (meas.hasAsymError()) {
105  Double_t delta = _meas-_true ;
106  if (delta<0) {
107  return delta/meas.getAsymErrorHi() ;
108  } else {
109  return -delta/meas.getAsymErrorLo() ;
110  }
111  } else if (meas.hasError()) {
112  return (_meas-_true)/meas.getError() ;
113  } else {
114  return 0 ;
115  }
116 }
117 
118