11from basf2
import process, set_random_seed, create_path, statistics, print_path, B2FATAL
13from basf2
import conditions
as b2c
14from simulation
import add_simulation
15from tracking
import add_prefilter_tracking_reconstruction
17from tracking.FlippingMVA.savingFlippingVariables
import Saving1stMVAData
18from tracking.FlippingMVA.savingFlippingVariablesFor2ndMVA
import Saving2ndMVAData
19from background
import get_background_files
23generating BBbar MC samples for training and testing the track-flipping MVAs
28 parser = argparse.ArgumentParser(description=__doc__)
29 parser.add_argument(
'-n',
'--events',
32 help=
'Number of events to be processed. Default is 1000.',
34 parser.add_argument(
'--no_bkg',
37 help=
'Flag to include background in the simulation. Default is False')
38 parser.add_argument(
'--exp',
41 help=
'Experiment number you want to simulate. Default is 0.',
43 parser.add_argument(
'--prepend_gt',
47 help=
'Global Tags to be prepended',
49 parser.add_argument(
'--output_file_mva',
50 default=
'BBbar_mva1.root',
52 help=
'Output file name. Default is \'\'.')
53 parser.add_argument(
'--output_file_mva2',
54 default=
'BBbar_mva2.root',
56 help=
'Output file2 name. Default is \'\'.')
57 parser.add_argument(
'--num',
60 help=
'The index of track-flipping MVA variables to be saved. (1 or 2). Default is 1.',
62 parser.add_argument(
'--randseed',
65 help=
'Random seed value. Default is 0.',
70if __name__ ==
"__main__":
74 args = arg_parser().parse_args()
77 B2FATAL(
"Number of events to process must be larger than 0. Terminating here.")
79 if args.num
not in [1, 2]:
80 B2FATAL(
"Argument num must be either 1 or 2. Terminating here.")
81 training_mva_number = args.num
83 if args.exp
not in [0, 1003]:
84 B2FATAL(
"Argument exp must be either 0 or 1003. Terminating here.")
86 if args.output_file_mva ==
'':
87 B2FATAL(
"Empty output file name. Terminating here.")
90 set_random_seed(args.randseed)
93 if not (args.prepend_gt ==
''):
94 for gt
in reversed(args.prepend_gt):
95 b2c.prepend_globaltag(gt)
98 bkgFiles = get_background_files()
105 main.add_module(
'EventInfoSetter', evtNumList=[args.events], runList=[0], expList=[args.exp])
106 main.add_module(
"EvtGenInput")
108 add_simulation(main, bkgfiles=bkgFiles)
113 add_prefilter_tracking_reconstruction(main)
115 main.add_module(
'TrackTimeEstimator')
116 add_mc_matcher(main, reco_tracks=
"RecoTracks")
119 if (training_mva_number):
120 main.add_module(
"FlipQuality", recoTracksStoreArrayName=
"RecoTracks",
121 identifier=
'TRKTrackFlipAndRefit_MVA1_weightfile',
122 indexOfFlippingMVA=1).set_name(
"FlipQuality_1stMVA")
124 reco_tracks_flipped =
"RecoTracks_flipped"
125 main.add_module(
"RecoTracksReverter", inputStoreArrayName=
"RecoTracks",
126 outputStoreArrayName=reco_tracks_flipped)
127 main.add_module(
"DAFRecoFitter", recoTracksStoreArrayName=reco_tracks_flipped).set_name(
"Combined_DAFRecoFitter_flipped")
128 main.add_module(
"IPTrackTimeEstimator",
129 recoTracksStoreArrayName=reco_tracks_flipped, useFittedInformation=
False)
130 main.add_module(
"TrackCreator", trackColName=
"Tracks_flipped",
131 trackFitResultColName=
"TrackFitResults_flipped",
132 recoTrackColName=reco_tracks_flipped,
133 pdgCodes=[211, 321, 2212]).set_name(
"TrackCreator_flipped")
134 main.add_module(
"FlipQuality", recoTracksStoreArrayName=
"RecoTracks",
135 identifier=
'TRKTrackFlipAndRefit_MVA2_weightfile',
136 indexOfFlippingMVA=2).set_name(
"FlipQuality_2ndMVA")
137 if (training_mva_number == 1):
138 saveFirstMVAData = Saving1stMVAData(
139 name=
"saving1stMVA_BBbar",
140 output_file_name=args.output_file_mva)
141 main.add_module(saveFirstMVAData)
143 saveSecondMVAData = Saving2ndMVAData(
144 name=
"saving2ndMVA_BBbar",
145 output_file_name=args.output_file_mva2)
146 main.add_module(saveSecondMVAData)
151 main.add_module(
"Progress")