def create_analysis_path(
        b_ntuple_filename="B_ntuple.root",
        d_ntuple_filename="D_ntuple.root",
        mbc_range=(5.2, 5.3),
):
    """
    Example of a minimal reconstruction with a cut as a changeable function
    parameter, adapted from code in the ``B2T_Basics_3_FirstAnalysis.ipynb``
    notebook from b2 starter kit.
    """
    path = basf2.create_path()
    # this local inputMdstList will only be used when this steerig file is run locally, gbasf2 overrides it
    local_input_files = [
        "/group/belle2/dataprod/MC/MC13a/prod00009434/s00/e1003/4S/r00000/mixed/mdst/sub00/mdst_000001_prod00009434_task10020000001.root"
    ]
    mA.inputMdstList(
        environmentType="default",
        filelist=local_input_files,
        path=path,
    )
    stdK("higheff", path=path)
    stdPi("higheff", path=path)
    mA.reconstructDecay('D0:Kpi -> K-:higheff pi+:higheff',
                        '1.7 < M < 1.9',
                        path=path)
    # use try except to have this code work for both the old and new function names for the tree fit
    mA.matchMCTruth('D0:Kpi', path=path)
    mA.reconstructDecay('B- -> D0:Kpi pi-:higheff',
                        f"{mbc_range[0]} < Mbc < {mbc_range[1]}",
                        path=path)
    try:
        vx.treeFit('B+', 0.1, path=path)
    except AttributeError:
        vx.vertexTree('B+', 0.1, path=path)
    mA.setAnalysisConfigParams({"mcMatchingVersion": "BelleII"}, path)
    mA.matchMCTruth('B-', path=path)
    vm.addAlias("p_cms",
                "useCMSFrame(p)")  # include aliases to test if they work
    vm.addAlias("E_cms", "useCMSFrame(E)")
    mA.variablesToNtuple('D0:Kpi', [
        'M', 'p', 'E', 'E_cms', 'p_cms', 'daughter(0, kaonID)',
        'daughter(1, pionID)', 'isSignal', 'mcErrors'
    ],
                         filename=d_ntuple_filename,
                         treename="D",
                         path=path)
    mA.variablesToNtuple('B-', ['Mbc', 'deltaE', 'isSignal', 'mcErrors', 'M'],
                         filename=b_ntuple_filename,
                         treename="B",
                         path=path)
    return path
def get_variables():
    variables.addAlias("Rank_deltaE", "extraInfo(Rank_deltaE)")

    gamma_vars = vc.mc_truth + vc.kinematics + vc.cluster
    k_pi_vars = vc.pid + vc.mc_truth + vc.kinematics + vc.inv_mass

    kst_vars = vc.mc_truth + vc.kinematics + vc.inv_mass + ["decay_hash"] \
               + vu.create_daughter_aliases(k_pi_vars, 0, prefix='K', include_indices=False) \
               + vu.create_daughter_aliases(k_pi_vars, 1, prefix='pi', include_indices=False)

    cs_vars = vc.event_shape

    all_vars = vc.deltae_mbc + vc.mc_truth + vc.kinematics \
               + vu.create_daughter_aliases(kst_vars, 0, prefix='Kst', include_indices=False) \
               + vu.create_daughter_aliases(gamma_vars, 1, prefix='gamma', include_indices=False) \
               + ["decay_hash", "chiProb", "Rank_deltaE", "isExtendedSignal", "SignalRegion"] \
               + vc.recoil_kinematics \
               + cs_vars
    return all_vars
Exemple #3
0
defaultInputFoldername = "test"
inputFilename = defaultInputFoldername + '/' + defaultInputFilename
defaultOutputFilename = "test.root"
defaultOutputFoldername = "."
outputFilename = defaultOutputFoldername + '/' + defaultOutputFilename
for arg in sys.argv:
    print(arg)
if len(sys.argv) == 2:
    inputFilename = sys.argv[1]
if len(sys.argv) == 3:
    inputFilename = sys.argv[1]
    outputFilename = sys.argv[2]
use_central_database("GT_gen_prod_003.11_release-00-09-01-FEI-a")

from variables import variables
variables.addAlias('K_10_M', 'daughterInvariantMass(0,1,2)')

#DELETE THIS
variables.addAlias('K_10_K_S0_M', 'daughter(2,M)')
variables.addAlias('K_10_K_S0_Rho', 'daughter(2,dr)')
#

# load input ROOT file2
add_beamparameters(analysis_main, 'Y4S')
inputMdst('default', inputFilename)
#stdMu('all')
stdKshorts()
stdPhotons('loose')
stdPi0s()
stdPi('all')
applyCuts('gamma:loose', '1.4 < E < 4')
Exemple #4
0
def makeFSPs(input_file,  isdata):
    path = b2.create_path()
    inputMdstList(environmentType='default', filelist=input_file, path=path)
    printDataStore(path=path)
    # path.add_module('EventInfoPrinter')
    variables.addAlias('pi_k', 'pidPairProbabilityExpert(211, 321, ALL)')
    variables.addAlias('k_pi', 'pidPairProbabilityExpert(321, 211, ALL)')
    # electron
    impactcut = 'abs(d0)<0.5 and abs(z0)<2.0 '
    # NOTE For BtoXll skim
    # event level cuts: R2 and require a minimum number of tracks
    fillParticleList(decayString='pi+:eventShapeForSkims', cut='pt > 0.1', path=path)
    fillParticleList(decayString='gamma:eventShapeForSkims', cut='E > 0.1', path=path)
    buildEventShape(inputListNames=['pi+:eventShapeForSkims', 'gamma:eventShapeForSkims'],
                    allMoments=False,
                    foxWolfram=True,
                    harmonicMoments=False,
                    cleoCones=False,
                    thrust=False,
                    collisionAxis=False,
                    jets=False,
                    sphericity=False,
                    checkForDuplicates=False,
                    path=path)

    fillParticleList(decayString='e+:all',
                     cut=impactcut + ' and electronID > 0.5', path=path)
    # muon
    fillParticleList(decayString='mu+:all',
                     cut=impactcut + ' and muonID > 0.5', path=path)
    # pion
    fillParticleList(decayString='pi+:all',
                     cut=impactcut + ' and pi_k>0.1', path=path)
    # kaon
    fillParticleList(decayString='K+:all',
                     cut=impactcut + ' and k_pi>0.1', path=path)
    # gamma
    fillParticleList(decayString='gamma:all', cut='', path=path)
    if isdata:
        print(yellow, 'Momentum correction for FSPs', end)
        trackingMomentum(inputListNames=['mu+:all', 'e+:all', 'K+:all', 'pi+:all'], scale=1.00056, path=path)
    # Bremrecovery
    correctBremsBelle('e-:corrected', 'e-:all', 'gamma:all', True, 0.05, 0.05,
                      False, path=path)
    # Ks0
    stdKshorts( path=path)
    cutAndCopyList('K_S0:my_ks', 'K_S0:merged', 'goodBelleKshort==1', writeOut=False, path=path)
    matchMCTruth(list_name='K_S0:my_ks', path=path)
    # pi0
    stdPhotons('all', path=path)
    cutAndCopyList(
        'gamma:eff30_Jan2020',
        'gamma:all',
        '[clusterReg==1 and E>0.080] or [clusterReg==2 and E>0.030] or [clusterReg==3 and E>0.060]',
        path=path)
    reconstructDecay('pi0:all -> gamma:eff30_Jan2020 gamma:eff30_Jan2020',
                     '0.1215 < M < 0.1415 and E > 0.4 and abs(cosHelicityAngleMomentum)<0.8', path=path)
    #vertex.KFit('pi0:all', conf_level=0.0, path=path)
    vertex.KFit('pi0:all', conf_level=0.0,fit_type='mass', path=path)
    # K*0->K+ pi-
    reconstructDecay(decayString='K*0:all -> K+:all pi-:all',
                     cut='0.6 < M < 1.2', path=path)
    matchMCTruth(list_name='K*0:all', path=path)
    # K*+ -> K_s pi+
    reconstructDecay(decayString='K*+:ks -> K_S0:my_ks pi+:all',
                     cut='0.6 < M < 1.2', path=path)
    matchMCTruth(list_name='K*+:ks', path=path)
    # K*+ -> K+ pi0
    reconstructDecay(decayString='K*+:pi0 -> K+:all pi0:all',
                     cut='0.6 < M < 1.2', path=path)
    matchMCTruth(list_name='K*+:pi0', path=path)
    return path
    variables.addAlias('csv_Likelihood', 'transformedNetworkOutput(Likelihood_Probability,0.0,1.0)')



# flavor tagging
#FlavorTagger(
#    mode='Expert',
#    weightFiles='B2JpsiKs_mu',
#    categories=['Electron', 'Muon', 'KinLepton', 'Kaon', 'SlowPion', 'FastPion', 'Lambda', 'FSC', 'MaximumP*', 'KaonPion'])


# variable aliases

from variables import variables

variables.addAlias('flLenSig', 'significanceOfDistance')
variables.addAlias('CosTHel', 'decayAngle(0)')



# define Ntuple tools 

# with tracks, neutrals, pi0's and intermediate resonances
# are meant only for debugging
#
# for the real analysis, anything included in B0_ch1
# should be sufficient

toolsTrk = ['EventMetaData', 'pi+:all']
toolsTrk += ['Kinematics', '^pi+:all']
toolsTrk += ['MCKinematics', '^pi+:all']
Exemple #6
0
                 '/mdst_000001_prod00007426_task10020000001.root'
        outfile = 'test.root'
    else:
        infile = sys.argv[1]
        outfile = sys.argv[2]
    
    print(f"Input = {infile}")
    print(f"Output = {outfile}")
    
    ma.inputMdstList('default', [infile], path = mp)

    eff = 60
    stdSigmas(f'pi0eff{eff}', path = mp)
    ma.matchMCTruth('Sigma+:std', path = mp)
    
    va.addAlias('cosa', 'cosAngleBetweenMomentumAndVertexVector')
    va.addAlias('cosaXY', 'cosAngleBetweenMomentumAndVertexVectorInXYPlane')
    va.addAlias('abs_dM', 'abs(dM)')
    va.addAlias('M_noupdate', 'extraInfo(M_noupdate)')
    va.addAlias('p_noupdate', 'extraInfo(p_noupdate)')
    
    ntuple = ['M', 'p', 'chiProb', 'cosa', 'cosaXY', 'dr', 'dz', 'distance', 'isSignal', 'genMotherPDG']
    ntuple += ['IPX', 'IPY', 'IPZ']
    ntuple += create_aliases_for_selected(['protonID', 'pionID', 'dr', 'dz', 'p', 'isSignal'],
                                          'Sigma+ -> ^p+ pi0', prefix = ['p'])
    ntuple += create_aliases_for_selected(['mcP', 'p', 'M', 'distance', 'isSignal', 'genMotherPDG', 'M_noupdate', 'p_noupdate'],
                                          'Sigma+ -> p+ ^pi0', prefix = ['pi0'])
    
    ma.variablesToNtuple('Sigma+:std', ntuple, treename = f'sigma_eff{eff}', filename = outfile, path = mp)
    
    ma.fillParticleListFromMC('Sigma+:gen', '', path = mp)
Exemple #7
0
#
# Contributors: A. Zupanc (June 2014)
#
######################################################

from basf2 import *
from modularAnalysis import *

defaultInputFilename = "evtgen.root"
defaultInputFoldername = "test"
inputFilename = defaultInputFoldername + '/' + defaultInputFilename
defaultOutputFilename = "reco-tf2signal.root"
defaultOutputFoldername = "test"
outputFilename = defaultOutputFoldername + '/' + defaultOutputFilename
from variables import variables
variables.addAlias('KresM', 'daughterInvariantMass(0,1,2)')
for arg in sys.argv:
    print(arg)
if len(sys.argv) == 2:
    inputFilename = sys.argv[1]
if len(sys.argv) == 3:
    inputFilename = sys.argv[1]
    outputFilename = sys.argv[2]

# load input ROOT file
inputMdst('None', inputFilename)

# print contents of the DataStore before loading MCParticles
#printDataStore()

# create and fill gamma/e/mu/pi/K/p ParticleLists
Exemple #8
0
        outfile = 'sigma_std_belle.root'
    else:
        infile = sys.argv[1]
        outfile = sys.argv[2]

    print(f"Input = {infile}")
    print(f"Output = {outfile}")

    b2c.setupB2BIIDatabase(isMC=True)

    print_env()

    mp = b2.create_path()
    b2c.convertBelleMdstToBelleIIMdst(infile, path=mp)

    va.addAlias('cosa', 'cosAngleBetweenMomentumAndVertexVector')
    va.addAlias('cosaXY', 'cosAngleBetweenMomentumAndVertexVectorInXYPlane')
    va.addAlias('abs_dM', 'abs(dM)')
    va.addAlias('abs_dr', 'abs(dr)')
    va.addAlias('pid_ppi', 'atcPIDBelle(4,2)')
    va.addAlias('pid_pk', 'atcPIDBelle(4,3)')
    va.addAlias('pid_kpi', 'atcPIDBelle(3,2)')
    va.addAlias('ppi0_angle', 'daughterAngle(0, 1)')
    va.addAlias('p_decayAngle', 'decayAngle(0)')
    va.addAlias('pi0_decayAngle', 'decayAngle(1)')

    ma.fillParticleList('p+:good', 'pid_ppi > 0.6 and pid_pk > 0.6', path=mp)
    #     ma.vertexTree('pi0:mdst', ipConstraint = True, massConstraint = ['pi0'], path = mp)
    ma.reconstructDecay('Sigma+:std -> p+:good pi0:mdst',
                        '1.1 < M < 1.3',
                        path=mp)
Exemple #9
0
# Reconstruct D* decay
ma.reconstructDecay('D*+:my -> D0:my pi+:higheff', cut='1.90 < M < 2.25' , path=path)

# Fit vertex
#vx.treeFit('D*+:my', ipConstraint=True, updateAllDaughters=True, conf_level=0, path=path)
vx.treeFit('D*+:my', conf_level=0, path=path)

#ma.printList('D0:my', True, path=path)
#ma.printVariableValues('D0:my', ['IPX'], path=path)

#ma.printMCParticles(path=path)


from variables import variables as vm

vm.addAlias('xDstar',  'x')
vm.addAlias('yDstar',  'y')
vm.addAlias('zDstar',  'z')

vm.addAlias('xGenDstar',  'mcProductionVertexX')
vm.addAlias('yGenDstar',  'mcProductionVertexY')
vm.addAlias('zGenDstar',  'mcProductionVertexZ')

vm.addAlias('dxDstar',  'dx')
vm.addAlias('dyDstar',  'dy')
vm.addAlias('dzDstar',  'dz')

vm.addAlias('pDstar',  'p')
vm.addAlias('eDstar',  'E')
vm.addAlias('eCmsDstar',  'useCMSFrame(E)')
vm.addAlias('mDstar',  'M')
Exemple #10
0
#The directories might need to be modified
from basf2 import *
from modularAnalysis import *
from variables import variables

variables.addAlias('JpsiDMID','daughter(0,extraInfo(decayModeID))')
variables.addAlias('Jpsieid','daughter(0,eid)')
variables.addAlias('Jpsimuid','daughter(0,muid)')
variables.addAlias('myRank','extraInfo(myRank)')

inputMdstList('default',['~/B02JpsiKs/B02Jpsi_ee_Ks_mdst.root','~/B02JpsiKs/B02Jpsi_mumu_Ks_mdst.root'])

fillParticleList('mu+:all','')
fillParticleList('e+:all','')
fillParticleList('K_S0:mdst','')

reconstructDecay('J/psi:allee -> e+:all e-:all','2.7<M<3.2',1)
reconstructDecay('J/psi:allmumu -> mu+:all mu-:all','2.7<M<3.2',2)

cutAndCopyList('J/psi:goodee','J/psi:allee','formula(daughter(0,eid)+daughter(1,eid))>0.1')
cutAndCopyList('J/psi:goodmumu','J/psi:allmumu','formula(daughter(0,muid)+daughter(1,muid))>0.1')
copyLists('J/psi:good',['J/psi:goodee','J/psi:goodmumu'])

reconstructDecay('B0:jpsiks -> J/psi:good K_S0:mdst', 'Mbc > 5.2 and abs(deltaE) < 0.250')

rankByLowest('B0:jpsiks','formula(abs(daughter(0,SigM))+abs(daughter(1,SigM)))',1,'myRank')
matchMCTruth('B0:jpsiks')
set_log_level(LogLevel.ERROR)


Exemple #11
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
##########################
# variables to be put in ntuple
# author: Seema Choudhury
#########################
from modularAnalysis import *
from variables.collections import *
from variables.utils import *
import variables.collections as vc
import variables.utils as vu
from variables import variables
import ROOT as root

# Aliases
variables.addAlias('gengrandMotherPDG', 'genMotherPDG(1)')
variables.addAlias('genGrtgrandMotherPDG', 'genMotherPDG(2)')
variables.addAlias('genGrtGrtgrandMotherPDG', 'genMotherPDG(3)')
variables.addAlias('genGrtGrtGrtgrandMotherPDG', 'genMotherPDG(4)')
variables.addAlias('gengrandMotherID', 'genMotherID(1)')
variables.addAlias('genGrtgrandMotherID', 'genMotherID(2)')
variables.addAlias('genGrtGrtgrandMotherID', 'genMotherID(3)')
variables.addAlias('genGrtGrtGrtgrandMotherID', 'genMotherID(4)')
variables.addAlias('delta_z_ll',     'formula(daughter(1,dz)-daughter(2,dz))')
variables.addAlias('roeE_BKst0ee',    'useCMSFrame(roeE(cleanMaskB0:kst0ee))')
variables.addAlias('roeE_BKst0mumu',  'useCMSFrame(roeE(cleanMaskB0:kst0mumu))')
variables.addAlias('roeE_BKst1mumu',  'useCMSFrame(roeE(cleanMaskB+:kst_ksmumu))')
variables.addAlias('roeE_BKst1ee',    'useCMSFrame(roeE(cleanMaskB+:kst_ksee))')
variables.addAlias('roeE_BKst2mumu',  'useCMSFrame(roeE(cleanMaskB+:kst_pi0mumu))')
variables.addAlias('roeE_BKst2ee',    'useCMSFrame(roeE(cleanMaskB+:kst_pi0ee))')
variables.addAlias('d0_px',  'daughter(0,px)')
          path=mypath)

# fill an all photon and all charged particle (does not really matter which one) list
# clusterE: Returns ECL cluster's energy corrected for leakage and background
fillParticleList('gamma:all', 'clusterE > 0.1', path=mypath)  # neutral clusters
fillParticleList('e-:all', 'clusterE > 0.1', path=mypath)  # track matched clusters

# reconstruct a pseudo particles with different combinations (implicit charge conjugation)
reconstructDecay('vpho:1 -> gamma:all gamma:all', '', 1, path=mypath)  # two neutral '00'
reconstructDecay('vpho:2 -> gamma:all e-:all', '', 2, path=mypath)  # neutral and charged '0+' and '0-'
reconstructDecay('vpho:3 -> e-:all e+:all', '', 3, path=mypath)  # different charge '+-' and '-+'
reconstructDecay('vpho:4 -> e-:all e-:all', '', 4, path=mypath)  # same charge '++' and '--'
copyLists('vpho:bhabha', ['vpho:1', 'vpho:2', 'vpho:3', 'vpho:4'], path=mypath)

# aliases to make output better readable
variables.addAlias('combinationID', 'extraInfo(decayModeID)')
variables.addAlias('deltaPhi', 'daughterDiffOfClusterPhi(0, 1)')
variables.addAlias('deltaTheta', 'formula(daughter(0, clusterTheta) - daughter(1, clusterTheta))')
variables.addAlias('charge_0', 'daughter(0, charge)')
variables.addAlias('charge_1', 'daughter(1, charge)')
variables.addAlias('clusterE_0', 'daughter(0, clusterE)')
variables.addAlias('clusterE_1', 'daughter(1, clusterE)')
variables.addAlias('clusterTheta_0', 'daughter(0, clusterTheta)')
variables.addAlias('clusterTheta_1', 'daughter(1, clusterTheta)')
variables.addAlias('clusterPhi_0', 'daughter(0, clusterPhi)')
variables.addAlias('clusterPhi_1', 'daughter(1, clusterPhi)')

variables.addAlias('clusterECMS_0', 'daughter(0, useCMSFrame(clusterE))')
variables.addAlias('clusterECMS_1', 'daughter(1, useCMSFrame(clusterE))')
variables.addAlias('clusterThetaCMS_0', 'daughter(0, useCMSFrame(clusterTheta))')
variables.addAlias('clusterThetaCMS_1', 'daughter(1, useCMSFrame(clusterTheta))')
Exemple #13
0
#ma.fillParticleListFromMC(decayString='p+:gen', cut='', path=my_path)

ma.printDataStore(path=my_path)

ma.printList(list_name='gamma:gen', full=False, path=my_path)
ma.printList(list_name='e-:gen', full=False, path=my_path)
ma.printList(list_name='mu-:gen', full=False, path=my_path)
ma.printList(list_name='pi-:gen', full=False, path=my_path)
ma.printList(list_name='nu_e:gen', full=False, path=my_path)
ma.printList(list_name='nu_mu:gen', full=False, path=my_path)
#ma.printList(list_name='anti-nu_mu:gen', full=False, path=my_path)
#ma.printList(list_name='anti-nu_me:gen', full=False, path=my_path)

#ma.reconstructDecay('tau-:gen -> e-:gen anti-nu_e:gen nu_tau:gen', '', path=my_path)

var.addAlias('invMS1', 'invMassInLists(e-:gen, anti-nu_e:gen, nu_tau:gen)')
var.addAlias('invMS2', 'invMassInLists(e-:gen, nu_tau:gen)')
var.addAlias('invMS3', 'invMassInLists(anti-nu_e:gen, nu_tau:gen)')

mcVariables = [
    'p', 'px', 'py', 'pz', 'E', 'PDG', 'pt', 'invMS1', 'invMS2', 'invMS3'
]

#tauVariables = vc.inv_mass

variableList = vu.create_aliases_for_selected(list_of_variables=mcVariables,
                                              decay_string='^e-')  #+ #\
#vu.create_aliases_for_selected(list_of_variables=tauVariables,
#decay_string='^tau- -> ^e- ^anti-nu_e ^nu_tau')
#output_file = 'mcparticles.root'
#ma.variablesToNtuple(decayString='e+:gen',
Exemple #14
0
def make_ntuple():
    from variables import variables as va
    from variables.utils import create_aliases_for_selected

    va.addAlias('PIDppi', 'atcPIDBelle(4,2)')
    va.addAlias('PIDpk', 'atcPIDBelle(4,3)')
    va.addAlias('PIDkpi', 'atcPIDBelle(3,2)')
    # Lambda vertex position relative to IP
    va.addAlias('abs_dz', 'abs(dz)')
    # va.addAlias('abs_dr', 'abs(dr)')
    va.addAlias('cosaXY', 'cosAngleBetweenMomentumAndVertexVectorInXYPlane')
    # Track parameters relative to IP
    # d0 and z0 are relative to the origin!
    va.addAlias('min_dr', 'min(abs(daughter(0, dr)), abs(daughter(1, dr)))')
    va.addAlias('min_dz', 'min(abs(daughter(0, dz)), abs(daughter(1, dz)))')
    """Create a list of all the variables to be included in the final ntuple"""
    ntuple = []
    # May have more feature than needed.
    features = [
        'dr', 'dz', 'cosaXY', 'min_dr', 'min_dz', 'pt', 'pz', 'chiProb', 'p'
    ]
    features += create_aliases_for_selected(['PIDppi', 'PIDpk', 'PIDkpi', 'p'],
                                            'Lambda0 -> ^p+ ^pi-',
                                            prefix=['proton', 'pi'])
    spectator = ['isSignal', 'isPrimarySignal', 'mcPDG', 'genMotherPDG']
    spectator += ['IPX', 'IPY', 'IPZ', 'M', 'p', 'goodBelleLambda', 'distance']
    ntuple = features + spectator
    return ntuple
Exemple #15
0
enableMCTruth = True
# Change K resonance name here:
Kres = 'Xsd'
for arg in sys.argv:
    print(arg)
if len(sys.argv) == 2:
    inputFilename = sys.argv[1]
if len(sys.argv) == 3:
    inputFilename = sys.argv[1]
    outputFilename = sys.argv[2]
#use_central_database("GT_gen_prod_003.11_release-00-09-01-FEI-a")
#use_central_database("GT_gen_prod_004.11_Master-20171213-230000")
#use_central_database("GT_gen_prod_004.10_release-01-00-00")
use_central_database("analysis_AAT-parameters_release-01-02-03")
from variables import variables
variables.addAlias('pi0Likeness', 'extraInfo(Pi0_Prob)')
variables.addAlias('etaLikeness', 'extraInfo(Eta_Prob)')
variables.addAlias('myRating', 'extraInfo(myRating)')
variables.addAlias('myRatingCriteria', ratingVar)
variables.addAlias('B0_CosTBTO', 'cosTBTO')
variables.addAlias('B0_cc2', 'CleoCone(2)')
variables.addAlias('B0_hso12', 'KSFWVariables(hso12)')
variables.addAlias('B0_R2', 'R2')
variables.addAlias('B0_hso10', 'KSFWVariables(hso10)')
variables.addAlias('B0_hso14', 'KSFWVariables(hso14)')
variables.addAlias('B0_cc9', 'CleoCone(9)')
variables.addAlias('B0_CosTBz', 'cosTBz')
variables.addAlias('B0_ThrustO', 'thrustOm')
variables.addAlias('B0_ThrustB', 'thrustBm')
variables.addAlias('B0_cc4', 'CleoCone(4)')
variables.addAlias('B0_hso02', 'KSFWVariables(hso02)')
Exemple #16
0
    for var in envs:
        print("%30s = %s" % (var, os.getenv(var)))
    print()


print_env()

# Show input and output file info
print("Input: %s" % sys.argv[1])
print("Ouput: %s" % sys.argv[2])

mp = b2.create_path()

b2c.convertBelleMdstToBelleIIMdst(sys.argv[1], applyHadronBJSkim=True, path=mp)

variables.addAlias('pid_ppi', 'atcPIDBelle(4,2)')
variables.addAlias('pid_pk', 'atcPIDBelle(4,3)')
variables.addAlias('pid_kpi', 'atcPIDBelle(3,2)')

variables.addAlias('cosa', 'cosAngleBetweenMomentumAndVertexVector')
variables.addAlias('cosaXY', 'cosAngleBetweenMomentumAndVertexVectorInXYPlane')

mc_vars = [
    'isSignal', 'isPrimarySignal', 'mcPDG', 'genMotherPDG', 'nMCMatches'
]
kinematic_vars = ['M', 'p', 'pt', 'pz', 'phi', 'theta', 'charge', 'xp']
vertex_vars = [
    'cosa', 'cosaXY', 'chiProb', 'dr', 'dz', 'x', 'y', 'z', 'distance',
    'significanceOfDistance'
]
track_vars = ['d0', 'z0', 'd0Err']
Exemple #17
0
]

# Print env variables for check
print("Environmental Variables".center(80, '='))
for v in env_list:
    print_env(v)

# Show input and output file info
print("Input: %s" % sys.argv[1])
print("Ouput: %s" % sys.argv[2])

mp = b2.create_path()

b2c.convertBelleMdstToBelleIIMdst(sys.argv[1], applyHadronBJSkim=True, path=mp)

variables.addAlias('pid_ppi', 'atcPIDBelle(4,2)')
variables.addAlias('pid_pk', 'atcPIDBelle(4,3)')
variables.addAlias('pid_kpi', 'atcPIDBelle(3,2)')

variables.addAlias('cosa', 'cosAngleBetweenMomentumAndVertexVector')
variables.addAlias('cosaXY', 'cosAngleBetweenMomentumAndVertexVectorInXYPlane')
variables.addAlias('goodLambda', 'extraInfo(goodLambda)')

variables.addAlias('abs_dz', 'abs(dz)')
variables.addAlias('abs_dr', 'abs(dr)')

variables.addAlias('min_daug_d0', 'abs(min(daughter(0, d0), daughter(1, d0)))')
variables.addAlias('min_daug_z0', 'abs(min(daughter(0, z0), daughter(1, z0)))')

list_mc = [
    'isSignal', 'isPrimarySignal', 'mcPDG', 'genMotherPDG', 'mcE', 'mcP',
#tauMinus = sys.argv[1]

ma.inputMdstList(environmentType='default', filelist=inputFile, path=my_path)

######################################################
# create and fill the ParticleLists
######################################################

ma.fillParticleListFromMC('tau-:gen', '', path=my_path)
ma.fillParticleListFromMC('tau+:gen', '', path=my_path)

####################################################
# track cuts
######################################################

var.addAlias('EoverP', 'formula( ifNANgiveX( clusterE, -1 )/p )')

#######################################################
# EventShape and EventKinamatics modules
#######################################################
ma.buildEventShape(['tau-:gen', 'tau+:gen'],
                   foxWolfram=False,
                   cleoCones=False,
                   jets=False,
                   harmonicMoments=False,
                   allMoments=False,
                   collisionAxis=False,
                   sphericity=False,
                   thrust=True,
                   path=my_path)
ma.buildEventKinematics(['tau-:gen', 'tau+:gen'], path=my_path)
Exemple #19
0
defaultInputFoldername = "test"
inputFilename = defaultInputFoldername + '/' + defaultInputFilename
defaultOutputFilename = "test.root"
defaultOutputFoldername = "."
outputFilename = defaultOutputFoldername + '/' + defaultOutputFilename
for arg in sys.argv:
	print(arg)
if len(sys.argv)==2:
	inputFilename = sys.argv[1]
if len(sys.argv)==3:
	inputFilename = sys.argv[1]
	outputFilename = sys.argv[2]
#use_central_database("GT_gen_prod_003.11_release-00-09-01-FEI-a")
use_central_database("GT_gen_prod_004.11_Master-20171213-230000")
from variables import variables
variables.addAlias('myRating','extraInfo(myRating)')
variables.addAlias('pi0veto_M','extraInfo(pi0veto_M)')
variables.addAlias('pi0veto_mcPDG','extraInfo(pi0veto_mcPDG)')
variables.addAlias('pi0veto_cosTheta','extraInfo(pi0veto_cosTheta)')
variables.addAlias('pi0veto_gamma0_E','extraInfo(pi0veto_gamma0_E)')
variables.addAlias('pi0veto_gamma1_E','extraInfo(pi0veto_gamma1_E)')
variables.addAlias('pi0veto_gamma1_cosTheta','extraInfo(pi0veto_gamma1_cosTheta)')
variables.addAlias('pi0veto_gamma1_clusterE1E9','extraInfo(pi0veto_gamma1_clusterE1E9)')
variables.addAlias('pi0veto_gamma1_clusterE9E21','extraInfo(pi0veto_gamma1_clusterE9E21)')
variables.addAlias('pi0veto_gamma1_clusterTiming','extraInfo(pi0veto_gamma1_clusterTiming)')
variables.addAlias('pi0veto_gamma1_clusterAZM40','extraInfo(pi0veto_gamma1_clusterAbsZernikeMoment40)')
variables.addAlias('pi0veto_gamma1_clusterAZM51','extraInfo(pi0veto_gamma1_clusterAbsZernikeMoment51)')
variables.addAlias('pi0veto_gamma1_clusterSecondMoment','extraInfo(pi0veto_gamma1_clusterSecondMoment)')
variables.addAlias('eta0veto_gamma1_cosTheta','extraInfo(eta0veto_gamma1_cosTheta)')
variables.addAlias('eta0veto_gamma1_clusterE1E9','extraInfo(eta0veto_gamma1_clusterE1E9)')
variables.addAlias('eta0veto_gamma1_clusterE9E21','extraInfo(eta0veto_gamma1_clusterE9E21)')
Exemple #20
0
filedirectory = '/gpfs/group/belle2/users/seemac/Kstll/signal/BtoKstjpsi/kst0jpsi'
ma.inputMdstList(
    environmentType='default',
    filelist=[
        f'{filedirectory}/mdst_000001_prod00012871_task10020000001.root'
    ],
    path=main)
# fill final state particle lists
impactcut = 'abs(d0)<2.0 and abs(z0)<5.0 '
ma.fillParticleList(decayString='e+:uncorrected',
                    cut=impactcut + ' and electronID > 0.5',
                    path=main)
stdV0s.stdKshorts(path=main)

# apply Bremsstrahlung correction to electrons
variables.addAlias("goodFWDGamma",
                   "passesCut(clusterReg == 1 and clusterE > 0.075)")
variables.addAlias("goodBRLGamma",
                   "passesCut(clusterReg == 2 and clusterE > 0.05)")
variables.addAlias("goodBWDGamma",
                   "passesCut(clusterReg == 3 and clusterE > 0.1)")
variables.addAlias('goodGamma',
                   'passesCut(goodFWDGamma or goodBRLGamma or goodBWDGamma)')
ma.fillParticleList('gamma:brems', 'goodGamma', path=main)
ma.correctBrems('e+:corrected', 'e+:uncorrected', 'gamma:brems', path=main)
variables.addAlias('isBremsCorrected', 'extraInfo(bremsCorrected)')

# combine final state particles to form composite particles
ma.reconstructDecay('J/psi:ee -> e+:corrected e-:corrected ?addbrems',
                    cut='dM < 0.11',
                    path=main)
Exemple #21
0
defaultInputFilename = "evtgen.root"
defaultInputFoldername = "test"
inputFilename = defaultInputFoldername + '/' + defaultInputFilename
defaultOutputFilename = "test.root"
defaultOutputFoldername = "."
outputFilename = defaultOutputFoldername + '/' + defaultOutputFilename
for arg in sys.argv:
	print(arg)
if len(sys.argv)==2:
	inputFilename = sys.argv[1]
if len(sys.argv)==3:
	inputFilename = sys.argv[1]
	outputFilename = sys.argv[2]
use_central_database("GT_gen_prod_003.11_release-00-09-01-FEI-a")
from variables import variables
variables.addAlias('myRating','extraInfo(myRating)')
variables.addAlias('myRatingCriteria',ratingVar)

# load input ROOT file2
add_beamparameters(analysis_main,'Y4S')
inputMdst('default', inputFilename)
#stdMu('all')
stdKshorts()
stdPhotons('loose')
stdPi0s('looseFit')
stdPi('all')
applyCuts('gamma:loose','1.4 < E < 4')
#applyCuts('K_S0:all','daughter(0,piid)>0.1 and daughter(1,piid)>0.1 and daughter(0,eid)<0.9 and daughter(1,eid)<0.9 and daughter(0,prid)<0.9 and daughter(1,prid)<0.9 and daughter(0,muid)<0.9 and daughter(1,muid)<0.9')
#vertexRave('K_S0:all',0.01)
vertexKFit('K_S0:all',0.01)
reconstructDecay("K_10:all -> pi+:all pi-:all pi0:looseFit K_S0:all", "0.5 < M < 2")
    return parser.parse_args()


particle_list = 'B+:generic'
# particle_list = 'B0:generic'

# Should alias this
gamma_cut = (
    'clusterHypothesis == 5'
    ' and theta > 0.296706 and theta < 2.61799'
    ' and clusterErrorTiming < 1e6'
    ' and [clusterE1E9 > 0.4 or E > 0.075]'
    ' and [[clusterReg == 1 and E > 0.05] or [clusterReg == 2 and E > 0.05] or [clusterReg == 3 and E > 0.075]]'
    ' and abs(clusterTiming) < formula(0.5 * clusterErrorTiming)'
)
variables.addAlias('nCleanedClusters', 'nCleanedECLClusters({})'.format(gamma_cut))
# Need to be event level vars as the smartBKG NN cut throws away events only
event_vars = [
    'evtNum',
    'nTracks',
    'nCleanedTracks(dr<2 and abs(dz)<4)',
    # 'nCleanedECLClusters({})'.format(gamma_cut),
    'nCleanedClusters',
    # 'Ecms',
    # 'Eher',
    # 'Eler',
    # 'missingEnergy',
    # 'missingEnergyOfEventCMS',
    # 'missingMomentumOfEvent',
    # 'missingMomentumOfEvent_Px',
    # 'missingMomentumOfEvent_Py',
Exemple #23
0
		output+=[newvar]
	return output

from ROOT import Belle2
env = Belle2.Environment.Instance()
print(env.getInputFilesOverride())
print(env.getOutputFileOverride())
outputFilename = env.getOutputFileOverride()

b2.use_database_chain()
b2.use_central_database('release-03-01-00')        # Database for MC  
b2.use_central_database("analysis_tools_release-03-01-00") # Database with Flavor Tag parameters


from variables import variables
variables.addAlias('EW90','extraInfo(EW90)')
variables.addAlias('pMissCMS','extraInfo(pMissCMS)')
variables.addAlias('cosThetaMissCMS','extraInfo(cosThetaMissCMS)')
variables.addAlias('myRating','extraInfo(myRating)')
variables.addAlias('myRatingCriteria',ratingVar)
variables.addAlias('B0_CosTBTO','cosTBTO')
variables.addAlias('B0_cc2','CleoConeCS(2)')
variables.addAlias('B0_hso12','KSFWVariables(hso12)')
variables.addAlias('B0_R2','R2')
variables.addAlias('B0_hso10','KSFWVariables(hso10)')
variables.addAlias('B0_hso14','KSFWVariables(hso14)')
variables.addAlias('B0_cc9','CleoConeCS(9)')
variables.addAlias('B0_CosTBz','cosTBz')
variables.addAlias('B0_ThrustO','thrustOm')
variables.addAlias('B0_ThrustB','thrustBm')
variables.addAlias('B0_cc4','CleoConeCS(4)')
    # Target variable used in training.
    targetVar = ['isNotContinuumEvent']

    # MVAExpert
    analysis_main.add_module('MVAExpert', listNames=['B0:ch3'], extraInfoName='FastBDT', identifier='MVAFastBDT_ch3.root')

    # Variables from MVAExpert.
    expertVars = ['extraInfo(FastBDT)', 'transformedNetworkOutput(FastBDT,0.,1.0)']



# variable aliases

from variables import variables

variables.addAlias('flLenSig', 'significanceOfDistance')
variables.addAlias('CosTHel', 'decayAngle(0)')
variables.addAlias('out_FastBDT',  'extraInfo(FastBDT)')
variables.addAlias('csv_FastBDT',  'transformedNetworkOutput(FastBDT,0.,1.0)')


# define Ntuple tools 

# with tracks, neutrals, pi0's and intermediate resonances
# are meant only for debugging
#
# for the real analysis, anything included in B0_ch3
# should be sufficient

toolsTrk = ['EventMetaData', 'pi+:all']
toolsTrk += ['Kinematics', '^pi+:all']
Exemple #25
0
from basf2 import *
from modularAnalysis import *
# check if the required input file exists (from B2A101 example)
import os.path
import sys
from vertex import vertexRave
from variables import variables
variables.addAlias('Mbvf', 'extraInfo(massBeforeFit)')
from beamparameters import *
from stdCharged import *
from stdLightMesons import *
from stdPhotons import *
from stdV0s import *
#import MCDecayString
#if not os.path.isfile('B-K*0gamma-reco.root'):
#   sys.exit('Required input file (B-K*0gamma-reco.root) does not exist. '
#           'Please run EvtGeneration.py tutorial script first.')
add_beamparameters(analysis_main,'Y4S')
# load input ROOT file
#inputMdst('default', '5000-B-K*0gamma-reco.root')

#inputMdst('default', '5000-B-K*0gamma-reco_v3_test.root')
inputMdst('default', 'reco-signal.root')
#inputMdst('None', 'default_5000-B-K*0gamma-reco.root')
#inputMdst('default', 'default_5000-B-K*0gamma-reco.root')

#Print contents of the DataStore before loading MCParticles
#printDataStore()

Exemple #26
0
from variables import variables
import sys
import argparse

#------------Parses the command line options of the fei and returns the corresponding arguments.--------
parser = argparse.ArgumentParser()

parser.add_argument(
    '-out',
    '--outputfile',
    dest='outputfile',
    type=str,
    default='/home/belle/ytchin/B+2mu+nu_mu/temp/20181027_signal.root',
    help='Name of the outputted file')
args = parser.parse_args()
variables.addAlias('Nlep', 'countInList(pi+:lep)')
variables.addAlias('NhighP', 'countInList(pi+:highP)')
#-------------------------------------------Input mdst file---------------------------------------------
inputMdstList('default', [
    '/ghi/fs01/belle/bdata2/users/ytchin/MC9signal/20171025_4_B+2mu+nu_mu_Udst.root.udst.root'
])

#------------------------------------------Mbc and deltaE cut----------------------------------------------
buildRestOfEvent('B-:good', path=analysis_main)

#------------------------------------continuum suppression-------------------------------------------------

appendROEMask(
    'B-:good',
    'cleanMask',
    'useCMSFrame(p)<=3.2 and nCDCHits>0 and abs(d0)<5 and abs(z0)<10',
Exemple #27
0
defaultOutputFilename = "test.root"
defaultOutputFoldername = "."
outputFilename = defaultOutputFoldername + '/' + defaultOutputFilename
# Change K resonance name here:
Kres = 'Xsd'
for arg in sys.argv:
    print(arg)
if len(sys.argv) == 2:
    inputFilename = sys.argv[1]
if len(sys.argv) == 3:
    inputFilename = sys.argv[1]
    outputFilename = sys.argv[2]
use_central_database("GT_gen_prod_003.11_release-00-09-01-FEI-a")
#use_central_database("GT_gen_prod_004.11_Master-20171213-230000")
from variables import variables
variables.addAlias('myRating', 'extraInfo(myRating)')
variables.addAlias('myRatingCriteria', ratingVar)
variables.addAlias('B0_CosTBTO', 'cosTBTO')
variables.addAlias('B0_cc2', 'CleoCone(2)')
variables.addAlias('B0_hso12', 'KSFWVariables(hso12)')
variables.addAlias('B0_R2', 'R2')
variables.addAlias('B0_hso10', 'KSFWVariables(hso10)')
variables.addAlias('B0_hso14', 'KSFWVariables(hso14)')
variables.addAlias('B0_cc9', 'CleoCone(9)')
variables.addAlias('B0_CosTBz', 'cosTBz')
variables.addAlias('B0_ThrustO', 'thrustOm')
variables.addAlias('B0_ThrustB', 'thrustBm')
variables.addAlias('B0_cc4', 'CleoCone(4)')
variables.addAlias('B0_hso02', 'KSFWVariables(hso02)')
variables.addAlias('CSMVA', 'extraInfo(CSMVA)')
Exemple #28
0
    for var in envs:
        print("%30s = %s" % (var, os.getenv(var)))
    print()


print_env()

# Show input and output file info
print("Input: %s" % sys.argv[1])
print("Ouput: %s" % sys.argv[2])

mp = b2.create_path()

b2c.convertBelleMdstToBelleIIMdst(sys.argv[1], applyHadronBJSkim=True, path=mp)

variables.addAlias('pid_ppi', 'atcPIDBelle(4,2)')
variables.addAlias('pid_pk', 'atcPIDBelle(4,3)')
variables.addAlias('pid_kpi', 'atcPIDBelle(3,2)')

variables.addAlias('cosa', 'cosAngleBetweenMomentumAndVertexVector')
variables.addAlias('cosaXY', 'cosAngleBetweenMomentumAndVertexVectorInXYPlane')

mc_vars = [
    'isSignal', 'isPrimarySignal', 'mcPDG', 'genMotherPDG', 'nMCMatches'
]
kinematic_vars = ['M', 'p', 'pt', 'pz', 'phi', 'theta', 'charge', 'xp']
vertex_vars = [
    'cosa', 'cosaXY', 'chiProb', 'dr', 'dz', 'x', 'y', 'z', 'distance',
    'significanceOfDistance'
]
track_vars = ['d0', 'z0', 'd0Err']
Exemple #29
0
from basf2 import *
import basf2_mva
from modularAnalysis import *
from variables import variables
variables.addAlias('pi0Likeness','extraInfo(Pi0_Prob)')
variables.addAlias('etaLikeness','extraInfo(Eta_Prob)')

variables.addAlias('pi0veto_M','extraInfo(pi0veto_M)')
variables.addAlias('pi0veto_mcPDG','extraInfo(pi0veto_mcPDG)')
variables.addAlias('pi0veto_cosTheta','extraInfo(pi0veto_cosTheta)')
variables.addAlias('pi0veto_gamma0_E','extraInfo(pi0veto_gamma0_E)')
variables.addAlias('pi0veto_gamma1_E','extraInfo(pi0veto_gamma1_E)')
variables.addAlias('pi0veto_gamma1_cosTheta','extraInfo(pi0veto_gamma1_cosTheta)')
variables.addAlias('pi0veto_gamma1_clusterE1E9','extraInfo(pi0veto_gamma1_clusterE1E9)')
variables.addAlias('pi0veto_gamma1_clusterE9E21','extraInfo(pi0veto_gamma1_clusterE9E21)')
variables.addAlias('pi0veto_gamma1_clusterTiming','extraInfo(pi0veto_gamma1_clusterTiming)')
variables.addAlias('pi0veto_gamma1_clusterAZM40','extraInfo(pi0veto_gamma1_clusterAbsZernikeMoment40)')
variables.addAlias('pi0veto_gamma1_clusterAZM51','extraInfo(pi0veto_gamma1_clusterAbsZernikeMoment51)')
variables.addAlias('pi0veto_gamma1_clusterSecondMoment','extraInfo(pi0veto_gamma1_clusterSecondMoment)')
variables.addAlias('eta0veto_gamma1_cosTheta','extraInfo(eta0veto_gamma1_cosTheta)')
variables.addAlias('eta0veto_gamma1_clusterE1E9','extraInfo(eta0veto_gamma1_clusterE1E9)')
variables.addAlias('eta0veto_gamma1_clusterE9E21','extraInfo(eta0veto_gamma1_clusterE9E21)')
variables.addAlias('eta0veto_gamma1_clusterTiming','extraInfo(eta0veto_gamma1_clusterTiming)')
variables.addAlias('eta0veto_gamma1_clusterAZM40','extraInfo(eta0veto_gamma1_clusterAbsZernikeMoment40)')
variables.addAlias('eta0veto_gamma1_clusterAZM51','extraInfo(eta0veto_gamma1_clusterAbsZernikeMoment51)')
variables.addAlias('eta0veto_gamma1_clusterSecondMoment','extraInfo(eta0veto_gamma1_clusterSecondMoment)')
variables.addAlias('eta0veto_M','extraInfo(eta0veto_M)')
variables.addAlias('eta0veto_mcPDG','extraInfo(eta0veto_mcPDG)')
variables.addAlias('eta0veto_cosTheta','extraInfo(eta0veto_cosTheta)')
variables.addAlias('eta0veto_gamma0_E','extraInfo(eta0veto_gamma0_E)')
variables.addAlias('eta0veto_gamma1_E','extraInfo(eta0veto_gamma1_E)')
# Print env variables for check
print("Environmental Variables".center(80, '='))
for v in env_list:
    print_env(v)

# Show input and output file info
print("Input: %s" % sys.argv[1])
print("Ouput: %s" % sys.argv[2])

mp = b2.create_path()

b2c.convertBelleMdstToBelleIIMdst(sys.argv[1], applyHadronBJSkim=True, path=mp)

# Aliases for the variables to make the root file easier to understand
variables.addAlias('pid_ppi', 'atcPIDBelle(4,2)')
variables.addAlias('pid_pk', 'atcPIDBelle(4,3)')
variables.addAlias('pid_kpi', 'atcPIDBelle(3,2)')

variables.addAlias('cosa', 'cosAngleBetweenMomentumAndVertexVector')
variables.addAlias('cosaXY', 'cosAngleBetweenMomentumAndVertexVectorInXYPlane')

mc_vars = [
    'isSignal', 'isPrimarySignal', 'mcPDG', 'genMotherPDG', 'nMCMatches',
    'mcP', 'mcE', 'mcPT'
]
kinematic_vars = ['M', 'p', 'pt', 'pz', 'phi', 'theta', 'charge', 'xp']
vertex_vars = [
    'cosa', 'cosaXY', 'chiProb', 'x', 'y', 'z', 'distance',
    'significanceOfDistance'
]
Exemple #31
0
def writePi0EtaVeto(
    particleList,
    decayString,
    workingDirectory='.',
    pi0vetoname='Pi0_Prob',
    etavetoname='Eta_Prob',
    downloadFlag=True,
    selection='',
    path=analysis_main,
):
	"""
	Give pi0/eta probability for hard photon.

	default weight files are set 1.4 GeV as the lower limit of hard photon energy in CMS Frame when mva training for pi0etaveto.
	current default weight files are optimised by MC9.
	The Input Variables are as below. Aliases are set to some variables when training.
	M : pi0/eta candidates Invariant mass
	lowE : soft photon energy in lab frame
	cTheta : soft photon ECL cluster's polar angle
	Zmva : soft photon output of MVA using Zernike moments of the cluster
	minC2Hdist : soft photon distance from eclCluster to nearest point on nearest Helix at the ECL cylindrical radius

	If you don't have weight files in your workingDirectory,
	these files are downloaded from database to your workingDirectory automatically.
	Please refer to analysis/examples/tutorials/B2A306-B02RhoGamma-withPi0EtaVeto.py
	about how to use this function.

	NOTE for debug
	Please don't use following ParticleList names elsewhere.
	'gamma:HARDPHOTON', pi0:PI0VETO, eta:ETAVETO,
	'gamma:PI0SOFT' + str(PI0ETAVETO_COUNTER), 'gamma:ETASOFT' + str(PI0ETAVETO_COUNTER)
	Please don't use "lowE", "cTheta", "Zmva", "minC2Hdist" as alias elsewhere.

	@param particleList     The input ParticleList
	@param decayString specify Particle to be added to the ParticleList
	@param workingDirectory The weight file directory
	@param downloadFlag whether download default weight files or not
	@param pi0vetoname extraInfo name of pi0 probability
	@param etavetoname extraInfo name of eta probability
	@param selection Selection criteria that Particle needs meet in order for for_each ROE path to continue
	@param path       modules are added to this path
	"""
	global PI0ETAVETO_COUNTER

	if PI0ETAVETO_COUNTER == 0:
		variables.addAlias('lowE', 'daughter(1,E)')
		variables.addAlias('cTheta', 'daughter(1,clusterTheta)')
		variables.addAlias('Zmva', 'daughter(1,clusterZernikeMVA)')
		variables.addAlias('minC2Hdist', 'daughter(1,minC2HDist)')

	PI0ETAVETO_COUNTER = PI0ETAVETO_COUNTER + 1

	roe_path = create_path()

	deadEndPath = create_path()

	signalSideParticleFilter(particleList, selection, roe_path, deadEndPath)

	fillSignalSideParticleList('gamma:HARDPHOTON', decayString, path=roe_path)

	pi0softname = 'gamma:PI0SOFT'
	etasoftname = 'gamma:ETASOFT'
	softphoton1 = pi0softname + str(PI0ETAVETO_COUNTER)
	softphoton2 = etasoftname + str(PI0ETAVETO_COUNTER)

	fillParticleList(
		softphoton1,
		'[clusterReg==1 and E>0.025] or [clusterReg==2 and E>0.02] or [clusterReg==3 and E>0.02]',
		path=roe_path)
	applyCuts(softphoton1, 'abs(clusterTiming)<120', path=roe_path)
	fillParticleList(
		softphoton2,
		'[clusterReg==1 and E>0.035] or [clusterReg==2 and E>0.03] or [clusterReg==3 and E>0.03]',
		path=roe_path)
	applyCuts(softphoton2, 'abs(clusterTiming)<120', path=roe_path)

	reconstructDecay('pi0:PI0VETO -> gamma:HARDPHOTON ' + softphoton1, '', path=roe_path)
	reconstructDecay('eta:ETAVETO -> gamma:HARDPHOTON ' + softphoton2, '', path=roe_path)

	if not os.path.isdir(workingDirectory):
		os.mkdir(workingDirectory)
		B2INFO('writePi0EtaVeto: ' + workingDirectory + ' has been created as workingDirectory.')

	if not os.path.isfile(workingDirectory + '/pi0veto.root'):
		if downloadFlag:
			use_central_database('development')
			basf2_mva.download('Pi0VetoIdentifier', workingDirectory + '/pi0veto.root')
			B2INFO('writePi0EtaVeto: pi0veto.root has been downloaded from database to workingDirectory.')

	if not os.path.isfile(workingDirectory + '/etaveto.root'):
		if downloadFlag:
			use_central_database('development')
			basf2_mva.download('EtaVetoIdentifier', workingDirectory + '/etaveto.root')
			B2INFO('writePi0EtaVeto: etaveto.root has been downloaded from database to workingDirectory.')

	roe_path.add_module('MVAExpert', listNames=['pi0:PI0VETO'], extraInfoName='Pi0Veto',
			identifier=workingDirectory + '/pi0veto.root')
	roe_path.add_module('MVAExpert', listNames=['eta:ETAVETO'], extraInfoName='EtaVeto',
			identifier=workingDirectory + '/etaveto.root')

	rankByHighest('pi0:PI0VETO', 'extraInfo(Pi0Veto)', 1, path=roe_path)
	rankByHighest('eta:ETAVETO', 'extraInfo(EtaVeto)', 1, path=roe_path)

	variableToSignalSideExtraInfo('pi0:PI0VETO', {'extraInfo(Pi0Veto)': pi0vetoname}, path=roe_path)
	variableToSignalSideExtraInfo('eta:ETAVETO', {'extraInfo(EtaVeto)': etavetoname}, path=roe_path)
	variableToSignalSideExtraInfo('pi0:PI0VETO', {'daughter(1,E)': 'pi0vetoGamma1E'}, path=roe_path)
	variableToSignalSideExtraInfo('pi0:PI0VETO', {'daughter(1,cosTheta)': 'pi0vetoGamma1CosTheta'}, path=roe_path)
	variableToSignalSideExtraInfo('pi0:PI0VETO', {'daughter(1,clusterTiming)': 'pi0vetoGamma1Timing'}, path=roe_path)

	path.for_each('RestOfEvent', 'RestOfEvents', roe_path)
Exemple #32
0
ma.inputMdstList(environmentType='default', filelist=inputFile, path=my_path)
b2.set_module_parameters(path=my_path, name='RootInput', cacheSize=100)

######################################################
# create and fill the ParticleLists
######################################################
ma.fillParticleList('e-:all', '', path=my_path)
ma.fillParticleList('mu+:all', '', path=my_path)
ma.fillParticleList('pi-:all', '', path=my_path)

######################################################
# track cuts
######################################################

var.addAlias('EoverP', 'formula( ifNANgiveX( clusterE, -1 )/p )')

cleanTrack = 'abs(z0) < 2.0 and abs(d0) < 0.5 and nCDCHits > 0'

ma.cutAndCopyLists('e-:good', 'e-:all', cleanTrack, path=my_path)

ma.cutAndCopyLists('pi-:good', 'pi-:all', cleanTrack, path=my_path)

ma.cutAndCopyLists('mu+:mugood', 'mu+:all', cleanTrack, path=my_path)

######################################################
# event based cut - ==  2 tracks in event
######################################################

var.addAlias('nCleanedTracks', 'nCleanedTracks(' + cleanTrack + ')')
ma.applyEventCuts(cut='nCleanedTracks == 2', path=my_path)
        ['transformedNetworkOutput(FastBDT_Probability,0.0,1.0)']
    transformedNetworkOutputBDT = \
        ['transformedNetworkOutput(BDT_Probability,0.0,1.0)']
    transformedNetworkOutputHMatrix = \
        ['transformedNetworkOutput(HMatrix_Probability,0.0,1.0)']
    transformedNetworkOutputFisher = \
        ['transformedNetworkOutput(Fisher_Probability,0.0,1.0)']
    transformedNetworkOutputLD = \
        ['transformedNetworkOutput(LD_Probability,0.0,1.0)']
    transformedNetworkOutputLikelihood = \
        ['transformedNetworkOutput(Likelihood_Probability,0.0,1.0)']


    # define human readable aliases for CS variables

    variables.addAlias('csv_FastBDT', 'transformedNetworkOutput(FastBDT_Probability,0.0,1.0)')
    variables.addAlias('csv_BDT', 'transformedNetworkOutput(BDT_Probability,0.0,1.0)')
    variables.addAlias('csv_HMatrix', 'transformedNetworkOutput(HMatrix_Probability,0.0,1.0)')
    variables.addAlias('csv_Fisher', 'transformedNetworkOutput(Fisher_Probability,0.0,1.0)')
    variables.addAlias('csv_LD', 'transformedNetworkOutput(LD_Probability,0.0,1.0)')
    variables.addAlias('csv_Likelihood', 'transformedNetworkOutput(Likelihood_Probability,0.0,1.0)')



# flavor tagging
#FlavorTagger(
#    mode='Expert',
#    weightFiles='B2JpsiKs_mu',
#    categories=['Electron', 'Muon', 'KinLepton', 'Kaon', 'SlowPion', 'FastPion', 'Lambda', 'FSC', 'MaximumP*', 'KaonPion'])