Created save function

This commit is contained in:
David Baranyai 2017-10-31 15:17:34 +01:00
parent a2509d6555
commit f849ad1f0a
2 changed files with 80 additions and 0 deletions

33
include/BM1DSave.hh Normal file
View File

@ -0,0 +1,33 @@
#ifndef BM1DSave_h
#define BM1DSave_h 1
#include <iostream>
#include <string>
#include <fstream>
#include <cmath>
#include "TROOT.h"
#include "TF1.h"
#include "TH1.h"
#include "TH2.h"
#include "TH3.h"
#include "TNtuple.h"
#include "TFile.h"
#include "TMath.h"
#include "TTree.h"
#include "TMultiGraph.h"
class BM1DSave {
public:
BM1DSave();
~BM1DSave();
void SaveToTree(TMultiGraph *mg, Int_t p0, Int_t p1, Int_t nSteps, Int_t nRuns, Double_t x1, Double_t x2, Double_t mu1, Double_t mu2, Double_t sigma1, Double_t sigma2, std::vector<Double_t> t, std::vector<Double_t> x);
private:
TFile* fOut;
TTree *BM1DTree;
TTree *DataTree;
Double_t tl,xl;
};
#endif

47
src/BM1DSave.cc Normal file
View File

@ -0,0 +1,47 @@
#include "BM1DSave.hh"
BM1DSave::BM1DSave()
{
}
BM1DSave::~BM1DSave()
{
}
void BM1DSave::SaveToTree(TMultiGraph *mg, Int_t p0, Int_t p1, Int_t nSteps, Int_t nRuns, Double_t x1, Double_t x2, Double_t mu1, Double_t mu2, Double_t sigma1, Double_t sigma2, std::vector<Double_t> t, std::vector<Double_t> x)
{
fOut = new TFile("result.root", "RECREATE");
TTree *BM1DTree = new TTree("BM1DTree","BM1DTree");
TTree *DataTree = new TTree("DataTree","DataTree");
BM1DTree->Branch("tl",&tl, "tl/D");
BM1DTree->Branch("xl",&xl, "xl/D");
DataTree->Branch("P0", &p0, "p0/D");
DataTree->Branch("P1", &p1, "p1/D");
DataTree->Branch("Steps", &nSteps, "nSteps/D");
DataTree->Branch("NumberofRuns", &nRuns, "nRuns/D");
DataTree->Branch("BottomLayer", &x1, "x1/D");
DataTree->Branch("UpperLayer", &x2, "x2/D");
DataTree->Branch("InnerMean", &mu1, "mu1/D");
DataTree->Branch("ExternalMean", &mu2, "mu2/D");
DataTree->Branch("InnerSigma", &sigma1, "sigma1/D");
DataTree->Branch("ExternalSigma", &sigma2, "sigma2/D");
DataTree->Fill();
mg->Write();
for (int i = 0; i < nSteps*nRuns; i++)
{
tl = t[i];
xl = x[i];
BM1DTree->Fill();
}
BM1DTree->Write();
DataTree->Write();
fOut->Close();
}