%jsroot on
TCanvas *c1=new TCanvas("c1","c1");//创建画布
//声明branch变量
Double_t ctof,tof;
Int_t pid;
Double_t tu, td, x;
//打开root文件
TFile *ipf=new TFile("./tree.root");//打开ROOT文件
//得到tree的指针
TTree *tree=(TTree*)ipf->Get("tree");
//将tree中Branch与变量地址联系
tree->SetBranchAddress("ctof",&ctof);
tree->SetBranchAddress("tof",&tof);
tree->SetBranchAddress("pid",&pid);
tree->SetBranchAddress("tu",&tu);
tree->SetBranchAddress("td",&td);
tree->SetBranchAddress("x",&x);
tree->Draw("ctof>>(1000,20,120)");
c1->Draw();
tree->Draw("ctof:td-tu>>(2000,-20,50,50,40,45)","pid==0","colz");//加入条件,gamma
c1->Draw();
TH2D *hgtofx=new TH2D("hgtofx","hgtofx",100,-120,120,100,39,48);
TH1D *hgctof=new TH1D("hgctof","hgctof",100,39,48);//挑出打在探测器中心的gamma事件
TH2D *ctofvstx=new TH2D("ctofvstx","ctofvstx",240,-120,120,100,41,45);//挑出打在探测器全区域的gamma事件
//对事件进行遍历
Long64_t nentries=tree->GetEntries();
for(Long64_t jentry=0; jentry<nentries; jentry++)
{
tree->GetEntry(jentry);
Double_t tx=3.742*(td-tu-14.915); //时间差法刻度的位置
if(ctof>42&& ctof<44.5)
{
Double_t d=TMath::Sqrt(502.5*502.5+tx*tx);//考虑了探测器的厚度的飞行距离
Double_t ctofa=(ctof)/d*500.;//不同距离的tof统一修正到500 cm
hgtofx->Fill(tx,ctofa);
ctofvstx->Fill(tx,ctof);
if(abs(tx)<5) hgctof->Fill(ctof);//挑出打在探测器中心的事件
}
}
hgtofx->Draw("colz");
c1->Draw();
hgctof->Draw();
hgctof->Fit("gaus");
c1->Draw();
ctofvstx->Draw("colz");
ctofvstx->Fit("pol2");
c1->Draw();
虽然光在塑闪传播时间可根据模拟得到,但电子学、线缆、PMT导致的offset成分无法确定。
以光子打在探测器中心为标准,$TOF=d/c$,带入$d = 502.5 cm$,$c=3.0*10^{8} m/s$, 可得$TOF = 16.748~ns$;
TH2D *hgtofcx=new TH2D("hgtofcx","corrected TOF",100,-120,120,100,15,19);//实验测量抽取的tof修正到500 cm(考虑offset)与位置关联
TH2D *hgtofcx1=new TH2D("hgtofcx1","corrected TOF (all gamma)",100,-120,120,100,15,19);//实验测量抽取的tof修正到500 cm(考虑offset_all gamma)与位置关联
TH1D *htofc=new TH1D("htofc","htofc",200,0,100);//实验测量抽取的tof修正到500 cm,即考虑offset;
TH1D *htofc1=new TH1D("htofc1","htofc (all gamma)",200,0,100);//实验测量抽取的tof修正到500 cm,即考虑offset;
TH1D *htof=new TH1D("htof","htof",200,0,100);//模拟中真实的tof修正到500 cm
//Long64_t nentries=tree->GetEntries();
for(Long64_t jentry=0; jentry<nentries; jentry++) {
tree->GetEntry(jentry);
Double_t tx=3.742*(td-tu-14.915);
Double_t d=TMath::Sqrt(502.5*502.5+tx*tx);
Double_t tofc=(ctof-26.2096)/d*500.;//normalized to 500cm
Double_t C=d/30.-(42.9542+1.95083e-6*tx+3.20798e-5*tx*tx);
Double_t tofc1=(ctof+C)/d*500.;//normalized to 500cm by all gamma
hgtofcx->Fill(tx,tofc);//gamma hits the center of the det.
hgtofcx1->Fill(tx,tofc1);//gamma hits the any position of the det.
htofc->Fill(tofc);
htofc1->Fill(tofc1);
htof->Fill(tof*500./d);
}
hgtofcx->Draw("colz");//tofc与x之间无关联
c1->Draw();
c1->SetLogy();
htofc->Draw();//修正后的飞行时间谱
htof->SetLineColor(kRed);
htof->Draw("same");
c1->Draw();
实验测量抽取的tof修正到500 cm(考虑offset)与模拟中真实的tof修正到500 cm符合很好!
同上:
以光子打在探测器任意位置,$TOF(tx)=\frac{\sqrt{d^{2}+x^{2}}}{c}$,其中$d = 502.5~cm$,$c=3.0*10^{8}~ m/s=30~cm/ns$;
c1->SetLogy(0);
hgtofcx1->Draw("colz");//tofc1与x之间无关联
c1->Draw();
c1->SetLogy();
htofc1->Draw();//修正后的飞行时间谱
htof->SetLineColor(kRed);
htof->Draw("same");
c1->Draw();
ipf->Close();//关闭root文件
!jupyter nbconvert homework1.1-3 --to html