13 Simple example script to simulate cosmics events only with CDC.
15 basf2 runSimulation.py <exp> <run> <nevt> <st>
16 exp: Experimental number
18 nevt: Number of events to be generated
23 from generators
import add_cosmics_generator
25 from cdc.cr
import getDataPeriod, getTriggerType, getMapperAngle
26 from cdc.cr
import add_cdc_cr_simulation
27 from cdc.cr
import add_GCR_Trigger_simulation
31 b2.set_log_level(b2.LogLevel.INFO)
35 b2.use_database_chain()
37 b2.use_central_database(
"GT_gen_data_003.04_gcr2017-08", b2.LogLevel.WARNING)
40 def sim(exp, run, evt, st, topInCounter=False, magneticField=True, fieldMapper=False):
42 exp : Experimental number
44 evt : Number of events to be generated
48 main_path = b2.create_path()
50 main_path.add_module(
'EventInfoSetter',
52 evtNumList=[int(evt)],
55 main_path.add_module(
'Progress')
57 period = getDataPeriod(exp=int(exp),
60 mapperAngle = getMapperAngle(exp=int(exp),
63 triggerType = getTriggerType(exp=int(exp),
66 if fieldMapper
is True:
67 main_path.add_module(
'CDCJobCntlParModifier',
69 MapperPhiAngle=mapperAngle)
71 components = [
'CDC',
'ECL',
'MagneticField']
if magneticField
is True else [
'CDC',
'ECL']
73 add_cosmics_generator(path=main_path,
74 components=components,
75 global_box_size=[8, 8, 8],
76 accept_box=[0.7, 0.3, 0.3],
77 keep_box=[0.7, 0.3, 0.3],
78 cosmics_data_dir=
'data/generators/modules/cryinput/',
79 setup_file=
'./cry.setup',
80 data_taking_period=period,
81 top_in_counter=topInCounter)
84 add_cdc_cr_simulation(main_path, components=components)
86 if triggerType
is not None:
87 add_GCR_Trigger_simulation(main_path,
88 backToBack=
True if triggerType ==
'b2b' else False,
91 b2.B2INFO(
'skip tsim')
93 output = b2.register_module(
'RootOutput',
94 outputFileName=
'gcr.cdc.{0:04d}.{1:06d}.{2:04d}.root'.format(int(exp), int(run), int(st)))
95 main_path.add_module(output)
96 b2.print_path(main_path)
101 if __name__ ==
"__main__":
104 parser = argparse.ArgumentParser()
105 parser.add_argument(
'exp', help=
'Experimental number')
106 parser.add_argument(
'run', help=
'Run number')
107 parser.add_argument(
'evt', help=
'Number of events to be generated')
108 parser.add_argument(
'st', help=
'Stream ID')
110 args = parser.parse_args()
111 sim(args.exp, args.run, args.evt, args.st, topInCounter=
False, magneticField=
True, fieldMapper=
True)