Belle II Software development
GenerateSimTask Class Reference
Inheritance diagram for GenerateSimTask:

Public Member Functions

 output_file_name (self, n_events=None, random_seed=None)
 Name of the ROOT output file with generated and simulated events.
 
 output (self)
 
 create_path (self)
 

Static Public Attributes

 n_events = b2luigi.IntParameter()
 Number of events to generate.
 
 experiment_number = b2luigi.IntParameter()
 Experiment number of the conditions database, e.g.
 
 random_seed = b2luigi.Parameter()
 Random basf2 seed.
 
 bkgfiles_dir
 Directory with overlay background root files.
 
str queue = 'l'
 specify queue.
 

Detailed Description

Generate simulated Monte Carlo with background overlay.

Make sure to use different ``random_seed`` parameters for the training data
format the classifier trainings and for the test data for the respective
evaluation/validation tasks.

Definition at line 381 of file combined_quality_estimator_teacher.py.

Member Function Documentation

◆ create_path()

create_path ( self)
Create basf2 path to process with event generation and simulation.

Definition at line 425 of file combined_quality_estimator_teacher.py.

425 def create_path(self):
426 """
427 Create basf2 path to process with event generation and simulation.
428 """
429 basf2.set_random_seed(self.random_seed)
430 path = basf2.create_path()
431 if self.experiment_number in [0, 1002, 1003]:
432 runNo = 0
433 else:
434 runNo = 0
435 raise ValueError(
436 f"Simulating events with experiment number {self.experiment_number} is not implemented yet.")
437 path.add_module(
438 "EventInfoSetter", evtNumList=[self.n_events], runList=[runNo], expList=[self.experiment_number]
439 )
440 if "BBBAR" in self.random_seed:
441 path.add_module("EvtGenInput")
442 elif "V0BBBAR" in self.random_seed:
443 path.add_module("EvtGenInput")
444 path.add_module("InclusiveParticleChecker", particles=[310, 3122], includeConjugates=True)
445 else:
446 import generators as ge
447 # WARNING: There are a few differences in the production of MC13a and b like the following lines
448 # as well as ActivatePXD.. and the beamparams for bhabha... I use these from MC13b, not a... :/
449 # import beamparameters as bp
450 # beamparameters = bp.add_beamparameters(path, "Y4S")
451 # beamparameters.param("covVertex", [(14.8e-4)**2, (1.5e-4)**2, (360e-4)**2])
452 if "V0STUDY" in self.random_seed:
453 if "V0STUDYKS" in self.random_seed:
454 # Bianca looked at the Ks dists and extracted these values:
455 mu = 0.5
456 beta = 0.2
457 pdgs = [310] # Ks (has no antiparticle, Klong is different)
458 if "V0STUDYL0" in self.random_seed:
459 # I just made the lambda values up, such that they peak at 0.35 and are slightly shifted to lower values
460 mu = 0.35
461 beta = 0.15 # if this is chosen higher, one needs to make sure not to get values >0 for 0
462 pdgs = [3122, -3122] # Lambda0
463 else:
464 # also these values are made up
465 mu = 0.43
466 beta = 0.18
467 pdgs = [310, 3122, -3122] # Ks and Lambda0
468 # create realistic momentum distribution
469 myx = [i*0.01 for i in range(321)]
470 myy = []
471 for x in myx:
472 y = createV0momenta(x, mu, beta)
473 myy.append(y)
474 polParams = myx + myy
475 # define particles that are produced
476 pdg_list = pdgs
477
478 particlegun = basf2.register_module('ParticleGun')
479 particlegun.param('pdgCodes', pdg_list)
480 particlegun.param('nTracks', 8) # number of particles (not tracks!) that is created in each event
481 particlegun.param('momentumGeneration', 'polyline')
482 particlegun.param('momentumParams', polParams)
483 particlegun.param('thetaGeneration', 'uniformCos')
484 particlegun.param('thetaParams', [17, 150]) # [0, 180]) #[17, 150]
485 particlegun.param('phiGeneration', 'uniform')
486 particlegun.param('phiParams', [0, 360])
487 particlegun.param('vertexGeneration', 'fixed')
488 particlegun.param('xVertexParams', [0])
489 particlegun.param('yVertexParams', [0])
490 particlegun.param('zVertexParams', [0])
491 path.add_module(particlegun)
492 if "BHABHA" in self.random_seed:
493 ge.add_babayaganlo_generator(path=path, finalstate='ee', minenergy=0.15, minangle=10.0)
494 elif "MUMU" in self.random_seed:
495 ge.add_kkmc_generator(path=path, finalstate='mu+mu-')
496 elif "YY" in self.random_seed:
497 babayaganlo = basf2.register_module('BabayagaNLOInput')
498 babayaganlo.param('FinalState', 'gg')
499 babayaganlo.param('MaxAcollinearity', 180.0)
500 babayaganlo.param('ScatteringAngleRange', [0., 180.])
501 babayaganlo.param('FMax', 75000)
502 babayaganlo.param('MinEnergy', 0.01)
503 babayaganlo.param('Order', 'exp')
504 babayaganlo.param('DebugEnergySpread', 0.01)
505 babayaganlo.param('Epsilon', 0.00005)
506 path.add_module(babayaganlo)
507 generatorpreselection = basf2.register_module('GeneratorPreselection')
508 generatorpreselection.param('nChargedMin', 0)
509 generatorpreselection.param('nChargedMax', 999)
510 generatorpreselection.param('MinChargedPt', 0.15)
511 generatorpreselection.param('MinChargedTheta', 17.)
512 generatorpreselection.param('MaxChargedTheta', 150.)
513 generatorpreselection.param('nPhotonMin', 1)
514 generatorpreselection.param('MinPhotonEnergy', 1.5)
515 generatorpreselection.param('MinPhotonTheta', 15.0)
516 generatorpreselection.param('MaxPhotonTheta', 165.0)
517 generatorpreselection.param('applyInCMS', True)
518 path.add_module(generatorpreselection)
519 empty = basf2.create_path()
520 generatorpreselection.if_value('!=11', empty)
521 elif "EEEE" in self.random_seed:
522 ge.add_aafh_generator(path=path, finalstate='e+e-e+e-', preselection=False)
523 elif "EEMUMU" in self.random_seed:
524 ge.add_aafh_generator(path=path, finalstate='e+e-mu+mu-', preselection=False)
525 elif "TAUPAIR" in self.random_seed:
526 ge.add_kkmc_generator(path, finalstate='tau+tau-')
527 elif "DDBAR" in self.random_seed:
528 ge.add_continuum_generator(path, finalstate='ddbar')
529 elif "UUBAR" in self.random_seed:
530 ge.add_continuum_generator(path, finalstate='uubar')
531 elif "SSBAR" in self.random_seed:
532 ge.add_continuum_generator(path, finalstate='ssbar')
533 elif "CCBAR" in self.random_seed:
534 ge.add_continuum_generator(path, finalstate='ccbar')
535 # activate simulation of dead/masked pixel and reproduce detector gain, which will be
536 # applied at reconstruction level when the data GT is present in the DB chain
537 # path.add_module("ActivatePXDPixelMasker")
538 # path.add_module("ActivatePXDGainCalibrator")
539 bkg_files = background.get_background_files(self.bkgfiles_dir)
540 # \cond suppress doxygen warning
541 if self.experiment_number == 1002:
542 # remove KLM because of bug in background files with release 4
543 components = ['PXD', 'SVD', 'CDC', 'ECL', 'TOP', 'ARICH', 'TRG']
544 else:
545 components = None
546 # \endcond
547 simulation.add_simulation(path, bkgfiles=bkg_files, bkgOverlay=True, components=components) # , usePXDDataReduction=False)
548
549 path.add_module(
550 "RootOutput",
551 outputFileName=self.get_output_file_name(self.output_file_name()),
552 )
553 return path
554
555
556# I don't use the default MergeTask or similar because they only work if every input file is called the same.
557# Additionally, I want to add more features like deleting the original input to save storage space.
get_background_files(folder=None, output_file_info=True)
Definition background.py:77
add_simulation(path, components=None, bkgfiles=None, bkgOverlay=True, forceSetPXDDataReduction=False, usePXDDataReduction=True, cleanupPXDDataReduction=True, generate_2nd_cdc_hits=False, simulateT0jitter=True, isCosmics=False, FilterEvents=False, usePXDGatedMode=False, skipExperimentCheckForBG=False, ignoreRunNumberForBG=False, save_slow_pions_in_mc=False, save_all_charged_particles_in_mc=False)

◆ output()

output ( self)
Generate list of output files that the task should produce.
The task is considered finished if and only if the outputs all exist.

Definition at line 418 of file combined_quality_estimator_teacher.py.

418 def output(self):
419 """
420 Generate list of output files that the task should produce.
421 The task is considered finished if and only if the outputs all exist.
422 """
423 yield self.add_to_output(self.output_file_name())
424

◆ output_file_name()

output_file_name ( self,
n_events = None,
random_seed = None )

Name of the ROOT output file with generated and simulated events.

Create output file name depending on number of events and production
mode that is specified in the random_seed string.

Definition at line 407 of file combined_quality_estimator_teacher.py.

407 def output_file_name(self, n_events=None, random_seed=None):
408 """
409 Create output file name depending on number of events and production
410 mode that is specified in the random_seed string.
411 """
412 if n_events is None:
413 n_events = self.n_events
414 if random_seed is None:
415 random_seed = self.random_seed
416 return "generated_mc_N" + str(n_events) + "_" + random_seed + ".root"
417

Member Data Documentation

◆ bkgfiles_dir

bkgfiles_dir
static
Initial value:
= b2luigi.Parameter(
)

Directory with overlay background root files.

Definition at line 398 of file combined_quality_estimator_teacher.py.

◆ experiment_number

experiment_number = b2luigi.IntParameter()
static

Experiment number of the conditions database, e.g.

defines simulation geometry

Definition at line 393 of file combined_quality_estimator_teacher.py.

◆ n_events

n_events = b2luigi.IntParameter()
static

Number of events to generate.

Definition at line 391 of file combined_quality_estimator_teacher.py.

◆ queue

str queue = 'l'
static

specify queue.

E.g. choose between 'l' (long), 's' (short) or 'sx' (short, extra ram)

Definition at line 404 of file combined_quality_estimator_teacher.py.

◆ random_seed

random_seed = b2luigi.Parameter()
static

Random basf2 seed.

It is further used to read of the production process to preserve clearness in the b2luigi output.

Definition at line 396 of file combined_quality_estimator_teacher.py.


The documentation for this class was generated from the following file: