Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
22Two-dimensional ellipse that can be used to represent an error contour.
23**/
24
25#include "RooEllipse.h"
26#include "TMath.h"
27#include "RooMsgService.h"
28
29#include "Riostream.h"
30#include "TClass.h"
31#include <cmath>
32
33
34////////////////////////////////////////////////////////////////////////////////
35/// Create a 2-dimensional ellipse centered at (x1,x2) that represents the confidence
36/// level contour for a measurement with errors (s1,s2) and correlation coefficient rho.
37/// The resulting curve is defined as the unique ellipse that passes through these points:
38///
39/// (x1+rho*s1,x2+s2) , (x1-rho*s1,x2-s2) , (x1+s1,x2+rho*s2) , (x1-s1,x2-rho*s2)
40///
41/// and is described by the implicit equation:
42///
43/// x*x 2*rho*x*y y*y
44/// ----- - --------- + ----- = 1 - rho*rho
45/// s1*s1 s1*s2 s2*s2
46///
47/// The input parameters s1,s2 must be > 0 and also |rho| <= 1.
48/// The degenerate case |rho|=1 corresponds to a straight line and
49/// is handled as a special case.
50
51RooEllipse::RooEllipse(const char *name, double x1, double x2, double s1, double s2, double rho, Int_t points)
52{
55
56 if(s1 <= 0 || s2 <= 0) {
57 coutE(InputArguments) << "RooEllipse::RooEllipse: bad parameter s1 or s2 < 0" << std::endl;
58 return;
59 }
60 double tmp= 1-rho*rho;
61 if(tmp < 0) {
62 coutE(InputArguments) << "RooEllipse::RooEllipse: bad parameter |rho| > 1" << std::endl;
63 return;
64 }
65
66 if(tmp == 0) {
67 // handle the degenerate case of |rho|=1
68 SetPoint(0,x1-s1,x2-s2);
69 SetPoint(1,x1+s1,x2+s2);
71 }
72 else {
73 double r;
74 double psi;
75 double phi;
76 double u1;
77 double u2;
78 double xx1;
79 double xx2;
80 double dphi(2 * TMath::Pi() / points);
81 for(Int_t index= 0; index < points; index++) {
82 phi= index*dphi;
83 // adjust the angular spacing of the points for the aspect ratio
84 psi= atan2(s2*sin(phi),s1*cos(phi));
85 u1= cos(psi)/s1;
86 u2= sin(psi)/s2;
87 r= sqrt(tmp/(u1*u1 - 2*rho*u1*u2 + u2*u2));
88 xx1= x1 + r*u1*s1;
89 xx2= x2 + r*u2*s2;
91 if(index == 0) {
93 // add an extra segment to close the curve
95 }
96 else {
98 }
99 }
100 }
101}
102
103
104
105////////////////////////////////////////////////////////////////////////////////
106/// Print name of ellipse on ostream
107
108void RooEllipse::printName(std::ostream& os) const
109{
110 os << GetName() ;
111}
112
113
114////////////////////////////////////////////////////////////////////////////////
115/// Print title of ellipse on ostream
116
117void RooEllipse::printTitle(std::ostream& os) const
118{
119 os << GetName() ;
120}
121
122
123////////////////////////////////////////////////////////////////////////////////
124/// Print class name of ellipse on ostream
125
126void RooEllipse::printClassName(std::ostream& os) const
127{
128 os << ClassName() ;
129}
130
131
132////////////////////////////////////////////////////////////////////////////////
133/// Print detailed multi line information on ellipse on ostreamx
134
135void RooEllipse::printMultiline(std::ostream& os, Int_t contents, bool verbose, TString indent) const
136{
137 RooPlotable::printMultiline(os,contents,verbose,indent);
138 for(Int_t index=0; index < fNpoints; index++) {
139 os << indent << "Point [" << index << "] is at (" << fX[index] << "," << fY[index] << ")" << std::endl;
140 }
141}
#define s1(x)
Definition RSha256.hxx:91
#define coutE(a)
static void indent(ostringstream &buf, int indent_level)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
char name[80]
Definition TGX11.cxx:110
void printTitle(std::ostream &os) const override
Print title of ellipse on ostream.
RooEllipse()=default
void printClassName(std::ostream &os) const override
Print class name of ellipse on ostream.
void printName(std::ostream &os) const override
Print name of ellipse on ostream.
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Print detailed multi line information on ellipse on ostreamx.
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Print detailed information.
void updateYAxisLimits(double y)
Definition RooPlotable.h:30
void setYAxisLimits(double ymin, double ymax)
Definition RooPlotable.h:34
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:2291
Double_t * fY
[fNpoints] array of Y points
Definition TGraph.h:48
void SetName(const char *name="") override
Set graph name.
Definition TGraph.cxx:2330
Double_t * fX
[fNpoints] array of X points
Definition TGraph.h:47
void SetTitle(const char *title="") override
Change (i.e.
Definition TGraph.cxx:2346
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:226
Basic string class.
Definition TString.h:139
constexpr Double_t Pi()
Definition TMath.h:37