minor fixes and optimsiation

This commit is contained in:
Gyongyosi Balazs 2018-01-24 10:40:46 +01:00
parent f8764de7e1
commit b2332bbea0
7 changed files with 39 additions and 28 deletions

View File

@ -45,7 +45,7 @@ int main(int argc, char* argv[])
//todo fix parameters
percent = 0.99;
nGenerated = 7000;
nop = 43;
nop = 30;
j_mu1=-25;
j_sigma1=0.3;

View File

@ -11,8 +11,10 @@
class Crusher
{
public:
Crusher(std::vector<Double_t> tp, std::vector<Double_t> xp, double p0p);
Crusher(std::vector<Double_t> tp, std::vector<Double_t> xp);
Crusher(const std::vector<Double_t> & tp, const std::vector<Double_t> & xp, double p0p);
Crusher(const std::vector<Double_t> & tp, const std::vector<Double_t> & xp);
~Crusher();
bool RunMachine(const int & nRunsm, const MuSigma & parameters);
@ -23,13 +25,14 @@ class Crusher
private:
int nSteps;
double p0;
std::vector<Double_t> t;
std::vector<Double_t> x;
double BiggerLimit;
std::vector<Double_t> t;
std::vector<Double_t> x;
BM1DProcess *myBM1DProcess;
Analyse *myAnalyse;
bool Bigger(double percent);
inline bool Bigger();
std::vector<Double_t> multipleRunVectorT;
std::vector<Double_t> multipleRunVectorX;

View File

@ -28,7 +28,7 @@ class Draw2DWorkerThread
{
public:
Draw2DWorkerThread(int jobOffset_, int jobSize_, std::vector<Double_t> x_, std::vector<Double_t> t_, int nRuns_, Lattice *myLattice_, TH2D *BM1D_histo_, TH2D *BM1D_histo2_, struct graphArray graphArray_, pthread_mutex_t *histoMutex_);
Draw2DWorkerThread(int jobOffset_, int jobSize_, const std::vector<Double_t> & x_, const std::vector<Double_t> & t_, int nRuns_, Lattice *myLattice_, TH2D *BM1D_histo_, TH2D *BM1D_histo2_, struct graphArray graphArray_, pthread_mutex_t *histoMutex_);
~Draw2DWorkerThread();
@ -45,8 +45,8 @@ private:
int nRuns; //Chrusher parameter number of tested "kukac"
std::vector<Double_t> t; //original "kukac"
std::vector<Double_t> x;
//std::vector<Double_t> t; //original "kukac"
//std::vector<Double_t> x;
Crusher *myCrusher;

View File

@ -3,6 +3,6 @@
rm -rf ../bm1d_build
mkdir ../bm1d_build
cd ../bm1d_build
cmake ../BM1D
cmake -DCMAKE_BUILD_TYPE=Release ../BM1D
make
echo Setup complete.

View File

@ -1,23 +1,30 @@
#include "Crusher.hh"
Crusher::Crusher(std::vector<Double_t> tp, std::vector<Double_t> xp, double p0p)
Crusher::Crusher(const std::vector<Double_t> & tp, const std::vector<Double_t> & xp, double p0p)
{
nSteps = tp.size();
t = tp;
x = xp;
p0 = p0p;
myBM1DProcess = new BM1DProcess();
nSteps = t.size();
const double percent = 0.5;
BiggerLimit = nSteps * percent;
myBM1DProcess = new BM1DProcess();
}
Crusher::Crusher(std::vector<Double_t> tp, std::vector<Double_t> xp)
Crusher::Crusher(const std::vector<Double_t> & tp, const std::vector<Double_t> & xp)
{
nSteps = tp.size();
t = tp;
x = xp;
p0 = 0.5;
nSteps = t.size();
const double percent = 0.5;
BiggerLimit = nSteps * percent;
myBM1DProcess = new BM1DProcess();
}
@ -26,22 +33,23 @@ Crusher::~Crusher()
delete myBM1DProcess;
}
bool Crusher::Bigger(double percent)
inline bool Crusher::Bigger()
{
int counterBig = 0;
double limit = nSteps * percent;
//double limit = nSteps * percent;
const std::vector<Double_t> & refx = myBM1DProcess -> GetX();
for(int i = 0; i < nSteps; i++)
{
if(myBM1DProcess -> GetX()[i] < x[i]) // reference < origin
if(refx[i] < x[i]) // reference < origin
{
counterBig ++;
}
}
if(counterBig >= limit)
if(counterBig >= BiggerLimit)
{
return true;
}
@ -71,7 +79,7 @@ bool Crusher::RunMachine(const int & nRuns, const MuSigma & parameters)
}
if(Bigger(0.5))
if(Bigger())
{
counter ++;
}

View File

@ -27,8 +27,8 @@ Draw2D::Draw2D(int nop, double percent, int nRunsp, std::vector<Double_t> tp, st
BM1D_histo2 = new TH2D("BM1D_histo2", "BM1D_histo2", myLattice -> GetWidth() , myLattice -> GetMuMin(), (myLattice -> GetMuMax()) , myLattice -> GetHeight() , myLattice -> GetSigmaMin(), (myLattice -> GetSigmaMax()) );
graphArray.size = myLattice -> GetLatticeSize();
graphArray.X = new double[graphArray.size];
graphArray.Y = new double[graphArray.size];
graphArray.X = new double[graphArray.size] {};
graphArray.Y = new double[graphArray.size] {};
gr = new TGraph(graphArray.size);

View File

@ -1,11 +1,11 @@
#include "Draw2DWorkerThread.hh"
Draw2DWorkerThread::Draw2DWorkerThread(int jobOffset_, int jobSize_, std::vector<Double_t> x_, std::vector<Double_t> t_, int nRuns_, Lattice *myLattice_, TH2D *BM1D_histo_, TH2D *BM1D_histo2_, struct graphArray graphArray_, pthread_mutex_t *histoMutex_)
Draw2DWorkerThread::Draw2DWorkerThread(int jobOffset_, int jobSize_, const std::vector<Double_t> & x_, const std::vector<Double_t> & t_, int nRuns_, Lattice *myLattice_, TH2D *BM1D_histo_, TH2D *BM1D_histo2_, struct graphArray graphArray_, pthread_mutex_t *histoMutex_)
{
std::cout << "Draw2DWorkerThread::Draw2DWorkerThread" <<std::endl;
//copy to private variables
x = x_;
t = t_;
//x = x_;
//t = t_;
myLattice = myLattice_;
@ -21,7 +21,7 @@ Draw2DWorkerThread::Draw2DWorkerThread(int jobOffset_, int jobSize_, std::vector
jobSize = jobSize_;
//create Crusher instance
myCrusher = new Crusher(t,x);
myCrusher = new Crusher(t_, x_);
//calculate lattice parameters TODO rework lattice class!!
XbinSize = (myLattice -> GetMuMax() - myLattice -> GetMuMin())/ myLattice -> GetWidth() ;
@ -63,5 +63,5 @@ void Draw2DWorkerThread::WorkerFunction()
}
}
pthread_exit((void*) 0); //kell?? vagy NULL??
pthread_exit((void*) 0);
}