Ejemplo n.º 1
0
def outputMdst(filename, path=analysis_main):
    """
    Saves mDST (mini-Data Summary Tables) to the output root file.
    """

    import reconstruction
    reconstruction.add_mdst_output(path, mc=True, filename=filename)
Ejemplo n.º 2
0
def outputUdst(filename, particleLists=[], path=analysis_main):
    """
    Save uDST (micro-Data Summary Tables) = MDST + Particles + ParticleLists
    The charge-conjugate lists of those given in particleLists are also stored.
    """

    import reconstruction
    import ROOT
    ROOT.gSystem.Load('libanalysis_DecayDescriptor')
    from ROOT import Belle2
    # also add anti-particle lists
    plSet = set(particleLists)
    for name in particleLists:
        antiName = Belle2.ParticleListName.antiParticleListName(name)
        plSet.add(antiName)

    partBranches = ['Particles', 'ParticlesToMCParticles',
                    'ParticlesToPIDLikelihoods', 'ParticleExtraInfoMap',
                    'EventExtraInfo'] + list(plSet)
    reconstruction.add_mdst_output(path, mc=True, filename=filename,
                                   additionalBranches=partBranches)
generateY4S(
    100,
    Belle2.FileSystem.findFile(
        '../dec_files/B0_etapr-eta-gg2pi_KS-pi+pi-.dec'
        #'../dec_files/B0_etapr-eta-gg2pi_KS-pi0pi0.dec'
        #'../dec_files/B0_etapr-eta-gg2pi_KL.dec'
        #'../dec_files/B0_etapr-eta-3pi2pi_KS-pi+pi-.dec'
        #'../dec_files/B0_etapr-eta-3pi2pi_KS-pi0pi0.dec'
    ))

# simulation
add_simulation(analysis_main)  # WITHOUT beam background

# reconstruction
add_reconstruction(analysis_main)

# dump in MDST format
add_mdst_output(
    analysis_main, True, 'B0_etapr-eta-gg2pi_KS-pi+pi-_gsim-BKGx0.root'
    #'B0_etapr-eta-gg2pi_KS-pi0pi0_gsim-BKGx0.root'
    #'B0_etapr-eta-gg2pi_KL_gsim-BKGx0.root'
    #'B0_etapr-eta-3pi2pi_KS-pi+pi-_gsim-BKGx0.root'
    #'B0_etapr-eta-3pi2pi_KS-pi0pi0_gsim-BKGx0.root'
)

# Process the events
process(analysis_main)

# print out the summary
print(statistics)
Ejemplo n.º 4
0
#######################################################                                                                                     #
#
# Adapted from B2A104 tutorial
#
# Author: A.Gaz
#
######################################################

from basf2 import *
from modularAnalysis import generateY4S
from modularAnalysis import loadGearbox
from modularAnalysis import analysis_main
from reconstruction import add_mdst_output
from ROOT import Belle2

# generate signal MC
generateY4S(1000000, Belle2.FileSystem.findFile('../dec_files/genericBBbar.dec'))

# dump in MDST format
add_mdst_output(analysis_main, True,
                'Gen_bbar_gsim-BKGx1-1M.root')

# if simulation/reconstruction scripts are not added than one needs to load gearbox
loadGearbox()

# Process the events
process(analysis_main)

# print out the summary
print statistics
Ejemplo n.º 5
0
import sys

# load input ROOT file

inputName = ['testSkimming_BBbar-10M-1.root']
outputName = 'reconstructedBBbar.root'

inputMdstList(inputName)

bkgdir = '/b2data/gaz/local_installation/bkg/bkg/'
bkgFiles = [bkgdir + '*.root']

# simulation
add_simulation(analysis_main)

# reconstruction
add_reconstruction(analysis_main)

# dump in MDST format
add_mdst_output(analysis_main, True,outputName)

# Show progress of processing
progress = register_module('Progress')
analysis_main.add_module(progress)

# Process the events
process(analysis_main)

# print out the summary
print statistics
Ejemplo n.º 6
0
evtgeninput.param('userDECFile',
                  Belle2.FileSystem.findFile('top/examples/B2Kpi.dec'))
main.add_module(evtgeninput)

# Detector simulation
bg = None
if 'BELLE2_BACKGROUND_DIR' in os.environ:
    bg = glob.glob(os.environ['BELLE2_BACKGROUND_DIR'] + '/*.root')
add_simulation(main, bkgfiles=bg)
print("DISPLAY: " + os.environ['DISPLAY'])

# Reconstruction
add_reconstruction(main)

# Output to mdst
add_mdst_output(main, filename='evtgenB2Kpi.mdst.root')

# Output to a flat ntuple with TOP likelihoods, track info and MC truth
ntuple = register_module('TOPNtuple')
ntuple.param('outputFileName', 'ntupleB2Kpi.root')
main.add_module(ntuple)

dqmmodule = register_module("TOPDataQualityOnline")
dqmmodule.param('framesPerEvent',1)
main.add_module(dqmmodule)

# Show progress of processing
progress = register_module('Progress')
main.add_module(progress)

# Process events
Ejemplo n.º 7
0
if os.path.isfile(filename):
	sys.exit('Required input file does exist. ')

add_beamparameters(analysis_main, 'Y4S')

# generation of 100 events according to the specified DECAY table
# Y(4S) -> Btag- Bsig+
# Btag- -> D0 pi-; D0 -> K- pi+
# Bsig+ -> mu+ nu_mu
#
# generateY4S function is defined in analysis/scripts/modularAnalysis.py
#generateY4S(1000, 'Y4SEventGeneration.dec')
generateY4S(5000, 'mydec-k-cpmix.dec')

# If the simulation and reconstruction is not performed in the sam job,
# then the Gearbox needs to be loaded with the loadGearbox() function.
loadGearbox()

# dump generated events in MDST format to the output ROOT file
#
# add_mdst_output function is defined in reconstruction/scripts/reconstruction.py
add_mdst_output(analysis_main, True, filename)
printPrimaryMCParticles()

# process all modules added to the analysis_main path
# (note: analysis_main is the default path created in the modularAnapys.py)
process(analysis_main)

# print out the summary
print(statistics)
    )

outFile = str(sys.argv[1])

from basf2 import *
from modularAnalysis import generateY4S
from modularAnalysis import analysis_main
from simulation import add_simulation
from reconstruction import add_reconstruction
from reconstruction import add_mdst_output
from ROOT import Belle2
import glob

# generate signal MC
generateY4S(10000, Belle2.FileSystem.findFile('../dec_files/B0_phi-K+K-_KS-pi+pi-.dec'))

# simulation
add_simulation(analysis_main)      # WITHOUT beam background

# reconstruction
add_reconstruction(analysis_main)

# dump in MDST format
add_mdst_output(analysis_main, True, outFile)

# Process the events
process(analysis_main)

# print out the summary
print (statistics)
from basf2 import *
from modularAnalysis import generateY4S
from modularAnalysis import analysis_main
from simulation import add_simulation
from reconstruction import add_reconstruction
from reconstruction import add_mdst_output
from ROOT import Belle2

# generate signal MC
generateY4S(1000, Belle2.FileSystem.findFile('../dec_files/B0_phi-K+K-_KS-pi+pi-.dec'))

bkgdir = '/sw/belle2/bkg/'
bkgFiles = [bkgdir + '*.root']

# simulation
add_simulation(analysis_main, None, bkgFiles)     # WITH beam background

# reconstruction
add_reconstruction(analysis_main)

# dump in MDST format
add_mdst_output(analysis_main, True,
                'B0_Phi-KK_Ks-pi+pi-_gsim-BKGx1.root')

# Process the events
process(analysis_main)

# print out the summary
print statistics
Ejemplo n.º 10
0
import sys

# load input ROOT file

inputName = ['testSkimming_2-7.root', 'testSkimming_8-10.root']
outputName = 'reconstructedContinuum.root'

inputMdstList(inputName)

bkgdir = '/b2data/gaz/local_installation/bkg/bkg/'
bkgFiles = [bkgdir + '*.root']

# simulation
add_simulation(analysis_main)

# reconstruction
add_reconstruction(analysis_main)

# dump in MDST format
add_mdst_output(analysis_main, True, outputName)

# Show progress of processing
progress = register_module('Progress')
analysis_main.add_module(progress)

# Process the events
process(analysis_main)

# print out the summary
print statistics
Ejemplo n.º 11
0
#######################################################                                                                                     #
#
# Adapted from B2A104 tutorial
#
# Author: A.Gaz
#
######################################################

from basf2 import *
from modularAnalysis import generateContinuum
from modularAnalysis import loadGearbox
from modularAnalysis import analysis_main
from reconstruction import add_mdst_output
from ROOT import Belle2

# generate signal MC
generateContinuum(1000000, 'K_S0',
                  Belle2.FileSystem.findFile('../dec_files/continuum.dec'))

# dump in MDST format
add_mdst_output(analysis_main, True, 'Gen_continuum_gsim-BKGx1-1M.root')

# if simulation/reconstruction scripts are not added than one needs to load gearbox
loadGearbox()

# Process the events
process(analysis_main)

# print out the summary
print statistics
Ejemplo n.º 12
0
from basf2 import *
from modularAnalysis import generateY4S
from modularAnalysis import analysis_main
from simulation import add_simulation
from reconstruction import add_reconstruction
from reconstruction import add_mdst_output
from ROOT import Belle2

# generate signal MC
generateY4S(
    10000,
    Belle2.FileSystem.findFile('../dec_files/B0_phi-K+K-_KS-pi+pi-.dec'))

bkgdir = '/sw/belle2/bkg/'
bkgFiles = [bkgdir + '*.root']

# simulation
add_simulation(analysis_main, None, bkgFiles)  # WITH beam background

# reconstruction
add_reconstruction(analysis_main)

# dump in MDST format
add_mdst_output(analysis_main, True, 'B0_Phi-KK_Ks-pi+pi-_gsim-BKGx1.root')

# Process the events
process(analysis_main)

# print out the summary
print statistics
Ejemplo n.º 13
0
#         model_type=model_type,
#         threshold=args.threshold,
#     )
#     dead_path = b2.create_path()
#     NNApplyModule_m.if_false(dead_path)

#     main.add_module(NNApplyModule_m)
#     # Do I need this here?
#     # c1.set_property_flags(b2.ModulePropFlags.PARALLELPROCESSINGCERTIFIED)

# ma.loadGearbox(path=main)
# main.add_module('Geometry', ignoreIfPresent=True, components=['MagneticField'])
simulation.add_simulation(path=main,
                          bkgfiles=glob.glob(args.bkg_dir + '/*.root'))
reconstruction.add_reconstruction(path=main)

# dump generated events in MDST format to the output ROOT file
reconstruction.add_mdst_output(
    path=main,
    mc=True,
    filename='RootOutput.root',
    additionalBranches=['EventExtraInfo'],
)

# Begin processing
################################################################################
main.add_module('ProgressBar')
b2.process(path=main)

print(b2.statistics)
Ejemplo n.º 14
0
main.add_module(topreco)

# TOP DQM
#topdqm = register_module('TOPDQM')
#main.add_module(topdqm)

# TOP DDT
#topddt = register_module('TOPDDT')
#topddt.param('outputFileName','TOPDDT_gun.root')
#main.add_module(topddt)
dqmmodule = register_module("TOPDataQualityOnline")
main.add_module(dqmmodule)

# Output
#output = register_module('RootOutput')
#output.param('outputFileName', 'TOPOutput.root')
#main.add_module(output)

# mdst output
add_mdst_output(main, filename='mdst_gun.root')

# Show progress of processing
progress = register_module('Progress')
main.add_module(progress)

# Process events
process(main)

# Print call statistics
print(statistics)
Ejemplo n.º 15
0
    #filelistSIG= ['../root_files/ch1/B0_etapr-eta-gg2pi_KS-pi+pi-_skim_ssbar.root']
    filelistSIG+= ['../root_files/ch1/B0_etapr-eta-gg2pi_KS-pi+pi-_skim_ccbar.root']
    #filelistSIG= ['../root_files/ch1/B0_etapr-eta-gg2pi_KS-pi+pi-_skim_mixed.root']
    #filelistSIG= ['../root_files/ch1/B0_etapr-eta-gg2pi_KS-pi+pi-_skim_charged.root']
    #filelistSIG= ['B0_etapr-eta-gg2pi_KS-pi+pi-_skim_signal.root']
    #filelistSIG+= ['../root_files/ch1/B0_etapr-eta-gg2pi_KS-pi+pi-_gsim-BKGx0.root']
    inputMdstList(filelistSIG)

else:
    filelistSIGnames={
        'signal':'B0_etapr-eta-gg2pi_KS-pi+pi-_gsim-BKGx0.list',
        'uubar':'BackgroundSkim_uubar_BGx1.list',
        'ddbar':'BackgroundSkim_ddbar_BGx1.list',
        'ssbar':'BackgroundSkim_ssbar_BGx1.list',
        'ccbar':'BackgroundSkim_ccbar_BGx1.list',
        'mixed':'BackgroundSkim_mixed_BGx1.list',
        'charged':'BackgroundSkim_charged_BGx1.list'
    }

    filelistSIGraw = open(filelistSIGnames[what], 'r').readlines()
    filelistSIG= [x.strip() for x in filelistSIGraw]
    inputMdstList(filelistSIG[firstFile:nFiles])

add_mdst_output(analysis_main, True, 'outputUdst.root')

# Process the events
process(analysis_main)

# print out the summary
print statistics
Ejemplo n.º 16
0
fragmentation.param(
    'UserDecFile',
    os.path.expandvars('$BELLE2_EXTERNALS_DIR/share/evtgen/DECAY_2010.DEC'))
main.add_module(fragmentation)

# branch to an empty path if PYTHIA failed, this will change the number of events
# but the file meta data will contain the total number of generated events
generator_emptypath = create_path()
fragmentation.if_value('<1', generator_emptypath)

# detector simulation
add_simulation(main, bkgfiles=bg)

# remove the cache for background files to reduce memory
set_module_parameters(main, "BeamBkgMixer", cacheSize=0)

# trigger simulation
add_tsim(main)

# reconstruction
add_reconstruction(main)

# Finally add mdst output
add_mdst_output(main,
                filename=output_filename,
                additionalBranches=['KlIds', 'KLMClustersToKlIds'])

#process events and print call statistics
process(main)
print(statistics)
Ejemplo n.º 17
0
        '../root_files/ch1/B0_etapr-eta-gg2pi_KS-pi+pi-_skim_ccbar.root'
    ]
    #filelistSIG= ['../root_files/ch1/B0_etapr-eta-gg2pi_KS-pi+pi-_skim_mixed.root']
    #filelistSIG= ['../root_files/ch1/B0_etapr-eta-gg2pi_KS-pi+pi-_skim_charged.root']
    #filelistSIG= ['B0_etapr-eta-gg2pi_KS-pi+pi-_skim_signal.root']
    #filelistSIG+= ['../root_files/ch1/B0_etapr-eta-gg2pi_KS-pi+pi-_gsim-BKGx0.root']
    inputMdstList(filelistSIG)

else:
    filelistSIGnames = {
        'signal': 'B0_etapr-eta-gg2pi_KS-pi+pi-_gsim-BKGx0.list',
        'uubar': 'BackgroundSkim_uubar_BGx1.list',
        'ddbar': 'BackgroundSkim_ddbar_BGx1.list',
        'ssbar': 'BackgroundSkim_ssbar_BGx1.list',
        'ccbar': 'BackgroundSkim_ccbar_BGx1.list',
        'mixed': 'BackgroundSkim_mixed_BGx1.list',
        'charged': 'BackgroundSkim_charged_BGx1.list'
    }

    filelistSIGraw = open(filelistSIGnames[what], 'r').readlines()
    filelistSIG = [x.strip() for x in filelistSIGraw]
    inputMdstList(filelistSIG[firstFile:nFiles])

add_mdst_output(analysis_main, True, 'outputUdst.root')

# Process the events
process(analysis_main)

# print out the summary
print statistics