void vdct0plane(int runnumber,int cal=0,int out=0){ //extract from rawtdc // char root_dir[300] = "$ROOTFILES/2011-08-18/vdct0"; // TFile *file = new TFile(Form("%s/e07006_vdct0_%d.root",root_dir,runnumber)); char root_dir[300] = "/taidisk/L_det"; TFile *file = new TFile(Form("%s/e07006_L_det_%d.root",root_dir,runnumber)); TTree *T = (TTree*)file->Get("T"); cout<<"run "<GetEntries()<GetXaxis()->SetTitle("TDC channel"); sprintf(plot_hist[i][j],"%s>>%s",plot_var[i][j],hist_name[i][j]); } } int binmax,currentbin; double binmaxvalue,binmaxedge,halfbinwidth; double x_maxslope; double slope, maxslope; //double aver=0; //TCanvas *vdc = new TCanvas("vdc","vdc: t0 ",800,600); TCanvas *vdc = new TCanvas("vdc",Form("vdc: t0 : run %d",runnumber),800,600); vdc->Divide(2,4); for(int i=0;icd(i*PLANE+j+1); T->Draw(plot_hist[i][j],select); if(cal){/////// //calculate average background //maximum bin properties binmax = hist[i][j]->GetMaximumBin(); binmaxvalue = hist[i][j]->GetBinContent(binmax); binmaxedge = hist[i][j]->GetBinLowEdge(binmax); halfbinwidth = 0.5*(hist[i][j]->GetBinWidth(binmax)); currentbin = binmax; bmax[i][j] = new TLine(binmaxedge+halfbinwidth,0,binmaxedge+halfbinwidth,binmaxvalue); bmax[i][j]->SetLineColor(kBlue); bmax[i][j]->Draw("same"); //cout<<"bin max "<< binmax<< "has count "<0;k--){ slope = hist[i][j]->GetBinContent(k) - hist[i][j]->GetBinContent(k-1); if(slope>maxslope){ maxslope = slope; x_maxslope = hist[i][j]->GetBinLowEdge(k-1)+0.5*binwidth; } } offset[i][j] = x_maxslope; //cout<<"max change "<< maxslope<<" at value " << x_maxslope<SetLineColor(kRed); zero[i][j]->Draw("same"); TLatex *txt = new TLatex();txt->SetNDC(); txt->SetTextSize(0.11); txt->SetTextColor(kRed); char txtstring[300]; sprintf(txtstring,"adjust t_{0} to channel %4.1lf ",offsetCh-offset[i][j]); txt->DrawLatex(0.5,0.7,txtstring); }/////////if vdc->Update(); } } //vdc->Print(Form("/home/nmuangma/2011SRC/scripts/vdc_calibration/time_plots/tdc_%d.png",runnumber)); if(out){ //vdc->Print(Form("/home/nmuangma/2011SRC/scripts/vdc_calibration/time_plots/tdc_%d.png",runnumber)); //vdc->Print("./time_plots/t0_vdc_fromlist.png"); FILE *fw = fopen("/home/nmuangma/2011SRC/scripts/vdc_calibration/tdclist20110621.dat","a"); fprintf(fw,"run %4d ",runnumber); fprintf(fw,"entries %7d ",T->GetEntries()); for(int i=0;i