void comp1(int R, int id, int MCdata ){ char fnam[128]; TCanvas *c1 = new TCanvas("c1", "TOF Efficiency", 1000, 800); if (id){ TFile *RF[3]; for (int k=0;k<3;k++){ int index = k*10+40; sprintf(fnam,"EFF/pos_eff_%02d_plots_run%06d.root", index, R); if (MCdata){ sprintf(fnam,"EFF/pos_eff_MC_%02d_plots_run%06d.root", index, R); } RF[k] = new TFile(fnam, "READ"); } for (int s=0; s<82; s++){ TGraphErrors *grX[3]; TGraphErrors *grY[3]; char grnam[128]; sprintf(grnam,"grXeff%02d",s); for (int k=0;k<3;k++){ grX[k] = (TGraphErrors*)RF[k]->Get(grnam); } sprintf(grnam,"grYeff%02d",s); for (int k=0;k<3;k++){ grY[k] = (TGraphErrors*)RF[k]->Get(grnam); } c1->Clear(); c1->Divide(1,2); c1->cd(1); TMultiGraph *mg2 = new TMultiGraph(); TLegend *leg2 = new TLegend(0.7,0.3, 0.85, 0.5); char str2[128]; for (int k=0;k<3;k++){ mg2->Add(grY[k]); grY[k]->SetMarkerColor(k+1); sprintf(str2,"Match Cut %02d",40+k*10); leg2->AddEntry(grY[k], str2, "ep"); } mg2->Draw("ap"); char t1[128]; sprintf(t1, "DATA =%5.1f",s*3.-123+1.5); if (MCdata){ sprintf(t1, "MC =%5.1f",s*3.-123+1.5); } mg2->SetTitle(t1); mg2->GetXaxis()->SetTitle("x-position [cm]"); mg2->GetYaxis()->SetTitle("TOF Match Efficiency"); leg2->Draw(); gPad->SetGrid(); gPad->Update(); c1->cd(2); TMultiGraph *mg1 = new TMultiGraph(); TLegend *leg1 = new TLegend(0.7,0.3, 0.85, 0.5); char str1[128]; for (int k=0;k<3;k++){ mg1->Add(grX[k]); grX[k]->SetMarkerColor(k+1); sprintf(str1,"Match Cut %02d",40+k*10); leg1->AddEntry(grX[k], str1, "ep"); } mg1->Draw("ap"); sprintf(t1, "DATA =%5.1f",s*3.-123+1.5); if (MCdata){ sprintf(t1, "MC =%5.1f",s*3.-123+1.5); } mg1->SetTitle(t1); mg1->GetXaxis()->SetTitle("y-position [cm]"); mg1->GetYaxis()->SetTitle("TOF Match Efficiency"); leg1->Draw(); gPad->SetGrid(); gPad->Update(); c1->SaveAs("tofpointmatch_MC_eff.pdf"); getchar(); } } else { int Rdata = 30735; for (int k=2;k<3;k++){ TFile *RF[2]; int index = k*10+40; sprintf(fnam,"EFF/pos_eff_%02d_plots_run%06d.root", index, Rdata); RF[0] = new TFile(fnam, "READ"); sprintf(fnam,"EFF/pos_eff_MC_%02d_plots_run%06d.root", index, R); RF[1] = new TFile(fnam, "READ"); for (int s=10; s<72; s++){ TGraphErrors *grX[2]; TGraphErrors *grY[2]; char grnam[128]; sprintf(grnam,"grXeff%02d",s); grX[0] = (TGraphErrors*)RF[0]->Get(grnam); sprintf(grnam,"grYeff%02d",s); grY[0] = (TGraphErrors*)RF[0]->Get(grnam); sprintf(grnam,"grXeff%02d",s); grX[1] = (TGraphErrors*)RF[1]->Get(grnam); sprintf(grnam,"grYeff%02d",s); grY[1] = (TGraphErrors*)RF[1]->Get(grnam); c1->Clear(); c1->Divide(1,2); c1->cd(1); TMultiGraph *mg1 = new TMultiGraph(); TLegend *leg1 = new TLegend(0.7,0.3, 0.85, 0.5); char str1[128]; mg1->Add(grY[0]); grY[0]->SetMarkerColor(1); sprintf(str1,"DATA Match Cut %02d",index); leg1->AddEntry(grY[0], str1, "ep"); mg1->Add(grY[1]); grY[1]->SetMarkerColor(2); sprintf(str1,"MC Match Cut %02d",index); leg1->AddEntry(grY[1], str1, "ep"); mg1->Draw("ap"); char t1[128]; sprintf(t1, "DATA/MC =%5.1f",s*3.-123+1.5); mg1->SetTitle(t1); mg1->GetXaxis()->SetTitle("x-position [cm]"); mg1->GetYaxis()->SetTitle("TOF Match Efficiency"); leg1->Draw(); gPad->SetGrid(); gPad->Update(); c1->cd(2); TMultiGraph *mg2 = new TMultiGraph(); TLegend *leg2 = new TLegend(0.7,0.3, 0.85, 0.5); char str2[128]; mg2->Add(grX[0]); grX[0]->SetMarkerColor(1); sprintf(str2,"DATA Match Cut %02d",index); leg2->AddEntry(grX[0], str2, "ep"); mg2->Add(grX[1]); grX[1]->SetMarkerColor(2); sprintf(str2,"MC Match Cut %02d",index); leg2->AddEntry(grX[1], str2, "ep"); mg2->Draw("ap"); char t2[128]; sprintf(t2, "DATA/MC =%5.1f",s*3.-123+1.5); mg2->SetTitle(t2); mg2->GetXaxis()->SetTitle("x-position [cm]"); mg2->GetYaxis()->SetTitle("TOF Match Efficiency"); leg2->Draw(); gPad->SetGrid(); gPad->Update(); c1->SaveAs("tofpointmatch_DATA_MC_eff.pdf"); getchar(); } } } }