def create_path(self): path = basf2.create_path() modularAnalysis.setupEventInfo(self.n_events, path) if self.event_type == SimulationType.y4s: # in current main branch and release 5 the Y(4S)decay file is moved, so try old and new locations find_file_ignore_error = True dec_file = Belle2.FileSystem.findFile( 'analysis/examples/tutorials/B2A101-Y4SEventGeneration.dec', find_file_ignore_error) if not dec_file: dec_file = Belle2.FileSystem.findFile( 'analysis/examples/simulations/B2A101-Y4SEventGeneration.dec' ) elif self.event_type == SimulationType.continuum: dec_file = Belle2.FileSystem.findFile( 'analysis/examples/simulations/B2A102-ccbarEventGeneration.dec' ) else: raise ValueError( f"Event type {self.event_type} is not valid. It should be either 'Y(4S)' or 'Continuum'!" ) generators.add_evtgen_generator(path, 'signal', dec_file) modularAnalysis.loadGearbox(path) simulation.add_simulation(path) path.add_module('RootOutput', outputFileName=self.get_output_file_name( 'simulation_full_output.root')) return path
def create_path(self): path = basf2.create_path() path.add_module('RootInput', inputFileNames=self.get_input_file_names( "simulation_full_output.root")) modularAnalysis.loadGearbox(path) reconstruction.add_reconstruction(path) modularAnalysis.outputMdst( self.get_output_file_name("reconstructed_output.root"), path=path) return path
def submit_generation(n_events, dec_file, out_name, random_seed): # Command line args passed as strings, so ensure they're corrected to ints n_events = int(n_events) random_seed = int(random_seed) ge.set_random_seed(random_seed) my_path = b2.create_path() ma.setupEventInfo(noEvents=n_events, path=my_path) ge.add_evtgen_generator(path=my_path, finalstate="signal", signaldecfile=dec_file) ma.loadGearbox(path=my_path) my_path.add_module("RootOutput", outputFileName=out_name) b2.process(path=my_path) print(b2.statistics)
####################################################### # # # 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
# Defining custom path my_path = b2.create_path() # Setting up number of events to generate # This is needed before you generate any events ma.setupEventInfo(noEvents=10000, path=my_path) # Adding generator # This specific event generator will generate either charged final states (charged B mesons) # or mixed final states (neutal B mesons) ge.add_evtgen_generator(path=my_path, finalstate='signal', signaldecfile='event_gen.dec') ma.loadGearbox(path=my_path) # Set the first parameter to zero if you want to see all the events. # This will show how many particles are generated in each event. #ma.printDataStore(0, path=my_path) # Show the decay chain in each event #ma.printMCParticles(path=my_path) # dump generated events in DST format to the output ROOT file my_path.add_module('RootOutput', outputFileName='event_gen.root') # Show progress bar my_path.add_module("ProgressBar") # Add log file b2.log_to_file("event_gen.log")