Belle II Software development
GenerateSimTask Class Reference
Inheritance 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.
 
def output (self)
 
def create_path (self)
 

Static Public Attributes

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

◆ 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.

410 def output(self):
411 """
412 Generate list of output files that the task should produce.
413 The task is considered finished if and only if the outputs all exist.
414 """
415 yield self.add_to_output(self.output_file_name())
416

◆ 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.

399 def output_file_name(self, n_events=None, random_seed=None):
400 """
401 Create output file name depending on number of events and production
402 mode that is specified in the random_seed string.
403 """
404 if n_events is None:
405 n_events = self.n_events
406 if random_seed is None:
407 random_seed = self.random_seed
408 return "generated_mc_N" + str(n_events) + "_" + random_seed + ".root"
409

Member Data Documentation

◆ bkgfiles_dir

b2luigi bkgfiles_dir
static
Initial value:
= b2luigi.Parameter(
)

Directory with overlay background root files.

Definition at line 390 of file combined_quality_estimator_teacher.py.

◆ experiment_number

b2luigi experiment_number = b2luigi.IntParameter()
static

Experiment number of the conditions database, e.g.

defines simulation geometry

Definition at line 385 of file combined_quality_estimator_teacher.py.

◆ n_events

b2luigi n_events = b2luigi.IntParameter()
static

Number of events to generate.

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

◆ random_seed

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


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