From f849ad1f0a3c83b98ec1b314be015cd7e6501f4a Mon Sep 17 00:00:00 2001 From: David Baranyai Date: Tue, 31 Oct 2017 15:17:34 +0100 Subject: [PATCH] Created save function --- include/BM1DSave.hh | 33 +++++++++++++++++++++++++++++++ src/BM1DSave.cc | 47 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 include/BM1DSave.hh create mode 100644 src/BM1DSave.cc diff --git a/include/BM1DSave.hh b/include/BM1DSave.hh new file mode 100644 index 0000000..fd31976 --- /dev/null +++ b/include/BM1DSave.hh @@ -0,0 +1,33 @@ +#ifndef BM1DSave_h +#define BM1DSave_h 1 + +#include +#include +#include +#include + +#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 t, std::vector x); +private: + TFile* fOut; + + TTree *BM1DTree; + TTree *DataTree; + + Double_t tl,xl; +}; +#endif \ No newline at end of file diff --git a/src/BM1DSave.cc b/src/BM1DSave.cc new file mode 100644 index 0000000..b1d21f4 --- /dev/null +++ b/src/BM1DSave.cc @@ -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 t, std::vector 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(); + +} \ No newline at end of file