Пример #1
0
def main(options):

    global program
    program = propyte.Program(options=options,
                              name=name,
                              version=version,
                              logo=logo)
    global log
    from propyte import log

    log.info("")

    input_data_filename = options["--data"]

    log.info(
        "input data file: {filename}".format(filename=input_data_filename))

    log.debug("start to print log messages at various levels")

    log.debug("message at level DEBUG")
    log.info("message at level INFO")
    log.warning("message at level WARNING")
    log.error("message at level ERROR")
    log.critical("message at level CRITICAL")

    log.debug("stop printing log messages at various levels")

    function_1()

    log.info("")

    program.terminate()
Пример #2
0
def main(options):

    global program
    program = propyte.Program(
        options = options,
        name    = name,
        version = version,
        logo    = logo
    )
    global log
    from propyte import log

    log.info("")

    input_data_filename = options["--data"]

    log.info("input data file: {filename}".format(
        filename = input_data_filename
    ))

    log.debug("start to print log messages at various levels")

    log.debug("message at level DEBUG")
    log.info("message at level INFO")
    log.warning("message at level WARNING")
    log.error("message at level ERROR")
    log.critical("message at level CRITICAL")

    log.debug("stop printing log messages at various levels")

    function_1()

    log.info("")

    program.terminate()
def main(options):

    utterance = options["--utterance"]

    global program
    program = propyte.Program(options=options,
                              name=name,
                              version=version,
                              logo=logo)
    global log
    from propyte import log

    log.warning("input utterance: {utterance}".format(utterance=utterance))
    response = abstraction.generate_response(utterance=utterance)
    log.warning("proposed response: {response}".format(response=response))

    program.terminate()
def main(options):

    utterance = options["--utterance"]

    global program
    program = propyte.Program(
        options = options,
        name    = name,
        version = version,
        logo    = logo
        )
    global log
    from propyte import log

    log.warning("input utterance: {utterance}".format(utterance = utterance))
    response = abstraction.generate_response(utterance = utterance)
    log.warning("proposed response: {response}".format(response = response))

    program.terminate()
Пример #5
0
def main(options):

    filename_log = options["--logfile"]

    global program
    program = propyte.Program(options=options,
                              name=name,
                              version=version,
                              logo=logo,
                              filename_log=filename_log)
    global log
    from propyte import log

    log.debug("message at level DEBUG")
    log.info("message at level INFO")
    log.warning("message at level WARNING")
    log.error("message at level ERROR")
    log.critical("message at level CRITICAL")

    program.terminate()
Пример #6
0
def main(options):

    filename_log = options["--logfile"]

    global program
    program = propyte.Program(
        options      = options,
        name         = name,
        version      = version,
        logo         = logo,
        filename_log = filename_log
    )
    global log
    from propyte import log

    log.debug("message at level DEBUG")
    log.info("message at level INFO")
    log.warning("message at level WARNING")
    log.error("message at level ERROR")
    log.critical("message at level CRITICAL")

    program.terminate()
Пример #7
0
def main(options):

    global program
    program = propyte.Program(options=options,
                              name=name,
                              version=version,
                              logo=logo)
    global log
    from propyte import log

    print("")

    filename_ROOT = options["--fileroot"]
    filename_CSV = options["--filecsv"]
    selection = options["--selection"]
    class_label = int(options["--classlabel"])
    name_tree = options["--tree"]
    maximum_number_of_events = None if options["--maxevents"].lower() == "none"\
                                  else int(options["--maxevents"])
    include_headings = options["--headings"].lower() == "true"

    if not os.path.isfile(os.path.expandvars(filename_ROOT)):
        log.error("file {filename} not found".format(filename=filename_ROOT))
        program.terminate()

    if os.path.isfile(os.path.expandvars(filename_CSV)):
        log.warning(
            "CSV file {filename} exists -- *append* data to file".format(
                filename=filename_CSV))
        print("")
        append = True
    else:
        append = False

    file_ROOT = abstraction.open_ROOT_file(filename_ROOT)
    tree = file_ROOT.Get(name_tree)
    number_of_events = tree.GetEntries()

    file_CSV = open(filename_CSV, "a")
    writer = csv.writer(file_CSV, delimiter=",")

    log.info(
        textwrap.dedent("""
        input ROOT file: {filename_ROOT}
        output CSV file: {filename_CSV}
        selection:       {selection}
        class label:     {class_label}
        """.format(filename_ROOT=filename_ROOT,
                   filename_CSV=filename_CSV,
                   selection=selection,
                   class_label=class_label)))

    print("")
    log.info("save variables of events to CSV {filename}".format(
        filename=filename_CSV))
    print("")

    progress = shijian.Progress()
    progress.engage_quick_calculation_mode()
    index_selected = 0
    detail = True
    for index, event in enumerate(tree):
        if select_event(event=event, selection=selection):
            index_selected = index_selected + 1
            if                                           \
                maximum_number_of_events is not None and \
                index_selected > maximum_number_of_events:
                break
            line = [
                #Variable_ttHbb(event = event, name = "Aplan_bjets"),
                Variable_ttHbb(event=event, name="Aplan_jets"),  #
                Variable_ttHbb(event=event, name="Centrality_all"),  #
                #Variable_ttHbb(event = event, name = "ClassifBDTOutput_6jsplit"),
                #Variable_ttHbb(event = event, name = "ClassifBDTOutput_basic"),
                #Variable_ttHbb(event = event, name = "ClassifBDTOutput_withReco_6jsplit"),
                #Variable_ttHbb(event = event, name = "ClassifBDTOutput_withReco_basic"),
                #Variable_ttHbb(event = event, name = "ClassifHPLUS_Semilep_HF_BDT200_Output"),
                Variable_ttHbb(event=event, name="dEtajj_MaxdEta"),  #
                Variable_ttHbb(event=event, name="dRbb_avg"),  #
                #Variable_ttHbb(event = event, name = "dRbb_MaxM"),
                Variable_ttHbb(event=event, name="dRbb_MaxPt"),  #
                #Variable_ttHbb(event = event, name = "dRbb_min"),
                #Variable_ttHbb(event = event, name = "dRbj_Wmass"),
                #Variable_ttHbb(event = event, name = "dRHl_MaxdR"),
                #Variable_ttHbb(event = event, name = "dRHl_MindR"),
                #Variable_ttHbb(event = event, name = "dRjj_min"),
                #Variable_ttHbb(event = event, name = "dRlepbb_MindR"),
                #Variable_ttHbb(event = event, name = "dRlj_MindR"),
                #Variable_ttHbb(event = event, name = "dRuu_MindR"),
                Variable_ttHbb(event=event, name="H1_all"),  #
                #Variable_ttHbb(event = event, name = "H4_all"),
                #Variable_ttHbb(event = event, name = "HhadT_nJets"),
                #Variable_ttHbb(event = event, name = "HiggsbbM"),
                #Variable_ttHbb(event = event, name = "HiggsjjM"),
                #Variable_ttHbb(event = event, name = "HT_all"),
                #Variable_ttHbb(event = event, name = "HT_jets"),
                #Variable_ttHbb(event = event, name = "Mbb_MaxM"),
                #Variable_ttHbb(event = event, name = "Mbb_MaxPt"),
                Variable_ttHbb(event=event, name="Mbb_MindR"),  #
                #Variable_ttHbb(event = event, name = "Mbj_MaxPt"),
                #Variable_ttHbb(event = event, name = "Mbj_MindR"),
                #Variable_ttHbb(event = event, name = "Mbj_Wmass"),
                #Variable_ttHbb(event = event, name = "met_met"),
                #Variable_ttHbb(event = event, name = "met_phi"),
                #Variable_ttHbb(event = event, name = "MHiggs"),
                #Variable_ttHbb(event = event, name = "Mjj_HiggsMass"),
                #Variable_ttHbb(event = event, name = "Mjjj_MaxPt"),
                #Variable_ttHbb(event = event, name = "Mjj_MaxPt"),
                #Variable_ttHbb(event = event, name = "Mjj_MindR"),
                #Variable_ttHbb(event = event, name = "Mjj_MinM"),
                #Variable_ttHbb(event = event, name = "mu"),
                #Variable_ttHbb(event = event, name = "Muu_MindR"),
                #Variable_ttHbb(event = event, name = "NBFricoNN_dil"),
                #Variable_ttHbb(event = event, name = "nBTags"),
                #Variable_ttHbb(event = event, name = "nBTags30"),
                #Variable_ttHbb(event = event, name = "nBTags50"),
                #Variable_ttHbb(event = event, name = "nBTags60"),
                #Variable_ttHbb(event = event, name = "nBTags70"),
                #Variable_ttHbb(event = event, name = "nBTags77"),
                #Variable_ttHbb(event = event, name = "nBTags80"),
                #Variable_ttHbb(event = event, name = "nBTags85"),
                #Variable_ttHbb(event = event, name = "nBTags90"),
                #Variable_ttHbb(event = event, name = "nBTagsFlatBEff_30"),
                #Variable_ttHbb(event = event, name = "nBTagsFlatBEff_40"),
                #Variable_ttHbb(event = event, name = "nBTagsFlatBEff_50"),
                #Variable_ttHbb(event = event, name = "nBTagsFlatBEff_60"),
                #Variable_ttHbb(event = event, name = "nBTagsFlatBEff_70"),
                #Variable_ttHbb(event = event, name = "nBTagsFlatBEff_77"),
                #Variable_ttHbb(event = event, name = "nBTagsFlatBEff_85"),

                #Variable_ttHbb(event = event, name = "nElectrons"),
                #Variable_ttHbb(event = event, name = "nHFJets"),
                Variable_ttHbb(event=event, name="NHiggs_30"),  #
                #Variable_ttHbb(event = event, name = "Njet_pt40"),
                #Variable_ttHbb(event = event, name = "Njet_pt40"),
                #Variable_ttHbb(event = event, name = "nJets"),
                #Variable_ttHbb(event = event, name = "nMuons"),
                #Variable_ttHbb(event = event, name = "nPrimaryVtx"),

                #Variable_ttHbb(event = event, name = "pT_jet3"),
                Variable_ttHbb(event=event, name="pT_jet5"),  #
                #Variable_ttHbb(event = event, name = "pTuu_MindR"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_b1higgsbhadtop_dR"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_bbhiggs_dR"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_BDT_output"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_BDT_output_6jsplit"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_BDT_output_truthMatchPattern"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_BDT_withH_output"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_BDT_withH_output_6jsplit"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_BDT_withH_output_truthMatchPattern"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_hadWb1Higgs_mass"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_higgsbhadtop_withH_dR"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_higgsbleptop_mass"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_higgsbleptop_withH_dR"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_higgslep_dR"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_higgsleptop_dR"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_higgs_mass"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_higgsq1hadW_mass"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_higgsttbar_withH_dR"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_leptophadtop_dR"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_leptophadtop_withH_dR"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_Ncombinations"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_nuApprox_recoBDT"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_nuApprox_recoBDT_6jsplit"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_nuApprox_recoBDT_withH"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_nuApprox_recoBDT_withH_6jsplit"),
                #Variable_ttHbb(event = event, name = "semilepMVAreco_ttH_Ht_withH"),
                #Variable_ttHbb(event = event, name = "ttHF_mva_discriminant"),

                #Variable_ttHbb(event = event, name = "el_d0sig[0]"),
                #Variable_ttHbb(event = event, name = "el_delta_z0_sintheta[0]"),
                #Variable_ttHbb(event = event, name = "el_e[0]"),
                #Variable_ttHbb(event = event, name = "el_eta[0]"),
                #Variable_ttHbb(event = event, name = "el_phi[0]"),
                #Variable_ttHbb(event = event, name = "el_pt[0]"),
                #Variable_ttHbb(event = event, name = "el_topoetcone20[0]"),

                #Variable_ttHbb(event = event, name = "mu_d0sig[0]"),
                #Variable_ttHbb(event = event, name = "mu_delta_z0_sintheta[0]"),
                #Variable_ttHbb(event = event, name = "mu_e[0]"),
                #Variable_ttHbb(event = event, name = "mu_eta[0]"),
                #Variable_ttHbb(event = event, name = "mu_phi[0]"),
                #Variable_ttHbb(event = event, name = "mu_pt[0]"),
                #Variable_ttHbb(event = event, name = "mu_topoetcone20[0]"),

                #Variable_ttHbb(event = event, name = "jet_e[0]"),
                #Variable_ttHbb(event = event, name = "jet_eta[0]"),
                #Variable_ttHbb(event = event, name = "jet_jvt[0]"),
                #Variable_ttHbb(event = event, name = "jet_mv2c10[0]"),
                #Variable_ttHbb(event = event, name = "jet_mv2c20[0]"),
                #Variable_ttHbb(event = event, name = "jet_phi[0]"),
                #Variable_ttHbb(event = event, name = "jet_pt[0]"),
                #Variable_ttHbb(event = event, name = "jet_semilepMVAreco_recoBDT_cand[0]"),
                #Variable_ttHbb(event = event, name = "jet_semilepMVAreco_recoBDT_cand_6jsplit[0]"),
                #Variable_ttHbb(event = event, name = "jet_semilepMVAreco_recoBDT_withH_cand[0]"),
                #Variable_ttHbb(event = event, name = "jet_semilepMVAreco_recoBDT_withH_cand_6jsplit[0]"),

                #Variable_ttHbb(event = event, name = "jet_e[1]"),
                #Variable_ttHbb(event = event, name = "jet_eta[1]"),
                #Variable_ttHbb(event = event, name = "jet_jvt[1]"),
                #Variable_ttHbb(event = event, name = "jet_mv2c10[1]"),
                #Variable_ttHbb(event = event, name = "jet_mv2c20[1]"),
                #Variable_ttHbb(event = event, name = "jet_phi[1]"),
                #Variable_ttHbb(event = event, name = "jet_pt[1]"),
                #Variable_ttHbb(event = event, name = "jet_semilepMVAreco_recoBDT_cand[1]"),
                #Variable_ttHbb(event = event, name = "jet_semilepMVAreco_recoBDT_cand_6jsplit[1]"),
                #Variable_ttHbb(event = event, name = "jet_semilepMVAreco_recoBDT_withH_cand[1]"),
                #Variable_ttHbb(event = event, name = "jet_semilepMVAreco_recoBDT_withH_cand_6jsplit[1]"),

                #Variable_ttHbb(event = event, name = "jet_e[2]"),
                #Variable_ttHbb(event = event, name = "jet_eta[2]"),
                #Variable_ttHbb(event = event, name = "jet_jvt[2]"),
                #Variable_ttHbb(event = event, name = "jet_mv2c10[2]"),
                #Variable_ttHbb(event = event, name = "jet_mv2c20[2]"),
                #Variable_ttHbb(event = event, name = "jet_phi[2]"),
                #Variable_ttHbb(event = event, name = "jet_pt[2]"),
                #Variable_ttHbb(event = event, name = "jet_semilepMVAreco_recoBDT_cand[2]"),
                #Variable_ttHbb(event = event, name = "jet_semilepMVAreco_recoBDT_cand_6jsplit[2]"),
                #Variable_ttHbb(event = event, name = "jet_semilepMVAreco_recoBDT_withH_cand[2]"),
                #Variable_ttHbb(event = event, name = "jet_semilepMVAreco_recoBDT_withH_cand_6jsplit[2]"),

                #Variable_ttHbb(event = event, name = "jet_e[3]"),
                #Variable_ttHbb(event = event, name = "jet_eta[3]"),
                #Variable_ttHbb(event = event, name = "jet_jvt[3]"),
                #Variable_ttHbb(event = event, name = "jet_mv2c10[3]"),
                #Variable_ttHbb(event = event, name = "jet_mv2c20[3]"),
                #Variable_ttHbb(event = event, name = "jet_phi[3]"),
                #Variable_ttHbb(event = event, name = "jet_pt[3]"),
                #Variable_ttHbb(event = event, name = "jet_semilepMVAreco_recoBDT_cand[3]"),
                #Variable_ttHbb(event = event, name = "jet_semilepMVAreco_recoBDT_cand_6jsplit[3]"),
                #Variable_ttHbb(event = event, name = "jet_semilepMVAreco_recoBDT_withH_cand[3]"),
                #Variable_ttHbb(event = event, name = "jet_semilepMVAreco_recoBDT_withH_cand_6jsplit[3]"),

                # large-R jets
                #Variable_ttHbb(event = event, name = "FirstLjetM"),
                #Variable_ttHbb(event = event, name = "FirstLjetPt"),
                #Variable_ttHbb(event = event, name = "HhadT_nLjets"),
                #Variable_ttHbb(event = event, name = "HT_ljets"),
                #Variable_ttHbb(event = event, name = "NBFricoNN_ljets"),
                #Variable_ttHbb(event = event, name = "nBjetOutsideLjet"),
                #Variable_ttHbb(event = event, name = "nJetOutsideLjet"),
                #Variable_ttHbb(event = event, name = "nLjet_m100"),
                #Variable_ttHbb(event = event, name = "nLjet_m50"),
                #Variable_ttHbb(event = event, name = "nLjets"),
                #Variable_ttHbb(event = event, name = "SecondLjetM"),
                #Variable_ttHbb(event = event, name = "SecondLjetPt"),
                #Variable_ttHbb(event = event, name = "ljet_C2[0]"),
                #Variable_ttHbb(event = event, name = "ljet_D2[0]"),
                #Variable_ttHbb(event = event, name = "ljet_e[0]"),
                #Variable_ttHbb(event = event, name = "ljet_eta[0]"),
                #Variable_ttHbb(event = event, name = "ljet_m[0]"),
                #Variable_ttHbb(event = event, name = "ljet_phi[0]"),
                #Variable_ttHbb(event = event, name = "ljet_pt[0]"),
                #Variable_ttHbb(event = event, name = "ljet_sd12[0]"),
                #Variable_ttHbb(event = event, name = "ljet_sd23[0]"),
                #Variable_ttHbb(event = event, name = "ljet_tau21[0]"),
                #Variable_ttHbb(event = event, name = "ljet_tau21_wta[0]"),
                #Variable_ttHbb(event = event, name = "ljet_tau32[0]"),
                #Variable_ttHbb(event = event, name = "ljet_tau32_wta[0]"),

                #rcjet_d12,
                #rcjet_d23,
                #rcjet_e,
                #rcjet_eta,
                #rcjet_phi,
                #rcjet_pt,
                Variable_ttHbb(name="class", value=class_label)
            ]
            if detail:
                log.info("event variable details:")
                log.info(
                    "\nnumber of variables: {number}".format(number=len(line)))
                table_contents = [["variable value", "variable type"]]
                for variable in line:
                    table_contents.append(
                        [str(variable.name()),
                         str(type(variable.value()))])
                print(pyprel.Table(contents=table_contents, ))
                detail = False
            if include_headings and not append:
                headings = [variable.name() for variable in line]
                writer.writerow(headings)
                include_headings = False
            values = [variable.value() for variable in line]
            writer.writerow(values)
        print(progress.add_datum(fraction=index / number_of_events))

    print("")
    log.info(
        "{number_selected} events of {number_total} passed selection".format(
            number_selected=index_selected, number_total=index))

    print("")

    program.terminate()