Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
soft:root [2020/08/19 08:30] – [Auto code by TTree] Ce Zhang | soft:root [2023/05/24 09:51] (current) – [ROOT study] Ce Zhang | ||
---|---|---|---|
Line 1: | Line 1: | ||
=====ROOT study===== | =====ROOT study===== | ||
+ | ==== Divide ==== | ||
+ | < | ||
+ | hHitTime_Ratio[i] = new TH1F(*hHitTime_Num[i]); | ||
+ | hHitTime_Ratio[i]-> | ||
+ | hHitTime_Ratio[i]-> | ||
+ | </ | ||
+ | ==== Sub Canvas and Pads ==== | ||
+ | < | ||
+ | TCanvas *c1 = new TCanvas(“c1”, | ||
+ | c1-> | ||
+ | c1-> | ||
+ | |||
+ | TVirtualPad *c1_1 = c1-> | ||
+ | gPad-> | ||
+ | // enter the 4 sub-pads and do stuff | ||
+ | c1_1-> | ||
+ | (new TText(0.1, 0.5, “c1 … 1 … 1”))-> | ||
+ | c1_1-> | ||
+ | (new TText(0.1, 0.5, “c1 … 1 … 2”))-> | ||
+ | c1_1-> | ||
+ | (new TText(0.1, 0.5, “c1 … 1 … 3”))-> | ||
+ | c1_1-> | ||
+ | (new TText(0.1, 0.5, “c1 … 1 … 4”))-> | ||
+ | </ | ||
+ | |||
+ | ==== TF1 ==== | ||
+ | < | ||
+ | TF1 * fit1 = new TF1(" | ||
+ | fit1-> | ||
+ | f3-> | ||
+ | gStyle-> | ||
+ | </ | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | ==== Time ==== | ||
+ | |||
+ | TDatime | ||
+ | |||
+ | < | ||
+ | TDatime * Time = new TDatime(); | ||
+ | cout<< | ||
+ | // output: Fri Jul 30 09:56:02 2021 20210730 95602 | ||
+ | // ... | ||
+ | c1-> | ||
+ | </ | ||
+ | ==== Get max and mim from TGraph ==== | ||
+ | |||
+ | < | ||
+ | TMath:: | ||
+ | </ | ||
+ | |||
+ | ==== Draw his from saved .root file in TCanvas ==== | ||
+ | |||
+ | < | ||
+ | TFile f1(" | ||
+ | | ||
+ | | ||
+ | |||
+ | TFile f2(" | ||
+ | | ||
+ | TH1D *h1; | ||
+ | |||
+ | | ||
+ | TIter next(l); | ||
+ | | ||
+ | while ((obj=next())) { | ||
+ | if (obj-> | ||
+ | h1 = (TH1D*)obj; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | TFile *_file0 = TFile:: | ||
+ | TCanvas *c1 = (TCanvas*)_file0-> | ||
+ | TH1D *aee = (TH1D*)c1-> | ||
+ | |||
+ | </ | ||
+ | ====Reset (refresh) the histogram==== | ||
+ | |||
+ | < | ||
+ | hT-> | ||
+ | </ | ||
+ | [[https:// | ||
+ | |||
+ | ====Subdivide the Canvas==== | ||
+ | |||
+ | < | ||
+ | c-> | ||
+ | gPad-> | ||
+ | //then always … | ||
+ | c-> | ||
+ | gPad-> | ||
+ | |||
+ | //the first row to take 80% and 2nd row to take 20% of the space. | ||
+ | |||
+ | | ||
+ | | ||
+ | TPad *p1 = new TPad(" | ||
+ | | ||
+ | | ||
+ | TPad *p11 = (TPad*)p1-> | ||
+ | | ||
+ | | ||
+ | TPad *p12 = (TPad*)p1-> | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | TPad *p2 = new TPad(" | ||
+ | | ||
+ | | ||
+ | TPad *p21 = (TPad*)p2-> | ||
+ | | ||
+ | | ||
+ | TPad *p22 = (TPad*)p2-> | ||
+ | | ||
+ | | ||
+ | |||
+ | </ | ||
+ | |||
==== Auto code by TTree==== | ==== Auto code by TTree==== | ||
< | < | ||
Line 5: | Line 132: | ||
mytree.MakeClass(" | mytree.MakeClass(" | ||
</ | </ | ||
+ | |||
+ | This will generate mycode.h and mycode.C | ||
+ | |||
+ | My modification: | ||
+ | * Replace the initialization of TTree with TString | ||
+ | * Delete the inherit fChain(0) | ||
+ | * Add fIdentidier as the name of the file with out ' | ||
====TList==== | ====TList==== | ||
Line 25: | Line 159: | ||
</ | </ | ||
+ | ====TList (adding trees)==== | ||
+ | < | ||
+ | Tree* t1 = TxtToTree(...); | ||
+ | Tree* t2 = TxtToTree(...); | ||
+ | |||
+ | TList *list = new TList; | ||
+ | |||
+ | list-> | ||
+ | list-> | ||
+ | list-> | ||
+ | //... | ||
+ | | ||
+ | TTree *newtree = TTree:: | ||
+ | newtree-> | ||
+ | |||
+ | </ | ||
====TBox==== | ====TBox==== | ||
< | < | ||
Line 61: | Line 211: | ||
- | ====TList (adding trees)==== | ||
- | < | ||
- | Tree* t1 = TxtToTree(...); | ||
- | Tree* t2 = TxtToTree(...); | ||
- | |||
- | TList *list = new TList; | ||
- | list-> | ||
- | list-> | ||
- | list-> | ||
- | //... | ||
- | | ||
- | TTree *newtree = TTree:: | ||
- | newtree-> | ||
- | |||
- | </ | ||
====TCutG==== | ====TCutG==== |