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 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)
# Background (collision) files bg = glob.glob('/srv/data/*/bkg/*.root') # Number of events to generate, can be overridden with `-n` num_events = 10000 # Output filename, can be overridden with `-o` output_filename = "RootOutput.root" # Create path main = create_path() # Specify number of events to be generated main.add_module("EventInfoSetter", expList=0, runList=0, evtNumList=num_events) # Generate BBbar events add_evtgen_generator(main, finalstate='charged') # Detector simulation add_simulation(main, bkgfiles=bg) # Trigger simulation add_tsim(main) # Reconstruction add_reconstruction(main) # Finally add mdst output add_mdst_output( main, filename=output_filename, additionalBranches=['TRGGDLResults', 'KlIds', 'KLMClustersToKlIds'])
#: number of events to generate, can be overriden with -n num_events = 10 #: output filename, can be overriden with -o output_filename = "mdst.root" # create path main = b2.create_path() # specify number of events to be generated main.add_module("EventInfoSetter", expList=1003, runList=0, evtNumList=num_events) # generate BBbar events ge.add_evtgen_generator(main, finalstate='mixed') # detector simulation si.add_simulation(main) # trigger simulation l1.add_tsim(main, Belle2Phase="Phase3") # reconstruction #RJS re.add_reconstruction(main) # Finally add mdst output #RJS re.add_mdst_output(main, filename=output_filename) # process events and print call statistics
# Btag- -> D0 pi-; D0 -> K- pi+ # Bsig+ -> mu+ nu_mu # # 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")