#include "RooFit.h"
#include "RooGraphSpring.h"
#include "RooGraphSpring.h"
#include "TList.h"
#include "TMath.h"
#include "RooGraphEdge.h"
#include "Riostream.h"
#include <fstream>
#include <math.h>
ClassImp(RooGraphSpring)
RooGraphSpring::RooGraphSpring()
{
fn1 = 0;
fn2 = 0;
}
RooGraphSpring::RooGraphSpring(RooGraphNode *n1, RooGraphNode *n2)
{
fn1 = n1;
fn2 = n2;
}
void RooGraphSpring::print()
{
cout << fn1->GetName() << ", " << fn2->GetName() << endl;
}
void RooGraphSpring::read(ifstream &)
{
}
void RooGraphSpring::Set1stNode(RooGraphNode *n1)
{
fn1 = n1;
}
void RooGraphSpring::Set2ndNode(RooGraphNode *n2)
{
fn2 = n2;
}
void RooGraphSpring::Connect(RooGraphNode *n1, RooGraphNode *n2)
{
fn1 = n1;
fn2 = n2;
fgraphlength = 1000.0;
}
double RooGraphSpring::GetX1()
{
const double x1 = fn1->GetX1();
return x1;
}
double RooGraphSpring::GetY1()
{
const double y1 = fn1->GetY1();
return y1;
}
double RooGraphSpring::GetX2()
{
const double x2 = fn2->GetX1();
return x2;
}
double RooGraphSpring::GetY2()
{
const double y2 = fn2->GetY1();
return y2;
}
void RooGraphSpring::SwitchNodes()
{
RooGraphNode *n1 = fn1;
RooGraphNode *n2 = fn2;
fn1 = n2;
fn2 = n1;
}
double RooGraphSpring::GetInitialDistance()
{
const double x1 = fn1->GetX1();
const double y1 = fn1->GetY1();
const double x2 = fn2->GetX1();
const double y2 = fn2->GetY1();
double ilength = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
return ilength;
}
void RooGraphSpring::SetGraphLength(double length)
{
fgraphlength = length;
}
double RooGraphSpring::GetLength()
{
double L = .5;
double d = fgraphlength;
double length = L*d;
return length;
}
double RooGraphSpring::GetSpringConstant()
{
double K = 1.0;
double k;
double d = fgraphlength;
k = K/(d*d);
return k;
}
double RooGraphSpring::GetSpringDEnergy(char m)
{
double l = GetLength();
double k = GetSpringConstant();
double x1(0);
double x2(0);
double y1(0);
double y2(0);
if (m == 'x')
{
x1 = fn1->GetX1();
y1 = fn1->GetY1();
x2 = fn2->GetX1();
y2 = fn2->GetY1();
}
if (m == 'y')
{
y1 = fn1->GetX1();
x1 = fn1->GetY1();
y2 = fn2->GetX1();
x2 = fn2->GetY1();
}
double energy = k*((x1-x2)-l*(x1-x2)/sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
return energy;
}
double RooGraphSpring::GetSpringD2Energy(char m)
{
double l = GetLength();
double k = GetSpringConstant();
double x1(0);
double x2(0);
double y1(0);
double y2(0);
if (m == 'y')
{
x1 = fn1->GetX1();
y1 = fn1->GetY1();
x2 = fn2->GetX1();
y2 = fn2->GetY1();
}
if (m == 'x')
{
y1 = fn1->GetX1();
x1 = fn1->GetY1();
y2 = fn2->GetX1();
x2 = fn2->GetY1();
}
double n = ((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
double energy = k*(1-l*(x1-x2)*(x1-x2)/TMath::Power(n,1.5));
return energy;
}
double RooGraphSpring::GetSpringDxyEnergy()
{
double l = GetLength();
double k = GetSpringConstant();
double x1 = fn1->GetX1();
double y1 = fn1->GetY1();
double x2 = fn2->GetX1();
double y2 = fn2->GetY1();
double n = ((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
double energy = k*(l*(x1-x2)*(y1-y2)/TMath::Power(n,1.5));
return energy;
}
ROOT page - Class index - Class Hierarchy - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.