void plot2(const char *armname = "North") { /* const int nfiles = 6; const char *fileId[] = { "Melynda", "Catherine", "MinJung", "None", "MuidSurvey", "MuidSurvey2" }; const int color[nfiles] = { 1,5,4,6,8,2}; const int style[nfiles] = { 8,4, 29,30, 21,25 }; */ const int nfiles = 5; const char *fileId[] = { "Melynda", "Catherine", "MuidSurvey", "MuidSurvey2", "VC" }; const int color[nfiles] = { 1,5,4,8,2}; const int style[nfiles] = { 8,4, 29, 21,25 }; /* const int nfiles = 3; const char *fileId[] = { "Melynda", "MuidSurvey", "MuidSurvey2" }; const int color[nfiles] = { 1,8,2}; const int style[nfiles] = { 8,21,25 }; */ int nbins = 30; float low = 150; float high = 450; TH1F *dg0_r[nfiles]; char id[100]; for (int ifile=0; ifileGetEntries() << endl; sprintf(id,"dg0%d",ifile); TProfile *dg0 = new TProfile(id,"sqrt(Tr0_DG0x**2+Tr0_DG0y**2) vs Momentum",nbins,low,high); sprintf(drawcmd,"sqrt(Tr0_DG0x**2+Tr0_DG0y**2):sqrt(muID_gap0_x0**2+muID_gap0_y0**2)>>%s",id); dg0->Reset(); dimuons->Draw(drawcmd,north_mut&&"sqrt(Tr0_px**2+Tr0_py**2+Tr0_pz**2)>4&&sqrt(Tr0_px**2+Tr0_py**2+Tr0_pz**2)<7&&(muID_gap0_x0>110&&muID_gap0_y0>20)","prof"); cout << " dg0 max " << dg0->GetMaximum() << endl; for (int ibin = 0; ibin<=dg0->GetNbinsX(); ibin++) { Stat_t cont = dg0->GetBinContent(ibin); Stat_t err = dg0->GetBinError(ibin); /* cout << " ibin " << ibin << " cont " << cont << " err " << err << endl; */ dg0_r[ifile]->SetBinContent(ibin, cont); dg0_r[ifile]->SetBinError(ibin, err); /* cont = dg0_r[ifile]->GetBinContent(ibin); err = dg0_r[ifile]->GetBinError(ibin); cout << " ibin " << ibin << " dg0_r cont " << cont << " dg0_r err " << err << endl; */ } cout << " dg0_r max " << dg0_r[ifile]->GetMaximum() << endl; dg0_r[ifile]->SetMarkerColor(color[ifile]); dg0_r[ifile]->SetMarkerStyle(style[ifile]); dg0_r[ifile]->SetMarkerSize(1.0); dg0_r[ifile]->SetLineColor(color[ifile]); if (dg0_r[ifile]->GetMaximum() > max) { max = dg0_r[ifile]->GetMaximum(); maxid = ifile; } if (dg0_r[ifile]->GetMinimum() < min) { min = dg0_r[ifile]->GetMinimum(); } } // plot the one with the maximum value first cout << " max " << max << " maxid " << maxid << endl; dg0_r[maxid]->GetYaxis()->SetTitle("sqrt(Tr0_DG0x**2+Tr0_DG0y**2)"); dg0_r[maxid]->GetXaxis()->SetTitle("sqrt(muID_gap0_x0**2+muID_gap0_y0**2)"); gStyle->SetOptStat(0); dg0_r[maxid]->SetMaximum(max*1.1); // dg0_r[maxid]->SetMinimum(min*0.9); dg0_r[maxid]->SetMinimum(0); dg0_r[maxid]->Draw("p"); // plot all on "same"; add to legend TLegend *leg = new TLegend(0.15,0.7,0.35,0.89); char text[100]; for (int ifile=0; ifileDraw("p same"); sprintf (text, "%s", fileId[ifile]); leg->AddEntry(dg0_r[ifile],text,"p"); } leg->Draw(); cout << " done " << endl; c1->Update(); c1->SaveAs("plot2.gif"); }