{ // Master options for plots //-------------------------- gROOT->LoadMacro("AtlasUtils.C"); gStyle->SetHatchesSpacing(2.2); gStyle->SetHatchesLineWidth(2); TColor *c1000 = new TColor(1000,0.,0.,0,"c1000",0.0); // Controls //---------- bool signal = 0; // Getting signal and background data from ntuples //------------------------------------------------- TString data = "signal"; if(!signal) data = "background"; TChain *tree_nopileup = new TChain("TauSubstruct"); tree_nopileup.Add("../../data/" + data + "NP.root"); TChain *tree_pileup = new TChain("TauSubstruct"); tree_pileup.Add("../../data/" + data + "P.root"); // Definition of the histogram settings vectors //---------------------------------------------- std::vector label; std::vector name; std::vector leg; std::vector bins; std::vector low; std::vector high; int realbin = 60; // Setting the variables to look at, with their corresponding histogram settings //------------------------------------------------------------------------------- // Cell-based variables: // label.push_back("R_{EM}"); // name.push_back("EMRadius"); // leg.push_back(1); // bins.push_back(realbin); // low.push_back(0); // high.push_back(0.3); // label.push_back("R_{Had}"); // name.push_back("hadRadius"); // leg.push_back(1); // bins.push_back(realbin); // low.push_back(0); // high.push_back(0.3); // label.push_back("f_{ring}"); // name.push_back("isolFrac"); // leg.push_back(1); // bins.push_back(realbin); // low.push_back(0); // high.push_back(1); // label.push_back("f_{core}"); // name.push_back("centFrac"); // leg.push_back(0); // bins.push_back(realbin); // low.push_back(0); // high.push_back(1); // label.push_back("W_{strip}"); // name.push_back("stripwidth2"); // leg.push_back(1); // bins.push_back(realbin); // low.push_back(0); // high.push_back(0.03); // label.push_back("N_{strip}"); // name.push_back("nStrip"); // leg.push_back(1); // bins.push_back(30); // low.push_back(0); // high.push_back(30); // Cluster-based variables label.push_back("N_{all}"); name.push_back("Nconstituents"); leg.push_back(1); bins.push_back(30); low.push_back(0); high.push_back(30); label.push_back("N_{eff}"); name.push_back("EffNConst"); leg.push_back(1); bins.push_back(realbin); low.push_back(0); high.push_back(15); label.push_back("m_{all}"); name.push_back("mass"); leg.push_back(1); bins.push_back(realbin); low.push_back(0.001); high.push_back(16.001); label.push_back("m_{eff}"); name.push_back("Effmass"); leg.push_back(1); bins.push_back(realbin); low.push_back(0.001); high.push_back(12.001); label.push_back("#LT R #GT_{all}"); name.push_back("AvgRadius"); leg.push_back(0); bins.push_back(realbin); low.push_back(0.001); high.push_back(0.301); label.push_back("#LT R #GT_{eff}"); name.push_back("AvgEffRadius"); leg.push_back(1); bins.push_back(realbin); low.push_back(0.001); high.push_back(0.331); // label.push_back("N_{all}^{truth}"); // name.push_back("truthNconstituents"); // leg.push_back(1); // bins.push_back(30); // low.push_back(0); // high.push_back(30); // label.push_back("N_{eff}^{truth}"); // name.push_back("truthEffNConst"); // leg.push_back(1); // bins.push_back(realbin); // low.push_back(0); // high.push_back(15); // label.push_back("m_{all}^{truth}"); // name.push_back("truthmass"); // leg.push_back(1); // bins.push_back(realbin); // low.push_back(0.001); // high.push_back(16.001); // label.push_back("m_{eff}^{truth}"); // name.push_back("truthEffmass"); // leg.push_back(1); // bins.push_back(realbin); // low.push_back(0.001); // high.push_back(12.001); // label.push_back("#LT R #GT_{all}^{truth}"); // name.push_back("truthAvgRadius"); // leg.push_back(1); // bins.push_back(realbin); // low.push_back(0.001); // high.push_back(0.301); // label.push_back("#LT R #GT_{eff}^{truth}"); // name.push_back("truthAvgEffRadius"); // leg.push_back(1); // bins.push_back(realbin); // low.push_back(0.001); // high.push_back(0.331); // label.push_back("N_{all}^{truthjet}"); // name.push_back("truthjetNconstituents"); // leg.push_back(1); // bins.push_back(30); // low.push_back(0); // high.push_back(30); // label.push_back("N_{eff}^{truthjet}"); // name.push_back("truthjetEffNConst"); // leg.push_back(1); // bins.push_back(realbin); // low.push_back(0); // high.push_back(15); // label.push_back("m_{all}^{truthjet}"); // name.push_back("truthjetmass"); // leg.push_back(1); // bins.push_back(realbin); // low.push_back(0.001); // high.push_back(16.001); // label.push_back("m_{eff}^{truthjet}"); // name.push_back("truthjetEffmass"); // leg.push_back(1); // bins.push_back(realbin); // low.push_back(0.001); // high.push_back(12.001); // label.push_back("#LT R #GT_{all}^{truthjet}"); // name.push_back("truthjetAvgRadius"); // leg.push_back(1); // bins.push_back(realbin); // low.push_back(0.001); // high.push_back(0.301); // label.push_back("#LT R #GT_{eff}^{truthjet}"); // name.push_back("truthjetAvgEffRadius"); // leg.push_back(1); // bins.push_back(realbin); // low.push_back(0.001); // high.push_back(0.331); // // Cluster moment variables // label.push_back("N_{cells}"); // name.push_back("ncells"); // leg.push_back(1); // bins.push_back(realbin); // low.push_back(0); // high.push_back(2500); // label.push_back("f_{EM}"); // name.push_back("avgeffemfraction"); // leg.push_back(0); // bins.push_back(realbin); // low.push_back(0); // high.push_back(1); // label.push_back("#LT r^{2} #GT"); // name.push_back("avgeffwidth"); // leg.push_back(1); // bins.push_back(realbin); // low.push_back(0); // high.push_back(120000); // label.push_back("I"); // name.push_back("avgeffisolation"); // leg.push_back(1); // bins.push_back(realbin); // low.push_back(0); // high.push_back(1); // label.push_back("E_{T} resolution"); // name.push_back("recoET-truthET"); // leg.push_back(0); // bins.push_back(realbin); // low.push_back(-40); // high.push_back(10); int nvars = (int)label.size(); // Looping over the bins, signal/background and prongs //----------------------------------------------------- std::vector tau_nature; if(signal) { tau_nature.push_back("nopileup1p"); tau_nature.push_back("nopileup3p"); tau_nature.push_back("pileup1p"); tau_nature.push_back("pileup3p"); } else { tau_nature.push_back("nopileup"); tau_nature.push_back("pileup"); } int nature_entries = (int)tau_nature.size(); for(int var_idx = 0; var_idx < nvars; var_idx++) { for(int nature_idx = 0; nature_idx < nature_entries; nature_idx++) { // Making up the histograms names //-------------------------------- TString hname; hname += name[var_idx]; hname += "_"; hname += tau_nature[nature_idx]; // Making up the histogram titles //-------------------------------- TString htitle; htitle += label[var_idx]; // Creating the histograms //------------------------- TH1F* histogram = new TH1F(hname, htitle, bins[var_idx] , low[var_idx], high[var_idx]); // Projecting the histograms //--------------------------- if(signal) { if(nature_idx == 0) tree_nopileup->Project(hname, name[var_idx],"(!(recoeta<-2.5))&&(!(recoeta>2.5))&&(recoET<80)&&(recoET>10)&&(truthNProng<=1)"); if(nature_idx == 1) tree_nopileup->Project(hname, name[var_idx],"(!(recoeta<-2.5))&&(!(recoeta>2.5))&&(recoET<80)&&(recoET>10)&&(truthNProng>=2)"); if(nature_idx == 2) tree_pileup->Project(hname, name[var_idx], "(!(recoeta<-2.5))&&(!(recoeta>2.5))&&(recoET<80)&&(recoET>10)&&(truthNProng<=1)"); if(nature_idx == 3) tree_pileup->Project(hname, name[var_idx], "(!(recoeta<-2.5))&&(!(recoeta>2.5))&&(recoET<80)&&(recoET>10)&&(truthNProng>=2)"); } else { if(nature_idx == 0) tree_nopileup->Project(hname, name[var_idx],"(!(recoeta<-2.5))&&(!(recoeta>2.5))&&(recoET<80)&&(recoET>10)"); if(nature_idx == 1) tree_pileup->Project(hname, name[var_idx],"(!(recoeta<-2.5))&&(!(recoeta>2.5))&&(recoET<80)&&(recoET>10)"); } } // Drawing the comparison histograms //----------------------------------- // Retrieving the histogram names TString hname_base; TString hname_nopileup1p; TString hname_nopileup3p; TString hname_pileup1p; TString hname_pileup3p; hname_base += name[var_idx]; hname_base += "_"; if(signal) { hname_nopileup1p = hname_base + tau_nature[0]; hname_nopileup3p = hname_base + tau_nature[1]; hname_pileup1p = hname_base + tau_nature[2]; hname_pileup3p = hname_base + tau_nature[3]; } else { hname_nopileup3p = hname_base + tau_nature[0]; hname_pileup3p = hname_base + tau_nature[1]; } TH1F* histo_nopileup1p = 0; TH1F* histo_nopileup3p = 0; TH1F* histo_pileup1p = 0; TH1F* histo_pileup3p = 0; histo_nopileup3p = (TH1F*)gROOT->FindObject(hname_nopileup3p); histo_pileup3p = (TH1F*)gROOT->FindObject(hname_pileup3p); if(signal) { histo_nopileup1p = (TH1F*)gROOT->FindObject(hname_nopileup1p); histo_pileup1p = (TH1F*)gROOT->FindObject(hname_pileup1p); } // Normalize histograms, get mean shifts if(signal) { float entriesNP1p = histo_nopileup1p->GetEntries(); float entriesNP3p = histo_nopileup3p->GetEntries(); float entriesNP = entriesNP1p + entriesNP3p; float entriesP1p = histo_pileup1p->GetEntries(); float entriesP3p = histo_pileup3p->GetEntries(); float entriesP = entriesP1p + entriesP3p; histo_nopileup1p->Scale(1/entriesNP); histo_nopileup3p->Scale(1/entriesNP); histo_pileup1p->Scale(1/entriesP); histo_pileup3p->Scale(1/entriesP); float meanNP1p = histo_nopileup1p->GetMean(); float meanNP3p = histo_nopileup3p->GetMean(); float meanP1p = histo_pileup1p->GetMean(); float meanP3p = histo_pileup3p->GetMean(); float meanshift1p = (meanP1p - meanNP1p)/(meanNP1p); float meanshift3p = (meanP3p - meanNP3p)/(meanNP3p); std::cout << "Mean shift 1p: " << meanshift1p << std::endl; std::cout << "Mean shift 3p: " << meanshift3p << std::endl; } else { float entriesNPB = histo_nopileup3p->GetEntries(); float entriesPB = histo_pileup3p->GetEntries(); histo_nopileup3p->Scale(1/entriesNPB); histo_pileup3p->Scale(1/entriesPB); float meanNPB = histo_nopileup3p->GetMean(); float meanPB = histo_pileup3p->GetMean(); float meanshiftB = (meanPB - meanNPB)/(meanNPB); std::cout << "Mean shift B: " << meanshiftB << std::endl; } // Histogram settings if(signal) { Color_t colorNP3p = TColor::GetColor("#e60000"); Color_t colorNP1p = TColor::GetColor("#ee7700"); Color_t colorP3p = TColor::GetColor("#006600"); Color_t colorP1p = TColor::GetColor("#0033cc"); histo_nopileup1p->SetLineColor(colorNP1p); histo_nopileup1p->SetFillStyle(3254); histo_nopileup1p->SetFillColor(colorNP1p); histo_nopileup1p->SetLineWidth(4); histo_nopileup3p->SetLineColor(colorNP3p); histo_nopileup3p->SetFillStyle(3154); histo_nopileup3p->SetFillColor(colorNP3p); histo_nopileup3p->SetLineWidth(4); histo_pileup1p->SetLineColor(colorP1p); histo_pileup1p->SetFillStyle(3245); histo_pileup1p->SetFillColor(colorP1p); histo_pileup1p->SetLineWidth(2); histo_pileup3p->SetLineColor(colorP3p); histo_pileup3p->SetFillStyle(3145); histo_pileup3p->SetFillColor(colorP3p); histo_pileup3p->SetLineWidth(2); } else { Color_t colorNPB = TColor::GetColor("#0000ff"); Color_t colorPB = TColor::GetColor("#e60077"); histo_nopileup3p->SetLineColor(colorNPB); histo_nopileup3p->SetFillStyle(3254); histo_nopileup3p->SetFillColor(colorNPB); histo_nopileup3p->SetLineWidth(4); histo_pileup3p->SetLineColor(colorPB); histo_pileup3p->SetFillStyle(3245); histo_pileup3p->SetFillColor(colorPB); histo_pileup3p->SetLineWidth(2); } THStack* hstack_nopileup = new THStack("hstacksignal", ""); THStack* hstack_pileup = new THStack("hstackpileup", ""); if(signal) { hstack_nopileup->Add(histo_nopileup3p); hstack_nopileup->Add(histo_nopileup1p); hstack_pileup->Add(histo_pileup3p); hstack_pileup->Add(histo_pileup1p); } else { hstack_nopileup->Add(histo_nopileup3p); hstack_pileup->Add(histo_pileup3p); } //Legend position Double_t x1 = 0.61; Double_t y1 = 0.80; Double_t y2 = 0.92; if(signal) { y1 = 0.68; } if(leg[var_idx] == 0) x1 = 0.19; if(leg[var_idx] == 2) x1 = 0.34; Double_t x2 = x1 + 0.25; // The legends TLegend *legend = new TLegend(x1, y1, x2, y2, NULL, "brNDC"); Color_t ci = TColor::GetColor("#ffffff"); legend->SetFillColor(ci); if(signal) { legend->AddEntry(histo_nopileup1p, "no pileup, 1p", "f"); legend->AddEntry(histo_nopileup3p, "no pileup, 3p", "f"); legend->AddEntry(histo_pileup1p, "pileup, 1p", "f"); legend->AddEntry(histo_pileup3p, "pileup, 3p", "f"); } else { legend->AddEntry(histo_nopileup3p, "no pileup", "f"); legend->AddEntry(histo_pileup3p, "pileup", "f"); } // The master canvas TCanvas *c1 = new TCanvas("c1", "c1", 50,50,800,600); // Setting axis titles hstack_nopileup->Draw(); c1->Update(); hstack_nopileup->GetXaxis()->SetTitle(label[var_idx]); hstack_nopileup->GetXaxis()->SetTitleFont(62); hstack_nopileup->GetYaxis()->SetTitle("normalized"); hstack_nopileup->GetYaxis()->SetTitleFont(62); hstack_pileup->Draw(); c1->Update(); hstack_pileup->GetXaxis()->SetTitle(label[var_idx]); hstack_pileup->GetXaxis()->SetTitleFont(62); hstack_pileup->GetYaxis()->SetTitle("normalized"); hstack_pileup->GetYaxis()->SetTitleFont(62); // Drawing the histograms float nopileup_max = hstack_nopileup->GetMaximum(); float pileup_max = hstack_pileup->GetMaximum(); float yaxismax = max(pileup_max, nopileup_max); hstack_nopileup->SetMaximum(yaxismax); hstack_pileup->SetMaximum(yaxismax); hstack_pileup->GetXaxis()->SetNdivisions(506); hstack_nopileup->GetXaxis()->SetNdivisions(506); hstack_pileup->Draw(); hstack_nopileup->Draw("SAME"); legend->Draw("SAME"); myText( x1+0.01, y1-0.05, 1,"7 TeV Simulation"); if(signal) myText( x1+0.01, y1-0.1, 1,"Signal"); else myText( x1+0.01, y1-0.11, 1,"Background"); TString outputstring = "background"; if(signal) outputstring = "signal"; c1->Update(); c1->SetFrameFillColor(0); c1->SetFrameFillStyle(4000); c1->Print(name[var_idx] + "7TeVIntegratedPvsNP" + outputstring + ".pdf"); c1->Print(name[var_idx] + "7TeVIntegratedPvsNP" + outputstring + ".eps"); delete c1; } }