Plotter v1.0
This commit is contained in:
parent
01754e746a
commit
9193223359
|
@ -17,16 +17,19 @@
|
||||||
#include "TCanvas.h"
|
#include "TCanvas.h"
|
||||||
#include "TGraph.h"
|
#include "TGraph.h"
|
||||||
#include "TTree.h"
|
#include "TTree.h"
|
||||||
|
#include "TMultiGraph.h"
|
||||||
|
|
||||||
class Plotter {
|
class Plotter
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
Plotter();
|
Plotter(bool draw);
|
||||||
void Plot(Int_t n, std::vector<Double_t> t, std::vector<Double_t> x);
|
void Plot(Int_t numRuns, Int_t nSteps, std::vector<Double_t> t, std::vector<Double_t> x);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool draw;
|
||||||
|
TMultiGraph *mg;
|
||||||
TGraph* g1;
|
TGraph* g1;
|
||||||
TFile* fOut;
|
|
||||||
TCanvas* canv;
|
TCanvas* canv;
|
||||||
TTree *BM1DTree;
|
|
||||||
Double_t tl,xl;
|
Double_t tl,xl;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,36 +1,39 @@
|
||||||
#include "Plotter.hh"
|
#include "Plotter.hh"
|
||||||
|
|
||||||
Plotter::Plotter()
|
Plotter::Plotter(bool draw)
|
||||||
{
|
{
|
||||||
fOut = new TFile("result.root", "RECREATE");
|
if(draw)
|
||||||
|
{
|
||||||
|
draw = draw;
|
||||||
canv = new TCanvas("canc","display",800,400);
|
canv = new TCanvas("canc","display",800,400);
|
||||||
BM1DTree = new TTree("BM1DTree","BM1DTree");
|
|
||||||
BM1DTree->Branch("t",&tl, "t/D");
|
|
||||||
BM1DTree->Branch("x",&xl, "x/D");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
void Plotter::Plot(Int_t n, std::vector<Double_t> t, std::vector<Double_t> x){
|
//g1 = new TGraph();
|
||||||
g1 = new TGraph(n,&t[0],&x[0]);
|
mg = new TMultiGraph();
|
||||||
canv->cd();
|
}
|
||||||
g1->Draw();
|
void Plotter::Plot(Int_t numRuns, Int_t nSteps, std::vector<Double_t> t, std::vector<Double_t> x)
|
||||||
g1->SetLineColor(1);
|
{
|
||||||
g1->SetLineWidth(1);
|
mg->SetTitle("BM1D");
|
||||||
g1->SetMarkerColor(1);
|
|
||||||
g1->SetMarkerStyle(0);
|
for(int i= 0; i < numRuns; i++)
|
||||||
g1->SetTitle("Brownian Movement D=1");
|
{
|
||||||
|
g1 = new TGraph(nSteps,&t[i*nSteps],&x[i*nSteps]);
|
||||||
|
|
||||||
|
g1->SetLineColor(i+1);
|
||||||
|
g1->SetTitle("Brownian Movement");
|
||||||
g1->GetYaxis()->SetTitle("X");
|
g1->GetYaxis()->SetTitle("X");
|
||||||
g1->GetXaxis()->SetTitle("Time");
|
g1->GetXaxis()->SetTitle("Time");
|
||||||
|
g1->SetLineWidth(1);
|
||||||
|
g1->SetMarkerColor(1);
|
||||||
|
g1->SetMarkerStyle(1);
|
||||||
|
|
||||||
// for (unsigned int i = 0; i < t.size(); i++){
|
mg -> Add(g1);
|
||||||
for (unsigned int i = 0; i < n; i++){
|
|
||||||
tl = t[i];
|
|
||||||
xl = x[i];
|
|
||||||
BM1DTree->Fill();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g1->Write();
|
if(draw)
|
||||||
BM1DTree->Write();
|
{
|
||||||
fOut->Close();
|
g1->Draw();
|
||||||
|
mg -> Draw();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue