RooWorkspace* makefit(char* filename, char* FitTitle, char* Outfile, double minMass, double maxMass, double mean_bw, double gamma_bw, double cutoff_cb, const char* plotOpt, const int nbins) { gROOT->ProcessLine(".L tdrstyle.C"); setTDRStyle(); gStyle->SetPadRightMargin(0.05); //Create Data Set RooRealVar mass("mass","m(EE)",minMass,maxMass,"GeV/c^{2}"); // RooDataSet *data = RooDataSet::read(filename,RooArgSet(mass)); // Reading everything from root tree instead TFile* treeFile = new TFile(filename); TTree* zeeTree = (TTree*) treeFile->Get("ZeeEvent"); float zMass; zeeTree->SetBranchAddress("mass", &zMass); RooArgSet zMassArgSet(mass); RooDataSet* data = new RooDataSet("data", "ntuple parameters", zMassArgSet); int nEntries = zeeTree->GetEntries(); for (int i = 0; i < nEntries; i++) { zeeTree->GetEntry(i); // Cutting manually the values outside of range (ugly but works...) if (zMass < minMass || zMass > maxMass) continue; zMassArgSet.setRealValue("mass", zMass); data->add(zMassArgSet); } // Closing file treeFile->Close(); //====================== Parameters=========================== //Crystal Ball parameters RooRealVar cbBias ("#Deltam_{CB}", "CB Bias", -.01, -10, 10, "GeV/c^{2}"); RooRealVar cbSigma("sigma_{CB}", "CB Width", 1.7, 0.02, 5.0, "GeV/c^{2}"); RooRealVar cbCut ("a_{CB}","CB Cut", 1.05, 0.1, 3.0); RooRealVar cbPower("n_{CB}","CB Order", 2.45, 0.1, 20.0); cbCut.setVal(cutoff_cb); //Breit_Wigner parameters RooRealVar bwMean("m_{Z}","BW Mean", 91.1876, "GeV/c^{2}"); bwMean.setVal(mean_bw); RooRealVar bwWidth("#Gamma_{Z}", "BW Width", 2.4952, "GeV/c^{2}"); bwWidth.setVal(gamma_bw); // Fix the Breit-Wigner parameters to PDG values bwMean.setConstant(kTRUE); bwWidth.setConstant(kTRUE); // Exponential Background parameters RooRealVar expRate("#lambda_{exp}", "Exponential Rate", -0.064, -1, 1); RooRealVar c0("c_{0}", "c0", 1., 0., 50.); //Number of Signal and Background events RooRealVar nsig("N_{S}", "# signal events", 524, 0.1, 10000000000.); RooRealVar nbkg("N_{B}", "# background events", 43, 1., 10000000.); //============================ P.D.F.s============================= // Mass signal for two decay electrons p.d.f. RooBreitWigner bw("bw", "bw", mass, bwMean, bwWidth); RooCBShape cball("cball", "Crystal Ball", mass, cbBias, cbSigma, cbCut, cbPower); RooFFTConvPdf BWxCB("BWxCB", "bw X crystal ball", mass, bw, cball); // Mass background p.d.f. RooExponential bg("bg", "exp. background", mass, expRate); // Mass model for signal electrons p.d.f. RooAddPdf model("model", "signal", RooArgList(BWxCB), RooArgList(nsig)); TStopwatch t ; t.Start() ; model.fitTo(*data,FitOptions("mh"),Optimize(0),Timer(1)); t.Print() ; TCanvas* c = new TCanvas("c","Unbinned Invariant Mass Fit", 0,0,800,600); //========================== Plotting ============================ //Create a frame RooPlot* plot = mass.frame(Range(minMass,maxMass),Bins(nbins)); // Add data and model to canvas data->plotOn(plot); model.plotOn(plot); model.paramOn(plot, Format(plotOpt, AutoPrecision(1)), Parameters(RooArgSet(cbBias, cbSigma, cbCut, cbPower, bwMean, bwWidth, expRate, nsig, nbkg)), Layout(0.66,0.63)); plot->getAttText()->SetTextSize(.03); plot->Draw(); // Print Fit Values TLatex *tex = new TLatex(); tex->SetNDC(); tex->SetTextSize(.04); tex->SetTextFont(2); tex->DrawLatex(0.195,0.875, "CMS ECAL, 2012"); tex->Draw(); tex->SetTextSize(0.022); tex->DrawLatex(0.195, 0.81, FitTitle); tex->DrawLatex(0.195, 0.75, "Z #rightarrow ee^{+}"); tex->SetTextSize(0.024); tex->DrawLatex(0.645, 0.59, Form("BW Mean = %.2f GeV/c^{2}", bwMean.getVal())); tex->DrawLatex(0.645, 0.54, Form("BW #sigma = %.2f GeV/c^{2}", bwWidth.getVal())); c->Update(); c->Print(Outfile); // tablefile << Form(Outfile + "& $ %f $ & $ %f $ & $ %f $\\ \hline",cbBias.getVal(), cbSigma.getVal(), cbCut.getVal()); // Output workspace with model and data RooWorkspace *w = new RooWorkspace("zfit"); w->import(model); w->import(*data); return w; }
TF1* fit(TTree* nt, TTree* ntMC, Double_t ptmin, Double_t ptmax, int isMC) { static int count=0; count++; TCanvas* c= new TCanvas(Form("c%d",count),"",600,600); TH1D* h = new TH1D(Form("h-%d",count),"",nbinsmasshisto,minhisto,maxhisto); TH1D* hMCSignal = new TH1D(Form("hMCSignal-%d",count),"",nbinsmasshisto,minhisto,maxhisto); TH1D* hMCSwapped = new TH1D(Form("hMCSwapped-%d",count),"",nbinsmasshisto,minhisto,maxhisto); TF1* f = new TF1(Form("f%d",count),"[0]*([7]*([9]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[9])*Gaus(x,[1],[10])/(sqrt(2*3.14159)*[10]))+(1-[7])*Gaus(x,[1],[8])/(sqrt(2*3.14159)*[8]))+[3]+[4]*x+[5]*x*x+[6]*x*x*x", 1.7, 2.0); if(isMC==1) nt->Project(Form("h-%d",count),"Dmass",Form("%s*(%s&&Dpt>%f&&Dpt<%f)",weight.Data(),seldata.Data(),ptmin,ptmax)); else nt->Project(Form("h-%d",count),"Dmass",Form("(%s&&Dpt>%f&&Dpt<%f)",seldata.Data(),ptmin,ptmax)); ntMC->Project(Form("hMCSignal-%d",count),"Dmass",Form("%s*(%s&&Dpt>%f&&Dpt<%f&&(Dgen==23333))",weight.Data(),selmc.Data(),ptmin,ptmax)); ntMC->Project(Form("hMCSwapped-%d",count),"Dmass",Form("%s*(%s&&Dpt>%f&&Dpt<%f&&(Dgen==23344))",weight.Data(),selmc.Data(),ptmin,ptmax)); /* TFile *fout=new TFile(Form("FitsFiles/Fits_%s_%d.root",collisionsystem.Data(),count),"recreate"); fout->cd(); hMCSignal->Write(); hMCSwapped->Write(); h->Write(); */ f->SetParLimits(4,-1000,1000); f->SetParLimits(10,0.001,0.05); f->SetParLimits(2,0.01,0.1); f->SetParLimits(8,0.02,0.2); f->SetParLimits(7,0,1); f->SetParLimits(9,0,1); f->SetParameter(0,setparam0); f->SetParameter(1,setparam1); f->SetParameter(2,setparam2); f->SetParameter(10,setparam10); f->SetParameter(9,setparam9); f->FixParameter(8,setparam8); f->FixParameter(7,1); f->FixParameter(1,fixparam1); f->FixParameter(3,0); f->FixParameter(4,0); f->FixParameter(5,0); f->FixParameter(6,0); h->GetEntries(); hMCSignal->Fit(Form("f%d",count),"q","",minhisto,maxhisto); hMCSignal->Fit(Form("f%d",count),"q","",minhisto,maxhisto); f->ReleaseParameter(1); hMCSignal->Fit(Form("f%d",count),"L q","",minhisto,maxhisto); hMCSignal->Fit(Form("f%d",count),"L q","",minhisto,maxhisto); hMCSignal->Fit(Form("f%d",count),"L m","",minhisto,maxhisto); f->FixParameter(1,f->GetParameter(1)); f->FixParameter(2,f->GetParameter(2)); f->FixParameter(10,f->GetParameter(10)); f->FixParameter(9,f->GetParameter(9)); f->FixParameter(7,0); f->ReleaseParameter(8); f->SetParameter(8,setparam8); hMCSwapped->Fit(Form("f%d",count),"L q","",minhisto,maxhisto); hMCSwapped->Fit(Form("f%d",count),"L q","",minhisto,maxhisto); hMCSwapped->Fit(Form("f%d",count),"L q","",minhisto,maxhisto); hMCSwapped->Fit(Form("f%d",count),"L m","",minhisto,maxhisto); f->FixParameter(7,hMCSignal->Integral(0,1000)/(hMCSwapped->Integral(0,1000)+hMCSignal->Integral(0,1000))); f->FixParameter(8,f->GetParameter(8)); f->ReleaseParameter(3); f->ReleaseParameter(4); f->ReleaseParameter(5); f->ReleaseParameter(6); f->SetLineColor(kRed); h->Fit(Form("f%d",count),"q","",minhisto,maxhisto); h->Fit(Form("f%d",count),"q","",minhisto,maxhisto); f->ReleaseParameter(1); //f->ReleaseParameter(2); // you need to release these two parameters if you want to perform studies on the sigma shape //f->ReleaseParameter(10); // you need to release these two parameters if you want to perform studies on the sigma shape h->Fit(Form("f%d",count),"L q","",minhisto,maxhisto); h->Fit(Form("f%d",count),"L q","",minhisto,maxhisto); h->Fit(Form("f%d",count),"L q","",minhisto,maxhisto); h->Fit(Form("f%d",count),"L m","",minhisto,maxhisto); TF1* background = new TF1(Form("background%d",count),"[0]+[1]*x+[2]*x*x+[3]*x*x*x"); background->SetParameter(0,f->GetParameter(3)); background->SetParameter(1,f->GetParameter(4)); background->SetParameter(2,f->GetParameter(5)); background->SetParameter(3,f->GetParameter(6)); background->SetLineColor(4); background->SetRange(minhisto,maxhisto); background->SetLineStyle(2); TF1* mass = new TF1(Form("fmass%d",count),"[0]*([3]*([4]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[4])*Gaus(x,[1],[5])/(sqrt(2*3.14159)*[5])))"); mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2),f->GetParameter(7),f->GetParameter(9),f->GetParameter(10)); mass->SetParError(0,f->GetParError(0)); mass->SetParError(1,f->GetParError(1)); mass->SetParError(2,f->GetParError(2)); mass->SetParError(3,f->GetParError(7)); mass->SetParError(4,f->GetParError(9)); mass->SetParError(5,f->GetParError(10)); mass->SetFillColor(kOrange-3); mass->SetFillStyle(3002); mass->SetLineColor(kOrange-3); mass->SetLineWidth(3); mass->SetLineStyle(2); TF1* massSwap = new TF1(Form("fmassSwap%d",count),"[0]*(1-[2])*Gaus(x,[1],[3])/(sqrt(2*3.14159)*[3])"); massSwap->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(7),f->GetParameter(8)); massSwap->SetParError(0,f->GetParError(0)); massSwap->SetParError(1,f->GetParError(1)); massSwap->SetParError(2,f->GetParError(7)); massSwap->SetParError(3,f->GetParError(8)); massSwap->SetFillColor(kGreen+4); massSwap->SetFillStyle(3005); massSwap->SetLineColor(kGreen+4); massSwap->SetLineWidth(3); massSwap->SetLineStyle(1); h->SetXTitle("m_{#piK} (GeV/c^{2})"); h->SetYTitle("Entries / (5 MeV/c^{2})"); h->GetXaxis()->CenterTitle(); h->GetYaxis()->CenterTitle(); h->SetAxisRange(0,h->GetMaximum()*1.4*1.2,"Y"); h->GetXaxis()->SetTitleOffset(1.3); h->GetYaxis()->SetTitleOffset(1.8); h->GetXaxis()->SetLabelOffset(0.007); h->GetYaxis()->SetLabelOffset(0.007); h->GetXaxis()->SetTitleSize(0.045); h->GetYaxis()->SetTitleSize(0.045); h->GetXaxis()->SetTitleFont(42); h->GetYaxis()->SetTitleFont(42); h->GetXaxis()->SetLabelFont(42); h->GetYaxis()->SetLabelFont(42); h->GetXaxis()->SetLabelSize(0.04); h->GetYaxis()->SetLabelSize(0.04); h->SetMarkerSize(0.8); h->SetMarkerStyle(20); h->SetStats(0); h->Draw("e"); background->Draw("same"); mass->SetRange(minhisto,maxhisto); mass->Draw("same"); massSwap->SetRange(minhisto,maxhisto); massSwap->Draw("same"); f->Draw("same"); Double_t yield = mass->Integral(minhisto,maxhisto)/binwidthmass; Double_t yieldErr = mass->Integral(minhisto,maxhisto)/binwidthmass*mass->GetParError(0)/mass->GetParameter(0); std::cout<<"YIELD="<<yield<<std::endl; TLegend* leg = new TLegend(0.65,0.58,0.82,0.88,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextSize(0.04); leg->SetTextFont(42); leg->SetFillStyle(0); leg->AddEntry(h,"Data","pl"); leg->AddEntry(f,"Fit","l"); leg->AddEntry(mass,"D^{0}+#bar{D^{#lower[0.2]{0}}} Signal","f"); leg->AddEntry(massSwap,"K-#pi swapped","f"); leg->AddEntry(background,"Combinatorial","l"); leg->Draw("same"); TLatex Tl; Tl.SetNDC(); Tl.SetTextAlign(12); Tl.SetTextSize(0.04); Tl.SetTextFont(42); Tl.DrawLatex(0.18,0.93, "#scale[1.25]{CMS} Preliminary"); Tl.DrawLatex(0.65,0.93, Form("%s #sqrt{s_{NN}} = 5.02 TeV",collisionsystem.Data())); TLatex* tex; tex = new TLatex(0.22,0.78,Form("%.1f < p_{T} < %.1f GeV/c",ptmin,ptmax)); tex->SetNDC(); tex->SetTextFont(42); tex->SetTextSize(0.04); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.22,0.83,"|y| < 1.0"); tex->SetNDC(); tex->SetTextFont(42); tex->SetTextSize(0.04); tex->SetLineWidth(2); tex->Draw(); h->GetFunction(Form("f%d",count))->Delete(); TH1F* histo_copy_nofitfun = ( TH1F * ) h->Clone("histo_copy_nofitfun"); histo_copy_nofitfun->Draw("esame"); // if(nBins==1) c->SaveAs(Form("DMass-inclusive%s_%d.pdf",collisionsystem.Data(),count)); else c->SaveAs(Form("DMass%s_%d.pdf",collisionsystem.Data(),count)); return mass; }
void analyzer_stack() { //int main(){ const int nfiles = 8; const int nhistos = 46; const int ndiscr = 5; TString leg_names[nfiles] = {/*"powheg, m(H) = 130 GeV","amc@NLO, m(H) = 125 GeV",*/"powheg, m(H) = 125 GeV" ,"QCD, H_{T}=100-200 GeV","QCD, H_{T}=200-300 GeV","QCD, H_{T}=300-500 GeV","QCD, H_{T}=500-700 GeV","QCD, H_{T}=700-1000 GeV","QCD, H_{T}=1500-2000 GeV","QCD, H_{T}=2000-Inf GeV"}; TString file_names[nfiles] = {/*"Spring15_powheg_M130","Spring15_amcatnlo_M125",*/"Spring15_powheg_M125","Spring15_QCD_HT100to200","Spring15_QCD_HT200to300","Spring15_QCD_HT300to500","Spring15_QCD_HT500to700","Spring15_QCD_HT700to1000","Spring15_QCD_HT1500to2000","Spring15_QCD_HT2000toInf"}; for (int i=0; i<nfiles; i++) { // file_names[i].Prepend("SingleBtag_"); file_names[i].Prepend("../data40pb/tree"); file_names[i].Append(".root"); } TString trigger = "DoubleBtag_"; //TString trigger = "SingleBtag_"; //TString dir_name= "plots_powheg_130/"; TString dir_name= "plots_powheg_125/"; //TString dir_name = "plots_amc/"; Double_t xsec[nfiles] = { /* 1.96, 2.16,*/2.16, 2.75E07, 6.52E03, 3.67E05, 2.94E04, 2.54E01, 1.74E06, 121.5 }; TLegend *leg = new TLegend(0.35,0.58,0.75,0.88); leg->SetBorderSize(0); leg->SetTextSize(0.04); TString hist_names[nhistos]= {"hJet1_pt","hJet2_pt","hJet3_pt","hJet4_pt","hJet1_eta","hJet2_eta","hJet3_eta","hJet4_eta","hJet1_phi","hJet2_phi","hJet3_phi","hJet4_phi","hMqq", "hEtaQQ", "hPhiBB", "hEtaSoftJets", "hPtSoftJets","hMassSoftJets","hHTsoft","hSoft_n2","hSoft_n5","hSoft_n10","hMbb","hqgl","hbtag","hqgl2","hbtag2","hPtSoftJets2","hPtSoftJets3","hcosOqqbb","hEtaQB1", "hEtaQB2", "hPhiQB1", "hPhiQB2","hx1","hx2","hVB1_mass","hVB2_mass","hEtot","hPxtot","hPytot","hPztot","hJet5_pt","hPtqqbb","hEtaqqbb","hPhiqqbb"}; std::string hist_names_sort[nhistos]; for (int i=0; i<nhistos; i++) { hist_names_sort[i] = hist_names[i]; } Float_t discriminators[nhistos]; TString stacks_names[nhistos]; for (int i=0; i<nhistos; i++) { stacks_names[i] = hist_names[i]; stacks_names[i].Prepend("s"); } TString output_names[nhistos]; for (int i=0; i<nhistos; i++) { output_names[i] = hist_names[i]; output_names[i].Prepend(dir_name); output_names[i].Prepend(trigger); output_names[i].Append(".png"); } const char *xaxis_names[100] = {"1^{st} Jet p_{T} (GeV)","2^{nd} Jet p_{T} (GeV)","3^{rd} Jet p_{T} (GeV)","4^{th} Jet p_{T} (GeV)","1^{st} Jet #eta", "2^{nd} Jet #eta", "3^{rd} Jet #eta", "4^{th} Jet #eta", "1^{st} Jet #phi", "2^{nd} Jet #phi", "3^{rd} Jet #phi", "4^{th} Jet #phi","m_{qq} (GeV)","|#Delta#eta_{qq}|","|#Delta#phi_{bb}|","#eta^{soft}","1^{st} Soft jet p_{T} (GeV)","m^{soft} (GeV)","H_{T}^{soft} (GeV)","N^{soft}","m_{bb} (GeV)", "QGL of the first quark jet candidate","CSV of 1^{st} b-jet","QGL of the second quark jet candidate","CSV of 2^{nd} b-jet","2^{nd} Soft jet p_{T} (GeV)","3^{rd} Soft jet p_{T} (GeV)","H_{T}^{soft 3 jets} (GeV)","cos#theta_{qqbb}","#Delta#eta_{qb}^{forward}","#Delta#eta_{qb}^{backward}","|#Delta#phi_{qb}^{forward}|","|#Delta#phi_{qb}^{backward}|","x_{1}","x_{2}","M_{W'_{1}} (GeV)","M_{W'_{2}} (GeV)","E^{tot} (GeV)","p_{x}^{tot} (GeV)","p_{y}^{tot} (GeV)","p_{z}^{tot} (GeV)", "5^{th} Jet p_{T} (GeV)"}; TH1F *signal_histos[100]; TH1F *discr_histos[100];//Mqq,delta eta, delta phi, qgl, btag //12,13,14,21,22 int discr_index[100] = {12,13,14,21,22};//not used now int files=0; THStack *stacks[100]; for (int i=0; i<nhistos; ++i) { stacks[i] = new THStack(stacks_names[i],""); } Double_t totalBG=0.; ofstream out_efficiency; ofstream out_discrimination; out_efficiency.open(trigger+dir_name+"efficiency.txt"); do { TFile *file_initial = new TFile(file_names[files]); file_initial->ls(); TString temp_number; temp_number.Form("%d",files); TH1F *histos[100]; for (int hist=0; hist<nhistos; ++hist) { histos[hist] = (TH1F*)file_initial->Get(hist_names[hist]); histos[hist]->Sumw2(kFALSE); // histos[hist]->Scale(40.); if (files==0) signal_histos[hist] = (TH1F*)file_initial->Get(hist_names[hist]); // signal_histos[hist]->Scale(40.); // histos[hist]->SetLineColor(1+files); // histos[hist]->SetFillColor(1+files); if (files==1) { histos[hist]->SetFillColor(kBlue-10); histos[hist]->SetLineColor(kBlue-10); } if (files==2) { histos[hist]->SetFillColor(kBlue); histos[hist]->SetLineColor(kBlue); } if (files==3) { histos[hist]->SetFillColor(kOrange); histos[hist]->SetLineColor(kOrange); } if (files==4) { histos[hist]->SetFillColor(kRed); histos[hist]->SetLineColor(kRed); } if (files==5) { histos[hist]->SetFillColor(kAzure+10); histos[hist]->SetLineColor(kAzure+10); } if (files==6) { histos[hist]->SetFillColor(kGreen+2); histos[hist]->SetLineColor(kGreen+2); } if (files==7) { histos[hist]->SetFillColor(kPink+9); histos[hist]->SetLineColor(kPink+9); } if (files==0) { histos[hist]->SetFillStyle(3324); histos[hist]->SetFillColor(1); histos[hist]->SetLineColor(1); signal_histos[hist]->SetFillStyle(3324); signal_histos[hist]->SetLineColor(1); signal_histos[hist]->SetFillColor(1); } if (files>=0)stacks[hist]->Add(histos[hist]); if (hist==0) leg->AddEntry(histos[hist],leg_names[files],"F"); if (files==1) { discr_histos[hist] = (TH1F*)file_initial->Get(hist_names[hist]); } if ((files>1)) { discr_histos[hist]->Add(histos[hist]); } } if (files!=0) totalBG+=histos[4]->Integral(); if (files==0) out_efficiency<<"Sample & \t\t\t yield(per $fb^{-1}$)& \t efficiency"<<endl; if (files==0) out_efficiency<<leg_names[files]<<"&\t \t \t"<<histos[5]->Integral()*1000. <<"&\t"<< histos[5]->Integral()/xsec[files] <<endl; else out_efficiency<<leg_names[files]<<"&\t "<<histos[4]->Integral()*1000. <<"&\t"<< histos[4]->Integral()/xsec[files] <<endl; if (files==nfiles-1) out_efficiency<<"Total BG"<<"&\t \t \t "<<totalBG*1000.<< endl; files++; } while (files<nfiles); out_efficiency.close(); for (int d=0; d<nhistos; d++) { discriminators[d] = Discr(discr_histos[d],signal_histos[d]); } bubblesort(discriminators, hist_names_sort,nhistos); out_discrimination.open(trigger+dir_name+"discrimination.txt"); for (int d=0; d<nhistos; d++) { if (d==0) out_discrimination<<"Variable &\t d"<<endl; out_discrimination<<"$"<<hist_names_sort[d]<<"$"<<" & \t "<< std::setprecision(2)<< discriminators[d]<<endl; } out_discrimination.close(); TLatex* tex = new TLatex(0.90,0.92,"13 TeV, PU = 20, bx = 25 ns, 1 pb^{-1}"); tex->SetNDC(); tex->SetTextAlign(35); tex->SetTextFont(42); tex->SetTextSize(0.04); tex->SetLineWidth(2); TLatex *tex1 = new TLatex(0.13,0.83,"CMS"); tex1->SetNDC(); tex1->SetTextAlign(20); tex1->SetTextFont(61); tex1->SetTextSize(0.06); tex1->SetLineWidth(2); TLatex* tex2 = new TLatex(0.22,0.77,"Work in progress"); tex2->SetNDC(); tex2->SetTextAlign(20); tex2->SetTextFont(52); tex2->SetTextSize(0.04); tex2->SetLineWidth(2); TLatex* tex_file = new TLatex(0.35,0.92,"Spring15, DoubleBtag"); // TLatex* tex_file = new TLatex(0.35,0.92,"Spring15, SingleBtag"); tex_file->SetNDC(); tex_file->SetTextAlign(35); tex_file->SetTextFont(42); tex_file->SetTextSize(0.04); tex_file->SetLineWidth(2); for (int i=0; i<nhistos; i++) { TString temp_str; temp_str.Form("%2.2f",Discr(discr_histos[i],signal_histos[i])); TString disc_value = temp_str.Prepend(", d = "); TLatex *disc_value_text = new TLatex(0.86,0.853,disc_value); disc_value_text->SetNDC(); disc_value_text->SetTextAlign(35); disc_value_text->SetTextFont(42); disc_value_text->SetTextSize(0.04); disc_value_text->SetLineWidth(2); TCanvas *c1 = new TCanvas(); c1->SetBottomMargin(.12); c1->cd(); c1->SetLogy(); Double_t xmin = signal_histos[i]->GetBinCenter(0); Double_t xmax = signal_histos[i]->GetBinCenter(signal_histos[i]->GetNbinsX()); TH1F *frame = new TH1F("frame","",1,xmin,xmax); frame->SetMinimum(1e-4); frame->SetMaximum(1e10); frame->GetYaxis()->SetTitleOffset(0.9); frame->GetXaxis()->SetTitleOffset(0.91); frame->SetStats(0); frame->SetTitleFont(42,"x"); frame->SetTitleFont(42,"y"); frame->SetTitleSize(0.05, "XYZ"); frame->SetXTitle(signal_histos[i]->GetXaxis()->GetTitle()); if ((i<4))frame->SetYTitle("Events / 20 GeV"); else if (i==37)frame->SetYTitle("Events / 20 GeV"); else if (i==41)frame->SetYTitle("Events / 20 GeV"); else if ((i>=4) && (i<8)) frame->SetYTitle("Events / 0.5"); else if (i==15) frame->SetYTitle("Events / 0.5"); else if ((i>=8) && (i<12)) frame->SetYTitle("Events / 0.2"); else if (i==40) frame->SetYTitle("Events / 100 GeV"); else if ((i==10)||(i==12)||(i==16)||(i==17)||(i==18) || (i==20) || (i==25) || (i==26) || (i==27) || (i==35) || (i==36) ||(i==38) || (i==39)) frame->SetYTitle("Events / 10 GeV"); else if ((i==13)||(i==14)) frame->SetYTitle("Events / 0.1"); else if ((i==21)||(i==22)) frame->SetYTitle("Events / 0.05"); else if ((i==23)||(i==24)) frame->SetYTitle("Events / 0.01"); else if (i==28) frame->SetYTitle("Events / 0.02"); else if ((i==29) || (i==30) || (i==31) || (i==32) )frame->SetYTitle("Events / 0.1"); else if ((i==33) || (i==33))frame->SetYTitle("Events / 0.01"); else frame->SetYTitle("Events"); frame->Draw(); tex->Draw(); tex1->Draw(); tex2->Draw(); tex_file->Draw(); stacks[i]->Draw("nostacksame"); leg->Draw("same"); signal_histos[i]->Draw("same"); disc_value_text->Draw(); c1->Print(output_names[i]); c1->Delete(); } }
int multiple_detector_fit() { std::cout << "Beginning : ... " << std::endl; Int_t npoints = 1000; Double_t emin = 0.2; Double_t emax = 3.0; bool use100m = true; bool use470m = true; bool use600m = true; std::vector<int> baselines; std::vector<double> scales; std::vector<std::string> names; std::vector<double> volume; if (use100m) baselines.push_back(100); if (use470m) baselines.push_back(470); if (use600m) baselines.push_back(600); double NULLVec[2][20]; double OscVec[2][1001][7][20]; for(int i = 0; i < 20; i++){ NULLVec[0][i] = 0; NULLVec[1][i] = 0; } for(int u = 0; u < 1000; u++){ for(int s = 0; s < 7; s++){ for(int i = 0; i < 20; i++){ OscVec[0][u][s][i] = 0; OscVec[1][u][s][i] = 0; } } } int nbinsE = 0; if (use100m){ std::string temp_name = /*"../MatrixFiles/combined_ntuple_100m_nu_processed_numu.root";*/"../MatrixFiles/combined_ntuple_100m_nu_processed_CoreyBins_numu.root"; TFile temp_file(temp_name.c_str()); TH1D *NULL_100; NULL_100 = (TH1D*)(temp_file.Get("NumuCC")); nbinsE = NULL_100->GetNbinsX(); std::cout << nbinsE << std::endl; for(int i = 1; i <= nbinsE; i++){ NULLVec[0][i-1] = (NULL_100->GetBinContent(i)); } for(int u = 0; u < npoints; u++){ for(int s = 0; s < 7; s++){ TH1D *OSC_100; TString upoint = Form("%d",u); TString name = "Universe_"; TString name2 = "_MultiSim_"; TString mul = Form("%d",s); name += upoint; name += name2; name += mul; OSC_100 = (TH1D*)(temp_file.Get(name)); for(int i = 1; i <= nbinsE; i++){ OscVec[0][u][s][i-1] = (OSC_100->GetBinContent(i)); // if(OscVec[0][u][s][i-1] != OscVec[0][u][s][i-1]) std::cout << "erm" <<std::endl; } delete OSC_100; } } delete NULL_100; temp_file.Close(); } if (use470m){ std::string temp_name = /*"../MatrixFiles/combined_ntuple_600m_onaxis_nu_processed_numu.root";*/"../MatrixFiles/combined_ntuple_600m_onaxis_nu_processed_CoreyBins_numu.root"; TFile temp_file(temp_name.c_str()); TH1D *NULL_470; NULL_470 = (TH1D*)(temp_file.Get("NumuCC")); nbinsE = NULL_470->GetNbinsX(); std::cout << nbinsE<< std::endl; for(int i = 1; i <= nbinsE; i++){ NULLVec[1][i-1] = (NULL_470->GetBinContent(i)); } for(int u = 0; u < npoints; u++){ for(int s = 0; s < 7; s++){ TH1D *OSC_470; TString upoint = Form("%d",u);//std::to_string(u); TString name = "Universe_"; TString name2 = "_MultiSim_"; TString mul = Form("%d",s);// = std::to_string(s); name += upoint; name += name2; name += mul; OSC_470 = (TH1D*)(temp_file.Get(name)); for(int i = 1; i <= nbinsE; i++){ OscVec[1][u][s][i-1] = (OSC_470->GetBinContent(i)); if(OscVec[1][u][s][i-1] != OscVec[1][u][s][i-1]) OscVec[1][u][s][i-1] = NULLVec[1][i-1];//std::cout << "erm, u :" << u << " s : " << s << " E : " << i <<std::endl; } delete OSC_470; } } delete NULL_470; temp_file.Close(); } int nL = 2; int mbins = (nbinsE*nL); TMatrix M6 (mbins,mbins); TMatrix M5 (mbins,mbins); TMatrix M4 (mbins,mbins); TMatrix M3 (mbins,mbins); TMatrix M2 (mbins,mbins); TMatrix M1 (mbins,mbins); TMatrix M0 (mbins,mbins); TMatrix C6 (mbins,mbins); TMatrix C5 (mbins,mbins); TMatrix C4 (mbins,mbins); TMatrix C3 (mbins,mbins); TMatrix C2 (mbins,mbins); TMatrix C1 (mbins,mbins); TMatrix C0 (mbins,mbins); int N = 0; TH1D *Fig6 = new TH1D("Fig6",";;",mbins,0,mbins); TH1D *Fig5 = new TH1D("Fig5",";;",mbins,0,mbins); TH1D *Fig4 = new TH1D("Fig4",";;",mbins,0,mbins); TH1D *Fig3 = new TH1D("Fig3",";;",mbins,0,mbins); TH1D *Fig2 = new TH1D("Fig2",";;",mbins,0,mbins); TH1D *Fig1 = new TH1D("Fig1",";;",mbins,0,mbins); TH1D *Fig0 = new TH1D("Fig0",";;",mbins,0,mbins); int Erri = 0, Errj = 0; std::cout << "Filling Error Matrix..." << std::endl; for(int Lrow = 0; Lrow < 2; Lrow++){ for(int Erow = 0; Erow < nbinsE; Erow++){ Errj = 0; for(int Lcol = 0; Lcol < 2; Lcol++){ for(int Ecol = 0; Ecol < nbinsE; Ecol++){ M6 (Erri,Errj) = 0; M5 (Erri,Errj) = 0; M4 (Erri,Errj) = 0; M3 (Erri,Errj) = 0; M2 (Erri,Errj) = 0; M1 (Erri,Errj) = 0; M0 (Erri,Errj) = 0; N = 0; for(int u = 0; u < npoints; u++){ M6 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][6][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][6][Ecol]); M5 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][5][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][5][Ecol]); M4 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][4][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][4][Ecol]); M3 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][3][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][3][Ecol]); M2 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][2][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][2][Ecol]); M1 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][1][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][1][Ecol]); M0 (Erri,Errj) += (NULLVec[Lrow][Erow]-OscVec[Lrow][u][0][Erow])*(NULLVec[Lcol][Ecol]-OscVec[Lcol][u][0][Ecol]); N++; } M6 (Erri,Errj) /= N; M5 (Erri,Errj) /= N; M4 (Erri,Errj) /= N; M3 (Erri,Errj) /= N; M2 (Erri,Errj) /= N; M1 (Erri,Errj) /= N; M0 (Erri,Errj) /= N; M6 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M5 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M4 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M3 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M2 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M1 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; M0 (Erri,Errj) /= NULLVec[Lrow][Erow]*NULLVec[Lcol][Ecol]; if(Erri == Errj) Fig6->SetBinContent(Erri+1, sqrt(M6 (Erri,Errj))); if(Erri == Errj) Fig5->SetBinContent(Erri+1, sqrt(M5 (Erri,Errj))); if(Erri == Errj) Fig4->SetBinContent(Erri+1, sqrt(M4 (Erri,Errj))); if(Erri == Errj) Fig3->SetBinContent(Erri+1, sqrt(M3 (Erri,Errj))); if(Erri == Errj) Fig2->SetBinContent(Erri+1, sqrt(M2 (Erri,Errj))); if(Erri == Errj) Fig1->SetBinContent(Erri+1, sqrt(M1 (Erri,Errj))); if(Erri == Errj) Fig0->SetBinContent(Erri+1, sqrt(M0 (Erri,Errj))); std::cout << M6 (Erri,Errj) << "\t"; Errj++; }} Erri++; }} for(int i = 0; i < Erri; i++){ for(int j = 0; j < Errj; j++){ C6 (i,j) = M6(i,j) / sqrt(M6 (i,i) * M6 (j,j)); C5 (i,j) = M5(i,j) / sqrt(M5 (i,i) * M5 (j,j)); C4 (i,j) = M4(i,j) / sqrt(M4 (i,i) * M4 (j,j)); C3 (i,j) = M3(i,j) / sqrt(M3 (i,i) * M3 (j,j)); C2 (i,j) = M2(i,j) / sqrt(M2 (i,i) * M2 (j,j)); C1 (i,j) = M1(i,j) / sqrt(M1 (i,i) * M1 (j,j)); C0 (i,j) = M0(i,j) / sqrt(M0 (i,i) * M0 (j,j)); } } std::cout << "...Error Matrix Filled" << std::endl; TCanvas* c6 = new TCanvas("c6","",700,700); c6->SetLeftMargin(.1); c6->SetBottomMargin(.1); c6->SetTopMargin(.075); c6->SetRightMargin(.15); c6->cd(); M6.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); // TMatrixFBase->GetZaxis()->SetRangeUser(-0.05,0.4); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); // TMatrixFBase->GetZaxis()->SetTitle("Fractional Error Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kBlue); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *ND = new TLatex(.15,.01,"LAr1-ND (100m) "); ND->SetNDC(); ND->SetTextFont(62); ND->SetTextSize(0.04); ND->Draw(); TLatex *MD = new TLatex(.5,.01,"T600 (600m, on axis)"); MD->SetNDC(); MD->SetTextFont(62); MD->SetTextSize(0.04); MD->Draw(); TLatex *ND45 = new TLatex(.05,.15,"LAr1-ND (100m) "); ND45->SetNDC(); ND45->SetTextAngle(90); ND45->SetTextFont(62); ND45->SetTextSize(0.04); ND45->Draw(); TLatex *MD45 = new TLatex(.05,.54,"T600 (600m, on axis)"); MD45->SetNDC(); MD45->SetTextAngle(90); MD45->SetTextFont(62); MD45->SetTextSize(0.04); MD45->Draw(); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} Flux Fractional Error Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); // c6->Print("total_matrix.pdf"); TCanvas* c61 = new TCanvas("c61","",700,700); c61->SetLeftMargin(.1); c61->SetBottomMargin(.1); c61->SetTopMargin(.075); c61->SetRightMargin(.15); c61->cd(); C6.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kYellow); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} Flux Correlation Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); // c61->Print("total_correlation_matrix.pdf"); TCanvas* c5 = new TCanvas("c5","",700,700); c5->SetLeftMargin(.1); c5->SetBottomMargin(.1); c5->SetTopMargin(.075); c5->SetRightMargin(.15); c5->cd(); M5.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); // TMatrixFBase->GetZaxis()->SetTitle("K^{+} Covariance Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kBlue); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{+} Fractional Error Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c5->Print("mult5_matrix.pdf"); TCanvas* c51 = new TCanvas("c51","",700,700); c51->SetLeftMargin(.1); c51->SetBottomMargin(.1); c51->SetTopMargin(.075); c51->SetRightMargin(.15); c51->cd(); C5.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); // TMatrixFBase->GetZaxis()->SetTitle("K#lower[-0.15]{+} Correlation Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kYellow); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{+} Correlation Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c51->Print("mult5_correlation_matrix.pdf"); TCanvas* c4 = new TCanvas("c4","",700,700); c4->SetLeftMargin(.1); c4->SetBottomMargin(.1); c4->SetTopMargin(.075); c4->SetRightMargin(.15); c4->cd(); M4.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); //TMatrixFBase->GetZaxis()->SetTitle("K#lower[-0.15]{-} Covariance Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kBlue); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{-} Fractional Error Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c4->Print("mult4_matrix.pdf"); TCanvas* c41 = new TCanvas("c41","",700,700); c41->SetLeftMargin(.1); c41->SetBottomMargin(.1); c41->SetTopMargin(.075); c41->SetRightMargin(.15); c41->cd(); C4.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); // TMatrixFBase->GetZaxis()->SetTitle("K#lower[-0.15]{-} Correlation Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kYellow); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{-} Correlation Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c41->Print("mult4_correlation_matrix.pdf"); TCanvas* c3 = new TCanvas("c3","",700,700); c3->SetLeftMargin(.1); c3->SetBottomMargin(.1); c3->SetTopMargin(.075); c3->SetRightMargin(.15); c3->cd(); M3.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); //TMatrixFBase->GetZaxis()->SetTitle("K#lower[-0.15]{0} Covariance Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kBlue); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{0} Fractional Error Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c3->Print("mult3_matrix.pdf"); TCanvas* c31 = new TCanvas("c31","",700,700); c31->SetLeftMargin(.1); c31->SetBottomMargin(.1); c31->SetTopMargin(.075); c31->SetRightMargin(.15); c31->cd(); C3.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); //TMatrixFBase->GetZaxis()->SetTitle("K#lower[-0.15]{0} Correlation Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kYellow); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} K#lower[-0.15]{0} Correlation Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c31->Print("mult3_correlation_matrix.pdf"); TCanvas* c2 = new TCanvas("c2","",700,700); c2->SetLeftMargin(.1); c2->SetBottomMargin(.1); c2->SetTopMargin(.075); c2->SetRightMargin(.15); c2->cd(); M2.Draw("COLZ"); gStyle->SetPalette(56,0); //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045); TMatrixFBase->SetContour(999); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); //TMatrixFBase->GetZaxis()->SetTitle("#pi#lower[-0.15]{+} Covariance Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kBlue); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} #pi#lower[-0.15]{+} Fractional Error Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c2->Print("mult2_matrix.pdf"); TCanvas* c21 = new TCanvas("c21","",700,700); c21->SetLeftMargin(.1); c21->SetBottomMargin(.1); c21->SetTopMargin(.075); c21->SetRightMargin(.15); c21->cd(); C2.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); //TMatrixFBase->GetZaxis()->SetTitle("#pi#lower[-0.15]{+} Correlation Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kYellow); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} #pi#lower[-0.15]{+} Correlation Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c21->Print("mult2_correlation_matrix.pdf"); TCanvas* c1 = new TCanvas("c1","",700,700); c1->SetLeftMargin(.1); c1->SetBottomMargin(.1); c1->SetTopMargin(.075); c1->SetRightMargin(.15); c1->cd(); M1.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); //TMatrixFBase->GetZaxis()->SetTitle("#pi#lower[-0.15]{-} Covariance Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kBlue); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} #pi#lower[-0.15]{-} Fractional Error Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c1->Print("mult1_matrix.pdf"); TCanvas* c11 = new TCanvas("c11","",700,700); c11->SetLeftMargin(.1); c11->SetBottomMargin(.1); c11->SetTopMargin(.075); c11->SetRightMargin(.15); c11->cd(); C1.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); // TMatrixFBase->GetZaxis()->SetTitle("#pi#lower[-0.15]{-} Correlation Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kYellow); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} #pi#lower[-0.15]{-} Correlation Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c11->Print("mult1_correlation_matrix.pdf"); TCanvas* c0 = new TCanvas("c0","",700,700); c0->SetLeftMargin(.1); c0->SetBottomMargin(.1); c0->SetTopMargin(.075); c0->SetRightMargin(.15); c0->cd(); M0.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-0.005,0.045); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); // TMatrixFBase->GetZaxis()->SetTitle("Beam UniSim Covariance Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kBlue); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} Beam Fractional Error Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c0->Print("mult0_matrix.pdf"); TCanvas* c01 = new TCanvas("c01","",700,700); c01->SetLeftMargin(.1); c01->SetBottomMargin(.1); c01->SetTopMargin(.075); c01->SetRightMargin(.15); c01->cd(); C0.Draw("COLZ"); gStyle->SetPalette(56,0); TMatrixFBase->SetContour(999); //TMatrixFBase->GetZaxis()->SetRangeUser(-1,1); TMatrixFBase->GetZaxis()->SetTitleFont(62); TMatrixFBase->GetZaxis()->SetLabelFont(62); TMatrixFBase->GetZaxis()->SetTitleSize(0.045); // TMatrixFBase->GetZaxis()->SetTitle("Beam UniSim Correlation Matrix"); TMatrixFBase->GetZaxis()->SetTitleOffset(1.5); TMatrixFBase->GetXaxis()->SetTitle(""); TMatrixFBase->GetXaxis()->SetLabelSize(0); TMatrixFBase->GetXaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetTitle(""); TMatrixFBase->GetYaxis()->SetTitleOffset(1.5); TMatrixFBase->GetYaxis()->SetLabelSize(0); TMatrixFBase->SetStats(0); TLine *split = new TLine(); split->SetLineStyle(2); split->SetLineWidth(5); split->SetLineColor(kYellow); split->DrawLineNDC(.1,.51,.849,.51); split->DrawLineNDC(.475,.101,.475,.930); add_plot_label("| 0.2 #minus 3.0 GeV | 0.2 #minus 3.0 GeV | ", 0.48,0.08,0.03); TLatex *Total = new TLatex(.2,.96,"#nu#lower[0.3]{#mu} Beam Correlation Matrix"); Total->SetNDC(); Total->SetTextFont(62); Total->SetTextSize(0.045); Total->Draw(); ND->Draw(); MD->Draw(); ND45->Draw(); MD45->Draw(); // c01->Print("mult0_correlation_matrix.pdf"); TCanvas* c86 = new TCanvas("c86","",800,400); c86->SetLeftMargin(.1); c86->SetBottomMargin(.1); c86->SetTopMargin(.05); c86->SetRightMargin(.05); c86->cd(); Fig6->GetYaxis()->SetTitle("Fractional Error"); Fig6->GetYaxis()->SetTitleFont(62); Fig6->GetXaxis()->SetTitleFont(62); Fig6->GetYaxis()->SetLabelFont(62); Fig6->GetXaxis()->SetLabelFont(62); Fig6->GetYaxis()->CenterTitle(); Fig6->GetYaxis()->SetTitleSize(0.06); Fig6->GetYaxis()->SetTitleOffset(0.8); Fig6->GetXaxis()->SetLabelSize(0.06); Fig6->GetYaxis()->SetLabelSize(0.06); Fig6->GetXaxis()->SetTitleOffset(1.5); Fig6->SetStats(0); Fig6->SetMinimum(-0.01); Fig6->SetMaximum(0.21); Fig6->SetMarkerStyle(8); Fig6->GetYaxis()->SetNdivisions(509); Fig6->GetXaxis()->SetNdivisions(509); Fig6->Draw("P"); split->SetLineColor(1); split->SetLineWidth(2); split->DrawLine(19,-0.01,19,0.21); TLatex *ND = new TLatex(.23,.85,"LAr1-ND (100m) "); ND->SetNDC(); ND->SetTextFont(62); ND->SetTextSize(0.05); ND->Draw(); TLatex *MD = new TLatex(.65,.85,"T600 (600m, on axis)"); MD->SetNDC(); MD->SetTextFont(62); MD->SetTextSize(0.05); MD->Draw(); // c86->Print("FractionalErrors_Total.pdf"); TCanvas* c85 = new TCanvas("c85","",800,400); c85->SetLeftMargin(.1); c85->SetBottomMargin(.1); c85->SetTopMargin(.05); c85->SetRightMargin(.05); c85->cd(); Fig5->GetYaxis()->SetTitle("K#lower[-0.2]{+} Fractional Error"); Fig5->GetYaxis()->SetTitleFont(62); Fig5->GetXaxis()->SetTitleFont(62); Fig5->GetYaxis()->SetLabelFont(62); Fig5->GetXaxis()->SetLabelFont(62); Fig5->GetYaxis()->CenterTitle(); Fig5->GetYaxis()->SetTitleSize(0.06); Fig5->GetYaxis()->SetTitleOffset(0.8); Fig5->GetXaxis()->SetLabelSize(0.06); Fig5->GetYaxis()->SetLabelSize(0.06); Fig5->GetXaxis()->SetTitleOffset(1.5); Fig5->SetStats(0); Fig5->SetMinimum(-0.01); Fig5->SetMaximum(0.21); Fig5->SetMarkerStyle(8); Fig5->GetYaxis()->SetNdivisions(509); Fig5->GetXaxis()->SetNdivisions(509); Fig5->Draw("P"); split->SetLineColor(1); split->SetLineWidth(2); split->DrawLine(19,-0.01,19,0.21); ND->Draw(); MD->Draw(); // c85->Print("FractionalErrors_Kplus.pdf"); TCanvas* c84 = new TCanvas("c84","",800,400); c84->SetLeftMargin(.1); c84->SetBottomMargin(.1); c84->SetTopMargin(.05); c84->SetRightMargin(.05); c84->cd(); Fig4->GetYaxis()->SetTitle("K#lower[-0.2]{-} Fractional Error"); Fig4->GetYaxis()->SetTitleFont(62); Fig4->GetXaxis()->SetTitleFont(62); Fig4->GetYaxis()->SetLabelFont(62); Fig4->GetXaxis()->SetLabelFont(62); Fig4->GetYaxis()->CenterTitle(); Fig4->GetYaxis()->SetTitleSize(0.06); Fig4->GetYaxis()->SetTitleOffset(0.8); Fig4->GetXaxis()->SetLabelSize(0.06); Fig4->GetYaxis()->SetLabelSize(0.06); Fig4->GetXaxis()->SetTitleOffset(1.5); Fig4->SetStats(0); Fig4->SetMinimum(-0.01); Fig4->SetMaximum(0.21); Fig4->SetMarkerStyle(8); Fig4->GetYaxis()->SetNdivisions(509); Fig4->GetXaxis()->SetNdivisions(509); Fig4->Draw("P"); split->SetLineColor(1); split->SetLineWidth(2); split->DrawLine(19,-0.01,19,0.21); ND->Draw(); MD->Draw(); // c84->Print("FractionalErrors_Kmin.pdf"); TCanvas* c83 = new TCanvas("c83","",800,400); c83->SetLeftMargin(.1); c83->SetBottomMargin(.1); c83->SetTopMargin(.05); c83->SetRightMargin(.05); c83->cd(); Fig3->GetYaxis()->SetTitle("K#lower[-0.2]{0} Fractional Error"); Fig3->GetYaxis()->SetTitleFont(62); Fig3->GetXaxis()->SetTitleFont(62); Fig3->GetYaxis()->SetLabelFont(62); Fig3->GetXaxis()->SetLabelFont(62); Fig3->GetYaxis()->CenterTitle(); Fig3->GetYaxis()->SetTitleSize(0.06); Fig3->GetYaxis()->SetTitleOffset(0.8); Fig3->GetXaxis()->SetLabelSize(0.06); Fig3->GetYaxis()->SetLabelSize(0.06); Fig3->GetXaxis()->SetTitleOffset(1.5); Fig3->SetStats(0); Fig3->SetMinimum(-0.01); Fig3->SetMaximum(0.21); Fig3->SetMarkerStyle(8); Fig3->GetYaxis()->SetNdivisions(509); Fig3->GetXaxis()->SetNdivisions(509); Fig3->Draw("P"); split->SetLineColor(1); split->SetLineWidth(2); split->DrawLine(19,-0.01,19,0.21); ND->Draw(); MD->Draw(); // c83->Print("FractionalErrors_K0.pdf"); TCanvas* c82 = new TCanvas("c82","",800,400); c82->SetLeftMargin(.1); c82->SetBottomMargin(.1); c82->SetTopMargin(.05); c82->SetRightMargin(.05); c82->cd(); Fig2->GetYaxis()->SetTitle("#pi#lower[-0.2]{+} Fractional Error"); Fig2->GetYaxis()->SetTitleFont(62); Fig2->GetXaxis()->SetTitleFont(62); Fig2->GetYaxis()->SetLabelFont(62); Fig2->GetXaxis()->SetLabelFont(62); Fig2->GetYaxis()->CenterTitle(); Fig2->GetYaxis()->SetTitleSize(0.06); Fig2->GetYaxis()->SetTitleOffset(0.8); Fig2->GetXaxis()->SetLabelSize(0.06); Fig2->GetYaxis()->SetLabelSize(0.06); Fig2->GetXaxis()->SetTitleOffset(1.5); Fig2->SetStats(0); Fig2->SetMinimum(-0.01); Fig2->SetMaximum(0.21); Fig2->SetMarkerStyle(8); Fig2->GetYaxis()->SetNdivisions(509); Fig2->GetXaxis()->SetNdivisions(509); Fig2->Draw("P"); split->SetLineColor(1); split->SetLineWidth(2); split->DrawLine(19,-0.01,19,0.21); ND->Draw(); MD->Draw(); // c82->Print("FractionalErrors_piplus.pdf"); TCanvas* c81 = new TCanvas("c81","",800,400); c81->SetLeftMargin(.1); c81->SetBottomMargin(.1); c81->SetTopMargin(.05); c81->SetRightMargin(.05); c81->cd(); Fig1->GetYaxis()->SetTitle("#pi#lower[-0.2]{-} Fractional Error"); Fig1->GetYaxis()->SetTitleFont(62); Fig1->GetXaxis()->SetTitleFont(62); Fig1->GetYaxis()->SetLabelFont(62); Fig1->GetXaxis()->SetLabelFont(62); Fig1->GetYaxis()->CenterTitle(); Fig1->GetYaxis()->SetTitleSize(0.06); Fig1->GetYaxis()->SetTitleOffset(0.8); Fig1->GetXaxis()->SetLabelSize(0.06); Fig1->GetYaxis()->SetLabelSize(0.06); Fig1->GetXaxis()->SetTitleOffset(1.5); Fig1->SetStats(0); Fig1->SetMinimum(-0.01); Fig1->SetMaximum(0.21); Fig1->SetMarkerStyle(8); Fig1->GetYaxis()->SetNdivisions(509); Fig1->GetXaxis()->SetNdivisions(509); Fig1->Draw("P"); split->SetLineColor(1); split->SetLineWidth(2); split->DrawLine(19,-0.01,19,0.21); ND->Draw(); MD->Draw(); // c81->Print("FractionalErrors_pimin.pdf"); TCanvas* c80 = new TCanvas("c80","",800,400); c80->SetLeftMargin(.1); c80->SetBottomMargin(.1); c80->SetTopMargin(.05); c80->SetRightMargin(.05); c80->cd(); Fig0->GetYaxis()->SetTitle("Beam Fractional Error"); Fig0->GetYaxis()->SetTitleFont(62); Fig0->GetXaxis()->SetTitleFont(62); Fig0->GetYaxis()->SetLabelFont(62); Fig0->GetXaxis()->SetLabelFont(62); Fig0->GetYaxis()->CenterTitle(); Fig0->GetYaxis()->SetTitleSize(0.06); Fig0->GetYaxis()->SetTitleOffset(0.8); Fig0->GetXaxis()->SetLabelSize(0.06); Fig0->GetYaxis()->SetLabelSize(0.06); Fig0->GetXaxis()->SetTitleOffset(1.5); Fig0->SetStats(0); Fig0->SetMinimum(-0.01); Fig0->SetMaximum(0.21); Fig0->SetMarkerStyle(8); Fig0->GetYaxis()->SetNdivisions(509); Fig0->GetXaxis()->SetNdivisions(509); Fig0->Draw("P"); split->SetLineColor(1); split->SetLineWidth(2); split->DrawLine(19,-0.01,19,0.21); ND->Draw(); MD->Draw(); // c80->Print("FractionalErrors_beam.pdf"); cout<<"\nEnd of routine.\n"; return 0; }
void getX0() { gROOT->Reset(); gROOT->LoadMacro("fitfun.C"); // fit function for localY, local Z const Int_t N = 120; const Int_t M = 7; // number of module angle groups //histograms to check the par2 and par3 distributions TH1D *hPar2 = new TH1D("Par2","",500,0., 5.); TH1D *hPar3 = new TH1D("Par3","",500,0., 1.); Double_t a[M] = {0., 16., 20., 22., 26., 30., 32.}; TH2D *zLocal2D[M]; TH1D *zLocal[N][M]; TFile *fin = new TFile("align.root"); for(int j=0;j<M;j++) { char inhis[100]; sprintf(inhis,"zLocal_%d",j); zLocal2D[j] = (TH2D *)fin->Get(inhis); zLocal2D[j]->RebinY(5); for(int i=0;i<N;i++) { char hisname[100]; sprintf(hisname,"Tray_%d_A_%d",i+1,j); zLocal[i][j] = zLocal2D[j]->ProjectionY(hisname,i+1,i+1); zLocal[i][j]->Sumw2(); } } TF1 *fitfun = new TF1("fitfun",fitfun,-6.,6.,5); double t[N]; double z0[N][M], ze[N][M]; gStyle->SetOptStat(101); gStyle->SetOptFit(100); gStyle->SetTextSize(0.06); gStyle->SetTextFont(42); TCanvas *c1 = new TCanvas("c1","c1",0,0,800,600); c1->SetFillColor(10); c1->SetBorderMode(0); c1->SetBorderSize(2); c1->Divide(4,3); TPostScript *ps = new TPostScript("fig/xLocalFit.ps",112); for(int j=0;j<M;j++) { for(int i=0;i<N;i++) { t[i] = i+1; // tray number if(i%12==0) ps->NewPage(); // 12 trays per page c1->cd(i%12+1); double par[5], err[5]; fitfun->SetParameters(0., zLocal[i][j]->GetBinContent(50), 0.1, 1., 0.); fitfun->SetLineWidth(2); zLocal[i][j]->Draw("e"); double entries = zLocal[i][j]->Integral(1,100); if(entries>10) { fitfun->SetParLimits(0, -3., 3.); fitfun->SetParLimits(2, 2.9, 3.1); fitfun->SetParLimits(3, 0.01, 0.16); zLocal[i][j]->Fit("fitfun","R"); fitfun->GetParameters(&par[0]); err[0] = fitfun->GetParError(0); } else { par[0] = 0.; err[0] = 0.; } hPar2->Fill(par[2]); hPar3->Fill(par[3]); char text[100]; sprintf(text, "Z0 = %5.3f #pm %5.3f", par[0], err[0]); TLatex *tex = new TLatex(-3, par[1]/3., text); tex->SetTextSize(0.07); tex->SetTextFont(12); tex->Draw("same"); z0[i][j] = par[0]; ze[i][j] = err[0]; c1->Update(); } } gStyle->SetOptStat(0); gStyle->SetOptFit(0); gStyle->SetEndErrorSize(0.01); TF1 *fitangle = new TF1("fitangle","[0]*sin(x*3.14159/180.)+[1]",-10.,40.); double z00[N], ze0[N]; // angle=0 modules zOffset double z0F[N], zeF[N]; // angle=0 modules zOffset after fitangle fit double x0[N], xe[N]; for(int i=0;i<N;i++) { if(i%12==0) ps->NewPage(); // 12 trays per page c1->cd(i%12+1); z00[i] = z0[i][0]; ze0[i] = ze[i][0]; double x1 = -10.; double x2 = 50.; double y1 = -2.5; double y2 = 1.5; char title[100]; sprintf(title,"Tray_%d",i+1); TH1D *h0 = new TH1D("h0",title,1, x1, x2); h0->SetMinimum(y1); h0->SetMaximum(y2); h0->GetXaxis()->SetNdivisions(208); h0->GetXaxis()->CenterTitle(); h0->GetXaxis()->SetTitle("Module Angle (deg)"); h0->GetXaxis()->SetTitleOffset(1.0); h0->GetXaxis()->SetTitleSize(0.07); h0->GetXaxis()->SetLabelOffset(0.01); h0->GetXaxis()->SetLabelSize(0.045); h0->GetXaxis()->SetLabelFont(42); h0->GetXaxis()->SetTitleFont(42); h0->GetYaxis()->SetNdivisions(210); h0->GetYaxis()->SetTitle("zLocal Offset"); h0->GetYaxis()->SetTitleOffset(1.0); h0->GetYaxis()->SetTitleSize(0.07); h0->GetYaxis()->SetLabelOffset(0.01); h0->GetYaxis()->SetLabelSize(0.045); h0->GetYaxis()->SetLabelFont(42); h0->GetYaxis()->SetTitleFont(42); h0->Draw(); TGraphErrors *gr = new TGraphErrors(M, a, z0[i], 0, ze[i]); gr->SetMarkerStyle(24); gr->SetMarkerSize(1.5); gr->SetLineWidth(2); gr->Draw("p"); fitangle->SetParameters(-0.5, 0.0); gr->Fit("fitangle","R"); x0[i] = fitangle->GetParameter(0); z0F[i] = fitangle->GetParameter(1); xe[i] = fitangle->GetParError(0); zeF[i] = fitangle->GetParError(1); c1->Update(); } ps->NewPage(); gStyle->SetOptStat(0); gStyle->SetOptFit(0); gStyle->SetEndErrorSize(0.01); TCanvas *c1 = new TCanvas("c1","c1",0,0,800,600); c1->SetFillColor(10); c1->SetBorderMode(0); c1->SetBorderSize(2); c1->SetLeftMargin(0.14); c1->SetBottomMargin(0.15); c1->SetTopMargin(0.02); c1->SetRightMargin(0.04); c1->Draw(); double x1 = 0.5; double x2 = 120.5; double y1 = -3.; double y2 = 1.; TH1D *h0 = new TH1D("h0","",1, x1, x2); h0->SetMinimum(y1); h0->SetMaximum(y2); h0->GetXaxis()->SetNdivisions(208); h0->GetXaxis()->CenterTitle(); h0->GetXaxis()->SetTitle("Tray #"); h0->GetXaxis()->SetTitleOffset(1.0); h0->GetXaxis()->SetTitleSize(0.07); h0->GetXaxis()->SetLabelOffset(0.01); h0->GetXaxis()->SetLabelSize(0.05); h0->GetXaxis()->SetLabelFont(42); h0->GetXaxis()->SetTitleFont(42); h0->GetYaxis()->SetNdivisions(210); h0->GetYaxis()->SetTitle("zLocal Offset"); h0->GetYaxis()->SetTitleOffset(1.0); h0->GetYaxis()->SetTitleSize(0.07); h0->GetYaxis()->SetLabelOffset(0.01); h0->GetYaxis()->SetLabelSize(0.045); h0->GetYaxis()->SetLabelFont(42); h0->GetYaxis()->SetTitleFont(42); h0->Draw(); TLine *l1 = new TLine(x1,y1,x2,y1); l1->SetLineWidth(3); l1->Draw("same"); TLine *l2 = new TLine(x1,y2,x2,y2); l2->SetLineWidth(3); l2->Draw("same"); TLine *l3 = new TLine(x1,y1,x1,y2); l3->SetLineWidth(3); l3->Draw("same"); TLine *l4 = new TLine(x2,y1,x2,y2); l4->SetLineWidth(3); l4->Draw("same"); TGraphErrors *gr = new TGraphErrors(N, t, z00, 0, ze0); gr->SetMarkerStyle(20); gr->SetMarkerSize(1.5); gr->SetLineWidth(2); gr->Draw("p"); TGraphErrors *gr = new TGraphErrors(N, t, z0F, 0, zeF); gr->SetMarkerStyle(24); gr->SetMarkerSize(1.5); gr->SetLineWidth(2); gr->Draw("p"); c1->Update(); ps->NewPage(); gStyle->SetOptStat(0); gStyle->SetOptFit(0); gStyle->SetEndErrorSize(0.01); TCanvas *c1 = new TCanvas("c1","c1",0,0,800,600); c1->SetFillColor(10); c1->SetBorderMode(0); c1->SetBorderSize(2); c1->SetLeftMargin(0.14); c1->SetBottomMargin(0.15); c1->SetTopMargin(0.02); c1->SetRightMargin(0.04); c1->Draw(); double x1 = 0.5; double x2 = 120.5; double y1 = -2.; double y2 = 3.; TH1D *h0 = new TH1D("h0","",1, x1, x2); h0->SetMinimum(y1); h0->SetMaximum(y2); h0->GetXaxis()->SetNdivisions(208); h0->GetXaxis()->CenterTitle(); h0->GetXaxis()->SetTitle("Tray #"); h0->GetXaxis()->SetTitleOffset(1.0); h0->GetXaxis()->SetTitleSize(0.07); h0->GetXaxis()->SetLabelOffset(0.01); h0->GetXaxis()->SetLabelSize(0.05); h0->GetXaxis()->SetLabelFont(42); h0->GetXaxis()->SetTitleFont(42); h0->GetYaxis()->SetNdivisions(210); h0->GetYaxis()->SetTitle("xLocal Offset"); h0->GetYaxis()->SetTitleOffset(1.0); h0->GetYaxis()->SetTitleSize(0.07); h0->GetYaxis()->SetLabelOffset(0.01); h0->GetYaxis()->SetLabelSize(0.045); h0->GetYaxis()->SetLabelFont(42); h0->GetYaxis()->SetTitleFont(42); h0->Draw(); TLine *l1 = new TLine(x1,y1,x2,y1); l1->SetLineWidth(3); l1->Draw("same"); TLine *l2 = new TLine(x1,y2,x2,y2); l2->SetLineWidth(3); l2->Draw("same"); TLine *l3 = new TLine(x1,y1,x1,y2); l3->SetLineWidth(3); l3->Draw("same"); TLine *l4 = new TLine(x2,y1,x2,y2); l4->SetLineWidth(3); l4->Draw("same"); TGraphErrors *gr = new TGraphErrors(N, t, x0, 0, xe); gr->SetMarkerStyle(20); gr->SetMarkerSize(1.5); gr->SetLineWidth(2); gr->Draw("p"); c1->Update(); ps->Close(); ofstream outData; outData.open("xOffset.dat"); for(int i=0;i<N;i++) { outData << setw(15) << z00[i] << setw(15) << ze0[i] << setw(15) << x0[i] << setw(15) << xe[i] << endl; } outData.close(); TFile *fout = new TFile("xFitPar.root","recreate"); hPar2->Write(); hPar3->Write(); fout->Close(); }
void plotTurnonCurve(char* var, double min, double max, int NPVmin=0, int NPVmax=50) { TString path("./uct15-plots/turnon/Taus/noPUC/isoStudies"); float PUcut = 1.0; TFile * f1; if( 1 ) { f1 = TFile::Open("/uscms_data/d2/aosorio/scratch0/UCT2015_BKP/root_files/uct_eff_trees_mutau_BC.root"); } TTree* tree1 = (TTree*) gDirectory->Get("rlxTauEfficiency/Ntuple"); int nBins = 10; if(var=="Pt") nBins = (int) ((max - min) / 2); if(var=="Eta") nBins = (int) ((max - min) / 0.5); nBins = 20; double RecoPtmin = 0.0; //////////////////////////////////////////////////////////////////////////////// // read the same selection used for the Rate/Efficiency plots // int lineWidth = 2; std::ifstream *m_in = new std::ifstream("config/efficiency_TS_WP_WI_Selection.dat"); if ( !m_in->is_open() ) { std::cout << " I could not open this file" << std::endl; exit(1); } TList * v_Selection = new TList(); char line[256]; while(1) { m_in->getline( line, 256 ); TObjString *selection = new TObjString( line ); v_Selection->Add( selection ); if ( m_in->eof() ) break; } v_Selection->RemoveLast(); TList * v_Labels = new TList(); TObjString *label; label = new TObjString( "L1 Upgrade Tau" ); v_Labels->Add( label ); label = new TObjString( "L1 Upgrade Iso Tau" ); v_Labels->Add( label ); //////////////////////////////////////////////////////////////////////////////// //This is the standard cut based on nPVS char cuts[100]; sprintf(cuts, " l1gMatch && recoPt > %d ", NPVmin, NPVmax, RecoPtmin); int min_sel = 0; int max_sel = v_Selection->GetEntries(); max_sel = 1; //Only focus on the relaxed tau plots - they go to TDR for( int k = min_sel; k < max_sel; ++k ) { TString egsel = ((TObjString*)v_Selection->At(k))->GetString(); std::cout << egsel.Data() << std::endl; ///// ----- Create all the histograms ---------- TH1D* allReco = new TH1D("allReco", "", nBins, min, max); allReco->SetLineWidth(2); allReco->Sumw2(); TH1D* l1Pt20 = allReco->Clone("l1Pt20"); if(var=="Pt") l1Pt20->GetYaxis()->SetRangeUser(0.0, 1.1); if(var=="Eta") l1Pt20->GetYaxis()->SetRangeUser(0.55, 1.05); l1Pt20->GetYaxis()->SetTitle("Efficiency"); char* xtitle = var; if(var=="Pt") xtitle = "Offline tau p_{T} [GeV]"; if(var=="Eta") xtitle = "Offline tau #eta"; l1Pt20->GetXaxis()->SetTitle(xtitle); l1Pt20->GetXaxis()->SetTitleOffset(1.3); l1Pt20->SetMinimum(0.); l1Pt20->SetMaximum(1.2); TH1D* l1Pt25 = allReco->Clone("l1Pt25"); l1Pt25->SetLineColor(6); l1Pt25->SetMarkerColor(6); TH1D* l1Pt30 = allReco->Clone("l1Pt30"); l1Pt30->SetLineColor(7); l1Pt30->SetMarkerColor(7); TString varName = TString("reco") + TString(var); TH1D* l1Pt40 = allReco->Clone("l1Pt40"); l1Pt40->SetLineColor(8); l1Pt40->SetMarkerColor(8); TString varName = TString("reco") + TString(var); TH1D* l1Pt60 = allReco->Clone("l1Pt60"); l1Pt60->SetLineColor(2); l1Pt60->SetMarkerColor(2); TString varName = TString("reco") + TString(var); ///// ----- Draw from tree ---------- tree1->Draw(varName+TString(">>allReco"),cuts,"goff"); tree1->Draw(varName+TString(">>l1Pt20"),TString(cuts)+TString(" && l1gPt>20. && ")+egsel,"goff"); tree1->Draw(varName+TString(">>l1Pt25"),TString(cuts)+TString(" && l1gPt>25. && ")+egsel,"goff"); tree1->Draw(varName+TString(">>l1Pt30"),TString(cuts)+TString(" && l1gPt>30. && ")+egsel,"goff"); tree1->Draw(varName+TString(">>l1Pt40"),TString(cuts)+TString(" && l1gPt>40. && ")+egsel,"goff"); tree1->Draw(varName+TString(">>l1Pt60"),TString(cuts)+TString(" && l1gPt>60. && ")+egsel,"goff"); //// ---- Now divide by allReco histogram to obtain efficiency ---- l1Pt20->Divide(allReco); l1Pt25->Divide(allReco); l1Pt30->Divide(allReco); l1Pt40->Divide(allReco); l1Pt60->Divide(allReco); TCanvas* canEffIso = new TCanvas("canEffIso","",500,500); l1Pt20->Draw("e"); l1Pt20->Draw("hist same"); l1Pt25->Draw("esame"); l1Pt25->Draw("hist same"); l1Pt30->Draw("esame"); l1Pt30->Draw("hist same"); l1Pt40->Draw("esame"); l1Pt40->Draw("hist same"); l1Pt60->Draw("esame"); l1Pt60->Draw("hist same"); TString legend_Label = ((TObjString*)v_Labels->At(k))->GetString(); TLegend* legend = new TLegend(0.5,0.22,0.9,0.45); legend->SetFillColor(0); legend->SetBorderSize(0); legend->SetTextFont(62); legend->SetTextSize(0.034); legend->AddEntry(l1Pt20, "L1 p_{T} > 20 GeV", "PLE"); legend->AddEntry(l1Pt25, "L1 p_{T} > 25 GeV", "PLE"); legend->AddEntry(l1Pt30, "L1 p_{T} > 30 GeV", "PLE"); legend->AddEntry(l1Pt40, "L1 p_{T} > 40 GeV", "PLE"); legend->AddEntry(l1Pt60, "L1 p_{T} > 60 GeV", "PLE"); legend->Draw(); cmsPrelim(); canEffIso->SetGridx(); canEffIso->SetGridy(); TLatex * tex = new TLatex(15.4, 1.1, legend_Label.Data() ); tex->SetTextFont(42); tex->SetLineWidth(2); tex->Draw(); canEffIso->Modified(); std::stringstream saveAs; saveAs.str(""); saveAs << path << "/eps/rlx_tau_eff_trg20_WP_" << varName << "_" << NPVmin << "_" << NPVmax << "_" << k << "_" << PUcut << "_" << lineWidth << ".eps"; canEffIso->SaveAs( saveAs.str().c_str() ); saveAs.str(""); saveAs << path << "/eps/rlx_tau_eff_trg20_WP_" << varName << "_" << NPVmin << "_" << NPVmax << "_" << k << "_" << PUcut << "_" << lineWidth << ".pdf"; canEffIso->SaveAs( saveAs.str().c_str() ); saveAs.str(""); saveAs << path << "/png/rlx_tau_eff_trg20_WP_" << varName << "_" << NPVmin << "_" << NPVmax << "_" << k << "_" << PUcut << "_" << lineWidth << ".png"; canEffIso->SaveAs( saveAs.str().c_str() ); //--------- Finally clean up the memory ------- delete allReco; delete l1Pt20; delete l1Pt25; delete l1Pt30; delete l1Pt40; delete l1Pt60; delete canEffIso; delete legend; } }
void plotPPBalanceAll(){ bool isPF = true; TString data_tag; TString mc_tag; TString jetfinder, jetfinder_tag; if(!isPF){ data_tag = "hdata_ak5calo_DijetBalance"; mc_tag = "hmc_ak5calo_DijetBalance_histonly"; jetfinder_tag = "calo"; }else{ data_tag = "hdata_ak5pf_DijetBalance"; mc_tag = "hmc_ak5pf_DijetBalance_histonly"; jetfinder_tag ="pf"; } TFile *fDATA = new TFile(Form("./%s.root",data_tag.Data())); TFile *fMC = new TFile(Form("./%s.root",mc_tag.Data())); TH1F *hDijetBal_data = (TH1F*) fDATA->Get("hDataDijetBalance"); TH1F *hDijetBal_mc = (TH1F*) fMC->Get("hQCDDijetBalance"); // normalization should be matched with what's in ANA hDijetBal_data->Scale(1./hDijetBal_data->Integral()); hDijetBal_data->Rebin(2); hDijetBal_mc->Scale(1./hDijetBal_mc->Integral()); hDijetBal_mc->Rebin(2); cout<<"Bin Width = "<<hDijetBal_data->GetBinWidth(1)<<endl; // canvas setting --- TCanvas *c1 = new TCanvas("c1","",560,620); // dum styling ---- TH1F *hDum = new TH1F("hDum","",10,0,1.0); hDum->SetLineColor(kBlue); hDum->SetFillColor(kAzure-8); hDum->SetFillStyle(3005); hDum->SetStats(0); hDum->SetXTitle("A_{J} = (p_{T}^{j1}-p_{T}^{j2})/(p_{T}^{j1}+p_{T}^{j2})"); hDum->SetYTitle("Event Fraction"); hDum->GetXaxis()->SetLabelSize(30); hDum->GetXaxis()->SetLabelFont(43); hDum->GetXaxis()->SetTitleSize(30); hDum->GetXaxis()->SetTitleFont(43); hDum->GetXaxis()->SetTitleOffset(1.4); hDum->GetXaxis()->CenterTitle(); hDum->GetXaxis()->SetNdivisions(905,true); hDum->GetYaxis()->SetLabelSize(30); hDum->GetYaxis()->SetLabelFont(43); hDum->GetYaxis()->SetTitleSize(30); hDum->GetYaxis()->SetTitleFont(43); hDum->GetYaxis()->SetTitleOffset(1.8); hDum->GetYaxis()->CenterTitle(); hDum->SetAxisRange(0,0.25,"Y"); // data, mc styling hDijetBal_mc->SetLineColor(kBlue); hDijetBal_mc->SetFillColor(kAzure-8); hDijetBal_mc->SetFillStyle(3352); // 3352 hDum->Draw("hist"); hDijetBal_mc->SetMarkerSize(2.0); hDijetBal_mc->Draw("histsame"); hDijetBal_data->SetMarkerSize(2.0); hDijetBal_data->Draw("pzsame"); // Legend TLegend *t3=new TLegend(0.53,0.57,0.91,0.82); //t3->SetHeader("ant-k_{T} (R=0.5) CaloJets"); t3->AddEntry(hDijetBal_data,"p + p #sqrt{s}=7.0 TeV","pl"); t3->AddEntry(hDijetBal_mc,"PYTHIA","lf"); t3->SetFillColor(0); t3->SetBorderSize(0); t3->SetFillStyle(0); t3->SetTextFont(63); t3->SetTextSize(20); t3->Draw(); // other labeling TLatex *cms = new TLatex(0.20,0.23,"CMS"); cms->SetTextFont(63); cms->SetTextSize(20); cms->Draw(); TLatex *lumi = new TLatex(0.35,0.23,"#intL dt = 35.1 pb^{-1}"); lumi->SetTextFont(63); lumi->SetTextSize(18); lumi->Draw(); TLatex *jetf; if(!isPF) jetf = new TLatex(0.46,0.21,"anti-k_{T} (R=0.5) CaloJets"); else jetf = new TLatex(0.46,0.21,"anti-k_{T} (R=0.5) PFJets"); jetf->SetTextFont(63); jetf->SetTextSize(20); jetf->Draw(); c1->Print(Form("./fig/%s_%s_v1.gif",data_tag.Data(),jetfinder_tag.Data())); c1->Print(Form("./fig/%s_%s_v1.pdf",data_tag.Data(),jetfinder_tag.Data())); c1->Print(Form("./fig/%s_%s_v1.eps",data_tag.Data(),jetfinder_tag.Data())); }
void fit(int fitType, bool ispp) { if(fitType==1) { histname = "BmassBpPi"; } else if(fitType==2) { histname = "BmassBpK_tkmatch"; } else if(fitType==3) { histname = "BmassB0K_tkmatch"; } TFile* outf; if(ispp) outf = new TFile(Form("plotspp/%s.root", histname.Data()), "recreate"); else outf = new TFile(Form("plotsPbPb/%s.root", histname.Data()), "recreate"); gStyle->SetOptStat(0); TFile* inf; if(ispp) inf = new TFile(infilepp.Data()); else inf = new TFile(infilePbPb.Data()); TH1D* h = (TH1D*)inf->Get(histname.Data()); h->GetXaxis()->SetRangeUser(minhisto, maxhisto); TH1D* hempty = new TH1D("", "", 50, minhisto, maxhisto); TCanvas* c = new TCanvas("c", "", 600, 600); c->cd(); TF1* f = new TF1(Form("f"),"[0]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2]) + [3]*Gaus(x,[4],[5])/(sqrt(2*3.14159)*[5]) + [9]+[10]*x "); f->SetParLimits(0, 1e-3, 1e3); f->SetParLimits(1, 4.9, 5.2); f->SetParLimits(2, 0.001, 0.1); f->SetParLimits(3, 1e-3, 1e3); f->SetParLimits(4, 4.9, 5.2); f->SetParLimits(5, 0.001, 0.1); f->SetParLimits(9, 0, 1e2); f->SetParLimits(10, -10, 10); f->SetParameter(0,1e2); f->SetParameter(1,5.11); f->SetParameter(2,0.05); f->SetParameter(3,1e2); f->SetParameter(4,4.98); f->SetParameter(5,0.05); f->SetParameter(9,1e3); f->SetParameter(10,0); if(fitType==1) { f->SetParLimits(0, 0, 1e4); f->SetParLimits(1, 5.2, 5.6); f->SetParLimits(2, 0.0001, 0.5); f->SetParameter(0,1e2); f->SetParameter(1,5.35); f->SetParameter(2,0.05); f->SetParLimits(3, 0, 1e4); f->SetParLimits(4, 5.2, 5.6); f->SetParLimits(5, 0.0001, 0.5); f->SetParameter(3,1e2); f->SetParameter(4,5.35); f->SetParameter(5,0.05); } //h->Fit(Form("f"),"q","",minhisto,maxhisto); //h->Fit(Form("f"),"q","",minhisto,maxhisto); //h->Fit(Form("f"),"L q","",minhisto,maxhisto); //h->Fit(Form("f"),"L m","",minhisto,maxhisto); h->SetMarkerSize(0.8); h->SetMarkerStyle(20); hempty->SetMaximum(h->GetMaximum()*1.4); hempty->SetXTitle("m_{#mu#muK} (GeV/c^{2})"); hempty->SetYTitle("Entries / (5 MeV/c^{2})"); hempty->GetXaxis()->CenterTitle(); hempty->GetYaxis()->CenterTitle(); hempty->SetAxisRange(0,h->GetMaximum()*1.4*1.2,"Y"); hempty->GetXaxis()->SetTitleOffset(1.3); hempty->GetYaxis()->SetTitleOffset(1.3); hempty->GetXaxis()->SetLabelOffset(0.007); hempty->GetYaxis()->SetLabelOffset(0.007); hempty->GetXaxis()->SetTitleSize(0.045); hempty->GetYaxis()->SetTitleSize(0.045); hempty->GetXaxis()->SetTitleFont(42); hempty->GetYaxis()->SetTitleFont(42); hempty->GetXaxis()->SetLabelFont(42); hempty->GetYaxis()->SetLabelFont(42); hempty->GetXaxis()->SetLabelSize(0.04); hempty->GetYaxis()->SetLabelSize(0.04); hempty->SetMarkerSize(0.01); hempty->SetMarkerStyle(20); hempty->Draw(); h->Draw("same e"); //f->Draw("same"); TLegend* leg = new TLegend(0.45,0.79,0.65,0.89,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextSize(0.04); leg->SetTextFont(42); leg->SetFillStyle(0); if(fitType==1) leg->AddEntry(h,"B^{+} to Jpsi Pi","p"); if(fitType==2) leg->AddEntry(h,"B^{+} to Jpsi and various K","p"); if(fitType==3) leg->AddEntry(h,"B^{0} to Jpsi and various K","p"); TLatex * tlatex; if(ispp) tlatex=new TLatex(0.48,0.89,"pp MC"); else tlatex=new TLatex(0.48,0.89,"PbPb MC"); tlatex->SetNDC(); tlatex->SetTextColor(1); tlatex->SetTextFont(42); tlatex->SetTextSize(0.04); tlatex->Draw(); //leg->AddEntry(f,"Fit","l"); leg->Draw("same"); outf->cd(); h->Write(); f->Write(); if(ispp) c->SaveAs(Form("plotspp/%s.png", histname.Data())); else c->SaveAs(Form("plotsPbPb/%s.png", histname.Data())); }
TF1* fit(TH1D* h, TH1D* hMCSignal, TH1D* hMCSwapped, Float_t ptmin, Float_t ptmax, Int_t j) { TCanvas* c = new TCanvas(Form("c_%.0f_%.0f_%d",ptmin,ptmax,j),"",600,600); TF1* f = new TF1(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"[0]*([7]*([9]*Gaus(x,[1],[2]*(1+[11]))/(sqrt(2*3.14159)*[2]*(1+[11]))+(1-[9])*Gaus(x,[1],[10]*(1+[11]))/(sqrt(2*3.14159)*[10]*(1+[11])))+(1-[7])*Gaus(x,[1],[8]*(1+[11]))/(sqrt(2*3.14159)*[8]*(1+[11])))+[3]+[4]*x+[5]*x*x+[6]*x*x*x", 1.7, 2.0); f->SetParLimits(4,-1000,1000); f->SetParLimits(10,0.001,0.05); f->SetParLimits(2,0.01,0.5); f->SetParLimits(8,0.02,0.2); f->SetParLimits(7,0,1); f->SetParLimits(9,0,1); f->SetParameter(0,setparam0); f->SetParameter(1,setparam1); f->SetParameter(2,setparam2); f->SetParameter(10,setparam10); f->SetParameter(9,setparam9); f->FixParameter(8,setparam8); f->FixParameter(7,1); f->FixParameter(1,fixparam1); f->FixParameter(3,0); f->FixParameter(4,0); f->FixParameter(5,0); f->FixParameter(6,0); f->FixParameter(11,0); h->GetEntries(); hMCSignal->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"q","",minhisto,maxhisto); hMCSignal->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"q","",minhisto,maxhisto); f->ReleaseParameter(1); hMCSignal->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"L q","",minhisto,maxhisto); hMCSignal->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"L q","",minhisto,maxhisto); hMCSignal->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"L m","",minhisto,maxhisto); f->FixParameter(1,f->GetParameter(1)); f->FixParameter(2,f->GetParameter(2)); f->FixParameter(10,f->GetParameter(10)); f->FixParameter(9,f->GetParameter(9)); f->FixParameter(7,0); f->ReleaseParameter(8); f->SetParameter(8,setparam8); hMCSwapped->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"L q","",minhisto,maxhisto); hMCSwapped->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"L q","",minhisto,maxhisto); hMCSwapped->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"L q","",minhisto,maxhisto); hMCSwapped->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"L m","",minhisto,maxhisto); f->FixParameter(7,hMCSignal->Integral(0,1000)/(hMCSwapped->Integral(0,1000)+hMCSignal->Integral(0,1000))); f->FixParameter(8,f->GetParameter(8)); f->ReleaseParameter(3); f->ReleaseParameter(4); f->ReleaseParameter(5); f->ReleaseParameter(6); f->SetLineColor(kRed); h->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"q","",minhisto,maxhisto); h->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"q","",minhisto,maxhisto); f->ReleaseParameter(1); f->SetParLimits(1,1.86,1.87); /* f->ReleaseParameter(11); f->SetParLimits(11,-1.,1.); */ h->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"L q","",minhisto,maxhisto); h->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"L q","",minhisto,maxhisto); h->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"L q","",minhisto,maxhisto); h->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"L m","",minhisto,maxhisto); TF1* background = new TF1(Form("background_%.0f_%.0f_%d",ptmin,ptmax,j),"[0]+[1]*x+[2]*x*x+[3]*x*x*x"); background->SetParameter(0,f->GetParameter(3)); background->SetParameter(1,f->GetParameter(4)); background->SetParameter(2,f->GetParameter(5)); background->SetParameter(3,f->GetParameter(6)); background->SetLineColor(4); background->SetRange(minhisto,maxhisto); background->SetLineStyle(2); TF1* mass = new TF1(Form("mass_%.0f_%.0f_%d",ptmin,ptmax,j),"[0]*([3]*([4]*Gaus(x,[1],[2]*(1+[6]))/(sqrt(2*3.14159)*[2]*(1+[6]))+(1-[4])*Gaus(x,[1],[5]*(1+[6]))/(sqrt(2*3.14159)*[5]*(1+[6]))))"); mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2),f->GetParameter(7),f->GetParameter(9),f->GetParameter(10),f->GetParameter(11)); mass->SetParError(0,f->GetParError(0)); mass->SetParError(1,f->GetParError(1)); mass->SetParError(2,f->GetParError(2)); mass->SetParError(3,f->GetParError(7)); mass->SetParError(4,f->GetParError(9)); mass->SetParError(5,f->GetParError(10)); mass->SetFillColor(kOrange-3); mass->SetFillStyle(3002); mass->SetLineColor(kOrange-3); mass->SetLineWidth(3); mass->SetLineStyle(2); TF1* massSwap = new TF1(Form("massSwap_%.0f_%.0f_%d",ptmin,ptmax,j),"[0]*(1-[2])*Gaus(x,[1],[3]*(1+[4]))/(sqrt(2*3.14159)*[3]*(1+[4]))"); massSwap->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(7),f->GetParameter(8),f->GetParameter(11)); massSwap->SetParError(0,f->GetParError(0)); massSwap->SetParError(1,f->GetParError(1)); massSwap->SetParError(2,f->GetParError(7)); massSwap->SetParError(3,f->GetParError(8)); massSwap->SetFillColor(kGreen+4); massSwap->SetFillStyle(3005); massSwap->SetLineColor(kGreen+4); massSwap->SetLineWidth(3); massSwap->SetLineStyle(1); h->SetXTitle("m_{#piK} (GeV/c^{2})"); h->SetYTitle("Entries / (5 MeV/c^{2})"); h->GetXaxis()->CenterTitle(); h->GetYaxis()->CenterTitle(); h->SetAxisRange(0,h->GetMaximum()*1.4*1.2,"Y"); h->GetXaxis()->SetTitleOffset(1.3); h->GetYaxis()->SetTitleOffset(1.8); h->GetXaxis()->SetLabelOffset(0.007); h->GetYaxis()->SetLabelOffset(0.007); h->GetXaxis()->SetTitleSize(0.045); h->GetYaxis()->SetTitleSize(0.045); h->GetXaxis()->SetTitleFont(42); h->GetYaxis()->SetTitleFont(42); h->GetXaxis()->SetLabelFont(42); h->GetYaxis()->SetLabelFont(42); h->GetXaxis()->SetLabelSize(0.04); h->GetYaxis()->SetLabelSize(0.04); h->SetMarkerSize(0.8); h->SetMarkerStyle(20); h->SetStats(0); h->Draw("e"); background->Draw("same"); mass->SetRange(minhisto,maxhisto); mass->Draw("same"); massSwap->SetRange(minhisto,maxhisto); massSwap->Draw("same"); f->Draw("same"); Double_t yield = mass->Integral(minhisto,maxhisto)/binwidthmass; Double_t yieldErr = mass->Integral(minhisto,maxhisto)/binwidthmass*mass->GetParError(0)/mass->GetParameter(0); std::cout<<"YIELD="<<yield<<std::endl; TLegend* leg = new TLegend(0.65,0.58,0.82,0.88,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextSize(0.04); leg->SetTextFont(42); leg->SetFillStyle(0); leg->AddEntry(h,"Data","pl"); leg->AddEntry(f,"Fit","l"); leg->AddEntry(mass,"D^{0}+#bar{D^{#lower[0.2]{0}}} Signal","f"); leg->AddEntry(massSwap,"K-#pi swapped","f"); leg->AddEntry(background,"Combinatorial","l"); leg->Draw("same"); DrawCmsTlatex("PbPb"); TLatex* tex; tex = new TLatex(0.22,0.83,"|y| < 1.0"); tex->SetNDC(); tex->SetTextFont(42); tex->SetTextSize(0.04); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.22,0.78,Form("%.1f < p_{T} < %.1f GeV/c",ptmin,ptmax)); tex->SetNDC(); tex->SetTextFont(42); tex->SetTextSize(0.04); tex->SetLineWidth(2); tex->Draw(); TString texper="%"; tex = new TLatex(0.22,0.72,Form("Centrality %.0f-%.0f%s",centMin,centMax,texper.Data())); tex->SetNDC(); tex->SetTextColor(1); tex->SetTextFont(42); tex->SetTextSize(0.045); tex->SetLineWidth(2); tex->Draw(); c->SaveAs(Form("plots/Mass_cent_%.0f_%.0f_pt_%.0f_%.0f_%s.pdf",centMin,centMax,ptmin,ptmax,tfend[j].Data())); return mass; }
void plot_eff_vs_general_var_grand_pas(Bool_t rebin=false, Bool_t range=false){ //------------------------------------------------------------------------------------- // variable: 1 - eta, 2 - pt, 3 - jet //------------------------------------------------------------------------------------- int variable = 2; rebin = false; range = true; bool MBonly = false; bool effonly = true; bool fakonly = false; bool lowerhalf = false; int logX = 1; double minpt = 5.0; double maxpt = 200; double minjet = 0; double maxjet = 0; double minjet2 = 130; double maxjet2 = 170; double maxeta = 1.0; Char_t VARIABLE[100]; if(variable==1){ TH1F *dum = new TH1F("dum","",100,-2.5,2.5); dum->GetXaxis()->SetTitle("#eta"); sprintf(VARIABLE,"ETA_%1.1f",maxeta); if(lowerhalf) dum->SetMaximum(0.5); }else if(variable==2){ TH1F *dum = new TH1F("dum","",100,0.5,320); //if(range) dum->SetAxisRange(0,160); dum->GetXaxis()->SetTitle("p_{T} [GeV/c]"); dum->GetXaxis()->CenterTitle(); dum->GetYaxis()->SetDecimals(); sprintf(VARIABLE,"PT_minpt_%1.1f_%1.1f_%1.1f",minpt,minjet,maxjet); }else if(variable==3){ TH1F *dum = new TH1F("dum","",100,0,1200); dum->GetXaxis()->SetTitle("Corrected leading jet E_{T} (GeV)"); sprintf(VARIABLE,"JETET_minpt_%1.1f",minpt); } dum->SetMinimum(-0.05); dum->SetMaximum(1.0); dum->SetStats(0); //dum->GetYaxis()->SetTitle("Fractional efficiency"); dum->GetYaxis()->SetTitle("A #times #epsilon_{TR}"); dum->GetXaxis()->SetTitleSize(0.05); dum->GetYaxis()->SetTitleSize(0.05); dum->GetYaxis()->SetTitleOffset(1.5); dum->GetYaxis()->SetNdivisions(911); //gROOT->LoadMacro("trkeffanalyzer_hist_jet.C"); gROOT->LoadMacro("trkeffanalyzer_hist_general_variable.C"); Char_t fileName1[100]; Char_t fileName2[100]; Char_t fileName3[100]; Char_t fileName4[100]; Char_t fileName5[100]; Char_t fileName6[100]; Char_t fileString1[200]; Char_t fileString2[200]; Char_t fileString3[200]; Char_t fileString4[200]; Char_t fileString5[200]; Char_t fileString6[200]; //sprintf(fileName1,"TrkHistMC_QCD_10M.root"); //sprintf(fileName1,"TrkHistMC_july09v2_qcdMBD6TdJuly09V3_div2.root"); //sprintf(fileString1,"/Users/andreyoon/Research/ana/spectra/pp_spectra/7TeV/root_files/%s",fileName1); sprintf(fileName1,"TrkHistGEN_oct06_qcdMBD6TV1.root"); sprintf(fileString1,"/Users/andreyoon/Research/pp7TeV/root_files_postApp/mc/%s",fileName1); cout<<"input file 1 is "<<fileString1<<endl; //sprintf(fileName2,"TrkHistMC_QCD_Pt15.root"); //sprintf(fileName2,"TrkHistMC_july09v2_qcdPt15dJuly09_div2.root"); //sprintf(fileString2,"/Users/andreyoon/Research/ana/spectra/pp_spectra/7TeV/root_files/%s",fileName2); sprintf(fileName2,"TrkHistGEN_oct01_qcdPt15V1.root"); sprintf(fileString2,"/Users/andreyoon/Research/pp7TeV/root_files_postApp/mc/%s",fileName2); cout<<"input file 2 is "<<fileString2<<endl; //sprintf(fileName3,"TrkHistMC_QCD_Pt30v2.root"); //sprintf(fileName3,"TrkHistMC_july09v2_qcdPt30dJuly09V2_div2.root"); //sprintf(fileString3,"/Users/andreyoon/Research/ana/spectra/pp_spectra/7TeV/root_files/%s",fileName3); sprintf(fileName3,"TrkHistGEN_oct01_qcdPt30V2.root"); sprintf(fileString3,"/Users/andreyoon/Research/pp7TeV/root_files_postApp/mc/%s",fileName3); cout<<"input file 3 is "<<fileString3<<endl; //sprintf(fileName4,"TrkHistMC_QCD_Pt80v2.root"); //sprintf(fileName4,"TrkHistMC_july09v2_qcdPt80dJuly09V2_div2.root"); //sprintf(fileString4,"/Users/andreyoon/Research/ana/spectra/pp_spectra/7TeV/root_files/%s",fileName4); sprintf(fileName4,"TrkHistGEN_oct01_qcdPt80V2.root"); sprintf(fileString4,"/Users/andreyoon/Research/pp7TeV/root_files_postApp/mc/%s",fileName4); cout<<"input file 4 is "<<fileString4<<endl; //sprintf(fileName5,"TrkHistMC_QCD_Pt170_V2_1st.root"); //sprintf(fileName5,"TrkHistMC_july09v2_qcdPt170dJuly09_div2.root"); //sprintf(fileString5,"/Users/andreyoon/Research/ana/spectra/pp_spectra/7TeV/root_files/%s",fileName5); sprintf(fileName5,"TrkHistGEN_oct01_qcdPt170V1.root"); sprintf(fileString5,"/Users/andreyoon/Research/pp7TeV/root_files_postApp/mc/%s",fileName5); cout<<"input file 5 is "<<fileString5<<endl; //sprintf(fileName6,"TrkHistMC_QCD_Pt470_V2_1st.root"); //sprintf(fileName6,"TrkHistMC_july09v2_dec14_qcdPt300dJuly09V2.root"); //sprintf(fileString6,"/Users/andreyoon/Research/ana/spectra/pp_spectra/7TeV/root_files/%s",fileName6); sprintf(fileName6,"TrkHistGEN_oct01_qcdPt300V1.root"); sprintf(fileString6,"/Users/andreyoon/Research/pp7TeV/root_files_postApp/mc/%s",fileName6); cout<<"input file 6 is "<<fileString6<<endl; char jetrange1[100], jetrange2[100], jetrange3[100], jetrange4[100], jetrange5[100], jetrange6[100]; char jetrange7[100], jetrange8[100], jetrange9[100], jetrange10[100], jetrange11[100], jetrange12[100]; // 0-20 MB minjet = 0, maxjet = 20; sprintf(jetrange1," %1.0f<E_{T}<%1.0f",minjet,maxjet); trkeffanalyzer_hist_data d1 = trkeffanalyzer_hist_graph(fileString1,rebin,range,variable,0.0,maxeta,minjet,maxjet,minpt,maxpt); TGraphAsymmErrors *Eff1 = d1.gEfficiency; TGraphAsymmErrors *FR1 = d1.gFakerate; TGraphAsymmErrors *Eff1Skm = removeLastPoint(Eff1,1); TGraphAsymmErrors *FR1Skm = removeLastPoint(FR1,1); // 20-40 MB, Pt15 minjet = 20, maxjet =40; sprintf(jetrange2," %1.0f<E_{T}<%1.0f",minjet,maxjet); trkeffanalyzer_hist_data d2 = trkeffanalyzer_hist_graph(fileString1,rebin,range,variable,0.0,maxeta,minjet,maxjet,minpt,maxpt); TGraphAsymmErrors *Eff2 = d2.gEfficiency; TGraphAsymmErrors *FR2 = d2.gFakerate; TGraphAsymmErrors *Eff2Skm = removeLastPoint(Eff2,1); TGraphAsymmErrors *FR2Skm = removeLastPoint(FR2,1); //TGraphAsymmErrors *Eff2Skm = removeLastPoint(Eff2,0); //TGraphAsymmErrors *FR2Skm = removeLastPoint(FR2,0); trkeffanalyzer_hist_data d3 = trkeffanalyzer_hist_graph(fileString2,rebin,range,variable,0.0,maxeta,minjet,maxjet,minpt,maxpt); TGraphAsymmErrors *Eff3 = d3.gEfficiency; TGraphAsymmErrors *FR3 = d3.gFakerate; TGraphAsymmErrors *Eff3Skm = removeLastPoint(Eff3,1); TGraphAsymmErrors *FR13km = removeLastPoint(FR3,1); //TGraphAsymmErrors *Eff3Skm = removeLastPoint(Eff3,0); //TGraphAsymmErrors *FR13km = removeLastPoint(FR3,0); // 40-60 Pt15, Pt30 minjet = 40, maxjet =60; sprintf(jetrange3," %1.0f<E_{T}<%1.0f ",minjet,maxjet); trkeffanalyzer_hist_data d4 = trkeffanalyzer_hist_graph(fileString2,rebin,range,variable,0.0,maxeta,minjet,maxjet,minpt,maxpt); TGraphAsymmErrors *Eff4 = d4.gEfficiency; TGraphAsymmErrors *FR4 = d4.gFakerate; TGraphAsymmErrors *Eff4Skm = removeLastPoint(Eff4,2); TGraphAsymmErrors *FR4Skm = removeLastPoint(FR4,2); //TGraphAsymmErrors *Eff4Skm = removeLastPoint(Eff4,0); //TGraphAsymmErrors *FR4Skm = removeLastPoint(FR4,0); trkeffanalyzer_hist_data d5 = trkeffanalyzer_hist_graph(fileString3,rebin,range,variable,0.0,maxeta,minjet,maxjet,minpt,maxpt); TGraphAsymmErrors *Eff5 = d5.gEfficiency; TGraphAsymmErrors *FR5 = d5.gFakerate; TGraphAsymmErrors *Eff5Skm = removeLastPoint(Eff5,2); TGraphAsymmErrors *FR5Skm = removeLastPoint(FR5,2); //TGraphAsymmErrors *Eff5Skm = removeLastPoint(Eff5,0); //TGraphAsymmErrors *FR5Skm = removeLastPoint(FR5,0); // 60-80 Pt30 minjet = 60, maxjet =80; sprintf(jetrange4," %1.0f<E_{T}<%1.0f",minjet,maxjet); trkeffanalyzer_hist_data d6 = trkeffanalyzer_hist_graph(fileString3,rebin,range,variable,0.0,maxeta,minjet,maxjet,minpt,maxpt); TGraphAsymmErrors *Eff6 = d6.gEfficiency; TGraphAsymmErrors *FR6 = d6.gFakerate; TGraphAsymmErrors *Eff6Skm = removeLastPoint(Eff6,3); TGraphAsymmErrors *FR6Skm = removeLastPoint(FR6,3); // 80-100 Pt80 -> Pt30 minjet = 80, maxjet =100; sprintf(jetrange5," %1.0f<E_{T}<%1.0f",minjet,maxjet); //trkeffanalyzer_hist_data d7 = trkeffanalyzer_hist_graph(fileString4,rebin,range,variable,0.0,maxeta,minjet,maxjet,minpt,maxpt); trkeffanalyzer_hist_data d7 = trkeffanalyzer_hist_graph(fileString3,rebin,range,variable,0.0,maxeta,minjet,maxjet,minpt,maxpt); TGraphAsymmErrors *Eff7 = d7.gEfficiency; TGraphAsymmErrors *FR7 = d7.gFakerate; TGraphAsymmErrors *Eff7Skm = removeLastPoint(Eff7,2); TGraphAsymmErrors *FR7Skm = removeLastPoint(FR7,2); //TGraphAsymmErrors *Eff7Skm = removeLastPoint(Eff7,0); //TGraphAsymmErrors *FR7Skm = removeLastPoint(FR7,0); // 100-120 Pt80 minjet = 100, maxjet =120; sprintf(jetrange6," %1.0f<E_{T}<%1.0f",minjet,maxjet); trkeffanalyzer_hist_data d8 = trkeffanalyzer_hist_graph(fileString4,rebin,range,variable,0.0,maxeta,minjet,maxjet,minpt,maxpt); TGraphAsymmErrors *Eff8 = d8.gEfficiency; TGraphAsymmErrors *FR8 = d8.gFakerate; TGraphAsymmErrors *Eff8Skm = removeLastPoint(Eff8,3); TGraphAsymmErrors *FR8Skm = removeLastPoint(FR8,3); //TGraphAsymmErrors *Eff8Skm = removeLastPoint(Eff8,0); //TGraphAsymmErrors *FR8Skm = removeLastPoint(FR8,0); // 120-140 // 140-160 // 160-180 // 180-200 Pt80, Pt170 minjet = 180, maxjet =200; sprintf(jetrange7," %1.0f<E_{T}<%1.0f",minjet,maxjet); trkeffanalyzer_hist_data d9 = trkeffanalyzer_hist_graph(fileString4,rebin,range,variable,0.0,maxeta,minjet,maxjet,minpt,maxpt); TGraphAsymmErrors *Eff9 = d9.gEfficiency; TGraphAsymmErrors *FR9 = d9.gFakerate; TGraphAsymmErrors *Eff9Skm = removeLastPoint(Eff9,1); TGraphAsymmErrors *FR9Skm = removeLastPoint(FR9,1); //TGraphAsymmErrors *Eff9Skm = removeLastPoint(Eff9,0); //TGraphAsymmErrors *FR9Skm = removeLastPoint(FR9,0); trkeffanalyzer_hist_data d10 = trkeffanalyzer_hist_graph(fileString5,rebin,range,variable,0.0,maxeta,minjet,maxjet,minpt,maxpt); TGraphAsymmErrors *Eff10 = d10.gEfficiency; TGraphAsymmErrors *FR10 = d10.gFakerate; TGraphAsymmErrors *Eff10Skm = removeLastPoint(Eff10,2); TGraphAsymmErrors *FR10Skm = removeLastPoint(FR10,2); //TGraphAsymmErrors *Eff10Skm = removeLastPoint(Eff10,0); //TGraphAsymmErrors *FR10Skm = removeLastPoint(FR10,0); //250 -300 minjet = 250, maxjet =300; sprintf(jetrange8," %1.0f<E_{T}<%1.0f",minjet,maxjet); trkeffanalyzer_hist_data d11 = trkeffanalyzer_hist_graph(fileString4,rebin,range,variable,0.0,maxeta,minjet,maxjet,minpt,maxpt); TGraphAsymmErrors *Eff11 = d11.gEfficiency; TGraphAsymmErrors *FR11 = d11.gFakerate; TGraphAsymmErrors *Eff11Skm = removeLastPoint(Eff11,1); TGraphAsymmErrors *FR11Skm = removeLastPoint(FR11,1); //TGraphAsymmErrors *Eff11Skm = removeLastPoint(Eff11,0); //TGraphAsymmErrors *FR11Skm = removeLastPoint(FR11,0); //500 - 2400 minjet = 500, maxjet =2400; sprintf(jetrange9," %1.0f<E_{T}<%1.0f",minjet,maxjet); trkeffanalyzer_hist_data d12 = trkeffanalyzer_hist_graph(fileString6,rebin,range,variable,0.0,maxeta,minjet,maxjet,minpt,maxpt); TGraphAsymmErrors *Eff12 = d12.gEfficiency; TGraphAsymmErrors *FR12 = d12.gFakerate; TGraphAsymmErrors *Eff12Skm = removeLastPoint(Eff12,0); TGraphAsymmErrors *FR12Skm = removeLastPoint(FR12,0); Char_t xTitle[100],yTitle[100]; sprintf(xTitle,"p_{T} [GeV/c]"); sprintf(yTitle,"Ratio"); TCanvas *call = new TCanvas("call","call",500,550); call->SetGridx(),call->SetGridy(); //if(logX) call->SetLogx(); call->cd(); dum->Draw(); float binsize = 1.3; float binsize2 = binsize*0.86; int color=0; color = 15; int dopt=4; th1Style1(Eff1Skm,color,20,binsize,color,1,1,dopt); th1Style1(FR1Skm,color,21,binsize,color,1,1,dopt); color = 16; th1Style1(Eff2Skm,color,20,binsize,color,1,1,dopt); th1Style1(FR2Skm,color,21,binsize,color,1,1,dopt); //th1Style1(Eff3Skm,color,24,binsize,color,1,1,dopt); //th1Style1(FR3Skm,color,25,binsize,color,1,1,dopt); color = 17; th1Style1(Eff4Skm,color,20,binsize,color,1,1,dopt); th1Style1(FR4Skm,color,21,binsize,color,1,1,dopt); //th1Style1(Eff5,color,24,binsize,color,1,1,1); //th1Style1(FR5,color,25,binsize,color,1,1,1); color = 18; th1Style1(Eff6Skm,color,20,binsize,color,1,1,dopt); th1Style1(FR6Skm,color,21,binsize,color,1,1,dopt); color = 19; th1Style1(Eff7Skm,color,20,binsize,color,1,1,dopt); th1Style1(FR7Skm,color,21,binsize,color,1,1,dopt); color = 20; th1Style1(Eff8Skm,color,20,binsize,color,1,1,dopt); th1Style1(FR8Skm,color,21,binsize,color,1,1,dopt); color = 21; //th1Style1(Eff9,color,20,binsize,color,1,1,1); //th1Style1(FR9,color,21,binsize,color,1,1,1); th1Style1(Eff10Skm,color,20,binsize,color,1,1,dopt); th1Style1(FR10Skm,color,21,binsize,color,1,1,dopt); color = 22; //th1Style1(Eff11Skm,color,20,binsize,color,1,1,dopt); //th1Style1(FR11Skm,color,21,binsize,color,1,1,dopt); th1Style1(Eff12Skm,color,20,binsize,color,1,1,dopt); th1Style1(FR12Skm,color,21,binsize,color,1,1,dopt); /* th1Style1(FR3,15,4,binsize,15,1,1,1); TGraphAsymmErrors* FR3_dum = FR3->Clone("FR3_dum"); th1Style1(FR3_dum,10,20,binsize2,15,1,1,1); if(!MBonly){ th1Style1(Eff4,16,20,binsize,16,1,1,1); th1Style1(FR4,16,4,binsize,16,1,1,1); TGraphAsymmErrors* FR4_dum = FR4->Clone("FR4_dum"); th1Style1(FR4_dum,10,20,binsize2,16,1,1,1); th1Style1(Eff5,17,20,binsize,17,1,1,1); th1Style1(FR5,17,4,binsize,17,1,1,1); TGraphAsymmErrors* FR5_dum = FR5->Clone("FR5_dum"); th1Style1(FR5_dum,10,20,binsize2,17,1,1,1); th1Style1(Eff6,15,24,binsize,15,1,1,1); th1Style1(FR6,18,4,binsize,18,1,1,1); TGraphAsymmErrors* FR6_dum = FR6->Clone("FR6_dum"); th1Style1(FR6_dum,10,20,binsize2,18,1,1,1); th1Style1(Eff7,16,24,binsize,16,1,1,1); th1Style1(FR7,19,4,binsize,19,1,1,1); TGraphAsymmErrors* FR7_dum = FR7->Clone("FR7_dum"); th1Style1(FR7_dum,10,20,binsize2,19,1,1,1); th1Style1(Eff8,17,24,binsize,17,1,1,1); th1Style1(FR8,20,4,binsize,20,1,1,1); TGraphAsymmErrors* FR8_dum = FR7->Clone("FR8_dum"); th1Style1(FR8_dum,10,20,binsize2,19,1,1,1); } */ if(!MBonly){ //TLegend *leg = new TLegend(0.54,0.4,0.89,0.62); //TLegend *leg = new TLegend(0.54,0.36,0.89,0.62); //TLegend *leg = new TLegend(0.19,0.37,0.93,0.63); //TLegend *leg = new TLegend(0.19,0.4,0.65,0.63); //TLegend *leg = new TLegend(0.23,0.3,0.69,0.52); TLegend *leg = new TLegend(0.23,0.25,0.69,0.47); leg->SetBorderSize(1); leg->SetFillColor(kWhite); //leg->SetFillStyle(0); leg->SetTextSize(0.031); leg->SetMargin(0.55); //leg->SetMargin(0.5); /* char jetrange1[100]; sprintf(jetrange1," %1.0f<E_{T}<%1.0f",minjet,maxjet); char jetrange2[100]; sprintf(jetrange2," %1.0f<E_{T}<%1.0f",minjet2,maxjet2); char header[100]; sprintf(header," p_{T}^{hat}>15 p_{T}^{hat}>30 p_{T}^{hat}>80"); leg->SetHeader(header); */ leg->SetNColumns(2); leg->SetColumnSeparation(0.000); leg->AddEntry(Eff1Skm,jetrange1,"lp"); leg->AddEntry(dum,"MB ",""); leg->AddEntry(Eff2Skm,jetrange2,"lp"); leg->AddEntry(dum,"MB ",""); leg->AddEntry(Eff4Skm,jetrange3,"lp"); leg->AddEntry(dum,"Pt15 ",""); leg->AddEntry(Eff6Skm,jetrange4,"lp"); leg->AddEntry(dum,"Pt30 ",""); leg->AddEntry(Eff7Skm,jetrange5,"lp"); leg->AddEntry(dum,"Pt30 ",""); leg->AddEntry(Eff8Skm,jetrange6,"lp"); leg->AddEntry(dum,"Pt80 ",""); leg->AddEntry(Eff10Skm,jetrange7,"lp"); leg->AddEntry(dum,"Pt170 ",""); leg->AddEntry(Eff12Skm,jetrange9,"lp"); leg->AddEntry(dum,"Pt300 ",""); }else{ TLegend *leg = new TLegend(0.54,0.4,0.89,0.62); leg->SetBorderSize(1); leg->SetFillColor(kWhite); leg->SetTextSize(0.031); leg->SetMargin(0.35); //leg->SetHeader(" 0 < Jet E_{T}< 20 "); leg->AddEntry(Eff3,"PYTHIA 7 TeV","lp"); } leg->Draw(); TLatex *tex = new TLatex(0.19,0.20,"Fake rate"); tex->SetTextSize(0.04); tex->SetLineWidth(2); tex->SetNDC(); //tex->Draw(); Char_t outName1[100]; //sprintf(outName1,"Eff_FR_GRAND_%s",VARIABLE); sprintf(outName1,"Eff_FR_GRAND_wider_v2"); Char_t outName2[100]; //sprintf(outName2,"Eff_FR_GRAND_logx_%s",VARIABLE); sprintf(outName2,"Eff_FR_GRAND_logx_wider_v2"); tex->Draw(); dum->SetMaximum(0.91); //dum->SetMinimum(0.65); dum->SetMinimum(0.50); printCanvases(call,outName1,0); dum->SetMinimum(-0.05); dum->SetMaximum(1.0); printCanvases(call,outName2,1); }
void xjg1step(int phoetmin, int phoetmax, int jetptmin) { TFile * _file0 = TFile::Open(Form("all_%d_%d_%d.root",phoetmin,phoetmax,jetptmin)); TFile * _fran = TFile::Open("/home/ursu/PbPb_Data_gammaJetHistogramArithmetic.root"); const static int nCentBins = 4; float yaxismax = 2; TH1D * xjgsignal_pbpbdata_recoreco[nCentBins]; TH1D * xjgmixsignal_pbpbdata_recoreco[nCentBins]; TH1D * phoetsignal_pbpbdata_recoreco[nCentBins]; TH1D * xjgsideband_pbpbdata_recoreco[nCentBins]; TH1D * xjgmixsideband_pbpbdata_recoreco[nCentBins]; TH1D * phoetsideband_pbpbdata_recoreco[nCentBins]; TH1D * h1D_xjg_ptBin1_hiBin_phoSIG_jetSIG_final_norm[nCentBins]; TH2D * dummy[nCentBins]; TLegend * leg[nCentBins]; int centmins[] = {0,20,60,100}; int centmaxs[] = {20,60,100,200}; string cents[] = {"0-10%","10-30%","30-50%","50-100%"}; TCanvas * c1 = new TCanvas("call","",1600,500); makeMultiPanelCanvas(c1,5,1,0.02,0.0,-6,0.2,0.04); for (int icent = 0; icent < nCentBins; icent++) { c1->cd(2+icent); xjgsignal_pbpbdata_recoreco[icent] = (TH1D*) _file0->Get(Form("xjgsignal_pbpbdata_recoreco_%d_%d",centmins[icent],centmaxs[icent])); xjgmixsignal_pbpbdata_recoreco[icent] = (TH1D*) _file0->Get(Form("xjgmixsignal_pbpbdata_recoreco_%d_%d",centmins[icent],centmaxs[icent])); phoetsignal_pbpbdata_recoreco[icent] = (TH1D*) _file0->Get(Form("phoetsignal_pbpbdata_recoreco_%d_%d",centmins[icent],centmaxs[icent])); xjgsideband_pbpbdata_recoreco[icent] = (TH1D*) _file0->Get(Form("xjgsideband_pbpbdata_recoreco_%d_%d",centmins[icent],centmaxs[icent])); xjgmixsideband_pbpbdata_recoreco[icent] = (TH1D*) _file0->Get(Form("xjgmixsideband_pbpbdata_recoreco_%d_%d",centmins[icent],centmaxs[icent])); phoetsideband_pbpbdata_recoreco[icent] = (TH1D*) _file0->Get(Form("phoetsideband_pbpbdata_recoreco_%d_%d",centmins[icent],centmaxs[icent])); h1D_xjg_ptBin1_hiBin_phoSIG_jetSIG_final_norm[icent] = (TH1D*) _fran->Get(Form("HI/h1D_xjg_ptBin1_hiBin%d_phoRAW_jetRAW_final_norm",icent+3)); xjgsignal_pbpbdata_recoreco[icent]->Sumw2(); xjgmixsignal_pbpbdata_recoreco[icent]->Sumw2(); xjgsideband_pbpbdata_recoreco[icent]->Sumw2(); xjgmixsideband_pbpbdata_recoreco[icent]->Sumw2(); float nphosignal = phoetsignal_pbpbdata_recoreco[icent]->Integral(); float nphosideband = phoetsideband_pbpbdata_recoreco[icent]->Integral(); float binwidth = xjgsignal_pbpbdata_recoreco[icent]->GetBinWidth(1); dummy[icent] = new TH2D(Form("dummy_%d_%d",centmins[icent],centmaxs[icent]),";x_{J#gamma};1/N#gamma dN/dx_{J#gamma}",1,0.01,1.99,1,0,yaxismax); dummy[icent]->GetXaxis()->SetTitleOffset(0.8); dummy[icent]->GetXaxis()->CenterTitle(); dummy[icent]->GetYaxis()->CenterTitle(); dummy[icent]->GetXaxis()->SetTitleSize(dummy[icent]->GetXaxis()->GetTitleSize()*1.4); dummy[icent]->Draw(); xjgsignal_pbpbdata_recoreco[icent]->Scale(1.0/(binwidth*nphosignal)); xjgmixsignal_pbpbdata_recoreco[icent]->Scale(1.0/(binwidth*nphosignal)); // xjgmixsignal_pbpbdata_recoreco[icent]->Draw("same"); h1D_xjg_ptBin1_hiBin_phoSIG_jetSIG_final_norm[icent]->SetMarkerStyle(24); h1D_xjg_ptBin1_hiBin_phoSIG_jetSIG_final_norm[icent]->SetMarkerColor(kRed); xjgsignal_pbpbdata_recoreco[icent]->Divide(h1D_xjg_ptBin1_hiBin_phoSIG_jetSIG_final_norm[icent]); xjgsignal_pbpbdata_recoreco[icent]->Draw("same"); // h1D_xjg_ptBin1_hiBin_phoSIG_jetSIG_final_norm[icent]->Draw("same"); if(icent==0) { leg[icent] = new TLegend(0.03,0.697,0.3,0.92); } else { leg[icent] = new TLegend(0,0.697,0.27,0.92); } leg[icent]->SetTextSize(0.05*1.3); leg[icent]->SetFillColor(0); leg[icent]->SetFillStyle(0); leg[icent]->SetTextFont(42); if(icent==0) { leg[icent]->AddEntry(xjgsignal_pbpbdata_recoreco[icent],"PbPb #sqrt{s_{NN}}=5 TeV","p"); leg[icent]->AddEntry(h1D_xjg_ptBin1_hiBin_phoSIG_jetSIG_final_norm[icent],"HIN-16-002","p"); } else if(icent==1) { leg[icent]->AddEntry(xjgsignal_pbpbdata_recoreco[icent],Form("%d>#gamma p_{T}>%d GeV",phoetmin,phoetmax),""); leg[icent]->AddEntry(xjgsignal_pbpbdata_recoreco[icent],"#sigma_{I#eta#eta}<0.1",""); } else if(icent==2) { leg[icent]->AddEntry(xjgsignal_pbpbdata_recoreco[icent],"|#eta^{jet}| < 1.6",""); leg[icent]->AddEntry(xjgsignal_pbpbdata_recoreco[icent],Form("p_{T}^{jet} > %d GeV",jetptmin),""); } else if(icent==3) { leg[icent]->AddEntry(xjgsignal_pbpbdata_recoreco[icent],"",""); leg[icent]->AddEntry(xjgsignal_pbpbdata_recoreco[icent],"",""); } leg[icent]->AddEntry(xjgsignal_pbpbdata_recoreco[icent],Form("%s",cents[icent].data()),""); leg[icent]->Draw(); } c1->cd(1); TH2D * axis_dummy = new TH2D("axis_dummy","",1,0.01,1.99,1,0,yaxismax); gStyle->SetFrameLineColor(0); axis_dummy->UseCurrentStyle(); axis_dummy->Draw("FB BB A"); TLatex * ldndxi = new TLatex(0.4,0.27,"1/N#gamma dN/dx_{J#gamma} Raw Signal"); ldndxi->SetTextSize(ldndxi->GetTextSize()*1.2); ldndxi->SetNDC(); ldndxi->SetTextAngle(90); ldndxi->Draw(); // float labelspace = yaxismax / 4.0; const int nlabels = 5; float fylabels[] = {0,0.5,1,1.5,2}; string sylabels[] = {"0",".5","1","1.5","2"}; TLatex * laxis[nlabels]; for (int ilatex = 0; ilatex < nlabels; ilatex++) { laxis[ilatex] = new TLatex(0.9,fylabels[ilatex]-0.1,Form("%s",sylabels[ilatex].data())); laxis[ilatex]->SetTextSize(laxis[ilatex]->GetTextSize()*1.3); laxis[ilatex]->Draw(); } c1->SaveAs("xjg_step1_allsubtractions.png"); }
void merge_results(int generated_PDF_set=1, int generated_PDF_member=0){ TString WCharge_str[]={"Pos","Neg"}; TRandom3 *initmass = new TRandom3(0); gStyle->SetOptStat(0); TFile *fout = new TFile(Form("likelihood_results.root"),"RECREATE"); TGraph *result; TCanvas*c_chi2; TF1*ffit[3][2]; // TGraph *result_NonScaled[WMass::PDF_members][3]; TGraph *result_NonScaled[WMass::NtoysMomCorr][WMass::PDF_members][3][2]; double deltaM[WMass::NtoysMomCorr][WMass::PDF_members][3][2]; double deltaMmin[3][2]={{0}},deltaMmax[3][2]={{0}}; double deltaMnegSummed[3][2]={{0}},deltaMposSummed[3][2]={{0}},deltaMSummed[3][2]={{0}},deltaMJuan[3][2]={{0}}; TH1D*h_deltaM_PDF[3][2]; TGraphErrors*g_deltaM_PDF[3][2]; for(int c=0; c<2; c++){ cout <<"merging W " << WCharge_str[c].Data() << endl; if(WMass::PDF_members>1 || WMass::NtoysMomCorr>1){ for(int k=0;k<3;k++){ TString eta_str = Form("%.1f",WMass::etaMaxMuons[0]); eta_str.ReplaceAll(".","p"); g_deltaM_PDF[k][c] = new TGraphErrors(); g_deltaM_PDF[k][c]->SetName(Form("g_deltaM_PDF_W%s_%sNonScaled_eta%s",WCharge_str[c].Data(),WMass::FitVar_str[k].Data(),eta_str.Data())); g_deltaM_PDF[k][c]->SetTitle(Form("g_deltaM_PDF_W%s_%sNonScaled_eta%s",WCharge_str[c].Data(),WMass::FitVar_str[k].Data(),eta_str.Data())); g_deltaM_PDF[k][c]->SetMarkerStyle(20); h_deltaM_PDF[k][c] = new TH1D(Form("h_deltaM_PDF_W%s_%sNonScaled_eta%s",WCharge_str[c].Data(),WMass::FitVar_str[k].Data(),eta_str.Data()),Form("h_deltaM_PDF_%sNonScaled_eta%s",WMass::FitVar_str[k].Data(),eta_str.Data()),200,-50,50); } } for(int h=0; h<WMass::PDF_members; h++){ for(int m=0; m<WMass::NtoysMomCorr; m++){ TString toys_str = ""; if(WMass::NtoysMomCorr>1) toys_str = Form("_MomCorrToy%d",m); // for(int i=0; i<WMass::etaMuonNSteps; i++){ cout << "using pdf " << (WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets) << "-"<<h<< endl; for(int i=0; i<1; i++){ TString eta_str = Form("%.1f",WMass::etaMaxMuons[i]); eta_str.ReplaceAll(".","p"); cout << "merging pdf eta bin= " << i << endl; for(int k=0;k<3;k++){ cout << "variable= " << k << endl; int npoint=0; // result = new TGraph(); // result->SetName(Form("likelihood_results_%s_eta%s",WMass::FitVar_str[k].Data(),eta_str.Data())); // result->SetTitle(Form("likelihood_results_%s_eta%s",WMass::FitVar_str[k].Data(),eta_str.Data())); result_NonScaled[m][h][k][c] = new TGraph(); result_NonScaled[m][h][k][c]->SetName(Form("likelihood_result_W%s_%sNonScaled_pdf%d-%d%s_eta%s",WCharge_str[c].Data(),WMass::FitVar_str[k].Data(),WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets,h,toys_str.Data(),eta_str.Data())); result_NonScaled[m][h][k][c]->SetTitle(Form("likelihood_result_W%s_%sNonScaled_pdf%d-%d%s_eta%s",WCharge_str[c].Data(),WMass::FitVar_str[k].Data(),WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets,h,toys_str.Data(),eta_str.Data())); std::vector<double> l_res; double lmin=0, lmax=0, deriv1=0, deriv2=0, deriv3=0; for(int j=0; j<2*WMass::WMassNSteps+1; j++){ int jWmass = WMass::WMassCentral_MeV-(WMass::WMassNSteps-j)*WMass::WMassStep_MeV; // std::ifstream fileNames(Form("dummy_datacard_Wmass_MuPos_eta%s_%d.log",eta_str.Data(),jWmass)); string StringFromFile; TString TStringFromFile; double likelihood_val; int ncol; // while (!fileNames.eof()){ // getline (fileNames,StringFromFile); // TStringFromFile = StringFromFile.c_str(); // if(TStringFromFile.Contains("nll S+B ->")){ // break; // } // } // TObjArray* LineColumns = TStringFromFile.Tokenize(" "); // ncol = LineColumns->GetEntries(); // if(ncol<3){ // cout << Form("problem while analyzing fit result in dummy_datacard_Wmass_MuPos_eta%s_%d.log",eta_str.Data(),jWmass) << endl; // return; // } // TString str_icol = ((TObjString *)LineColumns->At(3))->GetString(); // likelihood_val = (double) (str_icol.Atof()); // if(likelihood_val<0) result->SetPoint(npoint,jWmass,likelihood_val); // cout << Form("dummy_datacard_Wmass_MuPos_pdf%d-%d%s_eta%s_%d_%sNonScaled.log",WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets,h,(WMass::NtoysMomCorr>1?Form("_MomCorrToy%d",m):""),eta_str.Data(),jWmass,WMass::FitVar_str[k].Data()) << endl; TString test1 = Form("dummy_datacard_Wmass_Mu%s_pdf%d-%d%s_eta%s_%d_%sNonScaled.log",WCharge_str[c].Data(),WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets,h,(WMass::NtoysMomCorr>1?Form("_MomCorrToy%d",m):""),eta_str.Data(),jWmass,WMass::FitVar_str[k].Data()); // cout << test1 << endl; std::ifstream fileNames_NonScaled(test1.Data()); // string StringFromFile; // TString TStringFromFile; while (!fileNames_NonScaled.eof()){ getline (fileNames_NonScaled,StringFromFile); TStringFromFile = StringFromFile.c_str(); // if(TStringFromFile.Contains("nll S+B ->")){ if(TStringFromFile.Contains("-2 ln Q_{TEV}")){ break; } } TObjArray* LineColumns = TStringFromFile.Tokenize(" "); ncol = LineColumns->GetEntries(); // str_icol = ((TObjString *)LineColumns->At(3))->GetString(); TString str_icol = ((TObjString *)LineColumns->At(4))->GetString(); likelihood_val = (double) (str_icol.Atof()); // cout << jWmass << " LIKELIHOOD VALUE= "<<likelihood_val << " lmin= " << lmin << " lmax=" << lmax << endl; cout << " " << jWmass << " LIKELIHOOD VALUE= "<<likelihood_val; fflush(stdout); l_res.push_back(likelihood_val); if(likelihood_val<lmin) lmin=likelihood_val; if(likelihood_val>lmax) lmax=likelihood_val; if(npoint==0) deriv1=likelihood_val; else if(npoint==WMass::WMassNSteps) deriv2=likelihood_val; else if(npoint==2*WMass::WMassNSteps) deriv3=likelihood_val; npoint++; } cout << endl; double l_offset; if(lmax>0) l_offset=-lmax; else l_offset=-lmin; // cout << "lmin= " << lmin << " lmax= " << lmax << endl; for(int j=0; j<2*WMass::WMassNSteps+1; j++){ int jWmass = WMass::WMassCentral_MeV-(WMass::WMassNSteps-j)*WMass::WMassStep_MeV; // cout << "result_NonScaled[h][k]->SetPoint("<<j<<","<<jWmass<<","<<(lmax>0 ? -l_res.at(j) -l_offset : l_res.at(j) -l_offset) <<");"<<endl; result_NonScaled[m][h][k][c]->SetPoint(j,jWmass,deriv3-2*deriv2+deriv1<0 ? -l_res.at(j) -l_offset : l_res.at(j) -l_offset ); } // cout << "second derivative= " << (deriv3-2*deriv2+deriv1) << endl; // result->SetMarkerStyle(20); // result->SetMarkerSize(1); // result->Write(); result_NonScaled[m][h][k][c]->SetMarkerStyle(20); result_NonScaled[m][h][k][c]->SetMarkerSize(1); result_NonScaled[m][h][k][c]->Write(); c_chi2=new TCanvas(Form("c_chi2_W%s_%s_pdf%d-%d%s_eta%s",WCharge_str[c].Data(),WMass::FitVar_str[k].Data(),WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets,h,WMass::NtoysMomCorr>1?Form("_MomCorrToy%d",m):"",eta_str.Data()),Form("c_chi2_W%s_%s_pdf%d-%d%s_eta%s",WCharge_str[c].Data(),WMass::FitVar_str[k].Data(),WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets,h,WMass::NtoysMomCorr>1?Form("_MomCorrToy%d",m):"",eta_str.Data())); ffit[k][c]=new TF1(Form("ffit_W%s_%s_pdf%d-%d%s_eta%s",WCharge_str[c].Data(),WMass::FitVar_str[k].Data(),WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets,h,WMass::NtoysMomCorr>1?Form("_MomCorrToy%d",m):"",eta_str.Data()),Form("[0]+TMath::Power((x-[1])/[2],2)"),70,100); ffit[k][c]->SetParameter(0,result_NonScaled[m][h][k][c]->GetMinimum()); ffit[k][c]->SetParameter(1,80410); ffit[k][c]->SetParameter(2,10); // IF FIT DOES NOT CONVERGE, CHANGE THIS PARAMETER BY LOOKING AT THE CHI2 VS MASS DISTRIBUTION (~value for which Delta_chi2 = 1) // ffit[k]->SetParameter(2,1e4); // IF FIT DOES NOT CONVERGE, CHANGE THIS PARAMETER BY LOOKING AT THE CHI2 VS MASS DISTRIBUTION (~value for which Delta_chi2 = 1) ffit[k][c]->SetLineColor(2); ffit[k][c]->SetLineWidth(1); int fires = result_NonScaled[m][h][k][c]->Fit(Form("ffit_W%s_%s_pdf%d-%d%s_eta%s",WCharge_str[c].Data(),WMass::FitVar_str[k].Data(),WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets,h,WMass::NtoysMomCorr>1?Form("_MomCorrToy%d",m):"",eta_str.Data()),"WEM"); cout << "fitres= " << fires << " chi2= " << ffit[k][c]->GetChisquare() << " ndof= " << ffit[k][c]->GetNDF() << " chi2/ndof= " << (ffit[k][c]->GetChisquare()/ffit[k][c]->GetNDF()) << endl; int attempts=0; while((ffit[k][c]->GetChisquare()/ ffit[k][c]->GetNDF())>1 && attempts<10){ double rmass = initmass->Gaus(80410, 200); ffit[k][c]->SetParameter(1, rmass ); ffit[k][c]->SetParameter(2,10); // IF FIT DOES NOT CONVERGE, CHANGE THIS PARAMETER BY LOOKING AT THE CHI2 VS MASS DISTRIBUTION (~value for which Delta_chi2 = 1) ffit[k][c]->SetLineColor(2); ffit[k][c]->SetLineWidth(1); result_NonScaled[m][h][k][c]->Fit(Form("ffit_W%s_%s_pdf%d-%d%s_eta%s",WCharge_str[c].Data(),WMass::FitVar_str[k].Data(),WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets,h,WMass::NtoysMomCorr>1?Form("_MomCorrToy%d",m):"",eta_str.Data()),"WEM"); cout << "refitted with init mass: " << rmass << " chi2 norm: " << (ffit[k][c]->GetChisquare()/ ffit[k][c]->GetNDF()) << endl; attempts++; } result_NonScaled[m][h][k][c]->Draw("ap"); TLatex *text,*text2; text = new TLatex(0.25,0.7,Form("Best M_{W} with %s= %.0f #pm %.0f MeV", WMass::FitVar_str[k].Data(),ffit[k][c]->GetParameter(1),ffit[k][c]->GetParameter(2))); text->SetNDC(); text->Draw(); text = new TLatex(0.25,0.6,Form("#DeltaM_{W} = %.0f MeV", (ffit[k][c]->GetParameter(1) - WMass::WMassCentral_MeV ))); text->SetNDC(); text->Draw(); // text2 = new TLatex(0.25,0.6,Form("Best #chi^{2} ratio = %.1f", ffit[k]->GetParameter(0) )); // text2->SetNDC(); // text2->Draw(); cout << Form("Best M_W value with %s = %.0f +/- %.0f MeV, DeltaM_W = %.0f",WMass::FitVar_str[k].Data(), ffit[k][c]->GetParameter(1), ffit[k][c]->GetParameter(2), (ffit[k][c]->GetParameter(1) - WMass::WMassCentral_MeV)) << endl; // cout << "Best chi2 ratio value = " << ffit[k]->GetParameter(0) << endl; // cout << "Measured mass points chi2 min = " << chi2min << " max = " << chi2max << endl; c_chi2->Write(); // result_NonScaled[h][k]->Delete(); // result->Delete(); } TCanvas *c_summary=new TCanvas(Form("c_summary_W%s_pdf%d-%d%s_eta%s",WCharge_str[c].Data(),WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets,h,WMass::NtoysMomCorr>1?Form("_MomCorrToy%d",m):"",eta_str.Data()),Form("c_summary_pdf%d-%d%s_eta%s",WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets,h,WMass::NtoysMomCorr>1?Form("_MomCorrToy%d",m):"",eta_str.Data())); c_summary->SetGridy(); c_summary->SetGridx(); TH2D*frame=new TH2D("frame",Form("pdf %d-%d %s eta %s;M_{W} (MeV); -2ln(L/L_{ref})",WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets,h,WMass::NtoysMomCorr>1?Form("_MomCorrToy%d",m):"",eta_str.Data()),2*WMass::WMassStep_MeV+1,WMass::WMassCentral_MeV-(WMass::WMassNSteps)*WMass::WMassStep_MeV,WMass::WMassCentral_MeV+(WMass::WMassNSteps)*WMass::WMassStep_MeV,10,0,5); frame->Draw(); TLine *l=new TLine(WMass::WMassCentral_MeV,0,WMass::WMassCentral_MeV,5); l->SetLineStyle(6); l->SetLineColor(4); l->SetLineWidth(2); l->Draw(); TLegend *leg1 = new TLegend(0.51,0.7,0.89,0.89); leg1->SetFillColor(10); leg1->SetBorderSize(1); leg1->SetTextSize(0.035); leg1->AddEntry(l, Form("gen M_{W} (%d MeV)",WMass::WMassCentral_MeV), "l"); TF1*f[3]; for(int k=0;k<3;k++){ // cout << result_NonScaled[h][k]->GetParameter(1) << " " << ffit[k]->GetParameter(2) << endl; // ffit[k]->Draw(""); f[k] = (TF1*) result_NonScaled[m][h][k][c]->GetFunction(Form("ffit_W%s_%s_pdf%d-%d%s_eta%s",WCharge_str[c].Data(),WMass::FitVar_str[k].Data(),WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets,h,WMass::NtoysMomCorr>1?Form("_MomCorrToy%d",m):"",eta_str.Data())); f[k]->SetLineColor(k+1); f[k]->SetLineWidth(2); f[k]->Draw("same"); leg1->AddEntry(f[k], Form("%s Fit (#DeltaM_{W} = %.0f #pm %0.f MeV)",WMass::FitVar_str[k].Data(), (f[k]->GetParameter(1) - WMass::WMassCentral_MeV),f[k]->GetParameter(2)), "l"); // result_NonScaled[h][k]->Draw("l same"); // ffit[k]->SetLineColor(4); // ffit[k]->SetLineWidth(4); // ffit[k]->Draw(k>0?"same":""); // result_NonScaled[h][k]->SaveAs("test_func"); deltaM[m][h][k][c]=f[k]->GetParameter(1) - WMass::WMassCentral_MeV; if(deltaM[m][h][k][c]<deltaMmin[k][c]) deltaMmin[k][c]=deltaM[m][h][k][c]; if(deltaM[m][h][k][c]>deltaMmax[k][c]) deltaMmax[k][c]=deltaM[m][h][k][c]; if(h>0){ if(deltaM[m][h][k][c]<0) deltaMnegSummed[k][c] = TMath::Sqrt(deltaMnegSummed[k][c]*deltaMnegSummed[k][c] + deltaM[m][h][k][c]*deltaM[m][h][k][c]); if(deltaM[m][h][k][c]>0) deltaMposSummed[k][c] = TMath::Sqrt(deltaMposSummed[k][c]*deltaMposSummed[k][c] + deltaM[m][h][k][c]*deltaM[m][h][k][c]); deltaMSummed[k][c] = TMath::Sqrt(deltaMSummed[k][c]*deltaMSummed[k][c] + deltaM[m][h][k][c]*deltaM[m][h][k][c]); if(h%2==0) deltaMJuan[k][c] = TMath::Sqrt( deltaMJuan[k][c]*deltaMJuan[k][c] + (deltaM[m][h][k][c]-deltaM[m][h-1][k][c])*(deltaM[m][h][k][c]-deltaM[m][h-1][k][c])); } if(WMass::PDF_members>1){ g_deltaM_PDF[k][c]->SetPoint(h,h,deltaM[m][h][k][c]); g_deltaM_PDF[k][c]->SetPointError(h,0,f[k]->GetParameter(2)); h_deltaM_PDF[k][c]->Fill(deltaM[m][h][k][c]); }else if(WMass::NtoysMomCorr>1){ g_deltaM_PDF[k][c]->SetPoint(m,m,deltaM[m][h][k][c]); g_deltaM_PDF[k][c]->SetPointError(m,0,f[k]->GetParameter(2)); h_deltaM_PDF[k][c]->Fill(deltaM[m][h][k][c]); } } leg1->Draw("same"); c_summary->Write(); } } } for(int k=0;k<3;k++){ if(WMass::PDF_members>1){ cout << endl; int usedpdf = WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets; cout << Form("PDF %d with %s: #DeltaM_{W, min}= %.0f MeV, #DeltaM_{W,max}= %.0f MeV", WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets, WMass::FitVar_str[k].Data(), deltaMmin[k][c], deltaMmax[k][c]) << endl; double denominator = 1; TCanvas*c1= new TCanvas(Form("c_deltaM_PDF_W%s_%s",WCharge_str[c].Data(),WMass::FitVar_str[k].Data()),Form("c_deltaM_PDF_W%s_%s",WCharge_str[c].Data(),WMass::FitVar_str[k].Data())); g_deltaM_PDF[k][c]->Draw("ape"); TLatex *text; text = new TLatex(0.2,0.85,Form("W%s, PDF %d with %s: #DeltaM_{W, min}= %.0f MeV, #DeltaM_{W,max}= %.0f MeV", WCharge_str[c].Data(), WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets, WMass::FitVar_str[k].Data(), deltaMmin[k][c], deltaMmax[k][c])); text->SetTextSize(0.035); text->SetNDC(); text->Draw(); if(usedpdf==232000){ // NNPDF, see ref. http://arxiv.org/pdf/1301.6754v1.pdf formulae 2.23 and 2.25 // cout << Form("PDF %d with %s: #DeltaM_{W} square summed = -%.0f MeV, #DeltaM_{W} square summed = %.0f MeV", WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets, WMass::FitVar_str[k].Data(), deltaMnegSummed[k]/denominator, deltaMposSummed[k]/denominator) << endl; denominator = TMath::Sqrt(WMass::PDF_members/2-1); cout << Form("PDF %d with %s: #DeltaM_{W} square summed = %.0f MeV", WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets, WMass::FitVar_str[k].Data(), deltaMSummed[k][c]/denominator) << endl; text = new TLatex(0.2,0.8,Form("PDF %d with %s: #DeltaM_{W} square summed = %.0f MeV", WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets, WMass::FitVar_str[k].Data(), deltaMSummed[k][c]/denominator)); text->SetTextSize(0.035); text->SetNDC(); text->Draw(); }else{ cout << Form("PDF %d with %s: #DeltaM_{W} as of J. Rojo = %.0f MeV", WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets, WMass::FitVar_str[k].Data(), (deltaMJuan[k][c]/2/denominator)) << endl; text = new TLatex(0.2,0.8,Form("PDF %d with %s: #DeltaM_{W} as of J. Rojo = %.0f MeV", WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets, WMass::FitVar_str[k].Data(), (deltaMJuan[k][c]/2/denominator))); text->SetTextSize(0.035); text->SetNDC(); text->Draw(); } g_deltaM_PDF[k][c]->Write(); h_deltaM_PDF[k][c]->Write(); c1->Write(); // mean = TMath::Mean(n, &v[0]); // vector<double> v; // // std::generate(v.begin(), v.end(), 1); // if(k==1) // for(int h=0; h<WMass::PDF_members; h++){ // // v.push_back(deltaM[h][k]); // cout << deltaM[h][k] << endl; // } // double meanWmass= TMath::Mean(v.begin(), v.end()); // cout << "meanWmass= " << meanWmass << endl; } if(WMass::NtoysMomCorr>1){ cout << endl; // int usedpdf = WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets; cout << Form("MomCorr toys with %s: #DeltaM_{W, min}= %.0f MeV, #DeltaM_{W,max}= %.0f MeV", WMass::FitVar_str[k].Data(), deltaMmin[k][c], deltaMmax[k][c]) << endl; double denominator = 1; TCanvas*c1= new TCanvas(Form("c_deltaM_PDF_%s",WMass::FitVar_str[k].Data()),Form("c_deltaM_PDF_%s",WMass::FitVar_str[k].Data())); g_deltaM_PDF[k][c]->Draw("ape"); TLatex *text; text = new TLatex(0.2,0.85,Form("MomCorr toys with %s: #DeltaM_{W, min}= %.0f MeV, #DeltaM_{W,max}= %.0f MeV", WMass::FitVar_str[k].Data(), deltaMmin[k][c], deltaMmax[k][c])); text->SetTextSize(0.035); text->SetNDC(); text->Draw(); // if(usedpdf==232000){ // NNPDF, see ref. http://arxiv.org/pdf/1301.6754v1.pdf formulae 2.23 and 2.25 // cout << Form("PDF %d with %s: #DeltaM_{W} square summed = -%.0f MeV, #DeltaM_{W} square summed = %.0f MeV", WMass::PDF_sets<0?generated_PDF_set:WMass::PDF_sets, WMass::FitVar_str[k].Data(), deltaMnegSummed[k]/denominator, deltaMposSummed[k]/denominator) << endl; denominator = TMath::Sqrt(WMass::NtoysMomCorr/2-1); cout << Form("MomCorr toys with %s: #DeltaM_{W} square summed = %.0f MeV", WMass::FitVar_str[k].Data(), deltaMSummed[k][c]/denominator) << endl; text = new TLatex(0.2,0.8,Form("MomCorr toys with %s: #DeltaM_{W} square summed = %.0f MeV", WMass::FitVar_str[k].Data(), deltaMSummed[k][c]/denominator)); text->SetTextSize(0.035); text->SetNDC(); text->Draw(); // }else{ // cout << Form("MomCorr toys with %s: #DeltaM_{W} as of J. Rojo = %.0f MeV", WMass::FitVar_str[k].Data(), (deltaMJuan[k]/2/denominator)) << endl; // text = new TLatex(0.2,0.8,Form("MomCorr toys with %s: #DeltaM_{W} as of J. Rojo = %.0f MeV", WMass::FitVar_str[k].Data(), (deltaMJuan[k]/2/denominator))); // text->SetTextSize(0.035); // text->SetNDC(); // text->Draw(); // } g_deltaM_PDF[k][c]->Write(); h_deltaM_PDF[k][c]->Write(); c1->Write(); } } } fout->Write(); fout->Delete(); }
int Mbb_reg(int type_int){ gROOT->ProcessLine(".x /afs/cern.ch/work/n/nchernya/setTDRStyle.C"); // int type_int; //double =0; single=1 TString type; if (type_int==0) type = "_double"; if (type_int==1) type = "_single"; TString text_type; if (type_int==0) text_type = "DoubleB"; if (type_int==1) text_type = "SingleB"; const int num_ss = 1; // TString s_names[num_ss] = {"VBFHToBB_M-125_13TeV_powheg"}; TString s_names[num_ss] = {"vbf_76"}; TString tex_s_names[num_ss] = {"VBF powheg, m(H) = 125 GeV"}; TFile *file_s1 = new TFile("../output_hist/v14/golden/skimmed_tree_analysis"+type+s_names[0]+"_v14_final_74cmssw_woweight.root"); TH1F *hist_Mbb = (TH1F*)file_s1->Get("hMbb"); TH1F *hist_Mbb_reg = (TH1F*)file_s1->Get("hMbb_regVBF"); TH1F *hist_Mbb_reg_fsr = (TH1F*)file_s1->Get("hMbb_regVBF_fsr"); TF1 *gaus = new TF1("gaus","gaus",95,140); gaus->SetLineColor(4); gaus->SetLineWidth(1); hist_Mbb->Sumw2(kFALSE); hist_Mbb_reg->Sumw2(kFALSE); hist_Mbb_reg_fsr->Sumw2(kFALSE); hist_Mbb->Sumw2(kFALSE); hist_Mbb->Fit(gaus,"R"); Float_t Mbb_mean = gaus->GetParameter(1); Float_t Mbb_rms = gaus->GetParameter(2); hist_Mbb_reg->Sumw2(kFALSE); gaus->SetLineColor(2); hist_Mbb_reg->Fit(gaus,"R"); Float_t Mbb_reg_mean = gaus->GetParameter(1); Float_t Mbb_reg_rms = gaus->GetParameter(2); hist_Mbb_reg_fsr->Sumw2(kFALSE); gaus->SetLineColor(8); hist_Mbb_reg_fsr->Fit(gaus,"R"); Float_t Mbb_reg_fsr_mean = gaus->GetParameter(1); Float_t Mbb_reg_fsr_rms = gaus->GetParameter(2); ///// /* Float_t Mbb_mean = hist_Mbb->GetMean(1); Float_t Mbb_rms = hist_Mbb->GetRMS(1); Float_t Mbb_reg_mean = hist_Mbb_reg->GetMean(1); Float_t Mbb_reg_rms = hist_Mbb_reg->GetRMS(1); Float_t Mbb_reg_fsr_mean = hist_Mbb_reg_fsr->GetMean(1); Float_t Mbb_reg_fsr_rms = hist_Mbb_reg_fsr->GetRMS(1); */ ///// TCanvas *c1 = new TCanvas(); c1->SetBottomMargin(.15); c1->SetRightMargin(.25); c1->cd(); TH1F *frame2 = new TH1F("frame2","",50,0.,230.); frame2->SetMinimum(0.); frame2->SetMaximum(hist_Mbb->GetMaximum()*1.6); // if (type_int==1) frame2->SetMaximum(0.005); frame2->SetStats(0); frame2->SetYTitle("Events / 5 GeV"); frame2->SetXTitle("M_{bb} (GeV)"); frame2->GetYaxis()->SetNdivisions(505); frame2->GetXaxis()->SetLabelSize(0.0); frame2->GetXaxis()->SetTitleSize(0.05); frame2->GetXaxis()->SetLabelSize(0.04); frame2->Draw(); TLatex* tex = new TLatex(0.75,0.95,"13 TeV"); tex->SetNDC(); tex->SetTextAlign(35); tex->SetTextFont(42); tex->SetTextSize(0.035); tex->SetLineWidth(2); TLatex *tex1 = new TLatex(0.17,0.95,"CMS"); tex1->SetNDC(); tex1->SetTextAlign(20); tex1->SetTextFont(61); tex1->SetTextSize(0.04); tex1->SetLineWidth(2); TLatex* tex2 = new TLatex(0.25,0.89,"Work in progress"); tex2->SetNDC(); tex2->SetTextAlign(20); tex2->SetTextFont(52); tex2->SetTextSize(0.035); tex2->SetLineWidth(2); TLatex* tex_file = new TLatex(0.36,0.95,text_type); tex_file->SetNDC(); tex_file->SetTextAlign(35); tex_file->SetTextFont(42); tex_file->SetTextSize(0.04); tex_file->SetLineWidth(2); tex->Draw(); tex1->Draw(); tex2->Draw(); // tex_file->Draw(); hist_Mbb->SetLineColor(4); hist_Mbb->SetLineWidth(2); hist_Mbb_reg->SetLineColor(2); hist_Mbb_reg->SetLineWidth(2); hist_Mbb_reg_fsr->SetLineColor(8); hist_Mbb_reg_fsr->SetLineWidth(2); hist_Mbb_reg->Draw("same"); hist_Mbb_reg_fsr->Draw("same"); hist_Mbb->Draw("same"); TString leg_Mbb0 = "Nominal"; TString leg_Mbb_reg0 = "Regressed"; TString leg_Mbb_reg_fsr0 = "Regressed+FSR"; TString leg_Mbb = ""; TString leg_Mbb_reg = ""; TString leg_Mbb_reg_fsr = ""; TString leg_mean = "Mean="; TString leg_rms = ", RMS="; TString leg_mean = "#mu="; TString leg_rms = ", #sigma="; TString leg_ratio = ",#sigma/#mu="; TString temp_str; temp_str.Form("%2.1f",Mbb_mean); leg_Mbb.Append(leg_mean); leg_Mbb.Append(temp_str); leg_Mbb.Append(leg_rms); temp_str.Form("%2.1f",Mbb_rms); leg_Mbb.Append(temp_str); leg_Mbb.Append(leg_ratio); temp_str.Form("%2.2f",Mbb_rms/Mbb_mean); leg_Mbb.Append(temp_str); /////// temp_str.Form("%2.1f",Mbb_reg_mean); leg_Mbb_reg.Append(leg_mean); leg_Mbb_reg.Append(temp_str); leg_Mbb_reg.Append(leg_rms); temp_str.Form("%2.1f",Mbb_reg_rms); leg_Mbb_reg.Append(temp_str); leg_Mbb_reg.Append(leg_ratio); temp_str.Form("%2.2f",Mbb_reg_rms/Mbb_reg_mean); leg_Mbb_reg.Append(temp_str); //////// temp_str.Form("%2.1f",Mbb_reg_fsr_mean); leg_Mbb_reg_fsr.Append(leg_mean); leg_Mbb_reg_fsr.Append(temp_str); leg_Mbb_reg_fsr.Append(leg_rms); temp_str.Form("%2.1f",Mbb_reg_fsr_rms); leg_Mbb_reg_fsr.Append(temp_str); leg_Mbb_reg_fsr.Append(leg_ratio); temp_str.Form("%2.2f",Mbb_reg_fsr_rms/Mbb_reg_fsr_mean); leg_Mbb_reg_fsr.Append(temp_str); TLegend *leg = new TLegend(0.77,0.6,0.92,0.9); leg->SetFillColor(0); leg->SetBorderSize(0); leg->SetTextFont(42); leg->SetTextSize(0.025); leg->AddEntry(hist_Mbb,text_type,""); leg->AddEntry(hist_Mbb,leg_Mbb0,"L"); leg->AddEntry(hist_Mbb,leg_Mbb,""); leg->AddEntry(hist_Mbb_reg,leg_Mbb_reg0,"L"); leg->AddEntry(hist_Mbb_reg,leg_Mbb_reg,""); leg->AddEntry(hist_Mbb_reg_fsr,leg_Mbb_reg_fsr0,"L"); leg->AddEntry(hist_Mbb_reg_fsr,leg_Mbb_reg_fsr,""); leg->Draw("same"); c1->Print("plots/v14Mbb_regressed"+type+"_cmssw76.png"); return 0; }
TF1 *fit(TTree *nt, TTree *ntMC, Double_t ptmin, Double_t ptmax, int isMC,bool isPbPb,TF1* &total,Float_t centmin, Float_t centmax) { //cout<<cut.Data()<<endl; static Int_t count=0; count++; TCanvas* c= new TCanvas(Form("c%d",count),"",600,600); TH1D* h = new TH1D(Form("h%d",count),"",nbinsmasshisto,minhisto,maxhisto); // TF1* f = new TF1(Form("f%d",count),"[0]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2]) + [3]*Gaus(x,[4],[5])/(sqrt(2*3.14159)*[5]) + [6]*Gaus(x,[7],[8])/(sqrt(2*3.14159)*[8]) + [9]+[10]*x "); // TF1* f = new TF1(Form("f%d",count),"[0]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2]) + [3]*Gaus(x,[4],[5])/(sqrt(2*3.14159)*[5]) + [9]+[10]*x "); TF1* f = new TF1(Form("f%d",count),"[0]*TMath::Erf((x-[1])/[2]) + [0] + [9]+[10]*x "); if(isMC==1) nt->Project(Form("h%d",count),"Bmass",Form("%s*(%s&&Bpt>%f&&Bpt<%f)","1",seldata.Data(),ptmin,ptmax)); else nt->Project(Form("h%d",count),"Bmass",Form("(%s&&Bpt>%f&&Bpt<%f)",seldata.Data(),ptmin,ptmax)); clean0(h); h->Draw(); f->SetParLimits(0, 1e-2, 1e4); f->SetParLimits(1, 5.02, 5.06); f->SetParLimits(2, 0.001, 0.1); f->SetParLimits(3, 1e-2, 1e4); f->SetParLimits(4, 5.06, 5.10); f->SetParLimits(5, 0.001, 0.1); f->SetParLimits(6, 0, 1e4); f->SetParLimits(7, 5.3, 5.4); f->SetParLimits(8, 0.001, 0.5); f->SetParLimits(9, 0, 1e5); f->SetParLimits(10, -500, 100); f->SetParameter(0,1e2); f->SetParameter(1,5.03); f->SetParameter(2,0.05); f->SetParameter(0,1e2); f->SetParameter(1,5.03); f->SetParameter(2,0.05); f->SetParameter(3,1e2); f->SetParameter(4,5.07); f->SetParameter(5,0.05); f->SetParameter(6,1e2); f->SetParameter(7,5.35); f->SetParameter(8,0.05); f->SetParameter(9,1e3); f->SetParameter(10,-1); //error fn f->SetParLimits(0, 1e1, 1e3); f->SetParLimits(1, 5., 5.3); f->SetParLimits(2, -10, 0); f->SetParameter(0,100); f->SetParameter(1,5.1); f->SetParameter(2,0); h->GetEntries(); h->Fit(Form("f%d",count),"q","",minhisto,maxhisto); h->Fit(Form("f%d",count),"q","",minhisto,maxhisto); h->Fit(Form("f%d",count),"L q","",minhisto,maxhisto); h->Fit(Form("f%d",count),"L q","",minhisto,maxhisto); h->Fit(Form("f%d",count),"L q","",minhisto,maxhisto); h->Fit(Form("f%d",count),"L m","",minhisto,maxhisto); h->SetMarkerSize(0.8); h->SetMarkerStyle(20); TF1 *background = new TF1(Form("background%d",count),"[0]+[1]*x"); background->SetParameter(0,f->GetParameter(9)); background->SetParameter(1,f->GetParameter(10)); background->SetLineColor(4); background->SetRange(minhisto,maxhisto); background->SetLineStyle(2); // TF1 *mass = new TF1(Form("fmass%d",count),"[0]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2]) + [3]*Gaus(x,[4],[5])/(sqrt(2*3.14159)*[5]) + [6]*Gaus(x,[7],[8])/(sqrt(2*3.14159)*[8])"); // mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2),f->GetParameter(3),f->GetParameter(4),f->GetParameter(5),f->GetParameter(6),f->GetParameter(7),f->GetParameter(8)); //TF1 *mass = new TF1(Form("fmass%d",count),"[0]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2]) + [3]*Gaus(x,[4],[5])/(sqrt(2*3.14159)*[5])"); //mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2),f->GetParameter(3),f->GetParameter(4),f->GetParameter(5)); TF1 *mass = new TF1(Form("fmass%d",count),"[0]*TMath::Erf((x-[1])/[2]) + [0]"); mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2)); //mass->SetParError(0,f->GetParError(0)); //mass->SetParError(1,f->GetParError(1)); //mass->SetParError(2,f->GetParError(2)); mass->SetLineColor(2); h->SetXTitle("m_{#mu#muK} (GeV/c^{2})"); h->SetYTitle("Entries / (5 MeV/c^{2})"); h->GetXaxis()->CenterTitle(); h->GetYaxis()->CenterTitle(); h->SetAxisRange(0,h->GetMaximum()*1.4*1.2,"Y"); h->GetXaxis()->SetTitleOffset(1.3); h->GetYaxis()->SetTitleOffset(1.8); h->GetXaxis()->SetLabelOffset(0.007); h->GetYaxis()->SetLabelOffset(0.007); h->GetXaxis()->SetTitleSize(0.045); h->GetYaxis()->SetTitleSize(0.045); h->GetXaxis()->SetTitleFont(42); h->GetYaxis()->SetTitleFont(42); h->GetXaxis()->SetLabelFont(42); h->GetYaxis()->SetLabelFont(42); h->GetXaxis()->SetLabelSize(0.04); h->GetYaxis()->SetLabelSize(0.04); h->SetMarkerSize(0.8); h->SetMarkerStyle(20); h->SetStats(0); h->Draw("e"); background->Draw("same"); mass->SetRange(minhisto,maxhisto); mass->Draw("same"); mass->SetLineStyle(2); mass->SetFillStyle(3004); mass->SetFillColor(2); f->Draw("same"); Double_t yield = mass->Integral(minhisto,maxhisto)/binwidthmass; Double_t yieldErr = mass->Integral(minhisto,maxhisto)/binwidthmass*mass->GetParError(0)/mass->GetParameter(0); TLegend* leg = new TLegend(0.65,0.58,0.82,0.88,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextSize(0.04); leg->SetTextFont(42); leg->SetFillStyle(0); leg->AddEntry(h,"Data","pl"); leg->AddEntry(f,"Fit","l"); leg->AddEntry(mass,"Peaking BG","f"); leg->AddEntry(background,"Combinatorial","l"); leg->Draw("same"); TLatex* texCms = new TLatex(0.18,0.93, "#scale[1.25]{CMS} Preliminary"); texCms->SetNDC(); texCms->SetTextAlign(12); texCms->SetTextSize(0.04); texCms->SetTextFont(42); texCms->Draw(); TLatex* texCol; if(collisionsystem=="pp"||collisionsystem=="PP") texCol= new TLatex(0.96,0.93, Form("%s #sqrt{s_{NN}} = 5.02 TeV","pp")); else texCol= new TLatex(0.96,0.93, Form("%s #sqrt{s_{NN}} = 5.02 TeV","PbPb")); texCol->SetNDC(); texCol->SetTextAlign(32); texCol->SetTextSize(0.04); texCol->SetTextFont(42); texCol->Draw(); TLatex* tex; tex = new TLatex(0.22,0.78,Form("%.1f < p_{T} < %.1f GeV/c",ptmin,ptmax)); tex->SetNDC(); tex->SetTextFont(42); tex->SetTextSize(0.04); tex->SetLineWidth(2); tex->Draw(); if(centMax>0){ TString texper="%"; tex = new TLatex(0.22,0.71,Form("Centrality %.0f-%.0f%s",centMin,centMax,texper.Data()));//0.2612903,0.8425793 tex->SetNDC(); tex->SetTextColor(1); tex->SetTextFont(42); tex->SetTextSize(0.045); tex->SetLineWidth(2); tex->Draw(); } tex = new TLatex(0.22,0.83,"|y| < 2.4"); tex->SetNDC(); tex->SetTextFont(42); tex->SetTextSize(0.04); tex->SetLineWidth(2); tex->Draw(); total=f; h->Write(); f->Write(); if(!isPbPb) c->SaveAs(Form("plotNP/BMass%s_%d.pdf",collisionsystem.Data(),count)); else c->SaveAs(Form("plotNP/BMass%s_%.0f_%.0f_%d.pdf",collisionsystem.Data(),centMin,centMax,count)); return mass; }
void plotMultVtx() { //gROOT->Macro("/net/hisrv0001/home/edwenger/CMSSW_3_7_0/src/UserCode/ASYoon/dNdEtaPlotMacrosV2/paper/rootlogon.C"); gStyle->SetOptStat(0); //set_plot_style(); //TFile *f = new TFile("/net/hibat0003/d00/scratch/frankma/data/MinimumBias/MB-C10-PR9-TRKANASKIM-v3/all/trkhists_histOnly_all.root"); TFile *f = new TFile("../root_files/trkhists_histOnly_all.root"); TLatex *tex = new TLatex(0.52,0.83,"CMS Preliminary"); tex->SetTextSize(0.04); tex->SetLineWidth(2); tex->SetNDC(); TH2F *h1 = (TH2F*) f->Get("preVtxSel/hMultVtxZ"); h1->SetTitle(";z_{PV}^{0} [cm];z_{PV}^{1} [cm]"); h1->GetXaxis()->CenterTitle(); h1->GetXaxis()->SetRangeUser(-17,17); h1->GetYaxis()->CenterTitle(); h1->GetYaxis()->SetRangeUser(-17,17); TH2F *h2 = (TH2F*) f->Get("postTrkVtxSel/hMultVtxZ"); h2->SetTitle(";z_{PV}^{0} [cm];z_{PV}^{1} [cm]"); h2->GetXaxis()->CenterTitle(); h2->GetXaxis()->SetRangeUser(-17,17); h2->GetYaxis()->CenterTitle(); h2->GetYaxis()->SetRangeUser(-17,17); TH2F *h3 = (TH2F*) f->Get("preVtxSel/hMultVtxTracks"); h3->SetTitle(";ntrk_{PV}^{0} [cm];ntrk_{PV}^{1} [cm]"); h3->GetXaxis()->CenterTitle(); h3->GetXaxis()->SetRangeUser(0,40); h3->GetYaxis()->CenterTitle(); h3->GetYaxis()->SetRangeUser(0,40); TH2F *h4 = (TH2F*) f->Get("postTrkVtxSel/hMultVtxTracks"); h4->SetTitle(";ntrk_{PV}^{0} [cm];ntrk_{PV}^{1} [cm]"); h4->GetXaxis()->CenterTitle(); h4->GetXaxis()->SetRangeUser(0,40); h4->GetYaxis()->CenterTitle(); h4->GetYaxis()->SetRangeUser(0,40); TCanvas *c1 = new TCanvas("c1","c1",480,550); gPad->SetLogz(); gPad->SetRightMargin(0.15); h1->Draw("colz"); tex->Draw(); TCanvas *c2 = new TCanvas("c2","c2",480,550); gPad->SetLogz(); gPad->SetRightMargin(0.15); h2->Draw("colz"); tex->Draw(); TCanvas *c3 = new TCanvas("c3","c3",480,550); gPad->SetLogz(); gPad->SetRightMargin(0.15); h3->Draw("colz"); tex->Draw(); TCanvas *c4 = new TCanvas("c4","c4",480,550); gPad->SetLogz(); gPad->SetRightMargin(0.15); h4->Draw("colz"); tex->Draw(); }
void drawclosureffgamma() { const int yaxismax = 4; const int yaxismax2 = 3; TFile *_file0 = TFile::Open("closure.root"); int save = 1; const static int ncentbins = 5; float binwidth = 5.000000e-01; int centmins[] = {0,20,60,100,140}; int centmaxs[] = {20,60,100,140,200}; string cents[] = {"0-10%","10-30%","30-50%","50-70%","70-100%"}; TCanvas * c1_pbpbmc_gen[ncentbins]; // ncentbins TH1D * hgammaffxi_pbpbmc_gen_[ncentbins]; TH1D * hjetpt_pbpbmc_gen_[ncentbins]; TH1D * hgammaffxi_refcone_pbpbmc_gen_[ncentbins]; float njets_pbpbmc_gen[ncentbins]; TCanvas * c1_pbpbmc[ncentbins]; TH1D * hgammaffxi_pbpbmc_[ncentbins]; TH1D * hjetpt_pbpbmc_[ncentbins]; TH1D * hgammaffxi_refcone_pbpbmc_[ncentbins]; float njets_pbpbmc[ncentbins]; TCanvas * c1_subpbpb[ncentbins]; TH2D * dummy_pbpbsub[ncentbins]; TH2D * dummy2_pbpbsub[ncentbins]; TH1D * clone_hgammaffxi_refcone_pbpbmc_gen_[ncentbins]; TH1D * clone_hgammaffxi_pbpbmc_gen_[ncentbins]; TH1D * clone_hgammaffxi_refcone_pbpbmc_[ncentbins]; TH1D * clone_hgammaffxi_pbpbmc_[ncentbins]; TH2D * clone2_hgammaffxi_pbpbmc_gen_[ncentbins]; TH2D * clone2_hgammaffxi_pbpbmc_[ncentbins]; TLegend * leg_ff_pbpbsub[ncentbins]; TLegend * leg_ff_pbpbsub2[ncentbins]; TCanvas * call = new TCanvas("call","",1600,500); // makeMultiPanelCanvas(call,5,1,0,0,0.2,0.2,0.04); makeMultiPanelCanvas(call,6,1,0.02,0.0,-6,0.2,0.04); for (int icent = 0; icent < 5; icent++) { // Raw FF pbpdata hgammaffxi_pbpbmc_gen_[icent] = (TH1D*) _file0->Get(Form("hgammaffxi_pbpbmc_gen_%d_%d",centmins[icent],centmaxs[icent])); hjetpt_pbpbmc_gen_[icent] = (TH1D*) _file0->Get(Form("hjetpt_pbpbmc_gen_%d_%d",centmins[icent],centmaxs[icent])); hgammaffxi_refcone_pbpbmc_gen_[icent] = (TH1D*) _file0->Get(Form("hgammaffxi_refcone_pbpbmc_gen_%d_%d",centmins[icent],centmaxs[icent])); njets_pbpbmc_gen[icent] = hjetpt_pbpbmc_gen_[icent]->Integral(); hgammaffxi_pbpbmc_gen_[icent]->Sumw2(); hgammaffxi_refcone_pbpbmc_gen_[icent]->Sumw2(); hgammaffxi_pbpbmc_gen_[icent]->Scale(1.0/njets_pbpbmc_gen[icent]/binwidth); hgammaffxi_refcone_pbpbmc_gen_[icent]->Scale(1.0/njets_pbpbmc_gen[icent]/binwidth); hgammaffxi_pbpbmc_gen_[icent]->GetXaxis()->CenterTitle(); hgammaffxi_pbpbmc_gen_[icent]->SetYTitle("dN/d#xi"); hgammaffxi_pbpbmc_gen_[icent]->GetYaxis()->CenterTitle(); hgammaffxi_refcone_pbpbmc_gen_[icent]->SetMarkerStyle(24); // Raw FF pbpdata // Raw FF pbmc hgammaffxi_pbpbmc_[icent] = (TH1D*) _file0->Get(Form("hgammaffxi_pbpbmc__%d_%d",centmins[icent],centmaxs[icent])); hjetpt_pbpbmc_[icent] = (TH1D*) _file0->Get(Form("hjetpt_pbpbmc__%d_%d",centmins[icent],centmaxs[icent])); hgammaffxi_refcone_pbpbmc_[icent] = (TH1D*) _file0->Get(Form("hgammaffxi_refcone_pbpbmc__%d_%d",centmins[icent],centmaxs[icent])); njets_pbpbmc[icent] = hjetpt_pbpbmc_[icent]->Integral(); hgammaffxi_pbpbmc_[icent]->Sumw2(); hgammaffxi_refcone_pbpbmc_[icent]->Sumw2(); hgammaffxi_pbpbmc_[icent]->Scale(1.0/njets_pbpbmc[icent]/binwidth); hgammaffxi_refcone_pbpbmc_[icent]->Scale(1.0/njets_pbpbmc[icent]/binwidth); hgammaffxi_pbpbmc_[icent]->GetXaxis()->CenterTitle(); hgammaffxi_pbpbmc_[icent]->SetYTitle("dN/d#xi"); hgammaffxi_pbpbmc_[icent]->GetYaxis()->CenterTitle(); hgammaffxi_refcone_pbpbmc_[icent]->SetMarkerStyle(24); // Raw FF pbpbmc // Eta cone subtracted FF pbpbmc_gen and pbpbmc call->cd(icent+2); dummy_pbpbsub[icent] = new TH2D(Form("dummy_pbpbsub_%d_%d",centmins[icent],centmaxs[icent]),";#xi;dN/d#xi",1,0.01,4.99,1,0,yaxismax); dummy_pbpbsub[icent]->GetXaxis()->SetTitleOffset(0.8); dummy_pbpbsub[icent]->GetXaxis()->CenterTitle(); dummy_pbpbsub[icent]->GetYaxis()->CenterTitle(); dummy_pbpbsub[icent]->GetXaxis()->SetTitleSize(dummy_pbpbsub[icent]->GetXaxis()->GetTitleSize()*1.4); clone_hgammaffxi_refcone_pbpbmc_gen_[icent] = (TH1D*) hgammaffxi_refcone_pbpbmc_gen_[icent]->Clone(Form("clone_hgammaffxi_refcone_pbpbmc_gen_%d_%d",centmins[icent],centmaxs[icent])); clone_hgammaffxi_refcone_pbpbmc_gen_[icent]->Scale(-1); clone_hgammaffxi_pbpbmc_gen_[icent] = (TH1D*) hgammaffxi_pbpbmc_gen_[icent]->Clone(Form("clone_hgammaffxi_pbpbmc_gen_%d_%d",centmins[icent],centmaxs[icent])); // clone_hgammaffxi_pbpbmc_gen_[icent]->Add(clone_hgammaffxi_refcone_pbpbmc_gen_[icent]); // no longer needed when using sube == 0 clone_hgammaffxi_refcone_pbpbmc_[icent] = (TH1D*) hgammaffxi_refcone_pbpbmc_[icent]->Clone(Form("clone_hgammaffxi_refcone_pbpbmc__%d_%d",centmins[icent],centmaxs[icent])); clone_hgammaffxi_refcone_pbpbmc_[icent]->Scale(-1); clone_hgammaffxi_pbpbmc_[icent] = (TH1D*) hgammaffxi_pbpbmc_[icent]->Clone(Form("clone_hgammaffxi_pbpbmc__%d_%d",centmins[icent],centmaxs[icent])); clone_hgammaffxi_pbpbmc_[icent]->Add(clone_hgammaffxi_refcone_pbpbmc_[icent]); clone_hgammaffxi_pbpbmc_[icent]->SetMarkerColor(kRed); clone_hgammaffxi_pbpbmc_gen_[icent]->SetMarkerColor(kBlue); // fixedFontHist(dummy_pbpbsub[icent]); dummy_pbpbsub[icent]->Draw(); clone_hgammaffxi_pbpbmc_gen_[icent]->Draw("same"); // hgammaffxi_pbpbmc_[icent]->Draw("same"); // hgammaffxi_refcone_pbpbmc_[icent]->Draw("same"); clone_hgammaffxi_pbpbmc_[icent]->Draw("same"); if(icent==0) { leg_ff_pbpbsub[icent] = new TLegend(0.03,0.697,0.3,0.92); } else { leg_ff_pbpbsub[icent] = new TLegend(0,0.697,0.27,0.92); } leg_ff_pbpbsub[icent]->SetTextSize(0.05*1.3); leg_ff_pbpbsub[icent]->SetFillColor(0); leg_ff_pbpbsub[icent]->SetFillStyle(0); leg_ff_pbpbsub[icent]->SetTextFont(42); if(icent==0) { leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_gen_[icent],"gen(jet,trk) ff","p"); leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"reco(jet,trk) ff","p"); } else if(icent==1) { // leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"#eta cone sub",""); leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"trk p_{T}>1 GeV, R < 0.3",""); leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"100>#gamma p_{T}>300 GeV",""); } else if(icent==2) { leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"0.3 < |#eta^{jet}| < 1.6",""); leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"p_{T}^{jet} > 40 GeV",""); } else { leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"",""); leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"",""); } leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],Form("%s",cents[icent].data()),""); leg_ff_pbpbsub[icent]->Draw(); // c1_subpbpb[icent]->SaveAs("pbpbmc_gen_pbpbmc_etaconesubtracted_45_gamma_100.png"); // Eta cone subtracted FF pbpbmc_gen and pbpbmc } call->cd(1); TH2D * axis_dummy = new TH2D("axis_dummy","",1,0.01,4.99,1,0,yaxismax); gStyle->SetFrameLineColor(0); axis_dummy->UseCurrentStyle(); axis_dummy->Draw("FB BB A"); TLatex * ldndxi = new TLatex(0.4,0.5,"dN/d#xi"); ldndxi->SetTextSize(ldndxi->GetTextSize()*1.2); ldndxi->SetNDC(); ldndxi->SetTextAngle(90); TLatex * laxis[yaxismax]; for (int ilatex = 0; ilatex < yaxismax; ilatex++) { laxis[ilatex] = new TLatex(3.,ilatex-0.1,Form("%d",ilatex)); laxis[ilatex]->SetTextSize(laxis[ilatex]->GetTextSize()*1.2); laxis[ilatex]->Draw(); } ldndxi->Draw(); TCanvas * callratio = new TCanvas("callratio","",1600,500); makeMultiPanelCanvas(callratio,6,1,0.02,0.0,-6,0.2,0.04); for (int icent = 0; icent < 5; icent++) { callratio->cd(icent+2); clone2_hgammaffxi_pbpbmc_gen_[icent] = (TH2D*) clone_hgammaffxi_pbpbmc_gen_[icent]->Clone(Form("clone2_hgammaffxi_pbpbmc_gen_%d_%d",centmins[icent],centmaxs[icent])); clone2_hgammaffxi_pbpbmc_[icent] = (TH2D*) clone_hgammaffxi_pbpbmc_[icent]->Clone(Form("clone2_hgammaffxi_pbpbmc_%d_%d",centmins[icent],centmaxs[icent])); clone2_hgammaffxi_pbpbmc_gen_[icent]->Divide(clone2_hgammaffxi_pbpbmc_[icent]); dummy2_pbpbsub[icent] = new TH2D(Form("dummy2_pbpbsub_%d_%d",centmins[icent],centmaxs[icent]),";#xi;dN/d#xi",1,0.01,4.99,1,0,yaxismax2); dummy2_pbpbsub[icent]->GetXaxis()->SetTitleOffset(0.8); dummy2_pbpbsub[icent]->GetXaxis()->CenterTitle(); dummy2_pbpbsub[icent]->GetYaxis()->CenterTitle(); dummy2_pbpbsub[icent]->GetXaxis()->SetTitleSize(dummy2_pbpbsub[icent]->GetXaxis()->GetTitleSize()*1.4); dummy2_pbpbsub[icent]->Draw(); // clone2_hgammaffxi_pbpbmc_gen_[icent]->SetMarkerColor(kViolet); clone2_hgammaffxi_pbpbmc_gen_[icent]->SetMarkerColor(kBlack); clone2_hgammaffxi_pbpbmc_gen_[icent]->Draw("same"); TLine * lone = new TLine(0,1,5,1); lone->SetLineStyle(9); lone->Draw(); if(icent==0) { leg_ff_pbpbsub2[icent] = new TLegend(0.03,0.697,0.3,0.92); } else { leg_ff_pbpbsub2[icent] = new TLegend(0,0.697,0.27,0.92); } leg_ff_pbpbsub2[icent]->SetTextSize(0.05*1.3); leg_ff_pbpbsub2[icent]->SetFillColor(0); leg_ff_pbpbsub2[icent]->SetFillStyle(0); leg_ff_pbpbsub2[icent]->SetTextFont(42); if(icent==0) { leg_ff_pbpbsub2[icent]->AddEntry(clone2_hgammaffxi_pbpbmc_gen_[icent],"gen(jet,trk)/reco(jet,trk) ff","p"); leg_ff_pbpbsub2[icent]->AddEntry(clone2_hgammaffxi_pbpbmc_gen_[icent],"",""); } else if(icent==1) { // leg_ff_pbpbsub2[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"#eta cone sub",""); leg_ff_pbpbsub2[icent]->AddEntry(clone2_hgammaffxi_pbpbmc_gen_[icent],"trk p_{T}>1 GeV, R < 0.3",""); leg_ff_pbpbsub2[icent]->AddEntry(clone2_hgammaffxi_pbpbmc_gen_[icent],"100>#gamma p_{T}>300 GeV",""); } else if(icent==2) { leg_ff_pbpbsub2[icent]->AddEntry(clone2_hgammaffxi_pbpbmc_gen_[icent],"0.3 < |#eta^{jet}| < 1.6",""); leg_ff_pbpbsub2[icent]->AddEntry(clone2_hgammaffxi_pbpbmc_gen_[icent],"p_{T}^{jet} > 40 GeV",""); } else { leg_ff_pbpbsub2[icent]->AddEntry(clone2_hgammaffxi_pbpbmc_gen_[icent],"",""); leg_ff_pbpbsub2[icent]->AddEntry(clone2_hgammaffxi_pbpbmc_gen_[icent],"",""); } leg_ff_pbpbsub2[icent]->AddEntry(clone2_hgammaffxi_pbpbmc_gen_[icent],Form("%s",cents[icent].data()),""); leg_ff_pbpbsub2[icent]->Draw(); } callratio->cd(1); TH2D * axis_dummy_ratio = new TH2D("axis_dummy_ratio","",1,0.01,4.99,1,0,yaxismax2); gStyle->SetFrameLineColor(0); axis_dummy_ratio->UseCurrentStyle(); axis_dummy_ratio->Draw("FB BB A"); TLatex * ldndxi2 = new TLatex(0.4,0.4,"dN/d#xi Gen/Reco"); ldndxi2->SetTextSize(ldndxi2->GetTextSize()*1.2); ldndxi2->SetNDC(); ldndxi2->SetTextAngle(90); TLatex * laxis2[yaxismax2]; for (int ilatex = 0; ilatex < yaxismax2; ilatex++) { laxis2[ilatex] = new TLatex(3.,ilatex-0.1,Form("%d",ilatex)); laxis2[ilatex]->SetTextSize(laxis2[ilatex]->GetTextSize()*1.2); laxis2[ilatex]->Draw(); } ldndxi2->Draw(); }
void plotv2vseta(){ int ibin=0; TFile *f = TFile::Open("mergedv_Prod2_eta.root"); TFile *fProd = TFile::Open("mergedv_Prod2_eta.root"); TVectorD *vecDv2 = (TVectorD*)f->Get(Form("D_%d/vmean",ibin)); TVectorD *vecDv2err = (TVectorD*)f->Get(Form("D_%d/deltavmean",ibin)); TVectorD *vecDavgeta = (TVectorD*)f->Get(Form("D_%d/avgeta",ibin)); TVectorD *vecDv2_ = (TVectorD*)fProd->Get(Form("D_%d/vmean",ibin)); TVectorD *vecDv2err_ = (TVectorD*)fProd->Get(Form("D_%d/deltavmean",ibin)); TVectorD *vecDavgeta_ = (TVectorD*)fProd->Get(Form("D_%d/avgeta",ibin)); double *avgeta = vecDavgeta->GetMatrixArray(); double *v2 = vecDv2->GetMatrixArray(); double *v2err = vecDv2err->GetMatrixArray(); double *avgeta_ = vecDavgeta_->GetMatrixArray(); double *v2_ = vecDv2_->GetMatrixArray(); double *v2err_ = vecDv2err_->GetMatrixArray(); double v2corr[netav],v2corr_[netav]; for(int i=0;i<netav;i++){ v2corr[i]=v2[i]; v2corr_[i]=v2_[i]; } TCanvas *c1 = new TCanvas(); /*V2vsPt->SetLineColor(2); V2vsPt->SetTitle("v_{2} vs momentum"); V2vsPt->GetXaxis()->SetTitle("p_{T} (GeV/c)"); V2vsPt->GetYaxis()->SetTitle("v_{2}"); V2vsPt->GetYaxis()->SetRangeUser(0,0.1); V2vsPt->Draw(); */ TGraphErrors *gr=new TGraphErrors(netav,avgeta,v2corr,0,v2err); TGraphErrors *grProd=new TGraphErrors(netav,avgeta_,v2corr_,0,v2err_); grProd->SetTitle("v_{2} vs #eta"); grProd->GetXaxis()->SetTitle("#eta"); grProd->GetYaxis()->SetTitle("v_{2}"); grProd->GetYaxis()->SetRangeUser(0,0.15); grProd->SetMarkerSize(1.3); grProd->SetMarkerColor(1); grProd->SetMarkerStyle(20); grProd->SetMarkerStyle(29); grProd->SetMarkerColor(4); //gr->Draw("AP"); grProd->Draw("AP"); TLegend *tl = new TLegend(0.6,0.6,0.8,0.75); tl->SetFillColor(0); tl->SetBorderSize(0); tl->SetTextSize(0.05); //tl->AddEntry(V2vsPt,"input v_{2}","lp"); //tl->AddEntry(gr,"LYZ Sum method","lp"); tl->AddEntry(grProd,"LYZ Prod method","lp"); tl->Draw("same"); TLatex *tlx = new TLatex(0.2,0.7,"150<multi<185"); tlx->SetNDC(); tlx->SetTextSize(0.045); tlx->Draw("same"); c1->Print("v2vseta.png"); f->Close(); }
void compareplots(){ vector<TFile*> files; files.push_back(new TFile("/storage/9/schweiger/analyseFxFx/pythia8/100kEvents/mergingscale_100/ttbar2JetLO8TeVMECut50GeVCTEQ6M-extracted.root")); files.push_back(new TFile("/storage/9/schweiger/analyseFxFx/pythia8/100kEvents/mergingscale_100/ttbarMergedMS100GeVMCCut50GeV8TeVCTEQ6M-extracted.root")); vector<TString> names; names.push_back("ttbar+2 Jets, in LO"); names.push_back("ttbar+1 Jet, FxFx-Merged"); vector<TString> titles; titles.push_back("Gen-Jet p_{T} with pos weights (GeV)"); titles.push_back("Gen-Jet p_{T} with neg weights (GeV)"); titles.push_back("Gen-Jet p_{T} (GeV)"); titles.push_back("Gen_Jet #phi with pos. weights"); titles.push_back("Gen_Jet #phi with neg. weights"); titles.push_back("Gen_Jet #phi"); titles.push_back("Gen Jet #theta with pos weights"); titles.push_back("Gen Jet #theta with neg weights"); titles.push_back("Gen Jet #theta"); titles.push_back("Gen Jet Energy with pos weights (GeV) "); titles.push_back("Gen Jet Energy with neg weights (GeV)"); titles.push_back("Gen Jet Energy (GeV)"); titles.push_back("p_{T} of hardest Gen-Jet with pos weights (GeV)"); titles.push_back("p_{T} of hardest Gen-Jet with neg weights (GeV)"); titles.push_back("p_{T} of hardest Gen-Jet (GeV)"); titles.push_back("p_{T} of 2nd hardest Gen-Jet with pos weights (GeV)"); titles.push_back("p_{T} of 2nd hardest Gen-Jet with neg weights (GeV)"); titles.push_back("p_{T} of 2nd hardest Gen-Jet (GeV)"); titles.push_back("#eta of hardest Gen-Jets with pos weights"); titles.push_back("#eta of hardest Gen-Jets with neg weights"); titles.push_back("#eta of hardest Gen-Jets"); titles.push_back("Number of Gen-Jets with pos. weights"); titles.push_back("Number of Gen-Jets with neg. weights"); titles.push_back("Number of Gen-Jets"); TFile *vergleich = new TFile("vergleich_ttbar_Fx_vs_noFx.root","RECREATE"); // Show no statistics box gStyle->SetOptStat(0); TH1::SetDefaultSumw2(); // Main program part TIter nextkey(files.at(0)->GetListOfKeys()); TKey *key; bool first=true; TCanvas* c = new TCanvas(); c->Print("plots.pdf["); // Save also as pictures int pictureNumber = 0; int run = 0; while (key = (TKey*)nextkey()) { pictureNumber++; TString pictureName = TString::Format("%d.png",pictureNumber); vector<TH1F*> histos; histos.push_back((TH1F*)key->ReadObj()); for(size_t i=1;i<files.size();i++){ histos.push_back((TH1F*)files.at(i)->Get(histos.at(0)->GetName())); } for(size_t i=0;i<histos.size();i++){ if(i == 0){ histos.at(i)->SetLineColor(kBlack); } if(i == 1){ histos.at(i)->SetLineColor(kRed); } if(i == 2){ histos.at(i)->SetLineColor(kBlue); } if(i == 3){ histos.at(i)->SetLineColor(kGreen+2); } if(i == 4){ histos.at(i)->SetLineColor(kMagenta-7); } if(i == 5){ histos.at(i)->SetLineColor(kOrange+7); } } for(size_t i=0;i<histos.size();i++){ histos.at(i)->Sumw2(); histos.at(i)->Scale(1./histos.at(i)->Integral(),"width"); } // Set axis title histos.at(0)->GetYaxis()->SetTitle("Normalized units"); std::string const histogramName = histos.at(0)->GetName(); histos.at(0)->GetXaxis()->SetLabelSize(0.06); histos.at(0)->GetXaxis()->SetLabelOffset(0.006); histos.at(0)->GetYaxis()->SetLabelSize(0.06); histos.at(0)->GetYaxis()->SetLabelOffset(0.006); histos.at(0)->GetXaxis()->SetTitleSize(0.06); histos.at(0)->GetXaxis()->SetTitleOffset(1.1); histos.at(0)->GetYaxis()->SetTitleSize(0.06); histos.at(0)->GetYaxis()->SetTitleOffset(1.08); histos.at(0)->GetXaxis()->SetTitle(titles.at(run)); run = run+1; if(run == (3*8)){ run = 0; } // If only two histograms per plot make a ratio plot if(histos.size() == 2) { //create main pad TPad *mainPad = new TPad("","",0.0,0.3,1.0,1.0); mainPad->SetNumber(1); mainPad->SetBottomMargin(0.0); mainPad->SetRightMargin(0.04); mainPad->SetLeftMargin(0.13); mainPad->Draw(); //create ratio pad TPad *ratioPad = new TPad("","",0.0,0.0,1.0,0.3); ratioPad->SetTopMargin(0.0); ratioPad->SetBottomMargin(0.4); ratioPad->SetLeftMargin(0.13); ratioPad->SetRightMargin(0.04); gStyle->SetOptTitle(0); ratioPad->SetFillColor(0); ratioPad->SetNumber(2); ratioPad->SetGridy(); ratioPad->Draw(); // Draw both histograms first c->cd(1); histos.at(0)->Draw("histo E"); histos.at(1)->Draw("histo same E"); // Show legend and statistical tests in first pad for(size_t i=0;i<histos.size()-1;i=i+2){ double ksresult = histos.at(i)->KolmogorovTest(histos.at(i+1)); ksresult=floor(ksresult*1000+0.5)/1000; double chi2result =histos.at(i)->Chi2Test(histos.at(i+1),"WW"); chi2result=floor(chi2result*1000+0.5)/1000; stringstream ss; ss << " KS: " <<std::setprecision(3) << ksresult << " chi2: " <<std::setprecision(3) << chi2result << " Private Work"; const char * ch = & ss.str().c_str();; TLatex * ks = new TLatex(0.1, 0.9-0.03*i, ch ); ks->SetTextColor(histos.at(i)->GetLineColor()); ks->SetNDC(); ks->Draw(""); } TLegend* l = new TLegend(0.55,0.9,0.69,0.99); // Options for legend l->SetBorderSize(0); l->SetLineStyle(0); l->SetTextSize(0.049); l->SetFillStyle(0); for(size_t i=0;i<names.size();i++){ l->AddEntry(histos.at(i),names.at(i),"L"); } l->Draw("same"); // Clone histograms and draw ratio plot c->cd(2); TH1F* ratioHisto = (TH1F*)histos.at(0)->Clone(); ratioHisto->Divide(histos.at(1)); ratioHisto->SetLineColor(kBlue); ratioHisto->SetStats(false); ratioHisto->GetYaxis()->SetTitle("Ratio #frac{noFxFx}{FxFx}"); // Same Size like in histogram ratioHisto->SetLabelSize(histos.at(0)->GetLabelSize() * 0.7 / 0.3); ratioHisto->SetTitleOffset((histos.at(0)->GetTitleOffset("Y") * 0.3 / 0.7), "Y"); ratioHisto->SetTitleSize((histos.at(0)->GetTitleSize("Y") * 0.7 / 0.3), "Y"); ratioHisto->SetTitleOffset((histos.at(0)->GetTitleOffset("X")), "X"); ratioHisto->SetTitleSize((histos.at(0)->GetTitleSize("X") * 0.7 / 0.3), "X"); // Use nicer range ratioHisto->GetYaxis()->SetRangeUser(0, 2.2); ratioHisto->GetYaxis()->SetNdivisions(503); ratioHisto->GetYaxis()->SetLabelSize(0.06 * 0.7 / 0.3); ratioHisto->Draw(); } else { histos.at(0)->Draw("histo E"); for(size_t i=0;i<histos.size();i++){ histos.at(i)->Draw("histo same E"); } for(size_t i=0;i<histos.size()-1;i=i+2){ double ksresult = histos.at(i)->KolmogorovTest(histos.at(i+1)); ksresult=floor(ksresult*1000+0.5)/1000; double chi2result =histos.at(i)->Chi2Test(histos.at(i+1),"WW"); chi2result=floor(chi2result*1000+0.5)/1000; stringstream ss; ss << "KS: " <<std::setprecision(3) << ksresult << " chi2: " <<std::setprecision(3) << chi2result; const char * ch = & ss.str().c_str();; TText * ks = new TText(0.1, 0.9-0.03*i, ch ); ks->SetTextColor(histos.at(i)->GetLineColor()); ks->SetNDC(); ks->Draw(""); } TLegend* l = new TLegend(0.65,0.5,0.9,0.7); l->SetBorderSize(0); l->SetLineStyle(0); // l->SetTextSize(0.039); l->SetFillStyle(0); for(size_t i=0;i<names.size();i++){ l->AddEntry(histos.at(i),names.at(i),"L"); } l->Draw("same"); } c->Print("plots.pdf"); c->SaveAs(pictureName); vergleich->WriteTObject(c); } c->Print("plots.pdf]"); }
void X_Resolution() { //=========Macro generated from canvas: c/c //========= (Thu Sep 10 11:42:14 2015) by ROOT version6.03/03 TCanvas *c = new TCanvas("c", "c",2119,55,800,700); c->SetHighLightColor(2); c->Range(-6.445783,-257.7555,5.60241,1890.207); c->SetFillColor(0); c->SetBorderMode(0); c->SetBorderSize(2); c->SetLeftMargin(0.12); c->SetRightMargin(0.05); c->SetTopMargin(0.07); c->SetBottomMargin(0.12); c->SetFrameBorderMode(0); c->SetFrameBorderMode(0); TH1F *histo__1 = new TH1F("histo__1","",40,-5,5); histo__1->SetBinContent(0,72); histo__1->SetBinContent(1,14); histo__1->SetBinContent(2,17); histo__1->SetBinContent(3,17); histo__1->SetBinContent(4,21); histo__1->SetBinContent(5,29); histo__1->SetBinContent(6,22); histo__1->SetBinContent(7,29); histo__1->SetBinContent(8,18); histo__1->SetBinContent(9,23); histo__1->SetBinContent(10,45); histo__1->SetBinContent(11,41); histo__1->SetBinContent(12,70); histo__1->SetBinContent(13,122); histo__1->SetBinContent(14,156); histo__1->SetBinContent(15,314); histo__1->SetBinContent(16,471); histo__1->SetBinContent(17,709); histo__1->SetBinContent(18,1055); histo__1->SetBinContent(19,1472); histo__1->SetBinContent(20,1657); histo__1->SetBinContent(21,1576); histo__1->SetBinContent(22,1318); histo__1->SetBinContent(23,1050); histo__1->SetBinContent(24,800); histo__1->SetBinContent(25,511); histo__1->SetBinContent(26,263); histo__1->SetBinContent(27,180); histo__1->SetBinContent(28,110); histo__1->SetBinContent(29,60); histo__1->SetBinContent(30,64); histo__1->SetBinContent(31,41); histo__1->SetBinContent(32,20); histo__1->SetBinContent(33,27); histo__1->SetBinContent(34,17); histo__1->SetBinContent(35,12); histo__1->SetBinContent(36,14); histo__1->SetBinContent(37,27); histo__1->SetBinContent(38,14); histo__1->SetBinContent(39,23); histo__1->SetBinContent(40,17); histo__1->SetBinContent(41,65); histo__1->SetEntries(12583); histo__1->SetStats(0); TF1 *f1 = new TF1("f","[0]*(TMath::Erf((2*(x-[1])+[2])/([3]*TMath::Sqrt(8))) + TMath::Erf((2*([1]-x)+[2])/([3]*TMath::Sqrt(8))))",-1.8,1.8); f1->SetFillColor(19); f1->SetFillStyle(0); f1->SetLineColor(2); f1->SetLineWidth(2); f1->SetChisquare(44.11321); f1->SetNDF(10); f1->GetXaxis()->SetLabelFont(42); f1->GetXaxis()->SetLabelSize(0.035); f1->GetXaxis()->SetTitleSize(0.035); f1->GetXaxis()->SetTitleFont(42); f1->GetYaxis()->SetLabelFont(42); f1->GetYaxis()->SetLabelSize(0.035); f1->GetYaxis()->SetTitleSize(0.035); f1->GetYaxis()->SetTitleFont(42); f1->SetParameter(0,5944.829); f1->SetParError(0,4323.748); f1->SetParLimits(0,0,0); f1->SetParameter(1,0.002390321); f1->SetParError(1,0.007416957); f1->SetParLimits(1,0,0); f1->SetParameter(2,0.2459713); f1->SetParError(2,0.1804005); f1->SetParLimits(2,0,0); f1->SetParameter(3,0.7402116); f1->SetParError(3,0.008551957); f1->SetParLimits(3,0,0); histo__1->GetListOfFunctions()->Add(f1); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#000099"); histo__1->SetLineColor(ci); histo__1->SetLineWidth(2); histo__1->GetXaxis()->SetTitle("X [mm]"); histo__1->GetXaxis()->SetLabelFont(42); histo__1->GetXaxis()->SetLabelSize(0.035); histo__1->GetXaxis()->SetTitleSize(0.06); histo__1->GetXaxis()->SetTitleOffset(0.8); histo__1->GetXaxis()->SetTitleFont(42); histo__1->GetYaxis()->SetTitle("entries / 0.25 mm"); histo__1->GetYaxis()->SetLabelFont(42); histo__1->GetYaxis()->SetLabelSize(0.035); histo__1->GetYaxis()->SetTitleSize(0.06); histo__1->GetYaxis()->SetTitleOffset(0.95); histo__1->GetYaxis()->SetTitleFont(42); histo__1->GetZaxis()->SetLabelFont(42); histo__1->GetZaxis()->SetLabelSize(0.035); histo__1->GetZaxis()->SetTitleSize(0.035); histo__1->GetZaxis()->SetTitleFont(42); histo__1->Draw(""); TLatex * tex = new TLatex(0.93,0.88,"#sigma = 0.74 #pm 0.01 [mm]"); tex->SetNDC(); tex->SetTextAlign(31); tex->SetTextFont(42); tex->SetTextSize(0.04); tex->SetLineWidth(2); tex->Draw(); c->Modified(); c->cd(); c->SetSelected(c); }
void drawContour(TString bino="bino", TString jet="nojet", bool print=false) { bool useCustomGetContour = false; // TString data_dir = "table_20120131/multiChannel"; // answering preapproval questions TString data_dir = "table_20120209/multiChannel"; // last success after answering preapproval questions //TString data_dir = "."; gStyle->SetOptStat(0); TString label = bino + "_mN375_met100_" + jet; if(bino.Contains("mNScan")) label = bino + "_met100_" + jet; gStyle->SetPalette(1); gStyle->SetPadLeftMargin(0.15); // TString option2D = "CONT4 Z"; TString option2D = "COL Z"; // for bino & wino const int nG = 21; const int nS = 21; float mGVals[nG+1] = {400, 480, 560, 640, 720, 800, 880, 960, 1040, 1120, 1200, 1280, 1360, 1440, 1520, 1600, 1680, 1760, 1840, 1920, 2000, 2100}; float mSVals[nS+1] = {400, 480, 560, 640, 720, 800, 880, 960, 1040, 1120, 1200, 1280, 1360, 1440, 1520, 1600, 1680, 1760, 1840, 1920, 2000, 2100}; // to make valuse on the center of each bin float* mGBins = new float[nG+1]; float* mSBins = new float[nS+1]; for(int i=0; i<nG+1; i++) mGBins[i] = mGVals[i]-40; for(int i=0; i<nS+1; i++) mSBins[i] = mSVals[i]-40; // for mNScan const int nX = 10; const int nY = 23; float xVals[nX+1] = {150, 250, 350, 450, 550, 650, 750, 850, 950, 1050, 1150}; float yVals[nY+1] = {240, 320, 400, 480, 560, 640, 720, 800, 880, 960, 1040, 1120, 1200, 1280, 1360, 1440, 1520, 1600, 1680, 1760, 1840, 1920, 2000, 2100}; float* xBins = new float[nX+1]; float* yBins = new float[nY+1]; for(int i=0; i<nX+1; i++) xBins[i] = xVals[i]-50; for(int i=0; i<nY+1; i++) yBins[i] = yVals[i]-40; TFile* fout = new TFile("hist_exclusion_"+label+".root","RECREATE"); const int nxs = 6; TString xsname[nxs] = {"xsec","xsec_1L","xsec_1H","xsec_2L","xsec_2H","acc"}; TH2D* h_xs[nxs]; for(int i=0; i<nxs; i++) { if(bino.Contains("mNScan")) h_xs[i] = new TH2D(xsname[i],xsname[i],nX,xBins,nY,yBins); else h_xs[i] = new TH2D(xsname[i],xsname[i],nS,mSBins,nG,mGBins); } const int nlimit = 6; TString limitname[nlimit] = {"limit", "exp", "exp_1L","exp_1H","exp_2L","exp_2H"}; TH2D* h_limit[nlimit]; for(int i=0; i<nlimit; i++) { if(bino.Contains("mNScan")) h_limit[i] = new TH2D(limitname[i],limitname[i],nX,xBins,nY,yBins); else h_limit[i] = new TH2D(limitname[i],limitname[i],nS,mSBins,nG,mGBins); } TString datafile = data_dir + "/" + bino + "_" + jet + ".table"; std::ifstream fin; fin.open(datafile.Data()); while(1){ // #echo "mS mG mN acc xsec xsecPDFError xsecRSErrorNeg xsecRSErrorPos obsLimit expLimit exp_m1s exp_m2s exp_p1s exp_p2s" int mS, mG, mN; double acc, xsec, xsecPDFError, xsecRSErrorNeg, xsecRSErrorPos, obsLimit, expLimit, exp_m1s, exp_m2s, exp_p1s, exp_p2s; fin >> mS >> mG >> mN >> acc >> xsec >> xsecPDFError >> xsecRSErrorNeg >> xsecRSErrorPos >> obsLimit >> expLimit >> exp_m1s >> exp_m2s >> exp_p1s >> exp_p2s; if(!fin.good()) break; // std::cout << mS << ", " << mG << ", " << mN << ", " << acc << ", " << xsec << ", " << xsecPDFError << ", " // << xsecRSErrorNeg << ", " << xsecRSErrorPos << ", " << obsLimit << ", " << expLimit << ", " // << exp_m1s << ", " << exp_m2s << ", " << exp_p1s << ", " << exp_p2s << std::endl; double oneSigma_L = std::sqrt(xsecRSErrorNeg * xsecRSErrorNeg + xsecPDFError * xsecPDFError); double oneSigma_H = std::sqrt(xsecRSErrorPos * xsecRSErrorPos + xsecPDFError * xsecPDFError); if(bino.Contains("mNScan")) { if(mS != 2500) continue; h_xs[5]->Fill(mN,mG,acc); h_xs[0]->Fill(mN,mG,xsec); h_xs[1]->Fill(mN,mG,xsec - xsec*oneSigma_L); h_xs[2]->Fill(mN,mG,xsec + xsec*oneSigma_H); h_xs[3]->Fill(mN,mG,xsec - xsec*2*oneSigma_L); h_xs[4]->Fill(mN,mG,xsec + xsec*2*oneSigma_H); h_limit[0]->Fill(mN,mG,obsLimit*xsec); h_limit[1]->Fill(mN,mG,expLimit*xsec); h_limit[2]->Fill(mN,mG,exp_m1s*xsec); h_limit[3]->Fill(mN,mG,exp_p1s*xsec); h_limit[4]->Fill(mN,mG,exp_m2s*xsec); h_limit[5]->Fill(mN,mG,exp_p2s*xsec); } else { if(mN != 375) continue; h_xs[5]->Fill(mS,mG,acc); h_xs[0]->Fill(mS,mG,xsec); h_xs[1]->Fill(mS,mG,xsec - xsec*oneSigma_L); h_xs[2]->Fill(mS,mG,xsec + xsec*oneSigma_H); h_xs[3]->Fill(mS,mG,xsec - xsec*2*oneSigma_L); h_xs[4]->Fill(mS,mG,xsec + xsec*2*oneSigma_H); h_limit[0]->Fill(mS,mG,obsLimit*xsec); h_limit[1]->Fill(mS,mG,expLimit*xsec); h_limit[2]->Fill(mS,mG,exp_m1s*xsec); h_limit[3]->Fill(mS,mG,exp_p1s*xsec); h_limit[4]->Fill(mS,mG,exp_m2s*xsec); h_limit[5]->Fill(mS,mG,exp_p2s*xsec); }// if - else }// while fin.close(); for(int i=0; i<nxs; i++) fillPotHoles(h_xs[i]); for(int i=0; i<nlimit; i++) fillPotHoles(h_limit[i]); TGraph* noRegion2 = new TGraph(3); noRegion2->SetPoint(0,200,200); noRegion2->SetPoint(1,1100,200); noRegion2->SetPoint(2,1100,1100); noRegion2->SetFillColor(16); TLatex* lat44 = new TLatex(0.7,0.25,"#tilde{g} NLSP"); lat44->SetNDC(true); lat44->SetTextSize(0.04); TString title; TCanvas* can_acc = new TCanvas("can_acc_"+label,"can_acc_"+label,1000,800); can_acc->SetRightMargin(0.19); h_xs[5]->GetXaxis()->SetNdivisions(505); h_xs[5]->GetYaxis()->SetNdivisions(505); h_xs[5]->GetYaxis()->SetTitleOffset(1.2); h_xs[5]->GetZaxis()->SetTitleOffset(1.2); title = ";m_{#tilde{q}} (GeV/c^{2});m_{#tilde{g}} (GeV/c^{2});Acceptance"; if(bino.Contains("mNScan")) title = ";m_{#chi^{0}} (GeV/c^{2});m_{#tilde{g}} (GeV/c^{2});Acceptance"; h_xs[5]->SetTitle(title); h_xs[5]->Draw(option2D); if(bino.Contains("mNScan")){ noRegion2->Draw("same f"); lat44->Draw("same"); } if(print) { can_acc->Print("",".gif"); can_acc->Print("",".pdf"); } TCanvas* can_xs = new TCanvas("can_xsec_"+label,"can_xsec_"+label,1000,800); can_xs->SetRightMargin(0.17); can_xs->SetLogz(); h_xs[0]->GetXaxis()->SetNdivisions(505); h_xs[0]->GetYaxis()->SetNdivisions(505); h_xs[0]->GetYaxis()->SetTitleOffset(1.2); h_xs[0]->GetZaxis()->SetTitleOffset(1.0); title = ";m_{#tilde{q}} (GeV/c^{2});m_{#tilde{g}} (GeV/c^{2});Cross Section (pb)"; if(bino.Contains("mNScan")) title = ";m_{#chi^{0}} (GeV/c^{2});m_{#tilde{g}} (GeV/c^{2});Cross Section (pb)"; h_xs[0]->SetTitle(title); h_xs[0]->Draw(option2D); if(bino.Contains("mNScan")){ noRegion2->Draw("same f"); lat44->Draw("same"); } if(print) { can_xs->Print("",".gif"); can_xs->Print("",".pdf"); } TCanvas* can_limit = new TCanvas("can_limit_"+label,"can_limit_"+label,1000,800); can_limit->SetRightMargin(0.2); h_limit[0]->GetXaxis()->SetNdivisions(505); h_limit[0]->GetYaxis()->SetNdivisions(505); h_limit[0]->GetYaxis()->SetTitleOffset(1.2); h_limit[0]->GetZaxis()->SetTitleOffset(1.3); if(bino.Contains("wino")){ can_limit->SetRightMargin(0.17); h_limit[0]->GetZaxis()->SetTitleOffset(1.0); } title = ";m_{#tilde{q}} (GeV/c^{2});m_{#tilde{g}} (GeV/c^{2});95% CL Upper Limit (pb)"; if(bino.Contains("mNScan")) title = ";m_{#chi^{0}} (GeV/c^{2});m_{#tilde{g}} (GeV/c^{2});95% CL Upper Limit (pb)"; h_limit[0]->SetTitle(title); h_limit[0]->Draw(option2D); if(bino.Contains("mNScan")){ noRegion2->Draw("same f"); lat44->Draw("same"); } if(print) { can_limit->Print("",".gif"); can_limit->Print("",".pdf"); } // now find exclusion curves TCanvas* can_diff = new TCanvas("can_diff_"+label,"can_diff_"+label,1200,800); // can_diff->Divide(nlimit,nxs); TH2D* h_excl[nlimit][nxs-1]; for(int i=0; i<nlimit; i++) { for(int j=0; j<nxs-1; j++) { h_excl[i][j] = (TH2D*) h_limit[i]->Clone("exclusion_"+limitname[i]+"_"+xsname[j]); int nbinsx = h_excl[i][j]->GetXaxis()->GetNbins(); int nbinsy = h_excl[i][j]->GetYaxis()->GetNbins(); for( int ibx=1; ibx<=nbinsx; ++ibx){ for( int iby=1; iby<=nbinsy; ++iby){ double x1 = h_limit[i]->GetBinContent(ibx,iby); double x2 = h_xs[j]->GetBinContent(ibx,iby); h_excl[i][j]->SetBinContent(ibx,iby,x2-x1); x1 = h_limit[i]->GetBinError(ibx,iby); x2 = h_xs[j]->GetBinError(ibx,iby); h_excl[i][j]->SetBinError(ibx,iby,std::sqrt(x1*x1+x2*x2)); }// for iby }// for ibx fixBadCells(h_excl[i][j]); if(i==0 && j==0) h_excl[i][j]->Draw("TEXT"); }// for j }// for i float xmin = 400; float ymin = 400; float xmax = 2000; float ymax = 2000; if(bino.Contains("mNScan")){ xmin = 200; xmax = 1500; ymin = 300; ymax = 2000; } TGraph* curv[nlimit][nxs-1]; TGraphSmooth* gsmooth = new TGraphSmooth("normal"); TH2D* h_back; if(bino.Contains("mNScan")) h_back = new TH2D("h_back",";m_{#tilde{#chi^{0}}} (GeV/c^{2});m_{#tilde{g}} (GeV/c^{2})",100,xmin,xmax,100,ymin,ymax); else h_back = new TH2D("h_back",";m_{#tilde{q}} (GeV/c^{2});m_{#tilde{g}} (GeV/c^{2})",100,xmin,xmax,100,ymin,ymax); h_back->GetXaxis()->SetNdivisions(505); h_back->GetYaxis()->SetNdivisions(505); h_back->GetYaxis()->SetTitleOffset(1.2); double contours[2]={ 0.0, 1.0 }; TCanvas *can_excl01 = new TCanvas("can_excl01_"+label, "can_excl01_"+label,1200,800); can_excl01->Divide(nlimit,nxs-1); for(int i=0; i<nlimit; i++) { for(int j=0; j<nxs-1; j++) { can_excl01->cd(j*nlimit + i + 1); h_back->Draw(); if(useCustomGetContour) { curv[i][j] = getContour(h_excl[i][j],"excl_curv_"+limitname[i]+"_"+xsname[j]); curv[i][j]->Draw("SAME L"); } else { h_excl[i][j]->SetContour(2,contours); h_excl[i][j]->Draw("SAME CONT LIST"); gPad->Update(); TObjArray *contsM = (TObjArray*) gROOT->GetListOfSpecials()->FindObject("contours"); TList* contLevel = (TList*)contsM->At(0); curv[i][j] = (TGraph*)contLevel->First()->Clone("excl_curv_"+limitname[i]+"_"+xsname[j]); } // PrintPoints(curv[i][j]); // RemovePoints(curv[i][j]); }// for j }// for i if(bino.Contains("mNScan")) { for(int i=0; i<nlimit; i++) { for(int j=0; j<nxs-1; j++) { RemovePoints(curv[i][j]); } } for(int i=0; i<nlimit; i++) { for(int j=0; j<nxs-1; j++) { double x,y; int whichone = curv[i][j]->GetN()-1; curv[i][j]->GetPoint(whichone-1,x,y); curv[i][j]->SetPoint(whichone,y,y); } } } TGraphSmooth* gs[nlimit][nxs-1]; TGraph* curvS[nlimit][nxs-1]; for(int i=0; i<nlimit; i++) { for(int j=0; j<nxs-1; j++) { // gs[i][j] = new TGraphSmooth("normal"); // curvS[i][j] = gs[i][j]->SmoothSuper(curv[i][j]); curvS[i][j] = (TGraph*) curv[i][j]->Clone(); curvS[i][j]->SetName("excl_curvS_"+limitname[i]+"_"+xsname[j]); } } std::cout << "curv[3][0]----------------- N : " << curv[3][0]->GetN() << std::endl; PrintPoints(curv[3][0]); std::cout << "curvS[3][0]----------------- N : " << curvS[3][0]->GetN() << std::endl; PrintPoints(curvS[3][0]); std::cout << "---------------------------------" << std::endl; // make excluded region TGraph* excludedRegion = new TGraph(curvS[0][0]->GetN()+3); int nbins = curvS[0][0]->GetN(); for(int i=0; i<nbins; i++){ double x,y; curvS[0][0]->GetPoint(i,x,y); excludedRegion->SetPoint(i,x,y); } excludedRegion->SetPoint(nbins,xmax,ymin); excludedRegion->SetPoint(nbins+1,xmin,ymin); excludedRegion->SetPoint(nbins+2,xmin,ymax); // make band graph TGraph* exp1sigma_aroundExp = makeBandGraph(curvS[2][0],curvS[3][0]); TCanvas* can_excl02 = new TCanvas("can_excl02_"+label, "can_excl02_"+label,1000,800); h_back->Draw(); // can_excl02->SetGrid(1,1); // ecluded region excludedRegion->SetFillColor(kBlue-10); excludedRegion->SetFillStyle(1001); excludedRegion->Draw("SAME F"); // experimental 1 sigma band around expected limit exp1sigma_aroundExp->SetFillColor(kOrange-3); exp1sigma_aroundExp->SetFillStyle(1001); exp1sigma_aroundExp->Draw("SAME F"); // expected limit curvS[1][0]->SetLineStyle(9); curvS[1][0]->SetLineWidth(2); curvS[1][0]->SetLineColor(kOrange+9); curvS[1][0]->Draw("SAME L"); // theory 1 sigma around expected limit curvS[1][1]->SetLineStyle(3); curvS[1][1]->SetLineWidth(1); curvS[1][1]->SetLineColor(kOrange+9); curvS[1][1]->Draw("SAME L"); curvS[1][2]->SetLineStyle(3); curvS[1][2]->SetLineWidth(1); curvS[1][2]->SetLineColor(kOrange+9); curvS[1][2]->Draw("SAME L"); // observed limit curvS[0][0]->SetLineWidth(3); curvS[0][0]->SetLineColor(4); curvS[0][0]->Draw("SAME L"); // theory 1 sigma around observed limit curvS[0][1]->SetLineStyle(3); curvS[0][1]->SetLineWidth(2); curvS[0][1]->SetLineColor(kBlue); curvS[0][1]->Draw("SAME L"); curvS[0][2]->SetLineStyle(3); curvS[0][2]->SetLineWidth(2); curvS[0][2]->SetLineColor(kBlue); curvS[0][2]->Draw("SAME L"); PrintPoints(curvS[0][0]); float leg_xmin = 0.65; float leg_xmax = 0.9; float leg_ymin = 0.5; float leg_ymax = 0.8; if(bino.Contains("mNScan")){ leg_xmin -= 0.45; leg_xmax -= 0.45; } TLegend* leg; if(bino.Contains("mNScan")) leg = new TLegend(leg_xmin,leg_ymin,leg_xmax,leg_ymax,"","brNDC"); else leg = new TLegend(leg_xmin,leg_ymin,leg_xmax,leg_ymax,"GGM "+bino+"-like #tilde{#chi}^{0}","brNDC"); leg->SetFillColor(0); leg->SetLineColor(0); leg->SetBorderSize(0); leg->SetTextFont(62); leg->SetTextSize(0.03); if(bino.Contains("mNScan")) leg->AddEntry("NULL","m_{#tilde{q}} = 2500 (GeV/c^{2})","h"); else leg->AddEntry("NULL","m_{#tilde{#chi}^{0}} = 375 (GeV/c^{2})","h"); TString jetRequirement = "Without jet requirement"; if(jet.Contains("1jet")) jetRequirement = "At least 1 jet requirement"; leg->AddEntry("NULL",jetRequirement,"h"); leg->AddEntry("NULL","NLO Limits","h"); leg->AddEntry(curvS[0][0],"Observed","L"); leg->AddEntry(curvS[0][1],"#pm1#sigma (theory)","L"); leg->AddEntry(curvS[1][0],"Expected","L"); leg->AddEntry(curvS[1][1],"#pm1#sigma (theory)","L"); leg->AddEntry(exp1sigma_aroundExp,"#pm1#sigma (experimental)","F"); leg->Draw("same"); TLatex* lat = new TLatex(leg_xmin+0.02,0.87,"CMS Preliminary"); lat->SetNDC(true); lat->SetTextFont(43); lat->SetTextSize(30); lat->Draw("same"); TLatex* lat2 = new TLatex(leg_xmin,0.83,"#int #font[12]{L}dt = 4.7fb^{-1}, #sqrt{s} = 7 TeV"); lat2->SetNDC(true); lat2->SetTextFont(43); lat2->SetTextSize(24); lat2->Draw("same"); float xv = 0.25; float yv = 0.25; if(bino.Contains("wino")){ xv = 0.23; yv = 0.23; } if(bino.Contains("mNScan")){ xv = 0.2; yv = 0.3; } TLatex* lat3 = new TLatex(xv,yv,"Excluded"); lat3->SetNDC(true); lat3->SetTextFont(52); lat3->SetTextSize(0.06); lat3->Draw("same"); TGraph* noRegion = new TGraph(3); noRegion->SetPoint(0,TMath::Min(xmin,ymin),TMath::Min(xmin,ymin)); noRegion->SetPoint(1,xmax,ymin); noRegion->SetPoint(2,TMath::Min(xmax,ymax),TMath::Min(xmax,ymax)); noRegion->SetFillColor(16); TLatex* lat4 = new TLatex(0.7,0.25,"#tilde{g} NLSP"); lat4->SetNDC(true); lat4->SetTextSize(0.04); if(bino.Contains("mNScan")){ noRegion->Draw("same f"); lat4->Draw("same"); } can_excl02->RedrawAxis(); if(print) { can_excl02->Print("",".gif"); can_excl02->Print("",".pdf"); } fout->cd(); fout->Write(); can_acc->Write(); can_xs->Write(); can_limit->Write(); can_excl01->Write(); can_excl02->Write(); for(int i=0; i<nlimit; i++){ for(int j=0; j<nxs-1; j++){ curv[i][j]->Write(); curvS[i][j]->Write(); } } }
void cutChecker() { int kCut =2 ;//1:vProb, 2:dca, 3:MatchedStations, 4:ctau/ctauErr int pbpb=false; gROOT->Macro("./cm/logon.C+");//it all looks much nicer with this. // TString fname2011="../dimuonTree_HI2011_fulldataset_trkRot.root"; // TFile *_file0 = TFile::Open(fname2011); // TTree *upsi2011 = (TTree*)_file0->Get("UpsilonTree"); if(pbpb) { TString fname2013=" ../dimuonTree_upsiMiniTree_AA2p76tev_WithIDCuts_RunHIN-15-001_trigBit1_allTriggers0.root";//../dimuonTree_upsiMiniTree_aa276tev_regitreco_glbglb_Runa_trigBit1_allTriggers0_pt4.root"; }else if(!pbpb){ TString fname2013=" ../dimuonTree_upsiMiniTree_pp2p76tev_noIDVars_GlbGlb_RunHIN-15-001_trigBit2_allTriggers0.root"; } //TString fname2013="../upsiMiniTree_pyquen1S_noMuonPtCuts_QQtrigbit1_Trig_analysisOK_20140729_cuts10-006.root"; TFile *_file1 = TFile::Open(fname2013); TTree *upsi2013 = (TTree*)_file1->Get("UpsilonTree"); RooRealVar* upsPt = new RooRealVar("upsPt","p_{T}(#Upsilon)",0,60,"GeV"); // RooRealVar* upsEta = new RooRealVar("upsEta", "upsEta" ,-10,10); RooRealVar* upsRapidity= new RooRealVar("upsRapidity", "upsRapidity",-1000, 1000); RooRealVar* vProb = new RooRealVar("vProb", "vProb" ,0.01,1.00); RooRealVar* _dca = new RooRealVar("_dca", "_dca" ,0.0,5.00); RooRealVar* _ctau = new RooRealVar("_ctau", "_ctau" ,-100,100,"cm"); RooRealVar* _ctauErr = new RooRealVar("_ctauErr", "_ctauErr" ,-100,100,"cm"); RooRealVar* muPlusPt = new RooRealVar("muPlusPt","muPlusPt",3.5,100); RooRealVar* muMinusPt = new RooRealVar("muMinusPt","muMinusPt",3.5,100); RooRealVar* muPlusEta = new RooRealVar("muPlusEta","muPlusEta", -2.4,2.4); RooRealVar* muMinusEta = new RooRealVar("muMinusEta","muMinusEta",-2.4,2.4); RooRealVar* _mupl_StationsMatched = new RooRealVar("_mupl_StationsMatched","_mupl_StationsMatched",0,5); RooRealVar* _mumi_StationsMatched = new RooRealVar("_mumi_StationsMatched","_mumi_StationsMatched",0,5); RooRealVar* muMinusEta = new RooRealVar("muMinusEta","muMinusEta",-2.4,2.4); RooRealVar* mass = new RooRealVar("invariantMass","#mu#mu mass",7,14,"GeV/c^{2}"); TCut cut_acc = " ((muPlusPt >3.5 && muMinusPt>4)||(muPlusPt>4 &&muMinusPt>3.5)) && abs(upsRapidity)<2.4 && (invariantMass<14 && invariantMass>7)"; // cout << "cut: "<< cut_acc.Print() << endl; // TCut cut_add(cutList(1,1)); //cout << "cut: "<< cut_add.Print() << endl; switch (kCut){ case 1: //vProb] RooDataSet *data0 = new RooDataSet("data0","data0",upsi2013, RooArgSet(*mass,*muPlusPt,*muMinusPt,*upsRapidity,*vProb)); string cut[4]={"vProb>0.01",// very loose "vProb>0.05", "vProb>0.1", "vProb>0.2"};//very tight // for plotting purposes... break; case 2: //dca RooDataSet *data0 = new RooDataSet("data0","data0",upsi2013, RooArgSet(*mass,*muPlusPt,*muMinusPt,*upsRapidity,*_dca)); string cut[4]={"_dca<0.004", //very tight "_dca<0.006", "_dca<0.008", "_dca<0.01"}; // very loose break; case 3: // number of matched Stations RooDataSet *data0 = new RooDataSet("data0","data0",upsi2013, RooArgSet(*mass,*muPlusPt,*muMinusPt,*upsRapidity,*_mupl_StationsMatched,*_mumi_StationsMatched)); string cut[4]={ "_mumi_StationsMatched>0&&_mupl_StationsMatched>0", "_mumi_StationsMatched>1&&_mupl_StationsMatched>1", "_mumi_StationsMatched>2&&_mupl_StationsMatched>2", "_mumi_StationsMatched>3&&_mupl_StationsMatched>3"}; string cutname[4]={ "at least one", "more than 1", "more than 2", "more than 3"}; break; case 4: ///fabs(ctau/ctau_err) RooDataSet *data0 = new RooDataSet("data0","data0",upsi2013, RooArgSet(*mass,*muPlusPt,*muMinusPt,*upsRapidity,*_ctau,*_ctauErr)); string cut[4]={"abs(_ctau/_ctauErr)<5",//very loose "abs(_ctau/_ctauErr)<4" , "abs(_ctau/_ctauErr)<3" , "abs(_ctau/_ctauErr)<2" }; //tighter string cutname[4]={"|c#tau/#sigma(c#tau)| < 5", "|c#tau/#sigma(c#tau)| < 4", "|c#tau/#sigma(c#tau)| < 3", "|c#tau/#sigma(c#tau)| < 2"}; break; default: cout<< "no Cut Variable specified!"<<endl; break; } TCut cut_add1((cut[0]).c_str()); TCut cut_add2((cut[1]).c_str()); TCut cut_add3((cut[2]).c_str()); TCut cut_add4((cut[3]).c_str()); TString figName_(Form("%s",(cut[0]).c_str())); figName_.ReplaceAll(">","_gt"); figName_.ReplaceAll("<","_lt"); figName_.ReplaceAll(".","p"); figName_.ReplaceAll("&&","_AND_"); figName_.ReplaceAll("||","_OR_"); figName_.ReplaceAll("(",""); figName_.ReplaceAll("/","-"); figName_.ReplaceAll(")",""); cout << "hello"<< endl; // cut_add.Print(); int nt = data0->sumEntries(); redData1 = ( RooDataSet*) data0->reduce(Cut(cut_acc+cut_add1)); redData1->Print(); TH1D *MReco1; MReco1 = new TH1D("MReco1","Reco di-muon mass",70,7,14); MReco1 = (TH1D*) redData1->createHistogram("invariantMass",*mass); redData2 = ( RooDataSet*) data0->reduce(Cut(cut_acc+cut_add2)); redData2->Print(); TH1D *MReco2; MReco2 = new TH1D("MReco2","Reco di-muon mass",70,7,14); MReco2 = (TH1D*) redData2->createHistogram("invariantMass",*mass); redData3 = ( RooDataSet*) data0->reduce(Cut(cut_acc+cut_add3)); redData3->Print(); TH1D *MReco3; MReco3 = new TH1D("MReco3","Reco di-muon mass",70,7,14); MReco3 = (TH1D*) redData3->createHistogram("invariantMass",*mass); redData4 = ( RooDataSet*) data0->reduce(Cut(cut_acc+cut_add4)); redData4->Print(); TH1D *MReco4; MReco4 = new TH1D("MReco4","Reco di-muon mass",70,7,14); MReco4 = (TH1D*) redData4->createHistogram("invariantMass",*mass); const double M1S = 9.46; //upsilon 1S pgd mass value const double M2S = 10.023; //upsilon 2S pgd mass value const double M3S = 10.355; //upsilon 3S pgd mass value RooRealVar *nsig1f = new RooRealVar("N_{#Upsilon(1S)}","nsig1S",0,nt*10); RooRealVar *nsig2f = new RooRealVar("N_{#Upsilon(2S)}","nsig2S", nt*0.25,-1*nt,10*nt); RooRealVar *nsig3f = new RooRealVar("N_{#Upsilon(3S)}","nsig3S", nt*0.25,-1*nt,10*nt); RooRealVar *mean = new RooRealVar("mass1S","#Upsilon mean",M1S,M1S-0.1,M1S+0.1); RooConstVar *rat2 = new RooConstVar("rat2", "rat2", M2S/M1S); RooConstVar *rat3 = new RooConstVar("rat3", "rat3", M3S/M1S); // scale mean and resolution by mass ratio RooFormulaVar *mean1S = new RooFormulaVar("mean1S","@0",RooArgList(*mean)); RooFormulaVar *mean2S = new RooFormulaVar("mean2S","@0*@1", RooArgList(*mean,*rat2)); RooFormulaVar *mean3S = new RooFormulaVar("mean3S","@0*@1", RooArgList(*mean,*rat3)); //detector resolution ?? where is this coming from? RooRealVar *sigma1 = new RooRealVar("#sigma_{CB1}","#sigma_{CB1}",0,0.5); // RooFormulaVar *sigma1S = new RooFormulaVar("sigma1S","@0" ,RooArgList(*sigma1)); RooFormulaVar *sigma2S = new RooFormulaVar("sigma2S","@0*@1",RooArgList(*sigma1,*rat2)); RooFormulaVar *sigma3S = new RooFormulaVar("sigma3S","@0*@1",RooArgList(*sigma1,*rat3)); RooRealVar *alpha = new RooRealVar("#alpha_{CB}","tail shift",0.01,8); // MC 5tev 1S pol2 RooRealVar *npow = new RooRealVar("npow","power order",1,60); // MC 5tev 1S pol2 RooRealVar *sigmaFraction = new RooRealVar("sigmaFraction","Sigma Fraction",0.,1.); // scale the sigmaGaus with sigma1S*scale=sigmaGaus now. RooRealVar *scaleWidth = new RooRealVar("#sigma_{CB2}/#sigma_{CB1}","scaleWidth",1.,2.7); RooFormulaVar *sigmaGaus = new RooFormulaVar("sigmaGaus","@0*@1", RooArgList(*sigma1,*scaleWidth)); RooFormulaVar *sigmaGaus2 = new RooFormulaVar("sigmaGaus","@0*@1*@2", RooArgList(*sigma1,*scaleWidth,*rat2)); RooFormulaVar *sigmaGaus3 = new RooFormulaVar("sigmaGaus","@0*@1*@2", RooArgList(*sigma1,*scaleWidth,*rat3)); RooCBShape *cb1S_1 = new RooCBShape ("cb1S_1", "FSR cb 1s", *mass,*mean1S,*sigma1,*alpha,*npow); RooCBShape *cb1S_2 = new RooCBShape ("cb1S_2", "FSR cb 1s", *mass,*mean1S,*sigmaGaus,*alpha,*npow); RooAddPdf *sig1S = new RooAddPdf ("cbcb","1S mass pdf", RooArgList(*cb1S_1,*cb1S_2),*sigmaFraction); // /// Upsilon 2S RooCBShape *cb2S_1 = new RooCBShape ("cb2S_1", "FSR cb 2s", *mass,*mean2S,*sigma2S,*alpha,*npow); RooCBShape *cb2S_2 = new RooCBShape ("cb2S_2", "FSR cb 2s", *mass,*mean2S,*sigmaGaus2,*alpha,*npow); RooAddPdf *sig2S = new RooAddPdf ("sig2S","2S mass pdf", RooArgList(*cb2S_1,*cb2S_2),*sigmaFraction); // /// Upsilon 3S RooCBShape *cb3S_1 = new RooCBShape ("cb3S_1", "FSR cb 3s", *mass,*mean3S,*sigma3S,*alpha,*npow); RooCBShape *cb3S_2 = new RooCBShape ("cb3S_2", "FSR cb 3s", *mass,*mean3S,*sigmaGaus3,*alpha,*npow); RooAddPdf *sig3S = new RooAddPdf ("sig3S","3S mass pdf", RooArgList(*cb3S_1,*cb3S_2),*sigmaFraction); // bkg Chebychev RooRealVar *nbkgd = new RooRealVar("n_{Bkgd}","nbkgd",0,nt); RooRealVar *bkg_a1 = new RooRealVar("a1_bkg", "bkg_{a1}", 0, -5, 5); RooRealVar *bkg_a2 = new RooRealVar("a2_Bkg", "bkg_{a2}", 0, -5, 5); RooRealVar *bkg_a3 = new RooRealVar("a3_Bkg", "bkg_{a3}", 0, -2, 2); RooAbsPdf *pdf_combinedbkgd = new RooChebychev("bkgPdf","bkgPdf", *mass, RooArgList(*bkg_a1,*bkg_a2)); RooRealVar turnOn("turnOn","turnOn",2.,8.6); RooRealVar width("width","width",0.3,8.5);// MB 2.63 RooRealVar decay("decay","decay",1,18);// MB: 3.39 RooGenericPdf *ErrPdf = new RooGenericPdf("ErrPdf","ErrPdf", "exp(-@0/decay)*(TMath::Erf((@0-turnOn)/width)+1)", RooArgList(*mass,turnOn,width,decay)); // bkg_a2->setVal(0); // bkg_a2->setConstant(); RooDataHist binnedData1 ("binnedData1","binnedData1",*mass,Import(*MReco1)); RooDataHist binnedData2 ("binnedData2","binnedData2",*mass,Import(*MReco2)); RooDataHist binnedData3 ("binnedData3","binnedData3",*mass,Import(*MReco3)); RooDataHist binnedData4 ("binnedData4","binnedData4",*mass,Import(*MReco4)); RooAbsPdf *pdf = new RooAddPdf ("pdf","total p.d.f.", RooArgList(*sig1S,*sig2S,*sig3S,*ErrPdf), RooArgList(*nsig1f,*nsig2f,*nsig3f,*nbkgd)); npow->setVal(2); npow->setConstant(); //for the plots! TCanvas c; c.cd(); TPad phead("phead","phead",0.05,0.9,1.,1.,0,0,0); phead.Draw(); phead.cd(); TLatex *cms = new TLatex (0.1,0.1,"CMS Internal"); cms->SetTextFont(40); cms->SetTextSize(0.4); cms->SetTextColor(kBlack); cms->Draw(); if(pbpb){ TLatex *pbpb = new TLatex (0.6,0.1,"PbPb #sqrt{s_{NN}} = 2.76 TeV"); pbpb->SetTextFont(42); pbpb->SetTextSize(0.35); pbpb->SetTextColor(kBlack); pbpb->Draw(); }else if(!pbpb){ TLatex *pp = new TLatex (0.6,0.1,"pp #sqrt{s} = 2.76 TeV"); pp->SetTextFont(42); pp->SetTextSize(0.35); pp->SetTextColor(kBlack); pp->Draw(); } TPad pbody("pbody","pbody",0.0,0.0,1.,0.9,0,0,0); c.cd(); pbody.SetLeftMargin(0.15); pbody.Draw(); pbody.cd(); RooPlot* frame = mass->frame(Bins(70),Range(7,14)); // 1st round RooAbsReal* nll1 = pdf->createNLL(binnedData1,NumCPU(4)) ; RooMinuit(*nll1).migrad(); RooMinuit(*nll1).hesse(); binnedData1.plotOn(frame,Name("theData"),MarkerSize(0.6),MarkerStyle(20),MarkerColor(kBlue)); pdf->plotOn(frame,Name("thePdf"),LineColor(kBlue)); double signif1 = nsig1f->getVal()/nsig1f->getError(); double signif1_2s = nsig2f->getVal()/nsig2f->getError(); double signif1_3s = nsig3f->getVal()/nsig3f->getError(); MReco1->SetMarkerSize(1.0); MReco1->SetMarkerStyle(20); MReco1->SetMarkerColor(kBlue); MReco1->Draw("esame"); // 2nd round RooAbsReal* nll2 = pdf->createNLL(binnedData2,NumCPU(4)) ; RooMinuit(*nll2).migrad(); RooMinuit(*nll2).hesse(); binnedData2.plotOn(frame,Name("theData"),MarkerSize(0.6),MarkerStyle(20),MarkerColor(kRed)); pdf->plotOn(frame,Name("thePdf"),LineColor(kRed)); double signif2 = nsig1f->getVal()/nsig1f->getError(); double signif2_2s = nsig2f->getVal()/nsig2f->getError(); double signif2_3s = nsig3f->getVal()/nsig3f->getError(); MReco2->SetMarkerSize(1.0); MReco2->SetMarkerStyle(20); MReco2->SetMarkerColor(kRed); MReco2->Draw("esame"); // 3rd round RooAbsReal* nll3 = pdf->createNLL(binnedData3,NumCPU(4)) ; RooMinuit(*nll3).migrad(); RooMinuit(*nll3).hesse(); binnedData3.plotOn(frame,Name("theData"),MarkerSize(0.6),MarkerStyle(20),MarkerColor(8)); pdf->plotOn(frame,Name("thePdf"),LineColor(8)); double signif3 = nsig1f->getVal()/nsig1f->getError(); double signif3_2s = nsig2f->getVal()/nsig2f->getError(); double signif3_3s = nsig3f->getVal()/nsig3f->getError(); MReco3->SetMarkerSize(1.0); MReco3->SetMarkerStyle(20); MReco3->SetMarkerColor(8); MReco3->Draw("esame"); // 4th round RooAbsReal* nll4 = pdf->createNLL(binnedData4,NumCPU(4)) ; RooMinuit(*nll4).migrad(); RooMinuit(*nll4).hesse(); binnedData4.plotOn(frame,Name("theData"),MarkerSize(0.6),MarkerStyle(20),MarkerColor(28)); pdf->plotOn(frame,Name("thePdf"),LineColor(28)); double signif4 = nsig1f->getVal()/nsig1f->getError(); double signif4_2s = nsig2f->getVal()/nsig2f->getError(); double signif4_3s = nsig3f->getVal()/nsig3f->getError(); // pdf->paramOn(frame,Layout(0.5,0.95,0.9),Parameters(RooArgSet(signif)),Format("N",AutoPrecision(1))); MReco4->SetMarkerSize(1.0); MReco4->SetMarkerStyle(20); MReco4->SetMarkerColor(28); MReco4->Draw("esame"); // and all that. frame->SetTitle(""); frame->GetXaxis()->SetTitle("m_{#mu^{+}#mu^{-}} (GeV/c^{2})"); frame->GetXaxis()->CenterTitle(kTRUE); frame->GetYaxis()->SetTitleOffset(2); frame->GetXaxis()->SetTitleOffset(1.5); frame->Draw(); TLegend *legend = new TLegend(0.5,0.6,0.95,0.9); legend->SetTextSize(0.034); legend->SetFillStyle(0); legend->SetFillColor(0); legend->SetBorderSize(0); legend->SetTextFont(42); legend->AddEntry(MReco1,"1S significance, #Sigma",""); switch (kCut){ case 1: //vProb] legend->AddEntry(MReco1,"Vertex Probability",""); legend->AddEntry(MReco1,Form("%s, #Sigma = %0.2f",cut[0].c_str(),signif1),"p"); legend->AddEntry(MReco2,Form("%s, #Sigma = %0.2f",cut[1].c_str(),signif2),"p"); legend->AddEntry(MReco3,Form("%s, #Sigma = %0.2f",cut[2].c_str(),signif3),"p"); legend->AddEntry(MReco4,Form("%s, #Sigma = %0.2f",cut[3].c_str(),signif4),"p"); break; case 2: legend->AddEntry(MReco1,"Dist. of closest approach",""); legend->AddEntry(MReco1,Form("%s, #Sigma = %0.2f",cut[0].c_str(),signif1),"p"); legend->AddEntry(MReco2,Form("%s, #Sigma = %0.2f",cut[1].c_str(),signif2),"p"); legend->AddEntry(MReco3,Form("%s, #Sigma = %0.2f",cut[2].c_str(),signif3),"p"); legend->AddEntry(MReco4,Form("%s, #Sigma = %0.2f",cut[3].c_str(),signif4),"p"); break; case 3: legend->AddEntry(MReco1,"Stations matched to each track",""); legend->AddEntry(MReco1,Form("%s, #Sigma = %0.2f",cutname[0].c_str(),signif1),"p"); legend->AddEntry(MReco2,Form("%s, #Sigma = %0.2f",cutname[1].c_str(),signif2),"p"); legend->AddEntry(MReco3,Form("%s, #Sigma = %0.2f",cutname[2].c_str(),signif3),"p"); legend->AddEntry(MReco4,Form("%s, #Sigma = %0.2f",cutname[3].c_str(),signif4),"p"); break; case 4: legend->AddEntry(MReco1,"Pseudo-proper decay length",""); legend->AddEntry(MReco1,Form("%s, #Sigma = %0.2f",cutname[0].c_str(),signif1),"p"); legend->AddEntry(MReco2,Form("%s, #Sigma = %0.2f",cutname[1].c_str(),signif2),"p"); legend->AddEntry(MReco3,Form("%s, #Sigma = %0.2f",cutname[2].c_str(),signif3),"p"); legend->AddEntry(MReco4,Form("%s, #Sigma = %0.2f",cutname[3].c_str(),signif4),"p"); break; default: break; } legend->Draw(); // legend->AddEntry(MReco1,Form(",),"f"); // TLatex latex1; // latex1.SetNDC(); // latex1.SetTextSize(0.032); // latex1.DrawLatex(0.35,1.-0.05*2.,Form("significance: #Sigma vs %s",cut[0].c_str())); // latex1.DrawLatex(0.55,1.-0.05*3.,Form(" #Sigma = %f",signif1)); // latex1.DrawLatex(0.55,1.-0.05*4.,Form(" #Sigma = %f",signif2)); // latex1.DrawLatex(0.55,1.-0.05*5.,Form(" #Sigma = %f",signif3)); // latex1.DrawLatex(0.55,1.-0.05*6.,Form(" #Sigma = %f",signif4)); c.Draw(); if(pbpb){ c.SaveAs("~/Desktop/Grenelle/"+figName_+".pdf"); } else if(!pbpb){ c.SaveAs("~/Desktop/Grenelle/"+figName_+"_pp.pdf"); } cout <<" SIGNIFICANCES \\Sigma OF ALL STATES:" << endl; cout << "xxxx - \\Sigma(1S) \& \\Sigma(2S) \& \\Sigma(3S) " <<endl; cout << cut[0].c_str() <<" & "<< signif1 << " &"<< signif1_2s << " & "<< signif1_3s << endl; cout << cut[1].c_str() <<" & "<< signif2 << " &"<< signif2_2s << " & "<< signif2_3s << endl; cout << cut[2].c_str() <<" & "<< signif3 << " &"<< signif3_2s << " & "<< signif3_3s << endl; cout << cut[3].c_str() <<" & "<< signif4 << " &"<< signif4_2s << " & "<< signif4_3s << endl; }
void ttbar_nJet() { //=========Macro generated from canvas: c1/c1 //========= (Sun Dec 11 15:16:19 2016) by ROOT version6.06/01 TCanvas *c1 = new TCanvas("c1", "c1",1,1,1200,1416); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); c1->SetHighLightColor(2); c1->Range(0,0,1,1); c1->SetFillColor(0); c1->SetBorderMode(0); c1->SetBorderSize(2); c1->SetTickx(1); c1->SetTicky(1); c1->SetLeftMargin(0.15); c1->SetRightMargin(0.05); c1->SetTopMargin(0.07); c1->SetBottomMargin(0.13); c1->SetFrameFillStyle(0); c1->SetFrameBorderMode(0); // ------------>Primitives in pad: pad1 TPad *pad1 = new TPad("pad1", "pad1",0,0.3,1,1); pad1->Draw(); pad1->cd(); pad1->Range(-2.1875,0,9.0625,0.5878968); pad1->SetFillColor(0); pad1->SetBorderMode(0); pad1->SetBorderSize(2); pad1->SetTickx(1); pad1->SetTicky(1); pad1->SetLeftMargin(0.15); pad1->SetRightMargin(0.05); pad1->SetTopMargin(0.07); pad1->SetBottomMargin(0); pad1->SetFrameFillStyle(0); pad1->SetFrameBorderMode(0); pad1->SetFrameFillStyle(0); pad1->SetFrameBorderMode(0); THStack *h = new THStack(); h->SetName("h"); h->SetTitle(""); h->SetMinimum(0); h->SetMaximum(0.5207086); TH1F *h_stack_19 = new TH1F("h_stack_19","",9,-0.5,8.5); h_stack_19->SetMinimum(0); h_stack_19->SetMaximum(0.546744); h_stack_19->SetDirectory(0); h_stack_19->SetStats(0); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#000099"); h_stack_19->SetLineColor(ci); h_stack_19->GetXaxis()->SetLabelFont(42); h_stack_19->GetXaxis()->SetLabelOffset(0.007); h_stack_19->GetXaxis()->SetTitleSize(0.05); h_stack_19->GetXaxis()->SetTickLength(0.025); h_stack_19->GetXaxis()->SetTitleFont(42); h_stack_19->GetYaxis()->SetTitle("a.u."); h_stack_19->GetYaxis()->SetLabelFont(42); h_stack_19->GetYaxis()->SetLabelOffset(0.007); h_stack_19->GetYaxis()->SetTitleSize(0.05); h_stack_19->GetYaxis()->SetTickLength(0.025); h_stack_19->GetYaxis()->SetTitleOffset(1.5); h_stack_19->GetYaxis()->SetTitleFont(42); h_stack_19->GetZaxis()->SetLabelFont(42); h_stack_19->GetZaxis()->SetLabelOffset(0.007); h_stack_19->GetZaxis()->SetTitleSize(0.05); h_stack_19->GetZaxis()->SetTickLength(0.025); h_stack_19->GetZaxis()->SetTitleFont(42); h->SetHistogram(h_stack_19); TH1D *h_nJet_QCD__217 = new TH1D("h_nJet_QCD__217","",9,-0.5,8.5); h_nJet_QCD__217->SetBinContent(2,0.001991738); h_nJet_QCD__217->SetBinContent(3,0.0005078625); h_nJet_QCD__217->SetBinContent(4,0.006489724); h_nJet_QCD__217->SetBinContent(5,0.001899386); h_nJet_QCD__217->SetBinContent(6,0.000696849); h_nJet_QCD__217->SetBinError(2,0.001424948); h_nJet_QCD__217->SetBinError(3,0.0005078625); h_nJet_QCD__217->SetBinError(4,0.00246407); h_nJet_QCD__217->SetBinError(5,0.001037545); h_nJet_QCD__217->SetBinError(6,0.0004566736); h_nJet_QCD__217->SetEntries(25); h_nJet_QCD__217->SetStats(0); ci = TColor::GetColor("#cccccc"); h_nJet_QCD__217->SetFillColor(ci); h_nJet_QCD__217->GetXaxis()->SetTitle("N_{jet}"); h_nJet_QCD__217->GetXaxis()->SetLabelFont(42); h_nJet_QCD__217->GetXaxis()->SetLabelOffset(0.007); h_nJet_QCD__217->GetXaxis()->SetTitleSize(0.05); h_nJet_QCD__217->GetXaxis()->SetTickLength(0.025); h_nJet_QCD__217->GetXaxis()->SetTitleFont(42); h_nJet_QCD__217->GetYaxis()->SetTitle("a.u."); h_nJet_QCD__217->GetYaxis()->SetLabelFont(42); h_nJet_QCD__217->GetYaxis()->SetLabelOffset(0.007); h_nJet_QCD__217->GetYaxis()->SetTitleSize(0.05); h_nJet_QCD__217->GetYaxis()->SetTickLength(0.025); h_nJet_QCD__217->GetYaxis()->SetTitleFont(42); h_nJet_QCD__217->GetZaxis()->SetLabelFont(42); h_nJet_QCD__217->GetZaxis()->SetLabelOffset(0.007); h_nJet_QCD__217->GetZaxis()->SetTitleSize(0.05); h_nJet_QCD__217->GetZaxis()->SetTickLength(0.025); h_nJet_QCD__217->GetZaxis()->SetTitleFont(42); h->Add(h_nJet_QCD,""); TH1D *h_nJet_Diboson__218 = new TH1D("h_nJet_Diboson__218","",9,-0.5,8.5); h_nJet_Diboson__218->SetBinContent(2,0.009906449); h_nJet_Diboson__218->SetBinContent(3,0.01358602); h_nJet_Diboson__218->SetBinContent(4,0.008915388); h_nJet_Diboson__218->SetBinContent(5,0.003026678); h_nJet_Diboson__218->SetBinContent(6,0.001043565); h_nJet_Diboson__218->SetBinContent(7,0.0001748174); h_nJet_Diboson__218->SetBinContent(9,0.0001402611); h_nJet_Diboson__218->SetBinError(2,0.001411368); h_nJet_Diboson__218->SetBinError(3,0.001644099); h_nJet_Diboson__218->SetBinError(4,0.001329375); h_nJet_Diboson__218->SetBinError(5,0.0007635958); h_nJet_Diboson__218->SetBinError(6,0.0004304521); h_nJet_Diboson__218->SetBinError(7,0.0001249106); h_nJet_Diboson__218->SetBinError(9,0.0001402611); h_nJet_Diboson__218->SetEntries(227); h_nJet_Diboson__218->SetStats(0); ci = TColor::GetColor("#9966cc"); h_nJet_Diboson__218->SetFillColor(ci); h_nJet_Diboson__218->GetXaxis()->SetTitle("N_{jet}"); h_nJet_Diboson__218->GetXaxis()->SetLabelFont(42); h_nJet_Diboson__218->GetXaxis()->SetLabelOffset(0.007); h_nJet_Diboson__218->GetXaxis()->SetTitleSize(0.05); h_nJet_Diboson__218->GetXaxis()->SetTickLength(0.025); h_nJet_Diboson__218->GetXaxis()->SetTitleFont(42); h_nJet_Diboson__218->GetYaxis()->SetTitle("a.u."); h_nJet_Diboson__218->GetYaxis()->SetLabelFont(42); h_nJet_Diboson__218->GetYaxis()->SetLabelOffset(0.007); h_nJet_Diboson__218->GetYaxis()->SetTitleSize(0.05); h_nJet_Diboson__218->GetYaxis()->SetTickLength(0.025); h_nJet_Diboson__218->GetYaxis()->SetTitleFont(42); h_nJet_Diboson__218->GetZaxis()->SetLabelFont(42); h_nJet_Diboson__218->GetZaxis()->SetLabelOffset(0.007); h_nJet_Diboson__218->GetZaxis()->SetTitleSize(0.05); h_nJet_Diboson__218->GetZaxis()->SetTickLength(0.025); h_nJet_Diboson__218->GetZaxis()->SetTitleFont(42); h->Add(h_nJet_Diboson,""); TH1D *h_nJet_ZpLjets__219 = new TH1D("h_nJet_ZpLjets__219","",9,-0.5,8.5); h_nJet_ZpLjets__219->SetBinContent(2,0.008808307); h_nJet_ZpLjets__219->SetBinContent(3,0.01602806); h_nJet_ZpLjets__219->SetBinContent(4,0.01236436); h_nJet_ZpLjets__219->SetBinContent(5,0.006259341); h_nJet_ZpLjets__219->SetBinContent(6,0.002572435); h_nJet_ZpLjets__219->SetBinContent(7,0.0009920883); h_nJet_ZpLjets__219->SetBinContent(8,0.0002993959); h_nJet_ZpLjets__219->SetBinContent(9,8.98201e-05); h_nJet_ZpLjets__219->SetBinError(2,0.0003706893); h_nJet_ZpLjets__219->SetBinError(3,0.0003944594); h_nJet_ZpLjets__219->SetBinError(4,0.0003001856); h_nJet_ZpLjets__219->SetBinError(5,0.0001834367); h_nJet_ZpLjets__219->SetBinError(6,0.0001013424); h_nJet_ZpLjets__219->SetBinError(7,5.882736e-05); h_nJet_ZpLjets__219->SetBinError(8,2.500891e-05); h_nJet_ZpLjets__219->SetBinError(9,7.251011e-06); h_nJet_ZpLjets__219->SetEntries(24915); h_nJet_ZpLjets__219->SetStats(0); ci = TColor::GetColor("#3399cc"); h_nJet_ZpLjets__219->SetFillColor(ci); h_nJet_ZpLjets__219->GetXaxis()->SetTitle("N_{jet}"); h_nJet_ZpLjets__219->GetXaxis()->SetLabelFont(42); h_nJet_ZpLjets__219->GetXaxis()->SetLabelOffset(0.007); h_nJet_ZpLjets__219->GetXaxis()->SetTitleSize(0.05); h_nJet_ZpLjets__219->GetXaxis()->SetTickLength(0.025); h_nJet_ZpLjets__219->GetXaxis()->SetTitleFont(42); h_nJet_ZpLjets__219->GetYaxis()->SetTitle("a.u."); h_nJet_ZpLjets__219->GetYaxis()->SetLabelFont(42); h_nJet_ZpLjets__219->GetYaxis()->SetLabelOffset(0.007); h_nJet_ZpLjets__219->GetYaxis()->SetTitleSize(0.05); h_nJet_ZpLjets__219->GetYaxis()->SetTickLength(0.025); h_nJet_ZpLjets__219->GetYaxis()->SetTitleFont(42); h_nJet_ZpLjets__219->GetZaxis()->SetLabelFont(42); h_nJet_ZpLjets__219->GetZaxis()->SetLabelOffset(0.007); h_nJet_ZpLjets__219->GetZaxis()->SetTitleSize(0.05); h_nJet_ZpLjets__219->GetZaxis()->SetTickLength(0.025); h_nJet_ZpLjets__219->GetZaxis()->SetTitleFont(42); h->Add(h_nJet_Z+jets,""); TH1D *h_nJet_WpLjets__220 = new TH1D("h_nJet_WpLjets__220","",9,-0.5,8.5); h_nJet_WpLjets__220->SetBinContent(2,0.01228717); h_nJet_WpLjets__220->SetBinContent(3,0.01478108); h_nJet_WpLjets__220->SetBinContent(4,0.01095229); h_nJet_WpLjets__220->SetBinContent(5,0.004774536); h_nJet_WpLjets__220->SetBinContent(6,0.00183733); h_nJet_WpLjets__220->SetBinContent(7,0.0008017153); h_nJet_WpLjets__220->SetBinContent(8,0.0001693615); h_nJet_WpLjets__220->SetBinContent(9,7.928654e-05); h_nJet_WpLjets__220->SetBinError(2,0.0009957224); h_nJet_WpLjets__220->SetBinError(3,0.0009641816); h_nJet_WpLjets__220->SetBinError(4,0.0007772887); h_nJet_WpLjets__220->SetBinError(5,0.0004513384); h_nJet_WpLjets__220->SetBinError(6,0.0002602176); h_nJet_WpLjets__220->SetBinError(7,0.0001551598); h_nJet_WpLjets__220->SetBinError(8,2.724934e-05); h_nJet_WpLjets__220->SetBinError(9,1.806879e-05); h_nJet_WpLjets__220->SetEntries(3309); h_nJet_WpLjets__220->SetStats(0); ci = TColor::GetColor("#66cc66"); h_nJet_WpLjets__220->SetFillColor(ci); h_nJet_WpLjets__220->GetXaxis()->SetTitle("N_{jet}"); h_nJet_WpLjets__220->GetXaxis()->SetLabelFont(42); h_nJet_WpLjets__220->GetXaxis()->SetLabelOffset(0.007); h_nJet_WpLjets__220->GetXaxis()->SetTitleSize(0.05); h_nJet_WpLjets__220->GetXaxis()->SetTickLength(0.025); h_nJet_WpLjets__220->GetXaxis()->SetTitleFont(42); h_nJet_WpLjets__220->GetYaxis()->SetTitle("a.u."); h_nJet_WpLjets__220->GetYaxis()->SetLabelFont(42); h_nJet_WpLjets__220->GetYaxis()->SetLabelOffset(0.007); h_nJet_WpLjets__220->GetYaxis()->SetTitleSize(0.05); h_nJet_WpLjets__220->GetYaxis()->SetTickLength(0.025); h_nJet_WpLjets__220->GetYaxis()->SetTitleFont(42); h_nJet_WpLjets__220->GetZaxis()->SetLabelFont(42); h_nJet_WpLjets__220->GetZaxis()->SetLabelOffset(0.007); h_nJet_WpLjets__220->GetZaxis()->SetTitleSize(0.05); h_nJet_WpLjets__220->GetZaxis()->SetTickLength(0.025); h_nJet_WpLjets__220->GetZaxis()->SetTitleFont(42); h->Add(h_nJet_W+jets,""); TH1D *h_nJet_TopsPoPLFcP__221 = new TH1D("h_nJet_TopsPoPLFcP__221","",9,-0.5,8.5); h_nJet_TopsPoPLFcP__221->SetBinContent(2,0.008309954); h_nJet_TopsPoPLFcP__221->SetBinContent(3,0.04226496); h_nJet_TopsPoPLFcP__221->SetBinContent(4,0.08832035); h_nJet_TopsPoPLFcP__221->SetBinContent(5,0.08533392); h_nJet_TopsPoPLFcP__221->SetBinContent(6,0.05734558); h_nJet_TopsPoPLFcP__221->SetBinContent(7,0.02841211); h_nJet_TopsPoPLFcP__221->SetBinContent(8,0.01180029); h_nJet_TopsPoPLFcP__221->SetBinContent(9,0.006291982); h_nJet_TopsPoPLFcP__221->SetBinError(2,0.0003851356); h_nJet_TopsPoPLFcP__221->SetBinError(3,0.0007306422); h_nJet_TopsPoPLFcP__221->SetBinError(4,0.001088888); h_nJet_TopsPoPLFcP__221->SetBinError(5,0.0009551542); h_nJet_TopsPoPLFcP__221->SetBinError(6,0.0007663072); h_nJet_TopsPoPLFcP__221->SetBinError(7,0.0005284013); h_nJet_TopsPoPLFcP__221->SetBinError(8,0.0003199885); h_nJet_TopsPoPLFcP__221->SetBinError(9,0.0002275074); h_nJet_TopsPoPLFcP__221->SetEntries(45754); h_nJet_TopsPoPLFcP__221->SetStats(0); ci = TColor::GetColor("#cc33cc"); h_nJet_TopsPoPLFcP__221->SetFillColor(ci); h_nJet_TopsPoPLFcP__221->GetXaxis()->SetTitle("N_{jet}"); h_nJet_TopsPoPLFcP__221->GetXaxis()->SetLabelFont(42); h_nJet_TopsPoPLFcP__221->GetXaxis()->SetLabelOffset(0.007); h_nJet_TopsPoPLFcP__221->GetXaxis()->SetTitleSize(0.05); h_nJet_TopsPoPLFcP__221->GetXaxis()->SetTickLength(0.025); h_nJet_TopsPoPLFcP__221->GetXaxis()->SetTitleFont(42); h_nJet_TopsPoPLFcP__221->GetYaxis()->SetTitle("a.u."); h_nJet_TopsPoPLFcP__221->GetYaxis()->SetLabelFont(42); h_nJet_TopsPoPLFcP__221->GetYaxis()->SetLabelOffset(0.007); h_nJet_TopsPoPLFcP__221->GetYaxis()->SetTitleSize(0.05); h_nJet_TopsPoPLFcP__221->GetYaxis()->SetTickLength(0.025); h_nJet_TopsPoPLFcP__221->GetYaxis()->SetTitleFont(42); h_nJet_TopsPoPLFcP__221->GetZaxis()->SetLabelFont(42); h_nJet_TopsPoPLFcP__221->GetZaxis()->SetLabelOffset(0.007); h_nJet_TopsPoPLFcP__221->GetZaxis()->SetTitleSize(0.05); h_nJet_TopsPoPLFcP__221->GetZaxis()->SetTickLength(0.025); h_nJet_TopsPoPLFcP__221->GetZaxis()->SetTitleFont(42); h->Add(h_nJet_Top (LF),""); TH1D *h_nJet_TopsPoPHFcP__222 = new TH1D("h_nJet_TopsPoPHFcP__222","",9,-0.5,8.5); h_nJet_TopsPoPHFcP__222->SetBinContent(2,0.07376031); h_nJet_TopsPoPHFcP__222->SetBinContent(3,0.1364258); h_nJet_TopsPoPHFcP__222->SetBinContent(4,0.1333122); h_nJet_TopsPoPHFcP__222->SetBinContent(5,0.09566011); h_nJet_TopsPoPHFcP__222->SetBinContent(6,0.05315604); h_nJet_TopsPoPHFcP__222->SetBinContent(7,0.02411419); h_nJet_TopsPoPHFcP__222->SetBinContent(8,0.009464359); h_nJet_TopsPoPHFcP__222->SetBinContent(9,0.004552595); h_nJet_TopsPoPHFcP__222->SetBinError(2,0.00103096); h_nJet_TopsPoPHFcP__222->SetBinError(3,0.001340864); h_nJet_TopsPoPHFcP__222->SetBinError(4,0.001254557); h_nJet_TopsPoPHFcP__222->SetBinError(5,0.001028784); h_nJet_TopsPoPHFcP__222->SetBinError(6,0.0007477547); h_nJet_TopsPoPHFcP__222->SetBinError(7,0.0004712842); h_nJet_TopsPoPHFcP__222->SetBinError(8,0.0003185909); h_nJet_TopsPoPHFcP__222->SetBinError(9,0.0001812819); h_nJet_TopsPoPHFcP__222->SetEntries(77950); h_nJet_TopsPoPHFcP__222->SetStats(0); ci = TColor::GetColor("#ff9900"); h_nJet_TopsPoPHFcP__222->SetFillColor(ci); h_nJet_TopsPoPHFcP__222->GetXaxis()->SetTitle("N_{jet}"); h_nJet_TopsPoPHFcP__222->GetXaxis()->SetLabelFont(42); h_nJet_TopsPoPHFcP__222->GetXaxis()->SetLabelOffset(0.007); h_nJet_TopsPoPHFcP__222->GetXaxis()->SetTitleSize(0.05); h_nJet_TopsPoPHFcP__222->GetXaxis()->SetTickLength(0.025); h_nJet_TopsPoPHFcP__222->GetXaxis()->SetTitleFont(42); h_nJet_TopsPoPHFcP__222->GetYaxis()->SetTitle("a.u."); h_nJet_TopsPoPHFcP__222->GetYaxis()->SetLabelFont(42); h_nJet_TopsPoPHFcP__222->GetYaxis()->SetLabelOffset(0.007); h_nJet_TopsPoPHFcP__222->GetYaxis()->SetTitleSize(0.05); h_nJet_TopsPoPHFcP__222->GetYaxis()->SetTickLength(0.025); h_nJet_TopsPoPHFcP__222->GetYaxis()->SetTitleFont(42); h_nJet_TopsPoPHFcP__222->GetZaxis()->SetLabelFont(42); h_nJet_TopsPoPHFcP__222->GetZaxis()->SetLabelOffset(0.007); h_nJet_TopsPoPHFcP__222->GetZaxis()->SetTitleSize(0.05); h_nJet_TopsPoPHFcP__222->GetZaxis()->SetTickLength(0.025); h_nJet_TopsPoPHFcP__222->GetZaxis()->SetTitleFont(42); h->Add(h_nJet_Top (HF),""); h->Draw("hist"); TH1D *hsum__223 = new TH1D("hsum__223","",9,-0.5,8.5); hsum__223->SetBinContent(2,0.1150639); hsum__223->SetBinContent(3,0.2235937); hsum__223->SetBinContent(4,0.2603543); hsum__223->SetBinContent(5,0.196954); hsum__223->SetBinContent(6,0.1166518); hsum__223->SetBinContent(7,0.05449491); hsum__223->SetBinContent(8,0.0217334); hsum__223->SetBinContent(9,0.01115394); hsum__223->SetBinError(2,0.002522403); hsum__223->SetBinError(3,0.002525467); hsum__223->SetBinError(4,0.00336047); hsum__223->SetBinError(5,0.001966634); hsum__223->SetBinError(6,0.00127208); hsum__223->SetBinError(7,0.0007378717); hsum__223->SetBinError(8,0.0004530571); hsum__223->SetBinError(9,0.0003235352); hsum__223->SetEntries(43); hsum__223->SetStats(0); ci = 1198; color = new TColor(ci, 0, 0, 0, " ", 0.99); hsum__223->SetFillColor(ci); hsum__223->SetFillStyle(3003); hsum__223->SetLineWidth(0); hsum__223->GetXaxis()->SetTitle("N_{jet}"); hsum__223->GetXaxis()->SetLabelFont(42); hsum__223->GetXaxis()->SetLabelOffset(0.007); hsum__223->GetXaxis()->SetTitleSize(0.05); hsum__223->GetXaxis()->SetTickLength(0.025); hsum__223->GetXaxis()->SetTitleFont(42); hsum__223->GetYaxis()->SetTitle("a.u."); hsum__223->GetYaxis()->SetLabelFont(42); hsum__223->GetYaxis()->SetLabelOffset(0.007); hsum__223->GetYaxis()->SetTitleSize(0.05); hsum__223->GetYaxis()->SetTickLength(0.025); hsum__223->GetYaxis()->SetTitleFont(42); hsum__223->GetZaxis()->SetLabelFont(42); hsum__223->GetZaxis()->SetLabelOffset(0.007); hsum__223->GetZaxis()->SetTitleSize(0.05); hsum__223->GetZaxis()->SetTickLength(0.025); hsum__223->GetZaxis()->SetTitleFont(42); hsum__223->Draw("e2 same"); TH1D *h_nJet_Data__224 = new TH1D("h_nJet_Data__224","",9,-0.5,8.5); h_nJet_Data__224->SetBinContent(2,0.1095355); h_nJet_Data__224->SetBinContent(3,0.2408367); h_nJet_Data__224->SetBinContent(4,0.2713182); h_nJet_Data__224->SetBinContent(5,0.1982945); h_nJet_Data__224->SetBinContent(6,0.1091115); h_nJet_Data__224->SetBinContent(7,0.04494488); h_nJet_Data__224->SetBinContent(8,0.017243); h_nJet_Data__224->SetBinContent(9,0.008715726); h_nJet_Data__224->SetBinError(2,0.00227166); h_nJet_Data__224->SetBinError(3,0.003368428); h_nJet_Data__224->SetBinError(4,0.003575241); h_nJet_Data__224->SetBinError(5,0.003056478); h_nJet_Data__224->SetBinError(6,0.002267259); h_nJet_Data__224->SetBinError(7,0.001455144); h_nJet_Data__224->SetBinError(8,0.0009013063); h_nJet_Data__224->SetBinError(9,0.0006407929); h_nJet_Data__224->SetEntries(21226); h_nJet_Data__224->SetStats(0); h_nJet_Data__224->SetLineWidth(3); h_nJet_Data__224->SetMarkerStyle(20); h_nJet_Data__224->SetMarkerSize(2); h_nJet_Data__224->GetXaxis()->SetTitle("N_{jet}"); h_nJet_Data__224->GetXaxis()->SetLabelFont(42); h_nJet_Data__224->GetXaxis()->SetLabelOffset(0.007); h_nJet_Data__224->GetXaxis()->SetTitleSize(0.05); h_nJet_Data__224->GetXaxis()->SetTickLength(0.025); h_nJet_Data__224->GetXaxis()->SetTitleFont(42); h_nJet_Data__224->GetYaxis()->SetTitle("a.u."); h_nJet_Data__224->GetYaxis()->SetLabelFont(42); h_nJet_Data__224->GetYaxis()->SetLabelOffset(0.007); h_nJet_Data__224->GetYaxis()->SetTitleSize(0.05); h_nJet_Data__224->GetYaxis()->SetTickLength(0.025); h_nJet_Data__224->GetYaxis()->SetTitleFont(42); h_nJet_Data__224->GetZaxis()->SetLabelFont(42); h_nJet_Data__224->GetZaxis()->SetLabelOffset(0.007); h_nJet_Data__224->GetZaxis()->SetTitleSize(0.05); h_nJet_Data__224->GetZaxis()->SetTickLength(0.025); h_nJet_Data__224->GetZaxis()->SetTitleFont(42); h_nJet_Data__224->Draw("elp same"); TLegend *leg = new TLegend(0.6,0.55,0.88,0.9,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(0); TLegendEntry *entry=leg->AddEntry("h_nJet_Data","Data","ELP"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(3); entry->SetMarkerColor(1); entry->SetMarkerStyle(20); entry->SetMarkerSize(2); entry->SetTextFont(42); entry=leg->AddEntry("h_nJet_Top (HF)","Top (HF)","F"); ci = TColor::GetColor("#ff9900"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_nJet_Top (LF)","Top (LF)","F"); ci = TColor::GetColor("#cc33cc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_nJet_W+jets","W+jets","F"); ci = TColor::GetColor("#66cc66"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_nJet_Z+jets","Z+jets","F"); ci = TColor::GetColor("#3399cc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_nJet_Diboson","Diboson","F"); ci = TColor::GetColor("#9966cc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_nJet_QCD","QCD","F"); ci = TColor::GetColor("#cccccc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); leg->Draw(); leg = new TLegend(0.6,0.55,0.88,0.9,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(0); entry=leg->AddEntry("h_nJet_Data","Data","ELP"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(3); entry->SetMarkerColor(1); entry->SetMarkerStyle(20); entry->SetMarkerSize(2); entry->SetTextFont(42); entry=leg->AddEntry("h_nJet_Top (HF)","Top (HF)","F"); ci = TColor::GetColor("#ff9900"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_nJet_Top (LF)","Top (LF)","F"); ci = TColor::GetColor("#cc33cc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_nJet_W+jets","W+jets","F"); ci = TColor::GetColor("#66cc66"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_nJet_Z+jets","Z+jets","F"); ci = TColor::GetColor("#3399cc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_nJet_Diboson","Diboson","F"); ci = TColor::GetColor("#9966cc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_nJet_QCD","QCD","F"); ci = TColor::GetColor("#cccccc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); leg->Draw(); TLatex * tex = new TLatex(0.18,0.85,"CMS"); tex->SetNDC(); tex->SetTextSize(0.06); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.28,0.85,"Preliminary"); tex->SetNDC(); tex->SetTextFont(52); tex->SetTextSize(0.06); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.9,0.94,"36.6 fb^{-1} (13 TeV)"); tex->SetNDC(); tex->SetTextAlign(31); tex->SetTextFont(42); tex->SetTextSize(0.04); tex->SetLineWidth(2); tex->Draw(); pad1->Modified(); c1->cd(); // ------------>Primitives in pad: pad2 TPad *pad2 = new TPad("pad2", "pad2",0,0.05,1,0.3); pad2->Draw(); pad2->cd(); pad2->Range(-2.1875,-0.8914286,9.0625,0.48); pad2->SetFillColor(0); pad2->SetBorderMode(0); pad2->SetBorderSize(2); pad2->SetGridy(); pad2->SetTickx(1); pad2->SetTicky(1); pad2->SetLeftMargin(0.15); pad2->SetRightMargin(0.05); pad2->SetTopMargin(0); pad2->SetBottomMargin(0.3); pad2->SetFrameFillStyle(0); pad2->SetFrameBorderMode(0); pad2->SetFrameFillStyle(0); pad2->SetFrameBorderMode(0); TH1D *ratio__225 = new TH1D("ratio__225","",9,-0.5,8.5); ratio__225->SetBinContent(1,-999); ratio__225->SetBinContent(2,-0.04804683); ratio__225->SetBinContent(3,0.07711744); ratio__225->SetBinContent(4,0.0421114); ratio__225->SetBinContent(5,0.006806612); ratio__225->SetBinContent(6,-0.06463963); ratio__225->SetBinContent(7,-0.1752464); ratio__225->SetBinContent(8,-0.2066128); ratio__225->SetBinContent(9,-0.2185969); ratio__225->SetBinError(1,0.0001); ratio__225->SetBinError(2,0.0001); ratio__225->SetBinError(3,0.0001); ratio__225->SetBinError(4,0.0001); ratio__225->SetBinError(5,0.0001); ratio__225->SetBinError(6,0.0001); ratio__225->SetBinError(7,0.0001); ratio__225->SetBinError(8,0.0001); ratio__225->SetBinError(9,0.0001); ratio__225->SetMinimum(-0.48); ratio__225->SetMaximum(0.48); ratio__225->SetEntries(21235); ratio__225->SetStats(0); ratio__225->SetLineWidth(3); ratio__225->SetMarkerStyle(20); ratio__225->SetMarkerSize(2); ratio__225->GetXaxis()->SetTitle("N_{jet}"); ratio__225->GetXaxis()->SetLabelFont(43); ratio__225->GetXaxis()->SetLabelOffset(0.007); ratio__225->GetXaxis()->SetLabelSize(30); ratio__225->GetXaxis()->SetTitleSize(40); ratio__225->GetXaxis()->SetTickLength(0.025); ratio__225->GetXaxis()->SetTitleOffset(5); ratio__225->GetXaxis()->SetTitleFont(43); ratio__225->GetYaxis()->SetTitle("#frac{Data-Exp}{Exp}"); ratio__225->GetYaxis()->SetNdivisions(5); ratio__225->GetYaxis()->SetLabelFont(43); ratio__225->GetYaxis()->SetLabelOffset(0.007); ratio__225->GetYaxis()->SetLabelSize(30); ratio__225->GetYaxis()->SetTitleSize(40); ratio__225->GetYaxis()->SetTickLength(0.025); ratio__225->GetYaxis()->SetTitleOffset(2.5); ratio__225->GetYaxis()->SetTitleFont(43); ratio__225->GetZaxis()->SetLabelFont(42); ratio__225->GetZaxis()->SetLabelOffset(0.007); ratio__225->GetZaxis()->SetTitleSize(0.05); ratio__225->GetZaxis()->SetTickLength(0.025); ratio__225->GetZaxis()->SetTitleFont(42); ratio__225->Draw("elp"); TH1D *zero__226 = new TH1D("zero__226","",9,-0.5,8.5); zero__226->SetBinError(2,0.00227166); zero__226->SetBinError(3,0.003368428); zero__226->SetBinError(4,0.003575241); zero__226->SetBinError(5,0.003056478); zero__226->SetBinError(6,0.002267259); zero__226->SetBinError(7,0.001455144); zero__226->SetBinError(8,0.0009013063); zero__226->SetBinError(9,0.0006407929); zero__226->SetEntries(21235); zero__226->SetStats(0); zero__226->SetLineWidth(3); zero__226->SetMarkerStyle(20); zero__226->SetMarkerSize(2); zero__226->GetXaxis()->SetTitle("N_{jet}"); zero__226->GetXaxis()->SetLabelFont(42); zero__226->GetXaxis()->SetLabelOffset(0.007); zero__226->GetXaxis()->SetTitleSize(0.05); zero__226->GetXaxis()->SetTickLength(0.025); zero__226->GetXaxis()->SetTitleFont(42); zero__226->GetYaxis()->SetTitle("a.u."); zero__226->GetYaxis()->SetLabelFont(42); zero__226->GetYaxis()->SetLabelOffset(0.007); zero__226->GetYaxis()->SetTitleSize(0.05); zero__226->GetYaxis()->SetTickLength(0.025); zero__226->GetYaxis()->SetTitleFont(42); zero__226->GetZaxis()->SetLabelFont(42); zero__226->GetZaxis()->SetLabelOffset(0.007); zero__226->GetZaxis()->SetTitleSize(0.05); zero__226->GetZaxis()->SetTickLength(0.025); zero__226->GetZaxis()->SetTitleFont(42); zero__226->Draw("hist same"); TH1D *sumratioup__227 = new TH1D("sumratioup__227","",9,-0.5,8.5); sumratioup__227->SetBinContent(2,0.02192175); sumratioup__227->SetBinContent(3,0.01129489); sumratioup__227->SetBinContent(4,0.0129073); sumratioup__227->SetBinContent(5,0.009985248); sumratioup__227->SetBinContent(6,0.01090493); sumratioup__227->SetBinContent(7,0.01354019); sumratioup__227->SetBinContent(8,0.02084612); sumratioup__227->SetBinContent(9,0.02900635); sumratioup__227->SetBinError(2,0.002522403); sumratioup__227->SetBinError(3,0.002525467); sumratioup__227->SetBinError(4,0.00336047); sumratioup__227->SetBinError(5,0.001966634); sumratioup__227->SetBinError(6,0.00127208); sumratioup__227->SetBinError(7,0.0007378717); sumratioup__227->SetBinError(8,0.0004530571); sumratioup__227->SetBinError(9,0.0003235352); sumratioup__227->SetEntries(52); sumratioup__227->SetStats(0); ci = 1198; color = new TColor(ci, 0, 0, 0, " ", 0.99); sumratioup__227->SetFillColor(ci); sumratioup__227->SetFillStyle(3003); sumratioup__227->GetXaxis()->SetTitle("N_{jet}"); sumratioup__227->GetXaxis()->SetLabelFont(42); sumratioup__227->GetXaxis()->SetLabelOffset(0.007); sumratioup__227->GetXaxis()->SetTitleSize(0.05); sumratioup__227->GetXaxis()->SetTickLength(0.025); sumratioup__227->GetXaxis()->SetTitleFont(42); sumratioup__227->GetYaxis()->SetTitle("a.u."); sumratioup__227->GetYaxis()->SetLabelFont(42); sumratioup__227->GetYaxis()->SetLabelOffset(0.007); sumratioup__227->GetYaxis()->SetTitleSize(0.05); sumratioup__227->GetYaxis()->SetTickLength(0.025); sumratioup__227->GetYaxis()->SetTitleFont(42); sumratioup__227->GetZaxis()->SetLabelFont(42); sumratioup__227->GetZaxis()->SetLabelOffset(0.007); sumratioup__227->GetZaxis()->SetTitleSize(0.05); sumratioup__227->GetZaxis()->SetTickLength(0.025); sumratioup__227->GetZaxis()->SetTitleFont(42); sumratioup__227->Draw("hist same"); TH1D *sumratiodown__228 = new TH1D("sumratiodown__228","",9,-0.5,8.5); sumratiodown__228->SetBinContent(2,-0.02192175); sumratiodown__228->SetBinContent(3,-0.01129489); sumratiodown__228->SetBinContent(4,-0.0129073); sumratiodown__228->SetBinContent(5,-0.009985248); sumratiodown__228->SetBinContent(6,-0.01090493); sumratiodown__228->SetBinContent(7,-0.01354019); sumratiodown__228->SetBinContent(8,-0.02084612); sumratiodown__228->SetBinContent(9,-0.02900635); sumratiodown__228->SetBinError(2,0.002522403); sumratiodown__228->SetBinError(3,0.002525467); sumratiodown__228->SetBinError(4,0.00336047); sumratiodown__228->SetBinError(5,0.001966634); sumratiodown__228->SetBinError(6,0.00127208); sumratiodown__228->SetBinError(7,0.0007378717); sumratiodown__228->SetBinError(8,0.0004530571); sumratiodown__228->SetBinError(9,0.0003235352); sumratiodown__228->SetEntries(52); sumratiodown__228->SetStats(0); ci = 1198; color = new TColor(ci, 0, 0, 0, " ", 0.99); sumratiodown__228->SetFillColor(ci); sumratiodown__228->SetFillStyle(3003); sumratiodown__228->GetXaxis()->SetTitle("N_{jet}"); sumratiodown__228->GetXaxis()->SetLabelFont(42); sumratiodown__228->GetXaxis()->SetLabelOffset(0.007); sumratiodown__228->GetXaxis()->SetTitleSize(0.05); sumratiodown__228->GetXaxis()->SetTickLength(0.025); sumratiodown__228->GetXaxis()->SetTitleFont(42); sumratiodown__228->GetYaxis()->SetTitle("a.u."); sumratiodown__228->GetYaxis()->SetLabelFont(42); sumratiodown__228->GetYaxis()->SetLabelOffset(0.007); sumratiodown__228->GetYaxis()->SetTitleSize(0.05); sumratiodown__228->GetYaxis()->SetTickLength(0.025); sumratiodown__228->GetYaxis()->SetTitleFont(42); sumratiodown__228->GetZaxis()->SetLabelFont(42); sumratiodown__228->GetZaxis()->SetLabelOffset(0.007); sumratiodown__228->GetZaxis()->SetTitleSize(0.05); sumratiodown__228->GetZaxis()->SetTickLength(0.025); sumratiodown__228->GetZaxis()->SetTitleFont(42); sumratiodown__228->Draw("hist same"); Double_t Graph0_fx1019[9] = { 0, 1, 2, 3, 4, 5, 6, 7, 8}; Double_t Graph0_fy1019[9] = { -999, -0.04804683, 0.07711744, 0.0421114, 0.006806612, -0.06463963, -0.1752464, -0.2066128, -0.2185969}; Double_t Graph0_fex1019[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0}; Double_t Graph0_fey1019[9] = { 0, 0.01974259, 0.01506495, 0.01373222, 0.01551874, 0.01943612, 0.02670239, 0.04147102, 0.0574499}; TGraphErrors *gre = new TGraphErrors(9,Graph0_fx1019,Graph0_fy1019,Graph0_fex1019,Graph0_fey1019); gre->SetName("Graph0"); gre->SetTitle("Graph"); gre->SetFillColor(1); gre->SetLineWidth(3); TH1F *Graph_Graph1019 = new TH1F("Graph_Graph1019","Graph",100,0,8.8); Graph_Graph1019->SetMinimum(-1098.909); Graph_Graph1019->SetMaximum(100.0014); Graph_Graph1019->SetDirectory(0); Graph_Graph1019->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph1019->SetLineColor(ci); Graph_Graph1019->GetXaxis()->SetLabelFont(42); Graph_Graph1019->GetXaxis()->SetLabelOffset(0.007); Graph_Graph1019->GetXaxis()->SetTitleSize(0.05); Graph_Graph1019->GetXaxis()->SetTickLength(0.025); Graph_Graph1019->GetXaxis()->SetTitleFont(42); Graph_Graph1019->GetYaxis()->SetLabelFont(42); Graph_Graph1019->GetYaxis()->SetLabelOffset(0.007); Graph_Graph1019->GetYaxis()->SetTitleSize(0.05); Graph_Graph1019->GetYaxis()->SetTickLength(0.025); Graph_Graph1019->GetYaxis()->SetTitleFont(42); Graph_Graph1019->GetZaxis()->SetLabelFont(42); Graph_Graph1019->GetZaxis()->SetLabelOffset(0.007); Graph_Graph1019->GetZaxis()->SetTitleSize(0.05); Graph_Graph1019->GetZaxis()->SetTickLength(0.025); Graph_Graph1019->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1019); gre->Draw("pe0"); pad2->Modified(); c1->cd(); c1->Modified(); c1->cd(); c1->SetSelected(c1); }
void AccTimesEff::Loop() { TStopwatch timer; timer.Start(); // parameters ///////////////////////////////////////////////////////////// vector<TString> files; files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-500_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9999ev.root"); files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-750_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_10000ev.root"); files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-1000_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9998ev.root"); files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-1250_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9998ev.root"); files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-1500_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9997ev.root"); files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-1750_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9997ev.root"); files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-2000_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9999ev.root"); files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-2500_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9999ev.root"); files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-3000_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_10000ev.root"); files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-3500_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9898ev.root"); files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-4000_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9998ev.root"); files.push_back("file:////user/treis/mcsamples/ZprimeToEMu_M-5000_noAccCuts_TuneZ2star_8TeV_madgraph_treis-Summer12_DR53X_PU_S10_START53_V7C1-v1_9966ev.root"); string outfileName = "accTimesEffHistos"; // output file formats const bool saveSpec = 0; const bool saveAsPdf = 0; const bool saveAsPng = 1; const bool saveAsRoot = 0; TString plotDir = "./plots/"; int font = 42; //62 // selection cuts ///////////////////////////////////////////////////////// float elePtCut = 35.; float muPtCut = 35.; float minInvMass = 0.; TH1::SetDefaultSumw2(kTRUE); /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// TH1F *hGenEvts = new TH1F("hGenEvts", "hGenEvts", 145, 0., 5010.); hGenEvts->GetXaxis()->SetTitle("M_{Z'}^{truth}"); hGenEvts->GetXaxis()->SetTitleFont(font); hGenEvts->GetXaxis()->SetLabelFont(font); hGenEvts->GetYaxis()->SetTitle("Events"); hGenEvts->GetYaxis()->SetTitleFont(font); hGenEvts->GetYaxis()->SetLabelFont(font); hGenEvts->GetYaxis()->SetTitleOffset(1.2); hGenEvts->SetLineColor(kBlack); hGenEvts->SetLineWidth(2); hGenEvts->SetMarkerStyle(20); hGenEvts->SetMarkerColor(kBlack); TH1F *hGenEvtsEleInAcc = (TH1F*)hGenEvts->Clone("hGenEvtsEleInAcc"); TH1F *hGenEvtsEleInAccEB = (TH1F*)hGenEvts->Clone("hGenEvtsEleInAccEB"); TH1F *hGenEvtsEleInAccEE = (TH1F*)hGenEvts->Clone("hGenEvtsEleInAccEE"); TH1F *hGenEvtsMuInAcc = (TH1F*)hGenEvts->Clone("hGenEvtsMuInAcc"); TH1F *hGenEvtsInAcc = (TH1F*)hGenEvts->Clone("hGenEvtsInAcc"); TH1F *hTrgEvts = (TH1F*)hGenEvts->Clone("hTrgEvts"); hTrgEvts->SetTitle("hTrgEvts"); TH1F *hRecoEvts = (TH1F*)hGenEvts->Clone("hRecoEvts"); hRecoEvts->SetTitle("hRecoEvts"); TH1F *hRecoEvtsEB = (TH1F*)hRecoEvts->Clone("hRecoEvtsEB"); TH1F *hRecoEvtsEE = (TH1F*)hRecoEvts->Clone("hRecoEvtsEE"); TH1F *hRecoEleEvts = (TH1F*)hRecoEvts->Clone("hRecoEleEvts"); TH1F *hRecoEleEvtsEB = (TH1F*)hRecoEvts->Clone("hRecoEleEvtsEB"); TH1F *hRecoEleEvtsEE = (TH1F*)hRecoEvts->Clone("hRecoEleEvtsEE"); TH1F *hRecoMuEvts = (TH1F*)hRecoEvts->Clone("hRecoMuEvts"); TH1F *hRecoNoTrgEvts = (TH1F*)hGenEvts->Clone("hRecoNoTrgEvts"); hRecoNoTrgEvts->SetTitle("hRecoNoTrgEvts"); TH1F *hRecoNoTrgEvtsEB = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgEvtsEB"); TH1F *hRecoNoTrgEvtsEE = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgEvtsEE"); TH1F *hRecoNoTrgEleEvts = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgEleEvts"); TH1F *hRecoNoTrgEleEvtsEB = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgEleEvtsEB"); TH1F *hRecoNoTrgEleEvtsEE = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgEleEvtsEE"); TH1F *hRecoNoTrgMuEvts = (TH1F*)hRecoNoTrgEvts->Clone("hRecoNoTrgMuEvts"); TH1F* hAcc; TH1F* hAccEle; TH1F* hAccEleEB; TH1F* hAccEleEE; TH1F* hAccMu; TH1F* hAccTimesTrgEff; TH1F* hTrgEff; TH1F* hAccTimesEff; TH1F* hAccTimesEffEB; TH1F* hAccTimesEffEE; TH1F* hAccTimesEffEle; TH1F* hAccTimesEffEleEB; TH1F* hAccTimesEffEleEE; TH1F* hAccTimesEffMu; TH1F* hAccTimesEffNoTrg; //TH1F* hAccTimesEffNoTrgEB; //TH1F* hAccTimesEffNoTrgEE; TH1F* hAccTimesEffNoTrgEle; TH1F* hAccTimesEffNoTrgEleEB; TH1F* hAccTimesEffNoTrgEleEE; TH1F* hAccTimesEffNoTrgMu; TH1F* hEffAftTrg; TH1F* hEffAftTrgEle; TH1F* hEffAftTrgEleEB; TH1F* hEffAftTrgEleEE; TH1F* hEffAftTrgMu; TH1F* hTrgRecoVsReco; //TH1F* hTrgRecoVsRecoEB; //TH1F* hTrgRecoVsRecoEE; TH1F* hTrgRecoVsRecoEle; TH1F* hTrgRecoVsRecoEleEB; TH1F* hTrgRecoVsRecoEleEE; TH1F* hTrgRecoVsRecoMu; // output file stringstream ssOutfile; ssOutfile << outfileName << ".root"; TFile *output = new TFile(ssOutfile.str().c_str(), "recreate"); /////////////////////////////////////////////////////////////////////////// //LOOP OVER FILES /////////////////////////////////////////////////////////////////////////// for (unsigned int p = 0; p < files.size(); ++p) { TFile* input = new TFile(files[p]); TTree *thetree = (TTree*)input->Get("gsfcheckerjob/tree"); Init(thetree); Long64_t nentries = fChain->GetEntriesFast(); cout << nentries << " events" << endl; unsigned int evCounter = 0; ///////////////////////////////////////////////////////////////////////////////////////////// //LOOP OVER EVENTS ///////////////////////////////////////////////////////////////////////////////////////////// //nentries = 10000; for (Long64_t jentry = 0; jentry < nentries; ++jentry) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; fChain->GetEntry(jentry); // if (Cut(ientry) < 0) continue; //if (jentry % 50000 == 0) cout << "Processing event " << jentry << endl; thetree->GetEntry(jentry); // fill the gen histograms hGenEvts->Fill(genelemom_mass[0]); // fill the acc histograms if (hardGenEle_pt[0] > elePtCut) { if (fabs(hardGenEle_eta[0]) < 1.442) { hGenEvtsEleInAcc->Fill(genelemom_mass[0]); hGenEvtsEleInAccEB->Fill(genelemom_mass[0]); } else if (fabs(hardGenEle_eta[0]) > 1.56 && fabs(hardGenEle_eta[0]) < 2.5) { hGenEvtsEleInAcc->Fill(genelemom_mass[0]); hGenEvtsEleInAccEE->Fill(genelemom_mass[0]); } } if (hardGenMu_pt[0] > muPtCut && fabs(hardGenMu_eta[0]) < 2.4) { hGenEvtsMuInAcc->Fill(genelemom_mass[0]); if (fabs(hardGenEle_eta[0]) < 1.442 || (fabs(hardGenEle_eta[0]) > 1.56 && fabs(hardGenEle_eta[0]) < 2.5)) { if (hardGenEle_pt[0] > elePtCut) hGenEvtsInAcc->Fill(genelemom_mass[0]); } } // trigger? if (HLT_Mu22_Photon22_CaloIdL) hTrgEvts->Fill(genelemom_mass[0]); // at least one gsf electron and one muon above the threshold if (gsf_size < 1 || muon_size < 1) continue; vector<int> GSF_passHEEP; vector<int> MU_passGOOD; ///////////////////////////////////////////////////////////////////////////////////////////// //loop over electrons for (int j = 0; j < gsf_size; ++j) { //cleaning: fake electrons from muons bool fakeEle = false; for (int k = 0; k < muon_size; ++k) { float DeltaR = deltaR(gsf_eta[j], gsf_phi[j], muon_eta[k], muon_phi[k]); if (DeltaR < 0.1) { fakeEle = true; break; } } if (fakeEle) continue; if (PassHEEP(j)) GSF_passHEEP.push_back(j); } //loop over muons for (int j = 0; j < muon_size; ++j) { if (PassHighPtMu(j)) MU_passGOOD.push_back(j); } if (GSF_passHEEP.size() == 1) { if (HLT_Mu22_Photon22_CaloIdL) { hRecoEleEvts->Fill(genelemom_mass[0]); if (fabs(gsfsc_eta[GSF_passHEEP[0]]) < 1.5) hRecoEleEvtsEB->Fill(genelemom_mass[0]); if (fabs(gsfsc_eta[GSF_passHEEP[0]]) > 1.5) hRecoEleEvtsEE->Fill(genelemom_mass[0]); } hRecoNoTrgEleEvts->Fill(genelemom_mass[0]); if (fabs(gsfsc_eta[GSF_passHEEP[0]]) < 1.5) hRecoNoTrgEleEvtsEB->Fill(genelemom_mass[0]); if (fabs(gsfsc_eta[GSF_passHEEP[0]]) > 1.5) hRecoNoTrgEleEvtsEE->Fill(genelemom_mass[0]); } if (MU_passGOOD.size() == 1) { if (HLT_Mu22_Photon22_CaloIdL) hRecoMuEvts->Fill(genelemom_mass[0]); hRecoNoTrgMuEvts->Fill(genelemom_mass[0]); } // veto when there are more than one good candidates if (GSF_passHEEP.size() != 1 || MU_passGOOD.size() != 1) continue; //HEEP ele + GOOD muon TLorentzVector ele1; TLorentzVector mu1; ele1.SetPtEtaPhiM(gsf_gsfet[GSF_passHEEP[0]], gsf_eta[GSF_passHEEP[0]], gsf_phi[GSF_passHEEP[0]], 0.000511); mu1.SetPtEtaPhiM(muon_pt[MU_passGOOD[0]], muon_eta[MU_passGOOD[0]], muon_phi[MU_passGOOD[0]], 0.10566); double invMass = (ele1 + mu1).M(); //MASS CUT if (invMass < minInvMass) continue; if (HLT_Mu22_Photon22_CaloIdL) { hRecoEvts->Fill(genelemom_mass[0]); if (fabs(gsfsc_eta[GSF_passHEEP[0]]) < 1.5) hRecoEvtsEB->Fill(genelemom_mass[0]); if (fabs(gsfsc_eta[GSF_passHEEP[0]]) > 1.5) hRecoEvtsEE->Fill(genelemom_mass[0]); } hRecoNoTrgEvts->Fill(genelemom_mass[0]); if (fabs(gsfsc_eta[GSF_passHEEP[0]]) < 1.5) hRecoNoTrgEvtsEB->Fill(genelemom_mass[0]); if (fabs(gsfsc_eta[GSF_passHEEP[0]]) > 1.5) hRecoNoTrgEvtsEE->Fill(genelemom_mass[0]); ++evCounter; /////////////////////////////////////////////////////////////////////// } //END LOOP OVER EVENTS ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// } //END LOOP OVER FILES ////////////////////////////////////////////////////////////////////////// hAcc = (TH1F*)hGenEvtsInAcc->Clone("hAcc"); hAccEle = (TH1F*)hGenEvtsEleInAcc->Clone("hAccEle"); hAccEleEB = (TH1F*)hGenEvtsEleInAccEB->Clone("hAccEleEB"); hAccEleEE = (TH1F*)hGenEvtsEleInAccEE->Clone("hAccEleEE"); hAccMu = (TH1F*)hGenEvtsMuInAcc->Clone("hAccMu"); hAccTimesTrgEff = (TH1F*)hTrgEvts->Clone("hAccTimesTrgEff"); hTrgEff = (TH1F*)hTrgEvts->Clone("hTrgEff"); hAccTimesEff = (TH1F*)hRecoEvts->Clone("hAccTimesEff"); hAccTimesEffEB = (TH1F*)hRecoEvtsEB->Clone("hAccTimesEffEB"); hAccTimesEffEE = (TH1F*)hRecoEvtsEE->Clone("hAccTimesEffEE"); hAccTimesEffEle = (TH1F*)hRecoEleEvts->Clone("hAccTimesEffEle"); hAccTimesEffEleEB = (TH1F*)hRecoEleEvtsEB->Clone("hAccTimesEffEleEB"); hAccTimesEffEleEE = (TH1F*)hRecoEleEvtsEE->Clone("hAccTimesEffEleEE"); hAccTimesEffMu = (TH1F*)hRecoMuEvts->Clone("hAccTimesEffMu"); hAccTimesEffNoTrg = (TH1F*)hRecoNoTrgEvts->Clone("hAccTimesEffNoTrg"); //hAccTimesEffNoTrgEB = (TH1F*)hRecoNoTrgEvtsEB->Clone("hAccTimesEffNoTrgEB"); //hAccTimesEffNoTrgEE = (TH1F*)hRecoNoTrgEvtsEE->Clone("hAccTimesEffNoTrgEE"); hAccTimesEffNoTrgEle = (TH1F*)hRecoNoTrgEleEvts->Clone("hAccTimesEffNoTrgEle"); hAccTimesEffNoTrgEleEB = (TH1F*)hRecoNoTrgEleEvtsEB->Clone("hAccTimesEffNoTrgEleEB"); hAccTimesEffNoTrgEleEE = (TH1F*)hRecoNoTrgEleEvtsEE->Clone("hAccTimesEffNoTrgEleEE"); hAccTimesEffNoTrgMu = (TH1F*)hRecoNoTrgMuEvts->Clone("hAccTimesEffNoTrgMu"); hEffAftTrg = (TH1F*)hRecoEvts->Clone("hAccTimesEff"); hEffAftTrgEle = (TH1F*)hRecoEleEvts->Clone("hAccTimesEffEle"); hEffAftTrgEleEB = (TH1F*)hRecoEleEvtsEB->Clone("hAccTimesEffEleEB"); hEffAftTrgEleEE = (TH1F*)hRecoEleEvtsEE->Clone("hAccTimesEffEleEE"); hEffAftTrgMu = (TH1F*)hRecoMuEvts->Clone("hAccTimesEffMu"); hTrgRecoVsReco = (TH1F*)hRecoEvts->Clone("hTrgRecoVsReco"); //hTrgRecoVsRecoEB = (TH1F*)hRecoEvtsEB->Clone("hTrgRecoVsRecoEB"); //hTrgRecoVsRecoEE = (TH1F*)hRecoEvtsEE->Clone("hTrgRecoVsRecoEE"); hTrgRecoVsRecoEle = (TH1F*)hRecoEleEvts->Clone("hTrgRecoVsRecoEle"); hTrgRecoVsRecoEleEB = (TH1F*)hRecoEleEvtsEB->Clone("hTrgRecoVsRecoEleEB"); hTrgRecoVsRecoEleEE = (TH1F*)hRecoEleEvtsEE->Clone("hTrgRecoVsRecoEleEE"); hTrgRecoVsRecoMu = (TH1F*)hRecoMuEvts->Clone("hTrgRecoVsRecoMu"); hAcc->Divide(hGenEvts); hAccEle->Divide(hGenEvts); hAccEleEB->Divide(hGenEvts); hAccEleEE->Divide(hGenEvts); hAccMu->Divide(hGenEvts); hAccTimesTrgEff->Divide(hGenEvts); hTrgEff->Divide(hGenEvtsInAcc); hAccTimesEff->Divide(hGenEvts); hAccTimesEffEB->Divide(hGenEvts); hAccTimesEffEE->Divide(hGenEvts); hAccTimesEffEle->Divide(hGenEvts); hAccTimesEffEleEB->Divide(hGenEvts); hAccTimesEffEleEE->Divide(hGenEvts); hAccTimesEffMu->Divide(hGenEvts); hAccTimesEffNoTrg->Divide(hGenEvts); //hAccTimesEffNoTrgEB->Divide(hGenEvts); //hAccTimesEffNoTrgEE->Divide(hGenEvts); hAccTimesEffNoTrgEle->Divide(hGenEvts); hAccTimesEffNoTrgEleEB->Divide(hGenEvts); hAccTimesEffNoTrgEleEE->Divide(hGenEvts); hAccTimesEffNoTrgMu->Divide(hGenEvts); hEffAftTrg->Divide(hTrgEvts); hEffAftTrgEle->Divide(hTrgEvts); hEffAftTrgEleEB->Divide(hTrgEvts); hEffAftTrgEleEE->Divide(hTrgEvts); hEffAftTrgMu->Divide(hTrgEvts); hTrgRecoVsReco->Divide(hRecoNoTrgEvts); //hTrgRecoVsRecoEB->Divide(hRecoNoTrgEvtsEB); //hTrgRecoVsRecoEE->Divide(hRecoNoTrgEvtsEE); hTrgRecoVsRecoEle->Divide(hRecoNoTrgEleEvts); hTrgRecoVsRecoEleEB->Divide(hRecoNoTrgEleEvtsEB); hTrgRecoVsRecoEleEE->Divide(hRecoNoTrgEleEvtsEE); hTrgRecoVsRecoMu->Divide(hRecoNoTrgMuEvts); // plot TCanvas *accTimesEffPlot = new TCanvas("accTimesEffPlot", "acc x eff", 100, 100, 600, 600); TPad *accTimesEffPad = new TPad("accTimesEffPad", "acc x eff pad", 0., 0., 1., 1.); accTimesEffPad->SetBottomMargin(0.12); accTimesEffPad->SetBorderMode(0); accTimesEffPad->SetBorderSize(2); accTimesEffPad->SetFrameBorderMode(0); accTimesEffPad->SetFillColor(0); accTimesEffPad->SetFrameFillColor(0); accTimesEffPad->SetLeftMargin(0.11); accTimesEffPad->SetRightMargin(0.09); accTimesEffPad->SetTopMargin(0.08); accTimesEffPad->SetTickx(1); accTimesEffPad->SetTicky(1); accTimesEffPad->Draw(); accTimesEffPad->cd(); gStyle->SetTitleFont(font); gStyle->SetLabelFont(font); gStyle->SetLegendFont(font); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); gStyle->SetOptFit(1111); gStyle->SetTitleXOffset(1.); gStyle->SetTitleYOffset(1.3); gPad->SetTicks(1, 1); gPad->SetGrid(1, 1); TH1F* hAccTimesEff2 = (TH1F*)hAccTimesEff->Clone("hAccTimesEff2"); TF1 *fitFunc = new TF1("fitFunc", "[0] + [1]/ (x + [2]) + [3]*x", 10., 5010.); //TF1 *fitFuncEB = new TF1("fitFuncEB", "[0] + [1]/ (x + [2])", 10., 5010.); TF1 *fitFuncEB = new TF1("fitFuncEB", "[0] + [1]/ (x + [2]) + [3]*x", 10., 5010.); TF1 *fitFuncEE = new TF1("fitFuncEE", "[0] + [1]/ (x*x + [2])", 10., 5010.); fitFunc->SetLineColor(kBlue); fitFuncEB->SetLineColor(kBlue); fitFuncEE->SetLineColor(kBlue); hAccTimesEff->Fit("fitFunc", "", "", 480., 5010.); hAccTimesEffEB->Fit("fitFuncEB", "", "", 480., 5010.); hAccTimesEffEE->Fit("fitFuncEE", "", "", 480., 5010.); cout << "Chi^2 / NDF: " << fitFunc->GetChisquare() << " / " << fitFunc->GetNDF() << ", prob: " << fitFunc->GetProb() << endl; cout << "Chi^2 / NDF EB: " << fitFuncEB->GetChisquare() << " / " << fitFuncEB->GetNDF() << ", prob: " << fitFuncEB->GetProb() << endl; cout << "Chi^2 / NDF EE: " << fitFuncEE->GetChisquare() << " / " << fitFuncEE->GetNDF() << ", prob: " << fitFuncEE->GetProb() << endl; hAccTimesEff->GetYaxis()->SetTitle("acc x eff"); hAccTimesEff->GetYaxis()->SetRangeUser(0., 1.); hAccTimesEff->Draw(); TLatex *tex = new TLatex(0.22, 0.21, "P(M|p0,p1,p2,p3) = p0 + #frac{p1}{M+p2} + p3*M"); tex->SetNDC(); tex->SetTextFont(font); tex->SetLineWidth(2); tex->SetTextSize(0.03); tex->Draw(); tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV"); tex->DrawLatex(0.17, 0.85, "trg + electron + muon"); TCanvas *accTimesEffPlotEB = new TCanvas("accTimesEffPlotEB", "acc x eff, barrel electron + muon", 100, 100, 600, 600); TPad *accTimesEffPadEB = (TPad*)accTimesEffPad->Clone("accTimesEffPadEB"); accTimesEffPadEB->Draw(); accTimesEffPadEB->cd(); hAccTimesEffEB->GetYaxis()->SetTitle("acc x eff"); hAccTimesEffEB->GetYaxis()->SetRangeUser(0., 1.); hAccTimesEffEB->Draw(); tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV"); //tex->DrawLatex(0.46, 0.21, "P(M|p0,p1,p2) = p0 + #frac{p1}{M+p2}"); tex->DrawLatex(0.22, 0.21, "P(M|p0,p1,p2,p3) = p0 + #frac{p1}{M+p2} + p3*M"); tex->DrawLatex(0.17, 0.85, "trg + barrel electron + muon"); TCanvas *accTimesEffPlotEE = new TCanvas("accTimesEffPlotEE", "acc x eff, endcap electron + muon", 100, 100, 600, 600); TPad *accTimesEffPadEE = (TPad*)accTimesEffPad->Clone("accTimesEffPadEE"); accTimesEffPadEE->Draw(); accTimesEffPadEE->cd(); hAccTimesEffEE->GetYaxis()->SetTitle("acc x eff"); hAccTimesEffEE->GetYaxis()->SetRangeUser(0., 1.); hAccTimesEffEE->Draw(); tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV"); tex->DrawLatex(0.45, 0.38, "P(M|p0,p1,p2) = p0 + #frac{p1}{M^{2}+p2}"); tex->DrawLatex(0.17, 0.85, "trg + endcap electron + muon"); TCanvas *accTimesEffObjPlot = new TCanvas("accTimesEffObjPlot", "acc x eff, objects", 100, 100, 600, 600); TPad *accTimesEffObjPad = (TPad*)accTimesEffPad->Clone("accTimesEffObjPad"); accTimesEffObjPad->Draw(); accTimesEffObjPad->cd(); hAccTimesEffEle->GetYaxis()->SetTitle("acc x eff"); hAccTimesEffEle->GetYaxis()->SetRangeUser(0., 1.); hAccTimesEffEle->SetMarkerStyle(kFullSquare); hAccTimesEffEle->SetMarkerColor(kViolet); hAccTimesEffEle->SetLineColor(kViolet); hAccTimesEffEle->Draw(); hAccTimesEffEleEB->SetMarkerStyle(kFullTriangleUp); hAccTimesEffEleEB->SetMarkerColor(kRed); hAccTimesEffEleEB->SetLineColor(kRed); hAccTimesEffEleEB->Draw("same"); hAccTimesEffEleEE->SetMarkerStyle(kFullTriangleDown); hAccTimesEffEleEE->SetMarkerColor(kBlue); hAccTimesEffEleEE->SetLineColor(kBlue); hAccTimesEffEleEE->Draw("same"); hAccTimesEffMu->SetMarkerStyle(34); hAccTimesEffMu->SetMarkerColor(kGreen+1); hAccTimesEffMu->SetLineColor(kGreen+1); hAccTimesEffMu->Draw("same"); hAccTimesEff2->Draw("same"); TLegend* legend = new TLegend(0.592, 0.279, 0.881, 0.467); legend->SetTextFont(font); legend->SetTextSize(0.03); legend->SetBorderSize(0); legend->SetLineColor(1); legend->SetLineStyle(1); legend->SetLineWidth(1); legend->SetFillColor(19); legend->SetFillStyle(0); legend->AddEntry(hAccTimesEff, "total acc x eff"); legend->AddEntry(hAccTimesEffMu, "muons"); legend->AddEntry(hAccTimesEffEle, "all electrons"); legend->AddEntry(hAccTimesEffEleEB, "barrel electrons"); legend->AddEntry(hAccTimesEffEleEE, "endcap electrons"); legend->Draw("same"); tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV"); tex->DrawLatex(0.17, 0.85, "trg: HLT_Mu22_Photon22_CaloIdL"); // acc x eff with no trg applied TCanvas *accTimesEffNoTrgObjPlot = new TCanvas("accTimesEffNoTrgObjPlot", "acc x eff, no trigger, objects", 100, 100, 600, 600); TPad *accTimesEffNoTrgObjPad = (TPad*)accTimesEffPad->Clone("accTimesEffNoTrgObjPad"); accTimesEffNoTrgObjPad->Draw(); accTimesEffNoTrgObjPad->cd(); hAccTimesEffNoTrgEle->GetYaxis()->SetTitle("acc x eff"); hAccTimesEffNoTrgEle->GetYaxis()->SetRangeUser(0., 1.); hAccTimesEffNoTrgEle->SetMarkerStyle(kFullSquare); hAccTimesEffNoTrgEle->SetMarkerColor(kViolet); hAccTimesEffNoTrgEle->SetLineColor(kViolet); hAccTimesEffNoTrgEle->Draw(); hAccTimesEffNoTrgEleEB->SetMarkerStyle(kFullTriangleUp); hAccTimesEffNoTrgEleEB->SetMarkerColor(kRed); hAccTimesEffNoTrgEleEB->SetLineColor(kRed); hAccTimesEffNoTrgEleEB->Draw("same"); hAccTimesEffNoTrgEleEE->SetMarkerStyle(kFullTriangleDown); hAccTimesEffNoTrgEleEE->SetMarkerColor(kBlue); hAccTimesEffNoTrgEleEE->SetLineColor(kBlue); hAccTimesEffNoTrgEleEE->Draw("same"); hAccTimesEffNoTrgMu->SetMarkerStyle(34); hAccTimesEffNoTrgMu->SetMarkerColor(kGreen+1); hAccTimesEffNoTrgMu->SetLineColor(kGreen+1); hAccTimesEffNoTrgMu->Draw("same"); hAccTimesEffNoTrg->Draw("same"); TLegend* accXeffNoTrg = (TLegend*)legend->Clone("effAftTrgLegend"); accXeffNoTrg->Clear(); accXeffNoTrg->AddEntry(hAccTimesEffNoTrg, "total acc x eff"); accXeffNoTrg->AddEntry(hAccTimesEffNoTrgMu, "muons"); accXeffNoTrg->AddEntry(hAccTimesEffNoTrgEle, "all electrons"); accXeffNoTrg->AddEntry(hAccTimesEffNoTrgEleEB, "barrel electrons"); accXeffNoTrg->AddEntry(hAccTimesEffNoTrgEleEE, "endcap electrons"); accXeffNoTrg->Draw("same"); tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV"); tex->DrawLatex(0.17, 0.85, "trg: none"); // efficiency on triggered events TCanvas *effAftTrgPlot = new TCanvas("effAftTrgPlot", "efficiency after trigger", 100, 100, 600, 600); TPad *effAftTrgPad = (TPad*)accTimesEffPad->Clone("effAftTrgPad"); effAftTrgPad->Draw(); effAftTrgPad->cd(); hEffAftTrgEle->GetYaxis()->SetTitle("eff"); hEffAftTrgEle->GetYaxis()->SetRangeUser(0., 1.); hEffAftTrgEle->SetMarkerStyle(kFullSquare); hEffAftTrgEle->SetMarkerColor(kViolet); hEffAftTrgEle->SetLineColor(kViolet); hEffAftTrgEle->Draw(); hEffAftTrgEleEB->SetMarkerStyle(kFullTriangleUp); hEffAftTrgEleEB->SetMarkerColor(kRed); hEffAftTrgEleEB->SetLineColor(kRed); hEffAftTrgEleEB->Draw("same"); hEffAftTrgEleEE->SetMarkerStyle(kFullTriangleDown); hEffAftTrgEleEE->SetMarkerColor(kBlue); hEffAftTrgEleEE->SetLineColor(kBlue); hEffAftTrgEleEE->Draw("same"); hEffAftTrgMu->SetMarkerStyle(34); hEffAftTrgMu->SetMarkerColor(kGreen+1); hEffAftTrgMu->SetLineColor(kGreen+1); hEffAftTrgMu->Draw("same"); hEffAftTrg->Draw("same"); TLegend* effAftTrgLegend = (TLegend*)legend->Clone("effAftTrgLegend"); effAftTrgLegend->Clear(); effAftTrgLegend->AddEntry(hEffAftTrg, "total eff after trigger"); effAftTrgLegend->AddEntry(hEffAftTrgMu, "muons"); effAftTrgLegend->AddEntry(hEffAftTrgEle, "all electrons"); effAftTrgLegend->AddEntry(hEffAftTrgEleEB, "barrel electrons"); effAftTrgLegend->AddEntry(hEffAftTrgEleEE, "endcap electrons"); effAftTrgLegend->Draw("same"); tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV"); tex->DrawLatex(0.14, 0.15, "trg: HLT_Mu22_Photon22_CaloIdL"); // acceptance TCanvas *accPlot = new TCanvas("accPlot", "acc", 100, 100, 600, 600); TPad *accPad = (TPad*)accTimesEffPad->Clone("accPad"); accPad->Draw(); accPad->cd(); hAcc->GetYaxis()->SetTitle("acc"); hAcc->GetYaxis()->SetRangeUser(0., 1.); hAccEle->SetMarkerStyle(kFullSquare); hAccEle->SetMarkerColor(kViolet); hAccEle->SetLineColor(kViolet); hAccEle->Draw(); hAccEleEB->SetMarkerStyle(kFullTriangleUp); hAccEleEB->SetMarkerColor(kRed); hAccEleEB->SetLineColor(kRed); hAccEleEB->Draw("same"); hAccEleEE->SetMarkerStyle(kFullTriangleDown); hAccEleEE->SetMarkerColor(kBlue); hAccEleEE->SetLineColor(kBlue); hAccEleEE->Draw("same"); hAccMu->SetMarkerStyle(34); hAccMu->SetMarkerColor(kGreen+1); hAccMu->SetLineColor(kGreen+1); hAccMu->Draw("same"); hAcc->Draw("same"); TLegend* accLegend = (TLegend*)legend->Clone("accLegend"); accLegend->Clear(); accLegend->AddEntry(hAcc, "total acceptance"); accLegend->AddEntry(hAccMu, "muons"); accLegend->AddEntry(hAccEle, "all electrons"); accLegend->AddEntry(hAccEleEB, "barrel electrons"); accLegend->AddEntry(hAccEleEE, "endcap electrons"); accLegend->Draw("same"); tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV"); // reco with trg vs. reco TCanvas *trgRecoVsRecoPlot = new TCanvas("trgRecoVsRecoPlot", "reco with trg vs. reco", 100, 100, 600, 600); TPad *trgRecoVsRecoPad = (TPad*)accTimesEffPad->Clone("trgRecoVsRecoPad"); trgRecoVsRecoPad->Draw(); trgRecoVsRecoPad->cd(); hTrgRecoVsRecoEle->GetYaxis()->SetTitle("eff"); hTrgRecoVsRecoEle->GetYaxis()->SetRangeUser(0., 1.); hTrgRecoVsRecoEle->SetMarkerStyle(kFullSquare); hTrgRecoVsRecoEle->SetMarkerColor(kViolet); hTrgRecoVsRecoEle->SetLineColor(kViolet); hTrgRecoVsRecoEle->Draw(); //hTrgRecoVsRecoEleEB->SetMarkerStyle(kFullTriangleUp); //hTrgRecoVsRecoEleEB->SetMarkerColor(kRed); //hTrgRecoVsRecoEleEB->SetLineColor(kRed); //hTrgRecoVsRecoEleEB->Draw("same"); //hTrgRecoVsRecoEleEE->SetMarkerStyle(kFullTriangleDown); //hTrgRecoVsRecoEleEE->SetMarkerColor(kBlue); //hTrgRecoVsRecoEleEE->SetLineColor(kBlue); //hTrgRecoVsRecoEleEE->Draw("same"); hTrgRecoVsRecoMu->SetMarkerStyle(34); hTrgRecoVsRecoMu->SetMarkerColor(kGreen+1); hTrgRecoVsRecoMu->SetLineColor(kGreen+1); hTrgRecoVsRecoMu->Draw("same"); hTrgRecoVsReco->Draw("same"); TLegend* trgRecoVsRecoLegend = (TLegend*)legend->Clone("trgRecoVsRecoLegend"); trgRecoVsRecoLegend->Clear(); trgRecoVsRecoLegend->AddEntry(hTrgRecoVsReco, "total"); trgRecoVsRecoLegend->AddEntry(hTrgRecoVsRecoMu, "muons"); trgRecoVsRecoLegend->AddEntry(hTrgRecoVsRecoEle, "electrons"); //trgRecoVsRecoLegend->AddEntry(hTrgRecoVsRecoEleEB, "barrel electrons"); //trgRecoVsRecoLegend->AddEntry(hTrgRecoVsRecoEleEE, "endcap electrons"); trgRecoVsRecoLegend->Draw("same"); tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV"); TCanvas *accTimesTrgEffPlot = new TCanvas("accTimesTrgEffPlot", "acc x trigger eff", 100, 100, 600, 600); TPad *accTimesTrgEffPad = (TPad*)accTimesEffPad->Clone("accTimesTrgEffPad"); accTimesTrgEffPad->Draw(); accTimesTrgEffPad->cd(); hAccTimesTrgEff->GetYaxis()->SetTitle("acc x trg eff"); hAccTimesTrgEff->GetYaxis()->SetRangeUser(0., 1.); hAccTimesTrgEff->SetMarkerStyle(20); hAccTimesTrgEff->SetMarkerColor(kCyan); hAccTimesTrgEff->SetLineColor(kCyan); hAccTimesTrgEff->Draw(); hTrgEff->SetMarkerStyle(21); hTrgEff->SetMarkerColor(kMagenta); hTrgEff->SetLineColor(kMagenta); hTrgEff->Draw("same"); TLegend* trgLegend = (TLegend*)legend->Clone("trgLegend"); trgLegend->Clear(); trgLegend->AddEntry(hTrgEff, "trigger eff in acc"); trgLegend->AddEntry(hAccTimesTrgEff, "acc x trigger eff"); trgLegend->Draw("same"); tex->DrawLatex(0.109, 0.935, "CMS Simulation, 8 TeV"); // safe in various file formats if (saveSpec) { if (saveAsPdf) { accTimesTrgEffPlot->Print(plotDir + accTimesTrgEffPlot->GetName() + ".pdf", "pdf"); accTimesEffPlot->Print(plotDir + accTimesEffPlot->GetName() + ".pdf", "pdf"); accTimesEffPlotEB->Print(plotDir + accTimesEffPlotEB->GetName() + ".pdf", "pdf"); accTimesEffPlotEE->Print(plotDir + accTimesEffPlotEE->GetName() + ".pdf", "pdf"); accTimesEffObjPlot->Print(plotDir + accTimesEffObjPlot->GetName() + ".pdf", "pdf"); accTimesEffNoTrgObjPlot->Print(plotDir + accTimesEffNoTrgObjPlot->GetName() + ".pdf", "pdf"); effAftTrgPlot->Print(plotDir + effAftTrgPlot->GetName() + ".pdf", "pdf"); trgRecoVsRecoPlot->Print(plotDir + trgRecoVsRecoPlot->GetName() + ".pdf", "pdf"); accPlot->Print(plotDir + accPlot->GetName() + ".pdf", "pdf"); } if (saveAsPng) { accTimesTrgEffPlot->Print(plotDir + accTimesTrgEffPlot->GetName() + ".png", "png"); accTimesEffPlot->Print(plotDir + accTimesEffPlot->GetName() + ".png", "png"); accTimesEffPlotEB->Print(plotDir + accTimesEffPlotEB->GetName() + ".png", "png"); accTimesEffPlotEE->Print(plotDir + accTimesEffPlotEE->GetName() + ".png", "png"); accTimesEffObjPlot->Print(plotDir + accTimesEffObjPlot->GetName() + ".png", "png"); accTimesEffNoTrgObjPlot->Print(plotDir + accTimesEffNoTrgObjPlot->GetName() + ".png", "png"); effAftTrgPlot->Print(plotDir + effAftTrgPlot->GetName() + ".png", "png"); trgRecoVsRecoPlot->Print(plotDir + trgRecoVsRecoPlot->GetName() + ".png", "png"); accPlot->Print(plotDir + accPlot->GetName() + ".png", "png"); } if (saveAsRoot) { accTimesTrgEffPlot->Print(plotDir + accTimesTrgEffPlot->GetName() + ".root", "root"); accTimesEffPlot->Print(plotDir + accTimesEffPlot->GetName() + ".root", "root"); accTimesEffPlotEB->Print(plotDir + accTimesEffPlotEB->GetName() + ".root", "root"); accTimesEffPlotEE->Print(plotDir + accTimesEffPlotEE->GetName() + ".root", "root"); accTimesEffObjPlot->Print(plotDir + accTimesEffObjPlot->GetName() + ".root", "root"); accTimesEffNoTrgObjPlot->Print(plotDir + accTimesEffNoTrgObjPlot->GetName() + ".root", "root"); effAftTrgPlot->Print(plotDir + effAftTrgPlot->GetName() + ".root", "root"); trgRecoVsRecoPlot->Print(plotDir + trgRecoVsRecoPlot->GetName() + ".root", "root"); accPlot->Print(plotDir + accPlot->GetName() + ".root", "root"); } } // write histos to file output->cd(); hGenEvts->Write(); hGenEvtsEleInAcc->Write(); hGenEvtsEleInAccEB->Write(); hGenEvtsEleInAccEE->Write(); hGenEvtsMuInAcc->Write(); hGenEvtsInAcc->Write(); hTrgEvts->Write(); hRecoEvts->Write(); hRecoEvtsEB->Write(); hRecoEvtsEE->Write(); hRecoEleEvts->Write(); hRecoEleEvtsEB->Write(); hRecoEleEvtsEE->Write(); hRecoMuEvts->Write(); hAccEle->Write(); hAccEleEB->Write(); hAccEleEE->Write(); hAccMu->Write(); hAccTimesTrgEff->Write(); hTrgEff->Write(); hAccTimesEff->Write(); hAccTimesEffEB->Write(); hAccTimesEffEE->Write(); hAccTimesEffEle->Write(); hAccTimesEffEleEB->Write(); hAccTimesEffEleEE->Write(); hAccTimesEffMu->Write(); hEffAftTrg->Write(); hEffAftTrgEle->Write(); hEffAftTrgEleEB->Write(); hEffAftTrgEleEE->Write(); hEffAftTrgMu->Write(); fitFunc->Write(); fitFuncEB->Write(); fitFuncEE->Write(); output->Close(); timer.Stop(); timer.Print(); }
void SimpleFitter() { TFile*output=new TFile("histoX.root","read"); TH1D*h=(TH1D*)output->Get("h"); h->Sumw2(); TF1 *f = new TF1("f","[0]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2]) +[3]*Gaus(x,[4],[5])/(sqrt(2*3.14159)*[5])+[6]+[7]*x+[8]*x*x+[9]*x*x*x"); f->SetLineColor(4); f->SetParameters(21,3.68,0.0057,1.34714e+00,3.86,0.006,-2.21334e+04,1.01661e+04,-1.05364e+03,1.95474e+04); f->FixParameter(1,3.686); f->FixParameter(2,0.00357); f->FixParameter(4,3.8725); f->FixParameter(5,0.005); h->Fit("f","LL"); h->Fit("f",""); h->Fit("f","LL"); h->Fit("f","LL","",3.65,3.94); h->Fit("f","LL","",3.65,3.94); f->ReleaseParameter(1); f->ReleaseParameter(2); f->ReleaseParameter(4); f->ReleaseParameter(5); h->Fit("f","LL","",3.65,3.94); h->SetXTitle("m(J/#psi#pi^{+}#pi^{-}) [GeV]"); h->SetYTitle("Entries"); h->SetStats(0); h->SetAxisRange(0,h->GetMaximum()*1.3 ,"Y"); TF1 *f2 = new TF1("f2","[6]+[7]*x+[8]*x*x+[9]*x*x*x"); f2->SetParameter(6,f->GetParameter(6)); f2->SetParameter(7,f->GetParameter(7)); f2->SetParameter(8,f->GetParameter(8)); f2->SetParameter(9,f->GetParameter(9)); TF1 *f3 = new TF1("f3","[0]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])"); f3->SetParameter(0,f->GetParameter(0)); f3->SetParameter(1,f->GetParameter(1)); f3->SetParameter(2,f->GetParameter(2)); TF1 *f4 = new TF1("f4","[3]*Gaus(x,[4],[5])/(sqrt(2*3.14159)*[5])"); f4->SetParameter(3,f->GetParameter(3)); f4->SetParameter(4,f->GetParameter(4)); f4->SetParameter(5,f->GetParameter(5)); f->SetLineColor(4); f2->SetLineColor(4); f3->SetRange(3.65,3.94); f4->SetRange(3.65,3.94); f2->SetRange(3.65,3.94); f2->SetLineStyle(2); f3->SetLineStyle(2); f4->SetLineStyle(2); f2->Draw("same"); f3->SetLineColor(2); f3->SetFillStyle(3004); f3->SetFillColor(2); f3->Draw("same"); f4->SetLineColor(2); f4->SetFillStyle(3004); f4->SetFillColor(2); f4->Draw("same"); TLatex *l = new TLatex(3.7,70./80*h->GetMaximum(),"#psi(2S)"); l->Draw(); TLatex *l2 = new TLatex(3.875,50./80*h->GetMaximum(),"X(3872)"); l2->Draw(); TLatex *l3 = new TLatex(3.812,70./80*h->GetMaximum(),"CMS Preliminary"); l3->Draw(); TLatex *l4 = new TLatex(3.78,60./80*h->GetMaximum(),"pp #sqrt{s_{NN}}=5.02 TeV"); l4->Draw(); cout<<"********************* SIGNIFICANCE *********************"<<endl; double meanX=f4->GetParameter(4); double sigmaX=f4->GetParameter(5); double signalX=f4->Integral(meanX-3*sigmaX,meanX+3*sigmaX)/h->GetBinWidth(0); double bkgX=f2->Integral(meanX-3*sigmaX,meanX+3*sigmaX)/h->GetBinWidth(0); double signalpsi2=f4->Integral(meanX-3*sigmaX,meanX+3*sigmaX)/h->GetBinWidth(0); double bkgpsi2=f2->Integral(meanX-3*sigmaX,meanX+3*sigmaX)/h->GetBinWidth(0); double significanceX=signalX/TMath::Sqrt(signalX+bkgX); double meanpsi2=f3->GetParameter(1); double sigmapsi2=f3->GetParameter(2); double signalpsi2=f3->Integral(meanpsi2-3*sigmapsi2,meanpsi2+3*sigmapsi2)/h->GetBinWidth(0); double bkgpsi2=f2->Integral(meanpsi2-3*sigmapsi2,meanpsi2+3*sigmapsi2)/h->GetBinWidth(0); double signalpsi2=f3->Integral(meanpsi2-3*sigmapsi2,meanpsi2+3*sigmapsi2)/h->GetBinWidth(0); double bkgpsi2=f2->Integral(meanpsi2-3*sigmapsi2,meanpsi2+3*sigmapsi2)/h->GetBinWidth(0); double significancepsi2=signalpsi2/TMath::Sqrt(signalpsi2+bkgpsi2); cout<<"significance X ="<<significanceX<<endl; cout<<"significance psi(2S)="<<significancepsi2<<endl; cout<<"yield X="<<signalX<<endl; cout<<"yield 2S="<<signalpsi2<<endl; cout<<"yield X/yield 2S="<<signalX/signalpsi2<<endl; }
void drawPlot(string workspaceFilename, string inputFilename, string outFilename, Int_t EnergyType, Int_t CategoryBin, double minMass, double maxMass, double mean_bw, double gamma_bw, double cutoff_cb, double power_cb, const char* plotOpt, const int nbins) { TFile *workspaceFile = new TFile(workspaceFilename.c_str(), "read"); RooWorkspace* w = (RooWorkspace*)workspaceFile->Get("ZeeMassScaleAndResolutionFit"); //Create Data Set RooRealVar *mass = (RooRealVar*)w->var("mass"); // Reading everything from root tree instead citana::ZeeEventTree *zeeTree = new citana::ZeeEventTree(); zeeTree->LoadTree(inputFilename.c_str(), citana::ZeeEventTree::kCITZeeEvent); RooArgSet zMassArgSet(*mass); RooDataSet* data = new RooDataSet("data", "ntuple parameters", zMassArgSet); for (int i = 0; i < zeeTree->tree_->GetEntries(); i++) { zeeTree->tree_->GetEntry(i); //************************************************************************* //Electron Selection //************************************************************************* if (!(zeeTree->fEle1PassHZZICHEP2012 == 1 && zeeTree->fEle2PassHZZICHEP2012 == 1)) continue; //************************************************************************* //Compute electron four vector; //************************************************************************* double ele1pt = zeeTree->fEle1Pt; double ele2pt = zeeTree->fEle2Pt; if (EnergyType == 1) { ele1pt = zeeTree->fEle1EnergyRegressionWithTrkVarTwoPtBins / TMath::CosH(zeeTree->fEle1Eta); ele2pt = zeeTree->fEle2EnergyRegressionWithTrkVarTwoPtBins / TMath::CosH(zeeTree->fEle2Eta); } else if (EnergyType == 2) { ele1pt = zeeTree->fEle1EnergyRegressionWithTrkVar / TMath::CosH(zeeTree->fEle1Eta); ele2pt = zeeTree->fEle2EnergyRegressionWithTrkVar / TMath::CosH(zeeTree->fEle2Eta); } else if (EnergyType == 3) { ele1pt = zeeTree->fEle1EnergyRegressionNoTrkVarTwoPtBins / TMath::CosH(zeeTree->fEle1Eta); ele2pt = zeeTree->fEle2EnergyRegressionNoTrkVarTwoPtBins / TMath::CosH(zeeTree->fEle2Eta); } else if (EnergyType == 4) { ele1pt = zeeTree->fEle1EnergyRegressionNoTrkVar / TMath::CosH(zeeTree->fEle1Eta); ele2pt = zeeTree->fEle2EnergyRegressionNoTrkVar / TMath::CosH(zeeTree->fEle2Eta); } TLorentzVector ele1FourVector; ele1FourVector.SetPtEtaPhiM(ele1pt, zeeTree->fEle1Eta, zeeTree->fEle1Phi, ELECTRONMASS); TLorentzVector ele2FourVector; ele2FourVector.SetPtEtaPhiM(ele2pt, zeeTree->fEle2Eta, zeeTree->fEle2Phi, ELECTRONMASS); //************************************************************************* //pt and eta cuts on electron //************************************************************************* if (! (ele1pt > 7 && ele2pt > 7 && fabs( zeeTree->fEle1Eta) < 2.5 && fabs( zeeTree->fEle2Eta) < 2.5 )) continue; //************************************************************************* //pt bins and eta bins //************************************************************************* Int_t Ele1PtBin = -1; Int_t Ele1EtaBin = -1; Int_t Ele2PtBin = -1; Int_t Ele2EtaBin = -1; if (ele1pt > 10 && ele1pt < 20) Ele1PtBin = 0; else if (ele1pt < 30) Ele1PtBin = 1; else if (ele1pt < 40) Ele1PtBin = 2; else Ele1PtBin = 3; if (ele2pt > 10 && ele2pt < 20) Ele2PtBin = 0; else if (ele2pt < 30) Ele2PtBin = 1; else if (ele2pt < 40) Ele2PtBin = 2; else Ele2PtBin = 3; if (fabs(zeeTree->fEle1SCEta) < 1.0) Ele1EtaBin = 0; else if (fabs(zeeTree->fEle1SCEta) < 1.479) Ele1EtaBin = 1; else Ele1EtaBin = 2; if (fabs(zeeTree->fEle2SCEta) < 1.0) Ele2EtaBin = 0; else if (fabs(zeeTree->fEle2SCEta) < 1.479) Ele2EtaBin = 1; else Ele2EtaBin = 2; if (CategoryBin == 0) { if (!(Ele1EtaBin == 0 && Ele2EtaBin == 0)) continue; } else if (CategoryBin == 1) { if (!(Ele1EtaBin == 1 && Ele2EtaBin == 1)) continue; } else if (CategoryBin == 2) { if (!(Ele1EtaBin == 2 && Ele2EtaBin == 2)) continue; } //************************************************************************* // restrict range of mass //************************************************************************* double zMass = (ele1FourVector+ele2FourVector).M(); if (zMass < minMass || zMass > maxMass) continue; //************************************************************************* //set mass variable //************************************************************************* zMassArgSet.setRealValue("mass", zMass); data->add(zMassArgSet); } cout << "dataset size: " << data->numEntries() << endl; RooRealVar *cbBias = (RooRealVar*)w->var("#Deltam_{CB}"); RooRealVar *cbSigma = (RooRealVar*)w->var("sigma_{CB}"); RooRealVar *cbCut = (RooRealVar*)w->var("a_{CB}"); RooRealVar *cbPower = (RooRealVar*)w->var("n_{CB}"); // // Now if it's a restricted fit, fix values of cbCut and cbPower to MC values. // if (isRestricted) { // cbCut.setConstant(kTRUE); // cbPower.setConstant(kTRUE); // } // Mass model for signal electrons p.d.f. RooAddPdf *model = (RooAddPdf*)w->pdf("model"); TCanvas* c = new TCanvas("c","c", 0,0,800,600); //========================== Plotting ============================ //Create a frame RooPlot* plot = mass->frame(Range(minMass,maxMass),Bins(nbins)); // Add data and model to canvas plot->SetTitle(""); plot->GetYaxis()->SetTitleOffset(1.4); plot->GetXaxis()->SetTitle("m_{ee} (GeV/c^{2})"); data->plotOn(plot); model->plotOn(plot); // model->paramOn(plot, Format(plotOpt, AutoPrecision(1)), Parameters(RooArgSet(*cbBias, *cbSigma, *cbCut, *cbPower)), Layout(0.60,0.90,0.90)); model->paramOn(plot, Format(plotOpt, AutoPrecision(1)), Parameters(RooArgSet(*cbBias, *cbSigma, *cbCut, *cbPower)), Layout(0.12,0.38,0.60)); plot->getAttText()->SetTextSize(.025); plot->Draw(); // Print Fit Values TLatex *tex = new TLatex(); tex->SetNDC(); tex->SetTextSize(.04); tex->SetTextFont(2); tex->DrawLatex(0.195,0.775, "Run 2012A/B"); tex->Draw(); // tex->SetTextSize(0.022); // tex->DrawLatex(0.195, 0.75, "Z #rightarrow ee^{+}"); // tex->SetTextSize(0.024); // tex->DrawLatex(0.645, 0.59, Form("BW Mean = %.2f GeV/c^{2}", bwMean.getVal())); // tex->DrawLatex(0.645, 0.54, Form("BW #sigma = %.2f GeV/c^{2}", bwWidth.getVal())); c->Update(); c->SaveAs((outFilename + ".gif").c_str()); }
void CrossSectionRatio(TString inputFONLL="ROOTfiles/output_inclusiveDd0meson_5TeV_y1.root", TString input="ROOTfiles/hPtSpectrumDzeroPP.root", TString efficiency="test.root", TString inputprescales="prescalePP.root",int usePrescaleCorr=1,TString outputplot="myplot.root",int usePbPb=1,TString label="PbPb",double lumi=1.,Float_t centMin=0., Float_t centMax=100.) { gStyle->SetOptTitle(0); gStyle->SetOptStat(0); gStyle->SetEndErrorSize(0); gStyle->SetMarkerStyle(20); TFile* fileReference = new TFile(inputFONLL.Data()); TGraphAsymmErrors* gaeBplusReference = (TGraphAsymmErrors*)fileReference->Get("gaeSigmaDzero"); if (!(usePbPb==1||usePbPb==0)) std::cout<<"ERROR!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!, you are using a non valid isPbPb option"<<std::endl; bool isPbPb=(bool)(usePbPb); TFile* file = new TFile(input.Data()); TH1F* hYieldTriggerCorrected = (TH1F*)file->Get("hPt"); hYieldTriggerCorrected->SetName("hYieldTriggerCorrected"); TH1F* hYieldNoTriggerCorrected = (TH1F*)file->Get("hPt"); hYieldNoTriggerCorrected->SetName("hYieldNoTriggerCorrected"); TH1F* hYieldTriggerCorrectedFONLLnorm = (TH1F*)file->Get("hPt"); hYieldTriggerCorrectedFONLLnorm->SetName("hYieldTriggerCorrectedFONLLnorm"); TH1F* hDcandidatesTriggerCorrectedFONLLnorm = (TH1F*)file->Get("hDcandidates"); hDcandidatesTriggerCorrectedFONLLnorm->SetName("hDcandidatesTriggerCorrectedFONLLnorm"); TH1F* hYieldNoTriggerCorrectedFONLLnorm = (TH1F*)file->Get("hPt"); hYieldNoTriggerCorrectedFONLLnorm->SetName("hYieldNoTriggerCorrectedFONLLnorm"); TH1F* hDcandidatesNoTriggerCorrectedFONLLnorm = (TH1F*)file->Get("hDcandidates"); hDcandidatesNoTriggerCorrectedFONLLnorm->SetName("hDcandidatesNoTriggerCorrectedFONLLnorm"); TFile* fileeff = new TFile(efficiency.Data()); TH1F* hEff = (TH1F*)fileeff->Get("hEff"); TH1F* hfprompt = new TH1F("hfprompt","",nBins,ptBins); TH1F*hPrescalesPtBins; TH1F*hTriggerEfficiencyPtBins; TH1F* hPtSigma = (TH1F*)hYieldTriggerCorrected->Clone("hPtSigma"); hPtSigma->Divide(hEff); hPtSigma->Scale(1./(2*lumi*BRchain)); hPtSigma->SetName("hPtSigma"); /* TH1F* hPtSigma = (TH1F*)file->Get("hPtSigma"); hPtSigma->Scale(1./lumi); */ hYieldTriggerCorrected->Scale(1./lumi); hYieldNoTriggerCorrected->Scale(1./lumi); hYieldTriggerCorrectedFONLLnorm->Scale(1./lumi); hYieldNoTriggerCorrectedFONLLnorm->Scale(1./lumi); hDcandidatesTriggerCorrectedFONLLnorm->Scale(1./lumi); hDcandidatesNoTriggerCorrectedFONLLnorm->Scale(1./lumi); for (int i=0;i<nBins;i++) { double prompt=bFeedDownCorrection(hPtSigma->GetBinCenter(i+1),isPbPb,1); hfprompt->SetBinContent(i+1,prompt); hPtSigma->SetBinContent(i+1,hPtSigma->GetBinContent(i+1)*prompt); hPtSigma->SetBinError(i+1,hPtSigma->GetBinError(i+1)*prompt); std::cout<<"pt center="<<hPtSigma->GetBinCenter(i+1)<<", prompt fraction="<<prompt<<std::endl; } if (usePrescaleCorr==1){ TFile*fprescales=new TFile(inputprescales.Data()); hPrescalesPtBins=(TH1F*)fprescales->Get("hPrescalesPtBins"); hTriggerEfficiencyPtBins=(TH1F*)fprescales->Get("hTriggerEfficiencyPtBins"); for (int i=0;i<nBins;i++) { hPtSigma->SetBinContent(i+1,hPtSigma->GetBinContent(i+1)/hPrescalesPtBins->GetBinContent(i+1)/hTriggerEfficiencyPtBins->GetBinContent(i+1)); hPtSigma->SetBinError(i+1,hPtSigma->GetBinError(i+1)/hPrescalesPtBins->GetBinContent(i+1)/hTriggerEfficiencyPtBins->GetBinContent(i+1)); hYieldTriggerCorrected->SetBinContent(i+1,hYieldTriggerCorrected->GetBinContent(i+1)/hPrescalesPtBins->GetBinContent(i+1)/hTriggerEfficiencyPtBins->GetBinContent(i+1)); hYieldTriggerCorrected->SetBinError(i+1,hYieldTriggerCorrected->GetBinError(i+1)/hPrescalesPtBins->GetBinContent(i+1)/hTriggerEfficiencyPtBins->GetBinContent(i+1)); hYieldNoTriggerCorrected->SetBinContent(i+1,hYieldNoTriggerCorrected->GetBinContent(i+1)/hPrescalesPtBins->GetBinContent(i+1)); hYieldNoTriggerCorrected->SetBinError(i+1,hYieldNoTriggerCorrected->GetBinError(i+1)/hPrescalesPtBins->GetBinContent(i+1)); hYieldTriggerCorrectedFONLLnorm->SetBinContent(i+1,hYieldTriggerCorrectedFONLLnorm->GetBinContent(i+1)/hPrescalesPtBins->GetBinContent(i+1)/hTriggerEfficiencyPtBins->GetBinContent(i+1)); hYieldTriggerCorrectedFONLLnorm->SetBinError(i+1,hYieldTriggerCorrectedFONLLnorm->GetBinError(i+1)/hPrescalesPtBins->GetBinContent(i+1)/hTriggerEfficiencyPtBins->GetBinContent(i+1)); hDcandidatesTriggerCorrectedFONLLnorm->SetBinContent(i+1,hDcandidatesTriggerCorrectedFONLLnorm->GetBinContent(i+1)/hPrescalesPtBins->GetBinContent(i+1)/hTriggerEfficiencyPtBins->GetBinContent(i+1)); hDcandidatesTriggerCorrectedFONLLnorm->SetBinError(i+1,hDcandidatesTriggerCorrectedFONLLnorm->GetBinError(i+1)/hPrescalesPtBins->GetBinContent(i+1)/hTriggerEfficiencyPtBins->GetBinContent(i+1)); hYieldNoTriggerCorrectedFONLLnorm->SetBinContent(i+1,hYieldNoTriggerCorrectedFONLLnorm->GetBinContent(i+1)/hPrescalesPtBins->GetBinContent(i+1)); hYieldNoTriggerCorrectedFONLLnorm->SetBinError(i+1,hYieldNoTriggerCorrectedFONLLnorm->GetBinError(i+1)/hPrescalesPtBins->GetBinContent(i+1)); hDcandidatesNoTriggerCorrectedFONLLnorm->SetBinContent(i+1,hDcandidatesNoTriggerCorrectedFONLLnorm->GetBinContent(i+1)/hPrescalesPtBins->GetBinContent(i+1)); hDcandidatesNoTriggerCorrectedFONLLnorm->SetBinError(i+1,hDcandidatesNoTriggerCorrectedFONLLnorm->GetBinError(i+1)/hPrescalesPtBins->GetBinContent(i+1)); } } Double_t xr[nBins], xrlow[nBins], xrhigh[nBins], ycross[nBins],ycrossstat[nBins],ycrosssysthigh[nBins],ycrosssystlow[nBins], yFONLL[nBins]; Double_t yratiocrossFONLL[nBins], yratiocrossFONLLstat[nBins], yratiocrossFONLLsysthigh[nBins], yratiocrossFONLLsystlow[nBins]; Double_t yFONLLrelunclow[nBins], yFONLLrelunchigh[nBins], yunity[nBins]; for(int i=0;i<nBins;i++) { gaeBplusReference->GetPoint(i,xr[i],yFONLL[i]); xrlow[i] = gaeBplusReference->GetErrorXlow(i); xrhigh[i] = gaeBplusReference->GetErrorXhigh(i); ycross[i] = hPtSigma->GetBinContent(i+1); ycrossstat[i] = hPtSigma->GetBinError(i+1); double systematic=0.; if (!isPbPb) systematic=0.01*systematicsPP(xr[i],0.); else systematic=0.01*systematicsPbPb(xr[i],centMin,centMax,0.); ycrosssysthigh[i]= hPtSigma->GetBinContent(i+1)*systematic; ycrosssystlow[i]= hPtSigma->GetBinContent(i+1)*systematic; yratiocrossFONLL[i] = ycross[i]/yFONLL[i]; yratiocrossFONLLstat[i] = ycrossstat[i]/yFONLL[i]; yratiocrossFONLLsysthigh[i] = ycrosssysthigh[i]/yFONLL[i]; yratiocrossFONLLsystlow[i] = ycrosssystlow[i]/yFONLL[i]; yFONLLrelunclow[i] = gaeBplusReference->GetErrorYlow(i)/yFONLL[i]; yFONLLrelunchigh[i] = gaeBplusReference->GetErrorYhigh(i)/yFONLL[i]; yunity[i] = yFONLL[i]/yFONLL[i]; hYieldTriggerCorrectedFONLLnorm->SetBinContent(i+1,hYieldTriggerCorrectedFONLLnorm->GetBinContent(i+1)/yFONLL[i]); hYieldTriggerCorrectedFONLLnorm->SetBinError(i+1,hYieldTriggerCorrectedFONLLnorm->GetBinError(i+1)/yFONLL[i]); hDcandidatesTriggerCorrectedFONLLnorm->SetBinContent(i+1,hDcandidatesTriggerCorrectedFONLLnorm->GetBinContent(i+1)/yFONLL[i]); hDcandidatesTriggerCorrectedFONLLnorm->SetBinError(i+1,hDcandidatesTriggerCorrectedFONLLnorm->GetBinError(i+1)/yFONLL[i]); hYieldNoTriggerCorrectedFONLLnorm->SetBinContent(i+1,hYieldNoTriggerCorrectedFONLLnorm->GetBinContent(i+1)/yFONLL[i]); hYieldNoTriggerCorrectedFONLLnorm->SetBinError(i+1,hYieldNoTriggerCorrectedFONLLnorm->GetBinError(i+1)/yFONLL[i]); hDcandidatesNoTriggerCorrectedFONLLnorm->SetBinContent(i+1,hDcandidatesNoTriggerCorrectedFONLLnorm->GetBinContent(i+1)/yFONLL[i]); hDcandidatesNoTriggerCorrectedFONLLnorm->SetBinError(i+1,hDcandidatesNoTriggerCorrectedFONLLnorm->GetBinError(i+1)/yFONLL[i]); } TGraphAsymmErrors* gaeCrossSyst = new TGraphAsymmErrors(nBins,xr,ycross,xrlow,xrhigh,ycrosssystlow,ycrosssysthigh); gaeCrossSyst->SetName("gaeCrossSyst"); gaeCrossSyst->SetMarkerStyle(20); gaeCrossSyst->SetMarkerSize(0.8); TGraphAsymmErrors* gaeRatioCrossFONLLstat = new TGraphAsymmErrors(nBins,xr,yratiocrossFONLL,xrlow,xrhigh,yratiocrossFONLLstat,yratiocrossFONLLstat); gaeRatioCrossFONLLstat->SetName("gaeRatioCrossFONLLstat"); gaeRatioCrossFONLLstat->SetMarkerStyle(20); gaeRatioCrossFONLLstat->SetMarkerSize(0.8); TGraphAsymmErrors* gaeRatioCrossFONLLsyst= new TGraphAsymmErrors(nBins,xr,yratiocrossFONLL,xrlow,xrhigh,yratiocrossFONLLsystlow,yratiocrossFONLLsysthigh); gaeRatioCrossFONLLsyst->SetName("gaeRatioCrossFONLLsyst"); gaeRatioCrossFONLLsyst->SetLineWidth(2); gaeRatioCrossFONLLsyst->SetLineColor(1); gaeRatioCrossFONLLsyst->SetFillColor(2); gaeRatioCrossFONLLsyst->SetFillStyle(0); TGraphAsymmErrors* gaeRatioCrossFONLLunity = new TGraphAsymmErrors(nBins,xr,yunity,xrlow,xrhigh,yFONLLrelunclow,yFONLLrelunchigh); gaeRatioCrossFONLLunity->SetName("gaeRatioCrossFONLLunity"); gaeRatioCrossFONLLunity->SetLineWidth(2); gaeRatioCrossFONLLunity->SetLineColor(2); gaeRatioCrossFONLLunity->SetFillColor(2); gaeRatioCrossFONLLunity->SetFillStyle(3002); TCanvas* cSigma = new TCanvas("cSigma","",600,750); cSigma->SetFrameBorderMode(0); cSigma->SetFrameBorderMode(0); cSigma->Range(-1.989924,-0.2917772,25.49622,2.212202); cSigma->SetFillColor(0); cSigma->SetBorderMode(0); cSigma->SetBorderSize(2); cSigma->SetLeftMargin(0.1451613); cSigma->SetRightMargin(0.05443548); cSigma->SetTopMargin(0.08474576); cSigma->SetBottomMargin(0.1165254); cSigma->SetFrameBorderMode(0); cSigma->SetFrameBorderMode(0); cSigma->cd(); TPad* pSigma = new TPad("pSigma","",0,0.25,1,1); pSigma->SetFillColor(0); pSigma->SetBorderMode(0); pSigma->SetBorderSize(2); pSigma->SetLeftMargin(0.1451613); pSigma->SetRightMargin(0.05443548); pSigma->SetTopMargin(0.08474576); pSigma->SetBottomMargin(0); pSigma->SetLogy(); pSigma->Draw(); pSigma->cd(); Float_t yaxisMin=1.1,yaxisMax=1.e+9; if(label=="PPMB"||label=="PbPbMB") { yaxisMin=1.e+4; yaxisMax=1.e+13; } TH2F* hemptySigma=new TH2F("hemptySigma","",50,ptBins[0]-5.,ptBins[nBins]+5.,10.,yaxisMin,yaxisMax); hemptySigma->GetXaxis()->CenterTitle(); hemptySigma->GetYaxis()->CenterTitle(); hemptySigma->GetYaxis()->SetTitle("d#sigma / dp_{T}( pb GeV^{-1}c)"); if(isPbPb) hemptySigma->GetYaxis()->SetTitle("1/T_{AA} * dN / dp_{T}( pb GeV^{-1}c)"); hemptySigma->GetXaxis()->SetTitleOffset(1.); hemptySigma->GetYaxis()->SetTitleOffset(1.3); hemptySigma->GetXaxis()->SetTitleSize(0.045); hemptySigma->GetYaxis()->SetTitleSize(0.045); hemptySigma->GetXaxis()->SetTitleFont(42); hemptySigma->GetYaxis()->SetTitleFont(42); hemptySigma->GetXaxis()->SetLabelFont(42); hemptySigma->GetYaxis()->SetLabelFont(42); hemptySigma->GetXaxis()->SetLabelSize(0.04); hemptySigma->GetYaxis()->SetLabelSize(0.04); hemptySigma->SetMaximum(2); hemptySigma->SetMinimum(0.); hemptySigma->Draw(); gaeBplusReference->SetFillColor(2); gaeBplusReference->SetFillStyle(3001); gaeBplusReference->SetLineWidth(3); gaeBplusReference->SetLineColor(2); gaeBplusReference->Draw("5same"); hPtSigma->SetLineColor(1); hPtSigma->SetLineWidth(2); hPtSigma->Draw("epsame"); gaeCrossSyst->SetFillColor(1); gaeCrossSyst->SetFillStyle(0); gaeCrossSyst->SetLineWidth(2); gaeCrossSyst->SetLineColor(1); gaeCrossSyst->Draw("5same"); TLatex* texCms = new TLatex(0.16,0.95, "#scale[1.25]{CMS} Preliminary"); texCms->SetNDC(); texCms->SetTextAlign(12); texCms->SetTextSize(0.04); texCms->SetTextFont(42); texCms->Draw(); TLatex* texCol = new TLatex(0.94,0.95, Form("%s #sqrt{s_{NN}} = 5.02 TeV",label.Data())); texCol->SetNDC(); texCol->SetTextAlign(32); texCol->SetTextSize(0.04); texCol->SetTextFont(42); texCol->Draw(); TString texper="%"; TLatex* texCent = new TLatex(0.53,0.815,Form("Centrality %.0f - %.0f%s",centMin,centMax,texper.Data())); texCent->SetNDC(); texCent->SetTextFont(42); texCent->SetTextSize(0.04); if(isPbPb) texCent->Draw(); TLatex* texY = new TLatex(0.53,0.77,"|y| < 1.0"); texY->SetNDC(); texY->SetTextFont(42); texY->SetTextSize(0.04); texY->SetLineWidth(2); texY->Draw(); TLegend* leg_CS = new TLegend(0.52,0.64,0.85,0.75); leg_CS->SetBorderSize(0); leg_CS->SetFillStyle(0); leg_CS->AddEntry(hPtSigma,"data","pf"); leg_CS->AddEntry(gaeBplusReference,"FONLL pp ref.","f"); leg_CS->Draw("same"); /* TLatex * tlatexlumi=new TLatex(0.671371,0.7801268,"L = 9.97 pb^{-1}"); tlatexlumi->SetNDC(); tlatexlumi->SetTextColor(1); tlatexlumi->SetTextFont(42); tlatexlumi->SetTextSize(0.045); */ cSigma->cd(); TPad* pRatio = new TPad("pRatio","",0,0,1,0.25); pRatio->SetLeftMargin(0.1451613); pRatio->SetRightMargin(0.05443548); pRatio->SetTopMargin(0); pRatio->SetBottomMargin(0.25); pRatio->Draw(); pRatio->cd(); TH2F* hemptyRatio=new TH2F("hemptyRatio","",50,ptBins[0]-5.,ptBins[nBins]+5.,10.,0.,3.1); hemptyRatio->GetXaxis()->SetTitle("p_{T} (GeV/c)"); hemptyRatio->GetYaxis()->CenterTitle(); hemptyRatio->GetYaxis()->SetTitle("Data / FONLL"); hemptyRatio->GetXaxis()->SetTitleOffset(0.9); hemptyRatio->GetYaxis()->SetTitleOffset(0.5); hemptyRatio->GetXaxis()->SetTitleSize(0.12); hemptyRatio->GetYaxis()->SetTitleSize(0.12); hemptyRatio->GetXaxis()->SetTitleFont(42); hemptyRatio->GetYaxis()->SetTitleFont(42); hemptyRatio->GetXaxis()->SetLabelFont(42); hemptyRatio->GetYaxis()->SetLabelFont(42); hemptyRatio->GetXaxis()->SetLabelSize(0.1); hemptyRatio->GetYaxis()->SetLabelSize(0.1); hemptyRatio->Draw(); TLine* l = new TLine(ptBins[0]-5.,1,ptBins[nBins]+5.,1); l->SetLineWidth(1); l->SetLineStyle(2); gaeRatioCrossFONLLunity->Draw("5same"); gaeRatioCrossFONLLstat->Draw("epsame"); gaeRatioCrossFONLLsyst->Draw("5same"); l->Draw("same"); if(!isPbPb) cSigma->SaveAs(Form("plotCrossSection/canvasSigmaDzeroRatio%s.pdf",label.Data())); else cSigma->SaveAs(Form("plotCrossSection/canvasSigmaDzeroRatio%s_%.0f_%.0f.pdf",label.Data(),centMin,centMax)); TCanvas* cEff = new TCanvas("cEff","",550,500); TH2F* hemptyEff=new TH2F("hemptyEff","",50,0.,110.,10.,0,1.); hemptyEff->GetXaxis()->CenterTitle(); hemptyEff->GetYaxis()->CenterTitle(); hemptyEff->GetYaxis()->SetTitle("#alpha x #epsilon_{reco} x #epsilon_{sel} "); hemptyEff->GetXaxis()->SetTitle("p_{T} (GeV/c)"); hemptyEff->GetXaxis()->SetTitleOffset(0.9); hemptyEff->GetYaxis()->SetTitleOffset(1.05); hemptyEff->GetXaxis()->SetTitleSize(0.045); hemptyEff->GetYaxis()->SetTitleSize(0.045); hemptyEff->GetXaxis()->SetTitleFont(42); hemptyEff->GetYaxis()->SetTitleFont(42); hemptyEff->GetXaxis()->SetLabelFont(42); hemptyEff->GetYaxis()->SetLabelFont(42); hemptyEff->GetXaxis()->SetLabelSize(0.04); hemptyEff->GetYaxis()->SetLabelSize(0.04); hemptyEff->SetMaximum(2); hemptyEff->SetMinimum(0.); hemptyEff->Draw(); cEff->cd(); hemptyEff->Draw(); hEff->SetLineWidth(2); hEff->SetLineColor(1); hEff->Draw("same"); TString text; TString sample; if (label=="PbPb") { text="CMS Preliminary PbPb #sqrt{s}= 5.02 TeV"; sample="Pythia8+Hydjet MC simulation, prompt D^{0}";} else {text="CMS Preliminary pp #sqrt{s}= 5.02 TeV"; sample="Pythia8 MC simulation, prompt D^{0}";} TLatex * tlatexeff=new TLatex(0.1612903,0.8525793,text.Data()); tlatexeff->SetNDC(); tlatexeff->SetTextColor(1); tlatexeff->SetTextFont(42); tlatexeff->SetTextSize(0.04); tlatexeff->Draw(); TLatex * tlatexeff2=new TLatex(0.1612903,0.7925793,sample.Data()); tlatexeff2->SetNDC(); tlatexeff2->SetTextColor(1); tlatexeff2->SetTextFont(42); tlatexeff2->SetTextSize(0.04); tlatexeff2->Draw(); if(!isPbPb) cEff->SaveAs(Form("plotOthers/efficiency%s.pdf",label.Data())); else cEff->SaveAs(Form("plotOthers/efficiency%s_%.0f_%.0f.pdf",label.Data(),centMin,centMax)); TCanvas* cFprompt = new TCanvas("cFprompt","",550,500); TH2F* hemptyPrompt=new TH2F("hemptyPrompt","",50,0.,110.,10.,0,1.); hemptyPrompt->GetXaxis()->CenterTitle(); hemptyPrompt->GetYaxis()->CenterTitle(); hemptyPrompt->GetYaxis()->SetTitle("f_{prompt}"); hemptyPrompt->GetXaxis()->SetTitle("p_{T} (GeV/c)"); hemptyPrompt->GetXaxis()->SetTitleOffset(0.9); hemptyPrompt->GetYaxis()->SetTitleOffset(1.05); hemptyPrompt->GetXaxis()->SetTitleSize(0.045); hemptyPrompt->GetYaxis()->SetTitleSize(0.045); hemptyPrompt->GetXaxis()->SetTitleFont(42); hemptyPrompt->GetYaxis()->SetTitleFont(42); hemptyPrompt->GetXaxis()->SetLabelFont(42); hemptyPrompt->GetYaxis()->SetLabelFont(42); hemptyPrompt->GetXaxis()->SetLabelSize(0.04); hemptyPrompt->GetYaxis()->SetLabelSize(0.04); hemptyPrompt->SetMaximum(2); hemptyPrompt->SetMinimum(0.); hemptyPrompt->Draw(); cFprompt->cd(); hemptyPrompt->Draw(); hfprompt->SetLineWidth(2); hfprompt->SetLineColor(1); hfprompt->Draw("same"); if(!isPbPb) cFprompt->SaveAs(Form("plotOthers/cFprompt%s.pdf",label.Data())); else cFprompt->SaveAs(Form("plotOthers/cFprompt%s_%.0f_%.0f.pdf",label.Data(),centMin,centMax)); TFile *outputfile=new TFile(outputplot.Data(),"recreate"); outputfile->cd(); gaeCrossSyst->Write(); gaeRatioCrossFONLLstat->Write(); gaeBplusReference->Write(); hPtSigma->Write(); gaeRatioCrossFONLLstat->Write(); gaeRatioCrossFONLLsyst->Write(); gaeRatioCrossFONLLunity->Write(); hEff->Write(); hfprompt->Write(); hYieldTriggerCorrected->Write(); hYieldNoTriggerCorrected->Write(); hDcandidatesTriggerCorrectedFONLLnorm->Write(); hYieldTriggerCorrectedFONLLnorm->Write(); hDcandidatesNoTriggerCorrectedFONLLnorm->Write(); hYieldNoTriggerCorrectedFONLLnorm->Write(); if (usePrescaleCorr==1){ hPrescalesPtBins->Write(); hTriggerEfficiencyPtBins->Write(); } }
void drawcentffgamma() { TFile *_file0 = TFile::Open("all.root"); int save = 1; const int yaxismax = 5; const static int ncentbins = 4; float binwidth = 5.000000e-01; int centmins[] = {0,20,60,100,140}; int centmaxs[] = {20,60,100,200,200}; string cents[] = {"0-10%","10-30%","30-50%","50-100%","70-100%"}; TCanvas * c1_pbpbdata[ncentbins]; // ncentbins TH1D * hgammaffxi_pbpbdata_[ncentbins]; TH1D * hjetpt_pbpbdata_[ncentbins]; TH1D * hgammaffxi_refcone_pbpbdata_[ncentbins]; float njets_pbpbdata[ncentbins]; TLegend * leg_ff_pbpbdata[ncentbins]; TCanvas * c1_pbpbmc[ncentbins]; TH1D * hgammaffxi_pbpbmc_[ncentbins]; TH1D * hjetpt_pbpbmc_[ncentbins]; TH1D * hgammaffxi_refcone_pbpbmc_[ncentbins]; float njets_pbpbmc[ncentbins]; TLegend * leg_ff_pbpbmc[ncentbins]; TCanvas * c1_subpbpb[ncentbins]; TH2D * dummy_pbpbsub[ncentbins]; TH1D * clone_hgammaffxi_refcone_pbpbdata_[ncentbins]; TH1D * clone_hgammaffxi_pbpbdata_[ncentbins]; TH1D * clone_hgammaffxi_refcone_pbpbmc_[ncentbins]; TH1D * clone_hgammaffxi_pbpbmc_[ncentbins]; TLegend * leg_ff_pbpbsub[ncentbins]; TCanvas * call = new TCanvas("call","",1400,500); // makeMultiPanelCanvas(call,6,1,0,0,-2.99,0.2,0.04); // makeMultiPanelCanvas(call,6,1,0.02,0.0,-6,0.2,0.04); // makeMultiPanelCanvas(call,4,1,0,0,0.2,0.2,0.04); makeMultiPanelCanvas(call,ncentbins+1,1,0.02,0.0,-6,0.2,0.04); for (int icent = 0; icent < ncentbins; icent++) { // Raw FF pbpdata // c1_pbpbdata[icent] = new TCanvas(Form("c1_pbpbdata_%d_%d",centmins[icent],centmaxs[icent])); hgammaffxi_pbpbdata_[icent] = (TH1D*) _file0->Get(Form("hgammaffxi_pbpbdata__%d_%d",centmins[icent],centmaxs[icent])); hjetpt_pbpbdata_[icent] = (TH1D*) _file0->Get(Form("hjetpt_pbpbdata__%d_%d",centmins[icent],centmaxs[icent])); hgammaffxi_refcone_pbpbdata_[icent] = (TH1D*) _file0->Get(Form("hgammaffxi_refcone_pbpbdata__%d_%d",centmins[icent],centmaxs[icent])); njets_pbpbdata[icent] = hjetpt_pbpbdata_[icent]->Integral(); hgammaffxi_pbpbdata_[icent]->Sumw2(); hgammaffxi_refcone_pbpbdata_[icent]->Sumw2(); hgammaffxi_pbpbdata_[icent]->Scale(1.0/njets_pbpbdata[icent]/binwidth); hgammaffxi_refcone_pbpbdata_[icent]->Scale(1.0/njets_pbpbdata[icent]/binwidth); hgammaffxi_pbpbdata_[icent]->GetXaxis()->CenterTitle(); hgammaffxi_pbpbdata_[icent]->SetYTitle("dN/d#xi"); hgammaffxi_pbpbdata_[icent]->GetYaxis()->CenterTitle(); // hgammaffxi_pbpbdata_[icent]->Draw(); hgammaffxi_refcone_pbpbdata_[icent]->SetMarkerStyle(24); // hgammaffxi_refcone_pbpbdata_[icent]->Draw("same"); leg_ff_pbpbdata[icent] = new TLegend(0.23,0.59,0.50,0.92); leg_ff_pbpbdata[icent]->SetFillColor(0); leg_ff_pbpbdata[icent]->SetTextSize(0.05); leg_ff_pbpbdata[icent]->SetFillStyle(0); leg_ff_pbpbdata[icent]->SetTextFont(42); leg_ff_pbpbdata[icent]->AddEntry(hgammaffxi_pbpbdata_[icent],"raw frag. func","p"); leg_ff_pbpbdata[icent]->AddEntry(hgammaffxi_refcone_pbpbdata_[icent],"#eta reflected cone","p"); leg_ff_pbpbdata[icent]->AddEntry(hgammaffxi_refcone_pbpbdata_[icent],"PbPb #sqrt{s_{NN}}=5 TeV",""); leg_ff_pbpbdata[icent]->AddEntry(hgammaffxi_refcone_pbpbdata_[icent],"trk p_{T}>1 GeV",""); leg_ff_pbpbdata[icent]->AddEntry(hgammaffxi_refcone_pbpbdata_[icent],"100>#gamma p_{T}>300 GeV",""); // leg_ff_pbpbdata[icent]->Draw(); // c1_pbpbdata[icent]->SaveAs("pbpbdata_unsubffspectrum_45_gamma_100.png"); // Raw FF pbpdata // Raw FF pbmc // c1_pbpbmc[icent] = new TCanvas(Form("c1_pbpbmc_%d_%d",centmins[icent],centmaxs[icent])); hgammaffxi_pbpbmc_[icent] = (TH1D*) _file0->Get(Form("hgammaffxi_pbpbmc__%d_%d",centmins[icent],centmaxs[icent])); hjetpt_pbpbmc_[icent] = (TH1D*) _file0->Get(Form("hjetpt_pbpbmc__%d_%d",centmins[icent],centmaxs[icent])); hgammaffxi_refcone_pbpbmc_[icent] = (TH1D*) _file0->Get(Form("hgammaffxi_refcone_pbpbmc__%d_%d",centmins[icent],centmaxs[icent])); njets_pbpbmc[icent] = hjetpt_pbpbmc_[icent]->Integral(); hgammaffxi_pbpbmc_[icent]->Sumw2(); hgammaffxi_refcone_pbpbmc_[icent]->Sumw2(); hgammaffxi_pbpbmc_[icent]->Scale(1.0/njets_pbpbmc[icent]/binwidth); hgammaffxi_refcone_pbpbmc_[icent]->Scale(1.0/njets_pbpbmc[icent]/binwidth); hgammaffxi_pbpbmc_[icent]->GetXaxis()->CenterTitle(); hgammaffxi_pbpbmc_[icent]->SetYTitle("dN/d#xi"); hgammaffxi_pbpbmc_[icent]->GetYaxis()->CenterTitle(); // hgammaffxi_pbpbmc_[icent]->Draw(); hgammaffxi_refcone_pbpbmc_[icent]->SetMarkerStyle(24); // hgammaffxi_refcone_pclone_hgammaffxi_refcone_pbpbdata_bpbmc_[icent]->Draw("same"); leg_ff_pbpbmc[icent] = new TLegend(0.22,0.59,0.49,0.92); leg_ff_pbpbmc[icent]->SetFillColor(0); leg_ff_pbpbmc[icent]->SetTextSize(0.05); leg_ff_pbpbmc[icent]->SetFillStyle(0); leg_ff_pbpbmc[icent]->SetTextFont(42); leg_ff_pbpbmc[icent]->AddEntry(hgammaffxi_pbpbmc_[icent],"raw frag. func","p"); leg_ff_pbpbmc[icent]->AddEntry(hgammaffxi_refcone_pbpbmc_[icent],"#eta reflected cone","p"); leg_ff_pbpbmc[icent]->AddEntry(hgammaffxi_refcone_pbpbmc_[icent],"Pythia+Hydjet #hat{p}_{T}=",""); leg_ff_pbpbmc[icent]->AddEntry(hgammaffxi_refcone_pbpbmc_[icent],"trk p_{T}>1 GeV",""); leg_ff_pbpbmc[icent]->AddEntry(hgammaffxi_refcone_pbpbmc_[icent],"45>#gamma p_{T}>100 GeV",""); // leg_ff_pbpbmc[icent]->Draw(); // c1_pbpbmc[icent]->SaveAs("pbpbmc_unsubffspectrum_45_gamma_100.png"); // Raw FF pbpbmc // Eta cone subtracted FF pbpbdata and pbpbmc // c1_subpbpb[icent] = new TCanvas(Form("c1_subpbpb_%d_%d",centmins[icent],centmaxs[icent])); // call->cd(icent+2); call->cd(icent+2); dummy_pbpbsub[icent] = new TH2D(Form("dummy_pbpbsub_%d_%d",centmins[icent],centmaxs[icent]),";#xi;dN/d#xi",1,0.01,4.99,1,0,yaxismax); dummy_pbpbsub[icent]->GetXaxis()->SetTitleOffset(0.8); dummy_pbpbsub[icent]->GetXaxis()->CenterTitle(); dummy_pbpbsub[icent]->GetYaxis()->CenterTitle(); // if(icent!=0) // { dummy_pbpbsub[icent]->GetXaxis()->SetTitleSize(dummy_pbpbsub[icent]->GetXaxis()->GetTitleSize()*1.5); // } clone_hgammaffxi_refcone_pbpbdata_[icent] = (TH1D*) hgammaffxi_refcone_pbpbdata_[icent]->Clone(Form("clone_hgammaffxi_refcone_pbpbdata__%d_%d",centmins[icent],centmaxs[icent])); clone_hgammaffxi_refcone_pbpbdata_[icent]->Scale(-1); clone_hgammaffxi_pbpbdata_[icent] = (TH1D*) hgammaffxi_pbpbdata_[icent]->Clone(Form("clone_hgammaffxi_pbpbdata__%d_%d",centmins[icent],centmaxs[icent])); clone_hgammaffxi_pbpbdata_[icent]->Add(clone_hgammaffxi_refcone_pbpbdata_[icent]); clone_hgammaffxi_refcone_pbpbmc_[icent] = (TH1D*) hgammaffxi_refcone_pbpbmc_[icent]->Clone(Form("clone_hgammaffxi_refcone_pbpbmc__%d_%d",centmins[icent],centmaxs[icent])); clone_hgammaffxi_refcone_pbpbmc_[icent]->Scale(-1); clone_hgammaffxi_pbpbmc_[icent] = (TH1D*) hgammaffxi_pbpbmc_[icent]->Clone(Form("clone_hgammaffxi_pbpbmc__%d_%d",centmins[icent],centmaxs[icent])); clone_hgammaffxi_pbpbmc_[icent]->Add(clone_hgammaffxi_refcone_pbpbmc_[icent]); clone_hgammaffxi_pbpbmc_[icent]->SetMarkerColor(kRed); // fixedFontHist(dummy_pbpbsub[icent]); dummy_pbpbsub[icent]->Draw(); clone_hgammaffxi_pbpbdata_[icent]->Draw("same"); // hgammaffxi_pbpbmc_[icent]->Draw("same"); // hgammaffxi_refcone_pbpbmc_[icent]->Draw("same"); clone_hgammaffxi_pbpbmc_[icent]->Draw("same"); if(icent==0) { // leg_ff_pbpbsub[icent] = new TLegend(0.25,0.697,0.875,0.92); leg_ff_pbpbsub[icent] = new TLegend(0.05,0.697,0.27,0.92); leg_ff_pbpbsub[icent]->SetTextSize(0.05*1.3); } else { leg_ff_pbpbsub[icent] = new TLegend(0,0.697,0.27,0.92); // leg_ff_pbpbsub[icent]->SetTextSize(0.05*1.2); leg_ff_pbpbsub[icent]->SetTextSize(0.05*1.3); } leg_ff_pbpbsub[icent]->SetFillColor(0); leg_ff_pbpbsub[icent]->SetFillStyle(0); leg_ff_pbpbsub[icent]->SetTextFont(42); if(icent==0) { leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbdata_[icent],"PbPb #sqrt{s_{NN}}=5 TeV","p"); leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"Pythia+Hydjet","p"); } else if(icent==1) { // leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"#eta cone sub",""); leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"trk p_{T}>1 GeV, R < 0.3",""); leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"100>#gamma p_{T}>300 GeV",""); } else if(icent==2) { leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"0.3 < |#eta^{jet}| < 1.6",""); leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"p_{T}^{jet} > 40 GeV",""); } else { leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"",""); leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],"",""); } leg_ff_pbpbsub[icent]->AddEntry(clone_hgammaffxi_pbpbmc_[icent],Form("%s",cents[icent].data()),""); leg_ff_pbpbsub[icent]->Draw(); // c1_subpbpb[icent]->SaveAs("pbpbdata_pbpbmc_etaconesubtracted_45_gamma_100.png"); // Eta cone subtracted FF pbpbdata and pbpbmc } call->cd(1); TH2D * axis_dummy = new TH2D("axis_dummy","",1,0.01,4.99,1,0,yaxismax); gStyle->SetFrameLineColor(0); axis_dummy->UseCurrentStyle(); axis_dummy->Draw("FB BB A"); TLatex * ldndxi = new TLatex(0.4,0.5,"dN/d#xi"); ldndxi->SetTextSize(ldndxi->GetTextSize()*1.3); ldndxi->SetNDC(); ldndxi->SetTextAngle(90); TLatex * laxis[yaxismax]; for (int ilatex = 0; ilatex < yaxismax; ilatex++) { laxis[ilatex] = new TLatex(3.,ilatex-0.1,Form("%d",ilatex)); laxis[ilatex]->SetTextSize(laxis[ilatex]->GetTextSize()*1.3); laxis[ilatex]->Draw(); } ldndxi->Draw(); // call->cd(1); // TLatex * ldndxi = new TLatex(0.7,0.5,"dN/d#xi"); // ldndxi->SetTextSize(ldndxi->GetTextSize()*1.2); // ldndxi->SetNDC(); // ldndxi->SetTextAngle(90); // ldndxi->Draw(); }
void makePlotTrigger2D(){ string whichdata = "SingleMuon"; //string whichdata = "DoubleMuon"; map<string, TH2F*> histos2D; vector<string> histonames2Dtag; histonames2Dtag.clear(); vector<string> histonames2Dprobe; histonames2Dprobe.clear(); vector<string> histonames2Deff; histonames2Deff.clear(); histonames2Dtag.push_back("Trigger_PureIsoMu20Tag_EtavsPhi"); histonames2Dprobe.push_back("Trigger_PureIsoMu20Probe_EtavsPhi"); histonames2Deff.push_back("Trigger_PureIsoMu20Eff_EtavsPhi"); histonames2Dtag.push_back("Trigger_IsoTkMu20Tag_EtavsPhi"); histonames2Dprobe.push_back("Trigger_IsoTkMu20Probe_EtavsPhi"); histonames2Deff.push_back("Trigger_IsoTkMu20Eff_EtavsPhi"); string outputdir = "../plots/first_20150727/"; string inputdir = "../rootfiles/first_20150727/"; TString fdataname = (inputdir+"Histos3Trigger_"+whichdata+".root"); TFile *fdata = TFile::Open(fdataname.Data()); TCanvas *c1 = new TCanvas("c1", "c1",247,22,600,600); gStyle->SetOptFit(1); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); //c1->Range(-350.6494,-288.4615,1597.403,1634.615); c1->SetFillColor(0); c1->SetBorderMode(0); c1->SetBorderSize(2); //c1->SetLogz(); c1->SetTickx(1); c1->SetTicky(1); c1->SetLeftMargin(0.14); c1->SetRightMargin(0.19); c1->SetTopMargin(0.08); c1->SetBottomMargin(0.14); c1->SetFrameBorderMode(0); c1->SetFrameFillStyle(0); c1->SetFrameBorderMode(0); c1->SetFrameFillStyle(0); c1->SetFrameBorderMode(0); for(unsigned int i = 0; i<histonames2Dtag.size(); ++i){ for(unsigned int j = 0; j<6;++j){ string prefix = ""; if(j==1) prefix = "Run251244_"; else if(j==2) prefix = "Run251251_"; else if(j==3) prefix = "Run251252_"; else if(j==4) prefix = "RunPre251561_"; else if(j>=5) prefix = "RunAfter251561_"; string mapnamet = prefix + histonames2Dtag[i]+"_"+whichdata; if(histos2D.count(mapnamet) == 0 ) histos2D[mapnamet] = (TH2F*)fdata->Get(mapnamet.c_str()); histos2D[mapnamet]->Rebin2D(2,2); string mapnamep = prefix + histonames2Dprobe[i]+"_"+whichdata; if(histos2D.count(mapnamep) == 0 ) histos2D[mapnamep] = (TH2F*)fdata->Get(mapnamep.c_str()); histos2D[mapnamep]->Rebin2D(2,2); string mapnamee = prefix + histonames2Deff[i]+"_"+whichdata; if(histos2D.count(mapnamee) == 0 ) histos2D[mapnamee] = (TH2F*)histos2D[mapnamep]->Clone(mapnamee.c_str()); histos2D[mapnamee]->Divide(histos2D[mapnamet]); histos2D[mapnamee]->GetXaxis()->SetTitle("#eta"); histos2D[mapnamee]->GetYaxis()->SetTitle("#phi"); histos2D[mapnamee]->GetXaxis()->SetLabelFont(42); // histos2D[mapnamee]->GetXaxis()->SetLabelOffset(1.2); histos2D[mapnamee]->GetXaxis()->SetLabelSize(0.04); histos2D[mapnamee]->GetXaxis()->SetTitleSize(0.05); histos2D[mapnamee]->GetXaxis()->SetTitleOffset(1.2); histos2D[mapnamee]->GetXaxis()->SetTitleFont(42); histos2D[mapnamee]->GetYaxis()->SetLabelFont(42); // histos2D[mapnamee]->GetYaxis()->SetLabelOffset(0.007); histos2D[mapnamee]->GetYaxis()->SetLabelSize(0.04); histos2D[mapnamee]->GetYaxis()->SetTitleSize(0.05); histos2D[mapnamee]->GetYaxis()->SetTitleOffset(1.35); histos2D[mapnamee]->GetYaxis()->SetTitleFont(42); c1->cd(); histos2D[mapnamee]->Draw("COLZ"); TLatex * tex = new TLatex(0.253356,0.95,mapnamee.c_str()); tex->SetNDC(); tex->SetTextFont(42); tex->SetTextSize(0.04181185); tex->SetLineWidth(2); tex->Draw(); c1->Update(); string outname = outputdir + whichdata + "/" + mapnamee + ".pdf"; c1->SaveAs(outname.c_str()); c1->Clear(); delete tex; } } }
// // Principal code segment // void pi0_HadCorrelations_Projections(const int iMultOption = 4, const bool peakRegionFile = true, const bool sideBandFile = false, const bool usePbPbData = false, const bool usepPbData = false, const bool useSimReco = false, const bool useGenEvts = true, const bool useV1V2Fit = true, const bool useV2FitOnly = false) { // // Control Parameter Instructions // iMultOption = 0, 1, 2, 3, 4 controls the track multiplicity selection [120-150, 150-195, 185-220, 220-260, 120-260] // peakRegionFile = true means that the input file inputTrue.root will be used // it is assumed that inputTrue.root is soft-linked to a peak-region output ROOT file from the EDM // this could be either a PbPb, or a pPb, or a pPb simulation ROOT file from the EDM // // sideBandFile = true is the same logic for a side-band output ROOT file from the EDM analyzer // the inputSide.root is to be soft-lined to a side-band output ROOT file from the EDM // // only one of peakRegionFile or sideBandFile can be true // // usePbPbData, usepPbData, useSimReco, or useGenEvts indicate which type of data or MC is being processed // // for the pPb data and the Sim data choices, there are 8 pT bins // for the PbPb data there are 6 pT bins // // // Output results // The macro produces two sets of plots: two-dimensional correlation and Fourier-fitted one-dimension // The macro produces an output text file, either PeakRegion_ijkMultlmn.txt or SideBand_ijkMultlmn.txt // the ijk and lmn are the track multiplicity limits determined by the iOption choice // if(sideBandFile && useGenEvts) { cerr << "\n\n Error in input parameters: cannot have a side-band file for generator events" << endl << endl; return; } int nPtBins = 8; const float _PbPb_ptMin[6] = {0.7, 1.0, 1.5, 2.0, 2.5, 3.0}; const float _PbPb_ptMax[6] = {1.0, 1.5, 2.0, 2.5, 3.0, 5.0}; const float _pPb_ptMin[8] = {0.7, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0}; const float _pPb_ptMax[8] = {1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 5.0}; float _ptMin[8] = {0.7, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0}; float _ptMax[8] = {1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 5.0}; bool goodDataSource = false; char *dataText = new char[200]; if(usePbPbData) { if(usepPbData || useSimReco || useGenEvts) { cerr << "\n Cannot only specify one data source as true" << endl; return; } nPtBins = 6; for(int kPt=0; kPt<nPtBins; kPt++) { _ptMin[kPt] = _PbPb_ptMin[kPt]; _ptMax[kPt] = _PbPb_ptMax[kPt]; } goodDataSource = true; cout << "\n Using PbPbData source with " << nPtBins << " pT bins" << endl; sprintf(dataText, "CMS PbPb #sqrt{s_{NN}}=2.76 TeV"); } if(usepPbData) { if(usePbPbData || useSimReco || useGenEvts) { cerr << "\n Cannot only specify one data source as true" << endl; return; } nPtBins = 8; for(int kPt=0; kPt<nPtBins; kPt++) { _ptMin[kPt] = _pPb_ptMin[kPt]; _ptMax[kPt] = _pPb_ptMax[kPt]; } goodDataSource = true; cout << "\n Using pPbData source with " << nPtBins << " pT bins" << endl; sprintf(dataText, "CMS pPb #sqrt{s_{NN}}=5.0 TeV"); } if(useSimReco) { if(usePbPbData || usepPbData || useGenEvts) { cerr << "\n Cannot only specify one data source as true" << endl; return; } nPtBins = 8; for(int kPt=0; kPt<nPtBins; kPt++) { _ptMin[kPt] = _pPb_ptMin[kPt]; _ptMax[kPt] = _pPb_ptMax[kPt]; } goodDataSource = true; cout << "\n Using SimData source with " << nPtBins << " pT bins" << endl; sprintf(dataText, "EPOS RECO pPb #sqrt{s_{NN}}=5.01 TeV"); } if(useGenEvts) { if(usePbPbData || usepPbData || useSimReco) { cerr << "\n Cannot only specify one data source as true" << endl; return; } if(!peakRegionFile) { cerr << "\n The peakRegionFile must be set to true when useGenEvts is true" << endl; return; } nPtBins = 8; for(int kPt=0; kPt<nPtBins; kPt++) { _ptMin[kPt] = _pPb_ptMin[kPt]; _ptMax[kPt] = _pPb_ptMax[kPt]; } goodDataSource = true; cout << "\n Using GenEvts source with " << nPtBins << " pT bins" << endl; sprintf(dataText, "EPOS GEN pPb #sqrt{s_{NN}}=5.01 TeV"); } if(!goodDataSource) { cerr << "\n The data source was not specified" << endl; return; } if(peakRegionFile && sideBandFile) { cerr << "\n Cannot have the peakRegionFile and the sideBandFile both set to true"<< endl; return; } if(!peakRegionFile && !sideBandFile) { cerr << "\n Cannot have the peakRegionFile and the sideBandFile both set to false"<< endl; return; } TCanvas *c1 = new TCanvas("c1","",900,900); Canvas(); c1->SetFillColor(0); c1->SetBorderMode(0); c1->SetBorderSize(2); c1->SetTickx(1); c1->SetTicky(1); c1->SetFrameFillStyle(0); c1->SetFrameBorderMode(0); c1->SetTopMargin(0.05); c1->SetBottomMargin(0.1); c1->SetLeftMargin(0.1742581); c1->SetRightMargin(0.05); c1->SetTheta(50.61189); c1->SetPhi(40.90062); if(nPtBins == 8) c1->Divide(3,3); if(nPtBins == 6) c1->Divide(3,2); TCanvas *c2 = new TCanvas("c2", "c2",900,900); gStyle->SetOptFit(0); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); c2->Range(0,0,1,1); c2->SetFillColor(0); c2->SetBorderMode(0); c2->SetBorderSize(2); //c1->SetLogy(); c2->SetTickx(1); c2->SetTicky(1); c2->SetLeftMargin(0.16); c2->SetRightMargin(0.16); c2->SetTopMargin(0.05); c2->SetBottomMargin(0.13); c2->SetFrameFillStyle(0); c2->SetFrameBorderMode(0); if(nPtBins == 8) c2->Divide(3,3); if(nPtBins == 6) c2->Divide(3,2); TH1::SetDefaultSumw2(); char *inputFileName = new char[200]; if(peakRegionFile) { sprintf(inputFileName, "inputTrue.root"); } if(sideBandFile) { sprintf(inputFileName, "inputSide.root"); } TFile *_fpPbData = new TFile(inputFileName, "r"); if(!_fpPbData) { cerr << "\n Cannot find input file " << inputFileName << endl; return; } else { cout << "\n Found input file " << inputFileName << endl; } TH1F * _hEvent_pPb; double _nEvents_pPb; TH2D *_hSignal_pPb[8]; TH2D *_hBackground_pPb[8]; char *multText = new char[10]; char *eventText = new char[100]; char *signalText = new char[100]; char *bkgText = new char[100]; int lowMultiplicity = 120; int highMultiplicity = 150; char *multiplicityText = new char[200]; bool goodMultOption = false; if(iMultOption == 0) { sprintf(multText, "EcalFlowNtpMult100"); goodMultOption = true; sprintf(multiplicityText, "120 #leq N_{track}^{offline} < 150"); } if(iMultOption == 1) { sprintf(multText, "EcalFlowNtpMult130"); lowMultiplicity = 150; highMultiplicity = 185; goodMultOption = true; sprintf(multiplicityText, "150 #leq N_{track}^{offline} < 185"); } if(iMultOption == 2) { sprintf(multText, "EcalFlowNtpMult160"); lowMultiplicity = 185; highMultiplicity = 220; goodMultOption = true; sprintf(multiplicityText, "185 #leq N_{track}^{offline} < 220"); } if(iMultOption == 3) { sprintf(multText, "EcalFlowNtpMult190"); lowMultiplicity = 220; highMultiplicity = 260; goodMultOption = true; sprintf(multiplicityText, "220 #leq N_{track}^{offline} < 260"); } if(iMultOption == 4) { sprintf(multText, "EcalFlowNtp"); lowMultiplicity = 120; highMultiplicity = 260; goodMultOption = true; sprintf(multiplicityText, "120 #leq N_{track}^{offline} < 260"); } if(goodMultOption) { if(!useGenEvts) { sprintf(eventText, "%s/ChargedParticles/tHPTracks_", multText); sprintf(signalText, "%s/pi0HadCorrFunc/hSignalPtBin", multText); sprintf(bkgText, "%s/pi0HadCorrFunc/hBackgroundPtBin", multText); } else { sprintf(eventText, "%s/ChargedParticles/tHPTracks_", multText); sprintf(signalText, "%s/pi0HadCorrFunc/hGenSignalPtBin", multText); sprintf(bkgText, "%s/pi0HadCorrFunc/hGenBackgroundPtBin", multText); } } else { cerr << "\n Multiplicity option " << iMultOption << " is not valid" << endl; return; } // safety check ofstream myfile; char *myFileName = new char[200]; if(peakRegionFile) { sprintf(myFileName, "PeakRegion_%dMult%d.txt", lowMultiplicity, highMultiplicity); } if(sideBandFile) { sprintf(myFileName, "SideBand_%dMult%d.txt", lowMultiplicity, highMultiplicity); } cout << "\n Opening output text file " << myFileName << endl; myfile.open (myFileName); cout << "\n eventText = " << eventText; cout << "\n signalText= " << signalText; cout << "\n signalText = " << bkgText; cout << endl; char *_SignalHistoName1 = new char[200]; char *_BkgHistoName1 = new char[200]; // // Why are these numbers hard=coded here? // float _SignalFraction[8] = {0.09, 0.23, 0.44, 0.59, 0.66, 0.71, 0.73, 0.74}; _hEvent_pPb = (TH1F*)_fpPbData->Get(eventText); if(!_hEvent_pPb) { cerr << "\n Unable to find hEvent_pPb with name " << eventText << endl; return; } _nEvents_pPb = _hEvent_pPb->Integral(); cout << "\n Number of events _nEvents_pPb = " << _nEvents_pPb << "; setting up 8 histogram names" << endl; for(int iCount=0; iCount<8; ++iCount) { sprintf(_SignalHistoName1, "%s%d", signalText, iCount); sprintf(_BkgHistoName1, "%s%d", bkgText, iCount); cout << " iCount = " << iCount << '\t' << "Signal name = " << _SignalHistoName1<<endl; cout << " iCount = " << iCount << '\t' << "Background name = " << _BkgHistoName1<<endl; _hSignal_pPb[iCount] = (TH2D*)_fpPbData->Get(_SignalHistoName1); if(!_hSignal_pPb[iCount]) { cerr << "\n Unable to find _hSignal_pPb[iCount]" << endl; return; } _hBackground_pPb[iCount] = (TH2D*)_fpPbData->Get(_BkgHistoName1); if(!_hBackground_pPb[iCount]) { cerr << "\n Unable to find _hBackground_pPb[iCount]" << endl; return; } } // loop over 8 histogram bins double _etabinwidth = _hSignal_pPb[0]->GetXaxis()->GetBinWidth(1); double _phibinwidth = _hSignal_pPb[0]->GetYaxis()->GetBinWidth(1); for(long iCount=0; iCount<nPtBins; ++iCount) { _hSignal_pPb[iCount]->Divide(_hBackground_pPb[iCount]); int _x0 = _hBackground_pPb[iCount]->GetXaxis()->FindBin(0.0); int _y0 = _hBackground_pPb[iCount]->GetYaxis()->FindBin(0.0); double _B0 = _hBackground_pPb[iCount]->GetBinContent(_x0,_y0); _hSignal_pPb[iCount]->Scale(_B0/(_nEvents_pPb)); _hSignal_pPb[iCount]->Scale(1.0/_etabinwidth/_phibinwidth); c1->cd(iCount+1); _hSignal_pPb[iCount]->GetXaxis()->SetRange(5,29); _hSignal_pPb[iCount]->GetXaxis()->SetTitle("#Delta#eta"); _hSignal_pPb[iCount]->GetXaxis()->SetRange(5,29); _hSignal_pPb[iCount]->GetXaxis()->CenterTitle(true); _hSignal_pPb[iCount]->GetXaxis()->SetLabelFont(42); _hSignal_pPb[iCount]->GetXaxis()->SetLabelSize(0.035); _hSignal_pPb[iCount]->GetXaxis()->SetTitleSize(0.05); _hSignal_pPb[iCount]->GetXaxis()->SetTitleOffset(1.38); _hSignal_pPb[iCount]->GetXaxis()->SetTitleFont(42); _hSignal_pPb[iCount]->GetYaxis()->SetTitle("#Delta#phi"); _hSignal_pPb[iCount]->GetYaxis()->CenterTitle(true); _hSignal_pPb[iCount]->GetYaxis()->SetLabelFont(42); _hSignal_pPb[iCount]->GetYaxis()->SetLabelSize(0.035); _hSignal_pPb[iCount]->GetYaxis()->SetTitleSize(0.05); _hSignal_pPb[iCount]->GetYaxis()->SetTitleOffset(1.59); _hSignal_pPb[iCount]->GetYaxis()->SetTitleFont(42); _hSignal_pPb[iCount]->GetZaxis()->SetTitle("#frac{1}{N_{trig}} #frac{d^{2}N^{pair}}{d#Delta#etad#Delta#phi}"); _hSignal_pPb[iCount]->GetZaxis()->SetLabelFont(42); _hSignal_pPb[iCount]->GetZaxis()->SetLabelSize(0.035); _hSignal_pPb[iCount]->GetZaxis()->SetTitleSize(0.035); _hSignal_pPb[iCount]->GetZaxis()->SetTitleOffset(2.33); _hSignal_pPb[iCount]->GetZaxis()->SetTitleFont(42); _hSignal_pPb[iCount]->GetZaxis()->SetNdivisions(505); _hSignal_pPb[iCount]->Draw("SURF1"); TLatex * tex = new TLatex(-0.8847018,0.9364877,Form("%5.1f < p_{T} < %5.1f (GeV/c)",_ptMin[iCount],_ptMax[iCount])); tex->SetTextSize(0.06); tex->Draw(); } // loop over 8 histogram bins cout <<"\n Now drawing the projections..." << endl; float etaMin = 2.0; float etaMax = 3.6; TString _Name = "projClone"; TString _Name2 = "_pi0HadProj"; TString _Name4 = "FourierDecompose"; TString _Name1, _Name3, _Name5; TH2D *_projCorrFunc[9]; TH1D * _pi0HadCorrProj[9]; TF1 *_FourierDecompose[9]; const int n = 9; double _Parameter0[n]; double _Par0Error[n]; double _Parameter2[n]; double _Par2Error[n]; double _Ratio[n]; double _Error[n]; for(long iCount=0; iCount<nPtBins; ++iCount) { _Name1 = _Name + iCount; _Name3 = _Name2 + iCount; _Name5 = _Name4 + iCount; _projCorrFunc[iCount] = (TH2D*) _hSignal_pPb[iCount]->Clone(_Name1); Int_t etabin10m=_projCorrFunc[iCount]->GetXaxis()->FindBin(etaMin+0.01); Int_t etabin10p=_projCorrFunc[iCount]->GetXaxis()->FindBin(etaMax-0.01); _pi0HadCorrProj[iCount] = (TH1D *) _projCorrFunc[iCount]->ProjectionY(_Name3,etabin10m,etabin10p,"e"); _pi0HadCorrProj[iCount]->GetXaxis()->SetRange(8,24); c2->cd(iCount+1); _pi0HadCorrProj[iCount]->SetMarkerColor(4); _pi0HadCorrProj[iCount]->SetMarkerStyle(20); _pi0HadCorrProj[iCount]->SetMarkerSize(1.0); _pi0HadCorrProj[iCount]->GetXaxis()->SetTitle("#Delta#phi"); _pi0HadCorrProj[iCount]->GetXaxis()->SetLabelFont(42); _pi0HadCorrProj[iCount]->GetXaxis()->SetTitleSize(0.06); _pi0HadCorrProj[iCount]->GetXaxis()->SetTitleOffset(0.67); _pi0HadCorrProj[iCount]->GetXaxis()->SetTitleFont(42); _pi0HadCorrProj[iCount]->GetYaxis()->SetTitle("Associated yield"); _pi0HadCorrProj[iCount]->GetYaxis()->SetLabelFont(42); _pi0HadCorrProj[iCount]->GetYaxis()->SetTitleSize(0.06); _pi0HadCorrProj[iCount]->GetYaxis()->SetTitleOffset(0.77); _pi0HadCorrProj[iCount]->GetYaxis()->SetTitleFont(42); _pi0HadCorrProj[iCount]->GetZaxis()->SetLabelFont(42); _pi0HadCorrProj[iCount]->GetZaxis()->SetLabelSize(0.035); _pi0HadCorrProj[iCount]->GetZaxis()->SetTitleSize(0.035); _pi0HadCorrProj[iCount]->GetZaxis()->SetTitleFont(42); float maximumHistogramValue = _pi0HadCorrProj[iCount]->GetMaximum(); float minimumHistogramValue = _pi0HadCorrProj[iCount]->GetMinimum(); _pi0HadCorrProj[iCount]->SetMaximum(maximumHistogramValue + 0.60*(maximumHistogramValue - minimumHistogramValue)); _pi0HadCorrProj[iCount]->Draw("E1"); (c2->cd(iCount+1))->SetGrid(); if(useV1V2Fit) { _FourierDecompose[iCount] = new TF1(_Name5, v1v2Fit, -1.4, 4.88, 3); _FourierDecompose[iCount]->SetParNames("Norm","v1", "v2"); } if(useV2FitOnly) { _FourierDecompose[iCount] = new TF1(_Name5, v2Fit, -1.4, 4.88, 2); _FourierDecompose[iCount]->SetParNames("Norm","v2"); } if(!useV2FitOnly && !useV1V2Fit) { _FourierDecompose[iCount] = new TF1(_Name5, Function, -1.4, 4.88, 4); _FourierDecompose[iCount]->SetParNames("Par0","Par1","Par2","Par3"); } _pi0HadCorrProj[iCount]->Fit(_Name5, "", "", -1.4, 4.84); double v1 = 0; double v1Error = 0; double v3 = 0; double v3Error = 0; if(useV1V2Fit) { v1 = ((_FourierDecompose[iCount]->GetParameter(1))/0.232); v1Error = ((_FourierDecompose[iCount]->GetParError(1))/0.232); _Ratio[iCount] = (_FourierDecompose[iCount]->GetParameter(2))/0.232; _Error[iCount] = (_FourierDecompose[iCount]->GetParError(2))/0.232; } // using a v1 + v2 fit function if(useV2FitOnly) { _Ratio[iCount] = (_FourierDecompose[iCount]->GetParameter(1))/0.232; _Error[iCount] = (_FourierDecompose[iCount]->GetParError(1))/0.232; } // using a pure v2 fit function if(!useV2FitOnly && !useV1V2Fit) { _Parameter0[iCount] = _FourierDecompose[iCount]->GetParameter(0); _Par0Error[iCount] = _FourierDecompose[iCount]->GetParError(0); _Parameter2[iCount] = _FourierDecompose[iCount]->GetParameter(2); _Par2Error[iCount] = _FourierDecompose[iCount]->GetParError(2); v3 = ((_FourierDecompose[iCount]->GetParameter(3))/0.232)/_Parameter0[iCount]; v3Error = ((_FourierDecompose[iCount]->GetParError(3))/0.232)/_Parameter0[iCount]; _Ratio[iCount] = _Parameter2[iCount]/_Parameter0[iCount]; _Ratio[iCount] /= 0.232; // v2 of the EPOS generator charged particles, 0.3 - 3.0 GeV/c, according to Z. Chen (May 4, 2014, K0-short analysis) _Error[iCount] = _Ratio[iCount]*(sqrt((_Par2Error[iCount]/_Parameter2[iCount])*(_Par2Error[iCount]/_Parameter2[iCount]) + (_Par0Error[iCount]/_Parameter0[iCount])*(_Par0Error[iCount]/_Parameter0[iCount]) + (0.0001364/0.08609)*(0.0001364/0.08609))); } // using Monika's fitting function TLegend *legend = new TLegend(0.15, 0.65, 0.88, 0.85); char *legendHeader = new char[200]; sprintf(legendHeader, "%s, %s", dataText, multiplicityText); legend->SetHeader(legendHeader); legend->SetTextSize(0.04); legend->SetTextColor(kBlue); char *ptRangeText = new char[200]; if(sideBandFile) { sprintf(ptRangeText, "Bkg: %4.1f < p_{T} < %4.1f (GeV/c)", _ptMin[iCount], _ptMax[iCount]); } if(peakRegionFile) { sprintf(ptRangeText, "Peak for: %4.1f < p_{T} < %4.1f (GeV/c)", _ptMin[iCount], _ptMax[iCount]); } char *fitResults = new char[200]; if(useV1V2Fit) { sprintf(fitResults, "v_{2} = %4.3f #pm %4.3f, v_{1} = %4.3f #pm %4.3f",_Ratio[iCount], _Error[iCount], v1, v1Error); } if(useV2FitOnly) { sprintf(fitResults, "v_{2} = %4.3f #pm %4.3f (pure v_{2} fit)",_Ratio[iCount], _Error[iCount]); } if(!useV2FitOnly && !useV1V2Fit) { sprintf(fitResults, "v_{2} = %4.3f #pm %4.3f, v_{3} = %4.3f #pm %4.3f",_Ratio[iCount], _Error[iCount], v3, v3Error); } legend->AddEntry(_Name5, fitResults, "l"); legend->AddEntry((TObject*)0, ptRangeText, ""); legend->Draw(); } // loop over pT bins cout << "\n Now writing to the output text file " << myFileName << endl; cout << "------------------------****-------------------" << endl; for(long iCount=0; iCount<8; ++iCount) { cout << "Final v2(pi0) ["<< iCount << "] = " << _Ratio[iCount] << '\t' << _Error[iCount] << '\t' << _Error[iCount]/_SignalFraction[iCount] << endl; myfile << _Ratio[iCount] << '\t' << _Error[iCount] << endl; } cout <<"------------------------****-------------------" << endl; myfile.close(); }
void PostProcessQAMultistrange(Int_t icasType = 0, // 0) Xi- 1) Xi+ 2) Omega- 3) Omega+ Int_t collidingsystem = 2, // 0) PbPb 1) pp 2) pPb Bool_t isMC = kTRUE, // kTRUE-->MC and kFALSE-->Exp. Char_t *fileDir = ".", // Input file directory Char_t *filein = "AnalysisResults.root" // Input file name ) { //___________________ //DEFINE DRAW OPTIONS gStyle->SetOptStat(1110); gStyle->SetOptStat(kFALSE); gStyle->SetOptTitle(kFALSE); gStyle->SetFrameLineWidth(2.5); gStyle->SetCanvasColor(0); gStyle->SetPadColor(0); gStyle->SetHistLineWidth(2.5); gStyle->SetLabelSize(0.05, "x"); gStyle->SetLabelSize(0.05, "y"); gStyle->SetTitleSize(0.05, "x"); gStyle->SetTitleSize(0.05, "y"); gStyle->SetTitleOffset(1.1, "x"); gStyle->SetPadBottomMargin(0.14); //_______________________ //SOURCE USEFUL LIBRARIES gSystem->Load("libANALYSIS.so"); gSystem->Load("libANALYSISalice.so"); gSystem->Load("libCORRFW.so"); //_________________________________ //SOURCE THE FILE AND THE CONTAINER TFile *f1 = new TFile(Form("%s/%s",fileDir,filein)); AliCFContainer *cf = (AliCFContainer*) (f1->Get("PWGLFStrangeness.outputCheckCascade/fCFContCascadeCuts")); //____________ //DEEFINE TEXT TLatex* t1 = new TLatex(0.6,0.55,"#color[3]{OK!!}"); t1->SetTextSize(0.1); t1->SetNDC(); TLatex* t2 = new TLatex(0.6,0.55,"#color[2]{NOT OK!!}"); t2->SetTextSize(0.1); t2->SetNDC(); t2->SetTextColor(2); TLatex* tcasc; if (icasType == 0) tcasc = new TLatex(0.8,0.7,"#color[1]{#Xi^{-}}"); else if (icasType == 1) tcasc = new TLatex(0.8,0.7,"#color[1]{#Xi^{+}}"); else if (icasType == 2) tcasc = new TLatex(0.8,0.7,"#color[1]{#Omega^{-}}"); else if (icasType == 3) tcasc = new TLatex(0.8,0.7,"#color[1]{#Omega^{+}}"); tcasc->SetTextSize(0.2); tcasc->SetNDC(); tcasc->SetTextColor(2); TLatex* tpdgmass; if (icasType == 0) tpdgmass = new TLatex(0.55,0.7,"#color[1]{PDG mass: 1.321 GeV/c^{2}}"); else if (icasType == 1) tpdgmass = new TLatex(0.55,0.7,"#color[1]{PDG mass: 1.321 GeV/c^{2}}"); else if (icasType == 2) tpdgmass = new TLatex(0.55,0.7,"#color[1]{PDG mass: 1.672 GeV/c^{2}}"); else if (icasType == 3) tpdgmass = new TLatex(0.55,0.7,"#color[1]{PDG mass: 1.672 GeV/c^{2}}"); tpdgmass->SetTextSize(0.07); tpdgmass->SetNDC(); tpdgmass->SetTextColor(2); //________________________________ //DEFINE 1st CANVAS AND DRAW PLOTS TCanvas *c1 = new TCanvas("c1","",1200,800); c1->Divide(2,3); //Pad 1: DCA cascade daughters c1->cd(1); gPad->SetLogy(); TH1D *hvar0 = cf->ShowProjection(0,icasType); hvar0->Draw("histo"); Double_t x0; if (collidingsystem == 0) x0 = 0.3; else if (collidingsystem == 1) x0 = 2.0; else if (collidingsystem == 2) x0 = 2.0; TLine *line0 = new TLine(x0,0.,x0,hvar0->GetBinContent(hvar0->GetMaximumBin())); line0->SetLineColor(kRed); line0->SetLineStyle(9); line0->SetLineWidth(2.0); line0->Draw("same"); Bool_t check_0 = checkOverTheLimit(hvar0, x0); if (check_0) { cout<<"The cut is OK!!"<<endl; t1->Draw(); } else { cout<<"The cut is NOT OK!!"<<endl; t2->Draw(); } tcasc->Draw(); //Pad 2: Bachelor IP to PV c1->cd(2); gPad->SetLogy(); TH1D *hvar1 = cf->ShowProjection(1,icasType); hvar1->GetXaxis()->SetRangeUser(0.,0.24); hvar1->Draw("histo"); Double_t x1; if (collidingsystem == 0) x1 = 0.03; else if (collidingsystem == 1) x1 = 0.01; else if (collidingsystem == 2) x1 = 0.03; TLine *line1 = new TLine(x1,0.,x1,hvar1->GetBinContent(hvar1->GetMaximumBin())); line1->SetLineColor(kRed); line1->SetLineStyle(9); line1->SetLineWidth(2.0); line1->Draw("same"); Bool_t check_1 = checkUnderTheLimit(hvar1, x1); if (check_1) { cout<<"The cut is OK!!"<<endl; t1->Draw(); } else { cout<<"The cut is NOT OK!!"<<endl; t2->Draw(); } //Pad 3: Cascade cosine of Pointing Angle c1->cd(3); gPad->SetLogy(); TH1D *hvar2 = cf->ShowProjection(2,icasType); Double_t max2 = hvar2->GetBinContent(hvar2->GetMaximumBin()); hvar2->GetYaxis()->SetRangeUser(0.01,max2*1.5); hvar2->Draw("histo"); Double_t x2; if (collidingsystem == 0) x2 = 0.999; else if (collidingsystem == 1) x2 = 0.98; else if (collidingsystem == 2) x2 = 0.95; TLine *line2 = new TLine(x2,0.,x2,hvar2->GetBinContent(hvar2->GetMaximumBin())); line2->SetLineColor(kRed); line2->SetLineStyle(9); line2->SetLineWidth(2.0); line2->Draw("same"); line1->Draw("same"); Bool_t check_2 = checkUnderTheLimit(hvar2, x2); if (check_2) { cout<<"The cut is OK!!"<<endl; t1->Draw(); } else { cout<<"The cut is NOT OK!!"<<endl; t2->Draw(); } //Pad 4: Cascade radius of fiducial volume c1->cd(4); gPad->SetLogy(); TH1D *hvar3 = cf->ShowProjection(3,icasType); hvar3->GetXaxis()->SetRangeUser(0.,3.8); hvar3->Draw("histo"); Double_t x3; if (collidingsystem == 0) x3 = 0.9; else if (collidingsystem == 1) x3 = 0.2; else if (collidingsystem == 2) x3 = 0.4; TLine *line3 = new TLine(x3,0.,x3,hvar3->GetBinContent(hvar3->GetMaximumBin())); line3->SetLineColor(kRed); line3->SetLineStyle(9); line3->SetLineWidth(2.0); line3->Draw("same"); Bool_t check_3 = checkUnderTheLimit(hvar3, x3); if (check_3) { cout<<"The cut is OK!!"<<endl; t1->Draw(); } else { cout<<"The cut is NOT OK!!"<<endl; t2->Draw(); } //Pad 5: Invariant mass Lambda c1->cd(5); TH1D *hvar4 = cf->ShowProjection(4,icasType); hvar4->Draw("histo"); Double_t x41; if (collidingsystem < 2) x41 = 1.116 + 0.008; else if (collidingsystem == 2) x41 = 1.116 + 0.010; TLine *line41 = new TLine(x41,0.,x41,hvar4->GetBinContent(hvar4->GetMaximumBin())); line41->SetLineColor(kRed); line41->SetLineStyle(9); line41->SetLineWidth(2.0); line41->Draw("same"); Double_t x42; if (collidingsystem < 2) x42 = 1.115 - 0.008; else if (collidingsystem == 2) x42 = 1.115 - 0.010; TLine *line42 = new TLine(x42,0.,x42,hvar4->GetBinContent(hvar4->GetMaximumBin())); line42->SetLineColor(kRed); line42->SetLineStyle(9); line42->SetLineWidth(2.0); line42->Draw("same"); // for (Int_t i = 0; i < hvar4->GetNbinsX()+1; i++) { // cout<<"Content bin: "<<i<<": "<<hvar4->GetBinContent(i)<<endl; // cout<<"Bin low edge: "<<hvar4->GetBinLowEdge(i)<<endl; // cout<<"Bin high edge: "<<hvar4->GetBinLowEdge(i+1)<<endl; // } // cout<<"Low check limit: "<<x42<<endl; // cout<<"High check limit: "<<x41<<endl; Bool_t check_4_1 = checkUnderTheLimit(hvar4, x42); Bool_t check_4_2 = checkOverTheLimit(hvar4, x41); if (check_4_1 && check_4_2) { cout<<"The cut is OK!!"<<endl; t1->Draw(); } else { cout<<"The cut is NOT OK!!"<<endl; t2->Draw(); } //Pad 6: DCA V0 daughters c1->cd(6); gPad->SetLogy(); TH1D *hvar5 = cf->ShowProjection(5,icasType); hvar5->Draw("histo"); Double_t x5; if (collidingsystem == 0) x5 = 1.0; else if (collidingsystem == 1) x5 = 1.5; else if (collidingsystem == 2) x5 = 2.0; TLine *line5 = new TLine(x5,0.,x5,hvar5->GetBinContent(hvar5->GetMaximumBin())); line5->SetLineColor(kRed); line5->SetLineStyle(9); line5->SetLineWidth(2.0); line5->Draw("same"); Bool_t check_5 = checkOverTheLimit(hvar5, x5); if (check_5) { cout<<"The cut is OK!!"<<endl; t1->Draw(); } else { cout<<"The cut is NOT OK!!"<<endl; t2->Draw(); } c1->SaveAs("fig_lf_Multistrange.pdf("); //________________________________ //DEFINE 2nd CANVAS AND DRAW PLOTS TCanvas *c2 = new TCanvas("c2","",1200,800); c2->Divide(2,3); //Pad 1: V0 cosine of Pointing Angle to PV c2->cd(1); gPad->SetLogy(); TH1D *hvar6 = cf->ShowProjection(6,icasType); Double_t max6 = hvar6->GetBinContent(hvar6->GetMaximumBin()); hvar6->GetYaxis()->SetRangeUser(0.01,max6*1.5); hvar6->Draw("histo"); //Pad 2: Min V0 Radius Fid. Vol. c2->cd(2); gPad->SetLogy(); TH1D *hvar7 = cf->ShowProjection(7,icasType); hvar7->GetXaxis()->SetRangeUser(0.,3.0); hvar7->Draw("histo"); Double_t x7; if (collidingsystem == 0) x7 = 0.9; else if (collidingsystem == 1) x7 = 0.2; else if (collidingsystem == 2) x7 = 0.4; TLine *line7 = new TLine(x7,0.,x7,hvar7->GetBinContent(hvar7->GetMaximumBin())); line7->SetLineColor(kRed); line7->SetLineStyle(9); line7->SetLineWidth(2.0); line7->Draw("same"); Bool_t check_7 = checkUnderTheLimit(hvar7, x7); if (check_7) { cout<<"The cut is OK!!"<<endl; t1->Draw(); } else { cout<<"The cut is NOT OK!!"<<endl; t2->Draw(); } //Pad3: Min DCA V0 To PV c2->cd(3); gPad->SetLogy(); TH1D *hvar8 = cf->ShowProjection(8,icasType); hvar8->GetXaxis()->SetRangeUser(0.,0.3); hvar8->Draw("histo"); Double_t x8; if (collidingsystem == 0) x8 = 0.05; else if (collidingsystem == 1) x8 = 0.01; else if (collidingsystem == 2) x8 = 0.05; TLine *line8 = new TLine(x8,0.,x8,hvar8->GetBinContent(hvar8->GetMaximumBin())); line8->SetLineColor(kRed); line8->SetLineStyle(9); line8->SetLineWidth(2.0); line8->Draw("same"); Bool_t check_8 = checkUnderTheLimit(hvar8, x8); if (check_8) { cout<<"The cut is OK!!"<<endl; t1->Draw(); } else { cout<<"The cut is NOT OK!!"<<endl; t2->Draw(); } //Pad 4: Min DCA Pos To PV c2->cd(4); gPad->SetLogy(); TH1D *hvar9 = cf->ShowProjection(9,icasType); hvar9->GetXaxis()->SetRangeUser(0.,0.2); hvar9->Draw("histo"); Double_t x9; if (collidingsystem == 0) x9 = 0.1; else if (collidingsystem == 1) x9 = 0.05; else if (collidingsystem == 2) x9 = 0.02; TLine *line9 = new TLine(x9,0.,x9,hvar9->GetBinContent(hvar9->GetMaximumBin())); line9->SetLineColor(kRed); line9->SetLineStyle(9); line9->SetLineWidth(2.0); line9->Draw("same"); Bool_t check_9 = checkUnderTheLimit(hvar9, x9); if (check_9) { cout<<"The cut is OK!!"<<endl; t1->Draw(); } else { cout<<"The cut is NOT OK!!"<<endl; t2->Draw(); } //Pad 5: Min DCA Neg To PV c2->cd(5); gPad->SetLogy(); TH1D *hvar10 = cf->ShowProjection(10,icasType); hvar10->GetXaxis()->SetRangeUser(0.,0.2); hvar10->Draw("histo"); Double_t x10; if (collidingsystem == 0) x10 = 0.1; else if (collidingsystem == 1) x10 = 0.05; else if (collidingsystem == 2) x10 = 0.02; TLine *line10 = new TLine(x10,0.,x10,hvar10->GetBinContent(hvar10->GetMaximumBin())); line10->SetLineColor(kRed); line10->SetLineStyle(9); line10->SetLineWidth(2.0); line10->Draw("same"); Bool_t check_10 = checkUnderTheLimit(hvar10, x10); if (check_10) { cout<<"The cut is OK!!"<<endl; t1->Draw(); } else { cout<<"The cut is NOT OK!!"<<endl; t2->Draw(); } //Pad 6: V0 cosine of Pointing Angle to Xi vtx c2->cd(6); gPad->SetLogy(); TH1D *hvar20 = cf->ShowProjection(18,icasType); Double_t max20 = hvar20->GetBinContent(hvar20->GetMaximumBin()); hvar20->GetYaxis()->SetRangeUser(0.01,max20*1.5); hvar20->Draw("histo"); c2->SaveAs("fig_lf_Multistrange.pdf"); //________________________________ //DEFINE 3rd CANVAS AND DRAW PLOTS TCanvas *c3 = new TCanvas("c3","",1200,800); c3->Divide(2,3); //Pad 1: InvMass c3->cd(1); TH1D *hvar12 = cf->ShowProjection(11+icasType/2,icasType); hvar12->Draw("histo"); tpdgmass->Draw(); TLine *linemass; if (icasType == 0) linemass = new TLine(1.32171,0.,1.32171,0.5*hvar12->GetBinContent(hvar12->GetMaximumBin())); else if (icasType == 1) linemass = new TLine(1.32171,0.,1.32171,0.5*hvar12->GetBinContent(hvar12->GetMaximumBin())); else if (icasType == 2) linemass = new TLine(1.67245,0.,1.67245,0.5*hvar12->GetBinContent(hvar12->GetMaximumBin())); else if (icasType == 3) linemass = new TLine(1.67245,0.,1.67245,0.5*hvar12->GetBinContent(hvar12->GetMaximumBin())); linemass->SetLineColor(kRed); linemass->SetLineStyle(1); linemass->SetLineWidth(2.0); linemass->Draw("same"); //Pad 2: Transverse momentum c3->cd(2); TH1D *hvar13 = cf->ShowProjection(13,icasType); hvar13->Draw("histo"); //Pad 3: Y c3->cd(3); TH1D *hvar14 = cf->ShowProjection(14+icasType/2,icasType); hvar14->Draw("histo"); //Pad 4: Cascade proper length c3->cd(4); TH1D *hvar18; hvar18 = cf->ShowProjection(16,icasType); hvar18->GetXaxis()->SetRangeUser(0.,90.); hvar18->Draw("histo"); //Pad 5: V0 proper length c3->cd(5); TH1D *hvar19; hvar19 = cf->ShowProjection(17,icasType); hvar19->GetXaxis()->SetRangeUser(0.,90.); hvar19->Draw("histo"); //Pad 6 // empty c3->SaveAs("fig_lf_Multistrange.pdf"); //________________________________ //DEFINE 4th CANVAS AND DRAW PLOTS TCanvas *c4 = new TCanvas("c4","",600,400); c4->Divide(2,1); //Pad1: invariant mass fit c4->cd(1); TH1D *hvar18 = cf->ShowProjection(11+icasType/2,icasType); hvar18->Draw("histo"); // - SOME PARAMETER VALUE Bool_t kfitgauss = kFALSE; Bool_t kfitleft = kFALSE; Bool_t kfitright = kFALSE; Int_t ptbinNarrowY = 0; if (icasType < 2) ptbinNarrowY = 10; // 6; else ptbinNarrowY = 3; // 2; // - SOME DEFINITIONS Float_t lowlimmass; Float_t uplimmass; Float_t lowgausslim; Float_t upgausslim; if (icasType==0||icasType==1) { lowlimmass=1.30; uplimmass=1.34; lowgausslim=1.312; upgausslim=1.332; } else { lowlimmass=1.645; uplimmass=1.70; lowgausslim=1.668; upgausslim=1.678; } TF1* fitinvmass = new TF1("fitinvmass","gaus(0)+pol2(3)",lowlimmass,uplimmass); fitinvmass->SetParName(0, "cnstntG"); fitinvmass->SetParName(1, "meanG"); fitinvmass->SetParName(2, "sigmaG"); fitinvmass->SetParLimits(0,0.,500000.); if (icasType==0||icasType==1) { fitinvmass->SetParameter(1, 1.32171); fitinvmass->SetParLimits(1, 1.31,1.33); fitinvmass->SetParLimits(2,0.001,0.005); } else { fitinvmass->SetParameter(1, 1.67245); fitinvmass->SetParLimits(1, 1.664,1.68); fitinvmass->SetParLimits(2,0.0008,0.006); } hvar18->Fit("fitinvmass","rimeN"); fitinvmass->SetLineColor(kRed); fitinvmass->Draw("same"); Float_t meanGauss = fitinvmass->GetParameter(1); Float_t sigmaGauss = fitinvmass->GetParameter(2); cout<<"Mean: "<<meanGauss<<endl; cout<<"Sigma: "<<sigmaGauss<<endl; //Pad2: Text c4->cd(2); Float_t refwidth = 0.002; if (icasType > 1) refwidth = 0.0025; TPaveText *pave1 = new TPaveText(0.05,0.3,0.95,0.5); pave1->SetFillColor(0); pave1->SetTextSize(0.04); pave1->SetTextAlign(12); if (icasType < 2) pave1->AddText("PDG mass: 1.32171 GeV/c^{2}"); else pave1->AddText("PDG mass: 1.67245 GeV/c^{2}"); pave1->AddText(Form("#color[1]{Mass form Fit: %.5f #pm %.5f GeV/c^{2}}",meanGauss,sigmaGauss)); if (sigmaGauss > refwidth - 0.0003 && sigmaGauss < refwidth + 0.0003) pave1->AddText("#color[3]{OK!! The width is compatible with standard.}"); else pave1->AddText("#color[2]{NOT OK!! Problem.}"); pave1->Draw(); cout<<" "<<refwidth - 0.0003<<"<"<<sigmaGauss<<"<"<<refwidth + 0.0003<<endl; c4->SaveAs("fig_lf_Multistrange.pdf"); //________________________________ //DEFINE 5th CANVAS AND DRAW PLOTS if (collidingsystem == 0 || collidingsystem == 2) { TCanvas *c5 = new TCanvas("c5","",600,720);//1200,270); //c5->Divide(2,1); //Pad 1: centrality c5->cd(1); TH1D *hvar16 = cf->ShowProjection(19,icasType); hvar16->Draw("histo"); //Pad 2: track multiplicity //c5->cd(2); //TH1D *hvar17 = cf->ShowProjection(20,icasType); //hvar17->Draw("histo"); if (!isMC) c5->SaveAs("fig_lf_Multistrange.pdf)"); else if (isMC) c5->SaveAs("fig_lf_Multistrange.pdf"); } //_______________________________ //CHECK ON MONTE CARLO PRODUCTION if (isMC) { AliCFContainer *cfMC = (AliCFContainer*) (f1->Get("PWGLFStrangeness.outputCheckCascade/fCFContCascadeMCgen")); //DEFINE 6th CANVAS AND DRAW PLOTS TCanvas *c6 = new TCanvas("c6","",1200,800); c6->Divide(2,3); //Pad 1: Total Momentum c6->cd(1); TH1D *hvar17 = cfMC->ShowProjection(0,icasType); hvar17->Draw("histo"); tcasc->Draw(); //Pad 2: Transverse Momentum c6->cd(2); TH1D *hvar18 = cfMC->ShowProjection(1,icasType); hvar18->Draw("histo"); //Pad 3: Rapidity (y) c6->cd(3); TH1D *hvar19 = cfMC->ShowProjection(2,icasType); hvar19->Draw("histo"); //Pad 4: Pseudo-rapidity (eta) c6->cd(4); TH1D *hvar20 = cfMC->ShowProjection(3,icasType); hvar20->Draw("histo"); //Pad 5: Theta c6->cd(5); TH1D *hvar21 = cfMC->ShowProjection(4,icasType); hvar21->Draw("histo"); //Pad 6: Phi c6->cd(6); TH1D *hvar22 = cfMC->ShowProjection(5,icasType); hvar22->Draw("histo"); c6->SaveAs("fig_lf_Multistrange.pdf)"); } }