From 23d23ef4662fa1606544a7289b4932b4375c562e Mon Sep 17 00:00:00 2001 From: David Baranyai Date: Thu, 2 Nov 2017 16:51:27 +0100 Subject: [PATCH] Initial version of BM1DOpen class --- include/BM1DOpen.hh | 41 +++++++++++++++ src/BM1DOpen.cc | 118 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 include/BM1DOpen.hh create mode 100644 src/BM1DOpen.cc diff --git a/include/BM1DOpen.hh b/include/BM1DOpen.hh new file mode 100644 index 0000000..361d683 --- /dev/null +++ b/include/BM1DOpen.hh @@ -0,0 +1,41 @@ +// Created by Baranyai David on 2017. 11. 02. + +#ifndef BM1DOpen_h +#define BM1DOpen_h 1 + +#include +#include +#include +#include + +#include "TROOT.h" +#include "TTree.h" +#include "TFile.h" + +class BM1DOpen { +public: + BM1DOpen(); + ~BM1DOpen(); + void OpenfromTree(const char* filename); + std::vector GetT(); + std::vector GetX(); + Double_t GetMu1(); + Double_t GetMu2(); + Double_t GetSigma1(); + Double_t GetSigma2(); + Double_t Getx1(); + Double_t Getx2(); + Int_t GetP0(); + Int_t GetP1(); + Int_t GetSteps(); + Int_t GetnRuns(); +private: + TFile* fIn; + TTree *T2, *T3; + Long64_t nentries; + std::vector t; + std::vector x; + Double_t InnerMean,ExternalMean,InnerSigma,ExternalSigma,tl,xl,x1,x2; + Double_t P0, P1, Steps, NumberofRuns,BottomLayer,UpperLayer; +}; +#endif diff --git a/src/BM1DOpen.cc b/src/BM1DOpen.cc new file mode 100644 index 0000000..7e2fde2 --- /dev/null +++ b/src/BM1DOpen.cc @@ -0,0 +1,118 @@ +// Created by Baranyai David on 2017. 11. 02. + +#include "BM1DOpen.hh" + +BM1DOpen::BM1DOpen() +{ + +} +BM1DOpen::~BM1DOpen() +{ + +} + + +void BM1DOpen::OpenfromTree(const char *filename) +{ + fIn = new TFile(filename,"READ"); + if (fIn->IsZombie()) + { + std::cout << "Error opening file" << std::endl; + exit(-1); + } + + T2 = (TTree*)fIn->Get("BM1DTree"); + T3 = (TTree*)fIn->Get("DataTree"); + + T2->SetBranchAddress("xl",&xl); + T2->SetBranchAddress("tl",&tl); + + T3->SetBranchAddress("P0",&P0); + T3->SetBranchAddress("P1",&P1); + T3->SetBranchAddress("Steps",&Steps); + T3->SetBranchAddress("NumberofRuns",&NumberofRuns); + T3->SetBranchAddress("BottomLayer",&BottomLayer); + T3->SetBranchAddress("UpperLayer",&UpperLayer); + T3->SetBranchAddress("InnerMean",&InnerMean); + T3->SetBranchAddress("ExternalMean",&ExternalMean); + T3->SetBranchAddress("InnerSigma",&InnerSigma); + T3->SetBranchAddress("ExternalSigma",&ExternalSigma); + + nentries = T2->GetEntries(); + + for (Long64_t i=0;iGetEntry(i); + t.push_back(tl); + x.push_back(xl); + } + + nentries = T3->GetEntries(); + for (Long64_t i=0;iGetEntry(i); + } + + fIn->Close(); + +} + +std::vector BM1DOpen::GetT() +{ + return t; +} + +std::vector BM1DOpen::GetX() +{ + return x; +} + +Double_t BM1DOpen::GetMu1() +{ + return InnerMean; +} + +Double_t BM1DOpen::GetMu2() +{ + return ExternalMean; +} + +Double_t BM1DOpen::GetSigma1() +{ + return InnerSigma; +} + +Double_t BM1DOpen::GetSigma2() +{ + return ExternalMean; +} + +Double_t BM1DOpen::Getx1() +{ + return BottomLayer; +} + +Double_t BM1DOpen::Getx2() +{ + return UpperLayer; +} + +Int_t BM1DOpen::GetP0() +{ + return (Int_t)P0; +} + +Int_t BM1DOpen::GetP1() +{ + return (Int_t)P1; +} + +Int_t BM1DOpen::GetSteps() +{ + return (Int_t)Steps; +} + +Int_t BM1DOpen::GetnRuns() +{ + return (Int_t)NumberofRuns; +}