TRandom3 *r = new TRandom3(0);
Int_t ival;
Double_t val;
TFile *opf = new TFile("cal.root","recreate");
TTree *tree = new TTree("tree","tree");
tree->Branch("ival", &ival, "ival/I"); //raw ADC value
tree->Branch("val", &val, "val/D"); //with dithering
for(int i=0; i<50000; i++) {
ival = (int) r->Uniform(0,100);
val = ival + r->Uniform(0,1);//连续化
tree->Fill();
}
tree->Write();
opf->Close();
TFile *ipf = new TFile("cal.root");
TTree *tree = (TTree *)ipf->Get("tree");
tree->Draw("ival>>hraw(100,0,100)");
TH1D *hraw = (TH1D *)gROOT->FindObject("hraw");
hraw->SetMinimum(0);
c1->Draw();
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
tree->Draw("0.4*ival>>hcraw(40,0,40)");
TH1D *hcraw = (TH1D *)gROOT->FindObject("hcraw");
hcraw->SetMinimum(0);
c1->Draw();
tree->Draw("0.4*val>>hval(40,0,40)");
TH1D *hval = (TH1D *)gROOT->FindObject("hval");
hval->SetMinimum(0);
c1->Draw();
检查每一个实验参数的完整性,选择合适的变量计算方法。
只对有效值范围内的数据进行刻度,对有效值范围外的数据(如pedal以下或超界数据)设定与刻度值有明显区别的特定数值(如-1)。
run001.root
)外,将常用信息以histogram的格式存储在其他root文件(如hist001.root
)。这样可以快速查看感兴趣的参数。常用信息包括:
以目录结构存储不同类型的histogram
root -l mg18.root
root[0] new TBrowser
- 在左侧栏中双击文件名,在Draw Option栏中填入“colz”等绘图选项。
fout->cd();//fout为文件指针
TDirectoryFile *dir1= new TDirectoryFile("dir1","dir1");
TDirectoryFile *dir2= new TDirectoryFile("dir2","dir2");
dir1->cd();//fout为文件指针
TDirectoryFile *dir1sub= new TDirectoryFile("dir1sub","dir1sub");
TH1I *h0,*h1,*h2,*h1sub;
fout->cd(); h0=new TH1I();
dir1->cd(); h1=new TH1I();
dir2->cd(); h2=new TH1I();
dir1sub->cd(); h1sub=new TH1I();
h0->Fill();
...
fout->Write();
TFile *fout = new TFile("test1.root","recreate");
fout->cd();
//dir1 and dir2 are the top level directories in the root file
TDirectoryFile *dir1 = new TDirectoryFile("dir1","dir1");
TDirectoryFile *dir2 = new TDirectoryFile("dir2","dir2");
//create a sub-directory under dir1
dir1->cd();
TDirectoryFile *dir1sub = new TDirectoryFile("dir1sub","dir1sub");
//create histograms under each directory
TH1I *h0, *h1, *h2, *h1sub;
fout->cd();
h0 = new TH1I("h0","h0",100,-3,3);
dir1->cd();
h1 = new TH1I("h1","h1",100,-3,3);
dir1sub->cd();
h1sub = new TH1I("h1sub","h1sub",100,-3,3);
dir2->cd();
h2 = new TH1I("h2","h2",100,-3,3);
//fill histograms
h0->FillRandom("gaus",10000);
h1->FillRandom("gaus",10000);
h1sub->FillRandom("gaus",10000);
h2->FillRandom("gaus",10000);
//write to the file
fout->Write();
fout->Close();
root -l test1.root
>new TBrowser
在左边树形目录结构中找到文件,鼠标点击进入目录结构,点击相应hist
TFile *fin=new TFile("test1.root");
fin->ls();
TFile** test1.root TFile* test1.root KEY: TDirectoryFile dir1;1 dir1 KEY: TDirectoryFile dir2;1 dir2 KEY: TH1I h0;1 h0
TH1I* h0a=(TH1I*) fin->Get("h0");
TH1I* h1a=(TH1I*) fin->Get("dir1/h1");
TH1I* h2a=(TH1I*) fin->Get("dir2/h2");
TH1I* h1suba=(TH1I*) fin->Get("dir1/dir1sub/h1sub");
h1suba->Draw();
c1->Draw();
实验过程中由于探测器工作条件的变化(温度,噪声等)以及电子学参数的漂移,实验参数可能会随着时间变化。
在进行刻度和实验条件选取(cut)之前,必须确认参数是否随时间变化,并进行相应的修正。
观察实验参数随时间的变化:
下图显示某次实验中TDC值、位置探测器分辨、效率等参数随着文件号的变化。
第二阶段 包括实验物理量提取,物理分析等过程。 每个过程都涉及信息的整理和压缩,文件大小逐步减小,在内存中读入的时间越来越快。