示例#1
0
def main():

    from DIRAC.Core.Base import Script

    ### make_CTA_DST options ###############################################
    Script.registerSwitch("T:", "tellist=", "Tellist", setTellist)
    Script.registerSwitch("N:", "nevent=", "Nevent", setNevent)
    Script.registerSwitch("p:", "run_number=",
                          "Run Number (set automatically)", setRunNumber)
    ### other options ###############################################
    Script.registerSwitch("V:", "version=", "HAP version", setVersion)

    Script.parseCommandLine(ignoreErrors=True)

    args = Script.getPositionalArgs()

    if len(args) < 1:
        Script.showHelp()

    if tellist == None or version == None:
        Script.showHelp()
        jobReport.setApplicationStatus('Options badly specified')
        DIRAC.exit(-1)

    from CTADIRAC.Core.Workflow.Modules.HapRootMacro import HapRootMacro
    from CTADIRAC.Core.Utilities.SoftwareInstallation import checkSoftwarePackage
    from CTADIRAC.Core.Utilities.SoftwareInstallation import installSoftwarePackage
    from CTADIRAC.Core.Utilities.SoftwareInstallation import getSoftwareEnviron
    from CTADIRAC.Core.Utilities.SoftwareInstallation import localArea
    from CTADIRAC.Core.Utilities.SoftwareInstallation import sharedArea
    from DIRAC.Core.Utilities.Subprocess import systemCall
    from DIRAC.WorkloadManagementSystem.Client.JobReport import JobReport

    jobID = os.environ['JOBID']
    jobID = int(jobID)
    jobReport = JobReport(jobID)

    HapPack = 'HAP/' + version + '/HAP'

    packs = ['HESS/v0.2/lib', 'HESS/v0.3/root', HapPack]

    for package in packs:
        DIRAC.gLogger.notice('Checking:', package)
        if sharedArea:
            if checkSoftwarePackage(package, sharedArea())['OK']:
                DIRAC.gLogger.notice('Package found in Shared Area:', package)
                continue
        if localArea:
            if checkSoftwarePackage(package, localArea())['OK']:
                DIRAC.gLogger.notice('Package found in Local Area:', package)
                continue
            if installSoftwarePackage(package, localArea())['OK']:
                continue
        DIRAC.gLogger.error('Check Failed for software package:', package)
        DIRAC.gLogger.error('Software package not available')
        DIRAC.exit(-1)

    hr = HapRootMacro()
    hr.setSoftwarePackage(HapPack)

    telconf = os.path.join(localArea(),
                           'HAP/%s/config/%s' % (version, tellist))
    infile = build_infile()
    infilestr = '"' + infile + '"'
    telconfstr = '"' + telconf + '"'
    args = [str(int(run_number)), infilestr, telconfstr]

    try:
        args.extend([nevent])
    except NameError:
        DIRAC.gLogger.info('nevent arg not used')

    DIRAC.gLogger.notice('make_CTA_DST macro Arguments:', args)
    hr.rootMacro = '/hapscripts/dst/make_CTA_DST.C+'
    hr.rootArguments = args
    DIRAC.gLogger.notice('Executing Hap make_CTA_DST macro')
    res = hr.execute()

    if not res['OK']:
        DIRAC.gLogger.error('Failed to execute make_CTA_DST macro')
        jobReport.setApplicationStatus('Failure during make_CTA_DST')
        DIRAC.exit(-1)

############ check existance of output file ####
    filedst = 'dst_CTA_%08d' % int(run_number) + '.root'

    if not os.path.isfile(filedst):
        DIRAC.gLogger.error('dst file not found:', filedst)
        jobReport.setApplicationStatus('make_CTA_DST.C: DST file not created')
        DIRAC.exit(-1)

    fileout = 'dst_' + part_type + '_run' + run_number + '.root'
    cmd = 'mv ' + filedst + ' ' + fileout
    os.system(cmd)

    ###################Check std out #############################
    DIRAC.gLogger.notice('Executing DST Check step0')

    ret = getSoftwareEnviron(HapPack)
    if not ret['OK']:
        error = ret['Message']
        DIRAC.gLogger.error(error, HapPack)
        DIRAC.exit(-1)

    hapEnviron = ret['Value']
    hessroot = hapEnviron['HESSROOT']
    check_script = hessroot + '/hapscripts/dst/check_dst0.csh'
    cmdTuple = [check_script]
    ret = systemCall(0, cmdTuple, sendOutput)

    if not ret['OK']:
        DIRAC.gLogger.error('Failed to execute DST Check step0')
        jobReport.setApplicationStatus('Check_dst0: Failed')
        DIRAC.exit(-1)

    status, stdout, stderr = ret['Value']
    if status == 1:
        jobReport.setApplicationStatus(
            'Check_dst0: Big problem during the DST production')
        DIRAC.gLogger.error(
            'DST Check step0 reports: Big problem during the DST production')
        DIRAC.exit(-1)
    if status == 2:
        jobReport.setApplicationStatus('Check_dst0: No triggered events')
        DIRAC.gLogger.notice('DST Check step0 reports: No triggered events')
        DIRAC.exit()

############# run the CheckDST macro #################
    DIRAC.gLogger.notice('Executing DST check step1')
    hr.rootMacro = '/hapscripts/dst/CheckDST.C+'
    fileoutstr = '"' + fileout + '"'
    args = [fileoutstr]
    DIRAC.gLogger.notice('CheckDST macro Arguments:', args)
    hr.rootArguments = args
    DIRAC.gLogger.notice('Executing Hap CheckDST macro')
    res = hr.execute()

    if not res['OK']:
        DIRAC.gLogger.error('Failure during DST Check step1')
        jobReport.setApplicationStatus('Check_dst1: Failed')
        DIRAC.exit(-1)


#######################Check std out of CheckDST macro ##########################
    DIRAC.gLogger.notice('Executing DST Check step2')
    check_script = hessroot + '/hapscripts/dst/check_dst2.csh'
    cmdTuple = [check_script]
    ret = systemCall(0, cmdTuple, sendOutput)

    if not ret['OK']:
        DIRAC.gLogger.error('Failed to execute DST Check step2')
        jobReport.setApplicationStatus('Check_dst2: Failed')
        DIRAC.exit(-1)

    status, stdout, stderr = ret['Value']
    if status == 1:
        jobReport.setApplicationStatus(
            'DST Check step2: Big problem during the DST production')
        DIRAC.gLogger.error(
            'DST Check step2 reports: Big problem during the DST production')
        DIRAC.exit(-1)
    if status == 2:
        jobReport.setApplicationStatus('DST Check step2: No triggered events')
        DIRAC.gLogger.notice('DST Check step2 reports: No triggered events')
        DIRAC.exit()

    DIRAC.exit()
示例#2
0
def main():

    from DIRAC.Core.Base import Script

    #### eventio_cta options ##########################################
    Script.registerSwitch("T:", "tellist=", "Tellist", setTellist)
    Script.registerSwitch("F:", "Nfirst_mcevt=", "Nfirst_mcevt",
                          setNfirst_mcevt)
    Script.registerSwitch("L:", "Nlast_mcevt=", "Nlast_mcevt", setNlast_mcevt)
    ## add other eventio_cta options ################################
    #  Script.registerSwitch( "N:", "num=", "Num", setNum)
    ##  Script.registerSwitch( "L:", "limitmc=", "Limitmc", setLimitmc)
    #  Script.registerSwitch( "S:", "telidoffset=", "Telidoffset", setTelidoffset)
    Script.registerSwitch("P:", "pixelslices=", "setPixelslices (true/false)",
                          setPixelslices)
    Script.registerSwitch("p:", "run_number=",
                          "Run Number (set automatically)", setRunNumber)
    ### other options ###############################################
    Script.registerSwitch("V:", "version=", "HAP version", setVersion)

    Script.parseCommandLine(ignoreErrors=True)

    args = Script.getPositionalArgs()

    if len(args) < 1:
        Script.showHelp()

    if tellist == None or version == None:
        Script.showHelp()
        jobReport.setApplicationStatus('Options badly specified')
        DIRAC.exit(-1)

    from CTADIRAC.Core.Workflow.Modules.HapApplication import HapApplication
    from CTADIRAC.Core.Workflow.Modules.HapRootMacro import HapRootMacro
    from CTADIRAC.Core.Utilities.SoftwareInstallation import checkSoftwarePackage
    from CTADIRAC.Core.Utilities.SoftwareInstallation import installSoftwarePackage
    from CTADIRAC.Core.Utilities.SoftwareInstallation import getSoftwareEnviron
    from CTADIRAC.Core.Utilities.SoftwareInstallation import localArea
    from CTADIRAC.Core.Utilities.SoftwareInstallation import sharedArea
    from DIRAC.Core.Utilities.Subprocess import systemCall
    from DIRAC.WorkloadManagementSystem.Client.JobReport import JobReport

    jobID = os.environ['JOBID']
    jobID = int(jobID)
    jobReport = JobReport(jobID)

    HapPack = 'HAP/' + version + '/HAP'

    packs = ['HESS/v0.2/lib', 'HESS/v0.3/root', HapPack]

    for package in packs:
        DIRAC.gLogger.notice('Checking:', package)
        if sharedArea:
            if checkSoftwarePackage(package, sharedArea())['OK']:
                DIRAC.gLogger.notice('Package found in Shared Area:', package)
                continue
        if localArea:
            if checkSoftwarePackage(package, localArea())['OK']:
                DIRAC.gLogger.notice('Package found in Local Area:', package)
                continue
            if installSoftwarePackage(package, localArea())['OK']:
                continue
        DIRAC.gLogger.error('Check Failed for software package:', package)
        DIRAC.gLogger.error('Software package not available')
        DIRAC.exit(-1)

    telconf = os.path.join(localArea(),
                           'HAP/%s/config/%s' % (version, tellist))

    ha = HapApplication()
    ha.setSoftwarePackage(HapPack)
    ha.hapExecutable = 'eventio_cta'

    fileout = 'raw_' + part_type + '_run' + run_number + '.root'
    infile = build_infile()
    ha.hapArguments = ['-file', infile, '-o', fileout, '-tellist', telconf]

    try:
        ha.hapArguments.extend(
            ['-Nfirst_mcevt', Nfirst_mcevt, '-Nlast_mcevt', Nlast_mcevt])
    except NameError:
        DIRAC.gLogger.info('Nfirst_mcevt/Nlast_mcevt options are not used')

    try:
        if (pixelslices == 'true'):
            ha.hapArguments.extend(['-pixelslices'])
    except NameError:
        DIRAC.gLogger.info('pixelslices option is not used')

    DIRAC.gLogger.notice('Executing Hap Converter Application')
    res = ha.execute()

    if not res['OK']:
        DIRAC.gLogger.error('Failed to execute eventio_cta Application')
        jobReport.setApplicationStatus('eventio_cta: Failed')
        DIRAC.exit(-1)

    if not os.path.isfile(fileout):
        error = 'raw file was not created:'
        DIRAC.gLogger.error(error, fileout)
        jobReport.setApplicationStatus('eventio_cta: RawData not created')
        DIRAC.exit(-1)

###################### Check RAW DATA: step0 #######################
    hr = HapRootMacro()
    hr.setSoftwarePackage(HapPack)

    DIRAC.gLogger.notice('Executing RAW check step0')
    hr.rootMacro = '/hapscripts/dst/Open_Raw.C+'
    outfilestr = '"' + fileout + '"'
    args = [outfilestr]
    DIRAC.gLogger.notice('Open_Raw macro Arguments:', args)
    hr.rootArguments = args
    DIRAC.gLogger.notice('Executing Hap Open_Raw macro')
    res = hr.execute()

    if not res['OK']:
        DIRAC.gLogger.error('Open_Raw: Failed')
        DIRAC.exit(-1)


#####################Check RAW DATA: step1 ##################
    DIRAC.gLogger.notice('Executing Raw Check step1')

    ret = getSoftwareEnviron(HapPack)
    if not ret['OK']:
        error = ret['Message']
        DIRAC.gLogger.error(error, HapPack)
        DIRAC.exit(-1)

    hapEnviron = ret['Value']
    hessroot = hapEnviron['HESSROOT']
    check_script = hessroot + '/hapscripts/dst/check_raw.csh'
    cmdTuple = [check_script]
    ret = systemCall(0, cmdTuple, sendOutput)

    if not ret['OK']:
        DIRAC.gLogger.error('Failed to execute RAW Check step1')
        jobReport.setApplicationStatus('Check_raw: Failed')
        DIRAC.exit(-1)

    status, stdout, stderr = ret['Value']
    if status == 1:
        jobReport.setApplicationStatus(
            'RAW Check step1: Big problem during RAW production')
        DIRAC.gLogger.error('Check_raw: Big problem during RAW production')
        DIRAC.exit(-1)

    DIRAC.exit()
示例#3
0
def main():

    from DIRAC.Core.Base import Script
    ### DoCtaIrf options ##########################################################
    Script.registerSwitch("A:", "analysis=", "Analysis Type", setAnalysisType)
    Script.registerSwitch("C:", "cuts=", "Cuts Config", setCutsConfig)
    Script.registerSwitch("R:", "runlist=", "Runlist", setRunlist)
    Script.registerSwitch("Z:", "zenith=", "Zenith", setZenith)
    Script.registerSwitch("O:", "offset=", "Offset", setOffset)
    Script.registerSwitch("M:", "energy=", "Energy Method", setEnergyMethod)
    Script.registerSwitch("T:", "arrayconfig=", "Array Configuration",
                          setArrayConfig)
    Script.registerSwitch("P:", "particle=", "Particle Type", setParticleType)
    ## other options
    Script.registerSwitch("V:", "version=", "HAP version", setVersion)

    Script.parseCommandLine(ignoreErrors=True)

    args = Script.getPositionalArgs()
    if len(args) < 1:
        Script.showHelp()

    from CTADIRAC.Core.Workflow.Modules.HapApplication import HapApplication
    from CTADIRAC.Core.Workflow.Modules.HapRootMacro import HapRootMacro
    from CTADIRAC.Core.Utilities.SoftwareInstallation import checkSoftwarePackage
    from CTADIRAC.Core.Utilities.SoftwareInstallation import installSoftwarePackage
    from CTADIRAC.Core.Utilities.SoftwareInstallation import getSoftwareEnviron
    from CTADIRAC.Core.Utilities.SoftwareInstallation import localArea
    from CTADIRAC.Core.Utilities.SoftwareInstallation import sharedArea
    from DIRAC.Core.Utilities.Subprocess import systemCall
    from DIRAC.WorkloadManagementSystem.Client.JobReport import JobReport

    jobID = os.environ['JOBID']
    jobID = int(jobID)
    jobReport = JobReport(jobID)

    ha = HapApplication()

    HapPack = 'HAP/' + version + '/HAP'

    packs = ['HESS/v0.2/lib', 'HESS/v0.3/root', HapPack]

    for package in packs:
        DIRAC.gLogger.notice('Checking:', package)
        if sharedArea:
            if checkSoftwarePackage(package, sharedArea())['OK']:
                DIRAC.gLogger.notice('Package found in Shared Area:', package)
                continue
        if localArea:
            if checkSoftwarePackage(package, localArea())['OK']:
                DIRAC.gLogger.notice('Package found in Local Area:', package)
                continue
            if installSoftwarePackage(package, localArea())['OK']:
                continue
        DIRAC.gLogger.error('Check Failed for software package:', package)
        DIRAC.gLogger.error('Software package not available')
        DIRAC.exit(-1)

    ha.setSoftwarePackage(HapPack)

    ha.hapExecutable = 'DoCtaIrf'

    runlistdir = os.environ['PWD']

    build_infile(runlist)

    ha.hapArguments = [
        analysistype, cutsconfig, runlistdir, runlist, zenith, offset,
        arrayconfig, energymethod, particle
    ]

    DIRAC.gLogger.notice('Executing Hap Application')
    res = ha.execute()

    if not res['OK']:
        DIRAC.gLogger.error('Failed to execute Hap Application')
        jobReport.setApplicationStatus('Hap Application: Failed')
        DIRAC.exit(-1)

###################### Check TTree Output File #######################
    outfile = 'MVAFile_' + runlist + ".root"

    if not os.path.isfile(outfile):
        error = 'TTree file was not created:'
        DIRAC.gLogger.error(error, outfile)
        jobReport.setApplicationStatus('DoCtaIrf: TTree file not created')
        DIRAC.exit(-1)

###################### Quality Check for TTree Output File: step0######################
    hr = HapRootMacro()
    hr.setSoftwarePackage(HapPack)

    DIRAC.gLogger.notice('Executing TTree check step0')
    hr.rootMacro = '/hapscripts/mva/Open_TT.C+'
    outfilestr = '"' + outfile + '"'
    args = [outfilestr]
    DIRAC.gLogger.notice('Open_TT macro Arguments:', args)
    hr.rootArguments = args
    DIRAC.gLogger.notice('Executing Hap Open_TT macro')
    res = hr.execute()

    if not res['OK']:
        DIRAC.gLogger.error('Open_TT: Failed')
        DIRAC.exit(-1)

#########################Quality Check for TTree Output File: step1####################
    DIRAC.gLogger.notice('Executing TTree check step1')

    ret = getSoftwareEnviron(HapPack)
    if not ret['OK']:
        error = ret['Message']
        DIRAC.gLogger.error(error, HapPack)
        DIRAC.exit(-1)

    hapEnviron = ret['Value']
    hessroot = hapEnviron['HESSROOT']

    check_script = hessroot + '/hapscripts/mva/check_TT.csh'

    cmdTuple = [check_script]
    ret = systemCall(0, cmdTuple, sendOutput)

    if not ret['OK']:
        DIRAC.gLogger.error('Failed to execute TTree Check step1')
        jobReport.setApplicationStatus('Check_TTree: Failed')
        DIRAC.exit(-1)


#############################################

    DIRAC.exit()