double* IfitBin(TH1D* dataInput, TH1D* sigTemplate, TH1D* bkgTemplate) { // Start TFractionFitter double Spara(0), eSpara(0); double Bpara(0), eBpara(0); TObjArray *mc = new TObjArray(2); mc->Add(sigTemplate); mc->Add(bkgTemplate); TFractionFitter *fitTemplate = new TFractionFitter(dataInput, mc); fitTemplate->Constrain(0, 0.0, 1.0); fitTemplate->Constrain(1, 0.0, 1.0); int status = fitTemplate->Fit(); cout<<" Fitting status = "<<status<<endl; if (status == 0) { fitTemplate->GetResult(0, Spara, eSpara); fitTemplate->GetResult(1, Bpara, eBpara); cout<<" Fitting result = "<<endl; cout<<" Chi2 = "<<fitTemplate->GetChisquare()<<endl; cout<<" NDF = "<<fitTemplate->GetNDF()<<endl; cout<<" Prob = "<<fitTemplate->GetProb()<<endl; cout<<" Signal fraction = "<<Spara<<"; Error = "<<eSpara<<endl; cout<<" Background fraction = "<<Bpara<<"; Error = "<<eBpara<<endl; } TH1D *FitResultReal = (TH1D*)sigTemplate->Clone(); TH1D *FitResultFake = (TH1D*)bkgTemplate->Clone(); TH1D *FitResultAll = (TH1D*)dataInput->Clone(); FitResultReal->SetName("ResultReal"); FitResultFake->SetName("ResultFake"); FitResultAll->SetName("ResultAll"); FitResultReal->Scale(1./FitResultReal->Integral()*Spara*dataInput->Integral()); FitResultFake->Scale(1./FitResultFake->Integral()*Bpara*dataInput->Integral()); FitResultAll->Reset(); FitResultAll->Add(FitResultReal); FitResultAll->Add(FitResultFake); TCanvas *c1 = new TCanvas("c1", "", 600, 400); c1->cd(); FitResultAll->SetXTitle("#sigma_{i#etai#eta}"); FitResultAll->SetYTitle("Number of photons"); FitResultAll->SetMinimum(0); FitResultAll->SetMaximum(FitResultAll->GetMaximum()*1.4); FitResultAll->SetLineColor(1); FitResultAll->SetLineWidth(2); FitResultAll->Draw(); dataInput->SetMarkerStyle(21); dataInput->SetMarkerSize(0.7); dataInput->SetLineColor(1); dataInput->SetLineWidth(2); dataInput->Draw("PE1same"); FitResultReal->SetLineColor(2); FitResultReal->SetFillColor(2); FitResultReal->SetFillStyle(3002); FitResultReal->Draw("same"); FitResultFake->SetLineColor(4); FitResultFake->SetFillColor(4); FitResultFake->SetFillStyle(3004); FitResultFake->Draw("same"); TLegend *leg1 = new TLegend(0.5,0.5,0.9,0.85); char text[200]; leg1->SetFillColor(0); leg1->SetShadowColor(0); leg1->SetFillStyle(0); leg1->SetBorderSize(0); leg1->SetLineColor(0); sprintf(text,"Data: %5.1f events", dataInput->Integral()); leg1->AddEntry(dataInput, text, "pl"); sprintf(text,"Fitted: %5.1f events", FitResultAll->Integral()); leg1->AddEntry(FitResultAll, text, "l"); sprintf(text,"Signal %5.1f #pm %5.1f events", FitResultReal->Integral(), eSpara/Spara*FitResultReal->Integral()); leg1->AddEntry(FitResultReal, text, "f"); sprintf(text,"Background %5.1f #pm %5.1f events", FitResultFake->Integral(), eBpara/Bpara*FitResultFake->Integral()); leg1->AddEntry(FitResultFake, text, "f"); leg1->Draw(); return; }
void plotTurnOn(TTree* inttree, TString triggerpass, TString variable, TString varname, TString varlatex) { if(varname=="vtxprob") { BIN_MIN = 0; BIN_MAX = 1; } else if(varname=="ffls3d") { BIN_MIN = 0; BIN_MAX = 50; } else if(varname=="cosalpha") { BIN_MIN = 0.9; BIN_MAX = 1; } TH1D* hAll = new TH1D(Form("h%s_%s_All",triggerpass.Data(),varname.Data()),Form(";%s;Probability",varlatex.Data()),BIN_NUM,BIN_MIN,BIN_MAX); inttree->Project(Form("h%s_%s_All",triggerpass.Data(),varname.Data()),variable,prefilter); TH1D* hMBseed = new TH1D(Form("h%s_%s_MBseed",triggerpass.Data(),varname.Data()),Form(";%s;Probability",varlatex.Data()),BIN_NUM,BIN_MIN,BIN_MAX); inttree->Project(Form("h%s_%s_MBseed",triggerpass.Data(),varname.Data()),variable,Form("%s&&%s",prefilter.Data(),triggerpass.Data())); //cout<<hAll->Integral()<<endl; hAll->Scale(1./hAll->Integral()); hMBseed->Scale(1./hMBseed->Integral()); hAll->SetStats(0); hMBseed->SetStats(0); hAll->SetMaximum(hMBseed->GetMaximum()*1.3); hAll->SetLineWidth(2); hAll->SetLineColor(kBlue-7); hAll->SetFillColor(kBlue-7); hAll->SetFillStyle(3001); hMBseed->SetLineWidth(2); hMBseed->SetLineColor(kRed); hMBseed->SetFillColor(kRed); hMBseed->SetFillStyle(3004); TCanvas* c = new TCanvas(Form("c%s_%s",triggerpass.Data(),varname.Data()),"",500,500); hAll->Draw(); hMBseed->Draw("same"); TLatex* tex = new TLatex(0.18,0.96,triggerpass); tex->SetNDC(); tex->SetTextFont(42); tex->SetTextSize(0.04); tex->Draw(); TLegend* leg = new TLegend(0.60,0.82,0.92,0.93); leg->SetFillStyle(0); leg->SetBorderSize(0); leg->AddEntry(hAll,"all","f"); leg->AddEntry(hMBseed,"pass trigger","f"); leg->Draw(); c->SaveAs(Form("triggerturnonPlots/pthat%.0f/c%s_%s.pdf",pthat,triggerpass.Data(),varname.Data())); }
TH1D* CutFlow::hashErrors(AllSamples samples, Variable variable){ TH1D * hashErrors = allMChisto(samples, variable); hashErrors->SetFillColor(kBlack); hashErrors->SetFillStyle(3354); hashErrors->SetMarkerSize(0.); hashErrors->SetStats(0); return hashErrors; }
TH1D * GetITSsaSpectrum(TFile *file, Int_t part, Int_t charge, Int_t cent, Bool_t cutSpectrum = kTRUE, Bool_t addSystematicError = kTRUE) { /* pt limits for combined spectra */ Double_t ptMin[AliPID::kSPECIES] = {0., 0., 0.1, 0.2, 0.3}; Double_t ptMax[AliPID::kSPECIES] = {0., 0., 0.6, 0.5, 0.6}; TList *list = (TList *)file->Get("output"); TH1D *hin = (TH1D *)list->FindObject(Form("h_%s_%s_cen_%d", ITSsaPartName[part], ITSsaChargeName[charge], cent)); if (!hin) return NULL; /* get systematics */ TFile *fsys = TFile::Open("SPECTRASYS_ITSsa.root"); TH1 *hsys = fsys->Get(Form("hSystTot%s%s", ITSsaChargeName[charge], ITSsaPartName[part])); TH1D *h = new TH1D(Form("hITSsa_cent%d_%s_%s", cent, AliPID::ParticleName(part), chargeName[charge]), "ITSsa", NptBins, ptBin); Double_t pt, width, value, error, sys; Int_t bin; for (Int_t ipt = 0; ipt < NptBins; ipt++) { /* get input bin */ pt = h->GetBinCenter(ipt + 1); width = h->GetBinWidth(ipt + 1); bin = hin->FindBin(pt); /* sanity check */ if (TMath::Abs(hin->GetBinCenter(bin) - pt) > 0.001 || TMath::Abs(hin->GetBinWidth(bin) - width) > 0.001) continue; /* check pt limits */ if (cutSpectrum && (pt < ptMin[part] || pt > ptMax[part])) continue; /* copy bin */ value = hin->GetBinContent(bin); error = hin->GetBinError(bin); /*** TEMP ADD SYS ***/ if (addSystematicError) { sys = hsys->GetBinContent(bin) * value; error = TMath::Sqrt(error * error + sys * sys); } h->SetBinContent(ipt + 1, value); h->SetBinError(ipt + 1, error); } h->SetTitle("ITSsa"); h->SetLineWidth(1); h->SetLineColor(1); h->SetMarkerStyle(20); h->SetMarkerColor(1); h->SetFillStyle(0); h->SetFillColor(0); return h; }
TH1D * GetITSTPCSpectrum(TFile *file, Int_t part, Int_t charge, Int_t cent) { TList *list = (TList *)file->Get("output"); TH1D *hin = (TH1D *)list->FindObject(Form("h_%s_%s_cen_%d", ITSTPCPartName[part], ITSTPCChargeName[charge], cent + 1)); if (!hin) return NULL; TH1D *h = new TH1D(Form("hITSTPC_cent%d_%s_%s", cent, AliPID::ParticleName(part), chargeName[charge]), "ITSTPC", NptBins, ptBin); Double_t pt, width, value, error; Int_t bin; for (Int_t ipt = 0; ipt < NptBins; ipt++) { /* get input bin */ pt = h->GetBinCenter(ipt + 1); width = h->GetBinWidth(ipt + 1); bin = hin->FindBin(pt); /* sanity check */ if (TMath::Abs(hin->GetBinCenter(bin) - pt) > 0.001 || TMath::Abs(hin->GetBinWidth(bin) - width) > 0.001) continue; /* copy bin */ value = hin->GetBinContent(bin); error = hin->GetBinError(bin); h->SetBinContent(ipt + 1, value); h->SetBinError(ipt + 1, error); } #if 0 /* add systematic error */ Double_t sys; if (part == 2) sys = 0.5; else sys = 0.1; Double_t cont, conte; for (Int_t ipt = 0; ipt < h->GetNbinsX(); ipt++) { cont = h->GetBinContent(ipt + 1); conte = h->GetBinError(ipt + 1); conte = TMath::Sqrt(conte * conte + sys * sys * cont * cont); h->SetBinError(ipt + 1, conte); } #endif h->SetTitle("ITSTPC"); h->SetLineWidth(1); h->SetLineColor(1); h->SetMarkerStyle(21); h->SetMarkerColor(2); h->SetFillStyle(0); h->SetFillColor(0); return h; }
TCanvas* pMenu(std::string what) { TCanvas* c = new TCanvas(("cMenu"+what).c_str(),("cMenu"+what).c_str(),1500,400); c->SetBottomMargin(0.6); c->SetLeftMargin(0.04); c->SetRightMargin(0.01); TH1D* h = (TH1D*)gROOT->FindObject(("hMenuAlgos"+what).c_str()); h->SetLineColor(4); h->SetFillColor(4); h->SetFillStyle(3003); h->LabelsOption("v"); h->GetYaxis()->SetLabelOffset(0.005); // h->GetXaxis()->SetRange(550,680); h->DrawCopy(); return c; }
TH1D * GetTPCTOFSpectrum(TFile *file, Int_t part, Int_t charge, Int_t cent, Bool_t cutSpectrum = kTRUE) { /* pt limits for combined spectra */ Double_t ptMin[AliPID::kSPECIES] = {0., 0., 0., 0., 0.}; Double_t ptMax[AliPID::kSPECIES] = {0., 0., 1.2, 1.2, 1.8}; TH1D *hin = (TH1D *)file->Get(Form("%sFinal%s%d", TPCTOFPartName[part], TPCTOFChargeName[charge], cent)); if (!hin) return NULL; TH1D *h = new TH1D(Form("hTPCTOF_cent%d_%s_%s", cent, AliPID::ParticleName(part), chargeName[charge]), "TPCTOF", NptBins, ptBin); Double_t pt, width, value, error; Int_t bin; for (Int_t ipt = 0; ipt < NptBins; ipt++) { /* get input bin */ pt = h->GetBinCenter(ipt + 1); width = h->GetBinWidth(ipt + 1); bin = hin->FindBin(pt); /* sanity check */ if (TMath::Abs(hin->GetBinCenter(bin) - pt) > 0.001 || TMath::Abs(hin->GetBinWidth(bin) - width) > 0.001) continue; /* check pt limits */ if (cutSpectrum && (pt < ptMin[part] || pt > ptMax[part])) continue; /* copy bin */ value = hin->GetBinContent(bin); error = hin->GetBinError(bin); h->SetBinContent(ipt + 1, value); h->SetBinError(ipt + 1, error); } h->SetTitle("TPCTOF"); h->SetLineWidth(1); h->SetLineColor(1); h->SetMarkerStyle(22); h->SetMarkerColor(8); h->SetFillStyle(0); h->SetFillColor(0); return h; }
void makePlotWithSelection(TTree* tr, TString varToPlot, TString canvName, TString xAxisName, TCut cutLoose, TCut cutAdditional) { TTree* trCutted = tr->CopyTree(cutLoose); TH1D* histLoose = new TH1D("hist",varToPlot,50,trCutted->GetMinimum(varToPlot)-0.1*fabs(trCutted->GetMinimum(varToPlot)),trCutted->GetMaximum(varToPlot)+0.1*fabs(trCutted->GetMaximum(varToPlot))); trCutted->Draw(varToPlot+TString(">>hist"),"1","goff"); TCanvas* canv = new TCanvas(canvName,canvName); //TAxis* xAxis = histLoose->GetXaxis(); histLoose->GetXaxis()->SetTitle(xAxisName); histLoose->GetYaxis()->SetRangeUser(0,histLoose->GetMaximumStored()); histLoose->SetFillStyle(3004); histLoose->SetFillColor(2); histLoose->Draw(); trCutted->SetFillStyle(1001); trCutted->SetFillColor(3); trCutted->Draw(varToPlot,cutAdditional,"same"); canv->SaveAs(canvName+".png"); delete histLoose; histLoose=0; trCutted=0; //xAxis=0; }
void plotter::draw_rec(TH1D* data_, TH1D* sig_, TH1D* bgr_, TString file_name){ TH1D* data = (TH1D*) data_->Clone("data"); TH1D* sig = (TH1D*) sig_->Clone("sig"); TH1D* bgr = (TH1D*) bgr_->Clone("bgr"); TCanvas *c= new TCanvas("c","",1200,600); gPad->SetLeftMargin(0.15); sig->Add(bgr, 1.); sig->SetTitle(" "); sig->GetYaxis()->SetRangeUser(0., 250); sig->GetXaxis()->SetTitle("detector binning"); sig->GetYaxis()->SetTitle("events"); sig->GetYaxis()->SetTitleOffset(1.5); sig->GetYaxis()->SetNdivisions(505); sig->SetFillColor(810); sig->SetLineColor(810); sig->Draw("HIST"); bgr->SetFillColor(kGray); bgr->SetLineColor(kBlack); bgr->SetFillStyle(1001); bgr->Draw("HIST SAME"); data->SetLineColor(kBlack); data->SetLineColor(kBlack); data->SetLineStyle(1); data->SetMarkerColor(kBlack); data->SetMarkerStyle(20); data->Draw("E SAME"); TLegend *l=new TLegend(0.2,0.7,0.4,0.88); l->SetBorderSize(0); l->SetFillStyle(0); l->AddEntry(data,"Data","pl"); l->AddEntry(sig,"t#bar{t}","f"); l->AddEntry(bgr,"Background","f"); l->Draw(); gPad->RedrawAxis(); c->SaveAs(directory + file_name + ".pdf"); delete c; }
TH1D * GetTPCTOFRatio(TFile *file, Int_t num, Int_t den, Int_t cent, Bool_t cutSpectrum = kTRUE) { /* pt limits for combined spectra */ Double_t ptMin_[9] = { 0.0, 0.0, 0.0, 0., 0., 0., 0.5, 0.5, 0.5 }; Double_t ptMax_[9] = { 1.2, 1.2, 1.2, 1.2, 1.2, 1.2, 1.8, 1.8, 1.8 }; Double_t ptMin = TMath::Max(ptMin_[num], ptMin_[den]); Double_t ptMax = TMath::Min(ptMax_[num], ptMax_[den]); Int_t part = 0, charge = 0; if (num == kPiMinus && den == kPiPlus) { part = AliPID::kPion; charge = 1; } else if (num == kKaMinus && den == kKaPlus) { part = AliPID::kKaon; charge = 1; } else if (num == kPrMinus && den == kPrPlus) { part = AliPID::kProton; charge = 1; } else if (num == kKaMinus && den == kPiMinus) { part = AliPID::kKaon; charge = 1; } else if (num == kKaPlus && den == kPiPlus) { part = AliPID::kKaon; charge = 0; } else if (num == kPrMinus && den == kPiMinus) { part = AliPID::kProton; charge = 1; } else if (num == kPrPlus && den == kPiPlus) { part = AliPID::kProton; charge = 0; } TH1D *hin = (TH1D *)file->Get(Form("%sFinal%s%d", TPCTOFPartName[part], TPCTOFChargeName[charge], cent)); if (!hin) return NULL; TH1D *h = new TH1D(Form("hTPCTOF_cent%d_%s_%s", cent, ratioName[num], ratioName[den]), "TPCTOF", NptBins, ptBin); Double_t pt, width, value, error; Int_t bin; for (Int_t ipt = 0; ipt < NptBins; ipt++) { /* get input bin */ pt = h->GetBinCenter(ipt + 1); width = h->GetBinWidth(ipt + 1); bin = hin->FindBin(pt); /* sanity check */ if (TMath::Abs(hin->GetBinCenter(bin) - pt) > 0.001 || TMath::Abs(hin->GetBinWidth(bin) - width) > 0.001) continue; /* check pt limits */ if (cutSpectrum && (pt < ptMin || pt > ptMax)) continue; /* copy bin */ value = hin->GetBinContent(bin); error = hin->GetBinError(bin); h->SetBinContent(ipt + 1, value); h->SetBinError(ipt + 1, error); } h->SetTitle("TPCTOF"); h->SetLineWidth(1); h->SetLineColor(1); h->SetMarkerStyle(22); h->SetMarkerColor(8); h->SetFillStyle(0); h->SetFillColor(0); return h; }
void drawInclJetResultSys_Overlay_Feb04(int fragMode= 2, // 1=trkpt, 2=ff int cmpStyle = 1, // 1=ratio, 2=diff int jtrewthi = 1, int jtrewtpp = 1, int doMC=0, bool doEtaRef = true ) { TH1::SetDefaultSumw2(); ////////////////////////////////////////////////////////////////////// // Setup ////////////////////////////////////////////////////////////////////// int binMode =2; // 1 : aj, 2 : cent int doCompare=0; // 1=qm12, 2=paper data TString tag = Form("trkPtProj_binMode2_Feb05_hi_rewt%d_pp_rewt%d_mc%d",jtrewthi,jtrewtpp,doMC); // tag+="_eta1.2"; if (cmpStyle==1) tag += "_rat"; else tag += "_diff"; if (doEtaRef) tag += "_EtaRef"; TString outdir="plotsFinalFF"; ////////////////////////////////////////////////////////////////////// // Specify Inputs ////////////////////////////////////////////////////////////////////// std::string Input_="inclJetFF_output_trackPtCut1_FinalJetPt100to300eta2.00_Jan17data_hi_pprewt.root"; std::string Inputpp_="inclJetFF_output_trackPtCut1_FinalJetPt100to300eta2.00_Jan17data_hi_pprewt.root"; // std::string Input_="inclJetFF_output_trackPtCut1_FinalJetPt100to300eta1.20_Jan17data_and_mc80and100.root"; // std::string Inputpp_="inclJetFF_output_trackPtCut1_FinalJetPt100to300eta1.20_Jan17data_and_mc80and100.root"; // higher jet pt thresholds // std::string Input_="inclJetFF_output_trackPtCut1_FinalJetPt120to300eta2.00_Jan17data_and_mc80and100.root"; // std::string Inputpp_="inclJetFF_output_trackPtCut1_FinalJetPt120to300eta2.00_Jan17data_and_mc80and100.root"; // mc if (doMC) { // Input_="inclJetFF_output_trackPtCut1_FinalJetPt100to300eta2.00_Jan17mcrefjetsel.root"; // Inputpp_="inclJetFF_output_trackPtCut1_FinalJetPt100to300eta2.00_Jan17mcrefjetsel.root"; // Input_="inclJetFF_output_trackPtCut1_FinalJetPt100to300eta2.00_Jan17mc80and120_hi_ppunsmjet.root"; Input_="inclJetFF_output_trackPtCut1_FinalJetPt100to300eta2.00_Jan17mc80and100_hi.root"; Inputpp_="inclJetFF_output_trackPtCut1_FinalJetPt100to300eta2.00_Jan17mc80and120_pp.root"; // Input_="inclJetFF_output_trackPtCut1_FinalJetPt100to300eta1.20_Jan17data_and_mc80and100.root"; // Inputpp_="inclJetFF_output_trackPtCut1_FinalJetPt100to300eta1.20_Jan17data_and_mc80and100.root"; if (doCompare) doCompare=2; } if (doCompare==1) tag+="_vs_qm12"; if (doCompare==2) tag+="_vs_data"; std::string Input_QM="dijetFF_output_histograms_trkPtProjectOnJetAxis_trackPtCut1_FinaletaCut2.00_pas.root"; TString cmpFile = Input_QM.data(); if (doCompare==2) cmpFile = "inclJetFF_output_trackPtCut1_FinalJetPt100to300eta2.00_Jan17data_hi_pprewt.root"; // latest data ///////////////////////////////////////////////// // Get Result Histograms ///////////////////////////////////////////////// TFile* inf = new TFile(Input_.data()); TH1D* ffhi[3][5]; // (leading, subleading), (aj bin) TH1D* ffpp[3][5]; TH1D* ffratio[3][5]; // Analysis Histograms TString jname[3] = {"jet","lJet","slJet"}; int ijet=1; TString dataset="data"; // "data", "mc" if (doMC) dataset="mc"; for ( int iaj=1;iaj<=4;iaj++) { if ( binMode == 2 ) { if (!doEtaRef) ffhi[ijet][iaj] = (TH1D*)load(Input_.data(),Form("hpt_%s_sigTrk_hidata_icent%d_irj999_fragMode2_closure0_jtrewt0_wtmode0_pt1to300",jname[0].Data(),iaj)); else { ffhi[ijet][iaj] = (TH1D*)load(Input_.data(),Form("hpt_%s_sigTrk_hi%s_icent%d_irj999_fragMode%d_closure100_jtrewt%d_wtmode0_pt1to300",jname[0].Data(),dataset.Data(),iaj,fragMode,jtrewthi)); } ffpp[ijet][iaj] = (TH1D*)load(Inputpp_.data(),Form("hpt_%s_sigTrk_pp%s_icent%d_irj999_fragMode%d_closure100_jtrewt%d_wtmode0_pt1to300",jname[0].Data(),dataset.Data(),iaj,fragMode,jtrewtpp)); // ffpp[ijet][iaj] = (TH1D*)load(Inputpp_.data(),Form("hpt_%s_sigTrk_ppdata_icent%d_irj999_fragMode2_closure100_jtrewt0_wtmode0_pt1to300",jname[0].Data(),iaj)); // QM pp reference // ffpp[ijet][iaj] = (TH1D*)load(Input_QM.data(),Form("hpt_%s_sigTrk_ppdata_icent%d_irj999_fragMode2_closure100_wtmode0_pt1to500",jname[ijet].Data(),iaj)); } handsomeTH1(ffpp[ijet][iaj],1,1.3); handsomeTH1(ffhi[ijet][iaj],1,1.3); } if (doMC) tag += "_mc80and120"; ///////////////////////////////////////////////// // Get Comparison Histograms ///////////////////////////////////////////////// TH1D* ffhicmp[3][5]; TH1D* ffppcmp[3][5]; TH1D* ffratiocmp[3][5]; if (doCompare==1) { // QM Comparison if (fragMode==2) { for ( int iaj=1;iaj<=4;iaj++) { ffhicmp[ijet][iaj] = (TH1D*)load(cmpFile.Data(),Form("hpt_%s_sigTrk_hidata_icent%d_irj999_fragMode2_closure100_wtmode0_pt1to500",jname[ijet].Data(),iaj)); ffppcmp[ijet][iaj] = (TH1D*)load(cmpFile.Data(),Form("hpt_%s_sigTrk_ppdata_icent%d_irj999_fragMode2_closure100_wtmode0_pt1to500",jname[ijet].Data(),iaj)); ffratiocmp[ijet][iaj] = (TH1D*)ffhicmp[ijet][iaj]->Clone(Form("%s_ratcmp",ffhicmp[ijet][iaj]->GetName())); if (cmpStyle==1) ffratiocmp[ijet][iaj]->Divide(ffppcmp[ijet][iaj]); else if (cmpStyle==2) ffratiocmp[ijet][iaj]->Add(ffppcmp[ijet][iaj],-1); handsomeTH1(ffppcmp[ijet][iaj],kRed,0,0); ffppcmp[ijet][iaj]->SetLineStyle(2); handsomeTH1(ffhicmp[ijet][iaj],kRed,1.3,kOpenCircle); handsomeTH1(ffratiocmp[ijet][iaj],kRed,1.3,kOpenCircle); } } else if (fragMode==1) { GetQM12TrkPt(ffppcmp,ffhicmp); for ( int iaj=1;iaj<=4;iaj++) { ffratiocmp[1][iaj] = (TH1D*)ffhicmp[ijet][iaj]->Clone(Form("%s_ratcmp",ffhicmp[ijet][iaj]->GetName())); if (cmpStyle==1) ffratiocmp[ijet][iaj]->Divide(ffppcmp[ijet][iaj]); else if (cmpStyle==2) ffratiocmp[ijet][iaj]->Add(ffppcmp[ijet][iaj],-1); handsomeTH1(ffppcmp[ijet][iaj],kRed,0,0); ffppcmp[ijet][iaj]->SetLineStyle(2); handsomeTH1(ffhicmp[ijet][iaj],kRed,1.3,kOpenCircle); handsomeTH1(ffratiocmp[ijet][iaj],kRed,1.3,kOpenCircle); } } } else if (doCompare==2) { for ( int iaj=1;iaj<=4;iaj++) { ffhicmp[ijet][iaj] = (TH1D*)load(cmpFile.Data(),Form("hpt_%s_sigTrk_hidata_icent%d_irj999_fragMode%d_closure100_jtrewt1_wtmode0_pt1to300",jname[0].Data(),iaj,fragMode)); ffppcmp[ijet][iaj] = (TH1D*)load(cmpFile.Data(),Form("hpt_%s_sigTrk_ppdata_icent%d_irj999_fragMode%d_closure100_jtrewt1_wtmode0_pt1to300",jname[0].Data(),iaj,fragMode)); ffratiocmp[ijet][iaj] = (TH1D*)ffhicmp[ijet][iaj]->Clone(Form("%s_ratcmp",ffhicmp[ijet][iaj]->GetName())); if (cmpStyle==1) ffratiocmp[ijet][iaj]->Divide(ffppcmp[ijet][iaj]); else if (cmpStyle==2) ffratiocmp[ijet][iaj]->Add(ffppcmp[ijet][iaj],-1); handsomeTH1(ffppcmp[ijet][iaj],kRed,0,0); ffppcmp[ijet][iaj]->SetLineStyle(2); handsomeTH1(ffhicmp[ijet][iaj],kRed,1.3,kOpenCircle); handsomeTH1(ffratiocmp[ijet][iaj],kRed,1.3,kOpenCircle); } } ///////////////////////////////////////////////// // Monitor ///////////////////////////////////////////////// // TFile outf("finalSys.root","recreate"); // outf.Close(); ////////////////////////////////////////////////////////////////////// // Define Plotting Frames ////////////////////////////////////////////////////////////////////// float xmin=-0.15, xmax=5.5, rmin=0.3, rmax=2.58; if (fragMode==1) { xmin=1; xmax=51; } if (cmpStyle==2) { rmin=-0.4; rmax=1.1; } TH2F * hPadFF, *hPadR, * hPadPt; hPadPt = new TH2F("hPadPt",";p_{T}^{ jet} (GeV/c);1/N_{ jet} dN_{ jet} /dp_{T}",150,xmin,xmax,100,6e-3,20); hPadFF = new TH2F("hPadFF",";#xi = ln(1/z);1/N_{ jet} dN_{ track} /d#xi",100,xmin,xmax,100,0.02,20); hPadR = new TH2F("hPadR",";#xi = ln(1/z);PbPb/pp",100,xmin,xmax,20000,rmin,rmax); if (fragMode==1) hPadR->SetXTitle("p_{T}^{Track} (GeV/c)"); if (cmpStyle==2) hPadR->SetYTitle("PbPb - pp"); handsomeTH1(hPadFF,1,1.2); handsomeTH1(hPadR,1,1.2); handsomeTH1(hPadPt,1,1.2); fixedFontHist(hPadFF,2.2,2.5,25); fixedFontHist(hPadR,2.2,2.5,25); fixedFontHist(hPadPt,2.2,2.5,25); ///////////////////////////////////////////////// // Define Systematic Uncertainties ///////////////////////////////////////////////// SysErrors sysff(fragMode,binMode,1,xmin,xmax); ///////////////////////////////////////////////// // Draw Result ///////////////////////////////////////////////// TCanvas *c = new TCanvas("c","",1500,860); makeMultiPanelCanvasNew(c,4,2,0.0,0.0,0.22,0.22,0.01,1.0,0.95); for ( int iaj=1 ; iaj<=4 ; iaj++) { cout << "=============== " << Form("%.0f%% - %.0f%%", float(centBin1[iaj-1]*2.5), float(centBin1[iaj]*2.5)) << " ================" << endl; // Draw Distribution c->cd(5-iaj); bool doNorm=false; if (doNorm) {scaleInt(ffpp[ijet][iaj]); scaleInt(ffhi[ijet][iaj]);} if (doNorm) ffpp[ijet][iaj]->SetAxisRange(0.00025,1,"Y"); // Draw Spectrum if(fragMode==1) hPadPt->Draw(); else if(fragMode==2) hPadFF->Draw(); int iajSys = iaj; if (binMode==1) iaj=5-iaj; if (fragMode==1) gPad->SetLogx(); gPad->SetLogy(); // drawSysErr(ffhi[ijet][iaj],sysff.vErrorHi[ijet][iajSys],sysff.NErrorHi,ijet-1,1,2,1,ijet == 1,0,0,(TPad*)c->GetPad(5-iaj),(TPad*)cerr->GetPad(5-iaj)); sysff.Combine(ffhi[ijet][iaj],sysff.vErrorHi[ijet][iajSys],sysff.NErrorHi); sysff.Apply(ffhi[ijet][iaj]); sysff.Draw(ffhi[ijet][iaj]); if (doCompare) ffppcmp[ijet][iaj]->Draw("hist same"); ffpp[ijet][iaj]->Draw( "hist same"); ffhi[ijet][iaj]->Draw("same"); if (doCompare) ffhicmp[ijet][iaj]->Draw("sameE"); gPad->RedrawAxis(); // Draw Comparison c->cd(9-iaj); if (fragMode==1) gPad->SetLogx(); ffratio[ijet][iaj]= (TH1D*)ffhi[ijet][iaj]->Clone(Form("ffRattio_ijet%d_iaj%d",ijet,iaj)); if (cmpStyle==1) ffratio[ijet][iaj]->Divide(ffpp[ijet][iaj]); else if (cmpStyle==2) ffratio[ijet][iaj]->Add(ffpp[ijet][iaj],-1); if(ijet == 1)hPadR->Draw(); sysff.Combine(ffhi[ijet][iaj],sysff.vErrorRat[ijet][iajSys],sysff.NErrorRatio); sysff.ApplyOnRel(ffhi[ijet][iaj],ffpp[ijet][iaj],cmpStyle); sysff.Draw(ffratio[ijet][iaj]); if (doCompare) ffratiocmp[ijet][iaj]->Draw("sameE"); ffratio[ijet][iaj]->Draw("same"); if (cmpStyle==1) jumSun(xmin,1,xmax,1); else if (cmpStyle==2) jumSun(xmin,0,xmax,0); gPad->RedrawAxis(); PrintHistogram(ffratio[ijet][iaj]); } ///////////////////////////////////////////////// // Annotate ///////////////////////////////////////////////// TH1D* hYel = new TH1D("hYel","",0,10,20); handsomeTH1(hYel,TColor::GetColor(0xFFEE00)); hYel->SetFillColor(TColor::GetColor(0xFFEE00)); hYel->SetFillStyle(1001); TLegend* l2[3]; TLegend* lsys; l2[ijet] = new TLegend(0.04,0.747,0.77,1.02,NULL,"brNDC"); easyLeg(l2[ijet],""); if (!doMC) { // l2[ijet]->AddEntry(ffratiocmp[ijet][1],"PbPb AkPu3Calo","p"); // l2[ijet]->AddEntry(ffratiocmp[ijet][1],"Jet |#eta|<0.8","p"); // l2[ijet]->AddEntry(ffhi[ijet][1],"PbPb, 4 Cent. Trk. Eff.","p"); // l2[ijet]->AddEntry(ffratiocmp[ijet][1],"PbPb, QM12 Trk. Eff.","p"); // l2[ijet]->AddEntry(ffppcmp[ijet][1],"pp, 100<Jet<300 GeV","l"); l2[ijet]->AddEntry(ffhi[ijet][1],"PbPb","p"); if (doCompare==1) l2[ijet]->AddEntry(ffratiocmp[ijet][1],"PbPb QM12","p"); else if (doCompare==2) l2[ijet]->AddEntry(ffratiocmp[ijet][1],"PbPb (paper)","p"); l2[ijet]->AddEntry(ffpp[ijet][1],"pp reference","l"); if (doCompare==1) l2[ijet]->AddEntry(ffppcmp[ijet][1],"pp reference QM12","l"); else if (doCompare==2) l2[ijet]->AddEntry(ffppcmp[ijet][1],"pp (paper)","l"); } else { l2[ijet]->AddEntry(ffhi[ijet][1],"PYTHIA+HYDJET","p"); if (doCompare==1) l2[ijet]->AddEntry(ffratiocmp[ijet][1],"PbPb QM12","p"); else if (doCompare==2) l2[ijet]->AddEntry(ffratiocmp[ijet][1],"PbPb (paper)","p"); l2[ijet]->AddEntry(ffpp[ijet][1],"PYTHIA","l"); if (doCompare==1) l2[ijet]->AddEntry(ffppcmp[ijet][1],"pp reference QM12","l"); else if (doCompare==2) l2[ijet]->AddEntry(ffppcmp[ijet][1],"pp (paper)","l"); } for ( int iaj=1 ; iaj<=4 ; iaj++) { c->cd(5-iaj); if (iaj==3 && ijet == 1) l2[ijet]->Draw(); if (iaj==4) { drawText("CMS Preliminary",0.27,0.9,1,25); // drawText("L_{Int} = 129 #mub^{-1}",0.27,0.80,1,25); if (!doMC) drawText("L_{Int} = 150 #mub^{-1}",0.27,0.80,1,25); } float legdx = 0.2; if (binMode==1&&iaj==4) legdx=+0.15; if (binMode==2&&iaj==4) legdx=+0.30; if ( binMode == 1 ) { drawText(Form("%.2f < x_{2,1} < %.2f", float(rjBin1[iaj-1]), float(rjBin1[iaj])), 0.2+legdx,0.18); } else if ( binMode == 2 ) drawText(Form("%.0f%% - %.0f%%", float(centBin1[iaj-1]*2.5), float(centBin1[iaj]*2.5)), 2,0.03,kBlack,25,false); if (iaj==2) { lsys = new TLegend(0.03439587,0.8554279,0.7188686,1.001911,NULL,"brNDC"); easyLeg(lsys,""); lsys->AddEntry(hYel,"Systematic uncertainty","f"); lsys->Draw(); } if (iaj==1) { float ptx(0.08),pty1(0.89); drawText("Jet p_{T} > 100GeV/c, |#eta| < 2",ptx,pty1,kBlack,25); // drawText("Jet p_{T} > 100GeV/c, |#eta| < 1.2",ptx,pty1,kBlack,25); // drawText("Jet p_{T} > 120GeV/c, |#eta| < 2",ptx,pty1,kBlack,25); drawText("Track p_{T} > 1 GeV/c, r < 0.3",ptx,pty1-0.09,kBlack,25); } } c->SaveAs(outdir+Form("/FFana%d_%s.gif",fragMode,tag.Data())); c->SaveAs(outdir+Form("/FFana%d_%s.pdf",fragMode,tag.Data())); c->SaveAs(outdir+Form("/FFana%d_%s.C",fragMode,tag.Data())); ///////////////////////////////////////////////// // Inspect Errors ///////////////////////////////////////////////// // TCanvas *c2 = new TCanvas("c2","",1500,430); // //makeMultiPanelCanvasNew(c,4,2,0.0,0.0,0.22,0.22,0.01,1.0,0.95); // c2->Divide(4,1); // for ( int icent=1 ; icent<=4 ; icent++) { // c2->cd(5-icent); // if (fragMode==1) gPad->SetLogx(); // sysff.Combine(ffhi[ijet][icent],sysff.vErrorRat[ijet][icent],sysff.NErrorRatio); // int doLeg=(icent==4); // sysff.Inspect(sysff.vErrorRat[ijet][icent],sysff.NErrorRatio,doLeg); // drawText(Form("%.0f%% - %.0f%%", float(centBin1[icent-1]*2.5), float(centBin1[icent]*2.5)), 2,0.6,kBlack,25,false); // } // c2->SaveAs(outdir+Form("/sysana%d_%s.gif",fragMode,tag.Data())); // c2->SaveAs(outdir+Form("/sysana%d_%s.pdf",fragMode,tag.Data())); }
/** * * * @param o * @param useWeights * @param correct * * @ingroup pwglf_forward_scripts_tests */ void TestPoisson(Double_t o=.3, bool useWeights=false, bool correct=true) { const char* load = "$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/scripts/LoadLibs.C"; if (!gROOT->GetClass("AliAODForwardMult")) { gROOT->Macro(load); gROOT->GetInterpreter()->UnloadFile(gSystem->ExpandPathName(load)); } // --- Parameters of this script ----------------------------------- Int_t nBin = 5; // Our detector matrix size Int_t nMax = TMath::Max(Int_t(nBin * nBin * o + .5)+nBin/2,nBin); Int_t nEv = 10000; // Number of events Double_t mp = o; // The 'hit' probability TH2D* base = new TH2D("base", "Basic histogram", nBin,-.5, nBin-.5, nBin, -.5, nBin-.5); base->SetXTitle("#eta"); base->SetYTitle("#varphi"); base->SetDirectory(0); base->SetOption("colz"); Int_t tN1=nMax; Double_t tMin1; Double_t tMax1; Int_t tN2=nMax*10; Double_t tMin2; Double_t tMax2=nMax; MakeIntegerAxis(tN1, tMin1, tMax1); MakeIntegerAxis(tN2, tMin2, tMax2); TH2D* corr = new TH2D("comp", "Comparison", tN1, tMin1, tMax1, tN2, tMin2, tMax2); corr->SetXTitle("Input"); corr->SetYTitle("Poisson"); corr->SetDirectory(0); corr->SetOption("colz"); corr->SetStats(0); TLine* lcorr = new TLine(0, 0, tMax2, tMax2); Int_t mm = TMath::Max(Int_t(nBin * o + .5),nBin/2); tN2=mm*10; tMax2 = mm; MakeIntegerAxis(tN2, tMin2, tMax2); Info("", "Making mean w/nbins=%d,range=[%f,%f]", tN2, tMin2, tMax2); TH2D* mean = new TH2D("mean", "Mean comparison", tN2, tMin2, tMax2, tN2, tMin2, tMax2); mean->SetXTitle("Input"); mean->SetYTitle("Poisson"); mean->SetDirectory(0); mean->SetOption("colz"); mean->SetStats(0); TLine* lmean = new TLine(tMin2, tMin2, tMax2, tMax2); TH1D* dist = new TH1D("dist", "Distribution of hits", tN1, tMin1, tMax1); dist->SetXTitle("s"); dist->SetYTitle("P(s)"); dist->SetFillColor(kRed+1); dist->SetFillStyle(3001); dist->SetDirectory(0); TH1D* diff = new TH1D("diff", "P-T", 100, -25, 25); diff->SetXTitle("Difference"); diff->SetFillColor(kRed+1); diff->SetFillStyle(3001); diff->SetYTitle("Prob"); AliPoissonCalculator* c = new AliPoissonCalculator("ignored"); c->Init(nBin ,nBin); for (Int_t i = 0; i < nEv; i++) { c->Reset(base); base->Reset(); for (Int_t iEta = 0; iEta < nBin; iEta++) { for (Int_t iPhi = 0; iPhi < nBin; iPhi++) { // Throw a die Int_t m = gRandom->Poisson(mp); dist->Fill(m); // Fill into our base histogram base->Fill(iEta, iPhi, m); // Fill into poisson calculator c->Fill(iEta, iPhi, m > 0, (useWeights ? m : 1)); } } // Calculate the result TH2D* res = c->Result(correct); // Now loop and compare Double_t mBase = 0; Double_t mPois = 0; for (Int_t iEta = 0; iEta < nBin; iEta++) { for (Int_t iPhi = 0; iPhi < nBin; iPhi++) { Double_t p = res->GetBinContent(iEta, iPhi); Double_t t = base->GetBinContent(iEta, iPhi); mBase += t; mPois += p; corr->Fill(t, p); diff->Fill(p-t); } } Int_t nn = nBin * nBin; mean->Fill(mBase / nn, mPois / nn); } TCanvas* cc = new TCanvas("c", "c", 900, 900); cc->SetFillColor(0); cc->SetFillStyle(0); cc->SetBorderMode(0); cc->SetRightMargin(0.02); cc->SetTopMargin(0.02); cc->Divide(2,2); TVirtualPad* pp = cc->cd(1); pp->SetFillColor(0); pp->SetFillStyle(0); pp->SetBorderMode(0); pp->SetRightMargin(0.15); pp->SetTopMargin(0.02); pp->SetLogz(); pp->SetGridx(); pp->SetGridy(); corr->Draw(); lcorr->Draw(); pp = cc->cd(2); pp->SetFillColor(0); pp->SetFillStyle(0); pp->SetBorderMode(0); pp->SetRightMargin(0.02); pp->SetTopMargin(0.02); #if 0 c->GetMean()->Draw(); #elif 1 pp->SetLogy(); diff->Draw(); #elif 1 c->GetOccupancy()->Draw(); #else pp->SetLogy(); dist->SetStats(0); dist->Scale(1. / dist->Integral()); dist->Draw(); TH1D* m1 = c->GetMean(); m1->Scale(1. / m1->Integral()); m1->Draw("same"); Double_t eI; Double_t ii = 100 * dist->Integral(2, 0); TLatex* ll = new TLatex(.97, .85, Form("Input #bar{m}: %5.3f", mp)); ll->SetNDC(); ll->SetTextFont(132); ll->SetTextAlign(31); ll->Draw(); ll->DrawLatex(.97, .75, Form("Result #bar{m}: %5.3f", dist->GetMean())); ll->DrawLatex(.97, .65, Form("Occupancy: #int_{1}^{#infty}P(s)ds = %6.2f%%", ii)); #endif pp = cc->cd(3); pp->SetFillColor(0); pp->SetFillStyle(0); pp->SetBorderMode(0); pp->SetRightMargin(0.15); pp->SetTopMargin(0.02); pp->SetGridx(); pp->SetGridy(); c->GetCorrection()->Draw(); pp = cc->cd(4); pp->SetFillColor(0); pp->SetFillStyle(0); pp->SetBorderMode(0); pp->SetRightMargin(0.15); pp->SetTopMargin(0.02); pp->SetLogz(); pp->SetGridx(); pp->SetGridy(); mean->Draw(); lmean->Draw(); cc->cd(); }
void dimuonLoop(float ptmin, float ptmax, float ymin, float ymax, int i) { TFile *infData = new TFile(inputdata); TFile *infMC = new TFile(inputmc); TTree *ntData = (TTree*) infData->Get("ntKp"); TTree *ntMC = (TTree*) infMC->Get("ntKp"); TCanvas *c = new TCanvas(Form("c%i",i),"",600,600); //if (logy) c->SetLogy(); TH1D* hData = new TH1D("hData","",50,2.85,3.35); TH1D* hMC = new TH1D("hMC","",50,2.85,3.35); ntData->Project("hData","mumumass",Form("%s&&(pt>%f&&pt<%f)&&(y>%f&&y<%f)",cut.Data(),ptmin,ptmax,ymin,ymax)); ntMC->Project("hMC","mumumass",Form("%s&&(pt>%f&&pt<%f)&&(y>%f&&y<%f)",cut.Data(),ptmin,ptmax,ymin,ymax)); hData->Sumw2(); double normData=0,normMC=0; normData = hData->GetEntries(); normMC = hMC->GetEntries(); cout<<normData<<" "<<normMC<<endl; hData->Scale(1./normData); hMC->Scale(1./normMC); hData->Sumw2(); hMC->SetXTitle("#mu#mu mass"); hMC->SetYTitle("#Probability"); hMC->SetTitleOffset(1.5,"Y"); if(hData->GetMaximum()>hMC->GetMaximum()) hMC->SetMaximum(hData->GetMaximum()*1.1); else hMC->SetMaximum(hMC->GetMaximum()*1.1); //hData->SetLineColor(kBlue+1); //hData->SetFillStyle(1001); //hData->SetFillColor(kBlue-9); //hData->SetLineWidth(3); hData->SetMarkerStyle(8); hData->SetStats(0); hMC->SetLineColor(kRed); hMC->SetFillStyle(3004); hMC->SetFillColor(kRed); hMC->SetLineWidth(3); hMC->SetStats(0); hMC->Draw(); hData->Draw("same lep"); TLegend *leg = new TLegend(0.11,0.75,0.50,0.9); leg->AddEntry(hData,"data","lep"); leg->AddEntry(hMC,"MC","f"); leg->SetBorderSize(0); leg->SetFillStyle(0); leg->Draw("same"); TLegend *leg1 = new TLegend(0.60,0.7,0.90,0.9); leg1->AddEntry((TObject*)0,Form("%s",particle.Data()),""); leg1->AddEntry((TObject*)0,Form("%.0f<p_{T}<%.0f GeV",ptmin,ptmax),""); leg1->AddEntry((TObject*)0,Form("%.1f<y_{CM}<%.1f",ymin,ymax),""); leg1->SetBorderSize(0); leg1->SetFillStyle(0); leg1->Draw("same"); c->SaveAs(Form("MuonResult/plot_Bplus_chi2_trkPt/dimuon_yDM_%i.pdf",i)); //c->SaveAs(Form("MuonResult/plot_Bplus_chi2_trkPt/dimuon_DM_%i.pdf",i)); //c->SaveAs("MuonResult/plot_Bplus_chi2_trkPt/dimuon_DM_incl_1.pdf"); }
/* ***************************************************************************************************************** */ int main(int argc, char* argv[]) { cout << "sis3316_offline" << endl; // prints sis3316_offline /******************************************************************************************************************************/ /* CERN ROOT */ /******************************************************************************************************************************/ #ifdef CERN_ROOT_PLOT printf("--> CERN_ROOT_PLOT is defined \n"); int root_graph_x ; int root_graph_y ; int root_graph_x_size ; int root_graph_y_size ; char root_graph_text[80] ; root_graph_x_size = 1000 ; root_graph_y_size = 500 ; root_graph_x = 10 ; root_graph_y = 620 ; cout << "argc: " << argc << endl; for (int i = 1; i < argc; i++){ cout << "argv[" << i << "]: " << argv[i] << endl; } // this root class extracts data from argc and argv, modifying them in the // process TApplication theApp("SIS3316 Application: Test", &argc, argv); strcpy(root_graph_text,"SIS3316 Graph: Raw data") ; gl_graph_raw = new sis_root_graph(root_graph_text, root_graph_x, root_graph_y, root_graph_x_size, root_graph_y_size) ; #endif #ifdef raus printf("--> raus is defined \n"); // file read gl_FILE_DataEvenFilePointer = fopen("ne213/sis3316_test_data.dat","rb") ; if (gl_FILE_DataEvenFilePointer == NULL) { printf("gl_FILE_DataEvenFilePointer == NULL \n"); return -1; } else { printf("file is opened \n"); } #endif UInt_t valid_BankBufferHeader_valid_flag ; int nof_read ; UInt_t buffer_no ; UInt_t i_event ; UInt_t nof_events ; UInt_t buffer_length ; UInt_t event_length ; UInt_t header_length ; UInt_t wfm_length ; UInt_t channel_no ; UInt_t maw_length ; UInt_t i_ch ; UInt_t headerformat ; UInt_t header_indentifier ; UInt_t header_reserved ; //gl_graph_raw->sis3316_draw_XYaxis (50000); // clear and draw X/Y //gl_graph_raw->sis3316_draw_XYaxis (wfm_length); // clear and draw X/Y UInt_t bank_buffer_counter ; char filename[128] ; int i_file; bank_buffer_counter = 8 ; bool doDraw = true; if ( gROOT->IsBatch() ) { doDraw = false; cout << "--> running in batch mode" << endl; } // loop over enumerated files in internal directory: //for (i_file=0; i_file<10; i_file++) { //sprintf(filename,"../data_files/sample_test_gui/sis3316_test_data_%d.dat",i_file ) ; //sprintf(filename,"../data_files/external/sis3316_test_data_%d.dat",i_file ) ; //sprintf(filename,"../data_files/internal/sis3316_test_data_%d.dat",i_file ) ; // loop over args: for (i_file = 1; i_file<theApp.Argc(); i_file++) { //cout << "filename: " << argv[i_file+1] << endl; //sprintf(filename,"%s",argv[i_file+1]) ; sprintf(filename,"%s", theApp.Argv(i_file)) ; #ifdef CERN_ROOT_PLOT string filename_str(filename); if ( filename_str.size() < 3 ) { cout << "option: " << filename_str << endl; continue; } cout << "filename: " << filename << endl; size_t dot = filename_str.find_last_of("."); size_t slash = filename_str.find_last_of("/"); string basename_str = "tier1_" + filename_str.substr(slash+1, dot-slash-1); string config_filename_str = filename_str.substr(0, dot) + ".ini"; cout << "Setting file label " << basename_str << endl; // open a root file TFile root_file((basename_str + ".root").c_str(), "recreate"); // make trees TTree *tree[16]; //default values for branches //global parameters Bool_t is_external = true; Float_t sampling_freq_Hz = 25e6; // in Hz UShort_t wfm_delay = 200; UShort_t maw_delay = 600; Bool_t is_pospolarity[16]; Bool_t is_50ohm[16]; Bool_t is_2Vinput[16]; UShort_t maw_gap = 250; UShort_t maw_peaking = 50; UShort_t maw_thres = 60; for(int i=0; i<=15; i++) {is_pospolarity[i] = is_50ohm[i] = is_2Vinput[i] = true;} //read from config file ReadConfigFile(config_filename_str, &is_external, &sampling_freq_Hz, &wfm_delay, &maw_delay, is_pospolarity, is_50ohm, is_2Vinput, &maw_gap, &maw_peaking, &maw_thres); //other parameters Int_t wfm_max = 0; UShort_t wfm_max_time = 0; Int_t wfm_min = 0; Int_t maw_max = 0; Int_t maw_min = 0; UChar_t channel = 0; ULong64_t timestamp = 0; Double_t timestampDouble = 0; //ULong64_t timestampLo = 0; //ULong64_t timestampHi = 0; UShort_t * wfm = new UShort_t[65536]; Int_t * maw = new Int_t[2048*4]; //read configuration file for(int i=0; i<=15; i++) { // looping over the 16 trees ostringstream treename; treename << "tree" << i; tree[i] = new TTree(treename.str().c_str(), "tree of SIS waveform data"); // global parameters tree[i]->Branch("is_external", &is_external, "is_external/O"); tree[i]->Branch("sampling_freq_Hz", &sampling_freq_Hz, "sampling_freq_Hz/F"); tree[i]->Branch("wfm_delay", &wfm_delay, "wfm_delay/s"); tree[i]->Branch("wfm_length", &wfm_length, "wfm_length/i"); tree[i]->Branch("maw_delay", &maw_delay, "maw_delay/s"); tree[i]->Branch("maw_length", &maw_length, "maw_length/i"); tree[i]->Branch("is_pospolarity", &is_pospolarity[i], "is_pospolarity/O"); tree[i]->Branch("is_50ohm", &is_50ohm[i], "is_50ohm/O"); tree[i]->Branch("is_2Vinput", &is_2Vinput[i], "is_2Vinput/O"); tree[i]->Branch("maw_gap", &maw_gap, "maw_gap/s"); tree[i]->Branch("maw_peaking", &maw_peaking, "maw_peaking/s"); tree[i]->Branch("maw_thres", &maw_thres, "maw_thres/s"); // create a maximum-value branch //UInt_t wfm_max = 0; tree[i]->Branch("wfm_max", &wfm_max, "wfm_max/I"); // time of waveform max value: //UInt_t wfm_max_time = 0; tree[i]->Branch("wfm_max_time", &wfm_max_time, "wfm_max_time/s"); // create a mininum-value branch //UInt_t wfm_min = 0; tree[i]->Branch("wfm_min", &wfm_min, "wfm_min/I"); // create a maximum-value branch //signed int maw_max = 0; tree[i]->Branch("maw_max", &maw_max, "maw_max/I"); // create a mininum-value branch //signed int maw_min = 0; tree[i]->Branch("maw_min", &maw_min, "maw_min/I"); // create a channel branch //int channel = 0; tree[i]->Branch("channel", &channel, "channel/b"); // 8 bit unsigned integer // create a timestamp branch //ULong64_t timestamp = 0; //double timestampDouble = 0; tree[i]->Branch("timestamp", ×tamp, "timestamp/l"); // 64 bit unsigned integer (ULong64_t) tree[i]->Branch("timestampDouble", ×tampDouble, "timestampDouble/D"); // (Double_t) // create a buffer number branch // tree[i]->Branch("buffer_no", &buffer_no); // create an event number branch tree[i]->Branch("event", &i_event, "event/i"); // unsigned integer (UInt_t) // wfm //UShort_t * wfm = new UShort_t[2048*4]; tree[i]->Branch("wfm", wfm, "wfm[wfm_length]/s"); // maw buffer tree[i]->Branch("maw_length", &maw_length); // maw //signed int * maw = new signed int[2048*4]; tree[i]->Branch("maw", maw, "maw[maw_length]/I"); } #endif cout << "argc: " << argc << endl; for (int i = 1; i < argc; i++){ cout << "argv[" << i << "]: " << argv[i] << endl; } //cout << theApp.Argc() << endl; //cout << theApp.Argv(i_file) << endl; printf("--> processing file: %s\n",filename) ; gl_FILE_DataEvenFilePointer = fopen(filename,"rb") ; if (gl_FILE_DataEvenFilePointer != NULL) { do { valid_BankBufferHeader_valid_flag = 0 ; // read the buffer header nof_read = ReadBufferHeaderCounterNofChannelToDataFile (&header_indentifier, &buffer_no, &channel_no, &nof_events, &event_length, &maw_length, &header_reserved) ; buffer_length = event_length * nof_events ; printf("\n"); printf("header information: \tnof_read = %d \tindentifier = %d \tbuffer_no = %d \tchannel_no = %d \n", nof_read, header_indentifier, buffer_no, channel_no); printf("header information: \tnof_events = %d \tbuffer_length = %d \tevent_length = %d \n", nof_events, buffer_length, event_length ); printf("header information: \tmaw_length = %d \treserved = %d \n", maw_length, header_reserved); unsigned uint_plot_axis_flag; if (nof_read == 8) { uint_plot_axis_flag = 1 ; valid_BankBufferHeader_valid_flag = 1 ; // read buffer (of nof_events events) into gl_ch_data nof_read = ReadEventsFromDataFile (gl_ch_data, buffer_length); // grab header format and channel number from the 0th event; assume // this applies to all nof_events // mask to get the header format: headerformat = (gl_ch_data[0] & 0xf) ; // mask and bitshift to get the channel number i_ch = (gl_ch_data[0] & 0xfff0) >> 4 ; printf("nof_read = %d \tch = %d \theaderformat = 0x%02X \n", nof_read, i_ch, headerformat); if (i_ch != channel_no) { cout << "WARNING -- i_ch=" << i_ch << ", channel_no=" << channel_no << endl; } header_length = 3 ; // if headerformat == 0 if((headerformat & 0x1) == 1) {header_length = header_length + 7; } if((headerformat & 0x2) == 2) {header_length = header_length + 2; } if((headerformat & 0x4) == 4) {header_length = header_length + 3; } if((headerformat & 0x8) == 8) {header_length = header_length + 2; } // wfm_length is the number of 16-bit ADC samples in each event // event_length is the number of 32-bit words in each event wfm_length = 2 * (gl_ch_data[header_length-1] & 0x3ffffff) ; // if headerformat == 0 if(uint_plot_axis_flag == 1) { //printf("uint_plot_axis_flag == 1\n"); uint_plot_axis_flag = 0 ; gl_graph_raw->sis3316_draw_XYaxis (wfm_length); // clear and draw X/Y } // loop over all events in gl_ch_data for (i_event = 0; i_event < nof_events; i_event++) { //if (i_event<10) { // plot ony the first 10. events //if (i_event<1) { // plot ony 1. event //cout << sizeof(UInt_t) << endl; // gl_ch_data is an UInt_t is 4 bytes (32 bits), at least on // Alexis' Mac. Bit mask each part of the timestamp, then bit shift to // make the 48-bit timestamp // 0xffff = 32 bits, 4 bytes size_t event_index = i_event*event_length; //cout << "gl_ch_data[event_index + 1] : " << gl_ch_data[event_index + 1] << endl; //cout << "gl_ch_data[event_index]: " << gl_ch_data[event_index] << endl; //cout << "(gl_ch_data[event_index] & 0xffff0000): " << ( (ULong64_t) (gl_ch_data[event_index] & 0xffff0000)) << endl; //cout << "(gl_ch_data[event_index] & 0xffff0000) << 16 :" << ( (ULong64_t) (gl_ch_data[event_index] & 0xffff0000) << 16) << endl; timestamp = ( (ULong64_t) (gl_ch_data[event_index] & 0xffff0000) << 16) ; timestamp += gl_ch_data[event_index + 1]; //timestampHi = ( (ULong64_t) (gl_ch_data[event_index] & 0xffff0000) << 16) ; //timestampLo = gl_ch_data[event_index + 1]; timestampDouble = (Double_t) timestamp; // find the wfm maximum value wfm_max = 0; wfm_max_time = 0; wfm_min = pow(2, 14); // max value of ADC UShort_t* ushort_adc_buffer_ptr = (UShort_t*) (&gl_ch_data[i_event*(event_length) + header_length]); for (UInt_t i = 0; i < wfm_length; i++ ) { UInt_t adc_value = (UInt_t) ushort_adc_buffer_ptr[i]; wfm[i] = adc_value; //cout << i << " | " << adc_value << endl; if (adc_value > wfm_max){ wfm_max = adc_value; wfm_max_time = i; } if (adc_value < wfm_min){ wfm_min = adc_value; } } if (doDraw) { cout << "wfm_max: " << wfm_max << endl; cout << "timestamp: " << timestamp << endl; gl_graph_raw->sis3316_draw_chN (wfm_length, &gl_ch_data[event_index + header_length], i_ch&0xf); // insert pause cout << "event " << i_event << " | channel " << i_ch << " | enter to continue (q=quit, b=batch, p=print)--> "; int val = cin.get(); cout << endl; if (val == (int) 'q' || val == (int) 'Q') { return 0; } if (val == (int) 'b') { doDraw = false; } if (val == (int) 'p') { ostringstream plotName; plotName << basename_str << i_event; //gl_graph_raw->c1->Print((plotName.str() + ".png").c_str()); //gl_graph_raw->c1->Print((plotName.str() + ".pdf").c_str()); } } //wfm = (UShort_t*) &(gl_ch_data[event_index + header_length]); //------------------------------------------------------------------------------ // MAW //------------------------------------------------------------------------------ // find the maw maximum value // I hope this is the MAW maw_max = 0; maw_min = INT_MAX; // max value of MAW //UShort_t* maw_adc_buffer_ptr = (UShort_t*) //(&gl_ch_data[i_event*(event_length) + header_length + //wfm_length/2]); // Tino says maw is 32 bits: UInt_t* maw_adc_buffer_ptr = &gl_ch_data[i_event*(event_length) + header_length + wfm_length/2]; for (UInt_t i = 0; i < maw_length; i++ ) { signed int maw_value = maw_adc_buffer_ptr[i] - 0x8000000; // per Tino maw[i] = maw_value; //cout << i // << " | maw_adc_buffer_ptr[i]:" << maw_adc_buffer_ptr[i] // << " | maw_value: " << maw_value // << " | maw[i] " << maw[i] // << endl; if (maw_value > maw_max){ maw_max = maw_value; } if (maw_value < maw_min){ maw_min = maw_value; } } /* if (doDraw) { cout << "maw_max: " << maw_max << endl; cout << "timestamp: " << timestamp << endl; gl_graph_raw->sis3316_draw_chN (wfm_length, &gl_ch_data[event_index + header_length + wfm_length/2], i_ch&0xf); // insert pause cout << "event " << i_event << " | channel " << i_ch << " | enter to continue (q=quit, b=batch)--> "; int val = cin.get(); cout << endl; if (val == (int) 'q' || val == (int) 'Q') { return 0; } if (val == (int) 'b') { doDraw = false; } } */ channel = (gl_ch_data[event_index] & 0xfff0) >> 4; tree[channel]->Fill(); // each buffer should contain data from only one channel if (i_ch != channel_no) { cout << "WARNING -- channel=" << channel << ", channel_no=" << channel_no << endl; } //} // end limit on n events } // end loop over events } // end if(nof_read==8) else { valid_BankBufferHeader_valid_flag = 0 ; } } while(valid_BankBufferHeader_valid_flag == 1) ; printf("\n"); fclose(gl_FILE_DataEvenFilePointer); printf("file closed and finished \n"); bank_buffer_counter++; } gROOT->SetStyle("Plain"); gStyle->SetOptStat(0); gStyle->SetPalette(1); gStyle->SetTitleStyle(0); gStyle->SetTitleBorderSize(0); int n_bins = 200; int min = 0; int max = 16384; const size_t n_channels = 16; const size_t n_colors = 4; TH1D* hist_array[n_channels]; int color[n_colors] = {kRed, kBlue, kGreen+1, kViolet}; int fillStyle[n_channels] = {3004, 3005, 3006, 3007, 3001, 3002, 3003, 3016, 3017, 3018, 3020, 3021}; TH1D frame_hist("frame_hist","",n_bins, min, max); frame_hist.SetXTitle("Waveform max (ADC units)"); frame_hist.SetYTitle("Counts"); for (size_t i = 0; i <n_channels; i++) { ostringstream name; name << "h" << i; TH1D* hist = new TH1D(name.str().c_str(), "", n_bins, min, max); int i_color = i % n_colors; //cout << i << " | " << name.str() << " | " << i_color << endl; hist->SetLineColor(color[i_color]); hist->SetFillColor(color[i_color]); hist->SetFillStyle(fillStyle[i]); hist_array[i] = hist; } TLegend legend(0.1, 0.81, 0.9, 0.99); legend.SetNColumns(4); TCanvas canvas("canvas", ""); canvas.SetLogy(1); canvas.SetGrid(1,1); canvas.SetTopMargin(0.2); double hist_max = 0; frame_hist.Draw(); for (size_t i = 0; i < n_channels; i++) { ostringstream entry; ostringstream name; ostringstream selection; name << "wfm_max >> h" << i; selection << "channel==" << i; int n_counts = tree[0]->Draw(name.str().c_str(), selection.str().c_str(), "same"); cout << i << " | n counts = " << n_counts << " | " << name.str() << " | " << selection.str() << endl; entry << "ch " << i+1 << " (" << n_counts << ")"; TH1D* hist = hist_array[i]; legend.AddEntry(hist, entry.str().c_str(), "f"); if ( n_counts > hist_max ) { hist_max = n_counts; } } frame_hist.SetMaximum(hist_max*1.1); legend.Draw(); canvas.Update(); //canvas.Print((basename_str + ".png").c_str()); //canvas.Print((basename_str + ".pdf").c_str()); for(int i=0; i<=15; i++) {tree[i]->Write();} canvas.Write(); // create a run_tree with event parameters TTree *run_tree = new TTree("run_tree", "run tree"); run_tree->Branch("is_external", &is_external, "is_external/O"); run_tree->Branch("sampling_freq_Hz", &sampling_freq_Hz, "sampling_freq_Hz/F"); run_tree->Branch("wfm_delay", &wfm_delay, "wfm_delay/s"); run_tree->Branch("wfm_length", &wfm_length, "wfm_length/i"); run_tree->Branch("maw_delay", &maw_delay, "maw_delay/s"); run_tree->Branch("maw_length", &maw_length, "maw_length/i"); run_tree->Branch("maw_gap", &maw_gap, "maw_gap/s"); run_tree->Branch("maw_peaking", &maw_peaking, "maw_peaking/s"); run_tree->Branch("maw_thres", &maw_thres, "maw_thres/s"); run_tree->Fill(); run_tree->Write(); } // end loop over arguments/files
void chipSummary(const char *dirName, int chipId) { directory = TString(dirName); if (f && f->IsOpen()) f->Close(); if (f1 && f1->IsOpen()) f1->Close(); if (g && g->IsOpen()) g->Close(); gROOT->SetStyle("Plain"); gStyle->SetPalette(1); gStyle->SetOptStat(0); gStyle->SetTitle(0); gStyle->SetStatFont(132); gStyle->SetTextFont(132); gStyle->SetLabelFont(132, "X"); gStyle->SetLabelFont(132, "Y"); gStyle->SetLabelSize(0.08, "X"); gStyle->SetLabelSize(0.08, "Y"); gStyle->SetNdivisions(6, "X"); gStyle->SetNdivisions(8, "Y"); gStyle->SetTitleFont(132); gROOT->ForceStyle(); tl = new TLatex; tl->SetNDC(kTRUE); tl->SetTextSize(0.09); ts = new TLatex; ts->SetNDC(kTRUE); ts->SetTextSize(0.08); line = new TLine; line->SetLineColor(kRed); line->SetLineStyle(kSolid); box = new TBox; box->SetFillColor(kRed); box->SetFillStyle(3002); f = new TFile(Form("%s/%s", dirName, fileName), "READ"); if (strcmp(fileName, adFileName) == 0) f1 = f; else f1 = new TFile(Form("%s/%s", dirName, adFileName), "READ"); if (strcmp(fileName, trimFileName) == 0) g = f; else g = new TFile(Form("%s/%s", dirName, trimFileName), "READ"); sprintf(fname, "%s/../../macros/criteria-full.dat", dirName); if ( !readCriteria(fname) ) { printf("\nchipSummary> ----> COULD NOT READ GRADING CRITERIA !!!"); printf("chipSummary> ----> Aborting execution of chipgSummaryPage.C ... \n\n", fileName, dirName); break; } TH1D *h1; TH2D *h2; c1 = new TCanvas("c1", "", 800, 800); c1->Clear(); c1->Divide(4,4, 0.01, 0.04); // shrinkPad(0.1, 0.1, 0.1, 0.3); FILE *sCurveFile, *phLinearFile, *phTanhFile; TString noslash(dirName); noslash.ReplaceAll("/", " "); noslash.ReplaceAll(".. ", ""); char string[200]; int pixel_alive; int nDeadPixel(0); int nIneffPixel(0); int nMaskDefect(0); int nNoisy1Pixel(0); int nDeadBumps(0); int nDeadTrimbits(0); int nAddressProblems(0); int nNoisy2Pixel(0); int nThrDefect(0); int nGainDefect(0); int nPedDefect(0); int nPar1Defect(0); int nRootFileProblems(0); int nDoubleFunctCounts(0); int nDoublePerfCounts(0); int nDoubleCounts(0); int nDoubleTrims(0); int nDoublePHs(0); int vcal = dac_findParameter(dirName, "Vcal", chipId); // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Row 1 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // -- Dead pixels c1->cd(1); TH2D *hpm; hpm = (TH2D*)f->Get(Form("PixelMap_C%i", chipId)); if (hpm) { for (int icol = 0; icol < 52; ++icol) { for (int irow = 0; irow < 80; ++irow) { hpm->SetTitle(""); hpm->Draw("colz"); tl->DrawLatex(0.1, 0.92, "Pixel Map"); } } } else { ++nRootFileProblems; } // -- sCurve width and noise level TH1D *hw = new TH1D("hw", "", 100, 0., 600.); TH1D *hd = new TH1D("hd", "", 100, 0., 600.); // Noise in unbonded pixel (not displayed) TH2D *ht = new TH2D("ht", "", 52, 0., 52., 80, 0., 80.); TH1D *htmp; float mN(0.), sN(0.), nN(0.), nN_entries(0.); int over(0), under(0); double htmax(255.), htmin(0.); float thr, sig; int a,b; double minThrDiff(-5.); double maxThrDiff(5.); h2 = (TH2D*)f->Get(Form("vcals_xtalk_C%i", chipId)); sprintf(string, "%s/SCurve_C%i.dat", dirName, chipId); sCurveFile = fopen(string, "r"); if (!sCurveFile) { printf("chipSummary> !!!!!!!!! ----> SCurve: Could not open file %s to read fit results\n", string); } else { for (int i = 0; i < 2; i++) fgets(string, 200, sCurveFile); for (int icol = 0; icol < 52; ++icol) { for (int irow = 0; irow < 80; ++irow) { fscanf(sCurveFile, "%e %e %s %2i %2i", &thr, &sig, string, &a, &b); // printf("chipSummary> sig %e thr %e\n", sig, thr); hw->Fill(sig); thr = thr / 65.; ht->SetBinContent(icol+1, irow+1, thr); if ( h2 ) { if( h2->GetBinContent(icol+1, irow+1) >= minThrDiff) { hd->Fill(sig); } } } } fclose(sCurveFile); c1->cd(2); hw->Draw(); tl->DrawLatex(0.1, 0.92, "S-Curve widths: Noise (e^{-})"); /* c1->cd(15); hd->SetLineColor(kRed); hd->Draw(); tl->DrawLatex(0.1, 0.92, "S-Curve widths of dead bumps"); if ( hd->GetEntries() > 0 ) { ts->DrawLatex(0.55, 0.82, Form("entries: %4.0f", hd->GetEntries())); ts->DrawLatex(0.55, 0.74, Form("#mu:%4.2f", hd->GetMean())); ts->DrawLatex(0.55, 0.66, Form("#sigma: %4.2f", hd->GetRMS())); } */ mN = hw->GetMean(); sN = hw->GetRMS(); nN = hw->Integral(hw->GetXaxis()->GetFirst(), hw->GetXaxis()->GetLast()); nN_entries = hw->GetEntries(); under = hw->GetBinContent(0); over = hw->GetBinContent(hw->GetNbinsX()+1); ts->DrawLatex(0.65, 0.82, Form("N: %4.0f", nN)); ts->DrawLatex(0.65, 0.74, Form("#mu: %4.1f", mN)); ts->DrawLatex(0.65, 0.66, Form("#sigma: %4.1f", sN)); if ( under ) ts->DrawLatex(0.15, 0.55, Form("<= %i", under)); if ( over ) ts->DrawLatex(0.75, 0.55, Form("%i =>", over )); c1->cd(3); if ( ht->GetMaximum() < htmax ) { htmax = ht->GetMaximum(); } if ( ht->GetMinimum() > htmin ) { htmin = ht->GetMinimum(); } ht->GetZaxis()->SetRangeUser(htmin,htmax); ht->Draw("colz"); tl->DrawLatex(0.1, 0.92, "Vcal Threshold Untrimmed"); } // -- Noise level map c1->cd(4); gPad->SetLogy(1); gStyle->SetOptStat(1); float mV(0.), sV(0.), nV(0.), nV_entries(0.); over = 0.; under = 0.; if (!g->IsZombie()) { h1 = (TH1D*)g->Get(Form("VcalThresholdMap_C%iDistribution;7", chipId)); if (h1) { h1->SetTitle(""); h1->SetAxisRange(0., 100.); h1->Draw(); mV = h1->GetMean(); sV = h1->GetRMS(); nV = h1->Integral(h1->GetXaxis()->GetFirst(), h1->GetXaxis()->GetLast()); nV_entries = h1->GetEntries(); under = h1->GetBinContent(0); over = h1->GetBinContent(h1->GetNbinsX()+1); } else { ++nRootFileProblems; mV = 0.; sV = 0.; } ts->DrawLatex(0.15, 0.82, Form("N: %4.0f", nV)); ts->DrawLatex(0.15, 0.74, Form("#mu: %4.1f", mV)); ts->DrawLatex(0.15, 0.66, Form("#sigma: %4.1f", sV)); if ( under ) ts->DrawLatex(0.15, 0.55, Form("<= %i", under)); if ( over ) ts->DrawLatex(0.75, 0.55, Form("%i =>", over )); } tl->DrawLatex(0.1, 0.92, "Vcal Threshold Trimmed"); // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Row 2 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // -- Bump Map TH2D *hbm; c1->cd(5); gStyle->SetOptStat(0); hbm = (TH2D*)f->Get(Form("vcals_xtalk_C%i", chipId)); if (hbm) { h2->SetTitle(""); h2->GetZaxis()->SetRangeUser(minThrDiff, maxThrDiff); h2->Draw("colz"); tl->DrawLatex(0.1, 0.92, "Bump Bonding Problems"); } else { ++nRootFileProblems; } // -- Bump Map c1->cd(6); gPad->SetLogy(1); //gStyle->SetOptStat(1); h1 = (TH1D*)f->Get(Form("vcals_xtalk_C%iDistribution", chipId)); if (h1) { h1->SetTitle(""); h1->GetXaxis()->SetRangeUser(-50., 50.); h1->GetYaxis()->SetRangeUser(0.5, 5.0*h1->GetMaximum()); h1->DrawCopy(); tl->DrawLatex(0.1, 0.92, "Bump Bonding"); } else { ++nRootFileProblems; } // -- Trim bits int trimbitbins(3); c1->cd(7); gPad->SetLogy(1); h1 = (TH1D*)f->Get(Form("TrimBit14_C%i", chipId)); if (h1) { h1->SetTitle(""); h1->SetAxisRange(0., 60.); h1->SetMinimum(0.5); h1->Draw(""); tl->DrawLatex(0.1, 0.92, "Trim Bit Test"); } else { ++nRootFileProblems; } h1 = (TH1D*)f->Get(Form("TrimBit13_C%i", chipId)); if (h1) { h1->SetLineColor(kRed); h1->Draw("same"); } else { ++nRootFileProblems; } h1 = (TH1D*)f->Get(Form("TrimBit11_C%i", chipId)); if (h1) { h1->SetLineColor(kBlue); h1->Draw("same"); } else { ++nRootFileProblems; } h1 = (TH1D*)f->Get(Form("TrimBit7_C%i", chipId)); if (h1) { h1->SetLineColor(kGreen); h1->Draw("same"); } else { ++nRootFileProblems; } // -- For numerics and titels see at end // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Row 3 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // -- Address decoding // -------------------- TH2D *ham; ham = (TH2D*)f1->Get(Form("AddressDecoding_C%i", chipId)); c1->cd(9); gStyle->SetOptStat(0); if (ham) { ham->SetTitle(""); ham->Draw("colz"); tl->DrawLatex(0.1, 0.92, "Address decoding"); } else { ++nRootFileProblems; } // -- Address levels c1->cd(10); gPad->SetLogy(1); h1 = (TH1D*)f1->Get(Form("AddressLevels_C%i", chipId)); if (h1) { h1->SetTitle(""); h1->SetAxisRange(-1500., 1500.); h1->Draw(); tl->DrawLatex(0.1, 0.92, "Address Levels"); } else { ++nRootFileProblems; } // -- PHCalibration: Linear Fit (Gain & Pedesdtal) // ----------------------------------------------- TH1D *hg = new TH1D("hg", "", 300, -2.0, 5.5); TH2D *hgm = new TH2D("hgm", "", 52, 0., 52., 80, 0., 80.); TH1D *hp = new TH1D("hp", "", 900, -300., 600.); hp->StatOverflows(kTRUE); TH1D *rp = new TH1D("rp", "", 900, -300., 600.); rp->StatOverflows(kFALSE); TH1D *htmp; float par0, par1, par2, par3, par4, par5; // Parameters of Vcal vs. Pulse Height Fit float mG(0.), sG(0.), nG(0.), nG_entries(0.); float mP(0.), sP(0.), nP(0.), nP_entries(0.); over = 0.; under = 0.; float ped, gain; int a,b; int mPbin(0), xlow(-100), xup(255), extra(0); // for restricted RMS float pedMin(0), pedMax(1000); double integral(0.); sprintf(string, "%s/phCalibrationFit_C%i.dat", dirName, chipId); phLinearFile = fopen(string, "r"); if (!phLinearFile) { printf("chipSummary> !!!!!!!!! ----> phCal: Could not open file %s to read fit results\n", string); } else { for (int i = 0; i < 2; i++) fgets(string, 200, phLinearFile); for (int icol = 0; icol < 52; ++icol) { for (int irow = 0; irow < 80; ++irow) { fscanf(phLinearFile, "%e %e %e %e %e %e %s %2i %2i", &par0, &par1, &par2, &par3, &par4, &par5, string, &a, &b); if (par2 != 0.) { // dead pixels have par2 == 0. gain = 1./par2; ped = par3; hp->Fill(ped); hg->Fill(gain); hgm->SetBinContent(icol + 1, irow + 1, gain); } } } fclose(phLinearFile); // -- Gain c1->cd(11); mG = hg->GetMean(); sG = hg->GetRMS(); nG = hg->Integral(hg->GetXaxis()->GetFirst(), hg->GetXaxis()->GetLast()); nG_entries = hg->GetEntries(); under = hg->GetBinContent(0); over = hg->GetBinContent(hp->GetNbinsX()+1); gPad->SetLogy(1); hg->GetYaxis()->SetRangeUser(0.5, 5.0*hg->GetMaximum()); hg->Draw(); tl->DrawLatex(0.1, 0.92, "PH Calibration: Gain (ADC/DAC)"); if ( hg->GetMean() > 1.75 ) { ts->DrawLatex(0.15, 0.80, Form("N: %4.0f", nG)); ts->DrawLatex(0.15, 0.72, Form("#mu: %4.2f", mG)); ts->DrawLatex(0.15, 0.64, Form("#sigma: %4.2f", sG)); } else { ts->DrawLatex(0.65, 0.80, Form("N: %4.0f", nG)); ts->DrawLatex(0.65, 0.72, Form("#mu: %4.2f", mG)); ts->DrawLatex(0.65, 0.64, Form("#sigma: %4.2f", sG)); } if ( under ) ts->DrawLatex(0.15, 0.55, Form("<= %i", under)); if ( over ) ts->DrawLatex(0.75, 0.55, Form("%i =>", over )); c1->cd(15); hgm->Draw("colz"); tl->DrawLatex(0.1, 0.92, "PH Calibration: Gain (ADC/DAC)"); // -- Pedestal c1->cd(12); mP = hp->GetMean(); sP = hp->GetRMS(); nP = hp->Integral(hp->GetXaxis()->GetFirst(), hp->GetXaxis()->GetLast()); nP_entries = hp->GetEntries(); if ( nP > 0 ) { // -- restricted RMS integral = 0.; mPbin = -1000; xlow = -1000; xup = 1000; over = 0.; under = 0.; mPbin = hp->GetXaxis()->FindBin(mP); for (int i = 0; integral < pedDistr; i++) { xlow = mPbin-i; xup = mPbin+i; integral = hp->Integral(xlow, xup)/nP; } extra = xup - xlow; } else { xlow = -300; xup = 600; extra = 0; over = 0.; under = 0.; } under = hp->Integral(0, xlow - extra); over = hp->Integral(xup + 1.5*extra, hp->GetNbinsX()); hp->GetXaxis()->SetRange(xlow - extra, xup + 1.5*extra); nP = hp->Integral(hp->GetXaxis()->GetFirst(), hp->GetXaxis()->GetLast()); pedMin = hp->GetBinCenter(xlow-extra); pedMax = hp->GetBinCenter(xup+1.5*extra); cout<< " ========> Ped min " << pedMin << " Ped max " << pedMax << ", over: " << over << " under: " << under << endl; hp->DrawCopy(); rp->Add(hp); rp->GetXaxis()->SetRange(xlow, xup); mP = rp->GetMean(); sP = rp->GetRMS(); // box->DrawBox( rp->GetBinCenter(xlow), 0, rp->GetBinCenter(xup), 1.05*rp->GetMaximum()); rp->SetFillColor(kRed); rp->SetFillStyle(3002); rp->Draw("same"); line->DrawLine(rp->GetBinCenter(xlow), 0, rp->GetBinCenter(xlow), 0.6*rp->GetMaximum()); line->DrawLine(rp->GetBinCenter(xup), 0, rp->GetBinCenter(xup), 0.6*rp->GetMaximum()); tl->DrawLatex(0.1, 0.92, "PH Calibration: Pedestal (DAC)"); if ( hp->GetMean() < 126. ) { ts->DrawLatex(0.65, 0.82, Form("N: %4.0f", nP)); ts->SetTextColor(kRed); ts->DrawLatex(0.65, 0.74, Form("#mu: %4.1f", mP)); ts->DrawLatex(0.65, 0.66, Form("#sigma: %4.1f", sP)); } else { ts->DrawLatex(0.16, 0.82, Form("N: %4.0f", nP)); ts->SetTextColor(kRed); ts->DrawLatex(0.16, 0.74, Form("#mu: %4.1f", mP)); ts->DrawLatex(0.16, 0.66, Form("#sigma: %4.1f", sP)); } if ( under ) ts->DrawLatex(0.15, 0.55, Form("<= %i", under)); if ( over ) ts->DrawLatex(0.75, 0.55, Form("%i =>", over )); ts->SetTextColor(kBlack); } // -- PHCalibration: Tanh Fit (Parameter1) // ---------------------------------------- c1->cd(11); over = 0.; under = 0.; float nPar1(0.), nPar1_entries(0.), mPar1(0.), sPar1(0.); TH1D *hPar1 = new TH1D("par1", "", 350, -1., 6.); sprintf(string, "%s/phCalibrationFitTan_C%i.dat", dirName, chipId); phTanhFile = fopen(string, "r"); if (!phTanhFile) { printf("chipSummary> !!!!!!!!! ----> phCal: Could not open file %s to read fit results\n", string); } else { for (int i = 0; i < 2; i++) fgets(string, 200, phTanhFile); for (int icol = 0; icol < 52; ++icol) { for (int irow = 0; irow < 80; ++irow) { fscanf(phTanhFile, "%e %e %e %e %s %2i %2i", &par0, &par1, &par2, &par3, string, &a, &b); hPar1->Fill(par1); } } fclose(phTanhFile); // -- Parameter 1 hPar1->SetLineColor(kBlue); hPar1->Draw("same"); mPar1 = hPar1->GetMean(); sPar1 = hPar1->GetRMS(); nPar1 = hPar1->Integral(hPar1->GetXaxis()->GetFirst(), hPar1->GetXaxis()->GetLast()); nPar1_entries = hPar1->GetEntries(); under = hPar1->GetBinContent(0); over = hPar1->GetBinContent(hPar1->GetNbinsX()+1); ts->SetTextColor(kBlue); if ( hg->GetMean() > 1.75 ) { ts->DrawLatex(0.15, 0.40, "Par1:"); ts->DrawLatex(0.15, 0.30, Form("N: %4.0f", nPar1)); ts->DrawLatex(0.15, 0.22, Form("#mu: %4.2f", mPar1)); ts->DrawLatex(0.15, 0.14, Form("#sigma: %4.2f", sPar1)); } else { ts->DrawLatex(0.65, 0.40, "Par1:"); ts->DrawLatex(0.65, 0.30, Form("N: %4.0f", nPar1)); ts->DrawLatex(0.65, 0.22, Form("#mu: %4.2f", mPar1)); ts->DrawLatex(0.65, 0.14, Form("#sigma: %4.2f", sPar1)); } if ( under ) ts->DrawLatex(0.15, 0.48, Form("<= %i", under)); if ( over ) ts->DrawLatex(0.75, 0.48, Form("%i =>", over )); ts->SetTextColor(kBlack); } // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Row 4 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Trim Bits // ---------- TH2D *htm = new TH2D("htm", "", 80, 0., 80., 52, 0., 52.); c1->cd(13); gStyle->SetOptStat(0); h2 = (TH2D*)f->Get(Form("TrimMap_C%i;8", chipId)); if (h2) { for (int icol = 0; icol < 52; ++icol) { for (int irow = 0; irow < 80; ++irow) { htm->SetBinContent(irow+1, icol+1, h2->GetBinContent(icol+1, irow+1)); } } h2->SetTitle(""); h2->GetZaxis()->SetRangeUser(0., 16.); h2->Draw("colz"); } else { ++nRootFileProblems; } tl->DrawLatex(0.1, 0.92, "Trim Bits"); FILE *tCalFile; sprintf(string, "%s/../T-calibration/TemperatureCalibration_C%i.dat", dirName, chipId); tCalFile = fopen(string, "r"); char tCalDir[200]; sprintf(tCalDir, "%s/../T-calibration", dirName); if ( tCalFile ) { analyse(tCalDir, chipId); } else { c1->cd(14); TGraph *graph = (TGraph*)f->Get(Form("TempCalibration_C%i", chipId)); if ( graph ) { graph->Draw("A*"); } else { ++nRootFileProblems; } tl->DrawLatex(0.1, 0.92, "Temperature calibration"); } // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // -- Count defects and double counting // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% float fl0, fl1, fl2, fl3, fl4, fl5, tmp; int i1, i2; char hname[200]; // TH2D *get = 0, *hget = 0, *htb0 = 0, *htb1 = 0, *htb2 = 0, *htb3 = 0, *htb4 = 0; // for (int i = 1; i < 6; ++i) { // get = (TH2D*)f->Get(Form("CalThresholdMap_C%i;%i", chipId, i)); // if (get) { // hget = (TH2D*)get->Clone(); // hget->SetName(Form("TB0C%i", i)); // if (i == 1) htb0 = hget; // if (i == 2) htb1 = hget; // if (i == 3) htb2 = hget; // if (i == 4) htb3 = hget; // if (i == 5) htb4 = hget; // } // } TH2D *htb[5]; for (int i = 0; i < 5; ++i) { htb[i] = (TH2D*)f->Get(Form("CalThresholdMap_C%i;%i", chipId, i+1)); htb[i]->SetName(Form("tbC%i%i", chipId, i+1)); } TH2D *htthr = 0; htthr = (TH2D*)f->Get(Form("VcalThresholdMap_C%d;8", chipId)); sprintf(string, "%s/SCurve_C%i.dat", dirName, chipId); sCurveFile = fopen(string, "r"); sprintf(string, "%s/phCalibrationFit_C%i.dat", dirName, chipId); phLinearFile = fopen(string, "r"); sprintf(string, "%s/phCalibrationFitTan_C%i.dat", dirName, chipId); phTanhFile = fopen(string, "r"); if (sCurveFile) for (int i = 0; i < 2; i++) fgets(string, 200, sCurveFile); if (phLinearFile) for (int i = 0; i < 2; i++) fgets(string, 200, phLinearFile); if (phTanhFile) for (int i = 0; i < 2; i++) fgets(string, 200, phTanhFile); int px_counted = 0; int px_funct_counted = 0; int px_perf_counted = 0; int trim_counted = 0; int ph_counted = 0; float tb_diff = 0; float tb, tb0; for (int icol = 0; icol < 52; ++icol) { for (int irow = 0; irow < 80; ++irow) { pixel_alive = 1; px_funct_counted = 0; px_perf_counted = 0; px_counted = 0; trim_counted = 0; ph_counted = 0; // -- Pixel alive if (hpm && hpm->GetBinContent(icol+1, irow+1) == 0) { pixel_alive = 0; ++nDeadPixel; cout << Form("chipSummary> dead pixel %3d %3d: %7.5f", icol, irow, hpm->GetBinContent(icol+1, irow+1)) << endl; } if (hpm && hpm->GetBinContent(icol+1,irow+1) > 10) { ++nNoisy1Pixel; px_counted = 1; px_funct_counted = 1;} if (hpm && hpm->GetBinContent(icol+1, irow+1) < 0) { ++nMaskDefect; px_counted = 1; px_funct_counted = 1;} if (hpm && (hpm->GetBinContent(icol+1, irow+1) < 10) && (hpm->GetBinContent(icol+1, irow+1) > 0) ) { ++nIneffPixel; px_counted = 1; px_funct_counted = 1;} // -- Bump bonding if ( pixel_alive && hbm ) { if ( hbm->GetBinContent(icol+1, irow+1) >= minThrDiff ) { if ( px_counted ) nDoubleCounts++; px_counted = 1; if ( px_funct_counted ) nDoubleFunctCounts++; px_funct_counted = 1; ++nDeadBumps; cout << Form("chipSummary> bump defect %3d %3d: %7.5f", icol, irow, hbm->GetBinContent(icol+1, irow+1)) << endl; } } // -- Trim bits 1 - 4 if ( pixel_alive && htb[0] ) { tb0 = htb[0]->GetBinContent(icol+1, irow+1); for ( int i = 1; i <= 4; i++ ) { if ( htb[i] ) { tb = htb[i]->GetBinContent(icol+1, irow+1); tb_diff = TMath::Abs(tb-tb0); if (tb_diff <= 2) { if ( px_counted ) nDoubleCounts++; px_counted = 1; if ( px_funct_counted ) nDoubleFunctCounts++; px_funct_counted = 1; if ( trim_counted ) nDoubleTrims++; trim_counted = 1; ++nDeadTrimbits; cout << Form("chipSummary> trim bit defect %3d %3d: %4.2f", icol, irow, tb_diff) << endl; } } } } // -- Address decoding if (pixel_alive && ham) { if( ham->GetBinContent(icol+1, irow+1) < 1 ) { if ( px_counted ) nDoubleCounts++; px_counted = 1; if ( px_funct_counted ) nDoubleFunctCounts++; px_funct_counted = 1; ++nAddressProblems; cout << Form("chipSummary> address problem %3d %3d: %7.5f", icol, irow, ham->GetBinContent(icol+1, irow+1)) << endl; } } // -- Threshold if (pixel_alive && htthr) { if ( TMath::Abs(htthr->GetBinContent(icol+1, irow+1) - vcalTrim) > tthrTol ) { if ( px_counted ) nDoubleCounts++; px_counted = 1; if ( px_perf_counted ) nDoublePerfCounts++; px_perf_counted = 1; ++nThrDefect; cout << Form("chipSummary> threshold problem %3d %3d: %7.5f", icol, irow, htthr->GetBinContent(icol+1, irow+1)) << endl; } } // -- Noise fscanf(sCurveFile, "%e %e %s %2i %2i", &fl1, &fl2, string, &i1, &i2); if (pixel_alive) { if ( (fl2 < noiseMin) || (fl2 > noiseMax) ) { if ( px_counted ) nDoubleCounts++; px_counted = 1; if ( px_perf_counted ) nDoublePerfCounts++; px_perf_counted = 1; ++nNoisy2Pixel; cout << Form("chipSummary> noise defect %3d %3d: %7.5f (%2i %2i)", icol, irow, fl2, i1, i2) << endl; } } // -- Gain & Pedestal fscanf(phLinearFile, "%e %e %e %e %e %e %s %2i %2i", &fl0, &fl1, &fl2, &fl3, &fl4, &fl5, string, &i1, &i2); if (pixel_alive) { if (fl2 != 0) gain = 1./fl2; ped = fl3; if ( (gain < gainMin) || (gain > gainMax) ) { if ( px_counted ) nDoubleCounts++; px_counted = 1; if ( px_perf_counted ) nDoublePerfCounts++; px_perf_counted = 1; if ( ph_counted ) nDoublePHs++; ph_counted = 1; ++nGainDefect; cout << Form("chipSummary> gain defect %3d %3d: %7.5f (%2i %2i)", icol, irow, gain, i1, i2) << endl; } if ( (ped < pedMin) || (ped > pedMax) ) { if ( px_counted ) nDoubleCounts++; px_counted = 1; if ( px_perf_counted ) nDoublePerfCounts++; px_perf_counted = 1; if ( ph_counted ) nDoublePHs++; ph_counted = 1; ++nPedDefect; cout << Form("chipSummary> pedestal defect %3d %3d: %7.5f (%2i %2i)", icol, irow, ped, i1, i2) << endl; } } // -- Par1 fscanf(phTanhFile, "%e %e %e %e %s %2i %2i", &fl0, &fl1, &fl2, &fl3, string, &i1, &i2); if (pixel_alive && phTanhFile) { if ( (fl1 < par1Min) || (fl1 > par1Max) ) { if ( px_counted ) nDoubleCounts++; px_counted = 1; if ( px_perf_counted ) nDoublePerfCounts++; px_perf_counted = 1; if ( ph_counted ) nDoublePHs++; ph_counted = 1; ++nPar1Defect; cout << Form("chipSummary> par1 defect %3d %3d: %7.5f (%2i %2i)", icol, irow, par1, i1, i2) << endl; } } } } fclose(sCurveFile); fclose(phLinearFile); fclose(phTanhFile); // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Numerics and Titles // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // -- Compute the final verdict on this chip //?? FIXME (below is pure randomness) float finalVerdict(0); if (nDeadTrimbits > 0) finalVerdict += 1; if (nDeadPixel > 0) finalVerdict += 10; if (nNoisy1Pixel > 0) finalVerdict += 10; if (nAddressProblems > 0) finalVerdict += 10; if (nDeadBumps > 0) finalVerdict += 100; if (nNoisy2Pixel > 0) finalVerdict += 1000; if (nThrDefect > 0) finalVerdict += 10000; if (nGainDefect > 0) finalVerdict += 100000; if (nPedDefect > 0) finalVerdict += 100000; if (nPar1Defect > 0) finalVerdict += 100000; // -- Defects c1->cd(8); tl->SetTextSize(0.10); tl->SetTextFont(22); double y = 0.98; y -= 0.11; tl->DrawLatex(0.1, y, "Summary"); // tl->DrawLatex(0.6, y, Form("%06d", finalVerdict)); tl->SetTextFont(132); tl->SetTextSize(0.09); y -= 0.11; tl->DrawLatex(0.1, y, Form("Dead Pixels: ")); tl->DrawLatex(0.7, y, Form("%4d", nDeadPixel)); // y -= 0.10; // tl->DrawLatex(0.1, y, Form("Noisy Pixels 1: ")); // tl->DrawLatex(0.7, y, Form("%4d", nNoisy1Pixel)); y -= 0.10; tl->DrawLatex(0.1, y, "Mask defects: "); tl->DrawLatex(0.7, y, Form("%4d", nMaskDefect)); y -= 0.10; tl->DrawLatex(0.1, y, "Dead Bumps: "); tl->DrawLatex(0.7, y, Form("%4d", nDeadBumps)); y -= 0.10; tl->DrawLatex(0.1, y, "Dead Trimbits: "); tl->DrawLatex(0.7, y, Form("%4d", nDeadTrimbits)); y -= 0.10; tl->DrawLatex(0.1, y, "Address Probl: "); tl->DrawLatex(0.7, y, Form("%4d", nAddressProblems)); y -= 0.10; tl->DrawLatex(0.1, y, Form("Noisy Pixels 2: ")); tl->DrawLatex(0.7, y, Form("%4d", nNoisy2Pixel)); y -= 0.10; tl->DrawLatex(0.1, y, Form("Trim Probl.: ")); tl->DrawLatex(0.7, y, Form("%4d", nThrDefect)); y -= 0.10; tl->DrawLatex(0.1, y, Form("PH defects: ")); tl->DrawLatex(0.5, y, Form("%4d/", nGainDefect)); tl->SetTextColor(kRed); tl->DrawLatex(0.6, y, Form("%4d/",nPedDefect)); tl->SetTextColor(kBlack); tl->SetTextColor(kBlue); tl->DrawLatex(0.7, y, Form("%4d",nPar1Defect)); tl->SetTextColor(kBlack); // y -= 0.10; // tl->DrawLatex(0.1, y, Form("Par1 defect: ")); // tl->DrawLatex(0.7, y, Form("%4d", nPar1Defect)); // -- Operation Parameters c1->cd(16); y = 0.92; tl->SetTextSize(0.10); tl->SetTextFont(22); y -= 0.11; tl->DrawLatex(0.1, y, Form("Op. Parameters")); tl->SetTextFont(132); tl->SetTextSize(0.09); y -= 0.11; int vana(-1.); vana = dac_findParameter(dirName, "Vana", chipId); tl->DrawLatex(0.1, y, "VANA: "); if (vana >= 0.) tl->DrawLatex(0.6, y, Form("%3i DAC", vana)); else tl->DrawLatex(0.7, y, "N/A"); y -= 0.10; int caldel(-1.); caldel = dac_findParameter(dirName, "CalDel", chipId); tl->DrawLatex(0.1, y, "CALDEL: "); if (vana >= 0.) tl->DrawLatex(0.6, y, Form("%3d DAC", caldel)); else tl->DrawLatex(0.7, y, "N/A"); y -= 0.10; int vthrcomp(-1.); vthrcomp = dac_findParameter(dirName, "VthrComp", chipId); tl->DrawLatex(0.1, y, "VTHR: "); if (vana >= 0.) tl->DrawLatex(0.6, y, Form("%3d DAC", vthrcomp)); else tl->DrawLatex(0.7, y, "N/A"); y -= 0.10; int vtrim(-1.); vtrim = dac_findParameter(dirName, "Vtrim", chipId); tl->DrawLatex(0.1, y, "VTRIM: "); if (vana >= 0.) tl->DrawLatex(0.6, y, Form("%3d DAC", vtrim)); else tl->DrawLatex(0.7, y, "N/A"); y -= 0.10; int ibias(-1.); ibias = dac_findParameter(dirName, "Ibias_DAC", chipId); tl->DrawLatex(0.1, y, "IBIAS_DAC: "); if (vana >= 0.) tl->DrawLatex(0.6, y, Form("%3d DAC", ibias)); else tl->DrawLatex(0.7, y, "N/A"); y -= 0.10; int voffset(-1.); voffset = dac_findParameter(dirName, "VoffsetOp", chipId); tl->DrawLatex(0.1, y, "VOFFSETOP: "); if (vana >= 0.) tl->DrawLatex(0.6, y, Form("%3d DAC", voffset)); else tl->DrawLatex(0.7, y, "N/A"); // -- Page title c1->cd(0); tl->SetTextSize(0.04); tl->SetTextFont(22); tl->DrawLatex(0.02, 0.97, Form("%s (C%i)", noslash.Data(), chipId)); TDatime date; tl->SetTextSize(0.02); tl->DrawLatex(0.75, 0.97, Form("%s", date.AsString())); c1->SaveAs(Form("%s/chipSummary_C%i.ps", dirName, chipId)); c1->SaveAs(Form("%s/C%i.png", dirName, chipId)); // -- Dump into logfile ofstream OUT(Form("%s/summary_C%i.txt", dirName, chipId)); OUT << "nDeadPixel: " << nDeadPixel << endl; OUT << "nNoisy1Pixel: " << nNoisy1Pixel << endl; OUT << "nDeadTrimbits: " << nDeadTrimbits << endl; OUT << "nDeadBumps: " << nDeadBumps << endl; OUT << "nMaskDefect: " << nMaskDefect << endl; OUT << "nAddressProblems: " << nAddressProblems << endl; OUT << "nNoisy2Pixel: " << nNoisy2Pixel << endl; OUT << "nTThrDefect: " << nThrDefect << endl; OUT << "nGainDefect: " << nGainDefect << endl; OUT << "nPedDefect: " << nPedDefect << endl; OUT << "nParDefect: " << nPar1Defect << endl; OUT << "nDoubleCounts: " << nDoubleCounts << endl; OUT << "nDoubleFunctCounts: " << nDoubleFunctCounts << endl; OUT << "nDoublePerfCounts: " << nDoublePerfCounts << endl; OUT << "nDoubleTrims: " << nDoubleTrims << endl; OUT << "nDoublePHs: " << nDoublePHs << endl; OUT << "nRootFileProblems: " << nRootFileProblems << endl; OUT << "SCurve " << nN_entries << " " << mN << " " << sN << endl; OUT << "Threshold " << nV_entries << " " << mV << " " << sV << endl; OUT << "Gain " << nG_entries << " " << mG << " " << sG << endl; OUT << "Pedestal " << nP_entries << " " << mP << " " << sP << endl; OUT << "Parameter1 " << nPar1_entries << " " << mPar1 << " " << sPar1 << endl; OUT.close(); }
void MakeClosurePlot(TH1D* hObs, TH1D* hPred, TString name, bool logy=true) { set_style(hObs,"data_obs"); set_style(hPred,"pred"); // Setup canvas and pads TCanvas * c1 = new TCanvas("c1", "c1", 700, 700); c1->SetFillStyle(4000); TPad * pad1 = new TPad("pad1", "top pad" , 0.0, 0.3, 1.0, 1.0); pad1->SetFillStyle(4000); pad1->SetBottomMargin(0.0); pad1->Draw(); TPad * pad2 = new TPad("pad2", "bottom pad", 0.0, 0.0, 1.0, 0.3); pad2->SetFillStyle(4000); pad2->SetTopMargin(0.0); pad2->SetBottomMargin(0.35); pad2->Draw(); pad1->cd(); pad1->SetLogy(logy); TH1D * staterr = (TH1D *) hPred->Clone("staterr"); // staterr->Sumw2(); //staterr->SetFillColor(kRed); staterr->SetFillColor(kGray+3); staterr->SetMarkerSize(0); staterr->SetFillStyle(3013); //cout << "Compute ratio hist..." << endl; TH1D * ratio = (TH1D *) hPred->Clone("ratio"); //ratio->Sumw2(); ratio->SetMarkerSize(0.8); ratio->SetMarkerColor(1); //ratio->SetMarkerSize(0.5); ratio->Divide(hObs, hPred, 1., 1., "B"); ratio->Print("all"); TH1D * ratiostaterr = (TH1D *) hObs->Clone("ratiostaterr"); // ratiostaterr->Sumw2(); ratiostaterr->SetStats(0); ratiostaterr->SetTitle(hPred->GetTitle()); ratiostaterr->GetYaxis()->SetTitle("Obs/Pred."); ratiostaterr->SetMaximum(2.2); ratiostaterr->SetMinimum(0); ratiostaterr->SetMarkerSize(0); //ratiostaterr->SetFillColor(kRed); ratiostaterr->SetFillColor(kGray+3); ratiostaterr->SetFillStyle(3013); ratiostaterr->GetXaxis()->SetLabelSize(0.2); ratiostaterr->GetXaxis()->SetLabelOffset(0.03); ratiostaterr->GetXaxis()->SetTitleSize(0.14); ratiostaterr->GetXaxis()->SetTitleOffset(1.10); ratiostaterr->GetYaxis()->SetLabelSize(0.10); ratiostaterr->GetYaxis()->SetTitleSize(0.12); ratiostaterr->GetYaxis()->SetTitleOffset(0.6); ratiostaterr->GetYaxis()->SetNdivisions(505); TLine* ratiounity = new TLine(hPred->GetBinLowEdge(1),1,hPred->GetBinLowEdge(hPred->GetNbinsX()+1),1); ratiounity->SetLineStyle(2); for (Int_t i = 0; i < hPred->GetNbinsX()+2; i++) { // if (hObs->GetBinContent(i)>0.) ratio->SetBinError(i, hObs->GetBinError(i)/hObs->GetBinContent(i)); // just the fractional uncertainty on the observation ratiostaterr->SetBinContent(i, 1.0); if (hPred->GetBinContent(i) > 1e-6) { //< not empty double binerror = hPred->GetBinError(i) / hPred->GetBinContent(i); ratiostaterr->SetBinError(i, binerror); } else { ratiostaterr->SetBinError(i, 999.); } } TH1D * ratiosysterr = (TH1D *) ratiostaterr->Clone("ratiosysterr"); // ratiosysterr->Sumw2(); ratiosysterr->SetMarkerSize(0); ratiosysterr->SetFillColor(kYellow-4); //ratiosysterr->SetFillStyle(3002); ratiosysterr->SetFillStyle(1001); for (Int_t i = 0; i < hPred->GetNbinsX()+2; i++) { if (hPred->GetBinContent(i) > 1e-6) { //< not empty double binerror2 = (pow(hPred->GetBinError(i), 2)); double binerror = sqrt(binerror2); ratiosysterr->SetBinError(i, binerror / hPred->GetBinContent(i)); } } double max = hObs->GetMaximum(); if (hPred->GetMaximum() > max) max = hPred->GetMaximum(); if (logy) { hPred->SetMaximum(max*10); hPred->SetMinimum(0.09); } else { hPred->SetMaximum(max*1.5); hPred->SetMinimum(0.); } hPred->GetYaxis()->SetTitle("Events / bin"); hPred->Draw("hist"); hObs->Draw("e1,same"); staterr->Draw("e2 same"); hPred->GetXaxis()->SetTitleSize(0.035); hPred->GetXaxis()->SetLabelSize(0.035); /* hObs->GetYaxis()->SetTitleSize(0.035); */ /* hObs->GetYaxis()->SetLabelSize(0.035); */ TLegend * leg2 = new TLegend(0.72, 0.68, 0.94, 0.92); set_style(leg2,0.035); leg2->AddEntry(hObs,"Obs.","elp"); leg2->AddEntry(hPred,"Pred.","f"); leg2->AddEntry(staterr, "Syst. uncert.", "f"); leg2->Draw(); TLatex * latex = new TLatex(); latex->SetNDC(); latex->SetTextAlign(12); latex->SetTextFont(62); latex->SetTextSize(0.042); latex->DrawLatex(0.19, 0.89, "CMS Simulation"); latex->SetTextSize(0.03); TString stamp = Form("#sqrt{s} = 13 TeV, L = %3.1f fb^{-1}", int_lumi); latex->DrawLatex(0.19, 0.84, stamp); pad2->cd(); pad2->SetGridy(0); ratiostaterr->GetXaxis()->SetRangeUser(0,6); ratiostaterr->Draw("e2"); //ratiosysterr->Draw("e2 same"); ratiostaterr->Draw("e2 same"); ratiounity->Draw(); ratio->Draw("e1 same"); TPaveText * pave = new TPaveText(0.18, 0.86, 0.4, 0.96, "brNDC"); pave->SetLineColor(0); pave->SetFillColor(kWhite); pave->SetShadowColor(0); pave->SetBorderSize(1); double nchisq = hObs->Chi2Test(hPred, "UWCHI2/NDF, P"); // MC uncert. (stat) double p_value = hObs->Chi2Test(hPred, "UW"); // MC uncert. (stat) // //double kolprob = hdata_obs->KolmogorovTest(hmc_pred); // MC uncert. (stat) TText * text = pave->AddText(Form("#chi_{#nu}^{2}/ndf = %.3f, p = %.3f", nchisq, p_value)); // //TText * text = pave->AddText(Form("#chi_{#nu}^{2} = %.3f, K_{s} = %.3f", nchisq, kolprob)); text->SetTextFont(62); text->SetTextSize(0.07); // text->SetTextSize(0.06); pave->Draw(); /* TLegend * ratioleg = new TLegend(0.72, 0.88, 0.94, 0.96); */ /* set_style(ratioleg); */ /* ratioleg->SetTextSize(0.07); */ /* ratioleg->AddEntry(ratiostaterr, "MC uncert. (stat)", "f"); */ /* ratioleg->Draw(); */ pad1->cd(); gPad->RedrawAxis(); gPad->Modified(); gPad->Update(); pad2->cd(); gPad->RedrawAxis(); gPad->Modified(); gPad->Update(); c1->cd(); c1->Print("Closure/plots/no_dp_cut/"+name+".pdf"); delete staterr; delete ratio; delete ratiostaterr; delete ratiosysterr; delete leg2; // delete ratioleg; delete pad1; delete pad2; delete c1; delete latex; }
void draw_from_trees(TString var, TCut other_cuts, TString weights, TString title, int nbinsx, double xlow, double xup, TString options="plotSig:plotLog:plotData", double cut_low=-1, double cut_high=-1, TString plot_title="default") { bool plotSig = options.Contains("plotSig") && (!options.Contains("!plotSig")); bool plotLog = options.Contains("plotLog") && (!options.Contains("!plotLog")); bool plotData = options.Contains("plotData") && (!options.Contains("!plotData")); bool sigStack = options.Contains("sigStack") && (!options.Contains("!sigStack")); // Book histograms TH1D * httbar = new TH1D("ttbar" , title, nbinsx, xlow, xup); TH1D * hqcd = new TH1D("qcd" , title, nbinsx, xlow, xup); TH1D * hznn = new TH1D("znn" , title, nbinsx, xlow, xup); TH1D * hwjets = new TH1D("wjets" , title, nbinsx, xlow, xup); TH1D * hother = new TH1D("other" , title, nbinsx, xlow, xup); TH1D * hmc_exp = new TH1D("mc_exp" , title, nbinsx, xlow, xup); TH1D * hsingle_top = new TH1D("single_top" , title, nbinsx, xlow, xup); TH1D * ht1bbbb_1500_100 = new TH1D("t1bbbb_1500_100" , title, nbinsx, xlow, xup); TH1D * ht1bbbb_1000_900 = new TH1D("t1bbbb_1000_900" , title, nbinsx, xlow, xup); TH1D * ht1tttt_1500_100 = new TH1D("t1tttt_1500_100" , title, nbinsx, xlow, xup); TH1D * ht1tttt_1200_800 = new TH1D("t1tttt_1200_800" , title, nbinsx, xlow, xup); TH1D * ht1qqqq_1400_100 = new TH1D("t1qqqq_1400_100" , title, nbinsx, xlow, xup); TH1D * ht1qqqq_1000_800 = new TH1D("t1qqqq_1000_800" , title, nbinsx, xlow, xup); // Format cuts TCut cut(other_cuts); // TCut ttbar_weight("(weightppb*4000)/top_pt_weight_official"); TCut ttbar_weight("(3.17760399999999981e-05*4000)"); cout << "Filling histograms for " << var.Data() << endl; ttbar_ch->Project("ttbar",var,(cut)*ttbar_weight); qcd_ch->Project("qcd",var,cut*weights); znn_ch->Project("znn",var,cut*weights); wjets_ch->Project("wjets",var,(cut)*weights); other_ch->Project("other",var,cut*weights); single_top_ch->Project("single_top",var,cut*weights); t1bbbb_1500_100_ch->Project("t1bbbb_1500_100",var,(cut)*weights); t1bbbb_1000_900_ch->Project("t1bbbb_1000_900",var,(cut)*weights); t1tttt_1500_100_ch->Project("t1tttt_1500_100",var,(cut)*weights); t1tttt_1200_800_ch->Project("t1tttt_1200_800",var,(cut)*weights); t1qqqq_1400_100_ch->Project("t1qqqq_1400_100",var,(cut)*weights); t1qqqq_1000_800_ch->Project("t1qqqq_1000_800",var,(cut)*weights); bool addOverflow(true); Double_t e_overflow(0.), i_overflow(0.); if (addOverflow) { i_overflow=httbar->IntegralAndError(nbinsx,nbinsx+1,e_overflow); httbar->SetBinContent(nbinsx, i_overflow); httbar->SetBinError(nbinsx, e_overflow); i_overflow=hqcd->IntegralAndError(nbinsx,nbinsx+1,e_overflow); hqcd->SetBinContent(nbinsx, i_overflow); hqcd->SetBinError(nbinsx, e_overflow); i_overflow=hznn->IntegralAndError(nbinsx,nbinsx+1,e_overflow); hznn->SetBinContent(nbinsx, i_overflow); hznn->SetBinError(nbinsx, e_overflow); i_overflow=hwjets->IntegralAndError(nbinsx,nbinsx+1,e_overflow); hwjets->SetBinContent(nbinsx, i_overflow); hwjets->SetBinError(nbinsx, e_overflow); i_overflow=hsingle_top->IntegralAndError(nbinsx,nbinsx+1,e_overflow); hsingle_top->SetBinContent(nbinsx, i_overflow); hsingle_top->SetBinError(nbinsx, e_overflow); i_overflow=hother->IntegralAndError(nbinsx,nbinsx+1,e_overflow); hother->SetBinContent(nbinsx, i_overflow); hother->SetBinError(nbinsx, e_overflow); i_overflow=ht1bbbb_1500_100->IntegralAndError(nbinsx,nbinsx+1,e_overflow); ht1bbbb_1500_100->SetBinContent(nbinsx, i_overflow); ht1bbbb_1500_100->SetBinError(nbinsx, e_overflow); i_overflow=ht1bbbb_1000_900->IntegralAndError(nbinsx,nbinsx+1,e_overflow); ht1bbbb_1000_900->SetBinContent(nbinsx, i_overflow); ht1bbbb_1000_900->SetBinError(nbinsx, e_overflow); i_overflow=ht1tttt_1500_100->IntegralAndError(nbinsx,nbinsx+1,e_overflow); ht1tttt_1500_100->SetBinContent(nbinsx, i_overflow); ht1tttt_1500_100->SetBinError(nbinsx, e_overflow); i_overflow=ht1tttt_1200_800->IntegralAndError(nbinsx,nbinsx+1,e_overflow); ht1tttt_1200_800->SetBinContent(nbinsx, i_overflow); ht1tttt_1200_800->SetBinError(nbinsx, e_overflow); i_overflow=ht1qqqq_1400_100->IntegralAndError(nbinsx,nbinsx+1,e_overflow); ht1qqqq_1400_100->SetBinContent(nbinsx, i_overflow); ht1qqqq_1400_100->SetBinError(nbinsx, e_overflow); i_overflow=ht1qqqq_1000_800->IntegralAndError(nbinsx,nbinsx+1,e_overflow); ht1qqqq_1000_800->SetBinContent(nbinsx, i_overflow); ht1qqqq_1000_800->SetBinError(nbinsx, e_overflow); } // Add up MC histograms hmc_exp->Add(httbar); hmc_exp->Add(hqcd); hmc_exp->Add(hznn); hmc_exp->Add(hwjets); hmc_exp->Add(hsingle_top); hmc_exp->Add(hother); double binwidth = (xup - xlow) / nbinsx; TString ytitle = Form("Events / %.3f", binwidth); hmc_exp->GetXaxis()->SetTitle(httbar->GetXaxis()->GetTitle()); hmc_exp->GetYaxis()->SetTitle(ytitle); cout << "... DONE: add all backgrounds to mc_exp." << endl; Double_t ttbar_e(0.), qcd_e(0.), znn_e(0.), wjets_e(0.), other_e(0.), single_top_e(0.), bg_tot_e(0.), t1tttt_1500_100_e(0.); double ttbar_n(httbar->IntegralAndError(0,nbinsx+1, ttbar_e)); double qcd_n(hqcd->IntegralAndError(0,nbinsx+1, qcd_e)); double znn_n(hznn->IntegralAndError(0,nbinsx+1, znn_e)); double wjets_n(hwjets->IntegralAndError(0,nbinsx+1, wjets_e)); double other_n(hother->IntegralAndError(0,nbinsx+1, other_e)); double single_top_n(hsingle_top->IntegralAndError(0,nbinsx+1, single_top_e)); double bg_tot(hmc_exp->IntegralAndError(0,nbinsx+1, bg_tot_e)); double t1tttt_1500_100_n(ht1tttt_1500_100->IntegralAndError(0,nbinsx+1, t1tttt_1500_100_e)); printf("Counts before cut: %s\n",var.Data()); printf("&ttbar&qcd&znn&wjets&single top&other&t1bbbb_1500_100\\\\ \n"); printf("%s & %3.2f+-%3.2f & %3.2f+-%3.2f & %3.2f+-%3.2f & %3.2f+-%3.2f & %3.2f+-%3.2f & %3.2f+-%3.2f & %3.2f+-%3.2f & %3.2f+-%3.2f \\\\\n", var.Data(), ttbar_n,ttbar_e, qcd_n,qcd_e, znn_n,znn_e, wjets_n,wjets_e, single_top_n,single_top_e, other_n,other_e, // hmc_exp->GetBinContent(1), hmc_exp->GetBinError(1), bg_tot,bg_tot_e, t1tttt_1500_100_n,t1tttt_1500_100_e); cout << "... DONE: filled histograms." << endl; if (sigStack) { for (int bin(0); bin<nbinsx; bin++) { ht1bbbb_1500_100->SetBinContent(bin+1, hmc_exp->GetBinContent(bin+1)); ht1bbbb_1000_900->SetBinContent(bin+1, hmc_exp->GetBinContent(bin+1)); ht1tttt_1500_100->SetBinContent(bin+1, hmc_exp->GetBinContent(bin+1)); ht1tttt_1200_800->SetBinContent(bin+1, hmc_exp->GetBinContent(bin+1)); } } THStack * hs = new THStack("hs", ""); hs->Add(hother); hs->Add(hsingle_top); hs->Add(hwjets); hs->Add(hznn); if (httbar->Integral()>hqcd->Integral()) { hs->Add(hqcd); hs->Add(httbar); } else { hs->Add(httbar); hs->Add(hqcd); } //hs->GetYaxis()->SetTitle("Events / 5 fb^{-1}"); //hs->GetXaxis()->SetTitle(httbar->GetXaxis()->GetTitle()); // Setup histogram styles set_style(httbar, "ttbar"); set_style(hqcd, "qcd"); set_style(hznn, "znn"); set_style(hwjets, "wjets"); set_style(hother, "other"); set_style(hsingle_top, "single_top"); // Setup auxiliary histograms (ratios, errors, etc) TH1D * staterr = (TH1D *) hmc_exp->Clone("staterr"); staterr->Sumw2(); //staterr->SetFillColor(kRed); staterr->SetFillColor(kGray+3); staterr->SetMarkerSize(0); staterr->SetFillStyle(3013); // Setup legends TLegend * leg1 = new TLegend(0.48, 0.6, 0.72, 0.92); set_style(leg1,0.025); if (plotData) leg1->AddEntry(hsingle_top, "Data", "pel"); if (plotSig) { leg1->AddEntry(ht1bbbb_1500_100, "#splitline{T1bbbb}{(1500,100) GeV}", "l"); leg1->AddEntry(ht1bbbb_1000_900, "#splitline{T1bbbb}{(1000,900) GeV}", "l"); leg1->AddEntry(ht1tttt_1500_100, "#splitline{T1tttt}{(1500,100) GeV}", "l"); leg1->AddEntry(ht1tttt_1200_800, "#splitline{T1tttt}{(1200,800) GeV}", "l"); leg1->AddEntry(ht1qqqq_1400_100, "#splitline{T1qqqq}{(1400,100) GeV}", "l"); leg1->AddEntry(ht1qqqq_1000_800, "#splitline{T1qqqq}{(1000,800) GeV}", "l"); } TLegend * leg2 = new TLegend(0.72, 0.6, 0.94, 0.92); set_style(leg2,0.025); if (httbar->Integral()>hqcd->Integral()) { leg2->AddEntry(httbar, "t#bar{t}", "f"); leg2->AddEntry(hqcd, "QCD", "f"); } else { leg2->AddEntry(hqcd, "QCD", "f"); leg2->AddEntry(httbar, "t#bar{t}", "f"); } leg2->AddEntry(hznn, "Z+jets", "f"); leg2->AddEntry(hwjets, "W+jets", "f"); leg2->AddEntry(hsingle_top, "Single Top", "f"); leg2->AddEntry(hother, "Other", "f"); leg2->AddEntry(staterr, "MC uncert.", "f"); double ymax = hs->GetMaximum(); if (ht1tttt_1500_100->GetMaximum()>ymax) ymax=ht1tttt_1500_100->GetMaximum(); if (ht1bbbb_1500_100->GetMaximum()>ymax) ymax=ht1bbbb_1500_100->GetMaximum(); if (ht1qqqq_1400_100->GetMaximum()>ymax) ymax=ht1qqqq_1400_100->GetMaximum(); if(plotLog) { hs->SetMaximum(200*ymax); hs->SetMinimum(0.1); } else { hs->SetMaximum(2*ymax); if (plot_title.Contains("baseline")) hs->SetMaximum(1.3*ymax); } // Vertical lines for cuts TLine* line_low = new TLine(cut_low,0,cut_low,1.5*ymax); TLine* line_high = new TLine(cut_high,0,cut_high,1.5*ymax); set_style(line_low); set_style(line_high); // Setup canvas and pads TCanvas * c1 = new TCanvas("c1", "c1", 700, 700); TPad * pad1 = new TPad("pad1", "top pad" , 0.0, 0.3, 1.0, 1.0); TPad * pad2 = new TPad("pad2", "bottom pad", 0.0, 0.0, 1.0, 0.3); if(plotData) { pad1->SetBottomMargin(0.0); pad1->Draw(); pad2->SetTopMargin(0.0); pad2->SetBottomMargin(0.35); pad2->Draw(); pad1->cd(); pad1->SetLogy(plotLog); } else { c1->cd(); c1->SetLogy(plotLog); } // Draw hists hs->Draw("hist"); hs->SetTitle(hmc_exp->GetTitle()); hs->GetXaxis()->SetTitle(httbar->GetXaxis()->GetTitle()); hs->GetYaxis()->SetTitle(ytitle); hs->GetXaxis()->SetLabelSize(0.03); hs->GetYaxis()->SetLabelSize(0.03); if (plotData) { // hsingle_top->Draw("e1 same"); hs->GetXaxis()->SetLabelSize(0); } staterr->Draw("e2 same"); if (plotSig) { ht1bbbb_1500_100->SetLineColor(2); ht1bbbb_1500_100->SetLineWidth(4); ht1bbbb_1500_100->SetFillColor(0); ht1bbbb_1000_900->SetLineColor(2); ht1bbbb_1000_900->SetLineWidth(4); ht1bbbb_1000_900->SetLineStyle(7); ht1bbbb_1000_900->SetFillColor(0); ht1tttt_1500_100->SetLineColor(kGreen); ht1tttt_1500_100->SetLineWidth(4); ht1tttt_1500_100->SetFillColor(0); ht1tttt_1200_800->SetLineColor(kGreen); ht1tttt_1200_800->SetLineStyle(7); ht1tttt_1200_800->SetLineWidth(4); ht1tttt_1200_800->SetFillColor(0); ht1qqqq_1400_100->SetLineColor(1006); ht1qqqq_1400_100->SetLineWidth(4); ht1qqqq_1400_100->SetFillColor(0); ht1qqqq_1000_800->SetLineColor(1006); ht1qqqq_1000_800->SetLineWidth(4); ht1qqqq_1000_800->SetLineStyle(7); ht1qqqq_1000_800->SetFillColor(0); ht1bbbb_1500_100->Draw("hist same"); ht1bbbb_1000_900->Draw("hist same"); ht1tttt_1500_100->Draw("hist same"); ht1tttt_1200_800->Draw("hist same"); ht1qqqq_1400_100->Draw("hist same"); ht1qqqq_1000_800->Draw("hist same"); } if (cut_low>0) line_low->Draw("same"); if (cut_high>0) line_high->Draw("same"); // Draw legends leg1->Draw(); leg2->Draw(); TLatex * latex = new TLatex(); latex->SetNDC(); latex->SetTextAlign(12); latex->SetTextFont(62); latex->SetTextSize(0.042); latex->DrawLatex(0.19, 0.89, "CMS Simulation"); latex->SetTextSize(0.03); latex->DrawLatex(0.19, 0.84, "#sqrt{s} = 13 TeV, L = 4 fb^{-1}"); // Print cout << "MakePlots(): Printing..." << endl; c1->cd(); if (plot_title.EqualTo("default")) plot_title=plotdir+var; gPad->Print(plotdir+plot_title+".pdf"); // Clean up delete staterr; delete leg1; delete leg2; delete latex; // delete pave; delete hs; delete pad1; delete pad2; delete c1; delete httbar; delete hqcd; delete hznn; delete hwjets; delete hsingle_top; delete hother; delete hmc_exp; delete ht1bbbb_1500_100; delete ht1bbbb_1000_900; delete ht1tttt_1500_100; delete ht1tttt_1200_800; delete ht1qqqq_1400_100; delete ht1qqqq_1000_800; cout << "MakePlots(): DONE!" << endl; return; }
void fitWm(const TString outputDir, // output directory const Double_t lumi, // integrated luminosity (/fb) const Double_t nsigma=0 // vary MET corrections by n-sigmas (nsigma=0 means nominal correction) ) { gBenchmark->Start("fitWm"); //-------------------------------------------------------------------------------------------------------------- // Settings //============================================================================================================== // MET histogram binning and range const Int_t NBINS = 50; const Double_t METMAX = 100; const Double_t PT_CUT = 25; const Double_t ETA_CUT = 2.1; // file format for output plots const TString format("png"); // recoil correction RecoilCorrector recoilCorr("../Recoil/ZmmData/fits.root");//, (!) uncomment to perform corrections to recoil from W-MC/Z-MC //"../Recoil/WmpMC/fits.root", //"../Recoil/WmmMC/fits.root", //"../Recoil/ZmmMC/fits.root"); // NNLO boson pT k-factors TFile nnloCorrFile("/data/blue/ksung/EWKAna/8TeV/Utils/Ratio.root"); TH1D *hNNLOCorr = (TH1D*)nnloCorrFile.Get("RpT_B"); // // input ntuple file names // enum { eData, eWmunu, eEWK, eAntiData, eAntiWmunu, eAntiEWK }; // data type enum vector<TString> fnamev; vector<Int_t> typev; fnamev.push_back("/data/blue/ksung/EWKAna/8TeV/Selection/Wmunu/ntuples/data_select.root"); typev.push_back(eData); fnamev.push_back("/data/blue/ksung/EWKAna/8TeV/Selection/Wmunu/ntuples/wm_select.root"); typev.push_back(eWmunu); fnamev.push_back("/data/blue/ksung/EWKAna/8TeV/Selection/Wmunu/ntuples/ewk_select.root"); typev.push_back(eEWK); fnamev.push_back("/data/blue/ksung/EWKAna/8TeV/Selection/Wmunu/ntuples/top_select.root"); typev.push_back(eEWK); fnamev.push_back("/data/blue/ksung/EWKAna/8TeV/Selection/AntiWmunu/ntuples/data_select.root"); typev.push_back(eAntiData); fnamev.push_back("/data/blue/ksung/EWKAna/8TeV/Selection/AntiWmunu/ntuples/wm_select.root"); typev.push_back(eAntiWmunu); fnamev.push_back("/data/blue/ksung/EWKAna/8TeV/Selection/AntiWmunu/ntuples/ewk_select.root"); typev.push_back(eAntiEWK); fnamev.push_back("/data/blue/ksung/EWKAna/8TeV/Selection/AntiWmunu/ntuples/top_select.root"); typev.push_back(eAntiEWK); //-------------------------------------------------------------------------------------------------------------- // Main analysis code //============================================================================================================== // Create output directory gSystem->mkdir(outputDir,kTRUE); CPlot::sOutDir = outputDir; // // Declare MET histograms // TH1D *hDataMet = new TH1D("hDataMet","", NBINS,0,METMAX); hDataMet->Sumw2(); TH1D *hDataMetm = new TH1D("hDataMetm","", NBINS,0,METMAX); hDataMetm->Sumw2(); TH1D *hDataMetp = new TH1D("hDataMetp","", NBINS,0,METMAX); hDataMetp->Sumw2(); TH1D *hWmunuMet = new TH1D("hWmunuMet","", NBINS,0,METMAX); hWmunuMet->Sumw2(); TH1D *hWmunuMetp = new TH1D("hWmunuMetp","",NBINS,0,METMAX); hWmunuMetp->Sumw2(); TH1D *hWmunuMetm = new TH1D("hWmunuMetm","",NBINS,0,METMAX); hWmunuMetm->Sumw2(); TH1D *hEWKMet = new TH1D("hEWKMet", "", NBINS,0,METMAX); hEWKMet->Sumw2(); TH1D *hEWKMetp = new TH1D("hEWKMetp", "", NBINS,0,METMAX); hEWKMetp->Sumw2(); TH1D *hEWKMetm = new TH1D("hEWKMetm", "", NBINS,0,METMAX); hEWKMetm->Sumw2(); TH1D *hAntiDataMet = new TH1D("hAntiDataMet","", NBINS,0,METMAX); hAntiDataMet->Sumw2(); TH1D *hAntiDataMetm = new TH1D("hAntiDataMetm","", NBINS,0,METMAX); hAntiDataMetm->Sumw2(); TH1D *hAntiDataMetp = new TH1D("hAntiDataMetp","", NBINS,0,METMAX); hAntiDataMetp->Sumw2(); TH1D *hAntiWmunuMet = new TH1D("hAntiWmunuMet","", NBINS,0,METMAX); hAntiWmunuMet->Sumw2(); TH1D *hAntiWmunuMetp = new TH1D("hAntiWmunuMetp","",NBINS,0,METMAX); hAntiWmunuMetp->Sumw2(); TH1D *hAntiWmunuMetm = new TH1D("hAntiWmunuMetm","",NBINS,0,METMAX); hAntiWmunuMetm->Sumw2(); TH1D *hAntiEWKMet = new TH1D("hAntiEWKMet", "", NBINS,0,METMAX); hAntiEWKMet->Sumw2(); TH1D *hAntiEWKMetp = new TH1D("hAntiEWKMetp", "", NBINS,0,METMAX); hAntiEWKMetp->Sumw2(); TH1D *hAntiEWKMetm = new TH1D("hAntiEWKMetm", "", NBINS,0,METMAX); hAntiEWKMetm->Sumw2(); // // Declare variables to read in ntuple // UInt_t runNum, lumiSec, evtNum; UInt_t npv, npu; Float_t genVPt, genVPhi; Float_t scale1fb; Float_t met, metPhi, sumEt, mt, u1, u2; Int_t q; LorentzVector *lep=0; Float_t pfChIso, pfGamIso, pfNeuIso; TFile *infile=0; TTree *intree=0; // // Loop over files // for(UInt_t ifile=0; ifile<fnamev.size(); ifile++) { // Read input file and get the TTrees cout << "Processing " << fnamev[ifile] << "..." << endl; infile = new TFile(fnamev[ifile]); assert(infile); intree = (TTree*)infile->Get("Events"); assert(intree); intree->SetBranchAddress("runNum", &runNum); // event run number intree->SetBranchAddress("lumiSec", &lumiSec); // event lumi section intree->SetBranchAddress("evtNum", &evtNum); // event number intree->SetBranchAddress("npv", &npv); // number of primary vertices intree->SetBranchAddress("npu", &npu); // number of in-time PU events (MC) intree->SetBranchAddress("genVPt", &genVPt); // GEN W boson pT (signal MC) intree->SetBranchAddress("genVPhi", &genVPhi); // GEN W boson phi (signal MC) intree->SetBranchAddress("scale1fb", &scale1fb); // event weight per 1/fb (MC) intree->SetBranchAddress("met", &met); // MET intree->SetBranchAddress("metPhi", &metPhi); // phi(MET) intree->SetBranchAddress("sumEt", &sumEt); // Sum ET intree->SetBranchAddress("mt", &mt); // transverse mass intree->SetBranchAddress("u1", &u1); // parallel component of recoil intree->SetBranchAddress("u2", &u2); // perpendicular component of recoil intree->SetBranchAddress("q", &q); // lepton charge intree->SetBranchAddress("lep", &lep); // lepton 4-vector intree->SetBranchAddress("pfChIso", &pfChIso); intree->SetBranchAddress("pfGamIso", &pfGamIso); intree->SetBranchAddress("pfNeuIso", &pfNeuIso); // // loop over events // for(UInt_t ientry=0; ientry<intree->GetEntries(); ientry++) { intree->GetEntry(ientry); if(lep->Pt() < PT_CUT) continue; if(fabs(lep->Eta()) > ETA_CUT) continue; if( (typev[ifile]==eAntiData || typev[ifile]==eAntiWmunu || typev[ifile]==eAntiEWK) && (pfChIso+pfGamIso+pfNeuIso)>0.5*(lep->Pt()) ) continue; if(typev[ifile]==eData) { hDataMet->Fill(met); if(q>0) { hDataMetp->Fill(met); } else { hDataMetm->Fill(met); } } else if(typev[ifile]==eAntiData) { hAntiDataMet->Fill(met); if(q>0) { hAntiDataMetp->Fill(met); } else { hAntiDataMetm->Fill(met); } } else { Double_t weight = 1; weight *= scale1fb*lumi; if(typev[ifile]==eWmunu) { Double_t corrMet=met, corrMetPhi=metPhi; // apply recoil corrections to W MC Double_t lepPt = lep->Pt(); //Double_t lepPt = gRandom->Gaus(lep->Pt(),0.5); // (!) uncomment to apply scale/res corrections to MC recoilCorr.Correct(corrMet,corrMetPhi,genVPt,genVPhi,lepPt,lep->Phi(),nsigma,q); Double_t nnlocorr=1; for(Int_t ibin=1; ibin<=hNNLOCorr->GetNbinsX(); ibin++) { if(genVPt >= hNNLOCorr->GetBinLowEdge(ibin) && genVPt < (hNNLOCorr->GetBinLowEdge(ibin)+hNNLOCorr->GetBinWidth(ibin))) nnlocorr = hNNLOCorr->GetBinContent(ibin); } //weight *= nnlocorr; // (!) uncomment to apply NNLO corrections hWmunuMet->Fill(corrMet,weight); if(q>0) { hWmunuMetp->Fill(corrMet,weight); } else { hWmunuMetm->Fill(corrMet,weight); } } if(typev[ifile]==eAntiWmunu) { Double_t corrMet=met, corrMetPhi=metPhi; // apply recoil corrections to W MC Double_t lepPt = lep->Pt();//gRandom->Gaus(lep->Pt(),0.5); //Double_t lepPt = gRandom->Gaus(lep->Pt(),0.5); // (!) uncomment to apply scale/res corrections to MC recoilCorr.Correct(corrMet,corrMetPhi,genVPt,genVPhi,lepPt,lep->Phi(),nsigma,q); Double_t nnlocorr=1; for(Int_t ibin=1; ibin<=hNNLOCorr->GetNbinsX(); ibin++) { if(genVPt >= hNNLOCorr->GetBinLowEdge(ibin) && genVPt < (hNNLOCorr->GetBinLowEdge(ibin)+hNNLOCorr->GetBinWidth(ibin))) nnlocorr = hNNLOCorr->GetBinContent(ibin); } //weight *= nnlocorr; // (!) uncomment to apply NNLO corrections hAntiWmunuMet->Fill(corrMet,weight); if(q>0) { hAntiWmunuMetp->Fill(corrMet,weight); } else { hAntiWmunuMetm->Fill(corrMet,weight); } } if(typev[ifile]==eEWK) { hEWKMet->Fill(met,weight); if(q>0) { hEWKMetp->Fill(met,weight); } else { hEWKMetm->Fill(met,weight); } } if(typev[ifile]==eAntiEWK) { hAntiEWKMet->Fill(met,weight); if(q>0) { hAntiEWKMetp->Fill(met,weight); } else { hAntiEWKMetm->Fill(met,weight); } } } } } delete infile; infile=0, intree=0; // // Declare fit parameters for signal and background yields // Note: W signal and EWK+top PDFs are constrained to the ratio described in MC // RooRealVar nSig("nSig","nSig",0.7*(hDataMet->Integral()),0,hDataMet->Integral()); RooRealVar nQCD("nQCD","nQCD",0.3*(hDataMet->Integral()),0,hDataMet->Integral()); RooRealVar cewk("cewk","cewk",0.1,0,5) ; cewk.setVal(hEWKMet->Integral()/hWmunuMet->Integral()); cewk.setConstant(kTRUE); RooFormulaVar nEWK("nEWK","nEWK","cewk*nSig",RooArgList(nSig,cewk)); RooRealVar nAntiSig("nAntiSig","nAntiSig",0.05*(hAntiDataMet->Integral()),0,hAntiDataMet->Integral()); RooRealVar nAntiQCD("nAntiQCD","nAntiQCD",0.9*(hDataMet->Integral()),0,hDataMet->Integral()); RooRealVar dewk("dewk","dewk",0.1,0,5) ; dewk.setVal(hAntiEWKMet->Integral()/hAntiWmunuMet->Integral()); dewk.setConstant(kTRUE); RooFormulaVar nAntiEWK("nAntiEWK","nAntiEWK","dewk*nAntiSig",RooArgList(nAntiSig,dewk)); RooRealVar nSigp("nSigp","nSigp",0.7*(hDataMetp->Integral()),0,hDataMetp->Integral()); RooRealVar nQCDp("nQCDp","nQCDp",0.3*(hDataMetp->Integral()),0,hDataMetp->Integral()); RooRealVar cewkp("cewkp","cewkp",0.1,0,5) ; cewkp.setVal(hEWKMetp->Integral()/hWmunuMetp->Integral()); cewkp.setConstant(kTRUE); RooFormulaVar nEWKp("nEWKp","nEWKp","cewkp*nSigp",RooArgList(nSigp,cewkp)); RooRealVar nAntiSigp("nAntiSigp","nAntiSigp",0.05*(hAntiDataMetp->Integral()),0,hAntiDataMetp->Integral()); RooRealVar nAntiQCDp("nAntiQCDp","nAntiQCDp",0.9*(hAntiDataMetp->Integral()),0,hAntiDataMetp->Integral()); RooRealVar dewkp("dewkp","dewkp",0.1,0,5) ; dewkp.setVal(hAntiEWKMetp->Integral()/hAntiWmunuMetp->Integral()); dewkp.setConstant(kTRUE); RooFormulaVar nAntiEWKp("nAntiEWKp","nAntiEWKp","dewkp*nAntiSigp",RooArgList(nAntiSigp,dewkp)); RooRealVar nSigm("nSigm","nSigm",0.7*(hDataMetm->Integral()),0,hDataMetm->Integral()); RooRealVar nQCDm("nQCDm","nQCDm",0.3*(hDataMetm->Integral()),0,hDataMetm->Integral()); RooRealVar cewkm("cewkm","cewkm",0.1,0,5) ; cewkm.setVal(hEWKMetm->Integral()/hWmunuMetm->Integral()); cewkm.setConstant(kTRUE); RooFormulaVar nEWKm("nEWKm","nEWKm","cewkm*nSigm",RooArgList(nSigm,cewkm)); RooRealVar nAntiSigm("nAntiSigm","nAntiSigm",0.05*(hAntiDataMetm->Integral()),0,hAntiDataMetm->Integral()); RooRealVar nAntiQCDm("nAntiQCDm","nAntiQCDm",0.9*(hAntiDataMetm->Integral()),0,hAntiDataMetm->Integral()); RooRealVar dewkm("dewkm","dewkm",0.1,0,5) ; dewkm.setVal(hAntiEWKMetm->Integral()/hAntiWmunuMetm->Integral()); dewkm.setConstant(kTRUE); RooFormulaVar nAntiEWKm("nAntiEWKm","nAntiEWKm","dewkm*nAntiSigm",RooArgList(nAntiSigm,dewkm)); // // Construct PDFs for fitting // RooRealVar pfmet("pfmet","pfmet",0,METMAX); pfmet.setBins(NBINS); // Signal PDFs RooDataHist wmunuMet ("wmunuMET", "wmunuMET", RooArgSet(pfmet),hWmunuMet); RooHistPdf pdfWm ("wm", "wm", pfmet,wmunuMet, 1); RooDataHist wmunuMetp("wmunuMETp","wmunuMETp",RooArgSet(pfmet),hWmunuMetp); RooHistPdf pdfWmp("wmp","wmp",pfmet,wmunuMetp,1); RooDataHist wmunuMetm("wmunuMETm","wmunuMETm",RooArgSet(pfmet),hWmunuMetm); RooHistPdf pdfWmm("wmm","wmm",pfmet,wmunuMetm,1); // EWK+top PDFs RooDataHist ewkMet ("ewkMET", "ewkMET", RooArgSet(pfmet),hEWKMet); RooHistPdf pdfEWK ("ewk", "ewk", pfmet,ewkMet, 1); RooDataHist ewkMetp("ewkMETp","ewkMETp",RooArgSet(pfmet),hEWKMetp); RooHistPdf pdfEWKp("ewkp","ewkp",pfmet,ewkMetp,1); RooDataHist ewkMetm("ewkMETm","ewkMETm",RooArgSet(pfmet),hEWKMetm); RooHistPdf pdfEWKm("ewkm","ewkm",pfmet,ewkMetm,1); // QCD Pdfs CPepeModel1 qcd("qcd",pfmet); CPepeModel1 qcdp("qcdp",pfmet); CPepeModel1 qcdm("qcdm",pfmet); // Signal + Background PDFs RooAddPdf pdfMet ("pdfMet", "pdfMet", RooArgList(pdfWm,pdfEWK,*(qcd.model)), RooArgList(nSig,nEWK,nQCD)); RooAddPdf pdfMetp("pdfMetp","pdfMetp",RooArgList(pdfWmp,pdfEWKp,*(qcdp.model)),RooArgList(nSigp,nEWKp,nQCDp)); RooAddPdf pdfMetm("pdfMetm","pdfMetm",RooArgList(pdfWmm,pdfEWKm,*(qcdm.model)),RooArgList(nSigm,nEWKm,nQCDm)); // Anti-Signal PDFs RooDataHist awmunuMet ("awmunuMET", "awmunuMET", RooArgSet(pfmet),hAntiWmunuMet); RooHistPdf apdfWm ("awm", "awm", pfmet,awmunuMet, 1); RooDataHist awmunuMetp("awmunuMETp","awmunuMETp",RooArgSet(pfmet),hAntiWmunuMetp); RooHistPdf apdfWmp("awmp","awmp",pfmet,awmunuMetp,1); RooDataHist awmunuMetm("awmunuMETm","awmunuMETm",RooArgSet(pfmet),hAntiWmunuMetm); RooHistPdf apdfWmm("awmm","awmm",pfmet,awmunuMetm,1); // Anti-EWK+top PDFs RooDataHist aewkMet ("aewkMET", "aewkMET", RooArgSet(pfmet),hAntiEWKMet); RooHistPdf apdfEWK ("aewk", "aewk", pfmet,aewkMet, 1); RooDataHist aewkMetp("aewkMETp","aewkMETp",RooArgSet(pfmet),hAntiEWKMetp); RooHistPdf apdfEWKp("aewkp","aewkp",pfmet,aewkMetp,1); RooDataHist aewkMetm("aewkMETm","aewkMETm",RooArgSet(pfmet),hAntiEWKMetm); RooHistPdf apdfEWKm("aewkm","aewkm",pfmet,aewkMetm,1); // Anti-QCD Pdfs CPepeModel1 aqcd("aqcd",pfmet,qcd.a1); CPepeModel1 aqcdp("aqcdp",pfmet,qcdp.a1); CPepeModel1 aqcdm("aqcdm",pfmet,qcdm.a1); // Anti-selection PDFs RooAddPdf apdfMet ("apdfMet", "apdfMet", RooArgList(apdfWm,apdfEWK,*(aqcd.model)), RooArgList(nAntiSig,nAntiEWK,nAntiQCD)); RooAddPdf apdfMetp("apdfMetp","apdfMetp",RooArgList(apdfWmp,apdfEWKp,*(aqcdp.model)),RooArgList(nAntiSigp,nAntiEWKp,nAntiQCDp)); RooAddPdf apdfMetm("apdfMetm","apdfMetm",RooArgList(apdfWmm,apdfEWKm,*(aqcdm.model)),RooArgList(nAntiSigm,nAntiEWKm,nAntiQCDm)); // PDF for simultaneous fit RooCategory rooCat("rooCat","rooCat"); rooCat.defineType("Select"); rooCat.defineType("Anti"); RooSimultaneous pdfTotal("pdfTotal","pdfTotal",rooCat); pdfTotal.addPdf(pdfMet, "Select"); pdfTotal.addPdf(apdfMet,"Anti"); RooSimultaneous pdfTotalp("pdfTotalp","pdfTotalp",rooCat); pdfTotalp.addPdf(pdfMetp, "Select"); pdfTotalp.addPdf(apdfMetp,"Anti"); RooSimultaneous pdfTotalm("pdfTotalm","pdfTotalm",rooCat); pdfTotalm.addPdf(pdfMetm, "Select"); pdfTotalm.addPdf(apdfMetm,"Anti"); // // Perform fits // RooDataHist dataMet("dataMet", "dataMet", RooArgSet(pfmet), hDataMet); RooDataHist antiMet("antiMet", "antiMet", RooArgSet(pfmet), hAntiDataMet); RooDataHist dataTotal("dataTotal","dataTotal", RooArgList(pfmet), Index(rooCat), Import("Select", dataMet), Import("Anti", antiMet)); RooFitResult *fitRes = pdfTotal.fitTo(dataTotal,Extended(),Minos(kTRUE),Save(kTRUE)); RooDataHist dataMetp("dataMetp", "dataMetp", RooArgSet(pfmet), hDataMetp); RooDataHist antiMetp("antiMetp", "antiMetp", RooArgSet(pfmet), hAntiDataMetp); RooDataHist dataTotalp("dataTotalp","dataTotalp", RooArgList(pfmet), Index(rooCat), Import("Select", dataMetp), Import("Anti", antiMetp)); RooFitResult *fitResp = pdfTotalp.fitTo(dataTotalp,Extended(),Minos(kTRUE),Save(kTRUE)); RooDataHist dataMetm("dataMetm", "dataMetm", RooArgSet(pfmet), hDataMetm); RooDataHist antiMetm("antiMetm", "antiMetm", RooArgSet(pfmet), hAntiDataMetm); RooDataHist dataTotalm("dataTotalm","dataTotalm", RooArgList(pfmet), Index(rooCat), Import("Select", dataMetm), Import("Anti", antiMetm)); RooFitResult *fitResm = pdfTotalm.fitTo(dataTotalm,Extended(),Minos(kTRUE),Save(kTRUE)); // // Use histogram version of fitted PDFs to make ratio plots // (Will also use PDF histograms later for Chi^2 and KS tests) // TH1D *hPdfMet = (TH1D*)(pdfMet.createHistogram("hPdfMet", pfmet)); hPdfMet->Scale((nSig.getVal()+nEWK.getVal()+nQCD.getVal())/hPdfMet->Integral()); TH1D *hMetDiff = makeDiffHist(hDataMet,hPdfMet,"hMetDiff"); hMetDiff->SetMarkerStyle(kFullCircle); hMetDiff->SetMarkerSize(0.9); TH1D *hPdfMetp = (TH1D*)(pdfMetp.createHistogram("hPdfMetp", pfmet)); hPdfMetp->Scale((nSigp.getVal()+nEWKp.getVal()+nQCDp.getVal())/hPdfMetp->Integral()); TH1D *hMetpDiff = makeDiffHist(hDataMetp,hPdfMetp,"hMetpDiff"); hMetpDiff->SetMarkerStyle(kFullCircle); hMetpDiff->SetMarkerSize(0.9); TH1D *hPdfMetm = (TH1D*)(pdfMetm.createHistogram("hPdfMetm", pfmet)); hPdfMetm->Scale((nSigm.getVal()+nEWKm.getVal()+nQCDm.getVal())/hPdfMetm->Integral()); TH1D *hMetmDiff = makeDiffHist(hDataMetm,hPdfMetm,"hMetmDiff"); hMetmDiff->SetMarkerStyle(kFullCircle); hMetmDiff->SetMarkerSize(0.9); TH1D *hPdfAntiMet = (TH1D*)(apdfMet.createHistogram("hPdfAntiMet", pfmet)); hPdfAntiMet->Scale((nAntiSig.getVal()+nAntiEWK.getVal()+nAntiQCD.getVal())/hPdfAntiMet->Integral()); TH1D *hAntiMetDiff = makeDiffHist(hAntiDataMet,hPdfAntiMet,"hAntiMetDiff"); hAntiMetDiff->SetMarkerStyle(kFullCircle); hAntiMetDiff->SetMarkerSize(0.9); TH1D *hPdfAntiMetp = (TH1D*)(apdfMetp.createHistogram("hPdfAntiMetp", pfmet)); hPdfAntiMetp->Scale((nAntiSigp.getVal()+nAntiEWKp.getVal()+nAntiQCDp.getVal())/hPdfAntiMetp->Integral()); TH1D *hAntiMetpDiff = makeDiffHist(hAntiDataMetp,hPdfAntiMetp,"hAntiMetpDiff"); hAntiMetpDiff->SetMarkerStyle(kFullCircle); hAntiMetpDiff->SetMarkerSize(0.9); TH1D *hPdfAntiMetm = (TH1D*)(apdfMetm.createHistogram("hPdfAntiMetm", pfmet)); hPdfAntiMetm->Scale((nAntiSigm.getVal()+nAntiEWKm.getVal()+nAntiQCDm.getVal())/hPdfAntiMetm->Integral()); TH1D *hAntiMetmDiff = makeDiffHist(hAntiDataMetm,hPdfAntiMetm,"hAntiMetmDiff"); hAntiMetmDiff->SetMarkerStyle(kFullCircle); hAntiMetmDiff->SetMarkerSize(0.9); //-------------------------------------------------------------------------------------------------------------- // Make plots //============================================================================================================== TCanvas *c = MakeCanvas("c","c",800,800); c->Divide(1,2,0,0); c->cd(1)->SetPad(0,0.3,1.0,1.0); c->cd(1)->SetTopMargin(0.1); c->cd(1)->SetBottomMargin(0.01); c->cd(1)->SetLeftMargin(0.15); c->cd(1)->SetRightMargin(0.07); c->cd(1)->SetTickx(1); c->cd(1)->SetTicky(1); c->cd(2)->SetPad(0,0,1.0,0.3); c->cd(2)->SetTopMargin(0.05); c->cd(2)->SetBottomMargin(0.45); c->cd(2)->SetLeftMargin(0.15); c->cd(2)->SetRightMargin(0.07); c->cd(2)->SetTickx(1); c->cd(2)->SetTicky(1); gStyle->SetTitleOffset(1.100,"Y"); TGaxis::SetMaxDigits(3); char ylabel[100]; // string buffer for y-axis label // label for lumi char lumitext[100]; if(lumi<0.1) sprintf(lumitext,"%.1f pb^{-1} at #sqrt{s} = 8 TeV",lumi*1000.); else sprintf(lumitext,"%.2f fb^{-1} at #sqrt{s} = 8 TeV",lumi); // plot colors Int_t linecolorW = kOrange-3; Int_t fillcolorW = kOrange-2; Int_t linecolorEWK = kOrange+10; Int_t fillcolorEWK = kOrange+7; Int_t linecolorQCD = kViolet+2; Int_t fillcolorQCD = kViolet-5; Int_t ratioColor = kGray+2; // // Dummy histograms for TLegend // (I can't figure out how to properly pass RooFit objects...) // TH1D *hDummyData = new TH1D("hDummyData","",0,0,10); hDummyData->SetMarkerStyle(kFullCircle); hDummyData->SetMarkerSize(0.9); TH1D *hDummyW = new TH1D("hDummyW","",0,0,10); hDummyW->SetLineColor(linecolorW); hDummyW->SetFillColor(fillcolorW); hDummyW->SetFillStyle(1001); TH1D *hDummyEWK = new TH1D("hDummyEWK","",0,0,10); hDummyEWK->SetLineColor(linecolorEWK); hDummyEWK->SetFillColor(fillcolorEWK); hDummyEWK->SetFillStyle(1001); TH1D *hDummyQCD = new TH1D("hDummyQCD","",0,0,10); hDummyQCD->SetLineColor(linecolorQCD); hDummyQCD->SetFillColor(fillcolorQCD); hDummyQCD->SetFillStyle(1001); // // W MET plot // RooPlot *wmframe = pfmet.frame(Bins(NBINS)); wmframe->GetYaxis()->SetNdivisions(505); dataMet.plotOn(wmframe,MarkerStyle(kFullCircle),MarkerSize(0.9),DrawOption("ZP")); pdfMet.plotOn(wmframe,FillColor(fillcolorW),DrawOption("F")); pdfMet.plotOn(wmframe,LineColor(linecolorW)); pdfMet.plotOn(wmframe,Components(RooArgSet(pdfEWK,*(qcd.model))),FillColor(fillcolorEWK),DrawOption("F")); pdfMet.plotOn(wmframe,Components(RooArgSet(pdfEWK,*(qcd.model))),LineColor(linecolorEWK)); pdfMet.plotOn(wmframe,Components(RooArgSet(*(qcd.model))),FillColor(fillcolorQCD),DrawOption("F")); pdfMet.plotOn(wmframe,Components(RooArgSet(*(qcd.model))),LineColor(linecolorQCD)); pdfMet.plotOn(wmframe,Components(RooArgSet(pdfWm)),LineColor(linecolorW),LineStyle(2)); dataMet.plotOn(wmframe,MarkerStyle(kFullCircle),MarkerSize(0.9),DrawOption("ZP")); sprintf(ylabel,"Events / %.1f GeV",hDataMet->GetBinWidth(1)); CPlot plotMet("fitmet",wmframe,"","",ylabel); plotMet.SetLegend(0.68,0.57,0.93,0.77); plotMet.GetLegend()->AddEntry(hDummyData,"data","PL"); plotMet.GetLegend()->AddEntry(hDummyW,"W#rightarrow#mu#nu","F"); plotMet.GetLegend()->AddEntry(hDummyEWK,"EWK+t#bar{t}","F"); plotMet.GetLegend()->AddEntry(hDummyQCD,"QCD","F"); plotMet.AddTextBox(lumitext,0.55,0.80,0.90,0.86,0); plotMet.AddTextBox("CMS Preliminary",0.63,0.92,0.95,0.99,0); plotMet.SetYRange(0.1,1.1*(hDataMet->GetMaximum())); plotMet.Draw(c,kFALSE,format,1); CPlot plotMetDiff("fitmet","","#slash{E}_{T} [GeV]","#chi"); plotMetDiff.AddHist1D(hMetDiff,"EX0",ratioColor); plotMetDiff.SetYRange(-8,8); plotMetDiff.AddLine(0, 0,METMAX, 0,kBlack,1); plotMetDiff.AddLine(0, 5,METMAX, 5,kBlack,3); plotMetDiff.AddLine(0,-5,METMAX,-5,kBlack,3); plotMetDiff.Draw(c,kTRUE,format,2); plotMet.SetName("fitmetlog"); plotMet.SetLogy(); plotMet.SetYRange(1e-3*(hDataMet->GetMaximum()),10*(hDataMet->GetMaximum())); plotMet.Draw(c,kTRUE,format,1); RooPlot *awmframe = pfmet.frame(Bins(NBINS)); antiMet.plotOn(awmframe,MarkerStyle(kFullCircle),MarkerSize(0.9),DrawOption("ZP")); apdfMet.plotOn(awmframe,FillColor(fillcolorW),DrawOption("F")); apdfMet.plotOn(awmframe,LineColor(linecolorW)); apdfMet.plotOn(awmframe,Components(RooArgSet(apdfEWK,*(aqcd.model))),FillColor(fillcolorEWK),DrawOption("F")); apdfMet.plotOn(awmframe,Components(RooArgSet(apdfEWK,*(aqcd.model))),LineColor(linecolorEWK)); apdfMet.plotOn(awmframe,Components(RooArgSet(*(aqcd.model))),FillColor(fillcolorQCD),DrawOption("F")); apdfMet.plotOn(awmframe,Components(RooArgSet(*(aqcd.model))),LineColor(linecolorQCD)); apdfMet.plotOn(awmframe,Components(RooArgSet(apdfWm)),LineColor(linecolorW),LineStyle(2)); antiMet.plotOn(awmframe,MarkerStyle(kFullCircle),MarkerSize(0.9),DrawOption("ZP")); sprintf(ylabel,"Events / %.1f GeV",hAntiDataMet->GetBinWidth(1)); CPlot plotAntiMet("fitantimet",awmframe,"","",ylabel); plotAntiMet.SetLegend(0.68,0.57,0.93,0.77); plotAntiMet.GetLegend()->AddEntry(hDummyData,"data","PL"); plotAntiMet.GetLegend()->AddEntry(hDummyW,"W#rightarrow#mu#nu","F"); plotAntiMet.GetLegend()->AddEntry(hDummyEWK,"EWK+t#bar{t}","F"); plotAntiMet.GetLegend()->AddEntry(hDummyQCD,"QCD","F"); plotAntiMet.AddTextBox(lumitext,0.55,0.80,0.90,0.86,0); plotAntiMet.AddTextBox("CMS Preliminary",0.63,0.92,0.95,0.99,0); plotAntiMet.SetYRange(0.1,1.1*(hAntiDataMet->GetMaximum())); plotAntiMet.Draw(c,kFALSE,format,1); CPlot plotAntiMetDiff("fitantimet","","#slash{E}_{T} [GeV]","#chi"); plotAntiMetDiff.AddHist1D(hMetDiff,"EX0",ratioColor); plotAntiMetDiff.SetYRange(-8,8); plotAntiMetDiff.AddLine(0, 0,METMAX, 0,kBlack,1); plotAntiMetDiff.AddLine(0, 5,METMAX, 5,kBlack,3); plotAntiMetDiff.AddLine(0,-5,METMAX,-5,kBlack,3); plotAntiMetDiff.Draw(c,kTRUE,format,2); plotAntiMet.SetName("fitantimetlog"); plotAntiMet.SetLogy(); plotAntiMet.SetYRange(1e-3*(hAntiDataMet->GetMaximum()),10*(hAntiDataMet->GetMaximum())); plotAntiMet.Draw(c,kTRUE,format,1); // // W+ MET plot // RooPlot *wmpframe = pfmet.frame(Bins(NBINS)); wmpframe->GetYaxis()->SetNdivisions(505); dataMetp.plotOn(wmpframe,MarkerStyle(kFullCircle),MarkerSize(0.9),DrawOption("ZP")); pdfMetp.plotOn(wmpframe,FillColor(fillcolorW),DrawOption("F")); pdfMetp.plotOn(wmpframe,LineColor(linecolorW)); pdfMetp.plotOn(wmpframe,Components(RooArgSet(pdfEWKp,*(qcdp.model))),FillColor(fillcolorEWK),DrawOption("F")); pdfMetp.plotOn(wmpframe,Components(RooArgSet(pdfEWKp,*(qcdp.model))),LineColor(linecolorEWK)); pdfMetp.plotOn(wmpframe,Components(RooArgSet(*(qcdp.model))),FillColor(fillcolorQCD),DrawOption("F")); pdfMetp.plotOn(wmpframe,Components(RooArgSet(*(qcdp.model))),LineColor(linecolorQCD)); pdfMetp.plotOn(wmpframe,Components(RooArgSet(pdfWmp)),LineColor(linecolorW),LineStyle(2)); dataMetp.plotOn(wmpframe,MarkerStyle(kFullCircle),MarkerSize(0.9),DrawOption("ZP")); sprintf(ylabel,"Events / %.1f GeV",hDataMetp->GetBinWidth(1)); CPlot plotMetp("fitmetp",wmpframe,"","",ylabel); plotMetp.SetLegend(0.68,0.57,0.93,0.77); plotMetp.GetLegend()->AddEntry(hDummyData,"data","PL"); plotMetp.GetLegend()->AddEntry(hDummyW,"W^{+}#rightarrow#mu^{+}#nu","F"); plotMetp.GetLegend()->AddEntry(hDummyEWK,"EWK+t#bar{t}","F"); plotMetp.GetLegend()->AddEntry(hDummyQCD,"QCD","F"); plotMetp.AddTextBox(lumitext,0.55,0.80,0.90,0.86,0); plotMetp.AddTextBox("CMS Preliminary",0.63,0.92,0.95,0.99,0); // plotMetp.SetYRange(0.1,1.1*(hDataMetp->GetMaximum())); plotMetp.SetYRange(0.1,4100); plotMetp.Draw(c,kFALSE,format,1); CPlot plotMetpDiff("fitmetp","","#slash{E}_{T} [GeV]","#chi"); plotMetpDiff.AddHist1D(hMetpDiff,"EX0",ratioColor); plotMetpDiff.SetYRange(-8,8); plotMetpDiff.AddLine(0, 0,METMAX, 0,kBlack,1); plotMetpDiff.AddLine(0, 5,METMAX, 5,kBlack,3); plotMetpDiff.AddLine(0,-5,METMAX,-5,kBlack,3); plotMetpDiff.Draw(c,kTRUE,format,2); plotMetp.SetName("fitmetplog"); plotMetp.SetLogy(); plotMetp.SetYRange(1e-3*(hDataMetp->GetMaximum()),10*(hDataMetp->GetMaximum())); plotMetp.Draw(c,kTRUE,format,1); RooPlot *awmpframe = pfmet.frame(Bins(NBINS)); antiMetp.plotOn(awmpframe,MarkerStyle(kFullCircle),MarkerSize(0.9),DrawOption("ZP")); apdfMetp.plotOn(awmpframe,FillColor(fillcolorW),DrawOption("F")); apdfMetp.plotOn(awmpframe,LineColor(linecolorW)); apdfMetp.plotOn(awmpframe,Components(RooArgSet(apdfEWKp,*(aqcdp.model))),FillColor(fillcolorEWK),DrawOption("F")); apdfMetp.plotOn(awmpframe,Components(RooArgSet(apdfEWKp,*(aqcdp.model))),LineColor(linecolorEWK)); apdfMetp.plotOn(awmpframe,Components(RooArgSet(*(aqcdp.model))),FillColor(fillcolorQCD),DrawOption("F")); apdfMetp.plotOn(awmpframe,Components(RooArgSet(*(aqcdp.model))),LineColor(linecolorQCD)); apdfMetp.plotOn(awmpframe,Components(RooArgSet(apdfWmp)),LineColor(linecolorW),LineStyle(2)); antiMetp.plotOn(awmpframe,MarkerStyle(kFullCircle),MarkerSize(0.9),DrawOption("ZP")); sprintf(ylabel,"Events / %.1f GeV",hAntiDataMetp->GetBinWidth(1)); CPlot plotAntiMetp("fitantimetp",awmpframe,"","",ylabel); plotAntiMetp.SetLegend(0.68,0.57,0.93,0.77); plotAntiMetp.GetLegend()->AddEntry(hDummyData,"data","PL"); plotAntiMetp.GetLegend()->AddEntry(hDummyW,"W^{+}#rightarrow#mu^{+}#nu","F"); plotAntiMetp.GetLegend()->AddEntry(hDummyEWK,"EWK+t#bar{t}","F"); plotAntiMetp.GetLegend()->AddEntry(hDummyQCD,"QCD","F"); plotAntiMetp.AddTextBox(lumitext,0.55,0.80,0.90,0.86,0); plotAntiMetp.AddTextBox("CMS Preliminary",0.63,0.92,0.95,0.99,0); // plotAntiMetp.SetYRange(0.1,1.1*(hAntiDataMetp->GetMaximum())); plotAntiMetp.SetYRange(0.1,1500); plotAntiMetp.Draw(c,kFALSE,format,1); CPlot plotAntiMetpDiff("fitantimetp","","#slash{E}_{T} [GeV]","#chi"); plotAntiMetpDiff.AddHist1D(hAntiMetpDiff,"EX0",ratioColor); plotAntiMetpDiff.SetYRange(-8,8); plotAntiMetpDiff.AddLine(0, 0,METMAX, 0,kBlack,1); plotAntiMetpDiff.AddLine(0, 5,METMAX, 5,kBlack,3); plotAntiMetpDiff.AddLine(0,-5,METMAX,-5,kBlack,3); plotAntiMetpDiff.Draw(c,kTRUE,format,2); plotAntiMetp.SetName("fitantimetplog"); plotAntiMetp.SetLogy(); plotAntiMetp.SetYRange(1e-3*(hAntiDataMetp->GetMaximum()),10*(hAntiDataMetp->GetMaximum())); plotAntiMetp.Draw(c,kTRUE,format,1); // // W- MET plot // RooPlot *wmmframe = pfmet.frame(Bins(NBINS)); wmmframe->GetYaxis()->SetNdivisions(505); dataMetm.plotOn(wmmframe,MarkerStyle(kFullCircle),MarkerSize(0.9),DrawOption("ZP")); pdfMetm.plotOn(wmmframe,FillColor(fillcolorW),DrawOption("F")); pdfMetm.plotOn(wmmframe,LineColor(linecolorW)); pdfMetm.plotOn(wmmframe,Components(RooArgSet(pdfEWKm,*(qcdm.model))),FillColor(fillcolorEWK),DrawOption("F")); pdfMetm.plotOn(wmmframe,Components(RooArgSet(pdfEWKm,*(qcdm.model))),LineColor(linecolorEWK)); pdfMetm.plotOn(wmmframe,Components(RooArgSet(*(qcdm.model))),FillColor(fillcolorQCD),DrawOption("F")); pdfMetm.plotOn(wmmframe,Components(RooArgSet(*(qcdm.model))),LineColor(linecolorQCD)); pdfMetm.plotOn(wmmframe,Components(RooArgSet(pdfWmm)),LineColor(linecolorW),LineStyle(2)); dataMetm.plotOn(wmmframe,MarkerStyle(kFullCircle),MarkerSize(0.9),DrawOption("ZP")); sprintf(ylabel,"Events / %.1f GeV",hDataMetm->GetBinWidth(1)); CPlot plotMetm("fitmetm",wmmframe,"","",ylabel); plotMetm.SetLegend(0.68,0.57,0.93,0.77); plotMetm.GetLegend()->AddEntry(hDummyData,"data","PL"); plotMetm.GetLegend()->AddEntry(hDummyW,"W^{-}#rightarrow#mu^{-}#bar{#nu}","F"); plotMetm.GetLegend()->AddEntry(hDummyEWK,"EWK+t#bar{t}","F"); plotMetm.GetLegend()->AddEntry(hDummyQCD,"QCD","F"); plotMetm.AddTextBox(lumitext,0.55,0.80,0.90,0.86,0); plotMetm.AddTextBox("CMS Preliminary",0.63,0.92,0.95,0.99,0); // plotMetm.SetYRange(0.1,1.1*(hDataMetm->GetMaximum())); plotMetm.SetYRange(0.1,4100); plotMetm.Draw(c,kFALSE,format,1); CPlot plotMetmDiff("fitmetm","","#slash{E}_{T} [GeV]","#chi"); plotMetmDiff.AddHist1D(hMetmDiff,"EX0",ratioColor); plotMetmDiff.SetYRange(-8,8); plotMetmDiff.AddLine(0, 0,METMAX, 0,kBlack,1); plotMetmDiff.AddLine(0, 5,METMAX, 5,kBlack,3); plotMetmDiff.AddLine(0,-5,METMAX,-5,kBlack,3); plotMetmDiff.Draw(c,kTRUE,format,2); plotMetm.SetName("fitmetmlog"); plotMetm.SetLogy(); plotMetm.SetYRange(1e-3*(hDataMetm->GetMaximum()),10*(hDataMetm->GetMaximum())); plotMetm.Draw(c,kTRUE,format,1); RooPlot *awmmframe = pfmet.frame(Bins(NBINS)); antiMetm.plotOn(awmmframe,MarkerStyle(kFullCircle),MarkerSize(0.9),DrawOption("ZP")); apdfMetm.plotOn(awmmframe,FillColor(fillcolorW),DrawOption("F")); apdfMetm.plotOn(awmmframe,LineColor(linecolorW)); apdfMetm.plotOn(awmmframe,Components(RooArgSet(apdfEWKm,*(aqcdm.model))),FillColor(fillcolorEWK),DrawOption("F")); apdfMetm.plotOn(awmmframe,Components(RooArgSet(apdfEWKm,*(aqcdm.model))),LineColor(linecolorEWK)); apdfMetm.plotOn(awmmframe,Components(RooArgSet(*(aqcdm.model))),FillColor(fillcolorQCD),DrawOption("F")); apdfMetm.plotOn(awmmframe,Components(RooArgSet(*(aqcdm.model))),LineColor(linecolorQCD)); apdfMetm.plotOn(awmmframe,Components(RooArgSet(apdfWmm)),LineColor(linecolorW),LineStyle(2)); antiMetm.plotOn(awmmframe,MarkerStyle(kFullCircle),MarkerSize(0.9),DrawOption("ZP")); sprintf(ylabel,"Events / %.1f GeV",hDataMetm->GetBinWidth(1)); CPlot plotAntiMetm("fitantimetm",awmmframe,"","",ylabel); plotAntiMetm.SetLegend(0.68,0.57,0.93,0.77); plotAntiMetm.GetLegend()->AddEntry(hDummyData,"data","PL"); plotAntiMetm.GetLegend()->AddEntry(hDummyW,"W^{-}#rightarrow#mu^{-}#bar{#nu}","F"); plotAntiMetm.GetLegend()->AddEntry(hDummyEWK,"EWK+t#bar{t}","F"); plotAntiMetm.GetLegend()->AddEntry(hDummyQCD,"QCD","F"); plotAntiMetm.AddTextBox(lumitext,0.55,0.80,0.90,0.86,0); plotAntiMetm.AddTextBox("CMS Preliminary",0.63,0.92,0.95,0.99,0); // plotAntiMetm.SetYRange(0.1,1.1*(hAntiDataMetm->GetMaximum())); plotAntiMetm.SetYRange(0.1,1500); plotAntiMetm.Draw(c,kFALSE,format,1); CPlot plotAntiMetmDiff("fitantimetm","","#slash{E}_{T} [GeV]","#chi"); plotAntiMetmDiff.AddHist1D(hAntiMetmDiff,"EX0",ratioColor); plotAntiMetmDiff.SetYRange(-8,8); plotAntiMetmDiff.AddLine(0, 0,METMAX, 0,kBlack,1); plotAntiMetmDiff.AddLine(0, 5,METMAX, 5,kBlack,3); plotAntiMetmDiff.AddLine(0,-5,METMAX,-5,kBlack,3); plotAntiMetmDiff.Draw(c,kTRUE,format,2); plotAntiMetm.SetName("fitantimetmlog"); plotAntiMetm.SetLogy(); plotAntiMetm.SetYRange(1e-3*(hAntiDataMetm->GetMaximum()),10*(hAntiDataMetm->GetMaximum())); plotAntiMetm.Draw(c,kTRUE,format,1); //-------------------------------------------------------------------------------------------------------------- // Output //============================================================================================================== cout << "*" << endl; cout << "* SUMMARY" << endl; cout << "*--------------------------------------------------" << endl; // // Write fit results // ofstream txtfile; char txtfname[100]; ios_base::fmtflags flags; Double_t chi2prob, chi2ndf; Double_t ksprob, ksprobpe; chi2prob = hDataMet->Chi2Test(hPdfMet,"PUW"); chi2ndf = hDataMet->Chi2Test(hPdfMet,"CHI2/NDFUW"); ksprob = hDataMet->KolmogorovTest(hPdfMet); ksprobpe = hDataMet->KolmogorovTest(hPdfMet,"DX"); sprintf(txtfname,"%s/fitresWm.txt",CPlot::sOutDir.Data()); txtfile.open(txtfname); assert(txtfile.is_open()); flags = txtfile.flags(); txtfile << setprecision(10); txtfile << " *** Yields *** " << endl; txtfile << "Selected: " << hDataMet->Integral() << endl; txtfile << " Signal: " << nSig.getVal() << " +/- " << nSig.getPropagatedError(*fitRes) << endl; txtfile << " QCD: " << nQCD.getVal() << " +/- " << nQCD.getPropagatedError(*fitRes) << endl; txtfile << " Other: " << nEWK.getVal() << " +/- " << nEWK.getPropagatedError(*fitRes) << endl; txtfile << endl; txtfile.flags(flags); fitRes->printStream(txtfile,RooPrintable::kValue,RooPrintable::kVerbose); txtfile << endl; printCorrelations(txtfile, fitRes); txtfile << endl; printChi2AndKSResults(txtfile, chi2prob, chi2ndf, ksprob, ksprobpe); txtfile.close(); chi2prob = hDataMetp->Chi2Test(hPdfMetp,"PUW"); chi2ndf = hDataMetp->Chi2Test(hPdfMetp,"CHI2/NDFUW"); ksprob = hDataMetp->KolmogorovTest(hPdfMetp); ksprobpe = hDataMetp->KolmogorovTest(hPdfMetp,"DX"); sprintf(txtfname,"%s/fitresWmp.txt",CPlot::sOutDir.Data()); txtfile.open(txtfname); assert(txtfile.is_open()); flags = txtfile.flags(); txtfile << setprecision(10); txtfile << " *** Yields *** " << endl; txtfile << "Selected: " << hDataMetp->Integral() << endl; txtfile << " Signal: " << nSigp.getVal() << " +/- " << nSigp.getPropagatedError(*fitResp) << endl; txtfile << " QCD: " << nQCDp.getVal() << " +/- " << nQCDp.getPropagatedError(*fitResp) << endl; txtfile << " Other: " << nEWKp.getVal() << " +/- " << nEWKp.getPropagatedError(*fitResp) << endl; txtfile << endl; txtfile.flags(flags); fitResp->printStream(txtfile,RooPrintable::kValue,RooPrintable::kVerbose); txtfile << endl; printCorrelations(txtfile, fitResp); txtfile << endl; printChi2AndKSResults(txtfile, chi2prob, chi2ndf, ksprob, ksprobpe); txtfile.close(); chi2prob = hDataMetm->Chi2Test(hPdfMetm,"PUW"); chi2ndf = hDataMetm->Chi2Test(hPdfMetm,"CHI2/NDFUW"); ksprob = hDataMetm->KolmogorovTest(hPdfMetm); ksprobpe = hDataMetm->KolmogorovTest(hPdfMetm,"DX"); sprintf(txtfname,"%s/fitresWmm.txt",CPlot::sOutDir.Data()); txtfile.open(txtfname); assert(txtfile.is_open()); flags = txtfile.flags(); txtfile << setprecision(10); txtfile << " *** Yields *** " << endl; txtfile << "Selected: " << hDataMetm->Integral() << endl; txtfile << " Signal: " << nSigm.getVal() << " +/- " << nSigm.getPropagatedError(*fitResm) << endl; txtfile << " QCD: " << nQCDm.getVal() << " +/- " << nQCDm.getPropagatedError(*fitResm) << endl; txtfile << " Other: " << nEWKm.getVal() << " +/- " << nEWKm.getPropagatedError(*fitResm) << endl; txtfile << endl; txtfile.flags(flags); fitResm->printStream(txtfile,RooPrintable::kValue,RooPrintable::kVerbose); txtfile << endl; printCorrelations(txtfile, fitResm); txtfile << endl; printChi2AndKSResults(txtfile, chi2prob, chi2ndf, ksprob, ksprobpe); txtfile.close(); makeHTML(outputDir); cout << endl; cout << " <> Output saved in " << outputDir << "/" << endl; cout << endl; gBenchmark->Show("fitWm"); }
TH1D * GetTOFRatio(TFile *file, Int_t num, Int_t den, Int_t cent, Bool_t cutSpectrum = kTRUE) { /* pt limits for combined spectra */ Double_t ptMin_[9] = { 0.5, 0.5, 0.5, 0.45, 0.45, 0.45, 0.5, 0.5, 0.5 }; Double_t ptMax_[9] = { 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 4.5, 4.5, 4.5 }; Double_t ptMin = TMath::Max(ptMin_[num], ptMin_[den]); Double_t ptMax = TMath::Min(ptMax_[num], ptMax_[den]); TH1D *hin = (TH1D *)file->Get(Form("hRatio_cent%d_%s_%s", cent, ratioName[num], ratioName[den])); if (!hin) return NULL; #if 0 /* get matching systematics */ TFile *fsys = TFile::Open(Form("MATCHSYS_TOF_%s.root", TOFChargeName[charge])); TH1 *hsys = fsys->Get(Form("hErr%sMatch", ITSsaPartName[part])); TF1 *ffsys = new TF1("fsys", "[0] + [1] * x + [2] * TMath::Exp(-[3] * x)"); ffsys->SetParameter(0, 0.02); ffsys->FixParameter(1, 0.); ffsys->SetParameter(2, 0.5); ffsys->SetParameter(3, 10.); hsys->Fit(ffsys, "W"); ffsys->ReleaseParameter(1); hsys->Fit(ffsys, "W"); hsys->Fit(ffsys, "W"); hsys->Fit(ffsys, "W"); hsys->Draw(); #endif TH1D *h = new TH1D(Form("hTOF_cent%d_%s_%s", cent, ratioName[num], ratioName[den]), "TOF", NptBins, ptBin); Double_t pt, width, value, error, sys; Int_t bin; for (Int_t ipt = 0; ipt < NptBins; ipt++) { /* get input bin */ pt = h->GetBinCenter(ipt + 1); width = h->GetBinWidth(ipt + 1); bin = hin->FindBin(pt); /* sanity check */ if (TMath::Abs(hin->GetBinCenter(bin) - pt) > 0.001 || TMath::Abs(hin->GetBinWidth(bin) - width) > 0.001) continue; /* check pt limits */ if (cutSpectrum && (pt < ptMin || pt > ptMax)) continue; /* copy bin */ value = hin->GetBinContent(bin); error = hin->GetBinError(bin); /*** TEMP ADD SYS ***/ // sys = ffsys->Eval(pt) * value; // error = TMath::Sqrt(error * error + sys * sys); // h->SetBinContent(ipt + 1, value); // h->SetBinError(ipt + 1, error); h->SetBinContent(ipt + 1, value); h->SetBinError(ipt + 1, error); } h->SetTitle("TOF"); h->SetLineWidth(1); h->SetLineColor(1); h->SetMarkerStyle(23); h->SetMarkerColor(4); h->SetFillStyle(0); h->SetFillColor(0); return h; }
// ----------------------------------------------------------------------------- // TCanvas* aDrawBkgdPlots( TString path, TString canvas_name, TString name, TString dirmame, int rebin, bool norm, bool log, TDirectory* file ) { // SetSomeStyles(); // Create legend TLegend* legend = new TLegend( 0.75, 0.65, 0.92, 0.92, NULL, "brNDC" ); legend->SetFillColor(0); legend->SetLineColor(0); // Create canvas TCanvas* aCanvas = getaCanvas( canvas_name, file, log ); // Create histograms TH1D* qcd = readHist( path, name, "IC5Calo_QCD_Pythia_Merged.root", dirmame, rebin ); TH1D* tt_jets = readHist( path, name, "IC5Calo_TTbarJets.root", dirmame, rebin ); TH1D* w_jets = readHist( path, name, "IC5Calo_WJets.root", dirmame, rebin ); TH1D* z_inv = readHist( path, name, "IC5Calo_Zinv.root", dirmame, rebin ); TH1D* z_jets = readHist( path, name, "IC5Calo_ZJets.root", dirmame, rebin ); TH1D* lm0 = readHist( path, name, "IC5Calo_LM0.root", dirmame, rebin ); TH1D* lm1 = readHist( path, name, "IC5Calo_LM1.root", dirmame, rebin ); // Combine Z+jets and Z->inv TH1D* z_all = z_inv->Clone(); z_all->Add(z_jets,1); // TH1D* z_all = 0; // if ( z_inv && z_jets ) { // z_all = z_inv->Clone(); // z_all->Add(z_jets,1); // } else if ( z_inv ) { // z_all = z_inv->Clone(); // } else if ( z_jets ) { // z_all = z_jets->Clone(); // } // Select Z+jets and Z->inv separate or not bool combine = true; // Line colour and fill if ( qcd ) qcd->SetLineColor(kGreen+2); if ( qcd ) qcd->SetFillColor(kGreen+2); if ( qcd ) qcd->SetFillStyle(3003); if ( tt_jets ) tt_jets->SetLineColor(kBlue); if ( tt_jets ) tt_jets->SetLineStyle(1); if ( tt_jets ) tt_jets->SetLineWidth(1); w_jets->SetLineColor(kBlue); w_jets->SetLineStyle(3); w_jets->SetLineWidth(1); if ( combine ) { z_all->SetLineColor(kBlack); z_all->SetLineStyle(3); z_all->SetLineWidth(1); } else { z_inv->SetLineColor(kBlack); z_inv->SetLineStyle(1); z_inv->SetLineWidth(1); z_jets->SetLineColor(kBlack); z_jets->SetLineStyle(3); z_jets->SetLineWidth(1); } lm0->SetLineColor(kRed); lm0->SetLineStyle(1); lm0->SetLineWidth(2); lm1->SetLineColor(kRed); lm1->SetLineStyle(3); lm1->SetLineWidth(2); // Populate legend legend->AddEntry( qcd, " QCD", "f" ); legend->AddEntry( lm0, " SUSY LM0", "L" ); legend->AddEntry( lm1, " SUSY LM1", "L" ); legend->AddEntry( tt_jets, " t#bar{t}+jets", "L" ); legend->AddEntry( w_jets, " W+jets", "L" ); if ( combine ) { legend->AddEntry( z_all, " Z", "L" ); } else { legend->AddEntry( z_jets, " Z+jets", "L" ); legend->AddEntry( z_inv, " Z#rightarrow#nu#nu", "L" ); } // Calc maximum number of entries double aMax = 0.; if ( qcd->GetMaximum() > aMax ) { aMax = qcd->GetMaximum(); } if ( lm0->GetMaximum() > aMax ) { aMax = lm0->GetMaximum(); } if ( lm1->GetMaximum() > aMax ) { aMax = lm1->GetMaximum(); } if ( tt_jets->GetMaximum() > aMax ) { aMax = tt_jets->GetMaximum(); } if ( w_jets->GetMaximum() > aMax ) { aMax = w_jets->GetMaximum(); } if ( combine ) { if ( z_all->GetMaximum() > aMax ) { aMax = z_all->GetMaximum(); } } else { if ( z_inv->GetMaximum() > aMax ) { aMax = z_inv->GetMaximum(); } if ( z_jets->GetMaximum() > aMax ) { aMax = z_jets->GetMaximum(); } } // Calc minimum number of entries double aMin = 1.e12; if ( qcd->GetMinimum(1.e-12) < aMin ) { aMin = qcd->GetMinimum(1.e-12); } if ( lm0->GetMinimum(1.e-12) < aMin ) { aMin = lm0->GetMinimum(1.e-12); } if ( lm1->GetMinimum(1.e-12) < aMin ) { aMin = lm1->GetMinimum(1.e-12); } if ( tt_jets->GetMinimum(1.e-12) < aMin ) { aMin = tt_jets->GetMinimum(1.e-12); } if ( w_jets->GetMinimum(1.e-12) < aMin ) { aMin = w_jets->GetMinimum(1.e-12); } if ( combine ) { if ( z_all->GetMinimum(1.e-12) < aMin ) { aMin = z_all->GetMinimum(1.e-12); } } else { if ( z_inv->GetMinimum(1.e-12) < aMin ) { aMin = z_inv->GetMinimum(1.e-12); } if ( z_jets->GetMinimum(1.e-12) < aMin ) { aMin = z_jets->GetMinimum(1.e-12); } } if ( qcd ) qcd->GetYaxis()->SetTitleOffset(1.43); if ( qcd ) qcd->GetYaxis()->SetTitleSize(0.06); if ( qcd ) qcd->GetXaxis()->SetTitleSize(0.06); if ( qcd ) qcd->GetXaxis()->SetTitleOffset(0.9); if ( log ) { if ( qcd ) qcd->SetMaximum( aMax * 10. ); if ( qcd ) qcd->SetMinimum( aMin * 0.1 ); } else { if ( qcd ) qcd->SetMaximum( aMax * 1.1 ); if ( qcd ) qcd->SetMinimum( aMin * 0.9 ); } if ( norm ) { if ( qcd ) qcd->DrawNormalized("Ehist"); if ( lm0->GetEntries() > 0. ) { lm0->DrawNormalized("hsame"); } if ( lm1->GetEntries() > 0. ) { lm1->DrawNormalized("hsame"); } if ( tt_jets->GetEntries() > 0. ) { tt_jets->DrawNormalized("hsame"); } if ( w_jets->GetEntries() > 0. ) { w_jets->DrawNormalized("hsame"); } if ( combine ) { if ( z_all->GetEntries() > 0. ) { z_all->DrawNormalized("hsame"); } } else { if ( z_inv->GetEntries() > 0. ) { z_inv->DrawNormalized("hsame"); } if ( z_jets->GetEntries() > 0. ) { z_jets->DrawNormalized("hsame"); } } } else { if ( qcd ) qcd->Draw("h"); lm0->Draw("sameH"); lm1->Draw("sameH"); if ( tt_jets ) tt_jets->Draw("sameh"); w_jets->Draw("sameH"); if ( combine ) { z_all->Draw("sameH"); } else { z_inv->Draw("sameH"); z_jets->Draw("sameH"); } } file->cd(); legend->Draw("same"); aCanvas->Write(); return aCanvas; }
void Channel::GetShapes(TString SelectionName, TString xtitle, const int nbins, const double *bins){ MT2Shapes *tA; if(fWriteToFile) tA = new MT2Shapes(fOutDir, fRootFile, fLogStream); else tA = new MT2Shapes(fOutDir, fRootFile); tA->setVerbose(fVerbose); tA->init(fSamples); tA->SetPrintSummary(true); tA->SetDraw(false); tA->SetWrite(false); // variable, cuts, njet, nlep, selection_name, HLT, xtitle nbins bins tA->GetShapes(fVariable, fCuts, -1, -10 , SelectionName, fTrigger , xtitle , nbins, bins); // retrieve shapes for(int i=0; i<tA->GetNShapes(); ++i){ TString name =tA->fh_shapes[i]->GetName(); if (name.Contains("QCD_")) {hQCD = (TH1D*) tA->fh_shapes[i]->Clone(tA->fh_shapes[i]->GetName()); hQCD->SetDirectory(fDir);} else if (name.Contains("PhotonsJets_")){hPhotons = (TH1D*) tA->fh_shapes[i]->Clone(tA->fh_shapes[i]->GetName()); hPhotons->SetDirectory(fDir);} else if (name.Contains("Data_")) {hData = (TH1D*) tA->fh_shapes[i]->Clone(tA->fh_shapes[i]->GetName()); hData->SetDirectory(fDir);} else if (name.Contains("WJets_")) {hWJets = (TH1D*) tA->fh_shapes[i]->Clone(tA->fh_shapes[i]->GetName()); hWJets->SetDirectory(fDir);} else if (name.Contains("ZJetsToLL_")) {hZJetsToLL = (TH1D*) tA->fh_shapes[i]->Clone(tA->fh_shapes[i]->GetName()); hZJetsToLL->SetDirectory(fDir);} else if (name.Contains("ZJetsToNuNu_")){hZJetsToNuNu = (TH1D*) tA->fh_shapes[i]->Clone(tA->fh_shapes[i]->GetName()); hZJetsToNuNu->SetDirectory(fDir);} else if (name.Contains("Top_")) {hTop = (TH1D*) tA->fh_shapes[i]->Clone(tA->fh_shapes[i]->GetName()); hTop->SetDirectory(fDir);} else if (name.Contains("Signal_")) {hSignal = (TH1D*) tA->fh_shapes[i]->Clone(tA->fh_shapes[i]->GetName()); hSignal->SetDirectory(fDir);} else if (name.Contains("Other_")) {hOther = (TH1D*) tA->fh_shapes[i]->Clone(tA->fh_shapes[i]->GetName()); hOther->SetDirectory(fDir);} } delete tA; fGotShapes=true; fDir->cd(); // fix colors if(hQCD!=0) {hQCD ->SetLineColor(kYellow+1); hQCD ->SetFillColor(kYellow+1); hQCD ->SetFillStyle(3001);} if(hPhotons!=0) {hPhotons->SetLineColor(kViolet-3); hPhotons->SetFillColor(kViolet-3); hPhotons->SetFillStyle(3001);} if(hOther!=0) {hOther ->SetLineColor(kCyan+2); hOther ->SetFillColor(kCyan+2); hOther ->SetFillStyle(3001);} if(hZJetsToNuNu!=0){hZJetsToNuNu->SetLineColor(kGreen+1); hZJetsToNuNu->SetFillColor(kGreen+1); hZJetsToNuNu ->SetFillStyle(3001);} if(hSignal!=0) {hSignal ->SetLineColor(kBlack); hSignal ->SetFillColor(kBlack); hSignal ->SetFillStyle(3001);} if(hZJetsToLL!=0) {hZJetsToLL->SetLineColor(kOrange); hZJetsToLL->SetFillColor(kOrange); hZJetsToLL->SetFillStyle(3001);} if(hTop!=0) {hTop ->SetLineColor(600); hTop ->SetFillColor(600); hTop->SetFillStyle(3001);} if(fSaveResults){ if(hQCD!=0) {hQCD->Write();} if(hPhotons!=0) {hPhotons->Write();} if(hOther!=0) {hOther->Write();} if(hData!=0) {hData->Write();} if(hTop!=0) {hTop->Write();} if(hZJetsToLL!=0) {hZJetsToLL->Write();} if(hZJetsToNuNu!=0) {hZJetsToNuNu->Write();} if(hSignal!=0) {hSignal->Write();} } if(fDraw){ if(hQCD!=0) DrawHisto(hQCD, hQCD->GetName(), "hist", this); if(hPhotons!=0) DrawHisto(hPhotons, hPhotons->GetName(), "hist", this); if(hOther!=0) DrawHisto(hOther, hOther->GetName(), "hist", this); if(hData!=0) DrawHisto(hData, hData->GetName(), "EXO", this); if(hTop!=0) DrawHisto(hTop, hTop ->GetName(), "hist", this); if(hZJetsToNuNu!=0)DrawHisto(hZJetsToNuNu, hZJetsToNuNu->GetName(), "hist", this); if(hSignal!=0) DrawHisto(hSignal, hSignal->GetName(), "hist", this); if(hZJetsToLL!=0) DrawHisto(hZJetsToLL, hZJetsToLL->GetName(), "hist", this); } }
void run_DataGammaJetsZllToZnunu(){ // defs --------------------------------------------------------- gSystem->CompileMacro("../MT2Code/src/MT2Shapes.cc", "k"); // logStream fLogStream = new std::ostringstream(); // create dir if(!fOutDir.EndsWith("/")) fOutDir += "/"; char cmd[500]; sprintf(cmd,"mkdir -p %s", fOutDir.Data()); system(cmd); DefineCutStreams(fHTmin, fHTmax, fMT2min, fMT2max); TString filename=fOutDir+"/"+fRootFile; fOutFile = new TFile(filename.Data(), "RECREATE"); fDir = (TDirectory*) fOutFile; // fix output dir // if(fHTmax <10000) fOutDir= TString::Format("%s_%d_HT_%d", fOutDir.Data(), abs(fHTmin), abs(fHTmax)); // else fOutDir= TString::Format("%s_%d_HT_%s", fOutDir.Data(), abs(fHTmin), "Inf"); // if(fMT2max<10000) fOutDir= TString::Format("%s_%d_MT2_%d", fOutDir.Data(), abs(fMT2min), abs(fMT2max)); // else fOutDir= TString::Format("%s_%d_MT2_%s", fOutDir.Data(), abs(fMT2min), "Inf"); // log MT2 and HT cuts *fLogStream << "------------------------------------------------------------------------------------------------" << endl; *fLogStream << "+++ new Znunu with Gamma+jets prediction +++" << endl; *fLogStream << "+++ outputdir: " << fOutDir << "+++" << endl; *fLogStream << "------------------------------------------------------------------------------------------------" << endl; // new prediction ------------------------------------------------------ Prediction* prediction = new Prediction(); prediction->fVerbose=fVerbose; prediction->fSave =fSaveResults; // Photon Pt if(fDoPhotonPtShape){ const int gNMT2bins = 11; double gMT2bins[gNMT2bins+1] = {150, 160, 170, 180, 190, 200, 225, 250, 300, 400, 550, 800}; prediction->ChPhotonPt = new Channel("PhotonPt", "photon[0].lv.Pt()", cutStream_PhotonPt.str().c_str(), fTriggerStream.str().c_str(),fSamplesPhotonPt); prediction->ChPhotonPt->fVerbose =prediction->fVerbose; // prediction->ChPhotonPt->GetShapes("PhotonPt", "#gamma Pt", 2, 300, 800); prediction->ChPhotonPt->GetShapes("PhotonPt", "#gamma Pt", 100, 150, 800); // prediction->ChPhotonPt->GetShapes("PhotonPt", "#gamma Pt", gNMT2bins, gMT2bins); } // Zll Pt if(fDoZllPtShape){ const int gNMT2bins = 11; double gMT2bins[gNMT2bins+1] = {150, 160, 170, 180, 190, 200, 225, 250, 300, 400, 550, 800}; prediction->ChZllPt = new Channel("ZllPt", "RecoOSDiLeptPt(20,2.4,71,111)", cutStreamZll.str().c_str(), fTriggerStream.str().c_str(),fSamplesZllPt); prediction->ChZllPt->fVerbose =prediction->fVerbose; // prediction->ChZllPt->GetShapes("ZllPt", "Zll Pt", 2, 300, 800); prediction->ChZllPt->GetShapes("ZllPt", "Zll Pt", 100, 150, 800); // prediction->ChZllPt->GetShapes("ZllPt", "Zll Pt", gNMT2bins, gMT2bins); } // compute Zll/gamma pt ratio if(fDoPhotonPtShape && fDoZllPtShape){ TH1D* hPhotonToZllPtRatio = prediction->GetRatio(fDoDataZllToPhotonRatio? prediction->ChZllPt->hData : prediction->ChZllPt->hZJetsToLL, fDoDataZllToPhotonRatio? prediction->ChPhotonPt->hData : prediction->ChPhotonPt->hPhotons, 4); DrawHisto(hPhotonToZllPtRatio,hPhotonToZllPtRatio->GetName(),"EX0"); TString rationame=hPhotonToZllPtRatio->GetName(); rationame +="_fittedRatio"; TF1 *f_lin = new TF1(rationame,"pol0(0)", fZllToGammaFitMin , fZllToGammaFitMax); f_lin->SetLineColor(8); if(fDoFits){ hPhotonToZllPtRatio->Fit(rationame,"0L","", fZllToGammaFitMin, fZllToGammaFitMax); // set al weights to 1 fZllToPhotonRatio = f_lin->GetParameter(0); } else{ fZllToPhotonRatio = prediction->GetLimitedRatio(fDoDataZllToPhotonRatio? prediction->ChZllPt->hData: prediction->ChZllPt->hZJetsToLL, fDoDataZllToPhotonRatio? prediction->ChPhotonPt->hData : prediction->ChPhotonPt->hPhotons, fZllToGammaFitMin, fZllToGammaFitMax, false, fZllToPhotonRatioRelErr); f_lin->SetParameter(0,fZllToPhotonRatio); } const int nBins= 3; const double Bins[nBins+1] = {150, fZllToGammaFitMin>150?fZllToGammaFitMin:150.0001, fZllToGammaFitMax<800? fZllToGammaFitMax:799.99, 800}; TH1D* hErrorbar = new TH1D(rationame.Data(), "", nBins, Bins); hErrorbar->SetBinContent(2,fZllToPhotonRatio); hErrorbar->SetBinError(2,fZllToPhotonRatioRelErr*fZllToPhotonRatio); hErrorbar->SetBinContent(1,-10); hErrorbar->SetBinError( 1,0); hErrorbar->SetFillColor(5); hErrorbar->SetFillStyle(3001); hErrorbar->Draw("e2same"); f_lin->Draw("same"); hPhotonToZllPtRatio->Draw("EX0same"); } // GenLevel Zll Pt, no acceptance cuts if(fDoGenZllShape){ prediction->ChGenZllPt = new Channel("GenZllPt", "GenDiLeptPt(0,10,0,1000,true)", cutStreamGenZll.str().c_str(), fTriggerStream.str().c_str(),fSamplesZllPtMConly); prediction->ChGenZllPt->fVerbose =prediction->fVerbose; prediction->ChGenZllPt->GetShapes("GenZllPt", "GenZll Pt", 8, 0, 800); } // GenLevel Zll Pt, within acceptance if(fDoGenAccZllShape){ prediction->ChGenZllPtAcc = new Channel("GenZllPtAcc", "GenDiLeptPt(20,2.4,71,111,true)", cutStreamGenZllAcc.str().c_str(), fTriggerStream.str().c_str(),fSamplesZllPtMConly); prediction->ChGenZllPtAcc->fVerbose =prediction->fVerbose; prediction->ChGenZllPtAcc->GetShapes("GenZllPtAcc", "GenZll Pt", 8, 0, 800); } // Get Acceptance Efficiency if(fDoGenZllShape && fDoGenAccZllShape){ Bool_t binomial =true; TH1D* hZllAccEff = prediction->GetRatio(prediction->ChGenZllPtAcc->hZJetsToLL, prediction->ChGenZllPt->hZJetsToLL, 1, binomial); DrawHisto(hZllAccEff,hZllAccEff->GetName(),"EX"); // TString rationame=hZllAccEff->GetName(); // rationame +="_fittedRatio"; // TF1 *f_lin = new TF1(rationame,"pol0(0)", fZllAccFitMin , fZllAccFitMax); f_lin->SetLineColor(8); // if(fDoFits){ // hZllAccEff->Fit(rationame,"0L","", fZllAccFitMin, fZllAccFitMax); // set al weights to 1 // fZllAccEff= f_lin->GetParameter(0); // } else{ // fZllAccEff= prediction->GetLimitedRatio(prediction->ChGenZllPtAcc->hZJetsToLL,prediction->ChGenZllPt->hZJetsToLL, // fZllAccFitMin, fZllAccFitMax, true, fZllAccEffRelErr); // f_lin->SetParameter(0,fZllAccEff); // } // const int nBins= 3; // const double Bins[nBins+1] = {150, fZllAccFitMin>150?fZllAccFitMin:150.0001, fZllAccFitMax<800? fZllAccFitMax:799.99, 800}; // TH1D* hErrorbar = new TH1D(rationame.Data(), "", nBins,Bins); // hErrorbar->SetBinContent(2,fZllAccEff); // hErrorbar->SetBinError(2,fZllAccEffRelErr*fZllAccEff); // hErrorbar->SetBinContent(1,-1); // hErrorbar->SetBinError(1,0); // hErrorbar->SetFillColor(5); // hErrorbar->SetFillStyle(3001); // hErrorbar->Draw("e2same"); // f_lin->Draw("same"); // hZllAccEff->Draw("EX0same"); } // GenLevel Zll Pt, within acceptance, OS dilepton recoed if(fDoGenAccZllRecoShape){ prediction->ChGenZllPtAccRecoed = new Channel("GenZllPtAccRecoed", "GenDiLeptPt(20,2.4,71,111,true)", cutStreamGenZllAcc_recoed.str().c_str(), fTriggerStream.str().c_str(),fSamplesZllPtMConly); prediction->ChGenZllPtAccRecoed->fVerbose =prediction->fVerbose; prediction->ChGenZllPtAccRecoed->GetShapes("GenZllPtAccRecoed", "GenZll Pt", 100, 150, 800); } if(fDoGenAccZllShape && fDoGenAccZllRecoShape){ Bool_t binomial =true; TH1D* hZllRecoEff = prediction->GetRatio(prediction->ChGenZllPtAccRecoed->hZJetsToLL, prediction->ChGenZllPtAcc->hZJetsToLL, 4, binomial); DrawHisto(hZllRecoEff,hZllRecoEff->GetName(),"EX"); TString rationame=hZllRecoEff->GetName(); rationame +="_fittedRatio"; TF1 *f_lin = new TF1(rationame,"pol0(0)", fZllRecoEffFitMin , fZllRecoEffFitMax); f_lin->SetLineColor(8); if(fDoFits){ hZllRecoEff->Fit(rationame,"0L","", fZllRecoEffFitMin, fZllRecoEffFitMax); // set al weights to 1 fZllRecoEff= f_lin->GetParameter(0); } else{ fZllRecoEff= prediction->GetLimitedRatio(prediction->ChGenZllPtAccRecoed->hZJetsToLL,prediction->ChGenZllPtAcc->hZJetsToLL, fZllRecoEffFitMin, fZllRecoEffFitMax, true, fZllRecoEffRelErr); f_lin->SetParameter(0,fZllRecoEff); } const int nBins= 3; const double Bins[nBins+1] = {150, fZllRecoEffFitMin>150?fZllRecoEffFitMin:150.001, fZllRecoEffFitMax<800? fZllRecoEffFitMax:799.99, 800}; TH1D* hErrorbar = new TH1D(rationame.Data(), "", nBins,Bins); hErrorbar->SetBinContent(2,fZllRecoEff); hErrorbar->SetBinError(2,fZllRecoEffRelErr*fZllRecoEff); hErrorbar->SetBinContent(1,-1); hErrorbar->SetBinError(1,0); hErrorbar->SetFillColor(5); hErrorbar->SetFillStyle(3001); hErrorbar->Draw("e2same"); f_lin->Draw("same"); hZllRecoEff->Draw("EX0same"); } // Photons Hadronic Search MT2 if(fDoPhotonMT2Shape){ prediction->ChPhotonsMT2 = new Channel("PhotonsMT2", "photon[0].lv.Pt()", cutStreamPhotonMT2.str().c_str(), fTriggerStream.str().c_str(),fSamplesPhotonPt); prediction->ChPhotonsMT2->fVerbose =prediction->fVerbose; prediction->ChPhotonsMT2->GetShapes("PhotonsMT2", "MET", 40, 0, 800); } // Znunu Hadronic Search MT2 if(fDoZnunuMT2Shape){ prediction->ChZnunuMT2 = new Channel("ZnunuMT2", "misc.MET", cutStreamZnunuMT2.str().c_str(), fTriggerStream.str().c_str(),fSamplesZnunu); prediction->ChZnunuMT2->fVerbose =prediction->fVerbose; prediction->ChZnunuMT2->GetShapes("ZnunuMT2", "MET", 40, 0, 800); } if(fDoZnunuMT2Shape && fDoPhotonMT2Shape){ TH1D* ZnunuToPhotonMT2Ratio = prediction->GetRatio(prediction->ChZnunuMT2->hZJetsToNuNu, prediction->ChPhotonsMT2->hPhotons, 1); DrawHisto(ZnunuToPhotonMT2Ratio,ZnunuToPhotonMT2Ratio->GetName(),"EX0"); } // Do Pt spectra comparison plot if(fDoPtSpectraComparison && fDoPhotonPtShape && fDoZllPtShape){ *fLogStream<< "************************* produce pr spectra plot ****************************** " << endl; TH1D* hZllMC_cp = prediction->GetScaledHisto(prediction->ChZllPt->hZJetsToLL, fDoPtSpectraComparisonScaling?(prediction->ChZllPt->hData->Integral())/(prediction->ChZllPt->hZJetsToLL->Integral()) :1, 0, 1); TH1D* hZllData_cp = prediction->GetScaledHisto(prediction->ChZllPt->hData, 1, 0, 1) ; TH1D* hPhotonMC_cp = prediction->GetScaledHisto(prediction->ChPhotonPt->hPhotons,fDoPtSpectraComparisonScaling?(prediction->ChPhotonPt->hData->Integral())/(prediction->ChPhotonPt->hPhotons->Integral()):1, 0, 1); TH1D* hPhotonData_cp = prediction->GetScaledHisto(prediction->ChPhotonPt->hData, 1, 0, 1); if(fDoPtSpectraComparisonAccCorr){ TFile *f = new TFile("../RootMacros/ZllAcceptance.root", "OPEN"); TH1D* hZllAcc = (TH1D*) f->Get("ZJetsToLL_GenZllPtAcc_ZJetsToLL_GenZllPt_Ratio"); if (hZllAcc==0) {cout << "WARNING: could not get histo ZJetsToLL_GenZllPtAcc_ZJetsToLL_GenZllPt_Ratio" << endl; exit(1);} for(int i=1; i<=hZllMC_cp->GetNbinsX(); ++i){ if(hZllAcc->GetBinLowEdge(i) != hZllMC_cp->GetBinLowEdge(i)) {cout << "Zll Acc Correction: binnin does not match!!" << endl; exit(1);} if(hZllMC_cp ->GetBinContent(i)<=0) continue; double acc_eff = hZllAcc->GetBinContent(i); double orig_mc = hZllMC_cp ->GetBinContent(i); double orig_data = hZllData_cp ->GetBinContent(i); cout << "bin i " << i << " acc eff " << acc_eff << " orig_mc " << orig_mc << " become " << orig_mc/acc_eff << " orig_data " << orig_data << " becomes " << orig_data/acc_eff << endl; hZllMC_cp ->SetBinContent(i, orig_mc /acc_eff); hZllData_cp ->SetBinContent(i, orig_data/acc_eff); } delete f; } hZllMC_cp->SetMarkerStyle(22); hZllMC_cp->SetLineColor(kOrange); hZllMC_cp->SetMarkerColor(kOrange); hZllMC_cp->SetMarkerSize(1.2); hZllData_cp->SetMarkerStyle(26); hZllData_cp->SetMarkerColor(kBlack); hZllData_cp->SetLineColor(kBlack); hPhotonMC_cp->SetLineColor(kMagenta+2); hPhotonMC_cp->SetMarkerColor(kMagenta+2); hPhotonMC_cp->SetMarkerStyle(20); hPhotonMC_cp->SetMarkerSize(1.2); hPhotonData_cp->SetMarkerStyle(4); hPhotonData_cp->SetMarkerColor(kBlack); hPhotonData_cp->SetLineColor(kBlack); TCanvas *col = new TCanvas("ZllToGammaPtSpectra", "", 0, 0, 500, 500); col->SetFillStyle(0); col->SetFrameFillStyle(0); // col->cd(); gPad->SetFillStyle(0); gStyle->SetPalette(1); gPad->SetRightMargin(0.15); TLegend* leg2 = new TLegend(0.2, 0.6, 0.5, 0.9); leg2->AddEntry(hPhotonMC_cp,"Gamma+Jets MC","p" ); leg2->AddEntry(hPhotonData_cp,"Photon Data","p" ); leg2->AddEntry(hZllMC_cp ,"Zll MC","p" ); leg2->AddEntry(hZllData_cp,"Zll Data","p" ); leg2 -> SetFillColor(0); leg2 -> SetBorderSize(0); // hPhotonMC_cp->SetXTitle("V boson p_{T} (GeV)"); hPhotonMC_cp->SetYTitle("Events / 7 GeV"); hPhotonMC_cp->Draw("EX"); hPhotonData_cp->Draw("EXsame"); hZllMC_cp->Draw("EXsame"); hZllData_cp->Draw("EXsame"); leg2->Draw(); TCanvas *c3 = new TCanvas("ZllToGammaPtSpectraRatio", "", 500, 500); TH1D* h_ratio = (TH1D*) hZllMC_cp ->Clone("h_ratio"); TH1D* h_ratioData = (TH1D*) hZllData_cp ->Clone("h_ratioData"); TH1D* hPhotonMC_cp2 = (TH1D*) hPhotonMC_cp ->Clone("hPhotonMC_cp2"); TH1D* hPhotonData_cp2 = (TH1D*) hPhotonData_cp ->Clone("hPhotonData_cp2"); h_ratio->Rebin(1); h_ratioData->Rebin(1); h_ratio->SetYTitle("#frac{Z(ll)}{#gamma}"); h_ratio->SetXTitle("boson p_{T} (GeV)"); h_ratio ->Divide(hPhotonMC_cp2->Rebin(1)); h_ratioData->Divide(hPhotonData_cp2->Rebin(1)); h_ratio ->SetMarkerStyle(20); h_ratio ->SetMarkerSize(1.2); h_ratio ->SetLineColor(kMagenta+2); h_ratio ->SetMarkerColor(kMagenta+2); h_ratioData->SetMarkerStyle(26); h_ratioData->SetMarkerColor(kBlack); h_ratio ->Draw("EX0"); h_ratioData->Draw("EX0same"); TLegend* leg3 = new TLegend(0.2, 0.6, 0.5, 0.9); leg3->AddEntry(h_ratioData,"Zll/photon Data","p" ); leg3->AddEntry(h_ratio ,"Zll/photon MC","p" ); leg3 -> SetFillColor(0); leg3 -> SetBorderSize(0); leg3 ->Draw(); } if(fDoMT2SpectraCompaison && fDoZnunuMT2Shape && fDoPhotonMT2Shape){ *fLogStream<< "************************* MT2 spectra comparison *************** " << endl; TH1D* hZNunuMT2 = prediction->GetScaledHisto(prediction->ChZnunuMT2 ->hZJetsToNuNu, fDoMT2SpectraCompaisonScaling?(prediction->ChPhotonsMT2 ->hData->Integral())/(prediction->ChPhotonsMT2 ->hPhotons->Integral()):1, 0, 1); TH1D* hPhotonMT2 = prediction->GetScaledHisto(prediction->ChPhotonsMT2 ->hPhotons, fDoMT2SpectraCompaisonScaling?(prediction->ChPhotonsMT2 ->hData->Integral())/(prediction->ChPhotonsMT2 ->hPhotons->Integral()):1, 0, 1); TH1D* hPhotonDataMT2 = prediction->GetScaledHisto(prediction->ChPhotonsMT2 ->hData, 1, 0, 1); hZNunuMT2->SetFillStyle(0); hZNunuMT2->SetLineWidth(3); TCanvas *col = new TCanvas("ZnunuToGammaPtSpectra", "", 0, 0, 500, 500); col->SetFillStyle(0); col->SetFrameFillStyle(0); // col->cd(); gPad->SetFillStyle(0); gStyle->SetPalette(1); gPad->SetRightMargin(0.15); gPad->SetLogy(1); TLegend* leg2 = new TLegend(0.2, 0.6, 0.5, 0.9); leg2->AddEntry(hPhotonMT2,"#gamma+jets MC","f" ); leg2->AddEntry(hZNunuMT2,"Z(#nu#nu)+jets MC","l" ); leg2->AddEntry(hPhotonDataMT2,"data","p" ); leg2 -> SetFillColor(0); leg2 -> SetBorderSize(0); // hPhotonMT2->SetXTitle("min #Delta #phi(jets,MET)"); hPhotonMT2->SetYTitle("Events"); hPhotonMT2->Draw("hist"); hZNunuMT2->Draw("histsame"); hPhotonDataMT2->Draw("EXsame"); leg2->Draw(); // gPad->RedrawAxis(); // cout integral above 250 in MT2 and ratio // double sumPhotons=0; // double sumZnunu =0; // for(int i=1; i<=hPhotonMT2->GetNbinsX(); ++i){ // if(hPhotonMT2->GetBinLowEdge(i)>=250){ // sumPhotons+=hPhotonMT2->GetBinContent(i); // sumZnunu +=hZNunuMT2 ->GetBinContent(i); // } // } // *fLogStream<< ">>> hPhotonMT2: integral above 250: " << sumPhotons << endl; // *fLogStream<< ">>> hZNunuMT2 : integral above 250: " << sumZnunu << endl; // *fLogStream<< ">>> -> Ratio : " << sumZnunu/sumPhotons << endl; } if(fDoZnunuGammaGenPtSpectraComparison){ *fLogStream<< "*************************ZnunuGammaGenPtSpectraComparison**********" << endl; // gen photons prediction->ChGenPhotonPt = new Channel("GenPhotonPt", "GenPhoton[0].Pt()", cutStreamGenPhoton.str().c_str(), fTriggerStream.str().c_str(),fSamplesPhotonPtMConly); prediction->ChGenPhotonPt->fVerbose =prediction->fVerbose; prediction->ChGenPhotonPt->GetShapes("GenPhotonPt", "Gen-level #gamma Pt", 50, 150, 800); // Gen Znunu prediction->ChGenZnunuPt = new Channel("GenZnunuPt", "GenZ[0].Pt()", cutStreamGenZnunu.str().c_str(), fTriggerStream.str().c_str(),fSamplesZnunu); prediction->ChGenZnunuPt->fVerbose =prediction->fVerbose; prediction->ChGenZnunuPt->GetShapes("GenZnunuPt", "Gen-level Z(#nu#nu) Pt", 50, 150, 800); prediction->DrawHistos(prediction->ChGenPhotonPt->hPhotons, prediction->ChGenZnunuPt->hZJetsToNuNu, "EX0" , "EX0same", kViolet+3 , kBlack, 20 ,4, "#gamma Pt" ,"Z(#nu#nu)"); TH1D* hGenPhotonToZnunuRatio = prediction->GetRatio(prediction->ChGenZnunuPt->hZJetsToNuNu, prediction->ChGenPhotonPt->hPhotons, 1, false); hGenPhotonToZnunuRatio->SetMarkerColor(kBlack); hGenPhotonToZnunuRatio->SetLineColor(kBlack); hGenPhotonToZnunuRatio->SetMarkerStyle(4); DrawHisto(hGenPhotonToZnunuRatio, "GenPhotonToZnunuRatio","EX0", prediction->ChGenPhotonPt); } if(fDoPhotonRecoEff){ prediction->ChGenPhotonPtForRecoEff = new Channel("GenPhotonPtForRecoEff", "GenPhoton[0].Pt()", cutStream_GenPhotonforRecoEff.str().c_str(), fTriggerStream.str().c_str(),fSamplesPhotonPtMConly); prediction->ChGenPhotonPtForRecoEff->fVerbose =prediction->fVerbose; prediction->ChGenPhotonPtForRecoEff->GetShapes("GenPhotonPtForRecoEff", "Gen-level #gamma Pt", 50, 150, 800); prediction->ChPhotonPtForRecoEff = new Channel("PhotonPtForRecoEff", "GenPhoton[0].Pt()", cutStream_PhotonPtforRecoEff.str().c_str(), fTriggerStream.str().c_str(),fSamplesPhotonPtMConly); prediction->ChPhotonPtForRecoEff->fVerbose =prediction->fVerbose; prediction->ChPhotonPtForRecoEff->GetShapes("PhotonPtForRecoEff", "Gen-level #gamma Pt", 50, 150, 800); prediction->DrawHistos(prediction->ChGenPhotonPtForRecoEff->hPhotons, prediction->ChPhotonPtForRecoEff->hPhotons, "EX0" , "EX0same", kViolet+3 , kBlack, 20 ,4, "#all" ,"recoed"); TH1D* hPhotonRecoEff = prediction->GetRatio(prediction->ChPhotonPtForRecoEff->hPhotons, prediction->ChGenPhotonPtForRecoEff->hPhotons, 1, false); hPhotonRecoEff->SetMarkerColor(kBlack); hPhotonRecoEff->SetLineColor(kBlack); hPhotonRecoEff->SetMarkerStyle(4); DrawHisto(hPhotonRecoEff, "PhotonRecoEff","EX0", prediction->ChPhotonPtForRecoEff); } // Prediction if(fDoPrediction){ *fLogStream<< "************************* Prediction ****************************** " << endl; TH1D* MCZnunu = prediction->GetScaledHisto(prediction->ChZnunuMT2->hZJetsToNuNu,fLumiCorr,0); // scale to lumi 4400 double MCZnunuEst = MCZnunu->GetBinContent(1); double MCZnunuEstErr = MCZnunu->GetBinError(1); delete MCZnunu; if(fDoData){ double nGamma = prediction->ChPhotonsMT2->hData->Integral(); double nGammaErr = sqrt(nGamma); *fLogStream << "********** Data Prediction ***************************************************** " << endl; MakePrediction(nGamma, nGammaErr, fZllToPhotonRatio, fZllToPhotonRatioRelErr, fZllAccEff, fZllAccEffRelErr, fZllRecoEff, fZllRecoEffRelErr, MCZnunuEst, MCZnunuEstErr); } TH1D* hDummy = prediction->GetScaledHisto(prediction->ChPhotonsMT2->hPhotons, 1, 0); float nGammaMC =hDummy->GetBinContent(1); float nGammaMCErr=hDummy->GetBinError(1); *fLogStream << "********** MC Prediction ***************************************************** " << endl; MakePrediction(nGammaMC, nGammaMCErr, fZllToPhotonRatio, fZllToPhotonRatioRelErr, fZllAccEff, fZllAccEffRelErr, fZllRecoEff, fZllRecoEffRelErr, MCZnunuEst, MCZnunuEstErr); } // write ----------- if(fWriteToFile){ TString logname =fOutDir + ".log"; ofstream f_log (logname.Data(), ios::app); f_log << fLogStream->str(); } else{ cout << fLogStream->str(); } // fOutFile->Close(); }
void plotLeadingJet(int cbin, TString infname, TString pythia, TString mix, bool useWeight, bool drawXLabel, bool drawLeg) { TString cut="et1>120 && et2>50 && dphi>2.5"; TString cutpp="et1>120 && et2>50 && dphi>2.5"; TString cstring = ""; if(cbin==0) { cstring = "0-10%"; cut+=" && bin>=0 && bin<4"; cut+=" && ((et1-et2)/(et1+et2) > 0.3)"; } else if (cbin==1) { cstring = "10-30%"; cut+=" && bin>=4 && bin<12"; cut+=" && ((et1-et2)/(et1+et2) > 0.3)"; } else { cstring = "30-100%"; cut+=" && bin>=12 && bin<40"; cut+=" && ((et1-et2)/(et1+et2) > 0.3)"; } // open the data file TFile *inf = new TFile(infname.Data()); TTree *nt =(TTree*)inf->FindObjectAny("nt"); // open the pythia (MC) file TFile *infPythia = new TFile(pythia.Data()); TTree *ntPythia = (TTree*) infPythia->FindObjectAny("nt"); // open the datamix file TFile *infMix = new TFile(mix.Data()); TTree *ntMix =(TTree*)infMix->FindObjectAny("nt"); // projection histogram TH1D *h = new TH1D("h","",10,60,135); TH1D *hPythia = new TH1D("hPythia","",10,60,135); TH1D *hDataMix = new TH1D("hDataMix","",10,60,135); nt->Draw("et2>>h",Form("(%s)",cut.Data())); if (useWeight) { // use the weight value caluculated by Matt's analysis macro ntMix->Draw("et2>>hDataMix",Form("(%s)*weight",cut.Data())); } else { // ignore centrality reweighting ntMix->Draw("et2>>hDataMix",Form("(%s)",cut.Data())); } ntPythia->Draw("et2>>hPythia",Form("(%s)",cutpp.Data())); // calculate the statistical error and normalize h->Sumw2(); h->Scale(1./h->GetEntries()); h->SetMarkerStyle(20); hPythia->Scale(1./hPythia->Integral(0,20)); hPythia->SetLineColor(kBlue); hPythia->SetFillColor(kAzure-8); hPythia->SetFillStyle(3005); hPythia->SetStats(0); hPythia->Draw("hist"); if(drawXLabel) hPythia->SetXTitle("Subleading Jet E_{T} (GeV)"); hPythia->GetXaxis()->SetLabelSize(20); hPythia->GetXaxis()->SetLabelFont(43); hPythia->GetXaxis()->SetTitleSize(22); hPythia->GetXaxis()->SetTitleFont(43); hPythia->GetXaxis()->SetTitleOffset(1.5); hPythia->GetXaxis()->CenterTitle(); hPythia->GetXaxis()->SetNdivisions(904,true); hPythia->SetYTitle("Event Fraction"); hPythia->GetYaxis()->SetLabelSize(20); hPythia->GetYaxis()->SetLabelFont(43); hPythia->GetYaxis()->SetTitleSize(20); hPythia->GetYaxis()->SetTitleFont(43); hPythia->GetYaxis()->SetTitleOffset(2.5); hPythia->GetYaxis()->CenterTitle(); hPythia->SetAxisRange(2E-3,3,"Y"); hDataMix->SetAxisRange(2E-3,3,"Y"); h->SetAxisRange(2E-3,3,"Y"); h->Draw("same"); hDataMix->Scale(1./hDataMix->Integral(0,20)); hDataMix->SetLineColor(kRed); hDataMix->SetFillColor(kRed-9); hDataMix->SetFillStyle(3004); hDataMix->Draw("same"); if(drawLeg){ TLegend *t3=new TLegend(0.25,0.74,0.79,0.90); t3->AddEntry(h,"Pb+Pb #sqrt{s}_{_{NN}}=2.76 TeV","pl"); t3->AddEntry(hPythia,"PYTHIA","lf"); t3->AddEntry(hDataMix,"embedded PYTHIA","lf"); t3->SetFillColor(0); t3->SetBorderSize(0); t3->SetFillStyle(0); t3->SetTextFont(63); t3->SetTextSize(15); t3->Draw(); } }
void MuScale() { //-------------------------------------------------------------------------------------------------------------- // Settings //============================================================================================================== // event category enumeration enum { eMuMu2HLT=1, eMuMu1HLT1L1, eMuMu1HLT, eMuMuNoSel, eMuSta, eMuTrk }; // event category enum TString outputDir = "MuScaleResults"; vector<TString> infilenamev; infilenamev.push_back("/afs/cern.ch/work/c/cmedlock/public/wz-ntuples/Zmumu/ntuples/data_select.trkCuts.root"); // data infilenamev.push_back("/afs/cern.ch/work/c/cmedlock/public/wz-ntuples/Zmumu/ntuples/zmm_select.raw.trkCuts.root"); // MC const Double_t MASS_LOW = 60; const Double_t MASS_HIGH = 120; const Double_t PT_CUT = 25; const Double_t ETA_CUT = 2.4; const Double_t MU_MASS = 0.105658369; vector<pair<Double_t,Double_t> > scEta_limits; scEta_limits.push_back(make_pair(0.0,1.2)); scEta_limits.push_back(make_pair(1.2,2.1)); scEta_limits.push_back(make_pair(2.1,2.4)); CPlot::sOutDir = outputDir; const TString format("png"); //-------------------------------------------------------------------------------------------------------------- // Main analysis code //============================================================================================================== enum { eData=0, eMC }; char hname[100]; vector<TH1D*> hMCv, hDatav; for(UInt_t ibin=0; ibin<scEta_limits.size(); ibin++) { for(UInt_t jbin=ibin; jbin<scEta_limits.size(); jbin++) { sprintf(hname,"mc_%i_%i",ibin,jbin); hMCv.push_back(new TH1D(hname,"",80,MASS_LOW,MASS_HIGH)); hMCv.back()->Sumw2(); sprintf(hname,"data_%i_%i",ibin,jbin); hDatav.push_back(new TH1D(hname,"",80,MASS_LOW,MASS_HIGH)); hDatav.back()->Sumw2(); } } // // Declare output ntuple variables // UInt_t runNum, lumiSec, evtNum; Float_t scale1fb, puWeight; UInt_t matchGen; UInt_t category; UInt_t npv, npu; Int_t q1, q2; TLorentzVector *dilep=0, *lep1=0, *lep2=0; for(UInt_t ifile=0; ifile<infilenamev.size(); ifile++) { cout << "Processing " << infilenamev[ifile] << "..." << endl; TFile *infile = TFile::Open(infilenamev[ifile]); assert(infile); TTree *intree = (TTree*)infile->Get("Events"); assert(intree); intree->SetBranchAddress("runNum", &runNum); // event run number intree->SetBranchAddress("lumiSec", &lumiSec); // event lumi section intree->SetBranchAddress("evtNum", &evtNum); // event number intree->SetBranchAddress("scale1fb", &scale1fb); // event weight intree->SetBranchAddress("puWeight", &puWeight); // pileup reweighting intree->SetBranchAddress("matchGen", &matchGen); // event has both leptons matched to MC Z->ll intree->SetBranchAddress("category", &category); // dilepton category intree->SetBranchAddress("npv", &npv); // number of primary vertices intree->SetBranchAddress("npu", &npu); // number of in-time PU events (MC) intree->SetBranchAddress("q1", &q1); // charge of lead lepton intree->SetBranchAddress("q2", &q2); // charge of trail lepton intree->SetBranchAddress("dilep", &dilep); // dilepton 4-vector intree->SetBranchAddress("lep1", &lep1); // lead lepton 4-vector intree->SetBranchAddress("lep2", &lep2); // trail lepton 4-vector for(UInt_t ientry=0; ientry<intree->GetEntries(); ientry++) { intree->GetEntry(ientry); Double_t weight = 1; if(ifile==eMC) { //if(!matchGen) continue; weight=scale1fb*puWeight*1.1*TMath::Power(10,7)/5610.0; } if((category!=eMuMu2HLT) && (category!=eMuMu1HLT) && (category!=eMuMu1HLT1L1)) continue; if(q1 == q2) continue; if(dilep->M() < MASS_LOW) continue; if(dilep->M() > MASS_HIGH) continue; if(lep1->Pt() < PT_CUT) continue; if(lep2->Pt() < PT_CUT) continue; if(fabs(lep1->Eta()) > ETA_CUT) continue; if(fabs(lep2->Eta()) > ETA_CUT) continue; TLorentzVector vLep1(0,0,0,0); TLorentzVector vLep2(0,0,0,0); vLep1.SetPtEtaPhiM(lep1->Pt(), lep1->Eta(), lep1->Phi(), MU_MASS); vLep2.SetPtEtaPhiM(lep2->Pt(), lep2->Eta(), lep2->Phi(), MU_MASS); TLorentzVector vDilep = vLep1 + vLep2; Int_t bin1=-1, bin2=-1; for(UInt_t i=0; i<scEta_limits.size(); i++) { Double_t etalow = scEta_limits.at(i).first; Double_t etahigh = scEta_limits.at(i).second; if(fabs(lep1->Eta())>=etalow && fabs(lep1->Eta())<=etahigh) bin1=i; if(fabs(lep2->Eta())>=etalow && fabs(lep2->Eta())<=etahigh) bin2=i; } assert(bin1>=0); assert(bin2>=0); Int_t ibin= (bin1<=bin2) ? bin1 : bin2; Int_t jbin= (bin1<=bin2) ? bin2 : bin1; UInt_t n=jbin-ibin; for(Int_t k=0; k<ibin; k++) n+=(scEta_limits.size()-k); if(ifile==eData) hDatav[n]->Fill(vDilep.M(),weight); if(ifile==eMC) hMCv[n]->Fill(vDilep.M(),weight); } delete infile; infile=0, intree=0; } // // Fit for energy scale and resolution corrections // char vname[100]; // buffer for RooFit object names char pname[100]; char str1[100]; char str2[100]; TCanvas *c = MakeCanvas("c","c",800,600); // Dummy histograms for TLegend (I can't figure out how to properly pass RooFit objects...) TH1D *hDummyData = new TH1D("hDummyData","",0,0,10); hDummyData->SetMarkerStyle(kFullCircle); hDummyData->SetMarkerSize(0.9); TH1D *hDummyMC = new TH1D("hDummyMC","",0,0,10); hDummyMC->SetLineColor(kBlue); hDummyMC->SetFillColor(kBlue); hDummyMC->SetFillStyle(3002); TH1D *hDummyFit = new TH1D("hDummyFit","",0,0,10); hDummyFit->SetLineColor(kGreen+2); RooRealVar mass("mass","M_{#mu#mu}",60.0,120.0,"GeV") ; mass.setBins(1600,"cache"); RooRealVar massmc("massmc","massmc",0.0,150.0,"GeV"); // mass variable for building MC template RooCategory zscEta_cat("zscEta_cat","zscEta_cat"); RooSimultaneous combscalefit("combscalefit","combscalefit",zscEta_cat); map<string,TH1*> hmap; // Mapping of category labels and data histograms RooArgList scalebins; // List of RooRealVars storing per bin energy scale corrections RooArgList sigmabins; // List of RooRealVars storing per bin energy resolution corrections Int_t intOrder = 1; // Interpolation order for for(UInt_t ibin=0; ibin<scEta_limits.size(); ibin++) { sprintf(vname,"scale_%i",ibin); RooRealVar *scalebinned = new RooRealVar(vname,vname,1.0,0.5,1.5); scalebins.add(*scalebinned); sprintf(vname,"sigma_%i",ibin); RooRealVar *sigmabinned = new RooRealVar(vname,vname,1.0,0.0,2.0); sigmabins.add(*sigmabinned); } for(UInt_t ibin=0; ibin<scEta_limits.size(); ibin++) { for(UInt_t jbin=ibin; jbin<scEta_limits.size(); jbin++) { UInt_t n=jbin-ibin; for(UInt_t k=0; k<ibin; k++) n+=(scEta_limits.size()-k); sprintf(vname,"masslinearshifted_%i_%i",ibin,jbin); RooFormulaVar *masslinearshifted = new RooFormulaVar(vname,vname,"sqrt(@0*@1)",RooArgList(*scalebins.at(ibin),*scalebins.at(jbin))); sprintf(vname,"massshiftedscEta_%i_%i",ibin,jbin); RooLinearVar *massshiftedscEta = new RooLinearVar(vname,vname,mass,*masslinearshifted,RooConst(0.0)); // MC-based template sprintf(vname,"zmassmcscEta_%i_%i",ibin,jbin); RooDataHist *zmassmcscEta = new RooDataHist(vname,vname,RooArgList(massmc),hMCv[n]); sprintf(vname,"masstemplatescEta_%i_%i",ibin,jbin); RooHistPdf *masstemplatescEta = new RooHistPdf(vname,vname,RooArgList(*massshiftedscEta),RooArgList(massmc),*zmassmcscEta,intOrder); // Gaussian smearing function sprintf(vname,"sigmascEta_%i_%i",ibin,jbin); RooFormulaVar *sigmascEta = new RooFormulaVar(vname,vname,"sqrt(@0*@0+@1*@1)",RooArgList(*sigmabins.at(ibin),*sigmabins.at(jbin))); sprintf(vname,"resscEta_%i_%i",ibin,jbin); RooGaussian *resscEta = new RooGaussian(vname,vname,mass,RooConst(0.),*sigmascEta); // Fit model: MC-template convoluted with Gaussian sprintf(vname,"fftscEta_%i_%i",ibin,jbin); RooFFTConvPdf *fftscEta = new RooFFTConvPdf(vname,vname,mass,*masstemplatescEta,*resscEta); fftscEta->setBufferStrategy(RooFFTConvPdf::Flat); // Add bin as a category char zscEta_catname[100]; sprintf(zscEta_catname,"zscEta_cat_%i_%i",ibin,jbin); zscEta_cat.defineType(zscEta_catname); zscEta_cat.setLabel(zscEta_catname); hmap.insert(pair<string,TH1*>(zscEta_catname,hDatav[n])); combscalefit.addPdf(*fftscEta,zscEta_catname); } } // perform fit RooDataHist zdatascEta_comb("zdatascEta_comb","zdatascEta_comb",RooArgList(mass),zscEta_cat,hmap,1.0); combscalefit.fitTo(zdatascEta_comb,PrintEvalErrors(kFALSE),Minos(kFALSE),Strategy(0),Minimizer("Minuit2","")); Double_t xval[scEta_limits.size()]; Double_t xerr[scEta_limits.size()]; Double_t scaleDatatoMC[scEta_limits.size()]; Double_t scaleDatatoMCerr[scEta_limits.size()]; Double_t scaleMCtoData[scEta_limits.size()]; Double_t scaleMCtoDataerr[scEta_limits.size()]; Double_t sigmaMCtoData[scEta_limits.size()]; Double_t sigmaMCtoDataerr[scEta_limits.size()]; for(UInt_t ibin=0; ibin<scEta_limits.size(); ibin++) { Double_t etalow = scEta_limits.at(ibin).first; Double_t etahigh = scEta_limits.at(ibin).second; xval[ibin] = 0.5*(etahigh+etalow); xerr[ibin] = 0.5*(etahigh-etalow); scaleDatatoMC[ibin] = ((RooRealVar*)scalebins.at(ibin))->getVal(); scaleDatatoMCerr[ibin] = ((RooRealVar*)scalebins.at(ibin))->getError(); scaleMCtoData[ibin] = 1.0/scaleDatatoMC[ibin]; scaleMCtoDataerr[ibin] = scaleDatatoMCerr[ibin]/scaleDatatoMC[ibin]/scaleDatatoMC[ibin]; sigmaMCtoData[ibin] = ((RooRealVar*)sigmabins.at(ibin))->getVal(); sigmaMCtoDataerr[ibin] = ((RooRealVar*)sigmabins.at(ibin))->getError(); } TGraphErrors *grScaleDatatoMC = new TGraphErrors(scEta_limits.size(),xval,scaleDatatoMC,xerr,scaleDatatoMCerr); TGraphErrors *grScaleMCtoData = new TGraphErrors(scEta_limits.size(),xval,scaleMCtoData,xerr,scaleMCtoDataerr); TGraphErrors *grSigmaMCtoData = new TGraphErrors(scEta_limits.size(),xval,sigmaMCtoData,xerr,sigmaMCtoDataerr); CPlot plotScale1("mu_scale_datatomc","","Muon |#eta|","Data scale correction"); plotScale1.AddGraph(grScaleDatatoMC,"",kBlue); plotScale1.SetYRange(0.98,1.02); plotScale1.AddLine(0,1,2.5,1,kBlack,7); plotScale1.Draw(c,kTRUE,format); CPlot plotScale2("mu_scale_mctodata","","Muon |#eta|","MC#rightarrowData scale correction"); plotScale2.AddGraph(grScaleMCtoData,"",kBlue); plotScale2.SetYRange(0.98,1.02); plotScale2.AddLine(0,1,2.5,1,kBlack,7); plotScale2.Draw(c,kTRUE,format); CPlot plotRes("mu_res_mctodata","","Muon |#eta|","MC#rightarrowData additional smear [GeV]"); plotRes.AddGraph(grSigmaMCtoData,"",kBlue); plotRes.SetYRange(0,1.6); plotRes.Draw(c,kTRUE,format); double nData=0; for(UInt_t ibin=0; ibin<scEta_limits.size(); ibin++) { for(UInt_t jbin=ibin; jbin<scEta_limits.size(); jbin++) { UInt_t n=jbin-ibin; for(UInt_t k=0; k<ibin; k++) n+=(scEta_limits.size()-k); // Post-fit plot RooPlot *frame = mass.frame(); char catname[100]; sprintf(catname,"zscEta_cat_%i_%i",ibin,jbin); char cutstr[100]; sprintf(cutstr,"zscEta_cat==zscEta_cat::%s",catname); RooDataHist zmc(catname,catname,RooArgList(mass),hMCv[n]); RooHistPdf mctemplate(catname,catname,RooArgList(mass),zmc,intOrder); //mctemplate.plotOn(frame,LineColor(kBlue),LineWidth(1),Normalization(hDatav[n]->GetEntries())); mctemplate.plotOn(frame,LineColor(kBlue),LineWidth(1),Normalization(hDatav[n]->Integral())); //mctemplate.plotOn(frame,LineColor(kBlue),FillColor(kBlue),FillStyle(3002),DrawOption("F"),Normalization(hDatav[n]->GetEntries())); mctemplate.plotOn(frame,LineColor(kBlue),FillColor(kBlue),FillStyle(3002),DrawOption("F"),Normalization(hDatav[n]->Integral())); zdatascEta_comb.plotOn(frame,Cut(cutstr),MarkerStyle(kFullCircle),MarkerSize(1.0),DrawOption("ZP")); combscalefit.plotOn(frame,Slice(zscEta_cat,catname),ProjWData(RooArgSet(mass,catname),zdatascEta_comb), LineColor(kGreen+2)); sprintf(pname,"postfit_%i_%i",ibin,jbin); sprintf(str1,"[%.1f, %.1f]",scEta_limits.at(ibin).first,scEta_limits.at(ibin).second); sprintf(str2,"[%.1f, %.1f]",scEta_limits.at(jbin).first,scEta_limits.at(jbin).second); CPlot plot(pname,frame,"","m(#mu^{+}#mu^{-}) [GeV/c^{2}]","Events / 0.6 GeV/c^{2}"); plot.AddTextBox(str1,0.21,0.80,0.45,0.87,0,kBlack,-1); plot.AddTextBox(str2,0.21,0.73,0.45,0.80,0,kBlack,-1); plot.SetLegend(0.75,0.64,0.93,0.88); plot.GetLegend()->AddEntry(hDummyData,"Data","PL"); plot.GetLegend()->AddEntry(hDummyMC,"Sim","FL"); plot.GetLegend()->AddEntry(hDummyFit,"Fit","L"); plot.Draw(c,kTRUE,format); nData += hDatav[n]->Integral(); } } cout<<"nData = "<<nData<<endl; //-------------------------------------------------------------------------------------------------------------- // Output //============================================================================================================== cout << "*" << endl; cout << "* SUMMARY" << endl; cout << "*--------------------------------------------------" << endl; cout << endl; ofstream txtfile; char txtfname[100]; sprintf(txtfname,"%s/summary.txt",outputDir.Data()); txtfile.open(txtfname); assert(txtfile.is_open()); txtfile << " Data->MC scale correction" << endl; for(UInt_t ibin=0; ibin<scEta_limits.size(); ibin++) { Double_t etalow = scEta_limits.at(ibin).first; Double_t etahigh = scEta_limits.at(ibin).second; txtfile << "$" << etalow << " < |\\eta| < " << etahigh << "$ & "; txtfile << "$" << ((RooRealVar*)scalebins.at(ibin))->getVal() << "$ \\pm $" << ((RooRealVar*)scalebins.at(ibin))->getError() << "$ \\\\" << endl; } txtfile << endl; txtfile << " MC->Data resolution correction [GeV]" << endl; for(UInt_t ibin=0; ibin<scEta_limits.size(); ibin++) { Double_t etalow = scEta_limits.at(ibin).first; Double_t etahigh = scEta_limits.at(ibin).second; txtfile << etalow << " < |\\eta| < " << etahigh << " & "; txtfile << "$" << ((RooRealVar*)sigmabins.at(ibin))->getVal() << "$ \\pm $" << ((RooRealVar*)sigmabins.at(ibin))->getError() << "$ \\\\" << endl; } txtfile.close(); cout << endl; cout << " <> Output saved in " << outputDir << "/" << endl; cout << endl; }
void plot_stuff(){ gStyle->SetOptStat(0); gStyle->SetOptTitle(0); gROOT->ForceStyle(); TFile *in = TFile::Open("IncLusive_Plots_vmd.root"); TH1D *hIVEpEmGam = (TH1D*)in->Get("hIVEpEmGam"); TH1D *hIVEpEmGam_cut = (TH1D*)in->Get("hIVEpEmGam_cut"); hIVEpEmGam->SetLineColor(kBlack); hIVEpEmGam->SetStats(false); hIVEpEmGam_cut->SetStats(false); hIVEpEmGam->GetXaxis()->SetTitle("M(e^{+}e^{-}#gamma) [GeV]"); hIVEpEmGam->GetXaxis()->SetTitleSize(0.05); hIVEpEmGam->GetXaxis()->SetTitleOffset(0.8); hIVEpEmGam->GetYaxis()->SetTitle("Counts / 35.5 MeV"); hIVEpEmGam->GetYaxis()->SetTitleSize(0.05); hIVEpEmGam->GetYaxis()->SetTitleOffset(1.0); hIVEpEmGam->SetLineWidth(2); hIVEpEmGam_cut->SetLineColor(kRed); hIVEpEmGam_cut->SetFillColor(kRed); hIVEpEmGam_cut->SetFillStyle(3001); TH1D *hMMPEmX = (TH1D*)in->Get("hMMPEmX"); TH1D *hMMPEmX_cut = (TH1D*)in->Get("hMMPEmX_cut"); hMMPEmX->SetLineColor(kBlack); hMMPEmX->SetLineWidth(2); hMMPEmX->GetXaxis()->SetTitle("M_{x}(pe^{-}) [GeV]"); hMMPEmX->SetStats(false); hMMPEmX_cut->SetStats(false); hMMPEmX->GetXaxis()->SetTitleSize(0.05); hMMPEmX->GetXaxis()->SetTitleOffset(0.8); hMMPEmX->GetYaxis()->SetTitle("Counts / 35.5 MeV"); hMMPEmX->GetYaxis()->SetTitleSize(0.05); hMMPEmX->GetYaxis()->SetTitleOffset(1.0); hMMPEmX_cut->SetLineColor(kRed); hMMPEmX_cut->SetFillColor(kRed); hMMPEmX_cut->SetFillStyle(3001); TH1D *IVrest = (TH1D*)hIVEpEmGam->Clone(); int critIVbin = IVrest->GetXaxis()->FindFixBin(1.5); TH1D *MMrest = (TH1D*)hMMPEmX->Clone(); int critMMbin = MMrest->GetXaxis()->FindFixBin(1.2); for(int i=1;i<= IVrest->GetNbinsX();i++){ if(i<critIVbin){ IVrest->SetBinContent(i,0); } } IVrest->SetFillStyle(3001); IVrest->SetFillColor(8); IVrest->SetLineColor(8); for(int i=1;i<= MMrest->GetNbinsX();i++){ if(i>critMMbin){ MMrest->SetBinContent(i,0); } } MMrest->SetFillStyle(3001); MMrest->SetFillColor(8); MMrest->SetLineColor(8); TLegend *leg1 = new TLegend(0.25,0.7,0.9,0.9); leg1->SetFillColor(0); leg1->AddEntry(IVrest,"Select e^{-}' from e^{-}p#rightarrow e^{-}'pX"); leg1->AddEntry(hIVEpEmGam_cut,"Select e^{-} from #eta'#rightarrow e^{+}e^{-}#gamma"); TLegend *leg2 = new TLegend(0.25,0.7,0.9,0.9); leg2->SetFillColor(0); leg2->AddEntry(MMrest,"Select e^{-}' from e^{-}p#rightarrow e^{-}'pX"); leg2->AddEntry(hMMPEmX_cut,"Select e^{-} from #eta'#rightarrow e^{+}e^{-}#gamma"); TCanvas *c = new TCanvas("c","",1200,500); c->Divide(2); c->cd(1); //IVrest->Draw(); hIVEpEmGam->Draw(); fitMKVoight(hIVEpEmGam, 0.6, 2.1, 0, 0, 0, 0, 0.957, 0.01, 0.001, 2.5, 1); hIVEpEmGam_cut->Draw("same"); //hIVEpEmGam->Draw("same"); IVrest->Draw("same"); leg1->Draw("same"); c->cd(2); MMrest->Draw(); fitMKVoight(hMMPEmX, 0.6, 2.1, 0, 0, 0, 0, 0.957, 0.01, 0.001, 2.5, 1); hMMPEmX_cut->Draw("same"); hMMPEmX->Draw("same"); leg2->Draw("same"); c->cd(); TH1D *hIVEpEm = (TH1D*)in->Get("hIVEpEm"); TH1D *hIVEpEm_cut = (TH1D*)in->Get("hIVEpEm_cut"); TH1D *hEpEm_contam = (TH1D*)in->Get("hEpEm_contam"); hIVEpEm->GetXaxis()->SetTitle("M(e^{+}e^{-}) [GeV]"); hIVEpEm->GetXaxis()->SetTitleSize(0.05); hIVEpEm->GetXaxis()->SetTitleOffset(0.8); hIVEpEm->GetYaxis()->SetTitle("Counts / 40 MeV"); hIVEpEm->GetYaxis()->SetTitleSize(0.05); hIVEpEm->GetYaxis()->SetTitleOffset(0.8); hIVEpEm->SetLineColor(kBlack); hIVEpEm->SetLineWidth(2); hIVEpEm_cut->SetLineColor(kRed); hIVEpEm_cut->SetFillColor(kRed); hIVEpEm_cut->SetFillStyle(3001); hEpEm_contam->SetLineColor(8); hEpEm_contam->SetFillColor(8); hEpEm_contam->SetFillStyle(3001); TLegend *leg3 = new TLegend(0.6,0.6,0.9,0.9); leg3->SetFillColor(0); leg3->AddEntry(hIVEpEm_cut,"Select e^{-} from #eta'#rightarrowe^{+}e^{-}#gamma"); leg3->AddEntry(hEpEm_contam,"Select e^{-}' from e^{-}p#rightarrow e^{-}'pX"); TCanvas *c2 = new TCanvas("c2","",1); hIVEpEm->Draw(); hIVEpEm_cut->Rebin(4); hIVEpEm_cut->Draw("same"); hEpEm_contam->Rebin(4); hEpEm_contam->Draw("same"); hIVEpEm->Draw("same"); leg3->Draw("same"); c2->SetLogy(); TH1D *hEmP = (TH1D*)in->Get("hEmP"); TH1D *hEmP_cut = (TH1D*)in->Get("hEmP_cut"); hEmP->GetXaxis()->SetTitle("Momentum of e^{-} [GeV/c]"); hEmP->GetXaxis()->SetTitleSize(0.05); hEmP->GetXaxis()->SetTitleOffset(0.8); hEmP->GetYaxis()->SetTitle("Counts / 110 MeV"); hEmP->GetYaxis()->SetTitleSize(0.05); hEmP->GetYaxis()->SetTitleOffset(0.8); hEmP->SetLineColor(kBlack); hEmP->SetLineWidth(2); hEmP_cut->SetLineColor(kRed); hEmP_cut->SetFillColor(kRed); hEmP_cut->SetFillStyle(3001); TLegend *leg4 = new TLegend(0.6,0.6,0.9,0.9); leg4->SetFillStyle(0); leg4->AddEntry(hEmP_cut,"Select e^{-} from #eta'#rightarrow e^{+}e^{-}#gamma"); TCanvas *c3 = new TCanvas("c3","",1); hEmP->Draw(); hEmP_cut->Draw("same"); leg4->Draw("same"); c3->cd(); //MK stuff /* TCanvas *cmkII = new TCanvas("cmkII","cmkII",1200,500); //cmkII->Divide(1,2); cmkII->cd(); cmkII->SetLogy(); TH1D *hIVEpEm_cut_clone = (TH1D*)in->Get("hIVEpEm_cut_clone"); hIVEpEm_cut_clone->SetLineColor(kRed); hIVEpEm_cut_clone->SetYTitle("Expected Counts / 10 MeV"); hIVEpEm_cut_clone->GetYaxis()->SetTitleSize(0.05); hIVEpEm_cut_clone->GetYaxis()->SetTitleOffset(0.8); hIVEpEm_cut_clone->GetXaxis()->SetTitle("M(e^{+}e^{-}) [GeV]"); hIVEpEm_cut_clone->GetXaxis()->SetTitleSize(0.05); hIVEpEm_cut_clone->GetXaxis()->SetTitleOffset(0.8); TH1D *hEpEm_corrected = (TH1D*)in->Get("hEpEm_corrected"); hEpEm_corrected->SetYTitle("Counts / 10 MeV"); hEpEm_corrected->GetYaxis()->SetTitleSize(0.05); hEpEm_corrected->GetYaxis()->SetTitleOffset(0.8); hEpEm_corrected->GetXaxis()->SetTitle("M(e^{+}e^{-}) [GeV]"); hEpEm_corrected->GetXaxis()->SetTitleSize(0.05); hEpEm_corrected->Draw("EP"); hIVEpEm_cut_clone->Draw("EP same"); TLegend *legmkII = new TLegend(0.45,0.7,0.9,0.9); legmkII->SetTextSize(0.05); legmkII->SetFillColor(0); legmkII->AddEntry(hIVEpEm_cut_clone,"Expected counts in 80 days","l"); legmkII->AddEntry(hEpEm_corrected,"Accepted corrected counts in 80 days","l"); legmkII->Draw("same"); TCanvas *cmkIII = new TCanvas("cmkIII","cmkIII",1200,500); cmkIII->cd(); TH1D *hEpEm_acceptance = (TH1D*)in->Get("hEpEm_acceptance"); hEpEm_acceptance->SetLineColor(kRed); hEpEm_acceptance->SetYTitle("Acceptance / 10 MeV"); hEpEm_acceptance->GetYaxis()->SetTitleSize(0.05); hEpEm_acceptance->GetYaxis()->SetTitleOffset(0.8); hEpEm_acceptance->GetXaxis()->SetTitle("M(e^{+}e^{-}) [GeV]"); hEpEm_acceptance->GetXaxis()->SetTitleSize(0.05); hEpEm_acceptance->GetXaxis()->SetTitleOffset(0.8); TH1D *hEpEm_acceptance_flat = (TH1D*)inflat->Get("hEpEm_acceptance"); hEpEm_acceptance_flat->SetYTitle("Acceptance / 10 MeV"); hEpEm_acceptance_flat->GetYaxis()->SetTitleSize(0.05); hEpEm_acceptance_flat->GetYaxis()->SetTitleOffset(0.8); hEpEm_acceptance_flat->GetXaxis()->SetTitle("M(e^{+}e^{-}) [GeV]"); hEpEm_acceptance_flat->GetXaxis()->SetTitleSize(0.05); hEpEm_acceptance_flat->GetXaxis()->SetTitleOffset(0.8); hEpEm_acceptance->GetYaxis()->SetRangeUser(0,0.16); hEpEm_acceptance->Draw("EP"); hEpEm_acceptance_flat->Draw("EP same"); TLegend *legmkIII = new TLegend(0.11,0.7,0.45,0.9); legmkIII->SetTextSize(0.05); legmkIII->SetFillColor(0); legmkIII->AddEntry(hEpEm_acceptance,"QED+VMD M(e^{+}e^{-}) Acceptance","l"); legmkIII->AddEntry(hEpEm_acceptance_flat,"Flat M(e^{+}e^{-}) Acceptance","l"); legmkIII->Draw("same"); // double QED_par[8] = {0.957}; //{Mass} TF1 *QED_norm = new TF1("QED_norm",Eval_Kroll_wada,0.,1.,1); QED_norm->SetParameters(&QED_par[0]); TH1D *hEpEm_corrected_flat = new TH1D("hEpEm_corrected_flat","hEpEm_corrected_flat",100,0.0,1); TH1D *hEpEm_QEDnorm_flat = new TH1D("hEpEm_QEDnorm_flat","hEpEm_QEDnorm_flat",100,0.0,1); for (int i = 1; i<hIVEpEm_cut_clone->GetNbinsX(); i++) { Double_t bin_factor = 1.65; //this needs to be solved at somepoint Double_t intotal_acceptance = hEpEm_acceptance_flat->GetBinContent(i)*bin_factor; Double_t intotal_events_upper; if (intotal_acceptance == 0) { intotal_events_upper = 0; }else{ intotal_events_upper = hIVEpEm_cut_clone->GetBinContent(i)/intotal_acceptance; } hEpEm_corrected_flat->SetBinContent(i,intotal_events_upper); hEpEm_corrected_flat->SetBinError(i,sqrt(intotal_events_upper)); Double_t QED_factor = QED_norm->Eval(hIVEpEm_cut_clone->GetBinCenter(i));//2.0e-06; hEpEm_QEDnorm_flat->SetBinContent(i,intotal_events_upper/QED_factor); //hEpEm_QEDnorm->SetBinError(i,sqrt(intotal_events_upper/QED_factor)); } // double pole_par[3] = {10, 0.59,0.0144}; //{A,Lambda,Gamma} TF1 *FF_fittepole = new TF1("FF_fittepole", Pole_FFII,0.02,0.92,3); FF_fittepole->SetParameters(&pole_par[0]); FF_fittepole->SetParLimits(0,0.,100.); FF_fittepole->SetParLimits(1,pole_par[1] - pole_par[1]*0.1,pole_par[1] + pole_par[1]*0.1); FF_fittepole->SetParLimits(2,pole_par[2] - pole_par[2]*0.5,pole_par[2] + pole_par[2]*0.5); //for flat double pole_parII[3] = {10, 0.59,0.0144}; //{A,Lambda,Gamma} TF1 *FF_fittepoleII = new TF1("FF_fittepoleII", Pole_FFII,0.02,0.85,3); FF_fittepoleII->SetParameters(&pole_parII[0]); FF_fittepoleII->SetParLimits(0,0.,100.); FF_fittepoleII->SetParLimits(1,pole_parII[1] - pole_parII[1]*0.1,pole_parII[1] + pole_parII[1]*0.1); FF_fittepoleII->SetParLimits(2,pole_parII[2] - pole_parII[2]*0.5,pole_parII[2] + pole_parII[2]*0.5); FF_fittepoleII->SetLineColor(kBlue); //TF1 *FF_fitterGaus = new TF1("FF_fitterGaus","gaus",0.55,0.92); TCanvas *cmkI = new TCanvas("cmkI","cmkI",1200,500); TH1D *hEpEm_QEDnorm = (TH1D*)in->Get("hEpEm_QEDnorm"); cmkI->cd(); hEpEm_QEDnorm->SetTitle("Expected distribution of |F(q^{2})|^{2}"); hEpEm_QEDnorm->SetLineColor(kBlack); hEpEm_QEDnorm->SetYTitle("|F(q^{2})|^{2}"); hEpEm_QEDnorm->GetYaxis()->SetTitleSize(0.05); hEpEm_QEDnorm->GetYaxis()->SetTitleOffset(0.8); hEpEm_QEDnorm->GetXaxis()->SetTitle("M(e^{+}e^{-}) [GeV]"); hEpEm_QEDnorm->GetXaxis()->SetTitleSize(0.05); hEpEm_QEDnorm->GetXaxis()->SetTitleOffset(0.8); hEpEm_QEDnorm->Draw("EP"); hEpEm_QEDnorm_flat->SetLineColor(8); hEpEm_QEDnorm_flat->Draw("EP same"); hEpEm_QEDnorm_flat->Fit("FF_fittepoleII","REM"); hEpEm_QEDnorm->Fit("FF_fittepole","REM+"); Double_t Lambda = FF_fittepole->GetParameter(1); Double_t Lambdaerr = FF_fittepole->GetParError(1); Double_t bn = 1./Lambda; Double_t bn_err = Lambdaerr/(bn*bn); Double_t Lambda_flat = FF_fittepoleII->GetParameter(1); Double_t Lambdaerr_flat = FF_fittepoleII->GetParError(1); Double_t bn_flat = 1./Lambda_flat; Double_t bn_err_flat = Lambdaerr_flat/(bn_flat*bn_flat); TString sLambda = Form("#Lambda^{2}_{fit} = %2.4f #pm %2.4f ", Lambda,Lambdaerr); TString sbn = Form("b_{n} = %2.4f #pm %2.4f ", bn,bn_err); TString sLambda_gen = Form("#Lambda^{2}_{gen} = %2.4f ", 0.5776); TString sbn_gen = Form("b_{n gen} = %2.4f ", 1./0.5776); TString sLambda_flat = Form("#Lambda^{2}_{fit} = %2.4f #pm %2.4f ", Lambda_flat,Lambdaerr_flat); TString sbn_flat = Form("b_{n} = %2.4f #pm %2.4f ", bn_flat,bn_err_flat); >>>>>>> master TCanvas *cmkII = new TCanvas("cmkII","cmkII",1200,500); //cmkII->Divide(1,2); cmkII->cd(); cmkII->SetLogy(); TH1D *hIVEpEm_cut_clone = (TH1D*)in->Get("hIVEpEm_cut_clone"); hIVEpEm_cut_clone->SetLineColor(kRed); hIVEpEm_cut_clone->SetYTitle("Expected Counts / 10 MeV"); hIVEpEm_cut_clone->GetYaxis()->SetTitleSize(0.05); hIVEpEm_cut_clone->GetYaxis()->SetTitleOffset(0.8); hIVEpEm_cut_clone->GetXaxis()->SetTitle("M(e^{+}e^{-}) [GeV]"); hIVEpEm_cut_clone->GetXaxis()->SetTitleSize(0.05); hIVEpEm_cut_clone->GetXaxis()->SetTitleOffset(0.8); TH1D *hEpEm_corrected = (TH1D*)in->Get("hEpEm_corrected"); hEpEm_corrected->SetYTitle("Counts / 10 MeV"); hEpEm_corrected->GetYaxis()->SetTitleSize(0.05); hEpEm_corrected->GetYaxis()->SetTitleOffset(0.8); hEpEm_corrected->GetXaxis()->SetTitle("M(e^{+}e^{-}) [GeV]"); hEpEm_corrected->GetXaxis()->SetTitleSize(0.05); hEpEm_corrected->Draw("EP"); hIVEpEm_cut_clone->Draw("EP same"); TLegend *legmkII = new TLegend(0.45,0.7,0.9,0.9); legmkII->SetTextSize(0.05); legmkII->SetFillColor(0); legmkII->AddEntry(hIVEpEm_cut_clone,"Expected counts in 80 days","l"); legmkII->AddEntry(hEpEm_corrected,"Accepted corrected counts in 80 days","l"); legmkII->Draw("same"); TCanvas *cmkIII = new TCanvas("cmkIII","cmkIII",1200,500); cmkIII->cd(); TH1D *hEpEm_acceptance = (TH1D*)in->Get("hEpEm_acceptance"); hEpEm_acceptance->SetLineColor(kRed); hEpEm_acceptance->SetYTitle("Acceptance / 10 MeV"); hEpEm_acceptance->GetYaxis()->SetTitleSize(0.05); hEpEm_acceptance->GetYaxis()->SetTitleOffset(0.8); hEpEm_acceptance->GetXaxis()->SetTitle("M(e^{+}e^{-}) [GeV]"); hEpEm_acceptance->GetXaxis()->SetTitleSize(0.05); hEpEm_acceptance->GetXaxis()->SetTitleOffset(0.8); TH1D *hEpEm_acceptance_flat = (TH1D*)inflat->Get("hEpEm_acceptance"); hEpEm_acceptance_flat->SetYTitle("Acceptance / 10 MeV"); hEpEm_acceptance_flat->GetYaxis()->SetTitleSize(0.05); hEpEm_acceptance_flat->GetYaxis()->SetTitleOffset(0.8); hEpEm_acceptance_flat->GetXaxis()->SetTitle("M(e^{+}e^{-}) [GeV]"); hEpEm_acceptance_flat->GetXaxis()->SetTitleSize(0.05); hEpEm_acceptance_flat->GetXaxis()->SetTitleOffset(0.8); hEpEm_acceptance->GetYaxis()->SetRangeUser(0,0.16); hEpEm_acceptance->Draw("EP"); hEpEm_acceptance_flat->Draw("EP same"); TLegend *legmkIII = new TLegend(0.11,0.7,0.45,0.9); legmkIII->SetTextSize(0.05); legmkIII->SetFillColor(0); legmkIII->AddEntry(hEpEm_acceptance,"QED+VMD M(e^{+}e^{-}) Acceptance","l"); legmkIII->AddEntry(hEpEm_acceptance_flat,"Flat M(e^{+}e^{-}) Acceptance","l"); legmkIII->Draw("same"); // double QED_par[8] = {0.957}; //{Mass} TF1 *QED_norm = new TF1("QED_norm",Eval_Kroll_wada,0.,1.,1); QED_norm->SetParameters(&QED_par[0]); TH1D *hEpEm_corrected_flat = new TH1D("hEpEm_corrected_flat","hEpEm_corrected_flat",100,0.0,1); TH1D *hEpEm_QEDnorm_flat = new TH1D("hEpEm_QEDnorm_flat","hEpEm_QEDnorm_flat",100,0.0,1); for (int i = 1; i<hIVEpEm_cut_clone->GetNbinsX(); i++) { Double_t bin_factor = 1.65; //this needs to be solved at somepoint Double_t intotal_acceptance = hEpEm_acceptance_flat->GetBinContent(i)*bin_factor; Double_t intotal_events_upper; if (intotal_acceptance == 0) { intotal_events_upper = 0; }else{ intotal_events_upper = hIVEpEm_cut_clone->GetBinContent(i)/intotal_acceptance; } hEpEm_corrected_flat->SetBinContent(i,intotal_events_upper); hEpEm_corrected_flat->SetBinError(i,sqrt(intotal_events_upper)); Double_t QED_factor = QED_norm->Eval(hIVEpEm_cut_clone->GetBinCenter(i));//2.0e-06; hEpEm_QEDnorm_flat->SetBinContent(i,intotal_events_upper/QED_factor); //hEpEm_QEDnorm->SetBinError(i,sqrt(intotal_events_upper/QED_factor)); } // double pole_par[3] = {10, 0.59,0.0144}; //{A,Lambda,Gamma} TF1 *FF_fittepole = new TF1("FF_fittepole", Pole_FFII,0.02,0.92,3); FF_fittepole->SetParameters(&pole_par[0]); FF_fittepole->SetParLimits(0,0.,100.); FF_fittepole->SetParLimits(1,pole_par[1] - pole_par[1]*0.1,pole_par[1] + pole_par[1]*0.1); FF_fittepole->SetParLimits(2,pole_par[2] - pole_par[2]*0.5,pole_par[2] + pole_par[2]*0.5); //for flat double pole_parII[3] = {10, 0.59,0.0144}; //{A,Lambda,Gamma} TF1 *FF_fittepoleII = new TF1("FF_fittepoleII", Pole_FFII,0.02,0.85,3); FF_fittepoleII->SetParameters(&pole_parII[0]); FF_fittepoleII->SetParLimits(0,0.,100.); FF_fittepoleII->SetParLimits(1,pole_parII[1] - pole_parII[1]*0.1,pole_parII[1] + pole_parII[1]*0.1); FF_fittepoleII->SetParLimits(2,pole_parII[2] - pole_parII[2]*0.5,pole_parII[2] + pole_parII[2]*0.5); FF_fittepoleII->SetLineColor(kBlue); //TF1 *FF_fitterGaus = new TF1("FF_fitterGaus","gaus",0.55,0.92); TCanvas *cmkI = new TCanvas("cmkI","cmkI",1200,500); TH1D *hEpEm_QEDnorm = (TH1D*)in->Get("hEpEm_QEDnorm"); cmkI->cd(); hEpEm_QEDnorm->SetTitle("Expected distribution of |F(q^{2})|^{2}"); hEpEm_QEDnorm->SetLineColor(kBlack); hEpEm_QEDnorm->SetYTitle("|F(q^{2})|^{2}"); hEpEm_QEDnorm->GetYaxis()->SetTitleSize(0.05); hEpEm_QEDnorm->GetYaxis()->SetTitleOffset(0.8); hEpEm_QEDnorm->GetXaxis()->SetTitle("M(e^{+}e^{-}) [GeV]"); hEpEm_QEDnorm->GetXaxis()->SetTitleSize(0.05); hEpEm_QEDnorm->GetXaxis()->SetTitleOffset(0.8); hEpEm_QEDnorm->Draw("EP"); hEpEm_QEDnorm_flat->SetLineColor(8); hEpEm_QEDnorm_flat->Draw("EP same"); hEpEm_QEDnorm_flat->Fit("FF_fittepoleII","REM"); hEpEm_QEDnorm->Fit("FF_fittepole","REM+"); Double_t Lambda = FF_fittepole->GetParameter(1); Double_t Lambdaerr = FF_fittepole->GetParError(1); Double_t bn = 1./Lambda; Double_t bn_err = Lambdaerr/(bn*bn); Double_t Lambda_flat = FF_fittepoleII->GetParameter(1); Double_t Lambdaerr_flat = FF_fittepoleII->GetParError(1); Double_t bn_flat = 1./Lambda_flat; Double_t bn_err_flat = Lambdaerr_flat/(bn_flat*bn_flat); TString sLambda = Form("#Lambda^{2}_{fit} = %2.4f #pm %2.4f ", Lambda,Lambdaerr); TString sbn = Form("b_{n} = %2.4f #pm %2.4f ", bn,bn_err); TString sLambda_gen = Form("#Lambda^{2}_{gen} = %2.4f ", 0.5776); TString sbn_gen = Form("b_{n gen} = %2.4f ", 1./0.5776); TString sLambda_flat = Form("#Lambda^{2}_{fit} = %2.4f #pm %2.4f ", Lambda_flat,Lambdaerr_flat); TString sbn_flat = Form("b_{n} = %2.4f #pm %2.4f ", bn_flat,bn_err_flat); TLegend *legmkII = new TLegend(0.45,0.7,0.9,0.9); legmkII->SetTextSize(0.05); legmkII->SetFillColor(0); legmkII->AddEntry(hIVEpEm_cut_clone,"Expected counts in 80 days","l"); legmkII->AddEntry(hEpEm_corrected,"Accepted corrected counts in 80 days","l"); legmkII->Draw("same"); TCanvas *cmkIII = new TCanvas("cmkIII","cmkIII",1200,500); cmkIII->cd(); TH1D *hEpEm_acceptance = (TH1D*)in->Get("hEpEm_acceptance"); hEpEm_acceptance->SetLineColor(kRed); hEpEm_acceptance->SetYTitle("Acceptance / 10 MeV"); hEpEm_acceptance->GetYaxis()->SetTitleSize(0.05); hEpEm_acceptance->GetYaxis()->SetTitleOffset(0.8); hEpEm_acceptance->GetXaxis()->SetTitle("M(e^{+}e^{-}) [GeV]"); hEpEm_acceptance->GetXaxis()->SetTitleSize(0.05); hEpEm_acceptance->GetXaxis()->SetTitleOffset(0.8); TH1D *hEpEm_acceptance_flat = (TH1D*)inflat->Get("hEpEm_acceptance"); hEpEm_acceptance_flat->SetYTitle("Acceptance / 10 MeV"); hEpEm_acceptance_flat->GetYaxis()->SetTitleSize(0.05); hEpEm_acceptance_flat->GetYaxis()->SetTitleOffset(0.8); hEpEm_acceptance_flat->GetXaxis()->SetTitle("M(e^{+}e^{-}) [GeV]"); hEpEm_acceptance_flat->GetXaxis()->SetTitleSize(0.05); hEpEm_acceptance_flat->GetXaxis()->SetTitleOffset(0.8); hEpEm_acceptance->GetYaxis()->SetRangeUser(0,0.16); hEpEm_acceptance->Draw("EP"); hEpEm_acceptance_flat->Draw("EP same"); TLegend *legmkIII = new TLegend(0.11,0.7,0.45,0.9); legmkIII->SetTextSize(0.05); legmkIII->SetFillColor(0); legmkIII->AddEntry(hEpEm_acceptance,"QED+VMD M(e^{+}e^{-}) Acceptance","l"); legmkIII->AddEntry(hEpEm_acceptance_flat,"Flat M(e^{+}e^{-}) Acceptance","l"); legmkIII->Draw("same"); // double QED_par[8] = {0.957}; //{Mass} TF1 *QED_norm = new TF1("QED_norm",Eval_Kroll_wada,0.,1.,1); QED_norm->SetParameters(&QED_par[0]); TH1D *hEpEm_corrected_flat = new TH1D("hEpEm_corrected_flat","hEpEm_corrected_flat",100,0.0,1); TH1D *hEpEm_QEDnorm_flat = new TH1D("hEpEm_QEDnorm_flat","hEpEm_QEDnorm_flat",100,0.0,1); for (int i = 1; i<hIVEpEm_cut_clone->GetNbinsX(); i++) { Double_t bin_factor = 1.65; //this needs to be solved at somepoint Double_t intotal_acceptance = hEpEm_acceptance_flat->GetBinContent(i)*bin_factor; Double_t intotal_events_upper; if (intotal_acceptance == 0) { intotal_events_upper = 0; }else{ intotal_events_upper = hIVEpEm_cut_clone->GetBinContent(i)/intotal_acceptance; } hEpEm_corrected_flat->SetBinContent(i,intotal_events_upper); hEpEm_corrected_flat->SetBinError(i,sqrt(intotal_events_upper)); Double_t QED_factor = QED_norm->Eval(hIVEpEm_cut_clone->GetBinCenter(i));//2.0e-06; hEpEm_QEDnorm_flat->SetBinContent(i,intotal_events_upper/QED_factor); //hEpEm_QEDnorm->SetBinError(i,sqrt(intotal_events_upper/QED_factor)); } // double pole_par[3] = {10, 0.59,0.0144}; //{A,Lambda,Gamma} TF1 *FF_fittepole = new TF1("FF_fittepole", Pole_FFII,0.02,0.92,3); FF_fittepole->SetParameters(&pole_par[0]); FF_fittepole->SetParLimits(0,0.,100.); FF_fittepole->SetParLimits(1,pole_par[1] - pole_par[1]*0.1,pole_par[1] + pole_par[1]*0.1); FF_fittepole->SetParLimits(2,pole_par[2] - pole_par[2]*0.5,pole_par[2] + pole_par[2]*0.5); //for flat double pole_parII[3] = {10, 0.59,0.0144}; //{A,Lambda,Gamma} TF1 *FF_fittepoleII = new TF1("FF_fittepoleII", Pole_FFII,0.02,0.85,3); FF_fittepoleII->SetParameters(&pole_parII[0]); FF_fittepoleII->SetParLimits(0,0.,100.); FF_fittepoleII->SetParLimits(1,pole_parII[1] - pole_parII[1]*0.1,pole_parII[1] + pole_parII[1]*0.1); FF_fittepoleII->SetParLimits(2,pole_parII[2] - pole_parII[2]*0.5,pole_parII[2] + pole_parII[2]*0.5); FF_fittepoleII->SetLineColor(kBlue); //TF1 *FF_fitterGaus = new TF1("FF_fitterGaus","gaus",0.55,0.92); TCanvas *cmkI = new TCanvas("cmkI","cmkI",1200,500); TH1D *hEpEm_QEDnorm = (TH1D*)in->Get("hEpEm_QEDnorm"); cmkI->cd(); hEpEm_QEDnorm->SetTitle("Expected distribution of |F(q^{2})|^{2}"); hEpEm_QEDnorm->SetLineColor(kBlack); hEpEm_QEDnorm->SetYTitle("|F(q^{2})|^{2}"); hEpEm_QEDnorm->GetYaxis()->SetTitleSize(0.05); hEpEm_QEDnorm->GetYaxis()->SetTitleOffset(0.8); hEpEm_QEDnorm->GetXaxis()->SetTitle("M(e^{+}e^{-}) [GeV]"); hEpEm_QEDnorm->GetXaxis()->SetTitleSize(0.05); hEpEm_QEDnorm->GetXaxis()->SetTitleOffset(0.8); hEpEm_QEDnorm->Draw("EP"); hEpEm_QEDnorm_flat->SetLineColor(8); hEpEm_QEDnorm_flat->Draw("EP same"); hEpEm_QEDnorm_flat->Fit("FF_fittepoleII","REM"); hEpEm_QEDnorm->Fit("FF_fittepole","REM+"); Double_t Lambda = FF_fittepole->GetParameter(1); Double_t Lambdaerr = FF_fittepole->GetParError(1); Double_t bn = 1./Lambda; Double_t bn_err = Lambdaerr/(bn*bn); Double_t Lambda_flat = FF_fittepoleII->GetParameter(1); Double_t Lambdaerr_flat = FF_fittepoleII->GetParError(1); Double_t bn_flat = 1./Lambda_flat; Double_t bn_err_flat = Lambdaerr_flat/(bn_flat*bn_flat); TString sLambda = Form("#Lambda^{2}_{fit} = %2.4f #pm %2.4f ", Lambda,Lambdaerr); TString sbn = Form("b_{n} = %2.4f #pm %2.4f ", bn,bn_err); TString sLambda_gen = Form("#Lambda^{2}_{gen} = %2.4f ", 0.5776); TString sbn_gen = Form("b_{n gen} = %2.4f ", 1./0.5776); TString sLambda_flat = Form("#Lambda^{2}_{fit} = %2.4f #pm %2.4f ", Lambda_flat,Lambdaerr_flat); TString sbn_flat = Form("b_{n} = %2.4f #pm %2.4f ", bn_flat,bn_err_flat); TLegend *legmkI = new TLegend(0.12,0.55,0.37,0.9); legmkI->SetTextSize(0.04); legmkI->SetHeader("\t QED+VMD M(e^{+}e^{-}) Acceptance"); legmkI->SetFillColor(0); legmkI->AddEntry(FF_fittepole,sLambda,"l"); legmkI->AddEntry((TObject*)0,sbn,""); legmkI->AddEntry((TObject*)0,sLambda_gen,""); legmkI->AddEntry((TObject*)0,sbn_gen,""); legmkI->Draw("same"); TLegend *legmkI_I = new TLegend(0.37,0.55,0.57,0.9); legmkI_I->SetTextSize(0.04); legmkI_I->SetHeader("\t Flat M(e^{+}e^{-}) Acceptance"); legmkI_I->SetFillColor(0); legmkI_I->AddEntry(FF_fittepoleII,sLambda_flat,"l"); legmkI_I->AddEntry((TObject*)0,sbn_flat,""); legmkI_I->AddEntry((TObject*)0,"",""); legmkI_I->AddEntry((TObject*)0,"",""); legmkI_I->Draw("same"); */ }
// ----------------------------------------------------------------------------- // TCanvas* createPlot( TString path, TString canvas_name, TString name, TString dirmame, int rebin, bool norm, bool log, TDirectory* file ) { // SetSomeStyles(); float lumi = 250.0;// 15.04;//10.9;//6.8; // Create legend TLegend* legend = new TLegend(0.75, 0.6, 0.99, 0.99, "", "brNDC" ); legend->SetFillColor(0); legend->SetLineColor(0); legend->SetShadowColor(0); TLatex* prelim = new TLatex(0.6,0.54,"#scale[0.8]{CMS preliminary 2010}"); prelim->SetNDC(); TLatex* alumi = new TLatex(0.6,.45,"#scale[0.8]{#int L dt = 35 pb^{-1}, #sqrt{s} = 7 TeV}"); alumi->SetNDC(); // Create canvas TCanvas* aCanvas = createCanvas( canvas_name, file, log ); // Create histogram TString aname("nAll"); // TH1D* data1 = getHisto( path+"S14datacleaned/Edward_Data_Skim/",name,"data.root",aname,rebin); // TH1D* data = getHisto( path+"S14datacleaned/Edward_Data_Skim/",name,"data.root",dirmame,rebin); TH1D* data = getHisto( path+"", name, "tt.root", dirmame, rebin ); TH1D* qcd = getHisto( path+"", name, "lm1.root", dirmame, rebin ); TH1D* w_jets = getHisto( path+"", name, "w.root", dirmame, rebin ); TH1D* tt_jets = getHisto( path+"", name, "tt.root", dirmame, rebin ); TH1D* z_jets = getHisto( path+"", name, "z.root", dirmame, rebin ); TH1D* lm3 = getHisto( path+"", name, "lm3.root", dirmame, rebin ); TH1D* lm1 = getHisto( path+"", name, "lm1.root", dirmame, rebin ); TH1D* lm6 = getHisto( path+"", name, "data.root", dirmame, rebin ); TH1D* wm = getHisto( path+"", name, "w.root", dirmame, rebin ); data->Scale(lumi/100.); qcd->Scale(lumi/100.); tt_jets->Scale(lumi/100); w_jets->Scale(lumi/100); // w_jets->Scale(10); // z_inv->Scale(lumi/100); // lm6->Scale(lumi/100); lm1->Scale(lumi/100); lm3->Scale(lumi/100); z_jets->Scale(lumi/100); wm->Scale(lumi/100); // Combine Z+jets and Z->inv // TH1D* z_all = z_inv->Clone(); // z_all->Add(z_jets,1); //z_jets->Add(z_inv,1); TH1D* total = tt_jets->Clone(); total->Add(w_jets); total->Add(z_jets); // total-> Int_t binMax = total->GetNbinsX(); Double_t& err = new Double_t(0.); total->IntegralAndError(10,binMax ,err); Double_t& errW = new Double_t(0.); w_jets->IntegralAndError(10,binMax ,errW); Double_t& errtt = new Double_t(0.); tt_jets->IntegralAndError(10,binMax ,errtt); Double_t& errZ = new Double_t(0.); z_jets->IntegralAndError(10,binMax ,errZ); Double_t& errQCD = new Double_t(0.); qcd->IntegralAndError(10,binMax ,errQCD ); cout <<endl; // cout << "MC:" << total->IntegralAndError(11,binMax ,err) <<" && " << w_jets->Integral(11,binMax)<<" && "<<tt_jets->Integral(11,binMax) << "&& "<<z_jets->Integral(11,binMax)<<" && "<< "\/\ /\hline"<<endl; // cout << total->IntegralAndError(0,binMax ,err) <<" & " << lm1->Integral(0,binMax) <<" & " << lm3->Integral(0,binMax)<<" & " << lm6->Integral(0,binMax) <<"\\\\ \\hline"<<endl; // cout <<"270: " << total->IntegralAndError(27,binMax ,err) <<" & " << lm1->Integral(27,binMax) <<" & " << lm3->Integral(27,binMax)<<" & " << lm6->Integral(27,binMax) <<"\\\\ \\hline"<<endl; cout <<"250& " << total->IntegralAndError(6,binMax ,err) <<" & " << lm1->Integral(6,binMax) <<" & " << lm3->Integral(6,binMax)<<" & " << lm6->Integral(6,binMax) <<"\\\\ \\hline"<<endl; // cout << "300: " << total->IntegralAndError(7,binMax ,err) <<" & " << lm1->Integral(7,binMax) <<" & " << lm3->Integral(7,binMax)<<" &" << lm6->Integral(7,binMax) <<"\\\\ \\hline"<<endl; cout <<"350& " << total->IntegralAndError(8,binMax ,err) <<" & " << lm1->Integral(8,binMax) <<" & " << lm3->Integral(8,binMax)<<" & " << lm6->Integral(8,binMax) <<"\\\\ \\hline"<<endl; // cout << "400: " << total->IntegralAndError(9,binMax ,err) <<" & " << lm1->Integral(9,binMax) <<" & " << lm3->Integral(9,binMax)<<" & " << lm6->Integral(9,binMax) <<"\\\\ \\hline"<<endl; cout << "450& " << total->IntegralAndError(10,binMax ,err) <<" & " << lm1->Integral(10,binMax) <<" & " << lm3->Integral(10,binMax)<<" & " << lm6->Integral(10,binMax) <<"\\\\ \\hline"<<endl; //cout << "500: " << total->IntegralAndError(11,binMax ,err) <<" & " << lm1->Integral(11,binMax) <<" & " << lm3->Integral(11,binMax)<<" & " << lm6->Integral(11,binMax) <<"\\\\ \\hline"<<endl; cout <<"550& " << total->IntegralAndError(12,binMax ,err) <<" & " << lm1->Integral(12,binMax) <<" & " << lm3->Integral(12,binMax)<<" & " << lm6->Integral(12,binMax) <<"\\\\ \\hline"<<endl; /* cout << "MC:" << total->IntegralAndError(7,binMax ,err) <<" && " << lm1->Integral(7,binMax) <<" && " << lm3->Integral(7,binMax)<<" && " << lm6->Integral(6,binMax) <<"/\/\ /\hline"<<endl; cout << "MC:" << total->IntegralAndError(8,binMax ,err) <<" && " << lm1->Integral(8,binMax) <<" && " << lm3->Integral(8,binMax)<<" && " << lm6->Integral(7,binMax) <<"/\/\ /\hline"<<endl; cout << "MC:" << total->IntegralAndError(10,binMax ,err) <<" && " << lm1->Integral(10,binMax) <<" && " << lm3->Integral(10,binMax)<<" && " << lm6->Integral(10,binMax) <<"/\/\ /\hline"<<endl; cout << "MC:" << total->IntegralAndError(11,binMax ,err) <<" && " << lm1->Integral(11,binMax) <<" && " << lm3->Integral(11,binMax)<<" && " << lm6->Integral(11,binMax) <<"/\/\ /\hline"<<endl; cout << "MC:" << total->IntegralAndError(12,binMax ,err) <<" && " << lm1->Integral(12,binMax) <<" && " << lm3->Integral(12,binMax)<<" && " << lm6->Integral(12,binMax) <<"/\/\ /\hline"<<endl; // cout << "MC:" << err <<", W: " << errW<<", tt: "<<errtt << ", Z: "<<errZ<<", QCD: "<< errQCD<< endl; */ // cout << "data:" << data->Integral() << endl; TH1D* hcen = total->Clone(); TH1D* herr = total->Clone(); herr->SetLineColor(kTeal+3); herr->SetMarkerColor(kAzure+6); herr->SetFillColor(kAzure+6); herr->SetLineWidth(3); total->SetLineWidth(3); total->SetFillColor(kAzure+2); total->SetLineColor(kAzure+2); total->SetFillStyle(3245); hcen->SetFillStyle(0); hcen->SetMarkerColor(kTeal+3); hcen->SetLineColor(kTeal+3); hcen->SetLineWidth(3); // Merge Z+jets and Z->inv bool combine = false; // Line colour and fill qcd->SetLineColor(kPink+4); qcd->SetLineWidth(3); tt_jets->SetLineColor(kBlue+1); tt_jets->SetLineWidth(3); w_jets->SetLineColor(kPink+7); w_jets->SetLineWidth(3); z_jets->SetLineWidth(3); z_jets->SetLineColor(kTeal-7); if ( combine ) { z_all->SetLineColor(kBlack); z_all->SetLineStyle(3); z_all->SetLineWidth(1); } else { data->SetLineColor(1); data->SetLineStyle(1); data->SetLineWidth(3); data->SetMarkerStyle(20); data->SetFillColor(0); } // lm0->SetLineColor(kRed); // lm0->SetLineWidth(3); // lm1->SetLineColor(kRed+3); // lm1->SetLineWidth(3); // Populate legend // legend->AddEntry( data, "tt fully leptonic/", "LP" ); legend->AddEntry( herr, "full SM", "LP" ); legend->AddEntry( z_jets, " Z+jets ", "LP" ); legend->AddEntry( w_jets, " W+jets", "LP" ); legend->AddEntry( tt_jets, " t#bar{t}", "LP" ); // legend->AddEntry( lm3, " SUSY LM3", "LP" ); // legend->AddEntry( lm1, " SUSY LM1", "LP" ); legend->AddEntry( lm6, " data", "LP" ); // legend->AddEntry(wm,"W Mad","lp"); // Calc maximum number of entries double aMax = 0.; if( data->GetMaximum() > aMax ) { aMax = data->GetMaximum()+data->GetBinError(data->GetMaximumBin()); } if ( qcd->GetMaximum() > aMax ) { aMax = qcd->GetMaximum(); } // if ( lm0->GetMaximum() > aMax ) { aMax = lm0->GetMaximum(); } // if ( lm1->GetMaximum() > aMax ) { aMax = lm1->GetMaximum(); } if ( tt_jets->GetMaximum() > aMax ) { aMax = tt_jets->GetMaximum(); } if ( w_jets->GetMaximum() > aMax ) { aMax = w_jets->GetMaximum(); } if ( combine ) { if ( z_all->GetMaximum() > aMax ) { aMax = z_all->GetMaximum(); } } else { // if ( data->GetMaximum() > aMax ) { aMax = z_inv->GetMaximum(); } if ( z_jets->GetMaximum() > aMax ) { aMax = z_jets->GetMaximum(); } } // Calc minimum number of entries double aMin = 1.e12; if ( qcd->GetMinimum(1.e-12) < aMin ) { aMin = qcd->GetMinimum(1.e-12); } // if ( lm0->GetMinimum(1.e-12) < aMin ) { aMin = lm0->GetMinimum(1.e-12); } // if ( lm1->GetMinimum(1.e-12) < aMin ) { aMin = lm1->GetMinimum(1.e-12); } if ( tt_jets->GetMinimum(1.e-12) < aMin ) { aMin = tt_jets->GetMinimum(1.e-12); } if ( w_jets->GetMinimum(1.e-12) < aMin ) { aMin = w_jets->GetMinimum(1.e-12); } if ( combine ) { if ( z_all->GetMinimum(1.e-12) < aMin ) { aMin = z_all->GetMinimum(1.e-12); } } else { // if ( data->GetMinimum(1.e-12) < aMin ) { aMin = z_inv->GetMinimum(1.e-12); } if ( z_jets->GetMinimum(1.e-12) < aMin ) { aMin = z_jets->GetMinimum(1.e-12); } } if ( qcd ) qcd->GetYaxis()->SetTitleOffset(1.43); if ( qcd ) qcd->GetYaxis()->SetTitleSize(0.06); if ( qcd ) qcd->GetXaxis()->SetTitleSize(0.06); if ( qcd ) qcd->GetXaxis()->SetTitleOffset(0.9); if ( log ) { if ( qcd ) herr->SetMaximum( aMax * 10. ); // if ( qcd ) herr->SetMinimum( aMin * 0.1 ); if ( qcd ) herr->SetMinimum( 0.005); } else { if ( qcd ) herr->SetMaximum( aMax * 1.1 ); // if ( qcd ) herr->SetMinimum( aMin * 0.9 ); if ( qcd ) herr->SetMinimum( 0.005); } /* TPad* mainPad = new TPad("","",0.01,0.25,0.99,0.99); mainPad->SetNumber(1); mainPad->SetFillColor(0); // mainPad->Range(-288.2483,-2.138147,1344.235,6.918939); mainPad->SetFillColor(0); mainPad->SetBorderMode(0); mainPad->SetBorderSize(2); if ( log == true)mainPad->SetLogy(); mainPad->SetLeftMargin(0.1765705); mainPad->SetRightMargin(0.05772496); mainPad->SetTopMargin(0.04778761); mainPad->SetBottomMargin(0.1256637); mainPad->SetFrameFillStyle(0); mainPad->SetFrameLineWidth(2); mainPad->SetFrameBorderMode(0); mainPad->SetFrameFillStyle(0); mainPad->SetFrameLineWidth(2); mainPad->SetFrameBorderMode(0); if ( log == true)mainPad->SetLogy(); mainPad->Draw(); TPad* ratioPad = new TPad("","",0.01,0.01,0.99,0.25); ratioPad->SetNumber(2); ratioPad->SetFillColor(0); ratioPad->SetFillColor(0); ratioPad->SetBorderMode(0); ratioPad->SetBorderSize(2); // if ( log == true)ratioPad->SetLogy(); ratioPad->SetLeftMargin(0.1765705); ratioPad->SetRightMargin(0.05772496); ratioPad->SetTopMargin(0.04778761); ratioPad->SetBottomMargin(0.1256637); ratioPad->SetFrameFillStyle(0); ratioPad->SetFrameLineWidth(2); ratioPad->SetFrameBorderMode(0); ratioPad->SetFrameFillStyle(0); ratioPad->SetFrameLineWidth(2); ratioPad->SetFrameBorderMode(0); // if ( log == true)ratioPad->SetLogy(); ratioPad->Draw(); aCanvas->cd(1); */ herr->GetYaxis()->SetTitle("events"); if ( norm ) { if ( qcd ) qcd->DrawNormalized("Ehist"); // if ( lm0->GetEntries() > 0. ) { lm0->DrawNormalized("hsame"); } if ( lm1->GetEntries() > 0. ) { lm1->DrawNormalized("hsame"); } if ( tt_jets->GetEntries() > 0. ) { tt_jets->DrawNormalized("hsame"); } if ( w_jets->GetEntries() > 0. ) { w_jets->DrawNormalized("hsame"); } if ( combine ) { if ( z_all->GetEntries() > 0. ) { z_all->DrawNormalized("hsame"); } } else { if ( data->GetEntries() > 0. ) { z_inv->DrawNormalized("hsame"); } if ( z_jets->GetEntries() > 0. ) { z_jets->DrawNormalized("hsame"); } } } else { herr->Draw("hist"); // qcd->SetFillStyle(3240); // qcd->SetFillColor(kPink+4); // qcd->Draw("hist"); w_jets->Draw("hSameh"); z_jets->Draw("9Sameh"); w_jets->Draw("9Sameh"); tt_jets->Draw("9SAMEh"); //data1->Draw("9SAMEh"); //lm0->Draw("9SAMEh"); lm1->SetLineColor(12); lm1->SetLineStyle(2); lm1->SetLineWidth(2); // lm1->Draw("9SAMEh"); lm3->SetLineColor(14); lm3->SetLineStyle(2); lm3->SetLineWidth(2); // lm3->Draw("9SAMEh"); lm6->Draw("9SAMEh"); wm->SetLineStyle(2); wm->SetLineColor(kPink+7); // wm->Draw("9Sameh"); // total->DrawNormalized("9E2same"); // data->Draw("SAMEh"); // tt_jets->Divide(data); // tt_jets->Draw("h"); // data->SetLineColor(kRed); // data->Draw("sameh"); // data1->SetLineColor(kRed); // data1->Draw("9SAMEP"); } legend->Draw(); // prelim->Draw(); // alumi->Draw(); /* TH1D* ratioBottom = total->Clone(); TH1D* ratioTop = data->Clone(); ratioTop->GetYaxis()->SetTitle("data / sim"); ratioTop->Divide(ratioBottom); aCanvas->cd(1)->Update(); aCanvas->cd(2); ratioTop->SetTitleSize(0.1, "XYZ"); ratioTop->SetTitleOffset(0.55, "X"); ratioTop->SetTitleOffset(0.3, "Y"); ratioTop->SetLabelSize(0.06,"XY"); // ratioTop->GetXaxis().SetRangeUser(MinX,MaxX); ratioTop->GetYaxis()->SetRangeUser(0.,2.0); ratioTop->Draw();*/ /* TBox* unity = TBox(ratioTop->GetXaxis()->GetBinLowEdge(ratioTop->GetXaxis()->GetFirst()), 0.89,ratioTop->GetXaxis()->GetBinLowEdge(ratioTop->GetXaxis()->GetLast()), 1.11); unity->SetLineWidth(2); unity->SetLineColor(2); unity->SetFillColor(2); unity->SetFillStyle(3002); unity->Draw(); */ file->cd(); aCanvas->SaveAs( std::string(canvas_name+".pdf").c_str() ); aCanvas->Write(); // aCanvas->Print(".png"); return aCanvas; }
void plot(TString var, TString varlatex, TString varname, Int_t nbins, Double_t vmin, Double_t vmax) { cout<<"---- Processing - "<<var<<endl; cout<<" -- Fill histograms"<<endl; TFile* ifBkg = new TFile(infnameBkg[isChannel]); TTree* ntBkg = (TTree*)ifBkg->Get(texNtuple[isChannel]); ntBkg->AddFriend("ntHlt"); TFile* ifSgl = new TFile(infnameSgl[isChannel]); TTree* ntSgl = (TTree*)ifSgl->Get(texNtuple[isChannel]); ntSgl->AddFriend("ntHlt"); ntSgl->AddFriend("ntHi"); TH1D* hBkg = new TH1D(Form("hBkg_%s",varname.Data()),"",nbins,vmin,vmax); TH1D* hSgl = new TH1D(Form("hSgl_%s",varname.Data()),"",nbins,vmin,vmax); ntBkg->Project(Form("hBkg_%s",varname.Data()),var,Form("%s&&%s",selTriggerBkg[isChannel].Data(),selBkg[isChannel].Data())); ntSgl->Project(Form("hSgl_%s",varname.Data()),var,TCut(weight[isChannel])*Form("%s&&%s",selTriggerSgl[isChannel].Data(),selSgl[isChannel].Data())); cout<<" -- Calculate normalization"<<endl; Double_t normBkg=0,normSgl=0; //normBkg = hBkg->GetEntries(); //normSgl = hSgl->GetEntries(); normBkg = hBkg->Integral(vmin,vmax); normSgl = hSgl->Integral(vmin,vmax); cout<<" normBkg: "<<normBkg<<" ; normSgl: "<<normSgl<<endl; cout<<" -- Normalize histograms"<<endl; hBkg->Scale(1./normBkg); hSgl->Scale(1./normSgl); cout<<" -- Plot"<<endl; hBkg->SetXTitle(varlatex); hBkg->SetYTitle("#Probability"); hBkg->SetTitleOffset(1.5,"Y"); Double_t hisMax = (hBkg->GetMaximum()>hSgl->GetMaximum())?hBkg->GetMaximum():hSgl->GetMaximum(); hBkg->SetMaximum(hisMax*1.2); hBkg->SetLineColor(kBlue+1); hBkg->SetFillStyle(1001); hBkg->SetFillColor(kBlue-9); hBkg->SetLineWidth(3); hBkg->SetStats(0); TH1D* hSglplot = new TH1D(Form("hSglplot_%s",varname.Data()),"",nbins,vmin,vmax); for(int ib=0;ib<nbins;ib++) hSglplot->SetBinContent(ib+1,hSgl->GetBinContent(ib+1)); hSglplot->SetLineColor(kRed); hSglplot->SetFillStyle(3004); hSglplot->SetFillColor(kRed); hSglplot->SetLineWidth(3); hSglplot->SetStats(0); TCanvas* c = new TCanvas(Form("c_%s",varname.Data()),"",600,600); hBkg->Draw(); hSglplot->Draw("same"); cout<<" -- Plot legends"<<endl; TLatex* tex = new TLatex(0.18,0.935,Form("5.02TeV %s",texPP[isChannel].Data())); tex->SetNDC(); tex->SetTextFont(42); tex->SetTextSize(0.055); tex->Draw(); TLatex* texp; texp = new TLatex(0.68,0.935,texDecay[isChannel]); texp->SetNDC(); texp->SetTextFont(42); texp->SetTextSize(0.055); texp->Draw(); TLegend* leg = new TLegend(0.56,0.70,0.86,0.86); leg->AddEntry(hBkg,"Background","f"); leg->AddEntry(hSglplot,"Signal","f"); leg->SetBorderSize(0); leg->SetFillStyle(0); leg->Draw("same"); cout<<" -- Save plots"<<endl; c->SaveAs(Form("plots/%s_%s/c_%s.pdf",texPP[isChannel].Data(),texNtuple[isChannel].Data(),varname.Data())); cout<<endl; }
void plotXY(char* fname){ // input: root file from GBL gStyle->SetOptStat(0); Double_t w = 1.2; // number of RMS for gaussian fit TString filename = fname; TCanvas *cTop = new TCanvas("cTop","Residuals in lab frame, TOP", 800, 1000); TCanvas *cBot = new TCanvas("cBot","Residuals in lab frame, BOTTOM",800, 1000); cTop->SetFillColor(kBlue-10); cTop->SetFillStyle(3001); cBot->SetFillColor(kMagenta-10); cBot->SetFillStyle(3001); Double_t halfWid = 38.34/2.; Double_t halfLen = 98.33/2.; TBox *module = new TBox(-halfLen, -halfWid, halfLen, halfWid); module->SetLineColor(kMagenta); module->SetFillStyle(0); Int_t ic=0; TFile *f = new TFile(filename.Data()); // extract string Int_t idx2 = filename.Index("/"); Int_t idx1 = filename.Index("_"); TString outn = filename(idx1+1,idx2-(idx1+1)); TString outname ="predXY_"; outname += outn.Data(); outname += ".txt"; TString topName ="predXY_"; topName += outn.Data(); topName += "_topO.gif"; TString botName ="predXY_"; botName += outn.Data(); botName += "_botO.gif"; // ofstream outf(outname.Data()); // top Int_t nrow = 13; Double_t space = 0.007; Double_t space1 = 0.03; Double_t y2 = 1./13*nrow-space1; Double_t y1 = 1./13*(--nrow)-space1; TPad *tp1 = new TPad("tp1","tp1",0.33,y1,0.66,y2); y2 = y1; y1 = 1./13.*(--nrow)-space1; TPad *tp2 = new TPad("tp2","tp2",0.33,y1,0.66,y2); y2 = y1-space; y1 = 1./13.*(--nrow)-space1; TPad *tp3 = new TPad("tp3","tp3",0.33,y1,0.66,y2); y2 = y1; y1 = 1./13.*(--nrow)-space1; TPad *tp4 = new TPad("tp4","tp4",0.33,y1,0.66,y2); y2 = y1-space; y1 = 1./13.*(--nrow)-space1; TPad *tp5 = new TPad("tp5","tp5",0.33,y1,0.66,y2); y2 = y1; y1 = 1./13.*(--nrow)-space1; TPad *tp6 = new TPad("tp6","tp6",0.33,y1,0.66,y2); y2 = y1-space; y1 = 1./13.*(--nrow)-space1; Double_t off = 0.12; off = 0.165; y1 -= space1; y2 -= space1; space1 *= 2; TPad *tp7 = new TPad("tp7","tp7",0.+off,y1,0.33+off,y2); TPad *tp8 = new TPad("tp8","tp8",0.66-off,y1,1.-off,y2); y2 = y1; y1 = 1./13.*(--nrow)-space1; TPad *tp9 = new TPad("tp9","tp9",0.+off,y1,0.33+off,y2); TPad *tp10 = new TPad("tp10","tp10",0.66-off,y1,1.-off,y2); y2 = y1-space; y1 = 1./13.*(--nrow)-space1; TPad *tp11 = new TPad("tp11","tp11",0.+off,y1,0.33+off,y2); TPad *tp12 = new TPad("tp12","tp12",0.66-off,y1,1.-off,y2); y2 = y1; y1 = 1./13.*(--nrow)-space1; TPad *tp13 = new TPad("tp13","tp13",0.+off,y1,0.33+off,y2); TPad *tp14 = new TPad("tp14","tp14",0.66-off,y1,1.-off,y2); y2 = y1-space; y1 = 1./13.*(--nrow)-space1; TPad *tp15 = new TPad("tp15","tp15",0.+off,y1,0.33+off,y2); TPad *tp16 = new TPad("tp16","tp16",0.66-off,y1,1.-off,y2); y2 = y1; y1 = 1./13.*(--nrow)-space1; TPad *tp17 = new TPad("tp17","tp17",0.+off,y1,0.33+off,y2); TPad *tp18 = new TPad("tp18","tp18",0.66-off,y1,1.-off,y2); cout << " TOP " << endl; cTop->cd(); tp1->Draw(); tp2->Draw(); tp3->Draw(); tp4->Draw(); tp5->Draw(); tp6->Draw(); tp7->Draw(); tp8->Draw(); tp9->Draw(); tp10->Draw(); tp11->Draw(); tp12->Draw(); tp13->Draw(); tp14->Draw(); tp15->Draw(); tp16->Draw(); tp17->Draw(); tp18->Draw(); ic = 2; Int_t ipad=0; for(Int_t i=1; i<4; i++){ TString hisname = "h_xy_module_L"; hisname += i; hisname += "t_halfmodule_axial_sensor0"; TString layer = "L"; layer+=i; layer+= "TA"; TH2D *his2 = (TH2D*) f->Get(hisname.Data()); TH1D *his = (TH1D*)his2->ProjectionY(); ipad++; TString pd = "tp"; pd+=ipad; TPad *pad = (TPad*) cTop->GetListOfPrimitives()->FindObject(pd.Data()); pad->cd(); Double_t low = his->GetMean()-w*his->GetRMS(); Double_t up = his->GetMean()+w*his->GetRMS(); his->Fit("gaus","Q0","",low,up); his2->Draw("colz"); module->Draw("same"); TF1 *fit = his->GetFunction("gaus"); // cout << "sensor " << i << " axial mean : " << his->GetMean()*1000. << " - RMS : " << his->GetRMS()*1000. << " (um) " << " " << his->GetEntries() << endl; // cout << "sensor " << i << " axial mu : " << fit->GetParameter(1)*1000. << " - sigma : " << fit->GetParameter(2)*1000. << " (um) " << endl; // outf << layer.Data() << " " << fit->GetParameter(1)*1000. << " " << fit->GetParameter(2)*1000. << " " << his->GetEntries() << endl; hisname = "h_xy_module_L"; hisname += i; hisname += "t_halfmodule_stereo_sensor0"; layer = "L"; layer+=i; layer+= "TS"; his2 = (TH2D*) f->Get(hisname.Data()); his = (TH1D*)his2->ProjectionY(); ipad++; pd = "tp"; pd+=ipad; pad = (TPad*) cTop->GetListOfPrimitives()->FindObject(pd.Data()); pad->cd(); low = his->GetMean()-w*his->GetRMS(); up = his->GetMean()+w*his->GetRMS(); his->Fit("gaus","Q","",low,up); his2->Draw("colz"); module->Draw("same"); fit = his->GetFunction("gaus"); } // ic = 19; for(Int_t i=4; i<7; i++){ TString hisname = "h_xy_module_L"; hisname += i; TString hisname2 = hisname; hisname += "t_halfmodule_axial_hole_sensor0"; hisname2 += "t_halfmodule_axial_slot_sensor0"; TH2D *hisOther = (TH2D*) f->Get(hisname2.Data()); Double_t norma2 = hisOther->GetMaximum(); TString layer = "L"; layer+=i; layer+= "TAHo"; TH2D *his2 = (TH2D*) f->Get(hisname.Data()); TH1D *his = (TH1D*)his2->ProjectionY(); Double_t norma1 = his2->GetMaximum(); Double_t normamax = TMath::Max(norma1,norma2); his2->SetMaximum(normamax); ipad++; TString pd = "tp"; pd+=ipad; TPad *pad = (TPad*) cTop->GetListOfPrimitives()->FindObject(pd.Data()); pad->cd(); Double_t low = his->GetMean()-w*his->GetRMS(); Double_t up = his->GetMean()+w*his->GetRMS(); his->Fit("gaus","Q0","",low,up); his2->Draw("colz"); module->Draw("same"); TF1 *fit = his->GetFunction("gaus"); hisname = "h_xy_module_L"; hisname += i; hisname2 = hisname; hisname += "t_halfmodule_stereo_hole_sensor0"; hisname2 += "t_halfmodule_stereo_slot_sensor0"; TH2D *hisOther = (TH2D*) f->Get(hisname2.Data()); norma2 = hisOther->GetMaximum(); TString layer = "L"; layer+=i; layer+= "TAHo"; TH2D *his2 = (TH2D*) f->Get(hisname.Data()); TH1D *his = (TH1D*)his2->ProjectionY(); norma1 = his2->GetMaximum(); normamax2 = TMath::Max(norma1,norma2); his2->SetMaximum(normamax2); layer = "L"; layer+=i; layer+= "TSHo"; his2 = (TH2D*) f->Get(hisname.Data()); his = (TH1D*)his2->ProjectionY(); ipad++; ipad++; pd = "tp"; pd+=ipad; pad = (TPad*) cTop->GetListOfPrimitives()->FindObject(pd.Data()); pad->cd(); low = his->GetMean()-w*his->GetRMS(); up = his->GetMean()+w*his->GetRMS(); his->Fit("gaus","Q0","",low,up); his2->Draw("colz"); module->Draw("same"); fit = his->GetFunction("gaus"); hisname = "h_xy_module_L"; hisname += i; hisname += "t_halfmodule_axial_slot_sensor0"; layer = "L"; layer+=i; layer+= "TASl"; his2 = (TH2D*) f->Get(hisname.Data()); his2->SetMaximum(normamax); his = (TH1D*)his2->ProjectionY(); ipad--; pd = "tp"; pd+=ipad; pad = (TPad*) cTop->GetListOfPrimitives()->FindObject(pd.Data()); pad->cd(); low = his->GetMean()-w*his->GetRMS(); up = his->GetMean()+w*his->GetRMS(); his->Fit("gaus","Q0","",low,up); his2->Draw("colz"); module->Draw("same"); fit = his->GetFunction("gaus"); hisname = "h_xy_module_L"; hisname += i; hisname += "t_halfmodule_stereo_slot_sensor0"; layer = "L"; layer+=i; layer+= "TSSl"; his2 = (TH2D*) f->Get(hisname.Data()); his2->SetMaximum(normamax2); his = (TH1D*)his2->ProjectionY(); ipad++; ipad++; pd = "tp"; pd+=ipad; pad = (TPad*) cTop->GetListOfPrimitives()->FindObject(pd.Data()); pad->cd(); low = his->GetMean()-w*his->GetRMS(); up = his->GetMean()+w*his->GetRMS(); his->Fit("gaus","Q0","",low,up); his2->Draw("colz"); module->Draw("same"); fit = his->GetFunction("gaus"); } cout << endl; cout << "------------------------" << endl; cout << endl; cout << " BOTTOM " << endl; nrow = 13; space = 0.007; space1 = 0.03; y2 = 1./13*nrow-space1; y1 = 1./13*(--nrow)-space1; TPad *bp1 = new TPad("bp1","bp1",0.33,y1,0.66,y2); y2 = y1; y1 = 1./13.*(--nrow)-space1; TPad *bp2 = new TPad("bp2","bp2",0.33,y1,0.66,y2); y2 = y1-space; y1 = 1./13.*(--nrow)-space1; TPad *bp3 = new TPad("bp3","bp3",0.33,y1,0.66,y2); y2 = y1; y1 = 1./13.*(--nrow)-space1; TPad *bp4 = new TPad("bp4","bp4",0.33,y1,0.66,y2); y2 = y1-space; y1 = 1./13.*(--nrow)-space1; TPad *bp5 = new TPad("bp5","bp5",0.33,y1,0.66,y2); y2 = y1; y1 = 1./13.*(--nrow)-space1; TPad *bp6 = new TPad("bp6","bp6",0.33,y1,0.66,y2); y2 = y1-space; y1 = 1./13.*(--nrow)-space1; off = 0.165; y1 -= space1; y2 -= space1; space1 *= 2; TPad *bp7 = new TPad("bp7","bp7",0.+off,y1,0.33+off,y2); TPad *bp8 = new TPad("bp8","bp8",0.66-off,y1,1.-off,y2); y2 = y1; y1 = 1./13.*(--nrow)-space1; TPad *bp9 = new TPad("bp9","bp9",0.+off,y1,0.33+off,y2); TPad *bp10 = new TPad("bp10","bp10",0.66-off,y1,1.-off,y2); y2 = y1-space; y1 = 1./13.*(--nrow)-space1; TPad *bp11 = new TPad("bp11","bp11",0.+off,y1,0.33+off,y2); TPad *bp12 = new TPad("bp12","bp12",0.66-off,y1,1.-off,y2); y2 = y1; y1 = 1./13.*(--nrow)-space1; TPad *bp13 = new TPad("bp13","bp13",0.+off,y1,0.33+off,y2); TPad *bp14 = new TPad("bp14","bp14",0.66-off,y1,1.-off,y2); y2 = y1-space; y1 = 1./13.*(--nrow)-space1; TPad *bp15 = new TPad("bp15","bp15",0.+off,y1,0.33+off,y2); TPad *bp16 = new TPad("bp16","bp16",0.66-off,y1,1.-off,y2); y2 = y1; y1 = 1./13.*(--nrow)-space1; TPad *bp17 = new TPad("bp17","bp17",0.+off,y1,0.33+off,y2); TPad *bp18 = new TPad("bp18","bp18",0.66-off,y1,1.-off,y2); cBot->cd(); bp1->Draw(); bp2->Draw(); bp3->Draw(); bp4->Draw(); bp5->Draw(); bp6->Draw(); bp7->Draw(); bp8->Draw(); bp9->Draw(); bp10->Draw(); bp11->Draw(); bp12->Draw(); bp13->Draw(); bp14->Draw(); bp15->Draw(); bp16->Draw(); bp17->Draw(); bp18->Draw(); cBot->cd(); bp1->Draw(); bp2->Draw(); bp3->Draw(); bp4->Draw(); bp5->Draw(); bp6->Draw(); bp7->Draw(); bp8->Draw(); bp9->Draw(); bp10->Draw(); bp11->Draw(); bp12->Draw(); bp13->Draw(); bp14->Draw(); bp15->Draw(); bp16->Draw(); bp17->Draw(); bp18->Draw(); ic=0; ipad = 0; for(Int_t i=1; i<4; i++){ TString hisname = "h_xy_module_L"; hisname += i; TString hisname2 = hisname; hisname += "b_halfmodule_stereo_sensor0"; hisname2 += "b_halfmodule_axial_sensor0"; TH2D *hisOther = (TH2D*) f->Get(hisname2.Data()); Double_t norma2 = hisOther->GetMaximum(); TString layer = "L"; layer+=i; layer+= "BS"; TH2D *his2 = (TH2D*) f->Get(hisname.Data()); Double_t norma1 = his2->GetMaximum(); Double_t normamax = TMath::Max(norma1,norma2); // his2->SetMaximum(normamax); TH1D *his = (TH1D*)his2->ProjectionY(); if(layer.Contains("1")){his->SetFillColor(kRed);} else if(layer.Contains("2")){his->SetFillColor(kOrange);} else if(layer.Contains("3")){his->SetFillColor(kYellow);} else if(layer.Contains("4")){his->SetFillColor(kGreen);} else if(layer.Contains("5")){his->SetFillColor(kCyan);} else if(layer.Contains("6")){his->SetFillColor(kBlue);} if(layer.Contains("A")){his->SetFillStyle(3007);} else if(layer.Contains("S")){his->SetFillStyle(3004);} // cBot->cd(++ic); ipad++; TString pd = "bp"; pd+=ipad; TPad *pad = (TPad*) cBot->GetListOfPrimitives()->FindObject(pd.Data()); pad->cd(); Double_t low = his->GetMean()-w*his->GetRMS(); Double_t up = his->GetMean()+w*his->GetRMS(); his->Fit("gaus","Q0","",low,up); his2->Draw("colz"); module->Draw("same"); TF1 *fit = his->GetFunction("gaus"); hisname = "h_xy_module_L"; hisname += i; hisname += "b_halfmodule_axial_sensor0"; layer = "L"; layer+=i; layer+= "BA"; his2 = (TH2D*) f->Get(hisname.Data()); // his2->SetMaximum(normamax); his = (TH1D*)his2->ProjectionY(); ipad++; pd = "bp"; pd+=ipad; pad = (TPad*) cBot->GetListOfPrimitives()->FindObject(pd.Data()); pad->cd(); low = his->GetMean()-w*his->GetRMS(); up = his->GetMean()+w*his->GetRMS(); his->Fit("gaus","Q0","",low,up); his2->Draw("colz"); module->Draw("same"); fit = his->GetFunction("gaus"); } for(Int_t i=4; i<7; i++){ TString hisname = "h_xy_module_L"; hisname += i; TString hisname2 = hisname; hisname += "b_halfmodule_stereo_hole_sensor0"; hisname2 += "b_halfmodule_stereo_slot_sensor0"; TH2D *hisOther = (TH2D*) f->Get(hisname2.Data()); Double_t norma2 = hisOther->GetMaximum(); TString layer = "L"; layer+=i; layer+= "BSHo"; TH2D *his2 = (TH2D*) f->Get(hisname.Data()); TH1D *his = (TH1D*)his2->ProjectionY(); Double_t norma1 = his2->GetMaximum(); Double_t normamax1 = TMath::Max(norma1,norma2); his2->SetMaximum(normamax1); ipad++; TString pd = "bp"; pd+=ipad; TPad *pad = (TPad*) cBot->GetListOfPrimitives()->FindObject(pd.Data()); pad->cd(); Double_t low = his->GetMean()-w*his->GetRMS(); Double_t up = his->GetMean()+w*his->GetRMS(); his->Fit("gaus","Q0","",low,up); his2->Draw("colz"); module->Draw("same"); TF1 *fit = his->GetFunction("gaus"); hisname = "h_xy_module_L"; hisname += i; TString hisname2 = hisname; hisname += "b_halfmodule_axial_hole_sensor0"; hisname2 += "b_halfmodule_axial_slot_sensor0"; TH2D *hisOther = (TH2D*) f->Get(hisname2.Data()); Double_t norma2 = hisOther->GetMaximum(); TString layer = "L"; layer+=i; layer+= "BAHo"; TH2D *his2 = (TH2D*) f->Get(hisname.Data()); TH1D *his = (TH1D*)his2->ProjectionY(); Double_t norma1 = his2->GetMaximum(); Double_t normamax2 = TMath::Max(norma1,norma2); his2->SetMaximum(normamax2); ipad++; ipad++; pd = "bp"; pd+=ipad; pad = (TPad*) cBot->GetListOfPrimitives()->FindObject(pd.Data()); pad->cd(); low = his->GetMean()-w*his->GetRMS(); up = his->GetMean()+w*his->GetRMS(); his->Fit("gaus","Q0","",low,up); his2->Draw("colz"); module->Draw("same"); fit = his->GetFunction("gaus"); hisname = "h_xy_module_L"; hisname += i; hisname += "b_halfmodule_stereo_slot_sensor0"; layer = "L"; layer+=i; layer+= "BSSl"; his2 = (TH2D*) f->Get(hisname.Data()); his2->SetMaximum(normamax1); his = (TH1D*)his2->ProjectionY(); ipad--; pd = "bp"; pd+=ipad; pad = (TPad*) cBot->GetListOfPrimitives()->FindObject(pd.Data()); pad->cd(); low = his->GetMean()-w*his->GetRMS(); up = his->GetMean()+w*his->GetRMS(); his->Fit("gaus","Q0","",low,up); his2->Draw("colz"); module->Draw("same"); fit = his->GetFunction("gaus"); hisname = "h_xy_module_L"; hisname += i; hisname += "b_halfmodule_axial_slot_sensor0"; layer = "L"; layer+=i; layer+= "BASl"; his2 = (TH2D*) f->Get(hisname.Data()); his2->SetMaximum(normamax2); his = (TH1D*)his2->ProjectionY(); ipad++; ipad++; pd = "bp"; pd+=ipad; pad = (TPad*) cBot->GetListOfPrimitives()->FindObject(pd.Data()); pad->cd(); low = his->GetMean()-w*his->GetRMS(); up = his->GetMean()+w*his->GetRMS(); his->Fit("gaus","Q0","",low,up); his2->Draw("colz"); module->Draw("same"); fit = his->GetFunction("gaus"); } // outf.close(); cTop->SaveAs(topName.Data()); cBot->SaveAs(botName.Data()); }
void plottingmacro_IVF() { double fa = 0.46502; double fb = 0.53498; bool debug_ = true; // std::string path("Nov10thFall11Plots/"); // std::string path("Nov10Fall1160MTopSlimPlots/"); std::string path("Nov10Fall1160MTopIVFPlots_b/"); if(debug_) std::cout << "Init the style form setTDRStyle" << std::endl; setTDRStyle(); gStyle->SetErrorX(0.5); gROOT->ForceStyle(); initOptions(); if(debug_) std::cout << "Init the sample" << std::endl; // std::vector<Sample> s = Nov10thDiJetPtUpdatedSlimHistos(); //std::vector<Sample> s = Nov10Fall1160MTopSlimHistos(); std::vector<Sample> s = Nov10Fall1160MTopIVFHistos(); Sample data(1,"fake data","S1.root",0,true,1000); if(debug_) std::cout << "Init the data sample" << std::endl; for(size_t i=0;i< s.size();i++) if(s[i].data) {data=s[i];break;} if(debug_) std::cout << "Ls data sample" << std::endl; data.file()->ls(); if(debug_) std::cout << "Init the mc sample" << std::endl; for(size_t i=0;i< s.size();i++) s[i].dump(1,fa,fb); std::vector<std::string> names; if(debug_) std::cout << "Get List of Keys" << std::endl; TList * subs = data.file()->GetListOfKeys(); for(size_t i=0;i< subs->GetSize();i++) { TString nn = subs->At(i)->GetName(); if( nn.Contains(TRegexp("Count*")) ) continue; if(debug_) std::cout << "Get List of Keys in subdirs" << std::endl; TList * objs = ((TDirectoryFile *)data.file()->Get(subs->At(i)->GetName()))->GetListOfKeys(); for(size_t j=0;j< objs->GetSize();j++) { if(debug_) std::cout << "Name = " << subs->At(i)->GetName()+std::string("/") + objs->At(j)->GetName() << std::endl; names.push_back(subs->At(i)->GetName()+std::string("/") + objs->At(j)->GetName()); // std::cout << subs->At(i)->GetName() << "/" << objs->At(j)->GetName() << std::endl; //TODO: select plots via regexp } } if(debug_) std::cout << "Starting plotting" << std::endl; std::string process; for(size_t i = 0 ; i < names.size() ; i++) { std::map<std::string,TH1F *> grouped; TString n=names[i]; // if(!n.Contains(TRegexp("VlightRegionHZee/HiggsPtVlightRegionHZee"))) continue; // if(!n.Contains(TRegexp("VlightRegionHZee/ZPtVlightRegionHZee"))) continue; // if(!n.Contains(TRegexp("VlightRegionHZee"))) continue; // if(!n.Contains(TRegexp("ZSVRegionZmmSV"))) continue; // if(!n.Contains(TRegexp("ZSVRegionZeeSV"))) continue; // if(!n.Contains(TRegexp("ZSVRegionZcombSV"))) continue; // if(!n.Contains(TRegexp("ZSVPureRegionZcombSV"))) continue; // if(!n.Contains(TRegexp("ZSVTTbarPureRegionZcombSV"))) continue; if(!n.Contains(TRegexp("TTbarRegionZeeSVJets"))) continue; if(n.Contains(TRegexp("RegionHZcomb"))) process = "Z(l^{+}l^{-})H(b#bar{b})"; if(n.Contains(TRegexp("RegionHZmm"))) process = "Z(#mu^{+}#mu^{-})H(b#bar{b})"; if(n.Contains(TRegexp("RegionHZee"))) process = "Z(e^{+}e^{-})H(b#bar{b})"; if(debug_) std::cout << "Creating the Canvas" << std::endl; TCanvas *c = new TCanvas(); c->SetLogy(false); c->SetTitle(names[i].c_str()); if(debug_) std::cout << "Creating histograms" << std::endl; TH1F *hd = ((TH1F*)data.file()->Get(names[i].c_str())); hd->Sumw2(); Options o=options[names[i]]; // hd->Rebin(o.rebin); hd->SetMarkerStyle(20); hd->GetXaxis()->SetLabelOffset(99); hd->SetYTitle(o.yaxis.c_str()); double nbin = hd->GetNbinsX(); double min_bin = hd->GetXaxis()->GetXmin(); double max_bin = hd->GetXaxis()->GetXmax(); TH1F *hmc = new TH1F("hmc","hmc", nbin, min_bin, max_bin); hmc->SetFillColor(kWhite); hmc->Sumw2(); // hmc->Rebin(o.rebin); if(debug_) std::cout << "Creating the THStack and Legend" << std::endl; THStack * sta = new THStack("sta",hd->GetTitle()); TLegend * l = new TLegend(o.legendx1,o.legendy1,o.legendx2,o.legendy2); //0.7,0.1,0.9,0.6); l->SetFillColor(kWhite); l->SetBorderSize(0); l->SetTextFont(62); l->SetTextSize(0.03); if(debug_) std::cout << "Adding data to the legend" << std::endl; l->AddEntry(hd, "Data","P"); if(debug_) std::cout << "Adding MC to the THStack" << std::endl; //with the proper trigger eff // double SF[] = {1.01,1.03,1.00}; // double SF[] = {1.03,1.054,1.032}; double SF[] = {1.0,1.0,1.0}; if(debug_){ for(int i = 0; i< 3; ++i) std::cout << "SF [" << i << "] = " << SF[i] << std::endl; } double mcIntegral=0; for(size_t j=0;j< s.size() ;j++) { if(!s[j].data) { if(debug_) std::cout << "Creating TH1F from file " << s[j].name << std::endl; TH1F * h = ((TH1F*)s[j].file()->Get(names[i].c_str())); h->Sumw2(); if(debug_){ std::cout << "TH1F created from file " << s[j].name << std::endl; std::cout << "Scaling : " << s[j].scale(data.lumi(),fa,fb) << std::endl; std::cout << "Scaling with SF : " << s[j].scale(data.lumi(),fa,fb,SF) << std::endl; std::cout << "Histo integral before scaling = " << h->Integral() << std::endl; } h->Scale(s[j].scale(data.lumi(),fa,fb,SF)); if(debug_){ std::cout << "Histo integral after scaling = " << h->Integral() << std::endl; std::cout << "Managing style... " << std::endl; } h->SetLineWidth(1.); h->SetFillColor(s[j].color); h->SetLineColor(s[j].color); // h->Rebin(options[names[i]].rebin); if(debug_) std::cout << "Cloning and update legend " << std::endl; if(grouped.find(s[j].name) == grouped.end()){ l->AddEntry(h,s[j].name.c_str(),"F"); } std::cout << "Sample : " << s[j].name << " - Integral for plot " << names[i] << " = " << h->Integral(-10000,10000) << std::endl; mcIntegral += h->Integral(); sta->Add(h); hmc->Add(h); //TO FIX grouped map // sovrascrive histo con lo stesso nome tipo VV o ST etc... grouped[s[j].name]=(TH1F *)h->Clone(("_"+names[i]).c_str()); } } if(debug_){ std::cout << "Data total = " << hd->Integral() << std::endl; std::cout << "MC = " << mcIntegral << std::endl; std::cout << "Data/MC = " << hd->Integral()/mcIntegral << std::endl; } TPad * TopPad = new TPad("TopPad","Top Pad",0.,0.3,1.,1. ) ; TPad * BtmPad = new TPad("BtmPad","Bottom Pad",0.,0.,1.,0.313 ) ; TopPad->SetBottomMargin(0.02); BtmPad->SetTopMargin(0.0); BtmPad->SetFillStyle(4000); TopPad->SetFillStyle(4000); BtmPad->SetFillColor(0); BtmPad->SetBottomMargin(0.35); TopPad->Draw() ; BtmPad->Draw() ; std::cout << "hd maximum = " << hd->GetMaximum() << " sta maximum = " << sta->GetMaximum() << std::endl; double maxY; if(hd->GetMaximum() > sta->GetMaximum()) maxY = (hd->GetMaximum())*1.5; else maxY = (sta->GetMaximum())*1.5; TopPad->cd(); hd->Draw("E1X0"); sta->Draw("sameHIST"); hmc->Draw("sameE2"); hmc->SetFillColor(2); hmc->SetMarkerSize(0); hmc->SetFillStyle(3013); hd->Draw("E1X0same"); l->Draw("same"); std::cout << "Set Maximum to = " << maxY << std::endl; hd->GetYaxis()->SetRangeUser(0.,maxY); hd->GetXaxis()->SetRangeUser(options[names[i]].min,options[names[i]].max); BtmPad->cd(); std::cout << "Division" << std::endl; TH1D * divisionErrorBand = (TH1D*)(hmc)->Clone("divisionErrorBand"); divisionErrorBand->Sumw2(); divisionErrorBand->Divide(hmc); divisionErrorBand->Draw("E2"); divisionErrorBand->SetMaximum(2.49); divisionErrorBand->SetMinimum(0); divisionErrorBand->SetMarkerStyle(20); divisionErrorBand->SetMarkerSize(0.55); divisionErrorBand->GetXaxis()->SetTitleOffset(1.12); divisionErrorBand->GetXaxis()->SetLabelSize(0.12); divisionErrorBand->GetXaxis()->SetTitleSize(0.5); divisionErrorBand->GetYaxis()->SetTitle("Data/MC"); divisionErrorBand->GetYaxis()->SetLabelSize(0.12); divisionErrorBand->GetYaxis()->SetTitleSize(0.12); divisionErrorBand->GetYaxis()->SetTitleOffset(0.40); divisionErrorBand->GetYaxis()->SetNdivisions(505); //divisionErrorBand->UseCurrentStyle(); divisionErrorBand->SetFillColor(2); divisionErrorBand->SetFillStyle(3001); divisionErrorBand->SetMarkerSize(0.); TH1D * division = (TH1D*)(hd)->Clone("division"); division->Sumw2(); division->Divide(hmc); // division->SetMaximum(2.5); // division->SetMinimum(0); // division->SetMarkerStyle(20); // division->SetMarkerSize(0.55); // division->GetXaxis()->SetLabelSize(0.12); // division->GetXaxis()->SetTitleSize(0.14); // division->GetYaxis()->SetLabelSize(0.10); // division->GetYaxis()->SetTitleSize(0.10); // division->GetYaxis()->SetTitle("Data/MC"); Double_t min = division->GetXaxis()->GetXmin(); Double_t max = division->GetXaxis()->GetXmax(); division->Draw("E1X0same"); TLine *line = new TLine(min, 1.0, max, 1.0); line->SetLineColor(kRed); line->Draw("same"); TLegend * leg3 =new TLegend(0.50,0.86,0.69,0.96); leg3->AddEntry(divisionErrorBand,"MC uncert. (stat.)","f"); leg3->SetFillColor(0); leg3->SetLineColor(0); leg3->SetShadowColor(0); leg3->SetTextFont(62); leg3->SetTextSize(0.06); leg3->Draw(); TPaveText *pave = new TPaveText(0.15,0.85,0.32,0.96,"brNDC"); pave->SetTextAlign(12); pave->SetLineColor(0); pave->SetFillColor(0); pave->SetShadowColor(0); //TText *text = pave->AddText(Form("#chi_{#nu}^{2} = %.3f, K_{s} = %.3f",histDt->Chi2Test(histCopyMC5,"UWCHI2/NDF"),histDt->KolmogorovTest(histCopyMC5))); // stat + sys TText *text = pave->AddText(Form("#chi_{#nu}^{2} = %.3f, K_{s} = %.3f",hd->Chi2Test(hmc,"UWCHI2/NDF"),hd->KolmogorovTest(hmc))); // stat only text->SetTextFont(62); text->SetTextSize(0.08); pave->Draw(); TopPad->cd(); TLatex latex; latex.SetNDC(); latex.SetTextAlign(12); latex.SetTextSize(0.052); latex.DrawLatex(0.17,0.89,"CMS Preliminary"); latex.SetTextSize(0.04); latex.DrawLatex(0.17,0.84,"#sqrt{s} = 7 TeV, L = 4.7 fb^{-1}"); // latex.DrawLatex(0.17,0.79,"Z(e^{+}e^{-})H(b#bar{b})"); latex.DrawLatex(0.17,0.79,process.c_str()); c->Update(); std::string cName= hd->GetName(); cName += "_bare.pdf"; cName = path+cName; c->Print(cName.c_str(),"pdf"); // std::cout << names[i] << " d: " << hd->Integral() << " "; // THStack * sta2 = new THStack("sta2",hd->GetTitle()); // float tot=0; // float toterr2=0; // if(debug_) // std::cout << "Putting the iterator in the for loop" << std::endl; // for(std::map<std::string,TH1F *>::reverse_iterator it=grouped.rbegin(); it!=grouped.rend();++it) // { // if(debug_) // std::cout << "Using the iterator" << std::endl; // std::cout << (*it).first << " " << (*it).second->Integral() << " | " << std::endl ; // if((*it).second->GetEntries() > 0) { // float er=1.*sqrt((*it).second->GetEntries())/(*it).second->GetEntries()*(*it).second->Integral(); // toterr2+=er*er; // } // tot+=(*it).second->Integral(); // sta2->Add(it->second); // } // std::cout << " Tot: " << tot << "+-" << sqrt(toterr2) << " SF: " << hd->Integral()/tot << std::endl; // TCanvas *c2 = new TCanvas(); // c2->SetTitle(names[i].c_str()); // std::cout << "hd maximum = " << hd->GetMaximum() << " sta2 maximum = " << sta2->GetMaximum() << std::endl; // if(hd->GetMaximum() > sta2->GetMaximum()) maxY = hd->GetBinContent(hd->GetMaximumBin()) * 1.5; // else maxY = ( sta2->GetMaximum())*1.5; // // hd->Draw("E1"); // sta2->Draw("PADSHIST"); // // hd->Draw("E1same"); // // l->Draw("same"); // std::cout << "Set Maximum to = " << maxY << std::endl; // hd->GetYaxis()->SetRangeUser(0.,maxY); // hd->GetXaxis()->SetRangeUser(options[names[i]].min,options[names[i]].max); // c2->Update(); // std::string c2Name = hd->GetName(); // c2Name = path+c2Name; // c2Name += "_norm.pdf"; // c2->Print(c2Name.c_str(),"pdf"); } }
void updateHIN11010(int etPho = 60, int etJet = 30, bool scaleByR=true, bool drawMC=true, int prodDate=20131021) { bool mcOnly=false; int percentBin[5] = {0,10,30,50,100}; TH1D* hxgj[5][10]; //[data kind] [ centrality] TH1D* hxgjpp[20]; TFile *fSum1 = new TFile(Form("histOutputFiles60GeVInclusive/HisOutput_Photonv7_v29_akPu3PF_InclPtRatio_gamma%djet%ddphiSig2749_Isol0_Norm1.root",etPho,etJet)); for ( int icent=0; icent<=3 ; icent++) { hxgj[khimc][icent] = (TH1D*)fSum1->Get(Form("dataSrc%d_reco1_cent%dSubtractedExtrapExtrapNorm",khimc,icent)); hxgj[khidata][icent] = (TH1D*)fSum1->Get(Form("dataSrc%d_reco1_cent%dSubtractedExtrapExtrapNorm",khidata,icent)); } hxgjpp[kppdata] = (TH1D*)fSum1->Get("dataSrc2_reco1_cent0SubtractedExtrapExtrapNorm"); TFile *fSum2 = new TFile(Form("histOutputFiles60GeVInclusive/HisOutput_Photonv7_v29_akPu3PF_InclPtRatio_gamma%djet%ddphiSig2749_Isol0_Norm2.root",etPho,etJet)); TGraphAsymmErrors* mxhimc = (TGraphAsymmErrors*)fSum2->Get("dataSrc0_reco1_x_Summary_0"); TGraphAsymmErrors* mxhidata = (TGraphAsymmErrors*)fSum2->Get("dataSrc1_reco1_x_Summary_0"); // TGraphAsymmErrors* mxppdata = (TGraphAsymmErrors*)fSum2->Get("dataSrc2_reco1_x_Summary_0"); TGraphAsymmErrors* mxppdata; TGraphAsymmErrors* mxppmc = (TGraphAsymmErrors*)fSum2->Get("dataSrc10_reco1_x_Summary_0"); TGraphAsymmErrors* rxhimc = (TGraphAsymmErrors*)fSum2->Get("dataSrc0_reco1_R_Summary_0"); TGraphAsymmErrors* rxhidata = (TGraphAsymmErrors*)fSum2->Get("dataSrc1_reco1_R_Summary_0"); TGraphAsymmErrors* rxppdata = (TGraphAsymmErrors*)fSum2->Get("dataSrc2_reco1_R_Summary_0"); TGraphAsymmErrors* rxppmc = (TGraphAsymmErrors*)fSum2->Get("dataSrc10_reco1_R_Summary_0"); TFile *fSum3 = new TFile(Form("histOutputFiles60GeVInclusive/HisOutput_Photonv7_v29_akPu3PF_InclDeltaPhi_gamma%djet%ddphiSig628_subJ1SS1_Isol0_Norm1.root",etPho,etJet)); TFile *fSum4 = new TFile("histOutputFiles60GeVInclusive/HisSummary_Photonv7_v29_akPu3PF_InclDeltaPhi_gamma60jet30dphiSig628_subJ1SS1_Isol0_Norm1.root"); TGraphAsymmErrors* dphihimc = (TGraphAsymmErrors*)fSum4->Get("dataSrc0_reco1_dphi_Summary"); TGraphAsymmErrors* dphihidata = (TGraphAsymmErrors*)fSum4->Get("dataSrc1_reco1_dphi_Summary"); TGraphAsymmErrors* dphippdata = (TGraphAsymmErrors*)fSum4->Get("dataSrc2_reco1_dphi_Summary"); TGraphAsymmErrors* dphippmc = (TGraphAsymmErrors*)fSum4->Get("dataSrc10_reco1_dphi_Summary"); // new dphihidata points // double sysDphi[4] = {0.032,0.03,0.045,0.077}; //0.109940, 0.046998, 0.034206,0.142664}; double sysDphipp[1] = {sysDphi[3]}; double sysR[4] = {0.045,0.039,0.041,0.037}; //0.017232,0.012847,0.011691,0.012724}; double sysRpp[1] = {sysR[3]}; double sysMx[4] = { 0.053,0.048,0.051,0.032}; double sysMxpp[1] = {0.009}; double corrSysMx = 0.028; TH1D* hdphi[5][5]; //[data kind] [ centrality] TH1D* hdphipp[20]; for ( int icent=0; icent<=3 ; icent++) { hdphi[khimc][icent] = (TH1D*)fSum3->Get(Form("dataSrc%d_reco1_cent%dSubtractedExtrapExtrapNorm",khimc,icent)); hdphi[khidata][icent] = (TH1D*)fSum3->Get(Form("dataSrc%d_reco1_cent%dSubtractedExtrapExtrapNorm",khidata,icent)); } hdphipp[kppdata] = (TH1D*)fSum3->Get("dataSrc2_reco1_cent0SubtractedExtrapExtrapNorm"); // 2013 pp data!!!!!! TFile* pp13 = new TFile(Form("ffFilesPP60GeVInclusive/photonTrackCorr_ppDATA_output_photonPtThr60_to_9999_jetPtThr30_%d.root", prodDate)); // TFile* pp13 = new TFile("ffFilesPP60GeVInclusive/oldSmearing.root"); hdphi[kppdata13][1] = (TH1D*)pp13->Get("jetDphi_icent10010_final"); hxgj[kppdata13][1] = (TH1D*)pp13->Get("xjg_icent10010_final"); hdphi[kppdata13][2] = (TH1D*)pp13->Get("jetDphi_icent11030_final"); hxgj[kppdata13][2] = (TH1D*)pp13->Get("xjg_icent11030_final"); hdphi[kppdata13][3] = (TH1D*)pp13->Get("jetDphi_icent13050_final"); hxgj[kppdata13][3] = (TH1D*)pp13->Get("xjg_icent13050_final"); hdphi[kppdata13][4] = (TH1D*)pp13->Get("jetDphi_icent15099_final"); hxgj[kppdata13][4] = (TH1D*)pp13->Get("xjg_icent15099_final"); hdphi[kppdata13][5] = (TH1D*)pp13->Get("jetDphi_icent7_final"); hxgj[kppdata13][5] = (TH1D*)pp13->Get("xjg_icent7_final"); for ( int icent = 1 ; icent<=5 ; icent++) { hdphi[kppdata13][icent]->Scale(1./hdphi[kppdata13][icent]->Integral()); for ( int i = 1 ; i<=5 ; i++) { hdphi[kppdata13][icent]->SetBinContent(i,-1e4); } // hxgj[kppdata13][icent]->Rebin(10); // Now the bins are already rebined from photonTrackCorr_ppDATA_output_photonPtThr60_to_9999_jetPtThr30_20131021.root hxgj[kppdata13][icent]->Scale(1./hxgj[kppdata13][icent]->Integral("width")); } TH1D* hPtPP2013[10]; hPtPP2013[1] = (TH1D*)pp13->Get("jetPt_icent10010_final"); hPtPP2013[2] = (TH1D*)pp13->Get("jetPt_icent11030_final"); hPtPP2013[3] = (TH1D*)pp13->Get("jetPt_icent13050_final"); hPtPP2013[4] = (TH1D*)pp13->Get("jetPt_icent15099_final"); hPtPP2013[5] = (TH1D*)pp13->Get("jetPt_icent7_final"); TH1D* hRpp2013[10]; hRpp2013[1] = new TH1D("hrpp2013_icent1","",1, 359.1-10, 359.1+10); hRpp2013[2] = new TH1D("hrpp2013_icent2","",1, 235.6-10, 235.6+10); hRpp2013[3] = new TH1D("hrpp2013_icent3","",1, 116.4-10, 116.4+10); hRpp2013[4] = new TH1D("hrpp2013_icent4","",1, 43.6-10, 43.6 +10); hRpp2013[5] = new TH1D("hrpp2013_icent5","",1, -8, 18 ); for ( int icent=1 ; icent<=5; icent++) { double temprPP13err; double temprPP13 = hPtPP2013[icent]->IntegralAndError(1,hPtPP2013[icent]->GetNbinsX(),temprPP13err,"width"); hRpp2013[icent]->SetBinContent(1,temprPP13); hRpp2013[icent]->SetBinError(1,temprPP13err); handsomeTH1(hRpp2013[icent],1); hRpp2013[icent]->SetMarkerStyle(21); } TH1D* hMXpp2013[10]; hMXpp2013[1] = new TH1D("hmxpp2013_icent1","",1, 359.1-10, 359.1+10); hMXpp2013[2] = new TH1D("hmxpp2013_icent2","",1, 235.6-10, 235.6+10); hMXpp2013[3] = new TH1D("hmxpp2013_icent3","",1, 116.4-10, 116.4+10); hMXpp2013[4] = new TH1D("hmxpp2013_icent4","",1, 43.6-10, 43.6 +10); hMXpp2013[5] = new TH1D("hmxpp2013_icent5","",1, -8, 18); for ( int icent=1 ; icent<=5; icent++) { hMXpp2013[icent]->SetBinContent(1,hxgj[kppdata13][icent]->GetMean()); hMXpp2013[icent]->SetBinError(1,hxgj[kppdata13][icent]->GetMeanError()); handsomeTH1(hMXpp2013[icent],1); hMXpp2013[icent]->SetMarkerStyle(21); } TFile* fPPsys = new TFile("ffFilesPP60GeVInclusive/relativeSys_merged_pp60GeV.root"); TH1D* hdphiWidth = (TH1D*)fPPsys->Get("dphiWidth_uncertainty_merged"); TH1D* hDphiPPUnc = new TH1D("hdphippunc","",1,0,1); hDphiPPUnc->SetBinContent(1, hdphiWidth->GetBinContent(1) ); TH1D* ppSysX[4]; ppSysX[0] = (TH1D*)fPPsys->Get("dNdXjg_uncertainty_merged"); ppSysX[1] = (TH1D*)ppSysX[0]->Clone("ppSysx1"); ppSysX[2] = (TH1D*)ppSysX[0]->Clone("ppSysx2"); ppSysX[3] = (TH1D*)ppSysX[0]->Clone("ppSysx3"); TH1D* meanXpp13Sys = (TH1D*)fPPsys->Get("meanXjg_uncertainty_merged"); float ppSysMx60 = meanXpp13Sys->GetBinContent(1); // UPDATED on Oct 22nd TH1D* ppSysMx = new TH1D("ppSysMx","",1,0,1); ppSysMx->SetBinContent(1,ppSysMx60); TH1D* meanRpp13Sys = (TH1D*)fPPsys->Get("meanRjg_uncertainty_merged"); float ppSysR60 = meanRpp13Sys->GetBinContent(1); // UPDATED on Oct 22nd TH1D* ppSysR = new TH1D("ppSysR","",1,0,1); ppSysR->SetBinContent(1,ppSysR60); // xjg distributions TCanvas *c1 = new TCanvas("c1","",1100,330); makeMultiPanelCanvas(c1,4,1,0.0,0.0,0.24,0.15,0.075); c1->cd(0); drawCMSppPbPb(0.1,0.95); //c1->Divide(4,1,0.0,0.0); for ( int icent=0; icent<=3 ; icent++) { c1->cd( 4 - icent); //hxgj[khimc][icent]->SetAxisRange(-.2,2.5,"Y"); hxgj[khimc][icent]->SetAxisRange(0,2.5,"Y"); hxgj[khimc][icent]->SetNdivisions(505); // hxgj[khimc][icent]->SetTitle(";x_{J#gamma} = p^{Jet}_{T}/p^{#gamma}_{T}; #frac{1}{N_{J#gamma}} #frac{dN_{J#gamma}}{dx_{J#gamma}}"); hxgj[khimc][icent]->SetTitle(";x_{J#gamma}; #frac{1}{N_{J#gamma}} #frac{dN_{J#gamma}}{dx_{J#gamma}}"); handsomeTH1(hxgj[khimc][icent]); fixedFontHist(hxgj[khimc][icent],1,1.35); mcStyle2(hxgj[khimc][icent]); handsomeTH1(hxgj[khidata][icent],2); hxgj[khimc][icent]->GetYaxis()->SetTitleOffset(1.5); TH1D * htemp41 = (TH1D*)hxgj[khimc][icent]->Clone(Form("htemp41_%d",icent)); for ( int i=0 ; i<=20 ; i++) { htemp41->SetBinContent(i,0); htemp41->SetBinError(i,0); } if (scaleByR) { htemp41->SetAxisRange(0,2,"Y"); htemp41->SetYTitle("#frac{1}{N_{#gamma}} #frac{dN_{J#gamma}}{dx_{J#gamma}}"); } htemp41->DrawCopy("hist"); if (scaleByR) { hxgj[kppdata13][icent+1]->Scale(hRpp2013[icent+1]->GetBinContent(1)); std::cout <<" Scaled by pp R :" << hRpp2013[icent+1]->GetBinContent(1) << std::endl; double x,y; rxhidata->GetPoint(icent, x,y); hxgj[khidata][icent]->Scale(y); std::cout << " scaled by PbPb R: " << y << std::endl; rxhimc->GetPoint(icent, x,y); hxgj[khimc][icent]->Scale(y); std::cout << " scaled by PbPb R: " << y << std::endl; } if(drawMC) hxgj[khimc][icent]->DrawCopy("hist same"); if ( !mcOnly ) drawXSys(icent,hxgj[khidata][icent]); // if ( icent==3){ } handsomeTH1(hxgj[kppdata13][icent+1]); hxgj[kppdata13][icent+1]->SetMarkerStyle(21); drawSys(hxgj[kppdata13][icent+1],ppSysX[icent],kGreen,3001); hxgj[kppdata13][icent+1]->Draw("same "); if ( !mcOnly ) hxgj[khidata][icent]->Draw("same"); //onSun(0,0,2,0); // if ( icent == 2) { // TLegend *leg0 = new TLegend(0.2796373,0.7545885,0.9742202,0.9937661,NULL,"brNDC"); // easyLeg(leg0,""); // // if ( !mcOnly ) leg0->AddEntry(hxgj[khidata][icent],"PbPb Data","p"); // leg0->AddEntry(hxgj[khimc][icent],"PYTHIA + HYDJET","f"); // leg0->AddEntry(hxgjpp[kppdata],"",""); // leg0->Draw(); // } if ( icent == 3) { TLegend *leg0 = new TLegend(0.2916647,0.7045885,0.9862476,0.9869226,NULL,"brNDC"); easyLeg(leg0); leg0->AddEntry(hxgj[khidata][icent],"PbPb Data","p"); if ( !mcOnly ) leg0->AddEntry(hxgj[kppdata13][icent+1],"Smeared pp reference","p"); // leg0->AddEntry(hxgj[khidata][icent],"",""); if(drawMC) leg0->AddEntry(hxgj[khimc][icent],"PbPb PYTHIA + HYDJET","f"); leg0->Draw(); //drawText("#sqrt{s_{NN}}=2.76 TeV ",0.65,0.74,0,15); } if ( icent == 2) { drawText(Form("p^{#gamma}_{T} > %d GeV/c |#eta^{#gamma}| < 1.44",etPho),0.2,0.85,0,15); drawText(Form("p^{Jet}_{T} > %d GeV/c |#eta^{Jet}| < 1.6",etJet),0.2,0.77,0,15); drawText("#Delta#phi_{J#gamma} > #frac{7}{8}#pi",0.2,0.69,0,15); } if ( icent == 0 ) { // drawText("CMS",0.8,0.9,1); // drawText("pp #int L dt = 231 nb^{-1}",0.4,0.68,1,15); } if ( icent == 3) drawText(Form("%d%% - %d%%",percentBin[icent],percentBin[icent+1]),0.72,0.5,0,15); else drawText(Form("%d%% - %d%%",percentBin[icent],percentBin[icent+1]),0.67,0.5,0,15); /* if ( icent == 3) drawText("(a)",0.275,0.8,1); if ( icent == 2) drawText("(b)",0.05,0.8,1); if ( icent == 1) drawText("(c)",0.05,0.8,1); if ( icent == 0) drawText("(d)",0.05,0.8,1); */ gPad->RedrawAxis(); } c1->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_xjg_distribution.pdf"); //c1->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_xjg_distribution.png"); //c1->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_xjg_distribution.gif"); //c1->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_xjg_distribution.C"); // TCanvas *c1all = new TCanvas("c1all","",500,500); // for ( int icent=0;icent<4;icent++){ // hxgj[khimc][icent]->SetFillStyle(0); // hxgj[khimc][icent]->SetMarkerSize(1.5); // } // hxgj[khimc][0]->SetMarkerStyle(22); // hxgj[khimc][1]->SetMarkerStyle(26); // hxgj[khimc][2]->SetMarkerStyle(23); // hxgj[khimc][3]->SetMarkerStyle(32); // hxgj[khimc][0]->DrawCopy(""); // hxgj[khimc][1]->DrawCopy(" same"); // hxgj[khimc][2]->DrawCopy(" same"); // hxgj[khimc][3]->DrawCopy(" same"); // jumSun(0,0,2,0); // drawText("PYTHIA+HYDJET",0.2,0.80,0,25); // TLegend *legc1all = new TLegend(0.6149194,0.6716102,0.9435484,0.9555085,NULL,"brNDC"); // easyLeg(legc1all,""); // legc1all->AddEntry(hxgj[khimc][3],"50-100%","p"); // legc1all->AddEntry(hxgj[khimc][2],"30-50%","p"); // legc1all->AddEntry(hxgj[khimc][1],"10-30%","p"); // legc1all->AddEntry(hxgj[khimc][0],"0-10%","p"); // legc1all->Draw(); // dphi distributions TCanvas *c1ppDphi = new TCanvas("c1ppDphi","",500,500); TString fitFunc = "(TMath::Pi()/20.0)*exp(-(TMath::Pi()-x)/[0])/([0]*(1-exp(-TMath::Pi()/[0])))"; float fitxmin=3.1415926*2./3; TF1 *fdphiPP[10]; TH1D* hDphiPP2013[10]; hDphiPP2013[1] = new TH1D("hDphiPP2013_icent1","",1, 359.1-10, 359.1+10); hDphiPP2013[2] = new TH1D("hDphiPP2013_icent2","",1, 235.6-10, 235.6+10); hDphiPP2013[3] = new TH1D("hDphiPP2013_icent3","",1, 116.4-10, 116.4+10); hDphiPP2013[4] = new TH1D("hDphiPP2013_icent4","",1, 43.6-10, 43.6 +10); hDphiPP2013[5] = new TH1D("hDphiPP2013_icent5","",1, -8, 18); for ( int icent=1; icent<=5 ; icent++) { fdphiPP[icent] = new TF1(Form("fdphiPP_icent%d",icent),fitFunc.Data(),2.0*TMath::Pi()/3.0,TMath::Pi()); fdphiPP[icent]->SetParName(0,"width"); fdphiPP[icent]->SetParameter("width",0.3); hdphi[kppdata13][icent]->Fit(Form("fdphiPP_icent%d",icent),"0","",fitxmin,3.1415926); fdphiPP[icent]->SetLineWidth(1); fdphiPP[icent]->SetLineStyle(2); fdphiPP[icent]->SetLineColor(1); hdphi[kppdata13][icent]->SetAxisRange(1.00001e-3,1,"Y"); hdphi[kppdata13][icent]->SetStats(0); hdphi[kppdata13][icent]->Draw(""); hdphi[kppdata13][icent]->SetAxisRange(1.00001e-3,1,"Y"); hdphi[kppdata13][icent]->SetStats(0); fdphiPP[icent]->SetLineWidth(2); fdphiPP[icent]->SetLineStyle(7); fdphiPP[icent]->DrawCopy("same"); gPad->SetLogy(); float dphiWidth13 = fdphiPP[icent]->GetParameter(0) ; float dphiWidth13err = fdphiPP[icent]->GetParError(0); hDphiPP2013[icent]->SetBinContent(1,dphiWidth13); hDphiPP2013[icent]->SetBinError( 1,dphiWidth13err); handsomeTH1(hDphiPP2013[icent],1); hDphiPP2013[icent]->SetMarkerStyle(21); } TCanvas *c1dphi = new TCanvas("c1dphi","",1100,330); makeMultiPanelCanvas(c1dphi,4,1,0.0,0.0,0.24,0.18,0.075); c1dphi->cd(0); drawCMSppPbPb(0.1,0.95); for ( int icent=0; icent<=3 ; icent++) { c1dphi->cd( 4 - icent); hdphi[khimc][icent]->SetAxisRange(1.e-3,1,"Y"); // hdphi[khimc][icent]->SetNdivisions(505); hdphi[khimc][icent]->GetXaxis()->SetNdivisions(3,5,0,kFALSE); hdphi[khimc][icent]->SetTitle(";#Delta#phi_{J#gamma};Pair Fraction"); handsomeTH1(hdphi[khimc][icent]); fixedFontHist(hdphi[khimc][icent],1,1.35); mcStyle2(hdphi[khimc][icent]); handsomeTH1(hdphi[khidata][icent],2); TF1 *fdphi = new TF1("fdphi",fitFunc.Data(),2.0*TMath::Pi()/3.0,TMath::Pi()); fdphi->SetParName(0,"width"); fdphi->SetParameter("width",0.3); hdphi[khimc][icent]->Fit("fdphi","0llm","",fitxmin,3.1415926); fdphi->SetLineWidth(1); fdphi->SetLineStyle(2); fdphi->SetLineColor(kBlue); // float dphiWidth = fdphi->GetParameter("width"); // float dphiWidthErr = fdphi->GetParError(0); // std::cout << " dphiWidth,dphiWidthErr = " << dphiWidth <<" "<< dphiWidthErr << std::endl; hdphi[khimc][icent]->SetAxisRange(1.00001e-3,1,"Y"); hdphi[khimc][icent]->SetStats(0); TH1D* hdphitemp = (TH1D*)hdphi[khimc][icent]->Clone(Form("hdphitemp55_%d",icent)); if(!drawMC) { for ( int i=0;i<=30;i++) { hdphitemp->SetBinContent(i,0); hdphitemp->SetBinError(i,0); } } hdphitemp->Draw("hist"); hdphi[khidata][icent]->SetAxisRange(1.00001e-3,1,"Y"); if (!mcOnly) hdphi[khidata][icent]->Draw("same "); hdphi[khidata][icent]->SetStats(0); fdphi->SetLineWidth(2); fdphi->SetLineStyle(7); if ( mcOnly ) fdphi->DrawCopy("same"); gPad->SetLogy(); handsomeTH1(hdphi[kppdata13][icent+1]); hdphi[kppdata13][icent+1]->SetMarkerStyle(21); hdphi[kppdata13][icent+1]->Draw("same"); if ( icent == 3) { TLegend *leg0 = new TLegend(0.32,0.7,0.9,0.89,NULL,"brNDC"); easyLeg(leg0); if ( !mcOnly ) leg0->AddEntry(hdphi[kppdata13][icent+1],"Smeared pp reference","p"); if ( !mcOnly ) leg0->AddEntry(hdphi[khidata][icent],"PbPb Data","p"); if(drawMC) leg0->AddEntry(hdphi[khimc][icent],"PYTHIA + HYDJET","f"); leg0->Draw(); } if (( !mcOnly ) && ( icent == 2)) { //drawText("#sqrt{s_{NN}}=2.76 TeV ",0.4,0.88,0,15); //drawText("#int L dt = 150 #mub^{-1}",0.4,0.75,0,15); } if ( icent == 1) { drawText(Form("p^{#gamma}_{T} > %d GeV/c |#eta^{#gamma}| < 1.44",etPho),0.15,0.8,0,15); drawText(Form("p^{Jet}_{T} > %d GeV/c |#eta^{Jet}| < 1.6",etJet),0.15,0.7,0,15); } if ( icent == 0 ) { // drawText("CMS",0.8,0.9,1); // drawText("pp #int L dt = 231 nb^{-1}",0.4,0.68,1,15); } if ( icent == 3) drawText(Form("%d%% - %d%%",percentBin[icent],percentBin[icent+1]),0.313,0.6,0,15); else drawText(Form("%d%% - %d%%",percentBin[icent],percentBin[icent+1]),0.1,0.6,0,15); if ( icent == 3) drawText("(a)",0.275,0.8,1); if ( icent == 2) drawText("(b)",0.05,0.8,1); if ( icent == 1) drawText("(c)",0.05,0.8,1); if ( icent == 0) drawText("(d)",0.05,0.8,1); double bottomY = 0.0009; double pi = TMath::Pi(); drawPatch(-0.5,bottomY/100,pi+0.5,bottomY); bottomY = 0.0005; drawText("0",0.05,bottomY,0,18,false); drawText("#frac{1}{3}#pi",pi/3-0.05,bottomY,0,18,0); drawText("#frac{2}{3}#pi",2*pi/3-0.05,bottomY,0,18,0); if ( icent==0) drawText("#pi",pi-0.1,bottomY,0,18,0); drawText("#Delta#phi_{J#gamma}",pi/2.-0.1,bottomY-0.0002,0,18,0); } gPad->RedrawAxis(); c1dphi->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_dPhi_dist.pdf"); //c1dphi->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_dPhi_dist.png"); //c1dphi->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_dPhi_dist.gif"); //c1dphi->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_dPhi_dist.C"); ////////////////////////////// summary plots TCanvas *c2 = new TCanvas("c2","",350,350); TH1D* hTemp2 = new TH1D("htemp2",";N_{part};<x_{J#gamma}>",100,-20,400); hTemp2->SetNdivisions(505); handsomeTH1(hTemp2,1); handsomeTGraph(mxhidata,2); mxhidata->SetMarkerStyle(20); handsomeTGraph(mxhimc,1); mxhimc->SetMarkerStyle(24); // handsomeTGraph(mxppdata,1); // mxppdata->SetMarkerStyle(21); handsomeTGraph(mxppmc,1); mxppmc->SetMarkerStyle(25); hTemp2->SetAxisRange(0.6,1.1,"Y"); hTemp2->DrawCopy(); // TH1D* hMXpp2013_2 = new TH1D("hmxpp2013_2","",1,-10,370); // hMXpp2013_2->SetBinContent(1,hMXpp2013->GetBinContent(1)); // if ( !mcOnly ) drawSys(hMXpp2013_2,sysMxpp,kGreen,3001); if ( !mcOnly ) drawSys(mxhidata,sysMx,10); // mxppmc->Draw("p"); // if ( !mcOnly ) mxppdata->Draw("p"); if ( !mcOnly ) { hMXpp2013[5]->SetMarkerStyle(20); for ( int icent = 1 ; icent<=5 ; icent++) { drawSys(hMXpp2013[icent],ppSysMx,kGreen,3001); hMXpp2013[icent]->DrawCopy("p same"); } } if(drawMC) mxhimc->Draw("p same"); if ( !mcOnly ) mxhidata->Draw("p same"); hMXpp2013[5]->SetFillStyle(3001); hMXpp2013[5]->SetFillColor(kGreen); hMXpp2013[5]->SetLineColor(0); hDphiPP2013[2]->SetFillStyle(3001); hDphiPP2013[2]->SetFillColor(kGreen); hDphiPP2013[2]->SetLineColor(0); TH1D *dummyHist = new TH1D("dummyHist","",10,0,1); dummyHist->SetFillStyle(1001); dummyHist->SetMarkerColor(kRed); dummyHist->SetFillColor(90); dummyHist->SetLineColor(0); //// sys bar by energy scale /* TBox *b1 = new TBox(400-20,0.85 - corrSysMx ,400, 0.85 + corrSysMx); b1->SetFillColor(1); b1->SetFillStyle(1001); if ( !mcOnly ) b1->Draw(); TBox *b2 = new TBox(400-20+3,0.85 - corrSysMx+ 0.002 ,400-3, 0.85 + corrSysMx- 0.002); b2->SetFillColor(0); b2->SetFillStyle(1001); if ( !mcOnly ) b2->Draw(); */ // drawText("Common uncertainty due to jet ",0.35,0.25,0,15); // drawText("energy scale & photon purity",0.35,0.2,0,15); // drawText("#sqrt{s_{NN}}=2.76 TeV ",0.5,0.85,0,15); // drawText("#int L dt = 150 #mub^{-1}",0.5,0.72,0,15); // drawText("(a)",0.22,0.87,1); drawText("#Delta#phi_{J#gamma} > #frac{7}{8}#pi",0.7,0.75,0); drawCMSppPbPb(0.1,0.95,12); // drawText("#Delta#phi_{J#gamma} > #frac{7}{8}#pi",0.5,0.38,0); // drawText("CMS",0.78,0.88,1); TLegend *leg4 = new TLegend(0.1630303,0.6054839,0.7590909,0.8931183,NULL,"brNDC"); easyLeg(leg4,""); // if ( !mcOnly ) leg4->AddEntry(mxppdata,"pp Data 231nb^{-1}","p"); if ( !mcOnly ) leg4->AddEntry(dummyHist,"PbPb Data","fp"); if ( !mcOnly ) leg4->AddEntry(hMXpp2013[5],"pp Data","fp"); if ( !mcOnly ) leg4->AddEntry(hDphiPP2013[2],"Smeared pp reference","fp"); if(drawMC) leg4->AddEntry(mxhimc,"PYTHIA + HYDJET","p"); // leg4->AddEntry(mxppmc,"PYTHIA","p"); // leg4->AddEntry(hSysTemp,"Sys. Uncertainty","f"); leg4->Draw(); gPad->RedrawAxis(); c2->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_xjg_npart.pdf"); //c2->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_xjg_npart.png"); //c2->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_xjg_npart.gif"); //c2->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_xjg_npart.C"); ////////////////////////////// rx TCanvas *c3 = new TCanvas("c3","",350,350); TH1D* hTemp3 = new TH1D("htemp2",";N_{part};R_{J#gamma}",100,-20,400); hTemp3->SetNdivisions(505); handsomeTH1(hTemp3,1); handsomeTGraph(rxhidata,2); rxhidata->SetMarkerStyle(20); handsomeTGraph(rxhimc,1); rxhimc->SetMarkerStyle(24); handsomeTGraph(rxppdata,1); rxppdata->SetMarkerStyle(21); handsomeTGraph(rxppmc,1); rxppmc->SetMarkerStyle(25); hTemp3->SetAxisRange(0.41,1.,"Y"); hTemp3->Draw(); // Ratio // DivideTG(rxppdata,rxppmc); // DivideTG(rxhidata,rxhimc); ////////////////////////////////////////////// // TH1D* hdphi2013_2 = new TH1D("hdphi2013_2","",1,-10,370); // hdphi2013_2->SetBinContent(1,hRpp2013->GetBinContent(1)); // if ( !mcOnly ) drawSys(hdphi2013_2,sysRpp,kGreen,3001); if ( !mcOnly ) drawSys(rxhidata,sysR,10); // if ( !mcOnly ) drawSys(rxppdata,sysRpp,10); // jumSun(-10,1,400,1); if(drawMC) rxhimc->Draw("p"); // rxppmc->Draw("p"); // if ( !mcOnly ) rxppdata->Draw("p"); if ( !mcOnly ) { hRpp2013[5]->SetMarkerStyle(20); for ( int icent =1 ; icent<=5 ; icent++) { drawSys(hRpp2013[icent],ppSysR,kGreen,3001); hRpp2013[icent]->Draw("same"); } } if ( !mcOnly ) rxhidata->Draw("p same"); // drawText(Form("p^{#gamma}_{T} > %d GeV/c",etPho),0.6,0.75,0,15); // drawText(Form("p^{Jet}_{T} > %d GeV/c",etJet),0.6,0.67,0,15); // drawText("CMS",0.78,0.88,1); // drawText("(b)",0.22,0.87,1); drawText("#Delta#phi_{J#gamma} > #frac{7}{8}#pi",0.7,0.75,0); drawCMSppPbPb(0.1,0.95,12); leg4->Draw(); gPad->RedrawAxis(); c3->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_r_npart.pdf"); //c3->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_r_npart.png"); //c3->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_r_npart.gif"); //c3->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_r_npart.C"); TCanvas *c4 = new TCanvas("c4","",350,350); TH1D* hTemp4 = new TH1D("htemp2",";N_{part};#sigma(#Delta#phi_{J#gamma})",100,-20,400); hTemp4->SetNdivisions(505); handsomeTH1(hTemp4,1); handsomeTGraph(dphihidata,2); dphihidata->SetMarkerStyle(20); handsomeTGraph(dphihimc,1); dphihimc->SetMarkerStyle(24); handsomeTGraph(dphippdata,1); dphippdata->SetMarkerStyle(21); handsomeTGraph(dphippmc,1); dphippmc->SetMarkerStyle(25); hTemp4->SetAxisRange(0,.5,"Y"); hTemp4->Draw(); // TH1D* h2013_3 = new TH1D("hdphi2013_3","",1,-10,370); // h2013_3->SetBinContent(1,hDphiPP2013->GetBinContent(1)); // if ( !mcOnly ) drawSys(h2013_3,sysDphipp,kGreen,3001); if ( !mcOnly ) drawSys(dphihidata,sysDphi,10); if(drawMC) dphihimc->Draw("p same"); // dphippmc->Draw("p"); // if ( !mcOnly ) dphippdata->Draw("p"); for ( int icent=1 ; icent<=5 ; icent++){ drawSys(hDphiPP2013[icent], hDphiPPUnc, kGreen,3001); } TH1D* hDphiPP2013Temp = new TH1D("hDphiPP2013Temp","",1,380,400); hDphiPP2013Temp->SetBinContent(1,0.27); hDphiPP2013[5]->SetMarkerStyle(20); for ( int icent=1 ; icent<=5 ; icent++){ hDphiPP2013[icent]->Draw("same"); } if ( !mcOnly ) dphihidata->Draw("p"); // TLegend *legDphi = new TLegend(0.32,0.18,0.93,0.7,NULL,"brNDC"); // easyLeg(legDphi,""); // legDphi->SetTextSize(17); // // drawText("|#Delta#phi_{J#gamma}| > #frac{2}{3}#pi",0.5,0.38,0); // // drawText("Fit : #frac{e^{#frac{|#Delta#phi_{J#gamma}|-#pi}{#sigma}}}{#sigma(1-e^{-#pi/#sigma})}",0.5,0.23,0); // legDphi->Draw(); // // drawText("(a)",0.22,0.87,1); // // drawText("CMS",0.78,0.88,1); TH1D* hSysTemp = new TH1D("hSystemp","",1,0,1); hSysTemp->SetFillColor(newYellow); hSysTemp->SetLineColor(newYellow); leg4->Draw(); drawText(Form("p^{#gamma}_{T} > %d GeV/c |#eta^{#gamma}| < 1.44",etPho),0.25,0.3,0,15); drawText(Form("p^{Jet}_{T} > %d GeV/c |#eta^{Jet}| < 1.6",etJet),0.25,0.2,0,15); drawCMSppPbPb(0.1,0.95,12); gPad->RedrawAxis(); c4->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_dphi_npart.pdf"); //c4->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_dphi_npart.png"); //c4->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_dphi_npart.gif"); //c4->SaveAs("plotPPPbPb/inclusivePt_ppPbPb_dphi_npart.C"); // // print numbers // std::cout << " Summary of Points for PbPb " << std::endl; // PrintGraphAndSys(dphihidata,sysDphi); // PrintGraphAndSys(mxhidata,sysMx); // PrintGraphAndSys(rxhidata,sysR); // std::cout << " Summary of Points for PYTHIA + HYDJET " << std::endl; // PrintGraph(dphihimc); // PrintGraph(mxhimc); // PrintGraph(rxhimc); // std::cout << " Summary of Points for pp " << std::endl; // PrintGraphAndSys(dphippdata[5],sysDphipp); // PrintGraphAndSys(mxppdata[5],sysMxpp); // PrintGraphAndSys(rxppdata[5],sysRpp); /* TCanvas *c5 = new TCanvas("c5","",500,500); hxgj[khidata][0]->SetAxisRange(-.2,2.5,"Y"); hxgj[khidata][0]->SetNdivisions(505); fixedFontHist(hxgj[khidata][0],1,1.35); handsomeTH1(hxgj[khidata][0],2); hxgj[khidata][0]->GetYaxis()->SetTitleOffset(1.5); hxgj[khidata][0]->DrawCopy(""); handsomeTH1(hxgj[kppdata13][5],4); hxgj[kppdata13][5]->Draw("same hist"); onSun(0,0,2,0); */ }