void attachfile(char * runlist){ //1//chain file FILE *f1 = fopen(runlist,"rb"); char dummy[300]; int cnum=0; TChain *T = new TChain("T"); while( fscanf(f1,"%s", dummy)==1){ cout<Add(dummy); } fclose(f1); } void vdct0cardcheck(){ //void vdct0wire(char * runlist){ //extract from rawtdc //attachfile(runlist); TChain *T = new TChain("T"); T->Add("/taidisk/L_det/e07006_L_det_1231.root"); T->Add("/taidisk/L_det/e07006_L_det_1235.root"); T->Add("/taidisk/L_det/e07006_L_det_1236.root"); T->Add("/taidisk/L_det/e07006_L_det_1237.root"); T->Add("/taidisk/L_det/e07006_L_det_1241.root"); T->Add("/taidisk/L_det/e07006_L_det_1241_1.root"); T->Add("/taidisk/L_det/e07006_L_det_1241_2.root"); T->Add("/taidisk/L_det/e07006_L_det_1242.root"); T->Add("/taidisk/L_det/e07006_L_det_1243.root"); double const offsetCh = 1800; int const NBIN= 100; //200; int const DOM_MIN = 0; int const DOM_MAX = 400;//800; double binwidth = (DOM_MAX-DOM_MIN)/NBIN; int const WIRE = 368; int const ARM=1;//2 int const PLANE=4; char arm[ARM][10] = {"L"}; //{"L","R"}; char plane[PLANE][100] = {"u1","v1","u2","v2"}; TH1F *hist[ARM][PLANE][WIRE]; char hist_name[ARM][PLANE][WIRE][300]; char plot_var[ARM][PLANE][300]; char plot_wire[ARM][PLANE][300]; char select[ARM][PLANE][WIRE][300]; char plot_hist[ARM][PLANE][WIRE][300]; int temptest; TLine *bmax[ARM][PLANE][WIRE]; TLine *zero[ARM][PLANE][WIRE]; double offset[ARM][PLANE][WIRE]; for(int i=0;iGetXaxis()->SetTitle("TDC channel"); sprintf(plot_hist[i][j][l],"%s>>%s",plot_var[i][j],hist_name[i][j][l]); sprintf(select[i][j][l],"%s>=%d && %s<%d && DBB.evtypebits&(1<<3)",plot_wire[i][j],l,plot_wire[i][j],l+16); } } } int binmax,currentbin; double binmaxvalue,binmaxedge,halfbinwidth=0.5*binwidth; double x_maxslope; double slope, maxslope; //double aver=0; FILE *fin = fopen("t0card.dat","rb"); FILE *fpre = fopen("t0cardpre.dat","rb"); // fscanf(fin,"%d",&temptest); // fscanf(fin,"%lf",&x_maxslope); // fscanf(fpre,"%d",&temptest); // fscanf(fpre,"%lf",&maxslope); // return; if(1){/////// int section=0; int count=0; char canvas_name[300]; TCanvas *vdc[ARM][PLANE][WIRE/8+1]; for(int i=0;iDivide(2,4); } count++; //vdc[i][j][section]->cd(count); cout<Draw(plot_hist[i][j][l],select[i][j][l]); //maximum bin properties binmax = hist[i][j][l]->GetMaximumBin(); binmaxvalue = hist[i][j][l]->GetBinContent(binmax); // binmaxedge = hist[i][j][l]->GetBinLowEdge(binmax); // halfbinwidth = 0.5*(hist[i][j][l]->GetBinWidth(binmax)); // currentbin = binmax; // bmax[i][j][l] = new TLine(binmaxedge+halfbinwidth,0,binmaxedge+halfbinwidth,binmaxvalue); // bmax[i][j][l]->SetLineColor(kBlue); // bmax[i][j][l]->Draw("same"); //cout<<"bin max "<< binmax<< "has count "<0;k--){ // slope = hist[i][j][l]->GetBinContent(k) - hist[i][j][l]->GetBinContent(k-1); // if(slope>maxslope){ // maxslope = slope; // x_maxslope = hist[i][j][l]->GetBinLowEdge(k-1)+0.5*binwidth; // } // } fscanf(fin,"%d %lf",&temptest,&x_maxslope); fscanf(fpre,"%d %lf",&temptest,&offset[i][j][l]); x_maxslope = offsetCh - x_maxslope; offset[i][j][l] = offsetCh - offset[i][j][l]; //offset[i][j][l] = x_maxslope; //cout<<"max change "<< maxslope<<" at value " << x_maxslope<SetLineColor(kBlue); bmax[i][j][l]->Draw("same"); zero[i][j][l] = new TLine(offset[i][j][l],0,offset[i][j][l],binmaxvalue); zero[i][j][l]->SetLineColor(kRed); zero[i][j][l]->Draw("same"); // TLatex *txt = new TLatex();txt->SetNDC(); txt->SetTextSize(0.11); txt->SetTextColor(kRed); // char txtstring[300]; // sprintf(txtstring,"set t0 to %4.1lf",offsetCh-offset[i][j][l]); // txt->DrawLatex(0.3,0.7,txtstring); vdc[i][j][section]->Update(); if(l%8==7) vdc[i][j][section]->Print(Form("./timeplot/t0_vdc_card_%s%s%d.png",arm[i],plane[j],section)); } } } FILE *fw = fopen("t0card.dat","w"); for(int i=0;i