From fc04d04f636d5cfe07b50c54c88fed115434a2a2 Mon Sep 17 00:00:00 2001
From: Georgios Krintiras <gkrintir@cern.ch>
Date: Wed, 10 May 2017 19:02:39 +0200
Subject: [PATCH] added more jet related variables to speed up debugging

---
 TopAnalysis/interface/TOP-HIForest.h |  7 +++-
 TopAnalysis/src/TOP-16-023.cc        | 18 ++++++++
 TopAnalysis/src/TOP-pPb.cc           | 62 ++++++++++++++++++++++++----
 3 files changed, 78 insertions(+), 9 deletions(-)

diff --git a/TopAnalysis/interface/TOP-HIForest.h b/TopAnalysis/interface/TOP-HIForest.h
index 441aa34e..010ceece 100644
--- a/TopAnalysis/interface/TOP-HIForest.h
+++ b/TopAnalysis/interface/TOP-HIForest.h
@@ -13,8 +13,11 @@ struct LJEvent_t
   Float_t pt_pt[20],pt_eta[20],pt_phi[20],pt_m[20];
   Int_t gp_pdgid[20];
   Float_t gp_pt[20],gp_eta[20],gp_phi[20],gp_m[20];
-  Float_t j_pt[20],j_eta[20],j_phi[20],j_m[20];
-  Float_t gj_pt[20],gj_eta[20],gj_phi[20],gj_m[20];
+  Float_t j_pt[20],j_eta[20],j_phi[20],j_m[20], j_area[20];
+  Float_t j_PfCHF[20],j_PfNHF[20],j_PfCEF[20],j_PfNEF[20], j_PfMUF[20],j_PfCHM[20];//jet id
+  Int_t j_PfNHM[20], j_PfCEM[20],j_PfNEM[20], j_PfMUM[20]; //jet id
+  Float_t j_refpt[20],j_refarea[20],j_refdr[20], j_refparton_flavorForB[20], j_refparton_flavor[20];
+  Float_t gj_pt[20],gj_eta[20],gj_phi[20],gj_m[20],gj_dr[20],gj_index[20];
   Int_t l_id;
   Float_t l_pt, l_eta, l_phi, l_m;
   Float_t gl_pt, gl_eta, gl_phi, gl_m;
diff --git a/TopAnalysis/src/TOP-16-023.cc b/TopAnalysis/src/TOP-16-023.cc
index 313c744a..71e4e517 100644
--- a/TopAnalysis/src/TOP-16-023.cc
+++ b/TopAnalysis/src/TOP-16-023.cc
@@ -32,6 +32,22 @@ void defineTreeBranches(TTree *outT,LJEvent_t &ljev,bool isMC)
   outT->Branch("j_eta",  ljev.j_eta,  "j_eta[nj]/F");
   outT->Branch("j_phi",  ljev.j_phi,  "j_phi[nj]/F");
   outT->Branch("j_m",    ljev.j_m,    "j_m[nj]/F");
+  outT->Branch("j_PfCHF", ljev.j_PfCHF, "j_PfCHF[nj]/F");
+  outT->Branch("j_PfNHF", ljev.j_PfNHF, "j_PfNHF[nj]/F");
+  outT->Branch("j_PfCEF", ljev.j_PfCEF, "j_PfCEF[nj]/F");
+  outT->Branch("j_PfNEF", ljev.j_PfNEF, "j_PfNEF[nj]/F");
+  outT->Branch("j_PfMUF", ljev.j_PfMUF, "j_PfMUF[nj]/F");
+  outT->Branch("j_PfCHM", ljev.j_PfCHM, "j_PfCHM[nj]/I");
+  outT->Branch("j_PfNHM", ljev.j_PfNHM, "j_PfNHM[nj]/I");
+  outT->Branch("j_PfCEM", ljev.j_PfCEM, "j_PfCEM[nj]/I");
+  outT->Branch("j_PfNEM", ljev.j_PfNEM, "j_PfNEM[nj]/I");
+  outT->Branch("j_PfMUM", ljev.j_PfMUM, "j_PfMUM[nj]/I");
+  outT->Branch("j_area",    ljev.j_area,    "j_area[nj]/F");
+  outT->Branch("j_refpt",   ljev.j_refpt,   "j_refpt[nj]/F");
+  outT->Branch("j_refarea",    ljev.j_refarea,   "j_refarea[nj]/F");
+  outT->Branch("j_refdr",    ljev.j_refdr,    "j_refdr[nj]/F");
+  outT->Branch("j_refparton_flavorForB",    ljev.j_refparton_flavorForB,   "j_refparton_flavorForB[nj]/F");
+  outT->Branch("j_refparton_flavor",    ljev.j_refparton_flavor,    "j_refparton_flavor[nj]/F");
   outT->Branch("l_id",  &ljev.l_id,   "l_id/I");
   outT->Branch("l_pt",  &ljev.l_pt,   "l_pt/F");
   outT->Branch("l_eta", &ljev.l_eta,  "l_eta/F");
@@ -62,6 +78,8 @@ void defineTreeBranches(TTree *outT,LJEvent_t &ljev,bool isMC)
       outT->Branch("gj_eta",  ljev.gj_eta,  "gj_eta[ngj]/F");
       outT->Branch("gj_phi",  ljev.gj_phi,  "gj_phi[ngj]/F");
       outT->Branch("gj_m",    ljev.gj_m,    "gj_m[ngj]/F");
+      outT->Branch("gj_dr",  ljev.gj_dr,  "gj_dr[ngj]/F");
+      outT->Branch("gj_index",    ljev.gj_index,   "gj_index[ngj]/I");
       outT->Branch("gl_pt",  &ljev.gl_pt,   "gl_pt/F");
       outT->Branch("gl_eta", &ljev.gl_eta,  "gl_eta/F");
       outT->Branch("gl_phi", &ljev.gl_phi,  "gl_phi/F");
diff --git a/TopAnalysis/src/TOP-pPb.cc b/TopAnalysis/src/TOP-pPb.cc
index 8a0bd75f..9cfedb2d 100644
--- a/TopAnalysis/src/TOP-pPb.cc
+++ b/TopAnalysis/src/TOP-pPb.cc
@@ -41,7 +41,7 @@ void RunToppPb(TString inFileName,
     }
 
   bool isMC(false);
-  if(inFileName.Contains("/MC") || inFileName.Contains("PYQUEN")) isMC=true;
+  if(inFileName.Contains("/MC") || inFileName.Contains("PYQUEN") || inFileName.Contains("Pyquen")) isMC=true;
   bool isTTJets(false);
   if(inFileName.Contains("/MCTTNominal") || inFileName.Contains("TTBAR")) isTTJets=true;
 
@@ -363,35 +363,67 @@ void RunToppPb(TString inFileName,
     Float_t jtarea[maxJets]; 
     Float_t jtm[maxJets]; 
     Float_t discr_csvV2[maxJets];
-    Float_t refpt[maxJets];
-    Int_t refparton_flavor[maxJets];
+    Float_t refpt[maxJets], refarea[maxJets], refdrjt[maxJets], gendrjt[maxJets];
+    Float_t jPfCHF[maxJets],jPfNHF[maxJets],jPfCEF[maxJets],jPfNEF[maxJets], jPfMUF[maxJets];//jet id
+    Int_t jPfCHM[maxJets],jPfNHM[maxJets], jPfCEM[maxJets],jPfNEM[maxJets], jPfMUM[maxJets]; //jet id
+    Int_t refparton_flavorForB[maxJets], refparton_flavor[maxJets], genmatchindex[maxJets];
     jetTree_p->SetBranchStatus("*", 0);
     jetTree_p->SetBranchStatus("ngen", 1);
     jetTree_p->SetBranchStatus("genpt", 1);
     jetTree_p->SetBranchStatus("genphi", 1);
     jetTree_p->SetBranchStatus("geneta", 1);
+    jetTree_p->SetBranchStatus("gendrjt", 1);
+    jetTree_p->SetBranchStatus("genmatchindex", 1);
     jetTree_p->SetBranchStatus("nref", 1);
     jetTree_p->SetBranchStatus("jtpt", 1);
     jetTree_p->SetBranchStatus("jtphi", 1);
     jetTree_p->SetBranchStatus("jteta", 1);
     jetTree_p->SetBranchStatus("jtarea", 1);
     jetTree_p->SetBranchStatus("jtm", 1);
+    jetTree_p->SetBranchStatus("jtPfCHF", 1);
+    jetTree_p->SetBranchStatus("jtPfNHF", 1);
+    jetTree_p->SetBranchStatus("jtPfCEF", 1);
+    jetTree_p->SetBranchStatus("jtPfNEF", 1);
+    jetTree_p->SetBranchStatus("jtPfMUF", 1);
+    jetTree_p->SetBranchStatus("jtPfCHM", 1);
+    jetTree_p->SetBranchStatus("jtPfNHM", 1);
+    jetTree_p->SetBranchStatus("jtPfCEM", 1);
+    jetTree_p->SetBranchStatus("jtPfNEM", 1);
+    jetTree_p->SetBranchStatus("jtPfMUM", 1);
     jetTree_p->SetBranchStatus("discr_csvV2", 1);
     jetTree_p->SetBranchStatus("refpt", 1);
+    jetTree_p->SetBranchStatus("refarea", 1);
+    jetTree_p->SetBranchStatus("refdrjt", 1);
     jetTree_p->SetBranchStatus("refparton_flavorForB", 1);
+    jetTree_p->SetBranchStatus("refparton_flavor", 1);
     jetTree_p->SetBranchAddress("nref", &nref);
     jetTree_p->SetBranchAddress("jtpt", jtpt);
     jetTree_p->SetBranchAddress("jtphi", jtphi);
     jetTree_p->SetBranchAddress("jteta", jteta);
     jetTree_p->SetBranchAddress("jtarea", jtarea);
     jetTree_p->SetBranchAddress("jtm", jtm);
+    jetTree_p->SetBranchAddress("jtPfCHF", jPfCHF);
+    jetTree_p->SetBranchAddress("jtPfNHF", jPfNHF);
+    jetTree_p->SetBranchAddress("jtPfCEF", jPfCEF);
+    jetTree_p->SetBranchAddress("jtPfNEF", jPfNEF);
+    jetTree_p->SetBranchAddress("jtPfMUF", jPfMUF);
+    jetTree_p->SetBranchAddress("jtPfCHM", jPfCHM);
+    jetTree_p->SetBranchAddress("jtPfNHM", jPfNHM);
+    jetTree_p->SetBranchAddress("jtPfCEM", jPfCEM);
+    jetTree_p->SetBranchAddress("jtPfNEM", jPfNEM);
+    jetTree_p->SetBranchAddress("jtPfMUM", jPfMUM);
     jetTree_p->SetBranchAddress("discr_csvV2", discr_csvV2);
     jetTree_p->SetBranchAddress("refpt", refpt);
-    jetTree_p->SetBranchAddress("refparton_flavorForB", refparton_flavor);
+    jetTree_p->SetBranchAddress("refarea", refarea);
+    jetTree_p->SetBranchAddress("refdrjt", refdrjt);
+    jetTree_p->SetBranchAddress("refparton_flavorForB", refparton_flavorForB);
+    jetTree_p->SetBranchAddress("refparton_flavor", refparton_flavor);
     jetTree_p->SetBranchAddress("ngen", &ngen);
     jetTree_p->SetBranchAddress("genpt", genpt);
     jetTree_p->SetBranchAddress("genphi", genphi);
     jetTree_p->SetBranchAddress("geneta", geneta);
+    jetTree_p->SetBranchAddress("gendrjt", gendrjt);
+    jetTree_p->SetBranchAddress("genmatchindex", genmatchindex);
 
     //jet related variables from the hiFJRho tree
     std::vector<float>* etaMin_hiFJRho_p = 0;
@@ -542,10 +574,8 @@ void RunToppPb(TString inFileName,
 		  {
 		    int status=abs(mcStatus->at(imc));
 		    int abspid=abs(mcPID->at(imc));		
-
 		    TLorentzVector p4;
 		    p4.SetPtEtaPhiM(mcPt->at(imc),mcEta->at(imc),mcPhi->at(imc),mcMass->at(imc));
-                    
                     //hardprocess
 		    if(status==3 && (abspid<=6 || abspid==24 || abspid==11 || abspid==13))
                       {
@@ -601,6 +631,8 @@ void RunToppPb(TString inFileName,
 		    ljev.gj_eta[ljev.ngj]=p4.Eta();
 		    ljev.gj_phi[ljev.ngj]=p4.Phi();
 		    ljev.gj_m[ljev.ngj]=p4.M();
+		    ljev.gj_dr[ljev.ngj]=gendrjt[imcj];
+		    ljev.gj_index[ljev.ngj]=genmatchindex[imcj];
 		    ljev.ngj++;
 		  }
 
@@ -941,7 +973,7 @@ void RunToppPb(TString inFileName,
 	    if(TMath::Abs(jp4.Eta())>2.4) continue;
 
 	    //systematic variations
-	    Int_t jflav(abs(refparton_flavor[jetIter]));	    
+	    Int_t jflav(abs(refparton_flavorForB[jetIter]));	    
 	    bool passCSVL(discr_csvV2[jetIter]>0.460), passCSVM(discr_csvV2[jetIter]>0.8),passCSVMUp(passCSVM),passCSVMDn(passCSVM);	    
 	    std::vector<float> jerSmear(3,1.0),jesScaleUnc(3,1.0);
 	    if(isMC)
@@ -991,6 +1023,22 @@ void RunToppPb(TString inFileName,
 		    ljev.j_phi[ljev.nj] =jp4.Phi();
 		    ljev.j_m[ljev.nj]   =jp4.M();
 		    ljev.j_btag[ljev.nj]=passCSVL | (passCSVM<<1);
+		    ljev.j_area[ljev.nj]= jtarea[jetIter];
+		    ljev.j_refpt[ljev.nj]= refpt[jetIter];
+		    ljev.j_refarea[ljev.nj]= refarea[jetIter];
+		    ljev.j_refdr[ljev.nj]= refdrjt[jetIter]; 
+		    ljev.j_refparton_flavorForB[ljev.nj]= refparton_flavorForB[jetIter];
+		    ljev.j_refparton_flavor[ljev.nj]= refparton_flavor[jetIter];
+		    ljev.j_PfCHF[ljev.nj]=jPfCHF[jetIter];
+		    ljev.j_PfNHF[ljev.nj]=jPfNHF[jetIter];
+		    ljev.j_PfCEF[ljev.nj]=jPfCEF[jetIter];
+		    ljev.j_PfNEF[ljev.nj]=jPfNEF[jetIter];
+		    ljev.j_PfMUF[ljev.nj]=jPfMUF[jetIter];
+		    ljev.j_PfCHM[ljev.nj]=jPfCHM[jetIter];
+		    ljev.j_PfNHM[ljev.nj]=jPfNHM[jetIter];
+		    ljev.j_PfCEM[ljev.nj]=jPfCEM[jetIter];
+		    ljev.j_PfNEM[ljev.nj]=jPfNEM[jetIter];
+		    ljev.j_PfMUM[ljev.nj]=jPfMUM[jetIter];
 		    ljev.nj++;
 		  }
 
-- 
GitLab