#include #include #include #include #include #include //#include #include #include #include #define PI 3.14159265 #include "TPad.h" #include "TFile.h" #include "TTree.h" #include "TChain.h" #include "TVirtualPad.h" #include "TProfile.h" #include "TH1.h" #include "TH2.h" #include "TF1.h" #include "TCanvas.h" #include "TRandom.h" #include "TStyle.h" #include "TMath.h" #include "TLatex.h" #include #include #include using namespace std; void test(){ char* position = new char[100]; double nth_v0; TFile *file_test = new TFile("test_file.root", "RECREATE"); TTree *tree_test = new TTree("tree_test", "tree_test"); tree_test->Branch("position", position, "position/C"); tree_test->Branch("nth_v0", &nth_v0, "nth_v0/D"); ifstream fin_test("test.txt", ios::in); while (fin_test.good()){ fin_test >> position >> nth_v0; cout << "position = " << position << "\t nth_v0 = " << nth_v0 << endl; tree_test->Fill(); } TCanvas *can_nv = new TCanvas("can_nv", "nv Calculation", 0, 0, 850, 650); can_nv->Divide(1, 1); can_nv->ToggleEditor(); can_nv->ToggleEventStatus(); can_nv->ToggleToolBar(); gStyle->SetOptStat(0); gStyle->SetPalette(1); gPad->SetFillColor(10); TH2F *pos_nthv0 = new TH2F("pos_nthv0", "nthv0 vs position", 4, 0, 4, 40, 710000, 950000); can_nv->cd(1); pos_nthv0->SetMarkerStyle(26); tree_test->Draw("nth_v0 : position >> pos_nthv0","",""); //tree_test->Draw("col"); }