This is an old revision of the document!
ROOT study
TList
TList* glist = new TList(); glist->Add(g1); glist->Add(g2); file_out->Add(glist);
TList *list = f1->GetListOfKeys(); for (Int_t i=0;i<list->GetEntries();++i){ TKey *key = (TKey*)list->At(i); TString name = key->GetName(); TObject *o1 = f1->Get(name.Data()); TString cname(o1->ClassName()); if (!cname.Contains("TH1")) continue; }
TBox
TBox * b = new TBox(-25,-20,25,20); //b->SetFillStyle(3003); b->SetFillColorAlpha(10,0.0); b->SetLineStyle(1); b->SetLineColor(2); b->SetLineWidth(10); b->Draw();
External shell command
.!ls .! mv abc.txt def.txt gSystem->Exec(“ls”); gROOT->ProcessLine(Form(".!mkdir %s",filename.Data())); gROOT->Macro("rootlogon.C");
Vector in branch
std::vector<Double_t>* DiffusionVertexX; tree->Branch("DiffusionVertexX", "vector<Double_t>", &DiffusionVertexX);
TChain
TChain should be created in advance of files to be added.
TChain * tree = new TChain("tree","tree"); tree->Add("/home/had/zhangce/g-2/MuYield/Root/MuYield_statistic_compain_1.root"); //...
TList (adding trees)
Tree* t1 = TxtToTree(...); Tree* t2 = TxtToTree(...); TList *list = new TList; list->Add(t1); list->Add(t2); list->Add(t3); //... TTree *newtree = TTree::MergeTrees(list); newtree->SetName("newtree");
TCutG
build a circle cut:
const Int_t n = 30; Double_t x[n+1],y[n+1]; Double_t rcut = 21; Double_t dphi = TMath::TwoPi()/n; for (Int_t i=0;i<n;i++) { x[i] = rcut*TMath::Cos(i*dphi); y[i] = rcut*TMath::Sin(i*dphi); } x[n] = x[0]; y[n] = y[0]; TCutG *mcpcut = new TCutG("mcpcut",n+1,x,y);