void dileptonMassFit(const char* pInFileName="PanchoSkim4JanAll.root", // "PromtRecoV2V3V3H_DiMuonPlot_TightSTACutsAll15Dec.root", // "Z0_DataMixPt50_PatDiMuonPlots_NewCutAll14Dec.root", const char* pHistNameOpCh="diMuonsGlobalInvMassVsPt",//diMuonsGlobalInvMassVsPtW", const char* pHistNameSameCh="diMuonsGlobalSameChargeInvMassVsPt", const char* pSpectra="pt", // pt, y, centr bool doMc=false, int nFitFunction = 3, int getYield = 1) { gROOT->Macro("setStyle.C+"); //gROOT->Macro("/Users/eusmartass/Software/utilities/setStyle.C+"); char szBuf[256]; //////// definitions of Switches /////////// // nFitFunction = 1 RBW + Pol2 // nFitFunction = 2 Gaus + Pol2 // nFitFunction = 3 RBWGaus + Pol2 // getYield = 1 Bin counting // getYield = 2 Integral //////////////////////////////////////////////////////////// // make some choices float MassZ0 = 91.1876; float WidthZ0 = 2.4952; float massFit_low = 60; float massFit_high = 120; // Fit ranges float massDraw_low = 30.0; // 0. float massDraw_high = 130.0; // 200/ int nrebin = 80; bool isLog = 0; bool isFit = 1; // draw ranges float massCount_low = 60.0; //78.0 float massCount_high = 120.0; //102.0 //___________________________________________________________________________________ // ------- Open input file sprintf(szBuf,"%s",pInFileName); TString inFileName(szBuf); TFile *pfInFile = new TFile(inFileName); // ------- get histograms: sprintf(szBuf,"%s",pHistNameOpCh); TH2D *phDimuMass_1 = (TH2D*)pfInFile->Get(szBuf)->Clone("phDimuMass_1"); sprintf(szBuf,"%s",pHistNameSameCh); TH2D *phDimuMass_1S = (TH2D*)pfInFile->Get(szBuf)->Clone("phDimuMass_1S"); phDimuMass_1->SetDirectory(0); phDimuMass_1S->SetDirectory(0); // Open pp data file TFile *ppFile = new TFile("Zmumu_40-200_35pb.root"); TH1F *Zmumu = (TH1F*)ppFile->Get("hdata"); //___________________________________________________________________________________ // bins definition: const char* Xname[] = {" ", "p_{T}^{Dimuon} (GeV/c)", "rapidity", "centrality"}; bool doPt = false; bool doY = false; bool doCent = false; int GenRange, nBins; double binEdge[10]; char* label; sprintf(szBuf,"%s",pSpectra); TString wichSpectra(szBuf); if ( wichSpectra.CompareTo("pt") == 0) { doPt = true; label = (char*)Xname[1]; GenRange = 20; nBins = 1; binEdge[0] = 0.0; binEdge[1]= 100.0; // double binEdge[10] = {0.0, 10., 20., 100.0}; if(doMc) { nBins = 1; binEdge[0] = 0.0; binEdge[1]= 50.0; // nBins = 7; // binEdge[0] = 0.0; binEdge[1] = 2.0; binEdge[2] = 4.0; binEdge[3] = 8.0; //binEdge[4] = 12.0; binEdge[5] = 16.0; binEdge[6] = 22.0; binEdge[7] = 50.0; } } else { if ( wichSpectra.CompareTo("y") == 0) { doY = true; label = (char*)Xname[2]; nBins = 3; GenRange = 4.8; binEdge[0] = -2.4; binEdge[1] = -0.8; binEdge[2] = 0.8; binEdge[3] = 2.4; } else { if ( wichSpectra.CompareTo("cent") == 0) { doCent = true; label = (char*)Xname[3]; nBins = 4; GenRange = 40; binEdge[0] = 0.; binEdge[1] = 4; binEdge[2] = 8.; binEdge[3] = 16; binEdge[4] = 40; } else { cout<<"Don't know what you want to do!!!!"<<endl; return; } } } double PT[10], DelPT[10], mom_err[100]; for (Int_t ih = 0; ih < nBins; ih++) { PT[ih] = (binEdge[ih] + binEdge[ih+1])/2.0; DelPT[ih] = binEdge[ih+1] - binEdge[ih]; mom_err[ih] = DelPT[ih]/2.0; } //___________________________________________________________________________________ double gen_pt[10]; double egen_pt[10]; TCanvas *pcPt_1 = new TCanvas("pcPt_1"," Z0 Yield Vs. Pt ", 40,40,600,600); if(doMc) { pcPt_1->Divide(nBins,2); //TH2D *genMass_1 = (TH2D*)pfInFile->Get("diMuonsGenInvMassVsPt"); TH2D *genMass_1 = (TH2D*)pfInFile->Get("diMuonsGenInvMassVsPtW"); TH1D *ptaxis = (TH1D*)genMass_1->ProjectionY("ptaxis"); for (Int_t ih = 0; ih < nBins; ih++) { pcPt_1->cd(ih+nBins+1); int bin1 = ptaxis->FindBin(binEdge[ih]+0.0000001); int bin2 = ptaxis->FindBin(binEdge[ih+1]+0.0000001); TH1D * genMassVsPt = (TH1D*)genMass_1->ProjectionX("genMassVsPt", bin1, bin2-1); genMassVsPt->Draw("EPL"); pcPt_1->Update(); TAxis *axs = genMassVsPt->GetXaxis(); int binlow = axs->FindBin(massCount_low); int binhi = axs->FindBin(massCount_high); double int_sig_gen; double int_sig_gen_sqr; for(Int_t bin = binlow; bin<=binhi; bin++) { // cout << " int_sig += dimuonsGlobalInvMassVsPt[ih]->GetBinContent(bin);"<<int_sigpow_gen <<"+="<< "bin" << bin << " content"<<genMassVsPt->GetBinContent(bin)<<endl; int_sig_gen += genMassVsPt->GetBinContent(bin); int_sig_gen_sqr += pow(genMassVsPt->GetBinContent(bin),2); } gen_pt[ih] = int_sig_gen;//genMassVsPt->GetEntries(); cout<<" gen entries : "<< gen_pt[ih]<<endl; egen_pt[ih] =int_sig_gen_sqr; } } else { if (nBins == 2) pcPt_1->Divide(2,1); if (nBins == 3 || nBins == 4) pcPt_1->Divide(2,2); if (nBins == 5 || nBins == 6) pcPt_1->Divide(3,2); } //___________________________________________________________________________________ // Fit Function // const char *name_fit[] = {" ", "RBWPol1", "GausPol1", "RBWGausPol2"}; int nParam[] = {0,6,6,7}; int nFitParam = nParam[nFitFunction]; TF1 *RBWPOL=0; if(nFitFunction == 1) RBWPOL = new TF1("RBWPOL", RBWPol2, 0, 200, nFitParam); if(nFitFunction == 2) RBWPOL = new TF1("RBWPOL", GausPol2, 0, 200, nFitParam); if(nFitFunction == 3) RBWPOL = new TF1("RBWPOL", RBWGausPol2, 0, 200, nFitParam); TF1 *EXP = new TF1("EXP", Exp, 0, 200, 2); RBWPOL->SetLineWidth(1); RBWPOL->SetParameter(1, MassZ0); RBWPOL->SetParameter(2, WidthZ0); RBWPOL->SetParLimits(1, 0.9*MassZ0, 1.1*MassZ0); RBWPOL->SetParLimits(2, 0.1*WidthZ0, 5.0*WidthZ0); if(nFitFunction == 1 || nFitFunction == 2) RBWPOL->FixParameter(5, 0); if(nFitFunction == 3 || nFitFunction == 4) { RBWPOL->SetParameter(3, WidthZ0); RBWPOL->SetParLimits(3, 0.1, 20); RBWPOL->FixParameter(2, WidthZ0); RBWPOL->FixParameter(4, 0); // for no bkg RBWPOL->FixParameter(5, 0); // for no bkg RBWPOL->FixParameter(6, 0); } //___________________________________________________________________________________ // Efficiency double yld_cat_1[10], cyld_cat_1[10], eyld_cat_1[10], ceyld_cat_1[10]; double Eff_cat_1[10], errEff_cat_1[10]; ///// Write the spectra sprintf(szBuf,"fileSpecta%d.root", getYield); // TFile *fileSpectra = new TFile(szBuf, "recreate"); //___________________________________________________________________________________ // Drawing // Category _1 TLegend *pLegCategory = new TLegend(.66, .74, .92, .94); // pLegCategory = new TLegend(.1, .82, .50, .93); pLegCategory->SetBorderSize(0); pLegCategory->SetFillStyle(0); pLegCategory->SetFillColor(0); pLegCategory->SetTextSize(0.03); // pLegCategory->AddEntry(RBWPOL," CMS Preliminary", " "); pLegCategory->AddEntry(RBWPOL," CMS Pb+Pb ", " "); pLegCategory->AddEntry(RBWPOL," #sqrt{s_{NN}} = 2.76 TeV ", " "); pLegCategory->AddEntry(RBWPOL," #int Ldt = 6.6 #mub^{-1} ", " "); // pLegCategory->AddEntry(RBWPOL," Global-Global ", ""); //pLegCategory->AddEntry(RBWPOL," |y| < 2.4 ", "P"); //pLegCategory->AddEntry(RBWPOL," Run# 150431-151027 ", "P"); TLegend *legend_1[12]; for(int i=0; i<12; i++) { if(isFit) legend_1[i] = new TLegend(.13, .66, .52, 0.94); if(!isFit) legend_1[i] = new TLegend(.13, .66, .52, 0.94 ); // legend_1[i] = new TLegend(.68, .62, .91, 0.93 ); legend_1[i]->SetBorderSize(0); legend_1[i]->SetFillStyle(0); legend_1[i]->SetFillColor(0); legend_1[i]->SetTextSize(0.028); } int bin_bound[100]; TH1D *dimuonsGlobalInvMassVsPt[10]; TH1D *dimuonsGlobalInvMassVsPtS[10]; TH1D *service = (TH1D*)phDimuMass_1->ProjectionY("service"); // cout << endl << label << " Yield Mass (GeV) Width (GeV) GauWidth chi2/ndf " << endl << endl; for (Int_t ih = 0; ih < nBins; ih++) { pcPt_1->cd(ih+1); gPad->SetTickx(); gPad->SetTicky(); // Project 1 D bin_bound[ih] = service->FindBin(binEdge[ih]+0.0000001); bin_bound[ih+1] = service->FindBin(binEdge[ih+1]+0.0000001); sprintf(szBuf,"Z0_1_pt_%d",ih); dimuonsGlobalInvMassVsPt[ih] = (TH1D*)phDimuMass_1->ProjectionX(szBuf, bin_bound[ih], bin_bound[ih+1]-1+1, "e"); sprintf(szBuf,"Z0_1S_pt_%d",ih); dimuonsGlobalInvMassVsPtS[ih] = (TH1D*)phDimuMass_1S->ProjectionX(szBuf, bin_bound[ih], bin_bound[ih+1]-1+1); cout << "reco entries" << dimuonsGlobalInvMassVsPt[ih]->GetEntries() <<endl; if(doPt || doY) { sprintf(szBuf," %s [%.1f, %.1f]", label, service->GetBinLowEdge(bin_bound[ih]), service->GetBinLowEdge(bin_bound[ih+1]-1) + service->GetBinWidth(bin_bound[ih+1])); } if(doCent) { sprintf(szBuf," %s [%.1f, %.1f] %s", label, 2.5*service->GetBinLowEdge(bin_bound[ih]), 2.5*(service->GetBinLowEdge(bin_bound[ih+1]-1) + service->GetBinWidth(bin_bound[ih+1])), "%"); } dimuonsGlobalInvMassVsPt[ih]->Rebin(nrebin); dimuonsGlobalInvMassVsPtS[ih]->Rebin(nrebin); // -------- Fit Function + Bkg Function double part[20]; dimuonsGlobalInvMassVsPt[ih]->Fit("EXP","LEQ", "", 34, 60); EXP->GetParameters(part); if(nFitFunction == 4) { RBWPOL->FixParameter(4, part[0]); RBWPOL->FixParameter(5, part[1]); } if(isFit) { //dimuonsGlobalInvMassVsPt[ih]->Fit("RBWPOL","LEQ", "", massFit_low, massFit_high); //TFitResultPtr r = dimuonsGlobalInvMassVsPt[ih]->Fit("RBWPOL","LEQS0","", massFit_low, massFit_high); // if(r->IsValid()) r->Print(); //else cout<<"Fit not valid!!!\n"<<endl; } //------ get fit parameters double par[20]; RBWPOL->GetParameters(par); float GGphDimuMass = RBWPOL->GetParameter(1); float GGZ0Width = RBWPOL->GetParameter(2); float GauWidth =0; if(nFitFunction == 3 || nFitFunction == 4) GauWidth = RBWPOL->GetParameter(3); double chisq = RBWPOL->GetChisquare(); int ndf = RBWPOL->GetNDF(); double chisqdf =1000; if(ndf!=0) chisqdf=chisq/ndf; // +++ set backgroudn fit sprintf(szBuf,"pt_1B_%d",ih); TF1 *bkgFit_1 = new TF1(szBuf, Pol2, massFit_low, massFit_high, 3); // if(nFitFunction == 4) bkgFit_1 = new TF1(namePt_1B, Exp, massFit_low, massFit_high, 2); bkgFit_1->SetParameters(&par[3]); if(nFitFunction == 3 || nFitFunction == 4) bkgFit_1->SetParameters(&par[4]); // ---------- Integrated Yield // float massCount_low =GGphDimuMass-(4.0*GGZ0Width); // float massCount_high =GGphDimuMass+(4.0*GGZ0Width); TAxis *axs = dimuonsGlobalInvMassVsPt[ih]->GetXaxis(); int binlow = axs->FindBin(massCount_low); int binhi = axs->FindBin(massCount_high); Double_t bin_size = (1.0*dimuonsGlobalInvMassVsPt[ih]->GetNbinsX())/(axs->GetXmax() - axs->GetXmin()); Float_t int_sig = 0.0; Float_t int_sig_sqr = 0.0; for(Int_t bin = binlow; bin<=binhi; bin++) { // cout << " int_sig += dimuonsGlobalInvMassVsPt[ih]->GetBinContent(bin);"<<int_sig <<"+="<< "bin" << bin << " content"<<dimuonsGlobalInvMassVsPt[ih]->GetBinContent(bin)<<endl; int_sig += dimuonsGlobalInvMassVsPt[ih]->GetBinContent(bin); int_sig_sqr += pow(dimuonsGlobalInvMassVsPt[ih]->GetBinContent(bin),2); } if(getYield == 2) { int_sig = RBWPOL->Integral(massCount_low, massCount_high)*bin_size; yld_cat_1[ih] = int_sig - bin_size*bkgFit_1->Integral(massCount_low, massCount_high); eyld_cat_1[ih] = TMath::Sqrt(int_sig + bin_size*bkgFit_1->Integral(massCount_low, massCount_high) ); } else { yld_cat_1[ih] = int_sig ; eyld_cat_1[ih] = int_sig_sqr; } cout << "int_sig - bin_size*bkgFit_1->Integral(massCount_low, massCount_high);" << int_sig<< " -"<< bin_size<<"*"<<bkgFit_1->Integral(massCount_low, massCount_high)<< " with low"<< massCount_low<<" high "<< massCount_high<<endl; //// Printing ///// cout << PT[ih] << " " << yld_cat_1[ih] << " +- " << eyld_cat_1[ih] <<" " << GGphDimuMass << " " << GGZ0Width << " " << GauWidth <<" "<< chisq << "/" << ndf << endl; // -------------- Draw // dimuonsGlobalInvMassVsPt[ih]->SetMinimum(-.05*dimuonsGlobalInvMassVsPt[ih]->GetMaximum()); if(isLog) gPad->SetLogy(1); TColor *pal = new TColor(); Int_t kblue = pal->GetColor(9,0,200); // Int_t korange = pal->GetColor(101, 42, 0); // +++ opposite charge dimuonsGlobalInvMassVsPt[ih]->SetMarkerStyle(21); dimuonsGlobalInvMassVsPt[ih]->SetMarkerColor(kblue); dimuonsGlobalInvMassVsPt[ih]->SetLineColor(kblue); dimuonsGlobalInvMassVsPt[ih]->SetMarkerSize(1.1); dimuonsGlobalInvMassVsPt[ih]->GetXaxis()->SetTitle("Dimuon mass (GeV/c^{2})"); dimuonsGlobalInvMassVsPt[ih]->GetYaxis()->SetTitle("dN/dM (2 GeV/c^{2})^{-1}"); dimuonsGlobalInvMassVsPt[ih]->GetXaxis()->SetRangeUser(massDraw_low,massDraw_high); // dimuonsGlobalInvMassVsPt[ih]->Add(dimuonsGlobalInvMassVsPtS[ih], -1); pcPt_1->cd(ih+1); dimuonsGlobalInvMassVsPt[ih]->DrawCopy("EPLsame"); // pp data TAxis *axs1 = Zmumu->GetXaxis(); int ll = axs1->FindBin(massCount_low); int hh = axs1->FindBin(massCount_high); double scalefactor = yld_cat_1[ih]/Zmumu->Integral(ll, hh); cout << Zmumu->Integral(ll, hh) << endl; Zmumu->Scale(scalefactor); Zmumu->SetFillColor(19); Zmumu->Draw("same"); dimuonsGlobalInvMassVsPt[ih]->DrawCopy("EPLsame"); // dimuonsGlobalInvMassVsPt[ih]->Draw("B"); // +++ same charge dimuonsGlobalInvMassVsPtS[ih]->SetMarkerStyle(8); dimuonsGlobalInvMassVsPtS[ih]->SetMarkerColor(46); dimuonsGlobalInvMassVsPtS[ih]->SetLineColor(46); dimuonsGlobalInvMassVsPtS[ih]->SetMarkerSize(1.1); dimuonsGlobalInvMassVsPtS[ih]->DrawCopy("EPsame"); // background // RBWPOL->SetLineColor(kblue); bkgFit_1->SetLineColor(46); bkgFit_1->SetLineWidth(1); // if(isFit) bkgFit_1->Draw("same"); // ++++ legend pLegCategory->Draw("same"); // legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih]," Global-Global", " "); legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih]," |#eta^{#mu}| < 2.4, p_{T}^{#mu} > 10 GeV/c ", ""); legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih]," Unlike Sign ", "LP"); legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPtS[ih]," Like Sign ", "LP"); legend_1[ih]->AddEntry(Zmumu," pp Data ", "L"); // legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih], text, ""); sprintf(szBuf, "N=%1.0f #pm %1.1f ", yld_cat_1[ih], sqrt(yld_cat_1[ih]) ); legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih], szBuf, ""); // sprintf(label_1, "N_{Z^{0}} = 27"); sprintf(szBuf, "mass = %1.2f #pm %1.2f GeV/c^{2}", RBWPOL->GetParameter(1), RBWPOL->GetParError(1)); // if(isFit) legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih],szBuf, ""); sprintf(szBuf, "#sigma_{Gauss} = %1.2f #pm %1.2f GeV/c^{2}", RBWPOL->GetParameter(2), RBWPOL->GetParError(2)); if(nFitFunction ==3 || nFitFunction == 4) sprintf(szBuf, "#sigma_{Gauss} = %1.2f #pm %1.2f GeV/c^{2}", RBWPOL->GetParameter(3), RBWPOL->GetParError(3)); // if(isFit) legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih], szBuf, ""); sprintf(szBuf, "#chi^{2}/ndf = %1.2f / %d", chisq, ndf); // if(isFit) legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih], label_4, ""); legend_1[ih]->Draw("same"); pcPt_1->Update(); } cout << endl << endl; TGraphErrors *Z0pt_cat_1 = new TGraphErrors(nBins, PT, yld_cat_1, mom_err, eyld_cat_1); Z0pt_cat_1->SetMarkerStyle(20); Z0pt_cat_1->SetMarkerColor(2); Z0pt_cat_1->GetXaxis()->SetTitle(label); Z0pt_cat_1->GetYaxis()->SetTitle("counts"); TCanvas *pc2 = new TCanvas("pc2","pc2"); Z0pt_cat_1->SetMinimum(0.0); Z0pt_cat_1->SetName("Z0pt_cat_1"); Z0pt_cat_1->Draw("AP"); TGraphErrors *Z0ptC_cat_1_gen = new TGraphErrors(nBins, PT, gen_pt, mom_err, egen_pt); // Z0ptC_cat_1_gen->SetMarkerStyle(23); //Z0ptC_cat_1_gen->SetMarkerColor(3); //Z0ptC_cat_1_gen->Draw("AP"); pLegCategory->Draw("same"); Z0pt_cat_1->Write(); pLegCategory->Write(); // gPad->Print("Pt_Z0YieldCat_1.png"); pcPt_1->Print("Pt_Z0YieldCat_1.png"); cout << endl << endl; ////////////////////////////////////////////////////////////////////////////// // Efficiency correction if(doMc) { ofstream fileout("correction.txt"); cout << label << " Eff_cat_1 " << endl; for (Int_t ih = 0; ih < nBins; ih++) { Eff_cat_1[ih] = yld_cat_1[ih]/gen_pt[ih]; errEff_cat_1[ih] = sqrt( (pow(Eff_cat_1[ih]/yld_cat_1[ih],2))*eyld_cat_1[ih] +(pow((1-Eff_cat_1[ih]/yld_cat_1[ih]),2))*( yld_cat_1[ih]-gen_pt[ih]/ yld_cat_1[ih])); // errEff_cat_1[ih] = sqrt( (pow(Eff_cat_1[ih]/yld_cat_1[ih],2))*eyld_cat_1[ih] // +(pow((1-Eff_cat_1[ih]/yld_cat_1[ih]),2))*event failing); // fileout << PT[ih] <<" "<< Eff_cat_1[ih] << " " << Eff_cat_2[ih] <<" " << Eff_cat_3[ih] << endl; // cout <<" " << PT[ih] <<" "<< Eff_cat_1[ih] << " " << Eff_cat_2[ih] << " " << Eff_cat_3[ih] << endl; fileout << PT[ih] <<" "<< Eff_cat_1[ih] << " " << errEff_cat_1[ih] << endl; cout <<" " << PT[ih] <<" "<< Eff_cat_1[ih] << " +- " << errEff_cat_1[ih] << endl; cyld_cat_1[ih] = Eff_cat_1[ih]; ceyld_cat_1[ih] = errEff_cat_1[ih]; } } else { ifstream filein("correction.txt"); cout << label << " yld_cat_1 " << " efficiency " << " corr. yld_cat_1 " << endl; for (Int_t ih = 0; ih < nBins; ih++) { // filein >> PT[ih] >> Eff_cat_1[ih] >> Eff_cat_2[ih] >> Eff_cat_3[ih] ; // cout << " " << PT[ih] << " "<< yld_cat_1[ih] << " " << yld_cat_2[ih] <<" " << yld_cat_3[ih] << endl; filein >> PT[ih] >> Eff_cat_1[ih] >> errEff_cat_1[ih]; cout << " " << PT[ih] << " " << yld_cat_1[ih] << " " << Eff_cat_1[ih] << " " << yld_cat_1[ih]/Eff_cat_1[ih] << endl; cyld_cat_1[ih] = yld_cat_1[ih]/Eff_cat_1[ih]; ceyld_cat_1[ih] = eyld_cat_1[ih]/Eff_cat_1[ih]; } } // TF1 *EXPA = new TF1("EXPA", Exp, 0, 100, 2); TGraphErrors *Z0ptC_cat_1 = new TGraphErrors(nBins, PT, cyld_cat_1, mom_err, ceyld_cat_1); Z0ptC_cat_1->SetMarkerStyle(20); Z0ptC_cat_1->SetMarkerColor(2); Z0ptC_cat_1->GetXaxis()->SetTitle(label); Z0ptC_cat_1->GetYaxis()->SetTitle("Acc x Eff"); // if(part == 2) Z0ptC_cat_1->Fit("EXPA","LEQ", "", 7, 16); new TCanvas; Z0ptC_cat_1->SetMinimum(0.0); Z0ptC_cat_1->SetMaximum(0.8); Z0ptC_cat_1->SetName("Z0ptC_cat_1"); Z0ptC_cat_1->Draw("AP"); pLegCategory->Draw("same"); cout << endl << endl; Z0ptC_cat_1->Write(); }
void Z0AccEff(int isData = 2, int yieldInt = 1, int iSpec = 3, int Weight =1) { //////// definitions of Switches /////////// // isData = 1 for Data // isData = 2 for Simulation // iSpec = 1 pT spectra // iSpec = 2 Y spectra // iSpec = 3 Centrality Spectra //Weight = 1 for weighted histo //weight = 0 for non weighted histo //////////////////////////////////////////////////////////// gStyle->SetOptStat(0); gStyle->SetOptStat(0); gStyle->SetOptFit(0000); // Fit ranges float mass_low, mass_high, mlow, mhigh; int nrebin; bool isLog, isFit; double MassZ0, WidthZ0; // High Mass range MassZ0 = 91.1876; WidthZ0 = 2.4952; mass_low = 60; mass_high = 120; // Fit ranges Glb Glb //mass_low = 40; mass_high = 140; // Fit ranges STA mlow = 0.0; mhigh = 200.0; nrebin = 80; isLog =0; isFit = 0; // draw ranges int whis = 1; // 1 for full all eta, 2 for barrel //4 for trigger matched PAT //file one is good file TFile *fil1, *fil2; if (isData == 2) fil2 = new TFile("Z0_DataMixPt50_PatDiMuonPlots_All11Dec.root"); //if (isData == 2) fil2 = new TFile("ReReco_DM_DiMuonPlot_All16Dec.root"); if (isData == 2) fil1 = new TFile("Z0HydPt50_PatDiMuonPlots_AllWOSel12Dec.root"); // Pt bin sizes int Nptbin=1; double pt_bound[100] = {0}; if(iSpec == 1) { Nptbin = 3; pt_bound[0] = 0.0; pt_bound[1] = 6.0; pt_bound[2] = 12.0; pt_bound[3] = 100.0; if(isData == 2) { Nptbin = 25; // pt_bound[100] = {0.0,100.0,12.0,100.0}; pt_bound[0] = 0; pt_bound[1] = 2; pt_bound[2] = 4; pt_bound[3] = 6; pt_bound[4] = 8; pt_bound[5] = 10; pt_bound[6] = 12; pt_bound[7] = 14; pt_bound[8] = 16; pt_bound[9] = 18; pt_bound[10] = 20; pt_bound[11] = 22; pt_bound[12] = 24; pt_bound[13] = 26; pt_bound[14] = 28; pt_bound[15] = 30; pt_bound[16] = 32; pt_bound[17] = 34; pt_bound[18] = 36; pt_bound[19] = 38; pt_bound[20] = 40; pt_bound[21] = 42; pt_bound[22] = 44; pt_bound[23] = 46; pt_bound[24] = 48; pt_bound[25] = 50; } } // Y bin sizes if(iSpec == 2) { Nptbin = 10; // pt_bound[100] = {-2.4,-1.0,-0.5,0.5,1.0,2.4}; // pt_bound[100] = {-2.4,-1.0,-0.5,0.5,1.0,2.4}; // pt_bound[100] = {-2.4,-2.1,-1.6,-1.1,-0.6,0,0.6,1.1,1.6,2.1,2.4}; pt_bound[0] = -2.4; pt_bound[1] = -2.1; pt_bound[2] = -1.6; pt_bound[3] = -1.1; pt_bound[4] = -0.6; pt_bound[5] = 0.0; pt_bound[6] = 0.6; pt_bound[7] = 1.1; pt_bound[8] = 1.6; pt_bound[9] = 2.1; pt_bound[10] = 2.4; } if(iSpec == 3) { if(isData == 2) { Nptbin = 9; pt_bound[0] = 0.0; pt_bound[1] = 4.0; pt_bound[2] = 8.0; pt_bound[3] = 12.0; pt_bound[4] = 16.0; pt_bound[5] = 20.0; pt_bound[6] = 24.0; pt_bound[7] = 28.0; pt_bound[8] = 32.0; pt_bound[9] = 40.0; } } double PT[100], DelPT[100], mom_err[100]; for (Int_t ih = 0; ih < Nptbin; ih++) { PT[ih] = (pt_bound[ih] + pt_bound[ih+1])/2.0; DelPT[ih] = pt_bound[ih+1] - pt_bound[ih]; mom_err[ih] = DelPT[ih]/2.0; } float gen_pt[100], gen_ptError[100]; float gen_ptS[100], gen_ptErrorS[100]; if(isData==2){ TH2D *genMass_1, *genMassS_1; if (iSpec == 1 && Weight==1 ) genMass_1 = (TH2D*)fil1->Get("diMuonsGenInvMassVsPtW"); if (iSpec == 2 && Weight==1) genMass_1 = (TH2D*)fil1->Get("diMuonsGenInvMassVsYW"); if (iSpec == 3 && Weight==1) genMass_1 = (TH2D*)fil1->Get("diMuonsGenInvMassVsCenW"); if (iSpec == 1 && Weight==1) genMassS_1 = (TH2D*)fil2->Get("diMuonsGenInvMassVsPtW"); if (iSpec == 2 && Weight==1) genMassS_1 = (TH2D*)fil2->Get("diMuonsGenInvMassVsYW"); if (iSpec == 3 && Weight==1) genMassS_1 = (TH2D*)fil2->Get("diMuonsGenInvMassVsCenW"); if (iSpec == 1 && Weight==0) genMass_1 = (TH2D*)fil1->Get("diMuonsGenInvMassVsPt"); if (iSpec == 2 && Weight==0) genMass_1 = (TH2D*)fil1->Get("diMuonsGenInvMassVsY"); if (iSpec == 3 && Weight==0) genMass_1 = (TH2D*)fil1->Get("diMuonsGenInvMassVsCen"); if (iSpec == 1 && Weight==0) genMassS_1 = (TH2D*)fil2->Get("diMuonsGenInvMassVsPt"); if (iSpec == 2 && Weight==0) genMassS_1 = (TH2D*)fil2->Get("diMuonsGenInvMassVsY"); if (iSpec == 3 && Weight==0) genMassS_1 = (TH2D*)fil2->Get("diMuonsGenInvMassVsCen"); TH1D *ptaxis = (TH1D*)genMass_1->ProjectionY("ptaxis"); for (Int_t ih = 0; ih < Nptbin; ih++) { cout<<pt_bound[ih]<<" "<<pt_bound[ih+1]<<endl; int pt_bin1 = ptaxis->FindBin(pt_bound[ih]+0.0000001); int pt_bin2 = ptaxis->FindBin(pt_bound[ih+1]+0.0000001); cout<< pt_bin1<<" "<< pt_bin2<<endl; TH1D * genMassVsPt = (TH1D*)genMass_1->ProjectionX("genMassVsPt", pt_bin1, pt_bin2-1); TH1D * genMassVsPtS = (TH1D*)genMassS_1->ProjectionX("genMassVsPtS", pt_bin1, pt_bin2-1); //does not work with weight //gen_pt[ih] = genMassVsPt->GetEntries(); double genError,genErrorS; gen_pt[ih] = genMassVsPt->IntegralAndError(1,8000,genError); gen_ptError[ih]= genError; gen_ptS[ih] = genMassVsPtS->IntegralAndError(1,8000,genErrorS); gen_ptErrorS[ih]= genErrorS; cout<<" gen entries : "<< gen_pt[ih]<<endl; cout<<"genErro "<<genError<<" "<< gen_ptError[ih]<<endl<<endl; } } // Efficiency float Eff_cat_1[100]; float Eff_catS_1[100]; float errEff_cat_1[100]; float errEff_catS_1[100]; float errEff_cat_S1[100], errEff_cat_S2[100]; float errEff_catS_S1[100], errEff_catS_S2[100]; char *Xname[100] = {" ", "p_{T}^{Dimuon} (GeV/c)", "rapidity", "centrality"}; double yld_cat_1[100]; double yld_catS_1[100]; double cyld_cat_1[100]; double cyld_catS_1[100]; double eyld_cat_1[100]; double eyld_catS_1[100]; double ceyld_cat_1[100], ceyld_catS_1[100]; char namePt_1[500]; char namePt_1S[500]; //char namePt_1B[500]; char text[100]; ///// Write the spectra char fspectra[500]; sprintf(fspectra,"fileSpecta%d.root", yieldInt); TFile *fileSpectra = new TFile(fspectra, "recreate"); /////////////////////////////////////////////////////////////////////// // Category _1 TLegend *lcat_1; lcat_1 = new TLegend(.1, .82, .50, .93); lcat_1->SetName("lcat_1"); lcat_1->SetBorderSize(0); lcat_1->SetFillStyle(0); lcat_1->SetFillColor(0); lcat_1->SetTextSize(0.032); //lcat_1->AddEntry(RBWPOL," CMS Preliminary", " "); //lcat_1->AddEntry(RBWPOL," PbPb #sqrt{s_{NN}} = 2.76 TeV ", " "); TLegend *legend_1[100]; for(int i=0; i<100; i++) { if(isFit) legend_1[i] = new TLegend(.62, .52, .91, 0.93 ); if(!isFit) legend_1[i] = new TLegend(.62, .68, .91, 0.93 ); legend_1[i]->SetBorderSize(0); legend_1[i]->SetFillStyle(0); legend_1[i]->SetFillColor(0); legend_1[i]->SetTextSize(0.032); } //for no cut //if(whis == 1 && iSpec == 1 ) TH2D *Z0Mass_1 = (TH2D*)fil1->Get("dimu"); //if(whis == 2 && iSpec == 1) TH2D *Z0Mass_1 = (TH2D*)fil1->Get("diMuonsGlobalInvMassVsPtBRL"); //if(whis == 4 && iSpec == 1 ) { //TH2D *Z0Mass_1 = (TH2D*)fil1->Get("diMuonsPATInvMassVsPt"); //TH2D *Z0Mass_1 = (TH2D*)fil1->Get("diMuonsPATSTAInvMassVsPt"); //} TH2D *Z0Mass_1, *Z0Mass_1S; //with weight if(iSpec == 1 && Weight==1 ) Z0Mass_1 = (TH2D*)fil1->Get("diMuonsGlobalInvMassVsPtW"); if(iSpec == 2 && Weight==1) Z0Mass_1 = (TH2D*)fil1->Get("diMuonsGlobalInvMassVsYW"); if(iSpec == 3 && Weight==1) Z0Mass_1 = (TH2D*)fil1->Get("diMuonsGlobalInvMassVsCenW"); //without weight if(iSpec == 1 && Weight==0) Z0Mass_1 = (TH2D*)fil1->Get("diMuonsGlobalInvMassVsPt"); if(iSpec == 2 && Weight==0) Z0Mass_1 = (TH2D*)fil1->Get("diMuonsGlobalInvMassVsY"); if(iSpec == 3 && Weight==0) Z0Mass_1 = (TH2D*)fil1->Get("diMuonsGlobalInvMassVsCen"); //with weight fil2 if(iSpec == 1 && Weight==1) Z0Mass_1S = (TH2D*)fil2->Get("diMuonsGlobalInvMassVsPtW"); if(iSpec == 2 && Weight==1) Z0Mass_1S = (TH2D*)fil2->Get("diMuonsGlobalInvMassVsYW"); if(iSpec == 3 && Weight==1) Z0Mass_1S = (TH2D*)fil2->Get("diMuonsGlobalInvMassVsCenW"); //without weight fil2 if(iSpec == 1 && Weight==0 ) Z0Mass_1S = (TH2D*)fil2->Get("diMuonsGlobalInvMassVsPt"); if(iSpec == 2 && Weight==0 ) Z0Mass_1S = (TH2D*)fil2->Get("diMuonsGlobalInvMassVsY"); if(iSpec == 3 && Weight==0 ) Z0Mass_1S = (TH2D*)fil2->Get("diMuonsGlobalInvMassVsCen"); TH1D *service = (TH1D*)Z0Mass_1->ProjectionY("service"); int pt_bin_bound[100]; TH1D *dimuonsGlobalInvMassVsPt[100], *dimuonsGlobalInvMassVsPtS[100]; TCanvas *CanvPt_1 = new TCanvas("CanvPt_1"," Z0 Yield Vs. Pt ", 40,40,1000,700); if (Nptbin == 2) CanvPt_1->Divide(2,1); if (Nptbin == 3 || Nptbin == 4) CanvPt_1->Divide(2,2); if (Nptbin == 5 || Nptbin == 6) CanvPt_1->Divide(3,2); if (Nptbin == 9 || Nptbin == 10) CanvPt_1->Divide(5,2); cout << endl << Xname[iSpec] << " Yield Mass (GeV) Width (GeV) GauWidth chi2/ndf " << endl << endl; //ih loop for (Int_t ih = 0; ih < Nptbin; ih++) { CanvPt_1->cd(ih+1); gPad->SetTickx(); gPad->SetTicky(); // Project 1 D pt_bin_bound[ih] = Z0Mass_1->GetYaxis()->FindBin(pt_bound[ih]+0.0000001); pt_bin_bound[ih+1] = Z0Mass_1->GetYaxis()->FindBin(pt_bound[ih+1]-0.0000001); sprintf(namePt_1,"Z0_1_pt_%d",ih); sprintf(namePt_1S,"Z0_1S_pt_%d",ih); //printf(namePt_1,"Z0_1_pt_%d",ih); //cout<<endl<<endl; //continue; dimuonsGlobalInvMassVsPt[ih] = (TH1D*)Z0Mass_1->ProjectionX(namePt_1, pt_bin_bound[ih], pt_bin_bound[ih+1]-1+1, "e"); dimuonsGlobalInvMassVsPtS[ih] = (TH1D*)Z0Mass_1S->ProjectionX(namePt_1S, pt_bin_bound[ih], pt_bin_bound[ih+1]-1+1,"e"); if(iSpec == 1 || iSpec == 2) {sprintf(text," %s [%.1f, %.1f]", Xname[iSpec], service->GetBinLowEdge(pt_bin_bound[ih]), service->GetBinLowEdge(pt_bin_bound[ih+1])+service->GetBinWidth(pt_bin_bound[ih+1]));} if(iSpec == 3) {sprintf(text," %s [%.1f, %.1f] %s", Xname[iSpec], 2.5*service->GetBinLowEdge(pt_bin_bound[ih]), 2.5*(service->GetBinLowEdge(pt_bin_bound[ih+1])+service->GetBinWidth(pt_bin_bound[ih+1])), "%");} dimuonsGlobalInvMassVsPt[ih]->Rebin(nrebin); dimuonsGlobalInvMassVsPtS[ih]->Rebin(nrebin); float m_low = 60.0; float m_high = 120.0; TAxis *axs = dimuonsGlobalInvMassVsPt[ih]->GetXaxis(); int binlow = axs->FindBin(m_low); int binhi = axs->FindBin(m_high); // Double_t bin_size = (1.0*dimuonsGlobalInvMassVsPt[ih]->GetNbinsX())/(axs->GetXmax() - axs->GetXmin()); // Float_t int_sig = 0.0; //for(Int_t bin = binlow; bin<=binhi;bin++) { //int_sig+ = dimuonsGlobalInvMassVsPt[ih]->GetBinContent(bin); //} double recerror,recerrorS; //double yld; double yld_1 = dimuonsGlobalInvMassVsPt[ih]->IntegralAndError(binlow, binhi, recerror); double yldS_1 = dimuonsGlobalInvMassVsPtS[ih]->IntegralAndError(binlow, binhi, recerrorS); eyld_cat_1[ih] =recerror; eyld_catS_1[ih] =recerrorS; cout<< "yld " << yld_1 <<" eyld_cat_1[ih] "<< eyld_cat_1[ih]<<" rec error "<<recerror<<endl; yld_cat_1[ih] = yld_1; yld_catS_1[ih] = yldS_1; if(isLog) gPad->SetLogy(1); TColor *pal = new TColor(); Int_t kblue = pal->GetColor(9,0,200); // Int_t korange = pal->GetColor(101, 42, 0); dimuonsGlobalInvMassVsPt[ih]->SetMarkerStyle(21); dimuonsGlobalInvMassVsPt[ih]->SetMarkerColor(kblue); dimuonsGlobalInvMassVsPt[ih]->SetLineColor(kblue); dimuonsGlobalInvMassVsPt[ih]->GetXaxis()->SetTitle("Dimuon mass (GeV/c^{2})"); dimuonsGlobalInvMassVsPt[ih]->GetYaxis()->SetTitle("Events/(2 GeV/c^{2})"); dimuonsGlobalInvMassVsPt[ih]->GetXaxis()->SetRangeUser(mlow,mhigh); dimuonsGlobalInvMassVsPt[ih]->DrawCopy("EPL"); // fil2 dimuonsGlobalInvMassVsPtS[ih]->SetMarkerStyle(8); dimuonsGlobalInvMassVsPtS[ih]->SetMarkerColor(46); dimuonsGlobalInvMassVsPtS[ih]->SetLineColor(46); //****** dimuonsGlobalInvMassVsPtS[ih]->DrawCopy("EPsame"); //RBWPOL->SetLineColor(kblue); //backfun_1->SetLineColor(46); //backfun_1->SetLineWidth(1); //if(isFit) backfun_1->Draw("same"); lcat_1->Draw("same"); legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih],"Global-Global", " "); legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih]," |y| < 2.4 ", ""); legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih], text, ""); legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih]," Opposite Charge ", "LP"); legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPtS[ih]," Same Charge ", "LP"); char label_1[512]; // char label_2[512], label_3[512], label_4[512]; sprintf(label_1, "N=%1.2f #pm %1.2f ", yld_cat_1[ih], eyld_cat_1[ih]); // sprintf(label_1, "N_{Z^{0}} = 27"); legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih], label_1, ""); }//ih loop cout << endl << endl; CanvPt_1->Print("Pt_Z0MassCat_1.png"); TGraphErrors *Z0pt_cat_1 = new TGraphErrors(Nptbin, PT, yld_cat_1, mom_err, eyld_cat_1); Z0pt_cat_1->SetMarkerStyle(20); Z0pt_cat_1->SetMarkerColor(2); Z0pt_cat_1->GetXaxis()->SetTitle(Xname[iSpec]); Z0pt_cat_1->GetYaxis()->SetTitle("counts"); new TCanvas; Z0pt_cat_1->SetMinimum(0.0); Z0pt_cat_1->SetName("Z0pt_cat_1"); Z0pt_cat_1->Draw("AP"); lcat_1->Draw("same"); gPad->Print("Pt_Z0YieldCat_1.png"); cout << endl << endl; Z0pt_cat_1->Write(); lcat_1->Write(); // Efficiency correction if(isData==2) { ofstream fileout("correction.txt"); cout << Xname[iSpec] << " Eff_cat_1 " << endl; for (Int_t ih = 0; ih < Nptbin; ih++) { //cout<<"gen_pt[ih]; "<<gen_pt[ih]<<endl; Eff_cat_1[ih] = yld_cat_1[ih]/gen_pt[ih]; Eff_catS_1[ih] = yld_catS_1[ih]/gen_ptS[ih]; //eyld_cat_1[ih]; //gen_ptError[ih]; //cout<<endl<<endl<<endl; //cout<<"Eff_cat_1[ih] "<<Eff_cat_1[ih]<<endl; //cout<<"yld_cat_1[ih] "<< yld_cat_1[ih] <<endl; //cout<<"eyld_cat_1[ih] "<<eyld_cat_1[ih] <<endl; //cout<<"gen_pt[ih] "<< gen_pt[ih] <<endl; //cout<<"gen_ptError[ih] "<< gen_ptError[ih]<<endl; //Error for first graph double errEff_cat_S1_1[100]={0},errEff_cat_S1_2[100]={0}; double errEff_cat_S2_1[100]={0},errEff_cat_S2_2[100]={0}; errEff_cat_S1_1[ih]= ( (Eff_cat_1[ih] * Eff_cat_1[ih]) /(gen_pt[ih] * gen_pt[ih]) ); errEff_cat_S1_2[ih]= (gen_ptError[ih] * gen_ptError[ih] ) - ( eyld_cat_1[ih] * eyld_cat_1[ih] ); errEff_cat_S1[ih]= (errEff_cat_S1_1[ih] * errEff_cat_S1_2[ih]); //cout<<" errEff_cat_S1_1[ih] "<< errEff_cat_S1_1[ih]<< " errEff_cat_S1_2[ih] "<<errEff_cat_S1_2[ih]<<endl; errEff_cat_S2_1[ih]= ( (1 - Eff_cat_1[ih])* (1 - Eff_cat_1[ih]) ) / ( gen_pt[ih] * gen_pt[ih]); errEff_cat_S2_2[ih]= (eyld_cat_1[ih] * eyld_cat_1[ih]); errEff_cat_S2[ih]=errEff_cat_S2_1[ih]*errEff_cat_S2_2[ih]; //cout<<" errEff_cat_S2_1[ih] "<< errEff_cat_S2_1[ih]<< " errEff_cat_S2_2[ih] "<<errEff_cat_S2_2[ih]<<endl; //cout<<"errEff_cat_S1[ih] "<<errEff_cat_S1[ih]<< " errEff_cat_S2[ih] "<< errEff_cat_S2[ih]<<endl; errEff_cat_1[ih]=sqrt(errEff_cat_S1[ih] + errEff_cat_S2[ih]); //Error for second graph double errEff_catS_S1_1[100]={0},errEff_catS_S1_2[100]={0}; double errEff_catS_S2_1[100]={0},errEff_catS_S2_2[100]={0}; errEff_catS_S1_1[ih]= ( (Eff_catS_1[ih] * Eff_catS_1[ih]) /(gen_ptS[ih] * gen_ptS[ih]) ); errEff_catS_S1_2[ih]= (gen_ptErrorS[ih] * gen_ptErrorS[ih] ) - (eyld_catS_1[ih] * eyld_catS_1[ih] ); errEff_catS_S1[ih]= (errEff_catS_S1_1[ih] * errEff_catS_S1_2[ih]); errEff_catS_S2_1[ih]= ( (1 - Eff_catS_1[ih])* (1 - Eff_catS_1[ih]) ) / ( gen_ptS[ih] * gen_ptS[ih]); errEff_catS_S2_2[ih]= (eyld_catS_1[ih] * eyld_catS_1[ih]); errEff_catS_S2[ih]= errEff_catS_S2_1[ih]*errEff_catS_S2_2[ih]; errEff_catS_1[ih]=sqrt(errEff_catS_S1[ih] + errEff_catS_S2[ih]); //Error for no weight //errEff_cat_1[ih] =((Eff_cat_1[ih]*(1- Eff_cat_1[ih]))/gen_pt[ih]); //Prashant error //errEff_cat_1[ih] = eyld_cat_1[ih]/gen_pt[ih]; fileout << PT[ih] <<" "<< Eff_cat_1[ih] << " " << errEff_cat_1[ih] << endl; cout <<" " << PT[ih] <<" "<< Eff_cat_1[ih] << " +- " << errEff_cat_1[ih] << endl; cyld_cat_1[ih] = Eff_cat_1[ih]; ceyld_cat_1[ih] = errEff_cat_1[ih]; cyld_catS_1[ih] = Eff_catS_1[ih]; ceyld_catS_1[ih] = errEff_catS_1[ih]; } } TGraphErrors *Z0ptC_cat_1 = new TGraphErrors(Nptbin, PT, cyld_cat_1, mom_err, ceyld_cat_1); Z0ptC_cat_1->SetMarkerStyle(20); Z0ptC_cat_1->SetMarkerColor(2); Z0ptC_cat_1->GetXaxis()->SetTitle(Xname[iSpec]); Z0ptC_cat_1->GetYaxis()->SetTitle("Acc #times Eff"); Z0ptC_cat_1->GetYaxis()->SetRangeUser(0,1.0); TGraphErrors *Z0ptC_catS_1 = new TGraphErrors(Nptbin, PT, cyld_catS_1, mom_err, ceyld_catS_1); Z0ptC_catS_1->SetMarkerStyle(8); Z0ptC_catS_1->SetMarkerColor(1); Z0ptC_catS_1->GetYaxis()->SetRangeUser(0,0.8); TLegend *legend_GP = new TLegend( 0.59,0.79,0.88,0.89); legend_GP->SetBorderSize(0); legend_GP->SetFillStyle(0); legend_GP->SetFillColor(0); legend_GP->SetTextSize(0.032); //legend_GP->AddEntry(Z0ptC_catS_1,"Pythia Gun in MB HI Data ", ""); legend_GP->AddEntry(Z0ptC_catS_1,"Pythia Gun in MB Hydjet ", ""); new TCanvas; Z0ptC_cat_1->SetMinimum(0.0); Z0ptC_cat_1->Draw("AP"); //Z0ptC_catS_1->Draw("sameP"); lcat_1->Draw("same"); legend_GP->Draw("same"); cout << endl << endl; Z0ptC_cat_1->Write(); }
void draw_jetEt(){ TColor *pal = new TColor(); Int_t kred = pal->GetColor(190, 0, 3); Int_t kgreen = pal->GetColor( 15, 85, 15); Int_t kazure = pal->GetColor( 0, 48, 97); Int_t kcyan = pal->GetColor( 0, 83, 98); TFile *fMBNZP = new TFile("../test/dijetAna_anaJet_MinBias.root"); TFile *fHENZP = new TFile("../test/dijetAna_anaJet_HardEnriched.root"); TFile *fHEZP = new TFile("../franktrees/dijetAna_JEx_ZP_Hard_proc0_all.root"); fMBNZP->cd("dijetAna_data"); TH1F *h1 = new TH1F("hMBNZP","hMBNZP",170,0,170); TTree *tMBNZP = (TTree*)fMBNZP->Get("dijetAna_data/djTree"); cout<<tMBNZP->GetEntries()<<endl; tMBNZP->Draw("nljet>>hMBNZP","abs(nljeta)<2."); fHENZP->cd("dijetAna_data"); TH1F *h2 = new TH1F("hHENZP","hHENZP",170,0,170); TTree *tHENZP = (TTree*)fHENZP->Get("dijetAna_data/djTree"); cout<<tHENZP->GetEntries()<<endl; tHENZP->Draw("nljet>>hHENZP","abs(nljeta)<2."); TH1F *h3 = new TH1F("hHEZP","hHEZP",170,0,170); TTree *tHEZP = (TTree*)fHEZP->Get("dijetAna_data/djTree"); cout<<tHEZP->GetEntries()<<endl; tHEZP->Draw("nljet>>hHEZP","abs(nljeta)<2."); h1->Scale(1./h1->Integral("width")); h2->Scale(1./h2->Integral("width")); h3->Scale(1./h3->Integral("width")); h1->SetTitle("Minimum Bias (NZP) vs. Hard Enriched (ZP, NZP)"); h1->GetXaxis()->SetTitle("E_{T} [GeV]"); h1->GetYaxis()->SetTitle("dN/dE_{T} (Arb. Norm.)"); h1->Draw(); h2->SetLineColor(kred); h2->Draw("sames"); h3->SetLineColor(4); h3->Draw("sames"); TLegend *t=new TLegend(0.5,0.5,0.9,0.8); t->SetBorderSize(0); t->SetFillStyle(0); t->AddEntry(h1,"Minimum Bias, NZP","l"); t->AddEntry(h2,"Hard Enriched, NZP","l"); t->AddEntry(h3,"Hard Enriched, ZP","l"); t->Draw(); }