90 m1("m1","m1",this,_m1),
91 m2("m2","m2",this,_m2),
94 _npoints( mrefpoints.GetNrows() ),
97 if ( mrefpoints.GetNrows()<4 ) {
98 cerr <<
"Roo2DMomentMorphFunction::constructor(" << GetName() <<
") ERROR: less than four reference points provided." << endl ;
102 if ( mrefpoints.GetNcols()!=3 ) {
103 cerr <<
"RooPolyMorph2D::constructor(" << GetName() <<
") ERROR: no reference values provided." << endl ;
108 _frac.ResizeTo( _npoints );
133 m1(
"m1",
"m1",this,_m1),
134 m2(
"m2",
"m2",this,_m2),
140 cerr <<
"Roo2DMomentMorphFunction::constructor(" <<
GetName() <<
") ERROR: less than four reference points provided." << endl ;
149 _mref(i,0) = dm1arr[i] ;
150 _mref(i,1) = dm2arr[i] ;
151 _mref(i,2) = dvalarr[i] ;
163 m1(
"m1",this,other.m1),
164 m2(
"m2",this,other.m2),
165 _setting(other._setting),
166 _verbose(other._verbose),
167 _npoints(other._npoints),
209 if (
_verbose) { cout <<
"Now in evaluate." << endl; }
210 if (
_verbose) { cout <<
"x = " <<
m1 <<
" ; y = " <<
m2 << endl; }
217 if (
_verbose) { cout <<
"End of evaluate : " << ret << endl; }
238 std::vector<double> deltavec(4,1.0);
241 deltavec[3] = deltavec[1]*deltavec[2] ;
243 for (
Int_t i=0; i<4; ++i) {
245 for (
Int_t j=0; j<4; ++j) { ffrac +=
_MSqr(j,i) * deltavec[j]; }
249 if (ffrac>0) sumfrac += ffrac;
252 cout << _squareIdx[i] <<
" " << ffrac <<
" " <<
_squareVec(i,0) <<
" " <<
_squareVec(i,1) << endl;
258 for (
Int_t i=0; i<4; ++i) {
271 bool squareFound(
false);
273 std::vector< std::pair<int,double> > idvec;
280 dx = (x-
_mref(k,0))/xspacing ;
281 dy = (y-
_mref(k,1))/yspacing ;
283 idvec.push_back( std::pair<int,double>(k,delta) );
287 sort(idvec.begin(),idvec.end(),
SorterL2H());
288 std::vector< std::pair<int,double> >::iterator itr = idvec.begin();
289 std::vector<int> cidx;
290 for(; itr!=idvec.end(); ++itr) {
291 cidx.push_back(itr->first);
315 for (
unsigned int i=0; i<cidx.size() && !squareFound; ++i)
316 for (
unsigned int j=i+1; j<cidx.size() && !squareFound; ++j)
317 for (
unsigned int k=j+1; k<cidx.size() && !squareFound; ++k)
318 for (
unsigned int l=k+1;
l<cidx.size() && !squareFound; ++
l) {
319 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)) ) {
320 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)) ) {
341 for (
Int_t k=0; k<4; ++k) {
371 if (cp1*cp2 >= 0)
return true;
379 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
381 bool insquare(
false);
384 if (ntri<2) ntri +=
static_cast<int>(
pointInTriangle(px,py,ax,ay,bx,by,cx,cy) );
385 if (ntri<2) ntri +=
static_cast<int>(
pointInTriangle(px,py,ax,ay,bx,by,dx,dy) );
386 if (ntri<2) ntri +=
static_cast<int>(
pointInTriangle(px,py,ax,ay,cx,cy,dx,dy) );
387 if (ntri<2) ntri +=
static_cast<int>(
pointInTriangle(px,py,bx,by,cx,cy,dx,dy) );
389 if (ntri>=2) insquare=
true;
401 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;
411 return ( ax*by - bx*ay );
441 cout <<
this <<
" " << i <<
" " <<
_mref(i,0) <<
" " <<
_mref(i,1) <<
" " <<
_mref(i,2) << endl;
TVectorT< Element > & ResizeTo(Int_t lwb, Int_t upb)
Resize the vector to [lwb:upb] .
virtual ~Roo2DMomentMorphFunction()
Destructor.
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.
Bool_t findSquare(const double &x, const double &y) const
void calculateFractions(Bool_t verbose=kTRUE) 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.
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.
2-dimensional morph function between a list of function-numbers as a function of two input parameters...
ClassImp(Roo2DMomentMorphFunction) Roo2DMomentMorphFunction
Constructor.
virtual const char * GetName() const
Returns name of object.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
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
typedef void((*Func_t)())
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
Roo2DMomentMorphFunction()
Double_t Sqrt(Double_t x)
Double_t myCrossProduct(const double &ax, const double &ay, const double &bx, const double &by) const