Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:13:11

0001 #include <TH2D.h>
0002 #include <TFile.h>
0003 #include <TF1.h>
0004 #include <TF2.h>
0005 #include <TGraph.h>
0006 #include  <TCanvas.h>
0007 #include <TROOT.h>
0008 #include <TStyle.h>
0009 #include <TLegend.h>
0010 #include <TLatex.h>
0011 #include <TLine.h>
0012 #include <TColor.h>
0013 
0014 #include "sPhenixStyle.C"
0015 
0016 void plot_comparisons_purity()
0017 {
0018 
0019   SetsPhenixStyle();
0020 
0021   /*
0022   gROOT->SetStyle("Plain");
0023   gStyle->SetOptStat(0);
0024   gStyle->SetOptFit(0);
0025   gStyle->SetOptTitle(0);
0026   */
0027 
0028   bool toymodel = false;
0029 
0030   static const int NPLOTS = 2;
0031   double hptmax = 40.0;
0032 
0033   TFile *fin[NPLOTS];
0034 
0035   char label[NPLOTS][500]; 
0036 
0037 
0038   //fin[0] = new TFile("root_files/mar1_100pions_1ups_look_purity_out.root");  
0039  
0040 
0041 
0042 
0043   /*
0044   fin[0] = new TFile("root_files/mar1_100pions_1ups_look_purity_out.root");  
0045   fin[1] = new TFile("root_files/mar3_100pions_nomvtx_primvtxfit_look_purity_out.root");  
0046   sprintf(label[0], "100 pions only");
0047   sprintf(label[1], "100 pions only, no MVTX");
0048   */
0049 
0050   fin[0] = new TFile("root_files/look_purity_out_100pions_80ns_baseline_noMVTX.root");  
0051   fin[1] = new TFile("root_files/look_purity_out_central_167khz_80ns_1-5");  
0052   sprintf(label[0], "100pions");
0053   sprintf(label[1], "Central+store average lumi+100pions");
0054 
0055 
0056 
0057    
0058  
0059   TGraph *gdca[NPLOTS];
0060   TGraph *gdcaZ[NPLOTS];
0061   TGraph *geff[NPLOTS];
0062   TGraph *grdpt[NPLOTS];
0063 
0064   int col[3] = {kRed, kBlue, kBlack};
0065 
0066   for(int i=0;i<NPLOTS;i++)
0067     {
0068       if(!fin[i])
0069     {
0070       cout << "Did not find file " << i << "  quit!" << endl;
0071       exit(1);
0072     }
0073 
0074       fin[i]->GetObject("single_track_efficiency",geff[i]);
0075       fin[i]->GetObject("dca2d_resolution",gdca[i]);
0076       fin[i]->GetObject("dcaZ_resolution",gdcaZ[i]);
0077       fin[i]->GetObject("pt_resolution",grdpt[i]);
0078       
0079       if(!geff[i])
0080     {
0081       cout << "Failed to find geff for " << i  << endl;
0082       //exit(1);
0083     }
0084 
0085       if(!gdca[i])
0086     {
0087       cout << "Failed to find gdca for " << i  << endl;
0088       exit(1);
0089     }
0090       if(!gdcaZ[i])
0091     {
0092       cout << "Failed to find gdcaZ for " << i  << endl;
0093       exit(1);
0094     }
0095       if(!grdpt[i])
0096     {
0097       cout << "Failed to find grdpt for " << i  << endl;
0098       exit(1);
0099     }
0100     }
0101 
0102 
0103   char lab[500];
0104   //sprintf(lab,"Au+Au HIJING b=0-12 fm, 100 kHz pileup");
0105   //sprintf(lab,"Au+Au HIJING b=0-12 fm");
0106   sprintf(lab,"100 pion events");
0107   
0108   
0109   TCanvas *ceff = new TCanvas("ceff","ceff",50,50,800,800);
0110   //ceff->SetLeftMargin(0.12);
0111   
0112   TH1F *hd = new TH1F("hd","hd",100, 0.0, hptmax);
0113   hd->SetMinimum(0.0);
0114   hd->SetMaximum(1.1);
0115   hd->GetXaxis()->SetTitle("p_{T} (GeV/c)");
0116   hd->GetXaxis()->SetTitleOffset(1.15);
0117   hd->GetYaxis()->SetTitle("Single track efficiency");
0118   hd->GetYaxis()->SetTitleOffset(1.3);
0119   hd->Draw();
0120   
0121   for(int i=0;i<NPLOTS;i++)
0122     {
0123       geff[i]->SetMarkerColor(col[i]);
0124       
0125       if(i==0)
0126     geff[i]->Draw("p");
0127       else
0128     geff[i]->Draw("same p");
0129     }
0130   
0131   TLegend *lpd = new TLegend(0.30, 0.45, 0.95, 0.65, "", "NDC");
0132   lpd->SetBorderSize(0);
0133   lpd->SetFillColor(0);
0134   lpd->SetFillStyle(0);
0135   for(int i=0;i<NPLOTS;i++)
0136     {
0137       lpd->AddEntry(geff[i],label[i], "p");
0138     }
0139   lpd->Draw();
0140 
0141   TLine *unit = new TLine(0,1.0,40,1.0);
0142   unit->SetLineStyle(3);
0143   unit->SetLineWidth(1);
0144   unit->Draw();
0145 
0146   //for(int i=0;i<2;i++)
0147   //lmax[i]->Draw();
0148   
0149   TCanvas *cdca = new TCanvas("cdca","cdca",50,50,800,800);
0150   //cdca->SetLeftMargin(0.15);
0151   
0152   
0153   TH1F *hdca = new TH1F("hdca","hdca",100, 0.0, hptmax);
0154   hdca->SetMinimum(0.0003);
0155   hdca->SetMaximum(0.02);
0156   hdca->GetXaxis()->SetTitle("p_{T} (GeV/c)");
0157   hdca->GetXaxis()->SetTitleOffset(1.25);
0158   hdca->GetYaxis()->SetTitle("DCA(r#phi) resolution (cm)");
0159   hdca->GetYaxis()->SetTitleOffset(1.4);
0160   hdca->Draw();
0161   
0162   gPad->SetLogy(1);
0163   
0164   for(int i=0;i<NPLOTS;i++)
0165     {
0166       gdca[i]->SetMarkerColor(col[i]);
0167       
0168       if(i==0)
0169     gdca[i]->Draw("p");
0170       else
0171     gdca[i]->Draw("same p");
0172     }
0173   
0174   TLegend *lpd1 = new TLegend(0.30, 0.7, 0.95, 0.92, "", "NDC");
0175   lpd1->SetBorderSize(0);
0176   lpd1->SetFillColor(0);
0177   lpd1->SetFillStyle(0);
0178   for(int i=0;i<NPLOTS;i++)
0179     {
0180       lpd1->AddEntry(gdca[i],label[i], "p");
0181     }
0182 
0183   lpd1->Draw();
0184   
0185   TCanvas *cdcaz = new TCanvas("cdcaz","cdcaz",50,50,800,800);
0186   //cdcaz->SetLeftMargin(0.15);
0187   
0188   TH1F *hdcaz = new TH1F("hdcaz","hdcaz",100, 0.0, hptmax);
0189   hdcaz->SetMinimum(0.0003);
0190   hdcaz->SetMaximum(0.02);
0191   hdcaz->GetXaxis()->SetTitle("p_{T} (GeV/c)");
0192   hdcaz->GetXaxis()->SetTitleOffset(1.25);
0193   hdcaz->GetYaxis()->SetTitle("DCA(Z) resolution (cm)");
0194   hdcaz->GetYaxis()->SetTitleOffset(1.4);
0195   hdcaz->Draw();
0196   
0197   gPad->SetLogy(1);
0198   
0199   for(int i=0;i<NPLOTS;i++)
0200     {
0201       gdcaZ[i]->SetMarkerColor(col[i]);
0202       
0203       if(i==0)
0204     gdcaZ[i]->Draw("p");
0205       else
0206     gdcaZ[i]->Draw("same p");
0207     }
0208   
0209   TLegend *lpd1z = new TLegend(0.30, 0.70, 0.95, 0.92, "", "NDC");
0210   lpd1z->SetBorderSize(0);
0211   lpd1z->SetFillColor(0);
0212   lpd1z->SetFillStyle(0);
0213   lpd1z->AddEntry(geff[0],label[0], "p");
0214   lpd1z->AddEntry(geff[1], label[1], "p");
0215   lpd1z->Draw();
0216 
0217 
0218   double hdptmax = 40.0;
0219   //double hdptmax = 39.0;
0220    
0221   TCanvas *crdpt = new TCanvas("crdpt","crdpt",50,50,800,800);
0222   //crdpt->SetLeftMargin(0.15);
0223   
0224   TH1F *hrdpt = new TH1F("hrdpt","hrdpt",100, 0.0, hdptmax);
0225   hrdpt->SetMinimum(0.0);
0226   hrdpt->SetMaximum(0.11);
0227   hrdpt->GetXaxis()->SetTitle("p_{T} (GeV/c)");
0228   hrdpt->GetXaxis()->SetTitleOffset(1.25);
0229   hrdpt->GetYaxis()->SetTitle("#Delta p_{T} / p_{T}");
0230   hrdpt->GetYaxis()->SetTitleOffset(1.5);
0231   hrdpt->Draw();
0232   
0233   for(int i=0;i<NPLOTS;i++)
0234     {
0235       grdpt[i]->SetMarkerColor(col[i]);
0236 
0237       if(i==0)
0238     grdpt[i]->Draw("p");
0239       else
0240     grdpt[i]->Draw("same p");
0241     }
0242 
0243   TLegend *lpd2 = new TLegend(0.15, 0.72, 0.85, 0.87, "", "NDC");
0244   lpd2->SetBorderSize(0);
0245   lpd2->SetFillColor(0);
0246   lpd2->SetFillStyle(0);
0247   lpd2->AddEntry(grdpt[0], label[0], "p");
0248   lpd2->AddEntry(grdpt[1], label[1], "p");
0249   lpd2->Draw();
0250 
0251   /*
0252   // draw the ratio of momentum resolution histograms
0253 
0254   TCanvas *cdptratio = new TCanvas("cdptratio","cdptratio",50,50,800,600);
0255   //cdptratio->SetLeftMargin(0.15);
0256 
0257   TH1F *hdptratio = new TH1F("hdptratio","hdptratio",100, 0.0, hptmax);
0258   hdptratio->SetMinimum(0.8);
0259   hdptratio->SetMaximum(1.4);
0260   hdptratio->GetXaxis()->SetTitle("p_{T} (GeV/c)");
0261   hdptratio->GetXaxis()->SetTitleOffset(1.15);
0262   hdptratio->GetYaxis()->SetTitle("#Delta p_{T} ratio");
0263   hdptratio->GetYaxis()->SetTitleOffset(1.8);
0264   hdptratio->Draw();
0265 
0266   int N = grdpt[0]->GetN();
0267   int N2 = grdpt[1]->GetN();
0268   cout << "grdpt[0] has " << N << " points, " << " grdpt[1] has " << N2 <<  " points" << endl;
0269 
0270   TGraph *gratio = new TGraph(N-1);
0271   gratio->SetMarkerStyle(20);
0272   gratio->SetMarkerSize(1);
0273   for(int i=0;i<N-1;i++)
0274     {
0275       double x1 = 0;
0276       double y1=0;
0277       grdpt[0]->GetPoint(i, x1, y1);
0278       double x2 = 0;
0279       double y2=0;
0280       grdpt[1]->GetPoint(i, x2, y2);
0281       double ratio = y2/y1;
0282       gratio->SetPoint(i,x1,ratio);
0283     }
0284 
0285   gratio->Draw("p");  
0286   */
0287 
0288   /*
0289 
0290   // now the upsilon spectra
0291 
0292   TFile *fin_ups[NPLOTS_UPS];
0293 
0294   fin_ups[0] = new TFile("look_quarkonia_histos_2mpas+4maps_out.root");  
0295   fin_ups[1] = new TFile("look_quarkonia_histos_2pixels+4maps_out.root");  
0296 
0297   TH1D *recomass[NPLOTS_UPS];
0298 
0299   for(int i=0;i<NPLOTS_UPS;i++)
0300     {
0301       fin_ups[i]->GetObject("recomass",recomass[i]);
0302     }
0303 
0304   TCanvas *cups = new TCanvas("cups","cups",50,50,1000,600);
0305   cups->SetLeftMargin(0.12);
0306 
0307   for(int i=0;i<NPLOTS_UPS;i++)
0308     {
0309       recomass[i]->SetMarkerColor(col[i]);
0310       recomass[i]->SetLineColor(col[i]);
0311       recomass[i]->SetMarkerStyle(20);
0312       recomass[i]->SetMarkerSize(1.2);
0313 
0314       if(i==0)
0315     recomass[i]->Draw("p");
0316       else
0317     recomass[i]->Draw("same p");
0318     }
0319 
0320   TLegend *lpq = new TLegend(0.15, 0.55, 0.40, 0.80,"Inner barrel","NDC");
0321   lpq->SetBorderSize(0);
0322   lpq->SetFillColor(0);
0323   lpq->SetFillStyle(0);
0324   lpq->AddEntry(recomass[0], "2 maps", "p");
0325   lpq->AddEntry(recomass[1], "2 pixels", "p");
0326   
0327   lpq->Draw();
0328   */
0329 
0330 }