Belle II Software  release-08-01-10
GenerateSimTask Class Reference
Inheritance diagram for GenerateSimTask:
Collaboration diagram for GenerateSimTask:

Public Member Functions

def output_file_name (self, n_events=None, random_seed=None)
 Name of the ROOT output file with generated and simulated events. More...
 
def output (self)
 
def 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. More...
 
 random_seed = b2luigi.Parameter()
 Random basf2 seed. More...
 
 bkgfiles_dir
 Directory with overlay background root files. More...
 
string queue = 'l'
 specify queue. More...
 

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 374 of file combined_quality_estimator_teacher.py.

Member Function Documentation

◆ create_path()

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

Definition at line 417 of file combined_quality_estimator_teacher.py.

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

◆ output()

def 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 410 of file combined_quality_estimator_teacher.py.

◆ output_file_name()

def 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 399 of file combined_quality_estimator_teacher.py.

Member Data Documentation

◆ bkgfiles_dir

bkgfiles_dir
static
Initial value:
= b2luigi.Parameter(
)

Directory with overlay background root files.

Definition at line 391 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 386 of file combined_quality_estimator_teacher.py.

◆ queue

string queue = 'l'
static

specify queue.

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

Definition at line 396 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 389 of file combined_quality_estimator_teacher.py.


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