From 108444fcec1107cbcda9dd0ca71ef3129fa30b46 Mon Sep 17 00:00:00 2001
From: Sylvester Joosten <sjoosten@anl.gov>
Date: Fri, 6 Aug 2021 16:11:32 +0000
Subject: [PATCH] Update benchmarks for new EICD

---
 .gitignore                                        | 10 ++++++++++
 benchmarks/ecal/options/barrel.py                 | 15 ++++++++-------
 benchmarks/ecal/run_emcal_benchmarks.py           |  8 ++++----
 .../scripts/{draw_cluters.py => draw_clusters.py} |  9 +++++----
 4 files changed, 27 insertions(+), 15 deletions(-)
 rename benchmarks/ecal/scripts/{draw_cluters.py => draw_clusters.py} (92%)

diff --git a/.gitignore b/.gitignore
index ec2bfe82..8fdeae71 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,3 +41,13 @@ __pycache__/
 calorimeters/test/
 *.d
 *.pcm
+
+# transient directories and files
+setup
+results
+*.root
+fieldmaps
+eic-env.sh
+sim_output
+*.obj
+*.hepmc
diff --git a/benchmarks/ecal/options/barrel.py b/benchmarks/ecal/options/barrel.py
index e2df5b3b..870f6bf0 100644
--- a/benchmarks/ecal/options/barrel.py
+++ b/benchmarks/ecal/options/barrel.py
@@ -58,7 +58,7 @@ cb_ecal_digi = CalHitDigi("cb_ecal_digi",
         **cb_ecal_daq)
 
 cb_ecal_reco = ImCalPixelReco("cb_ecal_reco",
-        inputHitCollection="EcalBarrelHitsDigi",
+        inputHitCollection=cb_ecal_digi.outputHitCollection,
         outputHitCollection="EcalBarrelHitsReco",
         thresholdFactor=3,  # about 20 keV
         readoutClass="EcalBarrelHits",  # readout class
@@ -67,8 +67,8 @@ cb_ecal_reco = ImCalPixelReco("cb_ecal_reco",
         **cb_ecal_daq)
 
 cb_ecal_cl = ImagingCluster("cb_ecal_cl",
-        inputHitCollection="EcalBarrelHitsReco",
-        outputHitCollection="EcalBarrelClusterHits",
+        inputHitCollection=cb_ecal_reco.outputHitCollection,
+        outputProtoClusterCollection="EcalBarrelProtoClusters",
         localDistXY=[2.*mm, 2*mm],              # same layer
         layerDistEtaPhi=[10*mrad, 10*mrad],     # adjacent layer
         neighbourLayersRange=2,                 # id diff for adjacent layer
@@ -76,16 +76,17 @@ cb_ecal_cl = ImagingCluster("cb_ecal_cl",
 
 cb_ecal_clreco = ImagingClusterReco("cb_ecal_clreco",
         samplingFraction=cb_ecal_sf,
-        inputHitCollection="EcalBarrelClusterHits",
+        inputHitCollection=cb_ecal_cl.inputHitCollection,
+        inputProtoClusterCollection=cb_ecal_cl.outputProtoClusterCollection,
         outputClusterCollection="EcalBarrelClusters",
-        outputLayerCollection="EcalBarrelLayers")
+        outputLayerCollection="EcalBarrelLayers",
+        outputInfoCollection="EcalBarrelClustersInfo")
 
 podout.outputCommands = ['drop *',
         'keep mcparticles2',
         'keep *HitsReco',
         'keep *HitsDigi',
-        'keep *ClusterHits',
-        'keep *Clusters']
+        'keep *Cluster*']
 
 ApplicationMgr(
     TopAlg = [podin, copier,
diff --git a/benchmarks/ecal/run_emcal_benchmarks.py b/benchmarks/ecal/run_emcal_benchmarks.py
index f3ecf610..2380e404 100755
--- a/benchmarks/ecal/run_emcal_benchmarks.py
+++ b/benchmarks/ecal/run_emcal_benchmarks.py
@@ -15,19 +15,19 @@ import argparse
 default_type = {
     'endcap_e': [
         ['endcap_e.py'],
-        ['draw_cluters.py'],
+        ['draw_clusters.py'],
         ['EcalEndcapNClusters']],
     'endcap_i': [
         ['endcap_i.py'],
-        ['draw_cluters.py'],
+        ['draw_clusters.py'],
         ['EcalEndcapPClusters']],
     'barrel': [
         ['barrel.py'],
-        ['draw_cluters.py'],
+        ['draw_clusters.py'],
         ['EcalBarrelClusters']],
 #     'all': [
 #         ['all_ecal.py'],
-#         ['draw_cluters.py'],
+#         ['draw_clusters.py'],
 #         ['EcalEndcapNClusters', 'EcalEndcapPClusters', 'EcalBarrelClusters']],
 }
 
diff --git a/benchmarks/ecal/scripts/draw_cluters.py b/benchmarks/ecal/scripts/draw_clusters.py
similarity index 92%
rename from benchmarks/ecal/scripts/draw_cluters.py
rename to benchmarks/ecal/scripts/draw_clusters.py
index fd03f2dc..f4c81896 100644
--- a/benchmarks/ecal/scripts/draw_cluters.py
+++ b/benchmarks/ecal/scripts/draw_clusters.py
@@ -25,7 +25,8 @@ def load_root_macros(arg_macros):
 # read from RDataFrame and flatten a given collection, return pandas dataframe
 def flatten_collection(rdf, collection, cols=None):
     if not cols:
-        cols = [str(c) for c in rdf.GetColumnNames() if str(c).startswith('{}.'.format(collection))]
+        cols  = [str(c) for c in rdf.GetColumnNames() if str(c).startswith('{}.'.format(collection))]
+        cols += [str(c) for c in rdf.GetColumnNames() if str(c).startswith('{}Info.'.format(collection))]
     else:
         cols = ['{}.{}'.format(collection, c) for c in cols]
     if not cols:
@@ -92,10 +93,10 @@ if __name__ == '__main__':
     ]
     for coll in [c.strip() for c in args.coll.split(',')]:
         df = flatten_collection(rdf_rec, coll)
-        # calculate eta
-        df.loc[:, '{}.eta'.format(coll)] = -np.log(np.tan(df['{}.polar.theta'.format(coll)].values/2.))
+        # Get eta from info table
+        df[coll + '.eta'] = df[coll + 'Info.eta']
         fig, axs = plt.subplots(2, 2, figsize=(12, 8), dpi=160)
-        ncl = df.groupby('event')['{}.clusterID'.format(coll)].nunique().values
+        ncl = df.groupby('event')['{}.ID.value'.format(coll)].nunique().values
         axs[0][0].hist(ncl, weights=np.repeat(1./float(ncl.shape[0]), ncl.shape[0]),
                 bins=np.arange(0, 10), align='mid', ec='k')
         axs[0][0].set_xlabel('Number of Clusters', fontsize=16)
-- 
GitLab