ROOT  6.06/09
Reference Guide
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 //
19 // BEGIN_HTML
20 // Class RooPullVar represents the pull of measurement w.r.t to true value
21 // using the measurement value and its error. Both the true value and
22 // the measured value (with error) are taken from two user supplied
23 // RooRealVars. If an asymmetric error is defined on a given measurement the proper
24 // side of that asymmetric error will be used
25 // END_HTML
26 //
27 
28 #include "RooFit.h"
29 
30 #include "Riostream.h"
31 #include "Riostream.h"
32 #include <math.h>
33 
34 #include "RooPullVar.h"
35 #include "RooAbsReal.h"
36 #include "RooRealVar.h"
37 
38 using namespace std;
39 
41 ;
42 
43 
44 ////////////////////////////////////////////////////////////////////////////////
45 /// Default constructor
46 
48 {
49 }
50 
51 
52 
53 ////////////////////////////////////////////////////////////////////////////////
54 /// Construct RooAbsReal representing the pull of a RooRealVar 'meas' providing the
55 /// measured value and its error and a RooAbsReal 'truth' providing the true value
56 
57 RooPullVar::RooPullVar(const char* name, const char* title, RooRealVar& meas, RooAbsReal& truth) :
58  RooAbsReal(name, title),
59  _meas("meas","Measurement",this,meas),
60  _true("true","Truth",this,truth)
61 {
62 }
63 
64 
65 
66 
67 
68 ////////////////////////////////////////////////////////////////////////////////
69 /// Copy constructor
70 
71 RooPullVar::RooPullVar(const RooPullVar& other, const char* name) :
72  RooAbsReal(other, name),
73  _meas("meas",this,other._meas),
74  _true("true",this,other._true)
75 {
76 }
77 
78 
79 
80 ////////////////////////////////////////////////////////////////////////////////
81 /// Destructor
82 
84 {
85 }
86 
87 
88 
89 ////////////////////////////////////////////////////////////////////////////////
90 /// Calculate pull. Use asymmetric error if defined in measurement,
91 /// otherwise use symmetric error. If measurement has no error
92 /// return zero.
93 
95 {
96  const RooRealVar& meas = static_cast<const RooRealVar&>(_meas.arg()) ;
97  if (meas.hasAsymError()) {
98  Double_t delta = _meas-_true ;
99  if (delta<0) {
100  return delta/meas.getAsymErrorHi() ;
101  } else {
102  return -delta/meas.getAsymErrorLo() ;
103  }
104  } else if (meas.hasError()) {
105  return (_meas-_true)/meas.getError() ;
106  } else {
107  return 0 ;
108  }
109 }
110 
111 
Bool_t hasError(Bool_t allowZero=kTRUE) const
Definition: RooRealVar.h:55
virtual ~RooPullVar()
Destructor.
Definition: RooPullVar.cxx:83
STL namespace.
const RooAbsReal & arg() const
Definition: RooRealProxy.h:43
ClassImp(RooPullVar)
Bool_t hasAsymError(Bool_t allowZero=kTRUE) const
Definition: RooRealVar.h:60
RooPullVar()
Default constructor.
Definition: RooPullVar.cxx:47
Double_t getAsymErrorHi() const
Definition: RooRealVar.h:59
RooRealProxy _meas
Definition: RooPullVar.h:38
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
#define name(a, b)
Definition: linkTestLib0.cpp:5
Double_t getAsymErrorLo() const
Definition: RooRealVar.h:58
Double_t evaluate() const
Calculate pull.
Definition: RooPullVar.cxx:94
RooRealProxy _true
Definition: RooPullVar.h:39
Double_t getError() const
Definition: RooRealVar.h:54