#include "TFile.h" #include "TCanvas.h" #include "TStyle.h" #include "TH1.h" #include "TH2.h" #include "TH3.h" #include "TGaxis.h" #include "TRandom.h" #include "TLegend.h" #include "TPaveStats.h" #include "TGraph.h" #include "TSystem.h" #include "TTree.h" #include "TTreePlayer.h" #include "TF1.h" #include #include #include #include "TCut.h" float fillcolor=0.35; void deltakinene() { gStyle->SetOptStat(111110); TFile *fin = TFile::Open("B1/B1-build/B1.root"); fin->ls (); if (fin == 0) { printf("Error: cannot open the file!\n"); } else { TTree *t=0; TTree *te=0; fin->GetObject("B1Scintparticles",t); t->SetScanField(0); fin->GetObject("B1ScintOutparticles",te); te->SetScanField(0); TBranch *b = te->GetBranch("ScintParticleTrackEventID"); b->ls(); std::cout << "->" << b->GetName() << "<-\n"; std::cout << "->" << b->GetTitle() << "<-\n"; std::cout << "->" << b->GetFullName() << "<-\n"; TLeaf *l = (TLeaf*)b->GetListOfLeaves()->At(0); l->ls(); std::cout << "->" << l->GetName() << "<-\n"; std::cout << "->" << l->GetTitle() << "<-\n"; std::cout << "->" << l->GetFullName() << "<-\n"; //te->BuildIndex("ScintParticleTrackEventID.B1ScintOutparticles","ScintParticleParentID.B1ScintOutparticles"); te->BuildIndex("ScintParticleTrackEventID.ScintParticleTrackEventID","ScintParticleParentID.ScintParticleParentID"); t->AddFriend(te); TCanvas *c01 = new TCanvas("c01","",1280,1024); // c01->SetLogy(); t->SetLineColor(kBlue); TH1F *hene = new TH1F("hene", "", 100, 0., 0.); TString henestring = TString::Format("B1Scintparticles.ScintParticleKinEn-B1ScintOutparticles.ScintParticleKinEn>> hene"); t->Draw(henestring); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn hene->GetXaxis()->SetTitle("#DeltaKinetic Energy (MeV)"); hene->GetYaxis()->SetTitle("Counts"); hene->GetXaxis()->SetLabelFont(43); hene->GetXaxis()->SetLabelSize(30); hene->GetYaxis()->SetLabelFont(43); hene->GetYaxis()->SetLabelSize(30); hene->GetXaxis()->SetTitleFont(43); hene->GetXaxis()->SetTitleSize(30); hene->GetYaxis()->SetTitleFont(43); hene->GetYaxis()->SetTitleSize(30); hene->SetFillColorAlpha(kBlue, fillcolor); hene->SetName(" "); hene->SetStats(0); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn /*TLegend* leg = new TLegend(0.65, 0.7, .75, .75); leg->SetHeader("Legend"); leg->SetNColumns(1); leg->AddEntry(hene, "Data", "l"); leg->Draw();*/ gPad->Update(); /* TPaveStats *stats = (TPaveStats*)hene->GetListOfFunctions()->FindObject("stats"); stats->SetTextColor(kBlue); stats->SetX1NDC(0.80); stats->SetX2NDC(0.98); stats->SetY1NDC(0.77); stats->SetY2NDC(0.92);*/ gPad->Update(); c01->Print("DeltaKinEne.png"); delete c01; } }