#include "TLegend.h" #include "TH1.h" #include "TString.h" #include "TCanvas.h" #include "TChain.h" #include #include #include void plot(TString mu1_pt,TString pi1_dnn,TString pi2_dnn,TString pi3_dnn,TString variable, TString BsTauTau_tau_matched_ppdgId,int Nbin, float xmin, float xmax, TString outputfile, TString xaxis_title, TString Bs_alpha, TString Is_mu_soft){ //TFile* f1 = new TFile("/eos/user/p/psadangi/Bstotautau/ParkingBPH1/crab_14june_job_bparked_BPH1_2018A_crab_autojob_MINIAOD_CMSSW10218_2018ULMC_priyanka/210614_105532/0004/flatTuple_4050.root"); //TTree *c = (TTree*)f1->Get("ntuplizer/tree"); TChain *c = new TChain("ntuplizer/tree"); //c->Add("/eos/user/p/psadangi/Bstotautau/ParkingBPH1/crab_14june_job_bparked_BPH1_2018A_crab_autojob_MINIAOD_CMSSW10218_2018ULMC_priyanka/210614_105532/0004/flatTuple_4010.root"); c->Add("/afs/cern.ch/work/p/psadangi/public/flatTuple_4050.root"); std::vector *ppdgid = new std::vector(); std::vector *var = new std::vector(); std::vector *dnn1 = new std::vector(); std::vector *dnn2 = new std::vector(); std::vector *dnn3 = new std::vector(); std::vector *mupt = new std::vector(); std::vector *B_alpha = new std::vector(); std::vector *soft_mu = new std::vector(); //std::vector *soft_mu = new std::vector(); std::map *HLT = new std::map(); c->SetBranchAddress(BsTauTau_tau_matched_ppdgId, &ppdgid); c->SetBranchAddress(variable, &var); c->SetBranchAddress(pi1_dnn, &dnn1); c->SetBranchAddress(pi2_dnn, &dnn2); c->SetBranchAddress(pi3_dnn, &dnn3); c->SetBranchAddress(mu1_pt, &mupt); c->SetBranchAddress(Bs_alpha, &B_alpha); c->SetBranchAddress(Is_mu_soft, &soft_mu); //c->SetBranchStatus("HLT_BPH_isFired",0); c->SetBranchAddress("HLT_BPH_isFired",&HLT); TH1F* hist1 = new TH1F(variable,variable, Nbin, xmin,xmax); TH1F* hist2 = new TH1F(variable,variable, Nbin,xmin,xmax); int nevents = (Int_t)c->GetEntries(); float real=0; float fake=0; for(int i = 0; i < nevents; i++){ c->GetEntry(i); for(int j=0; jsize();j++){ if( (*dnn1)[j]>0.5 && (*dnn2)[j]>0.5 && (*dnn3)[j]>0.5 && (*mupt)[0]>9.&& (*soft_mu)[j]==1 ){ if((*ppdgid)[j]==531 ){ hist1->Fill((*var)[j]); real=real+1;} else{ hist2->Fill((*var)[j]); fake=fake+1;} } } for(map::const_iterator it = HLT[i].begin(); it != HLT[i].end(); it++) { cout<first<<"\t"<second<Scale(1./hist1->Integral()); hist1->SetLineColor(kRed); hist1->SetMarkerColor(kRed); hist1->SetMarkerSize(0.8); hist1->SetMarkerStyle(20); hist2->Scale(1./hist2->Integral()); hist2->SetLineColor(kBlue); hist2->SetMarkerColor(kBlue); hist2->SetMarkerSize(0.8); hist2->SetMarkerStyle(20); hist1->GetXaxis()->SetTitle(xaxis_title); hist1->GetYaxis()->SetRangeUser(0, 1.3*hist1->GetMaximum()); TCanvas *c1 = new TCanvas("c1","",5,30,650,600); TLegend *leg = new TLegend(0.767908,0.64135,0.961318,0.729958); leg->AddEntry(hist1,TString::Format("Real= %10.0f",real),"ep"); leg->AddEntry(hist2,TString::Format("Fake= %10.0f",fake),"ep"); hist1->Draw(); hist2->Draw("Same"); leg->Draw(); //TString outfile("NEW_ROOT_FILE/Plots/MC/"+outputfile); //c1->SaveAs(outfile); } void plotsAll() { plot("BsTauTau_mu1_pt","BsTauTau_tau_pi1_dnn","BsTauTau_tau_pi2_dnn","BsTauTau_tau_pi3_dnn" ,"BsTauTau_B_mass","BsTauTau_tau_matched_ppdgId",100,0.,25.,"B_mass.png","Bs_mass","BsTauTau_B_alpha","BsTauTau_mu1_isSoft"); }