12Simple example script to simulate cosmics events only with CDC.
14basf2 runSimulation.py <exp> <run> <nevt> <st>
15exp: Experimental number
17nevt: Number of events to be generated
22from generators
import add_cosmics_generator
24from cdc.cr
import getDataPeriod, getTriggerType, getMapperAngle
25from cdc.cr
import add_cdc_cr_simulation
26from cdc.cr
import add_GCR_Trigger_simulation
30b2.set_log_level(b2.LogLevel.INFO)
34b2.use_database_chain()
36b2.use_central_database(
"GT_gen_data_003.04_gcr2017-08", b2.LogLevel.WARNING)
39def sim(exp, run, evt, st, topInCounter=False, magneticField=True, fieldMapper=False):
41 exp : Experimental number
43 evt : Number of events to be generated
47 main_path = b2.create_path()
49 main_path.add_module('EventInfoSetter',
51 evtNumList=[int(evt)],
54 main_path.add_module(
'Progress')
56 period = getDataPeriod(exp=int(exp),
59 mapperAngle = getMapperAngle(exp=int(exp),
62 triggerType = getTriggerType(exp=int(exp),
65 if fieldMapper
is True:
66 main_path.add_module(
'CDCJobCntlParModifier',
68 MapperPhiAngle=mapperAngle)
70 components = [
'CDC',
'ECL',
'MagneticField']
if magneticField
is True else [
'CDC',
'ECL']
72 add_cosmics_generator(path=main_path,
73 components=components,
74 global_box_size=[8, 8, 8],
75 accept_box=[0.7, 0.3, 0.3],
76 keep_box=[0.7, 0.3, 0.3],
77 cosmics_data_dir=
'data/generators/modules/cryinput/',
78 setup_file=
'./cry.setup',
79 data_taking_period=period,
80 top_in_counter=topInCounter)
83 add_cdc_cr_simulation(main_path, components=components)
85 if triggerType
is not None:
86 add_GCR_Trigger_simulation(main_path,
87 backToBack=
True if triggerType ==
'b2b' else False,
90 b2.B2INFO(
'skip tsim')
92 output = b2.register_module(
'RootOutput',
93 outputFileName=f
'gcr.cdc.{int(exp):04d}.{int(run):06d}.{int(st):04d}.root')
94 main_path.add_module(output)
95 b2.print_path(main_path)
100if __name__ ==
"__main__":
103 parser = argparse.ArgumentParser()
104 parser.add_argument(
'exp', help=
'Experimental number')
105 parser.add_argument(
'run', help=
'Run number')
106 parser.add_argument(
'evt', help=
'Number of events to be generated')
107 parser.add_argument(
'st', help=
'Stream ID')
109 args = parser.parse_args()
110 sim(args.exp, args.run, args.evt, args.st, topInCounter=
False, magneticField=
True, fieldMapper=
True)