89 m1("m1","m1",this,_m1),
90 m2("m2","m2",this,_m2),
93 _npoints( mrefpoints.GetNrows() ),
96 if ( mrefpoints.GetNrows()<4 ) {
97 cerr <<
"Roo2DMomentMorphFunction::constructor(" <<
GetName() <<
") ERROR: less than four reference points provided." << endl ;
101 if ( mrefpoints.GetNcols()!=3 ) {
102 cerr <<
"RooPolyMorph2D::constructor(" <<
GetName() <<
") ERROR: no reference values provided." << endl ;
107 _frac.ResizeTo( _npoints );
131 m1(
"m1",
"m1",this,_m1),
132 m2(
"m2",
"m2",this,_m2),
138 cerr <<
"Roo2DMomentMorphFunction::constructor(" <<
GetName() <<
") ERROR: less than four reference points provided." << endl ;
147 _mref(i,0) = dm1arr[i] ;
148 _mref(i,1) = dm2arr[i] ;
149 _mref(i,2) = dvalarr[i] ;
160 m1(
"m1",this,other.
m1),
161 m2(
"m2",this,other.
m2),
203 if (
_verbose) { cout <<
"Now in evaluate." << endl; }
204 if (
_verbose) { cout <<
"x = " <<
m1 <<
" ; y = " <<
m2 << endl; }
211 if (
_verbose) { cout <<
"End of evaluate : " << ret << endl; }
231 std::vector<double> deltavec(4,1.0);
234 deltavec[3] = deltavec[1]*deltavec[2] ;
236 for (
Int_t i=0; i<4; ++i) {
238 for (
Int_t j=0; j<4; ++j) { ffrac +=
_MSqr(j,i) * deltavec[j]; }
242 if (ffrac>0) sumfrac += ffrac;
245 cout << _squareIdx[i] <<
" " << ffrac <<
" " <<
_squareVec(i,0) <<
" " <<
_squareVec(i,1) << endl;
251 for (
Int_t i=0; i<4; ++i) {
263 bool squareFound(
false);
265 std::vector< std::pair<int,double> > idvec;
272 dx = (x-
_mref(k,0))/xspacing ;
273 dy = (y-
_mref(k,1))/yspacing ;
275 idvec.push_back( std::pair<int,double>(k,delta) );
279 sort(idvec.begin(),idvec.end(),
SorterL2H());
280 std::vector< std::pair<int,double> >::iterator itr = idvec.begin();
281 std::vector<int> cidx;
282 for(; itr!=idvec.end(); ++itr) {
283 cidx.push_back(itr->first);
307 for (
unsigned int i=0; i<cidx.size() && !squareFound; ++i)
308 for (
unsigned int j=i+1; j<cidx.size() && !squareFound; ++j)
309 for (
unsigned int k=j+1; k<cidx.size() && !squareFound; ++k)
310 for (
unsigned int l=k+1;
l<cidx.size() && !squareFound; ++
l) {
311 if (
isAcceptableSquare(
_mref(cidx[i],0),
_mref(cidx[i],1),
_mref(cidx[j],0),
_mref(cidx[j],1),
_mref(cidx[k],0),
_mref(cidx[k],1),
_mref(cidx[
l],0),
_mref(cidx[l],1)) ) {
312 if (
pointInSquare(x,y,
_mref(cidx[i],0),
_mref(cidx[i],1),
_mref(cidx[j],0),
_mref(cidx[j],1),
_mref(cidx[k],0),
_mref(cidx[k],1),
_mref(cidx[l],0),
_mref(cidx[l],1)) ) {
333 for (
Int_t k=0; k<4; ++k) {
362 if (cp1*cp2 >= 0)
return true;
369 Roo2DMomentMorphFunction::pointInSquare(
const double& px,
const double& py,
const double& ax,
const double& ay,
const double& bx,
const double& by,
const double& cx,
const double& cy,
const double& dx,
const double& dy)
const 371 bool insquare(
false);
374 if (ntri<2) ntri +=
static_cast<int>(
pointInTriangle(px,py,ax,ay,bx,by,cx,cy) );
375 if (ntri<2) ntri +=
static_cast<int>(
pointInTriangle(px,py,ax,ay,bx,by,dx,dy) );
376 if (ntri<2) ntri +=
static_cast<int>(
pointInTriangle(px,py,ax,ay,cx,cy,dx,dy) );
377 if (ntri<2) ntri +=
static_cast<int>(
pointInTriangle(px,py,bx,by,cx,cy,dx,dy) );
379 if (ntri>=2) insquare=
true;
390 if (
onSameSide(px,py,ax,ay,bx,by,cx,cy) &&
onSameSide(px,py,bx,by,ax,ay,cx,cy) &&
onSameSide(px,py,cx,cy,ax,ay,bx,by))
return true;
399 return ( ax*by - bx*ay );
428 cout <<
this <<
" " << i <<
" " <<
_mref(i,0) <<
" " <<
_mref(i,1) <<
" " <<
_mref(i,2) << endl;
virtual const char * GetName() const
Returns name of object.
std::string GetName(const std::string &scope_name)
TVectorT< Element > & ResizeTo(Int_t lwb, Int_t upb)
Resize the vector to [lwb:upb] .
virtual ~Roo2DMomentMorphFunction()
Destructor.
Bool_t pointInTriangle(const double &px, const double &py, const double &ax, const double &ay, const double &bx, const double &by, const double &cx, const double &cy) const
virtual TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t=-1)
Set size of the matrix to nrows x ncols New dynamic elements are created, the overlapping part of the...
Double_t evaluate() const
TMatrixT< Element > & Invert(Double_t *det=0)
Invert the matrix and calculate its determinant.
Double_t myCrossProduct(const double &ax, const double &ay, const double &bx, const double &by) const
2-dimensional morph function between a list of function-numbers as a function of two input parameters...
Bool_t findSquare(const double &x, const double &y) const
Bool_t isAcceptableSquare(const double &ax, const double &ay, const double &bx, const double &by, const double &cx, const double &cy, const double &dx, const double &dy) const
Reject kinked shapes.
void calculateFractions(Bool_t verbose=kTRUE) const
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Bool_t onSameSide(const double &p1x, const double &p1y, const double &p2x, const double &p2y, const double &ax, const double &ay, const double &bx, const double &by) const
Returns true if p1 and p2 are on same side of line b-a.
typedef void((*Func_t)())
Roo2DMomentMorphFunction()
Double_t Sqrt(Double_t x)
void initialize(typename Architecture_t::Matrix_t &A, EInitialization m)
Bool_t pointInSquare(const double &px, const double &py, const double &ax, const double &ay, const double &bx, const double &by, const double &cx, const double &cy, const double &dx, const double &dy) const