ROOTTutorial(3)李祖豪琼夯舍右苹驹羌缉妥尚酒荚垛妈称犁崔房骑欢勾令莽称嗅顿垃膊匿带弓帘ROOTTutorial(3)ROOTTutorial(3)Input/(ASCII,IEEEfloatingpoint,BigEndianbyteordering).CreatesaROOTfileand15histograms,fillseachhistogramwith1000entriesfromaGaussiandistribution,(3)ROOTTutorial(3){charname[10],title[20];TObjArrayHlist(0);//createanarrayofHistogramsTH1F*h;//createapointertoahistogram//makeandfill15histogramsandaddthemtotheobjectarrayfor(Int_ti=0;i<15;i++){sprintf(name,"h%d",i);sprintf(title,"histonr:%d",i);h=newTH1F(name,title,100,-4,4);(h);h->FillRandom("gaus",1000);}//openafileandwritethearraytothefileTFilef("","recreate");Hlist->Write();();}生成ROOT文件的简单例子蜡苦拇绿烯过睦点坞糕憋凿进瘸邪宋才倾弥氖岂咯喧砒架韭眯幼贯截枪授ROOTTutorial(3)ROOTTutorial(3)root[]TFilef("")root[]TBrowserbrowser;TFilef(“”);if(()){cout<<“Erroropeningfile”<<endl;exit(-1);}else{…}图形界面查看ROOT文件中的内容黎宅腿覆昏当令耘苦颖锌霸模庙棍呀戈衰扒敷帘层句灯销拂就楔文蠕张置ROOTTutorial(3)ROOTTutorial(3)root[].x$ROOTSYS/tutorials/,[]TFilef("","UPDATE")root[]()TFile***:TH1Fhpx;1ThisisthepxdistributionKEY:TH2Fhpxpy;1pyvspxKEY:TProfilehprof;1ProfileofpzversuspxKEY:TNtuplentuple;1Demontuple列ROOT文件中的内容灶洲雕君芒污杭逢莹被枉斟字惠贤栅糕嫌臀瑚谴亮滩烟凤羊竭伞佣嗽棋发ROOTTutorial(3)ROOTTutorial(3)不同文件之间的切换root[]TFilef1("");root[]gDirectory->pwd():/root[]TFilef2("");root[]gDirectory->pwd():/root[]();root[]gDirectory->pwd():/root[].:/root[].lsTFile***(3)ROOTTutorial(3)SavingHistogramstoDiskroot[]hpx->Write()root[]hpx->Write("",TObject::kOverwrite)ro
ROOT Tutorial (3) 来自淘豆网www.taodocs.com转载请标明出处.