常用脚本参考
1.一个ROOT绘图脚本Draw.c(从TTree中读取数据,根据Cut条件画图)
{ string run; cout<<"please input runNO.:"; cin>>run; string rootfile_name; rootfile_name="./output_t/RUN_"+run+"_neutron.root"; TFile f1(rootfile_name.c_str()); cout<<"pleas in put draw choice"<<endl; cout<<"the canndidate are : py, px, py:px, tof*0.025, QX, QY, T0num, Qsum"<<endl; string choice; string cut; string rang; cin>>choice>>cut; if(choice=="py:px") rang="188,0,206.8,200,0,200"; else if(choice=="py") rang="200,0,200"; else if(choice=="px") rang="1880,0,206.8"; else if(choice=="tof*0.025") rang="40000,0,40000"; else if(choice=="T0num") rang="10000,0,10000"; else if(choice=="QX"||choice=="QY") rang="3000,0,3000"; else if(choice=="QX+QY") rang="5000,0,5000"; string drawp; drawp=choice+">>h1("+rang+")"; if(cut=="0") { cout<<"t->Draw("<<drawp.c_str()<<");h1->Draw();"<<endl; t->Draw(drawp.c_str()); } else { cout<<"t->Draw("<<drawp.c_str()<<","<<cut.c_str()<<");h1->Draw();"<<endl; t->Draw(drawp.c_str(),cut.c_str()); } h1->Draw(); }