#include #include #include // std::cout #include // std::ifstream int DEBUG = 1; bool File_exists_test(char name[]) { struct stat buffer; return (stat (name , &buffer) == 0); } void effplt(){ char fnam[128]; float Ratios1[2][20][44]; float Ratios2[2][20][44]; float dRatios1[2][20][44]; float dRatios2[2][20][44]; int Counts[2][20][44]; int Norm[2][20][44]; int TheBin[2][20][44]; memset(Counts,0,2*20*44*4); memset(Norm,0,2*20*44*4); memset(TheBin,0,2*20*44*4); int dummy; float dummy1; int a,b,c; for (int j=10000; j<10500; j++){ // loop over all files and collect data sprintf(fnam,"VER03/tofeff_run%d.dat",j); //sprintf(fnam,"tofeff_run%d.dat",j); if (File_exists_test(fnam)){ ifstream INF(fnam); for (int n=0; n<2; n++){ // loop over both planes for (int k=0;k<20;k++){ // loop over momenta bins for (int xbin=0; xbin<44; xbin++){ // loop over paddles INF>>dummy >>dummy1 >>dummy >>dummy1 >>a>>b>>c; Counts[n][k][xbin] += a; Norm[n][k][xbin] += b; TheBin[n][k][xbin] +=c; } } } INF.close(); cout<<"."; } } cout<<"done"<0.){ e2 = TMath::Sqrt(e2); } else { e2 =0; } dRatios1[n][k][xbin] = e2; a = (float)TheBin[n][k][xbin]; Ratios2[n][k][xbin] = a/b; e2 = 1./b + a/b/b*(a/b - 1.); if (e2>0.){ e2 = TMath::Sqrt(e2); } else { e2 =0; } dRatios2[n][k][xbin] = e2; } TGraphErrors *graphs[2]; graphs[0] = new TGraphErrors(44, X, Ratios1[n][k], NULL, dRatios1[n][k]); graphs[0]->SetLineColor(2); graphs[0]->SetMarkerColor(2); graphs[0]->SetMarkerStyle(21); graphs[0]->SetMarkerSize(1.35); graphs[1] = new TGraphErrors(44, X, Ratios2[n][k], NULL, dRatios2[n][k]); graphs[1]->SetLineColor(4); graphs[1]->SetMarkerColor(4); graphs[1]->SetMarkerStyle(22); graphs[1]->SetMarkerSize(1.35); TMultiGraph *mgr = new TMultiGraph(); TLegend *leg = new TLegend(0.35,0.1,0.65,0.3); char legtit[128]; sprintf(legtit,"Track Momentum %4.1f GeV/c",k*0.5 + 0.5); leg->SetHeader(legtit); leg->AddEntry(graphs[0],"paddle #pm 1"); char t1[128]; sprintf(t1,"paddle only P%d",n); leg->AddEntry(graphs[1],t1); TLegendEntry *header = (TLegendEntry*)leg->GetListOfPrimitives()->First(); header->SetTextColor(2); header->SetTextSize(.033); TList *list = leg->GetListOfPrimitives(); TObject *First = leg->GetListOfPrimitives()->First(); header = (TLegendEntry*)list->After(First); header->SetTextSize(.025); mgr->Add(graphs[0]); mgr->Add(graphs[1]); mgr->Draw("LAP"); mgr->GetXaxis()->SetTitle("Paddle Number"); mgr->GetYaxis()->SetTitle("Efficinecy"); mgr->GetYaxis()->SetRangeUser(0.,1.); sprintf(t1,"Efficinecy Plane %d track p = %4.1f GeV/c",n,k*0.5 + 0.5); mgr->GetHistogram()->SetTitle(t1); gPad->SetGrid(); leg->Draw(); c1->Update(); char ht[128]; sprintf(ht,"efficiency_plane%d_momentum%04.1fGeV.pdf",n,k*0.5 + 0.5); c1->SaveAs(ht); sprintf(ht,"efficiency_plane%d_momentum%04.1fGeV.gif",n,k*0.5 + 0.5); c1->SaveAs(ht); getchar(); } } }