Draw(); pad2->Draw(); pad1->cd(); Souřadnicové systémy ● uživatelský ● normalizovaný ● bodový CanvasDivision.C">

Prezentace se nahrává, počkejte prosím

Prezentace se nahrává, počkejte prosím

ROOT – 2. přednáška a cvičení Jiří Chudoba, 7.3.2012.

Podobné prezentace


Prezentace na téma: "ROOT – 2. přednáška a cvičení Jiří Chudoba, 7.3.2012."— Transkript prezentace:

1 ROOT – 2. přednáška a cvičení Jiří Chudoba,

2 Osnova ● TCanvas a TPad ● Fitování ● Skripty ● TTree

3 TCanvas a TPad TCanvas *c1 = new TCanvas("c1","Histograms",10,10,800,600); TPad *pad1 = new TPad("pad1","pad1",.02,.52,.98,.98,2); TPad *pad2 = new TPad("pad2","pad2",.02,.02,.98,.48,3); pad1->Draw(); pad2->Draw(); pad1->cd(); Souřadnicové systémy ● uživatelský ● normalizovaný ● bodový CanvasDivision.C

4 9/29/2016ROOT Day 2, Suzanne Panacek4 TCanvas a TPad - cvičení Vytvořte TCanvas, který bude rozdělen na 3 TPad – jeden v horní polovině a 2 v dolní polovině:

5 9/29/2016ROOT Day 2, Suzanne Panacek5 TCanvas a TPad – řešení cvičení TCanvas *c1 = new TCanvas("c1","Histograms",10,10,800,600); TPad *pad1 = new TPad("pad1","pad1",.02,.52,.98,.98,1); TPad *pad2 = new TPad("pad2","pad2",.02,.02,.48,.48,2); TPad *pad3 = new TPad("pad3","pad3",.52,.02,.98,.48,3); pad1->Draw(); pad2->Draw(); pad3->Draw(); Možno též rozdělit pomocí pad1->Divide() nebo přes menu vyvolané klikem na pravé tlačítko myši TPad *pad1_1 = (TPad*) pad1->GetPrimitive("pad1_1") pad1_1->cd(); ● transparetní pad ● přidávání grafických objektů

6 9/29/2016ROOT Day 2, Suzanne Panacek6 Fitování wget cd fits f = TFile("histogram.root").ls hist1->Draw(); hist2->Draw(); TF1 func("user","gaus(0)+gaus(3)"); func.SetParameters(5.,5.,1.,1.,10.,1.) func.SetParameters(5.,2.,1.,1.,10.,1.) Příklady podle Billa Seligmana, viz

7 9/29/2016ROOT Day 2, Suzanne Panacek7 Writing Scripts ● Named and Un-named Scripts ● Debugging ● ACLiC

8 9/29/2016ROOT Day 2, Suzanne Panacek8 Scripts Un-named Script Start with "{" and end with "}" All variables are in the global scope No class definitions No function declarations No parameters Named Script C++ functions Scope rules follow standard C++ Function with the same name as the file is executed with a.x Parameters Class definitions (derived from a compiled class at your own risk)

9 9/29/2016ROOT Day 2, Suzanne Panacek9 Scripts Examples ● Un-named Script: hello.C { cout << "Hello" << endl; } ● Named Script:say.C void say(char * what = "Hello") { cout << what << endl; } ● Executing the Named Script root [3].x say.C Hello root [4].x say.C("Hi there") Hi there

10 9/29/2016ROOT Day 2, Suzanne Panacek10 Resetting the Environment ● gROOT->Reset() – Calls destructors of all objects created on the stack – Objects on Heap are not deleted, but pointer variable is disassociated

11 9/29/2016ROOT Day 2, Suzanne Panacek11 Debugging: Stepping.s set the step mode to step into function.S set the step mode to go over function or loop.e continue to end of the function.c continue to next breakpoint.c 45 continue to line 45.p print the value of var

12 9/29/2016ROOT Day 2, Suzanne Panacek12 Debugging: Breakpoints.trace MyClass prints the executing code to window.deltrace MyClass removes the trace.break MyClass breaks at each method of MyClass.delbreak MyClass removes the break.b 34 sets a break point at line 34.db 34 removes the break point at line 34

13 9/29/2016ROOT Day 2, Suzanne Panacek13 Debugging: Inspecting DrawClass() Graphic list of methods including ancestors Inspect() Draw the current contents of an object Dump() Lists the current contents of an object gDebug = 1 Prints debugging information

14 9/29/2016ROOT Day 2, Suzanne Panacek14 Tracking Memory Leaks ● Counting Objects and Memory use – In the.rootrc or system.rootrc file: Root.MemStat: 1 Root.ObjectStat:1 ● Print the Object count and Memory use gObjectTable->Print();

15 9/29/2016ROOT Day 2, Suzanne Panacek15 Tracking Memory Leaks+ ● Example output: Before.x FirstContour.C: count on heap size total size heap size Total: 1,079 1,046 3,160 49,992 45,824 After: Total: 1,783 1,749 17, , ,568 ● Put gObjectTable->Print() before and after code segment in your script to find memory leaks.

16 9/29/2016ROOT Day 2, Suzanne Panacek16 ACLiC: Automatic Compiler of Libraries for CINT ● Use an external compiler to create a shared library from a macro. ● Use root [0].L MyMacro.C++ Always recompile root [0].L MyMacro.C+ Recompile as needed

17 9/29/2016ROOT Day 2, Suzanne Panacek17 ACLiC Use Restriction: can not use path name with.L.L../root_base/MyMacro.C+ Instead do: gSystem->cd("../directory"); gSystem->CompileMacro("MyMacro.C") Options are: k : keep the shared library after the session end. f : force recompilation. To set the Include path:.include "-I$HOME/mypackage/include";

18 9/29/2016ROOT Day 2, Suzanne Panacek18 ACLiC Advantages Advantages : syntax checking about five times faster full C++ feature set Disadvantage: On KCC, you can load each C++ shared library only once

19 9/29/2016ROOT Day 2, Suzanne Panacek19 Cvičení - ACLIC wget cvut/root-2/hrandom.c.x hrandom.c.L hrandom.c+

20 9/29/2016ROOT Day 2, Suzanne Panacek20 TTree Převzato od Billa Seligmana ● wget TFile f("tree.root","recreate"); TTree* t1 = new TTree("tree1","Reconstruction ntuple"); t1->Branch("event",&event,"event/I"); t1->Branch("ebeam",&ebeam,"ebeam/F"); t1->Branch("px",&px,"px/F"); spusťte macro ukončete ROOT a znovu ho spusťte TFile myFile(“tree.root”); tree1->Scan(); tree1->Print(); tree1->Draw(“ebeam”);

21 9/29/2016ROOT Day 2, Suzanne Panacek21 TTree - pokračování tree1->Draw(“ebeam:px”) tree1->Draw(“px:py:pz”) tree1->Draw(“zv”,”zv<20”) tree1->Draw(“ebeam”,”px > 10 && zv < 20”) tree1->MakeClass(“Analyze”).q Analyze.C, Analyze.h cp Analyze.C AnalyzeH.C editujte:

22 9/29/2016ROOT Day 2, Suzanne Panacek22 MakeClass SETUP: TH1* chi2Hist = new TH1F("chi2","Histogram of Chi2",100,0,20); chi2Hist->GetXaxis()->SetTitle("chi2"); chi2Hist->GetYaxis()->SetTitle("number of events"); LOOP: chi2Hist->Fill(chi2); KONEC: chi2Hist->Draw();.L AnalyzeH.C Analyze a a.Loop()

23 9/29/2016ROOT Day 2, Suzanne Panacek23 Cvičení 1. Přidejte histogram s p_T: Float_t pt = TMath::Sqrt(px*px+py*py) porovnejte s ttree->Draw 2. Vytvořte gif obrázek se 3 histogramy: ● pT pro všechny případy ● pT pro případy s abs(py) > 8. ● pT pro případy s abs(py) < 1. ● Porovnejte pomoci DrawNormalized(“same”) a pošlete mailem na


Stáhnout ppt "ROOT – 2. přednáška a cvičení Jiří Chudoba, 7.3.2012."

Podobné prezentace


Reklamy Google