neuthadSaveTool = DelphesSaveNeutralParticles(
    "neutral",
    delphesArrayName="HCal/eflowNeutralHadrons",
    saveIsolation=False)
apply_paths(neuthadSaveTool, out_names["neutral"])

photonsSaveTool = DelphesSaveNeutralParticles(
    "photons", delphesArrayName="PhotonIsolation/photons")
apply_paths(photonsSaveTool, out_names["photons"])

genJetSaveTool = DelphesSaveGenJets("genJets",
                                    delphesArrayName="GenJetFinder/jets")
apply_paths(genJetSaveTool, out_names["genJets"])

jetSaveTool = DelphesSaveJets("jets", delphesArrayName="JetEnergyScale/jets")
apply_paths(jetSaveTool, out_names["jets"])

metSaveTool = DelphesSaveMet("met",
                             delphesMETArrayName="MissingET/momentum",
                             delphesSHTArrayName="ScalarHT/energy")
apply_paths(metSaveTool, out_names["met"])

## Pythia generator
from Configurables import PythiaInterface

pythia8gen = PythiaInterface(Filename=pythiaConfFile,
                             OutputLevel=messageLevelPythia)
## Write the HepMC::GenEvent to the data service
pythia8gen.DataOutputs.hepmc.Path = "hepmc"
chhadSaveTool = DelphesSaveChargedParticles("pfcharged", delphesArrayName="ChargedHadronFilter/chargedHadrons", saveIsolation=False)
apply_paths(chhadSaveTool, out_names["pfcharged"])

neuthadSaveTool = DelphesSaveNeutralParticles("pfneutrals", delphesArrayName="HCal/eflowNeutralHadrons", saveIsolation=False)
apply_paths(neuthadSaveTool, out_names["pfneutrals"])

pfphotonsSaveTool = DelphesSaveNeutralParticles("pfphotons", delphesArrayName="ECal/eflowPhotons", saveIsolation=False)
apply_paths(pfphotonsSaveTool, out_names["pfphotons"])

photonsSaveTool = DelphesSaveNeutralParticles("photons", delphesArrayName="PhotonEfficiency/photons")
apply_paths(photonsSaveTool, out_names["photons"])

genJetSaveTool = DelphesSaveGenJets("genJets", delphesArrayName="GenJetFinder/jets")
apply_paths(genJetSaveTool, out_names["genJets"])

jetSaveTool = DelphesSaveJets("jets", delphesArrayName="JetEnergyScale/jets")
apply_paths(jetSaveTool, out_names["jets"])

fatjetSaveTool = DelphesSaveJets("fatjets", delphesArrayName="FatJetFinder/jets", saveSubstructure=True)
apply_paths(fatjetSaveTool, out_names["fatjets"])

metSaveTool = DelphesSaveMet("met", delphesMETArrayName="MissingET/momentum", delphesSHTArrayName="ScalarHT/energy")
apply_paths(metSaveTool, out_names["met"])

#### Pythia generator
from Configurables import PythiaInterface
from Configurables import PoissonPileUp
from Configurables import HepMCFullMerge

pythia8gentool = PythiaInterface(Filename=pythiaConfFile, OutputLevel=messageLevelPythia)
mergetool = HepMCFullMerge()