From 11550b61366e48f7d0e897affd558883bfbd9935 Mon Sep 17 00:00:00 2001
From: Wouter Deconinck <wouter.deconinck@umanitoba.ca>
Date: Tue, 17 Aug 2021 23:08:10 +0000
Subject: [PATCH] Use algorithms list for all steps

---
 .../full/options/full_reconstruction.py       | 118 +++++++++---------
 1 file changed, 59 insertions(+), 59 deletions(-)

diff --git a/benchmarks/full/options/full_reconstruction.py b/benchmarks/full/options/full_reconstruction.py
index 8f6e88f5..8845e721 100644
--- a/benchmarks/full/options/full_reconstruction.py
+++ b/benchmarks/full/options/full_reconstruction.py
@@ -103,25 +103,25 @@ sim_coll = [
 # list of algorithms
 algorithms = []
 
-# input and output
+# input
 podin = PodioInput("PodioReader", collections=sim_coll)
-podout = PodioOutput("out", filename=output_rec)
+algorithms.append(podin)
 
 ## copiers to get around input --> output copy bug. Note the "2" appended to the output collection.
 copier = MCCopier("MCCopier",
         inputCollection="mcparticles",
         outputCollection="mcparticles2")
-algorithms.append( copier )
+algorithms.append(copier)
 
 trkcopier = TrkCopier("TrkCopier",
         inputCollection="TrackerBarrelHits",
         outputCollection="TrackerBarrelHits2")
-algorithms.append( trkcopier )
+algorithms.append(trkcopier)
 
 pmtcopier = PMTCopier("PMTCopier",
         inputCollection="DRICHHits",
         outputCollection="DRICHHits2")
-algorithms.append( pmtcopier )
+algorithms.append(pmtcopier)
 
 # Crystal Endcap Ecal
 ce_ecal_daq = dict(
@@ -135,7 +135,7 @@ ce_ecal_digi = CalHitDigi("ce_ecal_digi",
         outputHitCollection="EcalEndcapNHitsDigi",
         energyResolutions=[0., 0.02, 0.],
         **ce_ecal_daq)
-algorithms.append( ce_ecal_digi )
+algorithms.append(ce_ecal_digi)
 
 ce_ecal_reco = CalHitReco("ce_ecal_reco",
         inputHitCollection=ce_ecal_digi.outputHitCollection,
@@ -144,7 +144,7 @@ ce_ecal_reco = CalHitReco("ce_ecal_reco",
         readoutClass="EcalEndcapNHits",
         sectorField="sector",
         **ce_ecal_daq)
-algorithms.append( ce_ecal_reco )
+algorithms.append(ce_ecal_reco)
 
 ce_ecal_cl = IslandCluster("ce_ecal_cl",
         inputHitCollection=ce_ecal_reco.outputHitCollection,
@@ -154,7 +154,7 @@ ce_ecal_cl = IslandCluster("ce_ecal_cl",
         minClusterCenterEdep=30*units.MeV,
         sectorDist=5.0*units.cm,
         dimScaledLocalDistXY=[1.8, 1.8]) # dimension scaled dist is good for hybrid sectors with different module size
-algorithms.append( ce_ecal_cl )
+algorithms.append(ce_ecal_cl)
 
 ce_ecal_clreco = RecoCoG("ce_ecal_clreco",
         inputHitCollection=ce_ecal_cl.inputHitCollection,
@@ -162,7 +162,7 @@ ce_ecal_clreco = RecoCoG("ce_ecal_clreco",
         outputClusterCollection="EcalEndcapNClusters",
         samplingFraction=0.998,      # this accounts for a small fraction of leakage
         logWeightBase=4.6)
-algorithms.append( ce_ecal_clreco )
+algorithms.append(ce_ecal_clreco)
 
 # Endcap Sampling Ecal
 ci_ecal_daq = dict(
@@ -175,14 +175,14 @@ ci_ecal_digi = CalHitDigi("ci_ecal_digi",
         inputHitCollection="EcalEndcapPHits",
         outputHitCollection="EcalEndcapPHitsDigi",
         **ci_ecal_daq)
-algorithms.append( ci_ecal_digi )
+algorithms.append(ci_ecal_digi)
 
 ci_ecal_reco = CalHitReco("ci_ecal_reco",
         inputHitCollection=ci_ecal_digi.outputHitCollection,
         outputHitCollection="EcalEndcapPHitsReco",
         thresholdFactor=5.0,
         **ci_ecal_daq)
-algorithms.append( ci_ecal_reco )
+algorithms.append(ci_ecal_reco)
 
 # merge hits in different layer (projection to local x-y plane)
 ci_ecal_merger = CalHitsMerger("ci_ecal_merger",
@@ -191,7 +191,7 @@ ci_ecal_merger = CalHitsMerger("ci_ecal_merger",
         fields=["layer", "slice"],
         fieldRefNumbers=[1, 0],
         readoutClass="EcalEndcapPHits")
-algorithms.append( ci_ecal_merger )
+algorithms.append(ci_ecal_merger)
 
 ci_ecal_cl = IslandCluster("ci_ecal_cl",
         inputHitCollection=ci_ecal_merger.outputHitCollection,
@@ -199,7 +199,7 @@ ci_ecal_cl = IslandCluster("ci_ecal_cl",
         splitCluster=False,
         minClusterCenterEdep=10.*units.MeV,
         localDistXY=[10*units.mm, 10*units.mm])
-algorithms.append( ci_ecal_cl )
+algorithms.append(ci_ecal_cl)
 
 ci_ecal_clreco = RecoCoG("ci_ecal_clreco",
         inputHitCollection=ci_ecal_cl.inputHitCollection,
@@ -208,7 +208,7 @@ ci_ecal_clreco = RecoCoG("ci_ecal_clreco",
         outputInfoCollection="EcalEndcapPClustersInfo",
         logWeightBase=6.2,
         samplingFraction=ci_ecal_sf)
-algorithms.append( ci_ecal_clreco )
+algorithms.append(ci_ecal_clreco)
 
 # Central Barrel Ecal (Imaging Cal.)
 cb_ecal_daq = dict(
@@ -222,7 +222,7 @@ cb_ecal_digi = CalHitDigi("cb_ecal_digi",
         outputHitCollection="EcalBarrelHitsDigi",
         energyResolutions=[0., 0.02, 0.],   # 2% flat resolution
         **cb_ecal_daq)
-algorithms.append( cb_ecal_digi )
+algorithms.append(cb_ecal_digi)
 
 cb_ecal_reco = ImCalPixelReco("cb_ecal_reco",
         inputHitCollection=cb_ecal_digi.outputHitCollection,
@@ -232,7 +232,7 @@ cb_ecal_reco = ImCalPixelReco("cb_ecal_reco",
         layerField="layer",             # field to get layer id
         sectorField="module",           # field to get sector id
         **cb_ecal_daq)
-algorithms.append( cb_ecal_reco )
+algorithms.append(cb_ecal_reco)
 
 cb_ecal_cl = ImagingCluster("cb_ecal_cl",
         inputHitCollection=cb_ecal_reco.outputHitCollection,
@@ -241,7 +241,7 @@ cb_ecal_cl = ImagingCluster("cb_ecal_cl",
         layerDistEtaPhi=[10*units.mrad, 10*units.mrad],     # adjacent layer
         neighbourLayersRange=2,                 # id diff for adjacent layer
         sectorDist=3.*units.cm)                       # different sector
-algorithms.append( cb_ecal_cl )
+algorithms.append(cb_ecal_cl)
 
 cb_ecal_clreco = ImagingClusterReco("cb_ecal_clreco",
         samplingFraction=cb_ecal_sf,
@@ -250,7 +250,7 @@ cb_ecal_clreco = ImagingClusterReco("cb_ecal_clreco",
         outputClusterCollection="EcalBarrelClusters",
         outputInfoCollection="EcalBarrelClustersInfo",
         outputLayerCollection="EcalBarrelLayers")
-algorithms.append( cb_ecal_clreco )
+algorithms.append(cb_ecal_clreco)
 
 # Central ECAL SciFi
 scfi_barrel_daq = dict(
@@ -263,6 +263,7 @@ scfi_barrel_digi = CalHitDigi("scfi_barrel_digi",
         inputHitCollection="EcalBarrelScFiHits",
         outputHitCollection="EcalBarrelScFiHitsDigi",
         **scfi_barrel_daq)
+algorithms.append(scfi_barrel_digi)
 
 scfi_barrel_reco = CalHitReco("scfi_barrel_reco",
         inputHitCollection=scfi_barrel_digi.outputHitCollection,
@@ -273,6 +274,7 @@ scfi_barrel_reco = CalHitReco("scfi_barrel_reco",
         sectorField="module",
         localDetFields=["system", "module"], # use local coordinates in each module (stave)
         **scfi_barrel_daq)
+algorithms.append(scfi_barrel_reco)
 
 # merge hits in different layer (projection to local x-y plane)
 scfi_barrel_merger = CalHitsMerger("scfi_barrel_merger",
@@ -281,6 +283,7 @@ scfi_barrel_merger = CalHitsMerger("scfi_barrel_merger",
          fields=["fiber"],
          fieldRefNumbers=[1],
          readoutClass="EcalBarrelScFiHits")
+algorithms.append(scfi_barrel_merger)
 
 scfi_barrel_cl = IslandCluster("scfi_barrel_cl",
          inputHitCollection=scfi_barrel_merger.outputHitCollection,
@@ -288,6 +291,7 @@ scfi_barrel_cl = IslandCluster("scfi_barrel_cl",
          splitCluster=False,
          minClusterCenterEdep=10.*MeV,
          localDistXZ=[30*mm, 30*mm])
+algorithms.append(scfi_barrel_cl)
 
 scfi_barrel_clreco = RecoCoG("scfi_barrel_clreco",
          inputHitCollection=scfi_barrel_cl.inputHitCollection,
@@ -296,6 +300,7 @@ scfi_barrel_clreco = RecoCoG("scfi_barrel_clreco",
          outputInfoCollection="EcalBarrelScFiClustersInfo",
          logWeightBase=6.2,
          samplingFraction= scifi_barrel_sf)
+algorithms.append(scfi_barrel_clreco)
 
 # Central Barrel Hcal
 cb_hcal_daq = dict(
@@ -308,6 +313,7 @@ cb_hcal_digi = CalHitDigi("cb_hcal_digi",
          inputHitCollection="HcalBarrelHits",
          outputHitCollection="HcalBarrelHitsDigi",
          **cb_hcal_daq)
+algorithms.append(cb_hcal_digi)
 
 cb_hcal_reco = CalHitReco("cb_hcal_reco",
         inputHitCollection=cb_hcal_digi.outputHitCollection,
@@ -317,6 +323,7 @@ cb_hcal_reco = CalHitReco("cb_hcal_reco",
         layerField="layer",
         sectorField="module",
         **cb_hcal_daq)
+algorithms.append(cb_hcal_reco)
 
 cb_hcal_merger = CalHitsMerger("cb_hcal_merger",
         inputHitCollection=cb_hcal_reco.outputHitCollection,
@@ -324,6 +331,7 @@ cb_hcal_merger = CalHitsMerger("cb_hcal_merger",
         readoutClass="HcalBarrelHits",
         fields=["layer", "slice"],
         fieldRefNumbers=[1, 0])
+algorithms.append(cb_hcal_merger)
 
 cb_hcal_cl = IslandCluster("cb_hcal_cl",
         inputHitCollection=cb_hcal_merger.outputHitCollection,
@@ -331,6 +339,7 @@ cb_hcal_cl = IslandCluster("cb_hcal_cl",
         splitCluster=False,
         minClusterCenterEdep=30.*units.MeV,
         localDistXY=[15.*units.cm, 15.*units.cm])
+algorithms.append(cb_hcal_cl)
 
 cb_hcal_clreco = RecoCoG("cb_hcal_clreco",
         inputHitCollection=cb_hcal_cl.inputHitCollection,
@@ -339,7 +348,7 @@ cb_hcal_clreco = RecoCoG("cb_hcal_clreco",
         outputInfoCollection="HcalBarrelClustersInfo",
         logWeightBase=6.2,
         samplingFraction=cb_hcal_sf)
-
+algorithms.append(cb_hcal_clreco)
 
 # Hcal Hadron Endcap
 ci_hcal_daq = dict(
@@ -347,16 +356,19 @@ ci_hcal_daq = dict(
          capacityADC=32768,
          pedestalMean=400,
          pedestalSigma=10)
+
 ci_hcal_digi = CalHitDigi("ci_hcal_digi",
          inputHitCollection="HcalEndcapPHits",
          outputHitCollection="HcalEndcapPHitsDigi",
          **ci_hcal_daq)
+algorithms.append(ci_hcal_digi)
 
 ci_hcal_reco = CalHitReco("ci_hcal_reco",
         inputHitCollection=ci_hcal_digi.outputHitCollection,
         outputHitCollection="HcalEndcapPHitsReco",
         thresholdFactor=5.0,
         **ci_hcal_daq)
+algorithms.append(ci_hcal_reco)
 
 ci_hcal_merger = CalHitsMerger("ci_hcal_merger",
         inputHitCollection=ci_hcal_reco.outputHitCollection,
@@ -364,6 +376,7 @@ ci_hcal_merger = CalHitsMerger("ci_hcal_merger",
         readoutClass="HcalEndcapPHits",
         fields=["layer", "slice"],
         fieldRefNumbers=[1, 0])
+algorithms.append(ci_hcal_merger)
 
 ci_hcal_cl = IslandCluster("ci_hcal_cl",
         inputHitCollection=ci_hcal_merger.outputHitCollection,
@@ -371,6 +384,7 @@ ci_hcal_cl = IslandCluster("ci_hcal_cl",
         splitCluster=False,
         minClusterCenterEdep=30.*units.MeV,
         localDistXY=[15.*units.cm, 15.*units.cm])
+algorithms.append(ci_hcal_cl)
 
 ci_hcal_clreco = RecoCoG("ci_hcal_clreco",
         inputHitCollection=ci_hcal_cl.inputHitCollection,
@@ -379,6 +393,7 @@ ci_hcal_clreco = RecoCoG("ci_hcal_clreco",
         outputInfoCollection="HcalEndcapPClustersInfo",
         logWeightBase=6.2,
         samplingFraction=ci_hcal_sf)
+algorithms.append(ci_hcal_clreco)
 
 # Hcal Electron Endcap
 ce_hcal_daq = dict(
@@ -391,12 +406,14 @@ ce_hcal_digi = CalHitDigi("ce_hcal_digi",
         inputHitCollection="HcalEndcapNHits",
         outputHitCollection="HcalEndcapNHitsDigi",
         **ce_hcal_daq)
+algorithms.append(ce_hcal_digi)
 
 ce_hcal_reco = CalHitReco("ce_hcal_reco",
         inputHitCollection=ce_hcal_digi.outputHitCollection,
         outputHitCollection="HcalEndcapNHitsReco",
         thresholdFactor=5.0,
         **ce_hcal_daq)
+algorithms.append(ce_hcal_reco)
 
 ce_hcal_merger = CalHitsMerger("ce_hcal_merger",
         inputHitCollection=ce_hcal_reco.outputHitCollection,
@@ -404,6 +421,7 @@ ce_hcal_merger = CalHitsMerger("ce_hcal_merger",
         readoutClass="HcalEndcapNHits",
         fields=["layer", "slice"],
         fieldRefNumbers=[1, 0])
+algorithms.append(ce_hcal_merger)
 
 ce_hcal_cl = IslandCluster("ce_hcal_cl",
         inputHitCollection=ce_hcal_merger.outputHitCollection,
@@ -411,6 +429,7 @@ ce_hcal_cl = IslandCluster("ce_hcal_cl",
         splitCluster=False,
         minClusterCenterEdep=30.*units.MeV,
         localDistXY=[15.*units.cm, 15.*units.cm])
+algorithms.append(ce_hcal_cl)
 
 ce_hcal_clreco = RecoCoG("ce_hcal_clreco",
         inputHitCollection=ce_hcal_cl.inputHitCollection,
@@ -419,53 +438,64 @@ ce_hcal_clreco = RecoCoG("ce_hcal_clreco",
         outputInfoCollection="HcalEndcapNClustersInfo",
         logWeightBase=6.2,
         samplingFraction=ce_hcal_sf)
-
+algorithms.append(ce_hcal_clreco)
 
 # Tracking
 trk_b_digi = TrackerDigi("trk_b_digi",
         inputHitCollection="TrackerBarrelHits",
         outputHitCollection="TrackerBarrelRawHits",
         timeResolution=8)
+algorithms.append(trk_b_digi)
+
 trk_ec_digi = TrackerDigi("trk_ec_digi",
         inputHitCollection="TrackerEndcapHits",
         outputHitCollection="TrackerEndcapRawHits",
         timeResolution=8)
+algorithms.append(trk_ec_digi)
 
 vtx_b_digi = TrackerDigi("vtx_b_digi",
         inputHitCollection="VertexBarrelHits",
         outputHitCollection="VertetimeResolution=10xBarrelRawHits",
         timeResolution=8)
+algorithms.append(vtx_b_digi)
 
 vtx_ec_digi = TrackerDigi("vtx_ec_digi",
         inputHitCollection="VertexEndcapHits",
         outputHitCollection="VertexEndcapRawHits",
         timeResolution=8)
+algorithms.append(vtx_ec_digi)
 
 gem_ec_digi = TrackerDigi("gem_ec_digi",
         inputHitCollection="GEMTrackerEndcapHits",
         outputHitCollection="GEMTrackerEndcapRawHits",
         timeResolution=10)
+algorithms.append(gem_ec_digi)
 
 # Tracker and vertex reconstruction
 trk_b_reco = TrackerHitReconstruction("trk_b_reco",
         inputHitCollection = trk_b_digi.outputHitCollection,
         outputHitCollection="TrackerBarrelRecHits")
+algorithms.append(trk_b_reco)
 
 trk_ec_reco = TrackerHitReconstruction("trk_ec_reco",
         inputHitCollection = trk_ec_digi.outputHitCollection,
         outputHitCollection="TrackerEndcapRecHits")
+algorithms.append(trk_ec_reco)
 
 vtx_b_reco = TrackerHitReconstruction("vtx_b_reco",
         inputHitCollection = vtx_b_digi.outputHitCollection,
         outputHitCollection="VertexBarrelRecHits")
+algorithms.append(vtx_b_reco)
 
 vtx_ec_reco = TrackerHitReconstruction("vtx_ec_reco",
         inputHitCollection = vtx_ec_digi.outputHitCollection,
         outputHitCollection="VertexEndcapRecHits")
+algorithms.append(vtx_ec_reco)
 
 gem_ec_reco = TrackerHitReconstruction("gem_ec_reco",
         inputHitCollection=gem_ec_digi.outputHitCollection,
         outputHitCollection="GEMTrackerEndcapRecHits")
+algorithms.append(gem_ec_reco)
 
 # Tracking hit collector
 trk_hit_col = TrackingHitsCollector("trk_hit_col",
@@ -476,34 +506,20 @@ trk_hit_col = TrackingHitsCollector("trk_hit_col",
             str(vtx_ec_reco.outputHitCollection),
             str(gem_ec_reco.outputHitCollection) ],
         trackingHits="trackingHits")
+algorithms.append(trk_hit_col)
 
 # Hit Source linker
 sourcelinker = TrackerSourcesLinker("trk_srcslnkr",
         inputHitCollections = trk_hit_col.trackingHits,
         outputSourceLinks = "TrackerSourceLinks",
         outputMeasurements = "TrackerMeasurements")
-
-#trk_hits_srclnkr = TrackerSourcesLinker("trk_srcslnkr",
-#        ITrackerBarrelHits = vtx_b_reco.outputHitCollection,
-#        ITrackerEndcapHits = vtx_ec_reco.outputHitCollection,
-#        OTrackerBarrelHits = trk_b_reco.outputHitCollection,
-#        OTrackerEndcapHits = trk_ec_reco.outputHitCollection,
-#        outputSourceLinks="TrackerMeasurements")
+algorithms.append(sourcelinker)
 
 ## Track param init
 truth_trk_init = TrackParamTruthInit("truth_trk_init",
         inputMCParticles="mcparticles",
         outputInitialTrackParameters="InitTrackParams")
-
-#clust_trk_init = TrackParamClusterInit("clust_trk_init",
-#        inputClusters="SimpleClusters",
-#        outputInitialTrackParameters="InitTrackParamsFromClusters")
-
-#vtxcluster_trk_init = TrackParamVertexClusterInit("vtxcluster_trk_init",
-#        inputVertexHits="VertexBarrelRecHits",
-#        inputClusters="EcalBarrelClusters",
-#        outputInitialTrackParameters="InitTrackParamsFromVtxClusters",
-#        maxHitRadius=40.0*units.mm)
+algorithms.append(truth_trk_init)
 
 # Tracking algorithms
 trk_find_alg = TrackFindingAlgorithm("trk_find_alg",
@@ -511,42 +527,24 @@ trk_find_alg = TrackFindingAlgorithm("trk_find_alg",
         inputMeasurements = sourcelinker.outputMeasurements,
         inputInitialTrackParameters = "InitTrackParams",
         outputTrajectories = "trajectories")
+algorithms.append(trk_find_alg)
 
 parts_from_fit = ParticlesFromTrackFit("parts_from_fit",
         inputTrajectories = "trajectories",
         outputParticles = "ReconstructedParticles",
         outputTrackParameters = "outputTrackParameters")
-
-#trk_find_alg1 = TrackFindingAlgorithm("trk_find_alg1",
-#        inputSourceLinks = sourcelinker.outputSourceLinks,
-#        inputMeasurements = sourcelinker.outputMeasurements,
-#        inputInitialTrackParameters= "InitTrackParamsFromClusters",
-#        outputTrajectories="trajectories1")
-
-#parts_from_fit1 = ParticlesFromTrackFit("parts_from_fit1",
-#        inputTrajectories="trajectories1",
-#        outputParticles="ReconstructedParticlesInitFromClusters",
-#        outputTrackParameters="outputTrackParameters1")
-
-#trk_find_alg2 = TrackFindingAlgorithm("trk_find_alg2",
-#        inputSourceLinks = trk_hits_srclnkr.outputSourceLinks,
-#        inputMeasurements = trk_hits_srclnkr.outputMeasurements,
-#        inputInitialTrackParameters= "InitTrackParamsFromVtxClusters",
-#        outputTrajectories="trajectories2")
-#parts_from_fit2 = ParticlesFromTrackFit("parts_from_fit2",
-#        inputTrajectories="trajectories2",
-#        outputParticles="ReconstructedParticles2",
-#        outputTrackParameters="outputTrackParameters2")
-
+algorithms.append(parts_from_fit)
 
 pmtdigi = PhotoMultiplierDigi("pmtdigi",
         inputHitCollection="DRICHHits",
         outputHitCollection="DRICHHitsDigi",
         quantumEfficiency=[(a*units.eV, b) for a, b in qe_data])
+algorithms.append(pmtdigi)
 
 pmtreco = PhotoMultiplierReco("pmtreco",
         inputHitCollection="DRICHHitsDigi",
         outputHitCollection="DRICHHitsReco")
+algorithms.append(pmtreco)
 
 # FIXME
 #richcluster = PhotoRingClusters("richcluster",
@@ -555,6 +553,7 @@ pmtreco = PhotoMultiplierReco("pmtreco",
 #        outputClusterCollection="ForwardRICHClusters")
 
 # Output
+podout = PodioOutput("out", filename=output_rec)
 podout.outputCommands = [
         "keep *",
         "drop *Digi",
@@ -565,6 +564,7 @@ podout.outputCommands = [
         "drop InitTrackParams",
         "drop mcparticles"
         ]
+algorithms.append(podout)
 
 ApplicationMgr(
     TopAlg = algorithms,
-- 
GitLab