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)
 | 
				
			||||||
   canv = new TCanvas("canc","display",800,400);
 | 
					  {
 | 
				
			||||||
   BM1DTree = new TTree("BM1DTree","BM1DTree");
 | 
						draw = draw;
 | 
				
			||||||
   BM1DTree->Branch("t",&tl, "t/D");
 | 
						canv = new TCanvas("canc","display",800,400);
 | 
				
			||||||
   BM1DTree->Branch("x",&xl, "x/D");
 | 
					  }
 | 
				
			||||||
   
 | 
					//g1 = new TGraph();
 | 
				
			||||||
 | 
					mg = new TMultiGraph();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
void Plotter::Plot(Int_t n, std::vector<Double_t> t, std::vector<Double_t> x){
 | 
					void Plotter::Plot(Int_t numRuns, Int_t nSteps, std::vector<Double_t> t, std::vector<Double_t> x)
 | 
				
			||||||
  g1 = new TGraph(n,&t[0],&x[0]);
 | 
					{
 | 
				
			||||||
  canv->cd();
 | 
					  mg->SetTitle("BM1D");
 | 
				
			||||||
  g1->Draw();
 | 
					 | 
				
			||||||
  g1->SetLineColor(1);
 | 
					 | 
				
			||||||
  g1->SetLineWidth(1);
 | 
					 | 
				
			||||||
  g1->SetMarkerColor(1);
 | 
					 | 
				
			||||||
  g1->SetMarkerStyle(0);
 | 
					 | 
				
			||||||
  g1->SetTitle("Brownian Movement D=1");
 | 
					 | 
				
			||||||
  g1->GetYaxis()->SetTitle("X");
 | 
					 | 
				
			||||||
  g1->GetXaxis()->SetTitle("Time");
 | 
					 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  // for (unsigned int i = 0; i < t.size(); i++){
 | 
					  for(int i= 0; i < numRuns; i++)
 | 
				
			||||||
  for (unsigned int i = 0; i < n; i++){
 | 
					  { 
 | 
				
			||||||
    tl = t[i];
 | 
							g1 = new TGraph(nSteps,&t[i*nSteps],&x[i*nSteps]);
 | 
				
			||||||
    xl = x[i];
 | 
							
 | 
				
			||||||
    BM1DTree->Fill();
 | 
							g1->SetLineColor(i+1);
 | 
				
			||||||
 | 
							g1->SetTitle("Brownian Movement");
 | 
				
			||||||
 | 
							g1->GetYaxis()->SetTitle("X");
 | 
				
			||||||
 | 
							g1->GetXaxis()->SetTitle("Time");
 | 
				
			||||||
 | 
							g1->SetLineWidth(1);
 | 
				
			||||||
 | 
							g1->SetMarkerColor(1);
 | 
				
			||||||
 | 
							g1->SetMarkerStyle(1);
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
							mg -> Add(g1);	
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  g1->Write();
 | 
					  if(draw)
 | 
				
			||||||
  BM1DTree->Write();
 | 
					  {
 | 
				
			||||||
  fOut->Close();
 | 
							g1->Draw();
 | 
				
			||||||
  
 | 
							mg -> Draw();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue