Skip to content

Commit

Permalink
fixing earlier issues on with push
Browse files Browse the repository at this point in the history
  • Loading branch information
andresnava1000 committed Aug 14, 2023
1 parent d6d4f65 commit 781ebcf
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 640 deletions.
94 changes: 1 addition & 93 deletions VBFgenInfoTests.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -428,16 +428,11 @@
}
],
"source": [
<<<<<<< HEAD
"df = pd.read_parquet('0-2.parquet')\n",
"\n",
"df.columns.values.tolist()\n",
"df\n",
" "
=======
"df = pd.read_parquet(\"0-10.parquet\")\n",
"df.columns.values.tolist()"
>>>>>>> 219b36b8254c529b99a31b88fb9609023c060267
]
},
{
Expand Down Expand Up @@ -473,10 +468,9 @@
"source": [
"# Apply lepton veto selections ($N_\\mu =0$ and $N_e=0$)\n",
"print(np.shape(df))\n",
"df_em = df[(df[(\"nGoodMuons\", 0)] == 0) & (df[(\"nGoodElectrons\", 0)] == 0)]\n",
"df_em = df[(df[('nGoodMuons', 0)] == 0) & (df[('nGoodElectrons', 0)] == 0)]\n",
"\n",
"# 2 vbf jets\n",
<<<<<<< HEAD
"#df_vbf = df[ (df[('nGoodVBFJetsUnsorted', 0)] >= 2)]\n",
"\n",
"# lepton veto and 2 vbf jets\n",
Expand All @@ -495,47 +489,6 @@
"print('tsts',np.sum(df_sorted_pt['weight']),np.sum(df_sorted_pt['weight_noxsec']))\n",
"df_sorted_pt\n",
"print(np.sum(df_sorted_pt['weight_noxsec']))\n"
=======
"df_vbf = df[(df[(\"nGoodVBFJetsUnsorted\", 0)] >= 2)]\n",
"\n",
"# lepton veto and 2 vbf jets\n",
"df_unsorted = df[\n",
" (df[(\"nGoodMuons\", 0)] == 0)\n",
" & (df[(\"nGoodElectrons\", 0)] == 0)\n",
" & (df[(\"nGoodVBFJetsUnsorted\", 0)] >= 2)\n",
" & (df[(\"nGoodJets\", 0)] == 0)\n",
"]\n",
"df_sorted_pt = df[\n",
" (df[(\"nGoodMuons\", 0)] == 0)\n",
" & (df[(\"nGoodElectrons\", 0)] == 0)\n",
" & (df[(\"nGoodVBFJetsSortedpt\", 0)] >= 2)\n",
" & (df[(\"nGoodJets\", 0)] == 0)\n",
"]\n",
"df_sorted_M = df[\n",
" (df[(\"nGoodMuons\", 0)] == 0)\n",
" & (df[(\"nGoodElectrons\", 0)] == 0)\n",
" & (df[(\"nGoodVBFJetsSortedM\", 0)] >= 2)\n",
" & (df[(\"nGoodJets\", 0)] == 0)\n",
"]\n",
"df_sorted_eta = df[\n",
" (df[(\"nGoodMuons\", 0)] == 0)\n",
" & (df[(\"nGoodElectrons\", 0)] == 0)\n",
" & (df[(\"nGoodVBFJetsSortedeta\", 0)] >= 2)\n",
" & (df[(\"nGoodJets\", 0)] == 0)\n",
"]\n",
"\n",
"\n",
"# generate all variables that are needed for the ak8 jet selections in VBF HH4b paper.\n",
"# df[('DijetDeltaPhi', 0)] = np.abs(df[('ak8FatJetPhi', 0)] - df[('ak8FatJetPhi', 1)])\n",
"# df[('DijetDeltaEta', 0)] = np.abs(df[('ak8FatJetEta', 0)] - df[('ak8FatJetEta', 1)])\n",
"print(\n",
" np.shape(df)[0],\n",
" np.shape(df_unsorted)[0],\n",
" np.shape(df_sorted_pt)[0],\n",
" np.shape(df_sorted_M)[0],\n",
" np.shape(df_sorted_eta)[0],\n",
")"
>>>>>>> 219b36b8254c529b99a31b88fb9609023c060267
]
},
{
Expand Down Expand Up @@ -690,7 +643,6 @@
" dphi = np.where(dphi < np.pi, dphi, 2 * np.pi - dphi)\n",
" return np.sqrt(deta**2 + dphi**2)\n",
"\n",
<<<<<<< HEAD
"# Calculate delta R for each sorting method and add it to the DataFrame\n",
"for df, method in zip([df_sorted_Rand, df_sorted_pt, df_sorted_M, df_sorted_eta], ['Rand', 'pt', 'M', 'eta']):\n",
" df[\"deltaR_1_to_0\"] = deltaR(df[('vbfetaGen', 0)], df[('vbfphiGen', 0)],\n",
Expand Down Expand Up @@ -3167,31 +3119,6 @@
" plt.title(\"Combined drj1VV and drj2VV values\")\n",
" plt.xlabel(\"Delta R\")\n",
" plt.legend()\n",
=======
"\n",
"# Create a dictionary mapping sorting methods to their dataframes\n",
"sorting_methods_to_dfs = {\n",
" \"Rand\": df_unsorted,\n",
" \"pt\": df_sorted_pt,\n",
" \"M\": df_sorted_M,\n",
" \"eta\": df_sorted_eta,\n",
"}\n",
"\n",
"# Iterate over each DataFrame and modify the column names\n",
"for df_name, df_method in sorting_methods_to_dfs.items():\n",
" df_method.rename(\n",
" columns={(\"vbfphiUnsortedRand\", jet): (\"vbfphiSortedRand\", jet) for jet in [0, 1]},\n",
" inplace=True,\n",
" )\n",
" df_method.rename(\n",
" columns={(\"vbfMUnsortedRand\", jet): (\"vbfMSortedRand\", jet) for jet in [0, 1]}, inplace=True\n",
" )\n",
"\n",
"for df_name, df_method in sorting_methods_to_dfs.items():\n",
" print(f\"{df_name} DataFrame:\\n\")\n",
" print(df_method.columns.values.tolist())\n",
" print(\"\\n---\\n\")\n",
>>>>>>> 219b36b8254c529b99a31b88fb9609023c060267
"\n",
" # All variables combined\n",
" plt.subplot(2, 1, 2)\n",
Expand All @@ -3203,31 +3130,12 @@
" plt.ylabel(\"Number of Events\")\n",
" plt.legend()\n",
"\n",
<<<<<<< HEAD
" plt.tight_layout()\n",
" plt.show()\n",
"\n",
"# The function call remains the same:\n",
"process_and_plot_refactored('output_deltaRtruthinfo.txt')\n",
"process_and_plot_refactored('output_deltaRtruthinfo_bbtagging.txt')"
=======
"# Iterate over each sorting method and calculate delta R\n",
"for method, df_method in sorting_methods_to_dfs.items():\n",
" for jet in [0, 1]:\n",
" eta_gen = df_method[(f\"vbfetaGen\", jet)]\n",
" phi_gen = df_method[(f\"vbfphiGen\", jet)]\n",
"\n",
" eta_sorted = df_method[(f\"vbfetaSorted{method}\", jet)]\n",
" phi_sorted = df_method[(f\"vbfphiSorted{method}\", jet)]\n",
"\n",
" df_method[(f\"deltaR_{method}\", jet)] = deltaR(eta_gen, phi_gen, eta_sorted, phi_sorted)\n",
"\n",
"# Print DataFrames to check results\n",
"for df_name, df_method in sorting_methods_to_dfs.items():\n",
" print(f\"{df_name} DataFrame:\\n\")\n",
" print(df_method)\n",
" print(\"\\n---\\n\")"
>>>>>>> 219b36b8254c529b99a31b88fb9609023c060267
]
},
{
Expand Down
Loading

0 comments on commit 781ebcf

Please sign in to comment.