Esempio n. 1
0
                    cut='dM < 0.11',
                    path=main)

# perform vertex fit of J/psi candidates
vertex.KFit('J/psi:ee', conf_level=0.0, path=main)

# combine J/psi and KS candidates to form B0 candidates
ma.reconstructDecay('B0 -> J/psi:ee K_S0:merged',
                    cut='Mbc > 5.2 and abs(deltaE) < 0.3',
                    path=main)

# match reconstructed with MC particles
ma.matchMCTruth('B0', path=main)

# build the rest of the event
ma.buildRestOfEvent('B0', fillWithMostLikely=True, path=main)

# call flavor tagging
ft.flavorTagger('B0', path=main)

# remove B0 candidates without a valid flavor information
ma.applyCuts('B0', 'qrOutput(FBDT) > -2', path=main)

# fit B vertex on the tag-side
vertex.TagV('B0', constraintType='tube', fitAlgorithm='Rave', path=main)

# perform best candidate selection
#b2.set_random_seed('USBelleIISummerSchool')
#ma.rankByHighest('B0', variable='random', numBest=1, path=main)

# create list of variables for output ntuple
                    path=my_path)

ma.reconstructDecay(decayString='K_S0 -> pi+:good pi-:good',
                    cut='0.480<=M<=0.516',
                    dmID=1,
                    path=my_path)
ma.reconstructDecay(decayString='pi0  -> gamma:all gamma:all',
                    cut='0.115<=M<=0.152',
                    dmID=1,
                    path=my_path)
ma.reconstructDecay(decayString='B0   -> K_S0 pi0',
                    cut='5.2 < Mbc < 5.3 and -0.3 < deltaE < 0.2',
                    path=my_path)

ma.matchMCTruth(list_name='B0', path=my_path)
ma.buildRestOfEvent(target_list_name='B0', path=my_path)

# The momentum cuts used to be hard-coded in the continuum suppression module. They can now be applied
# via this mask. The nCDCHits requirement is new, and is recommended to remove VXD-only fake tracks.
cleanMask = ('cleanMask', 'nCDCHits > 0 and useCMSFrame(p)<=3.2', 'p >= 0.05 and useCMSFrame(p)<=3.2')
ma.appendROEMasks(list_name='B0',
                  mask_tuples=[cleanMask],
                  path=my_path)

ma.buildContinuumSuppression(list_name='B0',
                             roe_mask='cleanMask',
                             path=my_path)

# Define the variables for training.
#  For details, please see: https://confluence.desy.de/display/BI/Continuum+Suppression+Framework
#  Note that KSFWVariables takes the optional additional argument FS1, to return the variables calculated from the
if __name__ == '__main__':

    args = GetCmdArgs()
    os.makedirs(os.path.dirname(args.out_file), exist_ok=True)

    # Load the input skim file
    path = ma.create_path()
    ma.inputMdstList('MC9', filelist=[], path=path)
    # ma.inputMdstList('default', filelist=[], path=path)

    ma.applyCuts(particle_list,
                 'nCleanedTracks(dr<2 and abs(dz)<4) <= 12',
                 path=path)

    # Build some event specific ROE and continuum vars
    ma.buildRestOfEvent(particle_list, path=path)
    ROEMask = ('ROE', IPtrack_cut, gamma_cut)
    ma.appendROEMasks(particle_list, [ROEMask], path=path)
    ma.buildContinuumSuppression(particle_list, roe_mask='ROE', path=path)

    # Apply the smartBKG NN model
    # Will use extraInfo saved as training labels later,
    # need to be flattened before training to 0 or 1
    NNApplyModule_m = NNApplyModule(
        model_file=args.model,
        model_type='combined-wideCNN',
        threshold=0.,
        # threshold=args.threshold,
        extra_info_var='smartBKG')
    # dead_path = b2.create_path()
    # NNApplyModule_m.if_false(dead_path)
Esempio n. 4
0
bp.add_beamparameters(main_path,'Y4S')
ma.inputMdst('MC10', inputFilename, path=main_path)
sv.goodBelleKshort(path=main_path)
sg.stdPhotons('loose', path=main_path)
sc.stdPi('95eff', path=main_path)
ma.applyCuts('gamma:loose','1.4 < E < 4', path=main_path)
krescuts = " and daughterInvM(0,1,2) < 2 and daughterInvM(0,1) > 0.6 and daughterInvM(0,1) < 0.9"
#reconstructDecay(Kres+":all -> pi+:good pi-:good K_S0:all", krescuts)
ma.reconstructDecay("B0:signal -> pi+:95eff pi-:95eff K_S0:legacyGoodKS gamma:loose",
        "Mbc > 5.2 and deltaE < 0.2 and deltaE > -0.2 and  -0.65 < daughter(1, cosTheta) < 0.85"+krescuts, path=main_path)
ma.vertexRave('B0:signal',0.0001, 'B0 -> ^pi+ ^pi- ^K_S0 gamma', path=main_path)
#vertexTree('B0:signal',0.0001)

ma.rankByHighest('B0:signal',ratingVar, 1, outputVariable='myRating', path=main_path)

ma.buildRestOfEvent('B0:signal', path=main_path)


# define the "cleaner" mask
eclCut = '[E > 0.062 and abs(clusterTiming) < 18 and clusterReg==1] or \
[E>0.060 and abs(clusterTiming) < 20 and clusterReg==2] or \
[E>0.056 and abs(clusterTiming) < 44 and clusterReg==3]'
cleanMask = ('cleanMask', 'abs(d0) < 10.0 and abs(z0) < 20.0', eclCut)

# append both masks to ROE
ma.appendROEMasks('B0:signal', [cleanMask], path=main_path)

# choose one mask which is applied
ma.buildContinuumSuppression('B0:signal', 'cleanMask', path=main_path)

ma.matchMCTruth('B0:signal', path=main_path)
                    cut='5.2 < Mbc < 5.29 and abs(deltaE) < 1.0',
                    dmID=1,
                    path=my_path)

ma.matchMCTruth(list_name='B+:tag', path=my_path)

# 3. reconstruct Upsilon(4S) -> Btag+ Bsig- -> Btag+ mu-
ma.reconstructDecay(decayString='Upsilon(4S) -> B-:tag mu+:loose',
                    cut="",
                    path=my_path)

# perform MC matching (MC truth asociation)
ma.matchMCTruth(list_name='Upsilon(4S)', path=my_path)

# 5. build rest of the event
ma.buildRestOfEvent(target_list_name='Upsilon(4S)', path=my_path)

# 6. Select variables that we want to store to ntuple
d_vars = vc.mc_truth + vc.kinematics + vc.inv_mass
b_vars = vc.mc_truth + \
    vc.deltae_mbc + \
    vu.create_aliases_for_selected(list_of_variables=d_vars,
                                   decay_string='B- -> ^D0 pi-') + \
    vu.create_aliases(list_of_variables=['decayModeID'],
                      wrapper='daughter(0,extraInfo(variable))',
                      prefix="D")
mu_vars = vc.mc_truth

u4s_vars = vc.mc_truth + \
    vc.roe_multiplicities + \
    vc.recoil_kinematics + \
Esempio n. 6
0
def reconstruction(input_file, output_file):
    my_path = b2.create_path()
    ma.inputMdst("default", input_file, my_path)

    # Find decay name from the input file name
    decay_name = "_".join(input_file.split("/")[-1].split("_")[0:2])

    # Load configuration file
    config = yaml.safe_load(open("config/reco_config.yaml"))
    options = config[decay_name]

    # Parse list of subdecays in decay chain
    decays = options["sub_decays"]
    decays = DecayList(decays)

    # Create particle lists for final state particles
    fsps = decays.get_fsps()
    for particle in fsps:
        ma.fillParticleList(particle, "", path=my_path)

    # Reconstruct requested decay chains
    for decay in decays:
        ma.reconstructDecay(str(decay), "", path=my_path)

    # Perform truth matching for requested particles
    truth_match_particles = decays.mothers
    for truth_match_particle in truth_match_particles:
        ma.looseMCTruth(truth_match_particle, path=my_path)

    # Perform vertex fitting
    head = decays.get_head()
    vtx_decay_string = decays.get_chain()
    print(vtx_decay_string)

    vx.vertexRave(head, 0, vtx_decay_string, constraint="iptube", path=my_path)

    # ma.rankByLowest("B0", 'chiProb', numBest=3, outputVariable='B_vtx_rank', path=my_path)
    # ma.variables.addAlias('B_vtx_rank', 'extraInfo(B_vtx_rank)')
    ma.buildRestOfEvent(head, path=my_path)

    # Tag-side
    vx.TagV(head, "breco", 0.001, path=my_path)

    ma.buildEventKinematics(path=my_path)
    ma.buildEventShape(path=my_path)

    # Create centre-of-mass frame variables
    cms_kinematics = vu.create_aliases(
        vc.kinematics, "useCMSFrame({variable})", prefix="CMS"
    )

    variables = [
        item
        for sublist in [
            vc.kinematics,
            cms_kinematics,
            vc.deltae_mbc,
            vc.inv_mass,
            vc.event_shape,
            vc.vertex,
            vc.mc_truth,
            vc.mc_kinematics,
            vc.mc_vertex,
            vc.mc_tag_vertex,
        ]
        for item in sublist
    ]

    trees = yaml.safe_load(open("config/tree_names.yaml"))
    for particle in decays.all_particles:
        ma.variablesToNtuple(
            particle,
            variables,
            filename=output_file,
            treename=trees[particle],
            path=my_path,
        )

    b2.process(my_path)
    print(b2.statistics)
                    path=main)

ma.reconstructDecay(decayString='K_S0 -> pi+:good pi-:good',
                    cut='0.480<=M<=0.516',
                    dmID=1,
                    path=main)
ma.reconstructDecay(decayString='pi0  -> gamma:all gamma:all',
                    cut='0.115<=M<=0.152',
                    dmID=1,
                    path=main)
ma.reconstructDecay(decayString='B0   -> K_S0 pi0',
                    cut='5.2 < Mbc < 5.3 and -0.3 < deltaE < 0.2',
                    path=main)

ma.matchMCTruth(list_name='B0', path=main)
ma.buildRestOfEvent(list_name='B0', path=main)

# The momentum cuts used to be hard-coded in the continuum suppression module. They can now be applied
# via this mask. The nCDCHits requirement is new, and is recommended to remove VXD-only fake tracks.
cleanMask = ('cleanMask', 'nCDCHits > 0 and useCMSFrame(p)<=3.2',
             'p >= 0.05 and useCMSFrame(p)<=3.2')
ma.appendROEMasks(list_name='B0', mask_tuples=[cleanMask], path=main)

ma.buildContinuumSuppression(list_name='B0', roe_mask='cleanMask', path=main)

# Define the variables for training.
#  For details, please see: https://confluence.desy.de/display/BI/Continuum+Suppression+Framework
#  Note that KSFWVariables takes the optional additional argument FS1, to return the variables calculated from the
#  signal-B final state particles.
#  CleoCone also takes the optional additional argument ROE, to return the cones calculated from ROE particles only.
trainVars = [