dupP = 13
finE = 9
finP = 17
threshold = 12

from Configurables import CreateCaloClustersSlidingWindow
createClusters = CreateCaloClustersSlidingWindow("CreateClusters")
createClusters.towerTool = towers
createClusters.nEtaWindow = windE
createClusters.nPhiWindow = windP
createClusters.nEtaPosition = posE
createClusters.nPhiPosition = posP
createClusters.nEtaDuplicates = dupE
createClusters.nPhiDuplicates = dupP
createClusters.nEtaFinal = finE
createClusters.nPhiFinal = finP
createClusters.energyThreshold = threshold
createClusters.clusters.Path = "CaloClusters"
createClusters.AuditExecute = True
ApplicationMgr().TopAlg +=[createClusters]

out = PodioOutput("out")
out.filename="output_runFullCaloSystem_ReconstructionSW_noiseFromFile.root"
out.outputCommands = ["keep *"]
out.AuditExecute = True
ApplicationMgr().TopAlg +=[out]


#ApplicationMgr(
#    TopAlg = [podioinput,
#              rewriteHcal,
towers.hcalFwdCells.Path = "emptyCaloCells"



from Configurables import CreateCaloClustersSlidingWindow
createClusters = CreateCaloClustersSlidingWindow("CreateClusters")
# Cluster variables
createClusters.towerTool = towers
createClusters.nEtaWindow =      9
createClusters.nPhiWindow =     17
createClusters.nEtaPosition =    5
createClusters.nPhiPosition =   11
createClusters.nEtaDuplicates =  7
createClusters.nPhiDuplicates = 13
createClusters.nEtaFinal =       9
createClusters.nPhiFinal =      17
# Minimal energy to create a cluster in GeV (FCC-ee detectors have to reconstruct low energy particles)
createClusters.energyThreshold = 0.1
createClusters.attachCells = True
createClusters.clusters.Path = "CaloClusters"
createClusters.clusterCells.Path = "CaloClusterCells"
ApplicationMgr().TopAlg += [createClusters]


################ Output
from Configurables import PodioOutput
out = PodioOutput("out")
out.outputCommands = ["keep *", "drop ECalBarrelHits", "drop HCal*", "drop ECalBarrelCellsStep*", "drop ECalBarrelPositionedHits", "drop emptyCaloCells", "drop CaloClusterCells"]
import uuid
out.filename = "output_fullCalo_SimAndDigi.root"
ApplicationMgr().TopAlg += [out]