#include "TLorentzVector.h" #include void oneDHist_(){ TH1F *h1 = new TH1F("h1", "" ,100,0,1000); TH1F *h2 = new TH1F("h2", "" ,100,0,1000); // TH1F *h3 = new TH1F("h3", "" ,100,0,1000); TFile *f1 = new TFile("/eos/user/s/sverma/www/WWTo2L2Nu_hadd_2.root "); TFile *f2 = new TFile("/afs/cern.ch/work/s/sverma/Framework/CMSSW_10_6_4/src/PhysicsTools/NanoAODTools/scripts/VBF_hadd_500.root"); // TFile *f3 = new TFile("Cl1loose2018v7__MCCorr2018v7__l2loose__l2tightOR2018v7__AddLHE_MEs/nanoLatino_VBFHToWWTo2L2Nu_M500__part2.root"); TTree *t1 = (TTree*)f1->Get("Events"); TTree *t2 = (TTree*)f2->Get("Events"); // TTree *t3 = (TTree*)f3->Get("Events"); const int nParticlesMax = 1000; Float_t NeutrinoGen_pt[nParticlesMax], NeutrinoGen_eta[nParticlesMax],NeutrinoGen_phi[nParticlesMax]; UInt_t nNeutrinoGen; Float_t p_Gen_GG_SIG_kappaTopBot_1_ghz1_1_MCFM; Float_t p_Gen_CPStoBWPropRewgt; Float_t weight; TLorentzVector N1(0.,0.,0.,0.); TLorentzVector N2(0.,0.,0.,0.); TLorentzVector NN(0.,0.,0.,0.); Float_t mass_nn; t1->SetBranchAddress("NeutrinoGen_pt", &NeutrinoGen_pt); t1->SetBranchAddress("NeutrinoGen_eta", &NeutrinoGen_eta); t1->SetBranchAddress("NeutrinoGen_phi", &NeutrinoGen_phi); t1->SetBranchAddress("nNeutrinoGen", &nNeutrinoGen); // unsigned nNeu(*nNeutrinoGen->Get()); // unsigned nLep(*nLeptonGen->Get()); // TTree->Print(); // t1->Print(); // t1->Scan(); t2->SetBranchAddress("NeutrinoGen_pt", &NeutrinoGen_pt); t2->SetBranchAddress("NeutrinoGen_eta", &NeutrinoGen_eta); t2->SetBranchAddress("NeutrinoGen_phi", &NeutrinoGen_phi); t2->SetBranchAddress("nNeutrinoGen", &nNeutrinoGen); // t3->SetBranchAddress("NeutrinoGen_pt", &NeutrinoGen_pt); // t3->SetBranchAddress("NeutrinoGen_eta", &NeutrinoGen_eta); // t3->SetBranchAddress("NeutrinoGen_phi", &NeutrinoGen_phi); // t3->SetBranchAddress("nNeutrinoGen", &nNeutrinoGen); t1->Print(); ///1 Int_t n1entries = (Int_t)t1->GetEntries(); for (Int_t i=0; iGetEntry(i); if (nNeutrinoGen>1) { N1.SetPtEtaPhiM(NeutrinoGen_pt[0],NeutrinoGen_eta[0], NeutrinoGen_phi[0],0.); N2.SetPtEtaPhiM(NeutrinoGen_pt[1],NeutrinoGen_eta[1],NeutrinoGen_phi[1],0.); //cout << N1[0] << endl; NN = N1 +N2; mass_nn = NN.M(); //cout << NN[0] <Fill(mass_nn,weight); } //////////////////////////////2 Int_t n2entries = (Int_t)t2->GetEntries(); for (Int_t i=0; iGetEntry(i); if (nNeutrinoGen>1) { N1.SetPtEtaPhiM(NeutrinoGen_pt[0],NeutrinoGen_eta[0], NeutrinoGen_phi[0],0.); N2.SetPtEtaPhiM(NeutrinoGen_pt[1],NeutrinoGen_eta[1],NeutrinoGen_phi[1],0.); //cout << N1[0] << endl; NN = N1 +N2; mass_nn = NN.M(); //cout << NN[0] <Fill(mass_nn,weight ); } ////////////////////////////////////////////////3 /* Int_t n3entries = (Int_t)t3->GetEntries(); for (Int_t i=0; iGetEntry(i); if (nNeutrinoGen>1) { N1.SetPtEtaPhiM(NeutrinoGen_pt[0],NeutrinoGen_eta[0], NeutrinoGen_phi[0],0.); N2.SetPtEtaPhiM(NeutrinoGen_pt[1],NeutrinoGen_eta[1],NeutrinoGen_phi[1],0.); //cout << N1[0] << endl; NN = N1 +N2; mass_nn = NN.M(); //cout << NN[0] <Fill(mass_nn); } */ //cout << "Trans mass of X"<< Mt_X<SetTitleSize(0.05,"X"); h1->SetTitleSize(0.05,"Y"); h1->SetXTitle("genvv_mass"); h1->SetYTitle("Events"); h1->SetLineColor(kRed); TCanvas *c1 = new TCanvas("c1", "Transverse mass of X", 1000, 1000); TPad *gpad = new TPad("gpad", "",0., 0.,1,1); gpad->Draw(); gpad->cd(); h1->DrawNormalized(); h2->SetLineColor(kBlue); h2->DrawNormalized("same"); //h3->SetLineColor(kOrange); //h3->DrawNormalized("same"); //h3->SetLineColor(kGreen); //h3->DrawNormalized("same"); gpad->Modified(); /////////// Do clear the TLegend Options........... TLegend *pl = new TLegend(0.3,0.4,0.3,0.4); //// For time being I have filled this Options bracket like this. pl->SetTextSize(0.04); pl->SetFillColor(kYellow); TLegendEntry *pl1 = pl->AddEntry(h1, "WW","l"); TLegendEntry *pl2 = pl->AddEntry(h2, "h500","l"); //TLegendEntry *pl3 = pl->AddEntry(h2, "h500","l"); //TLegendEntry *pl4 = pl->AddEntry(h3, "Signal","l"); pl1->SetMarkerSize(2.0); pl1->SetMarkerColor(kRed); pl2->SetMarkerSize(2.0); pl2->SetMarkerColor(kBlue); //pl3->SetMarkerSize(2.0); //pl3->SetMarkerColor(kOrange); //pl4->SetMarkerSize(2.0); //pl4->SetMarkerColor(kGreen); pl->Draw(); c1->SaveAs("genvv_mass.png"); }