void calbet4(){ vector v_file{"road60"}; vector v_var{"innerClosePrecHits", "middleClosePrecHits", "outerClosePrecHits", "extendedClosePrecHits"}; vector v_type{"non_iso", "hadron", "other", "prompt"}; vector v_pt{"3-5", "5-10", "10-20", "gt20"}; vector v_eta{"barrel", "endcap"}; vector v_color{kBlack, kBlue, kGreen, kRed}; // hist const int n_file = v_file.size(); const int n_var = v_var .size(); const int n_type = v_type.size(); const int n_pt = v_pt .size(); const int n_eta = v_eta .size(); TH1D *hist[n_file][n_type][n_pt][n_var]; string name; for (int file=0; fileGet("IDTracksTree"); tree->SetBranchAddress("innerClosePrecHits" , &innerClosePrecHits); tree->SetBranchAddress("middleClosePrecHits" , &middleClosePrecHits); tree->SetBranchAddress("outerClosePrecHits" , &outerClosePrecHits); tree->SetBranchAddress("extendedClosePrecHits", &extendedClosePrecHits); tree->SetBranchAddress("TruthType" , &TruthType); tree->SetBranchAddress("pt" , &pt); int entries = tree->GetEntries(); cout<<"entries: "<GetEntry(i); bool is_prompt {0}; bool is_non_iso{0}; bool is_hadron {0}; bool is_other {0}; bool pt_3_5 {0}; bool pt_5_10 {0}; bool pt_10_20 {0}; bool pt_gt20 {0}; if (TruthType==6) is_prompt = true; else if (TruthType==7) is_non_iso = true; else if (TruthType==8 || TruthType==17) is_hadron = true; else is_other = true; if (pt>3 && pt<=5 ) pt_3_5 = true; else if (pt>5 && pt<=10) pt_5_10 = true; else if (pt>10 && pt<=20) pt_10_20 = true; else if (pt>20) pt_gt20 = true; if (is_prompt) { if (pt_3_5) { if (innerClosePrecHits != 0) hist[file][0][0][0]->Fill((double)innerClosePrecHits); if (middleClosePrecHits != 0) hist[file][0][0][1]->Fill((double)middleClosePrecHits); if (outerClosePrecHits != 0) hist[file][0][0][2]->Fill((double)outerClosePrecHits); if (extendedClosePrecHits != 0) hist[file][0][0][3]->Fill((double)extendedClosePrecHits); } if (pt_5_10) { if (innerClosePrecHits != 0) hist[file][0][1][0]->Fill((double)innerClosePrecHits); if (middleClosePrecHits != 0) hist[file][0][1][1]->Fill((double)middleClosePrecHits); if (outerClosePrecHits != 0) hist[file][0][1][2]->Fill((double)outerClosePrecHits); if (extendedClosePrecHits != 0) hist[file][0][1][3]->Fill((double)extendedClosePrecHits); } if (pt_10_20) { if (innerClosePrecHits != 0) hist[file][0][2][0]->Fill((double)innerClosePrecHits); if (middleClosePrecHits != 0) hist[file][0][2][1]->Fill((double)middleClosePrecHits); if (outerClosePrecHits != 0) hist[file][0][2][2]->Fill((double)outerClosePrecHits); if (extendedClosePrecHits != 0) hist[file][0][2][3]->Fill((double)extendedClosePrecHits); } if (pt_gt20) { if (innerClosePrecHits != 0) hist[file][0][3][0]->Fill((double)innerClosePrecHits); if (middleClosePrecHits != 0) hist[file][0][3][1]->Fill((double)middleClosePrecHits); if (outerClosePrecHits != 0) hist[file][0][3][2]->Fill((double)outerClosePrecHits); if (extendedClosePrecHits != 0) hist[file][0][3][3]->Fill((double)extendedClosePrecHits); } } // is_prompt if (is_non_iso) { if (pt_3_5) { if (innerClosePrecHits != 0) hist[file][1][0][0]->Fill((double)innerClosePrecHits); if (middleClosePrecHits != 0) hist[file][1][0][1]->Fill((double)middleClosePrecHits); if (outerClosePrecHits != 0) hist[file][1][0][2]->Fill((double)outerClosePrecHits); if (extendedClosePrecHits != 0) hist[file][1][0][3]->Fill((double)extendedClosePrecHits); } if (pt_5_10) { if (innerClosePrecHits != 0) hist[file][1][1][0]->Fill((double)innerClosePrecHits); if (middleClosePrecHits != 0) hist[file][1][1][1]->Fill((double)middleClosePrecHits); if (outerClosePrecHits != 0) hist[file][1][1][2]->Fill((double)outerClosePrecHits); if (extendedClosePrecHits != 0) hist[file][1][1][3]->Fill((double)extendedClosePrecHits); } if (pt_10_20) { if (innerClosePrecHits != 0) hist[file][1][2][0]->Fill((double)innerClosePrecHits); if (middleClosePrecHits != 0) hist[file][1][2][1]->Fill((double)middleClosePrecHits); if (outerClosePrecHits != 0) hist[file][1][2][2]->Fill((double)outerClosePrecHits); if (extendedClosePrecHits != 0) hist[file][1][2][3]->Fill((double)extendedClosePrecHits); } if (pt_gt20) { if (innerClosePrecHits != 0) hist[file][1][3][0]->Fill((double)innerClosePrecHits); if (middleClosePrecHits != 0) hist[file][1][3][1]->Fill((double)middleClosePrecHits); if (outerClosePrecHits != 0) hist[file][1][3][2]->Fill((double)outerClosePrecHits); if (extendedClosePrecHits != 0) hist[file][1][3][3]->Fill((double)extendedClosePrecHits); } } // is_non_iso } // entries } // files auto C = new TCanvas("C","C",1800,800); C->Divide(4,1); double integral; for (int var=0; var<1; var++) { for (int pt=0; ptClone(); integral = hist_prompt->Integral(); if (integral != 0) hist_prompt->Scale(1/integral); hist_prompt->SetLineWidth(2); hist_prompt->SetLineColor(kRed); TH1D *hist_fake_noniso = (TH1D*)hist[file][1][pt][var]->Clone(); integral = hist_fake_noniso->Integral(); if (integral != 0) hist_fake_noniso->Scale(1/integral); hist_fake_noniso->SetLineWidth(2); hist_fake_noniso->SetLineColor(kBlue); C->cd(1); hist_prompt->Draw("hist text"); C->cd(2); hist_fake_noniso->Draw("hist text"); C->cd(3)->DrawFrame(0.,0.,30.,11.); auto ga = new TGraphAsymmErrors(); ga->Divide(hist_prompt, hist_fake_noniso, "pois"); ga->Draw("l*"); C->cd(4); auto ratio_noniso = new TRatioPlot(hist_prompt, hist_fake_noniso); ratio_noniso -> SetH2DrawOpt("hist"); ratio_noniso -> Draw(); // draw 1st to access primitive!! ratio_noniso -> GetLowerRefGraph() -> SetMinimum(0.); ratio_noniso -> GetLowerRefGraph() -> SetMaximum(1.5); } // pt } // file } // var }