---root---
rootファイルとして保存
hstore("~~~.root")
軸名を付ける
g1->Draw();
g1->GetXaxis()->SetTitle("X-Title");
g1->GetYaxis()->SetTitle("Y-Title");
テキストを挿入
root> TLatex* text = new TLatex(500,2400,"COMMENT")
// TLatex(x座標、y座標、挿入したいテキスト)
root> text->Draw()
entriesとかを消す
gStyle->SetOptStat(0)
Draw()
値を表示
yval()
積分値を表示
hh->Integral(0,32)
raw dataをcheck
root[] book(new TAlRawDataExample)
root[] push("~~.ridf")
root[] start()
root[] stop()
root[] ntp->StartViewer()
root[] ntp->Draw("det")
detが何に対応してるかはanaroot/include/segidlist.hhにかいてある
あとは
root[] ntp->Draw("val","det==4")
などとして調べる。
datファイルを読み込んでプロット
{
#include "<"fstream.h">"
const Int_t N=1017;
float ch[N], count[N];
ifstream data("nai/data137Cs.dat");
int i=0;
while(data >> ch[i] >> count[i] )
{cout<< ch[i]<<", "<< count[i] << endl; i++;}
TCanvas *c1 = new TCanvas("c1","c1",650,450);
TGraph *g =new TGraph(N,ch,count);
c1->cd();
g->Draw("AP*");
}
重ねてプロット
{
TFile *file1 = new TFile("test-rootfiles/CsI252Cf+Ni_Alnasirun109.root","readonly");
TFile *file2 = new TFile("test-rootfiles/CsI252Cfonlyrun111.root","readonly");
TH1* h1 = (TH1*)file1->Get("qdcval0");
TH1* h2 = (TH1*)file2->Get("qdcval0");
h1->Rebin(8x);
h2->Rebin(8x);
h1->Draw();
h2->SetLineColor(2);
h2->SetFillColor(2);
h2->Draw("same");
}
プロットを印刷
c1->Print()
.! lpr c1.ps
2つのrootファイルをくっつける
[ozaki@a01]$ hadd ~~~~.root(新しいの) ~~~~.root ~~~~.root
treeの中身を見る
tree->StartViewer
tree Draw
tree->Draw("y軸:x軸>>hh(~~,~~,~~,~~,~~,~~)","gate条件","colz")
2つプロット (anaroot)
~~~~->Draw()
zone(1,2)
ht(~~~,~~~)
Projection Y (anaroot)
ht(1とか)
pry(~~,~~)
gaussian fit (anaroot)
ht(1とか)
fitg(~~~,~~~)
いろいろ
void peaksumopt(Int_t HV){
float xmin=0;
float xmax=0;
cout << "start fit: HV = " << HV <<"V" << endl;
fetch(Form("PMTcheck/opticalpad/rootfiles/withopt_22Na_%dV.root",HV));
hh->Draw();
c1->Update();
cout << "xmin: , xmax: " << endl;
cin >> xmin >> xmax;
cout << "xmin="<< xmin << ", xmax=" << xmax << endl;
fit1g(hh,xmin,xmax);
// c1->Update();
// wait();
Int_t hbin = hh->GetBinWidth(1);
Double_t peaksum = (fitfunc->GetParameter(0))*(fitfunc->GetParameter(2))*sqrt(3.14)/hbin;
Double_t err = sqrt(pow(fitfunc->GetParError(0)/fitfunc->GetParameter(0),2) + pow(fitfunc->GetParError(2)/fitfunc->GetParameter(2),2));
Double_t peaksumer = peaksum * err;
cout << hbin <<", " << peaksum <<", " << peaksumer << ", "
<< fitfunc->GetParameter(1) << endl;
ofstream fout("./PMTcheck/opticalpad/result/fitcalc_withopt.txt"
, std::ios::app);
cout << HV <<", " << peaksum <<", " << peaksumer << ", "
<< fitfunc->GetParameter(1) << endl;
if(HV==1140){
fout << "HV" <<" " << "peaksum" <<" " << "error" << " " << "peakchannel"
<< endl;
}
fout << HV <<" " << peaksum <<" " << peaksumer << " "
<< fitfunc->GetParameter(1) << " "
<< fitfunc->GetParError(1) << endl;
fout.close();
}
void fit1g(TH1* hh, float xmin, float xmax){
cout << "Starting fit..." << endl;
Float_t ymin = hh->GetBinContent(hh->FindBin(xmin));
Float_t ymax = hh->GetBinContent(hh->FindBin(xmax));
double x[]={xmin, xmax};
double y[]={ymin, ymax};
cout << x[0] << ", " << x[1] << endl;
cout << y[0] << ", " << y[1] << endl;
TGraph* tg =new TGraph(2,x,y);
TF1 *exp = new TF1("exp","exp([0]+[1]*x)");
tg->Fit("exp","","",xmin-100,xmax+100);
cout << xmin << ", " << xmax << endl;
cout << ymin << ", " << ymax << endl;
cout << exp->GetParameter(0)<< ", " << exp->GetParameter(1)<< endl;
TF1* gausfunc1 = new TF1("gausfunc1","gaus");
gausfunc1->SetParameter(1,(xmin+xmax)/2.);
hh->Fit("gausfunc1","","",xmin,xmax);
TF1* fitfunc = new TF1("fitfunc","gaus(0)+expo(3)",xmin,xmax);
fitfunc->SetParameter(0,gausfunc1->GetParameter(0));
fitfunc->SetParameter(1,gausfunc1->GetParameter(1));
fitfunc->SetParLimits(1,gausfunc1->GetParameter(1)-100,
gausfunc1->GetParameter(1)+100);
fitfunc->SetParameter(2,gausfunc1->GetParameter(2));
fitfunc->SetParameter(3,exp->GetParameter(0));
fitfunc->SetParameter(4,exp->GetParameter(1));
hh->Fit("fitfunc","","",xmin,xmax);
}