#####
tauAtMiniTools.addTauReReco(process)

#####
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
from Configuration.AlCa.GlobalTag import GlobalTag
if not phase2:
    process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2018_realistic', '')
else:
    process.GlobalTag = GlobalTag(
        process.GlobalTag, 'auto:phase2_realistic', '')

#####
# mode = 0: store original MiniAOD and new selectedPatTaus
# mode = 1: store original MiniAOD, new selectedPatTaus, and all PFtau products as in AOD (except of unsuported ones)
process.output = tauAtMiniTools.setOutputModule(mode=outMode)
if runSignal:
    process.output.fileName = 'miniAOD_TauReco_ggH.root'
    if reclusterJets:
        process.output.fileName = 'miniAOD_TauReco_ak4PFJets_ggH.root'
else:
    process.output.fileName = 'miniAOD_TauReco_QCD.root'
    if reclusterJets:
        process.output.fileName = 'miniAOD_TauReco_ak4PFJets_QCD.root'
process.out = cms.EndPath(process.output)

#####
tauAtMiniTools.adaptTauToMiniAODReReco(process, reclusterJets)

#####
process.load('FWCore.MessageService.MessageLogger_cfi')
process.load(
    'Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
from Configuration.AlCa.GlobalTag import GlobalTag
if not phase2 and runType != 'data':
    process.GlobalTag = GlobalTag(process.GlobalTag,
                                  'auto:phase1_2018_realistic', '')
elif phase2:
    process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic',
                                  '')
else:  # data
    process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_data', '')

#####
# mode = 0: store original MiniAOD and new selectedPatTaus
# mode = 1: store original MiniAOD, new selectedPatTaus, and all PFtau products as in AOD (except of unsuported ones)
process.output = tauAtMiniTools.setOutputModule(mode=outMode)
if runType == 'signal':
    process.output.fileName = 'miniAOD_TauReco_ggH.root'
    if reclusterJets:
        process.output.fileName = 'miniAOD_TauReco_ak4PFJets_ggH.root'
elif runType == 'background':
    process.output.fileName = 'miniAOD_TauReco_QCD.root'
    if reclusterJets:
        process.output.fileName = 'miniAOD_TauReco_ak4PFJets_QCD.root'
else:  # data
    process.output.fileName = 'miniAOD_TauReco_data.root'
    if reclusterJets:
        process.output.fileName = 'miniAOD_TauReco_ak4PFJets_data.root'
process.out = cms.EndPath(process.output)

#####