00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "RooFit.h"
00027
00028 #include "RooEllipse.h"
00029 #include "RooEllipse.h"
00030 #include "TMath.h"
00031 #include "RooMsgService.h"
00032
00033 #include "Riostream.h"
00034 #include "TClass.h"
00035 #include <math.h>
00036 #include <assert.h>
00037
00038 ClassImp(RooEllipse)
00039
00040
00041
00042
00043 RooEllipse::RooEllipse()
00044 {
00045
00046 }
00047
00048
00049
00050 RooEllipse::~RooEllipse()
00051 {
00052
00053 }
00054
00055
00056
00057 RooEllipse::RooEllipse(const char *name, Double_t x1, Double_t x2, Double_t s1, Double_t s2, Double_t rho, Int_t points)
00058 {
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 SetName(name);
00076 SetTitle(name);
00077
00078 if(s1 <= 0 || s2 <= 0) {
00079 coutE(InputArguments) << "RooEllipse::RooEllipse: bad parameter s1 or s2 < 0" << endl;
00080 return;
00081 }
00082 Double_t tmp= 1-rho*rho;
00083 if(tmp < 0) {
00084 coutE(InputArguments) << "RooEllipse::RooEllipse: bad parameter |rho| > 1" << endl;
00085 return;
00086 }
00087
00088 if(tmp == 0) {
00089
00090 SetPoint(0,x1-s1,x2-s2);
00091 SetPoint(1,x1+s1,x2+s2);
00092 setYAxisLimits(x2-s2,x2+s2);
00093 }
00094 else {
00095 Double_t r,psi,phi,u1,u2,xx1,xx2,dphi(2*TMath::Pi()/points);
00096 for(Int_t index= 0; index < points; index++) {
00097 phi= index*dphi;
00098
00099 psi= atan2(s2*sin(phi),s1*cos(phi));
00100 u1= cos(psi)/s1;
00101 u2= sin(psi)/s2;
00102 r= sqrt(tmp/(u1*u1 - 2*rho*u1*u2 + u2*u2));
00103 xx1= x1 + r*u1*s1;
00104 xx2= x2 + r*u2*s2;
00105 SetPoint(index, xx1, xx2);
00106 if(index == 0) {
00107 setYAxisLimits(xx2,xx2);
00108
00109 SetPoint(points, xx1, xx2);
00110 }
00111 else {
00112 updateYAxisLimits(xx2);
00113 }
00114 }
00115 }
00116 }
00117
00118
00119
00120
00121 void RooEllipse::printName(ostream& os) const
00122 {
00123
00124 os << GetName() ;
00125 }
00126
00127
00128
00129 void RooEllipse::printTitle(ostream& os) const
00130 {
00131
00132 os << GetName() ;
00133 }
00134
00135
00136
00137 void RooEllipse::printClassName(ostream& os) const
00138 {
00139
00140 os << IsA()->GetName() ;
00141 }
00142
00143
00144
00145 void RooEllipse::printMultiline(ostream& os, Int_t contents, Bool_t verbose, TString indent) const
00146 {
00147
00148 RooPlotable::printMultiline(os,contents,verbose,indent);
00149 for(Int_t index=0; index < fNpoints; index++) {
00150 os << indent << "Point [" << index << "] is at (" << fX[index] << "," << fY[index] << ")" << endl;
00151 }
00152 }