Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooEllipse.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 RooEllipse.cxx
19\class RooEllipse
20\ingroup Roofitcore
21
22A RooEllipse is a two-dimensional ellipse that can be used to represent
23an error contour.
24**/
25
26
27#include "RooFit.h"
28
29#include "RooEllipse.h"
30#include "TMath.h"
31#include "RooMsgService.h"
32
33#include "Riostream.h"
34#include "TClass.h"
35#include <math.h>
36
37using namespace std;
38
40
41
42
43////////////////////////////////////////////////////////////////////////////////
44/// Default constructor
45
47{
48}
49
50
51////////////////////////////////////////////////////////////////////////////////
52/// Destructor
53
55{
56}
57
58
59////////////////////////////////////////////////////////////////////////////////
60/// Create a 2-dimensional ellipse centered at (x1,x2) that represents the confidence
61/// level contour for a measurement with errors (s1,s2) and correlation coefficient rho.
62/// The resulting curve is defined as the unique ellipse that passes through these points:
63///
64/// (x1+rho*s1,x2+s2) , (x1-rho*s1,x2-s2) , (x1+s1,x2+rho*s2) , (x1-s1,x2-rho*s2)
65///
66/// and is described by the implicit equation:
67///
68/// x*x 2*rho*x*y y*y
69/// ----- - --------- + ----- = 1 - rho*rho
70/// s1*s1 s1*s2 s2*s2
71///
72/// The input parameters s1,s2 must be > 0 and also |rho| <= 1.
73/// The degenerate case |rho|=1 corresponds to a straight line and
74/// is handled as a special case.
75
77{
80
81 if(s1 <= 0 || s2 <= 0) {
82 coutE(InputArguments) << "RooEllipse::RooEllipse: bad parameter s1 or s2 < 0" << endl;
83 return;
84 }
85 Double_t tmp= 1-rho*rho;
86 if(tmp < 0) {
87 coutE(InputArguments) << "RooEllipse::RooEllipse: bad parameter |rho| > 1" << endl;
88 return;
89 }
90
91 if(tmp == 0) {
92 // handle the degenerate case of |rho|=1
93 SetPoint(0,x1-s1,x2-s2);
94 SetPoint(1,x1+s1,x2+s2);
95 setYAxisLimits(x2-s2,x2+s2);
96 }
97 else {
98 Double_t r,psi,phi,u1,u2,xx1,xx2,dphi(2*TMath::Pi()/points);
99 for(Int_t index= 0; index < points; index++) {
100 phi= index*dphi;
101 // adjust the angular spacing of the points for the aspect ratio
102 psi= atan2(s2*sin(phi),s1*cos(phi));
103 u1= cos(psi)/s1;
104 u2= sin(psi)/s2;
105 r= sqrt(tmp/(u1*u1 - 2*rho*u1*u2 + u2*u2));
106 xx1= x1 + r*u1*s1;
107 xx2= x2 + r*u2*s2;
108 SetPoint(index, xx1, xx2);
109 if(index == 0) {
110 setYAxisLimits(xx2,xx2);
111 // add an extra segment to close the curve
112 SetPoint(points, xx1, xx2);
113 }
114 else {
116 }
117 }
118 }
119}
120
121
122
123////////////////////////////////////////////////////////////////////////////////
124/// Print name of ellipse on ostream
125
126void RooEllipse::printName(ostream& os) const
127{
128 os << GetName() ;
129}
130
131
132////////////////////////////////////////////////////////////////////////////////
133/// Print title of ellipse on ostream
134
135void RooEllipse::printTitle(ostream& os) const
136{
137 os << GetName() ;
138}
139
140
141////////////////////////////////////////////////////////////////////////////////
142/// Print class name of ellipse on ostream
143
144void RooEllipse::printClassName(ostream& os) const
145{
146 os << IsA()->GetName() ;
147}
148
149
150////////////////////////////////////////////////////////////////////////////////
151/// Print detailed multi line information on ellipse on ostreamx
152
153void RooEllipse::printMultiline(ostream& os, Int_t contents, Bool_t verbose, TString indent) const
154{
155 RooPlotable::printMultiline(os,contents,verbose,indent);
156 for(Int_t index=0; index < fNpoints; index++) {
157 os << indent << "Point [" << index << "] is at (" << fX[index] << "," << fY[index] << ")" << endl;
158 }
159}
ROOT::R::TRInterface & r
Definition Object.C:4
#define s1(x)
Definition RSha256.hxx:91
static const double x2[5]
static const double x1[5]
#define coutE(a)
#define ClassImp(name)
Definition Rtypes.h:364
static void indent(ostringstream &buf, int indent_level)
char name[80]
Definition TGX11.cxx:110
point * points
Definition X3DBuffer.c:22
A RooEllipse is a two-dimensional ellipse that can be used to represent an error contour.
Definition RooEllipse.h:22
virtual void printTitle(std::ostream &os) const
Print title of ellipse on ostream.
virtual void printName(std::ostream &os) const
Print name of ellipse on ostream.
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Print detailed multi line information on ellipse on ostreamx.
virtual ~RooEllipse()
Destructor.
RooEllipse()
Default constructor.
virtual void printClassName(std::ostream &os) const
Print class name of ellipse on ostream.
void updateYAxisLimits(Double_t y)
Definition RooPlotable.h:33
void setYAxisLimits(Double_t ymin, Double_t ymax)
Definition RooPlotable.h:37
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Print detailed information.
Int_t fNpoints
Number of points <= fMaxSize.
Definition TGraph.h:46
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
Definition TGraph.cxx:2298
virtual void SetName(const char *name="")
Set graph name.
Definition TGraph.cxx:2337
virtual void SetTitle(const char *title="")
Change (i.e.
Definition TGraph.cxx:2353
Double_t * fY
[fNpoints] array of Y points
Definition TGraph.h:48
Double_t * fX
[fNpoints] array of X points
Definition TGraph.h:47
virtual const char * GetName() const
Returns name of object.
Definition TNamed.h:47
Basic string class.
Definition TString.h:136
constexpr Double_t Pi()
Definition TMath.h:37