def setupJSON( process ):

    print 'setting up JSON:'

    fileName = process.source.fileNames[0]
    print fileName
    # in case filename is a local filename, removing CMGLOCALBASEDIR
    #Jose: dont know where this var is set
    #fileName = fileName.replace( os.environ['CMGLOCALBASEDIR'],'' ) 
    json = jsonPick( fileName, True )
    applyJSON(process, json )
    return json
from CMGTools.Production.datasetToSource import *
process.source = datasetToSource(
    dataset_user,
    dataset_name,
    dataset_pattern) 

# restricting the number of files to process to a given number
if numberOfFilesToProcess > 0:
    process.source.fileNames = process.source.fileNames[:numberOfFilesToProcess]

# attach JSON mask to the source if reading a data file
json = None
if dataset_name.find('Run201')>-1:
    from CMGTools.Common.Tools.applyJSON_cff import *
    from CMGTools.H2TauTau.tools.jsonPick import *
    json = jsonPick( dataset_name )
    applyJSON(process, json )


# Sequence & path definition -------------------------------------------------

process.load('CMGTools.H2TauTau.h2TauTau_cff')

# running only the tauMu selection and counting
process.tauMuBaselinePath = cms.Path(
    process.cmgTauMuFullSel +
    process.tauMuFullSelCount
    )

# OUTPUT definition ----------------------------------------------------------