Belle II Software development
run_eclBhabhaTimeCalibrationValidation_collector.py
1#!/usr/bin/env python3
2
3
10
11
19
20# There are two ways you can use this script:
21# 1. Provide parameters from command line:
22# basf2 run_eclBhabhaTimeCalibrationValidation_collector.py -i "/path/to/input/files/*.root" -o collector_output.root
23#
24# 2. Set parameters directly in steering file.
25# Change INPUT_LIST and OUTPUT variables.
26# (Multiple files can be easily added with glob.glob("/path/to/your/files/*.root"))
27# And then call
28# basf2 run_eclBhabhaTimeCalibrationValidation_collector.py
29
30
31import basf2 as b2
32from ROOT import Belle2
33import glob
34import tracking
35import rawdata
36import reconstruction
37
38from basf2 import conditions as b2conditions
39from reconstruction import prepare_user_cdst_analysis
40
41
43
44
47
48# == List of input files
49# NOTE: It is going to be sorted (alphabetic and length sorting, files with
50# shortest names are first)
51INPUT_LIST = []
52# = Processed data
53INPUT_LIST += glob.glob("oneTestFile/*.root")
54
55# == Output file
56OUTPUT = "eclBhabhaTimeCalibrationValidationCollector.root"
57
58
60
61# Override input if "-i file.root" argument was sent to basf2.
62input_arg = env.getInputFilesOverride()
63if len(input_arg) > 0:
64 INPUT_LIST = [str(x) for x in input_arg]
65# Sort list of input files.
66INPUT_LIST.sort(key=lambda item: (len(item), item))
67
68# Override output if "-o file.root" argument was sent to basf2.
69output_arg = env.getOutputFileOverride()
70if len(output_arg) > 0:
71 OUTPUT = output_arg
72
73
76
77
78# Events with abs(time_ECL-time_CDC) > TIME_ABS_MAX are excluded
79TIME_ABS_MAX = 70
80
81# If true, output file will contain TTree "tree" with detailed
82# event information.
83SAVE_TREE = True
84
85
86
87components = ['CDC', 'ECL']
88
89# == Create path
90main = b2.create_path()
91
92add_unpackers = False
93
94# == SeqRoot/Root input
95if INPUT_LIST[0].endswith('sroot'):
96 main.add_module('SeqRootInput', inputFileNames=INPUT_LIST)
97 add_unpackers = True
98else:
99 main.add_module('RootInput', inputFileNames=INPUT_LIST)
100
101main.add_module("HistoManager", histoFileName=OUTPUT)
102
103if 'Raw' in INPUT_LIST[0]:
104 add_unpackers = True
105
106
107main.add_module('Gearbox')
108
109if add_unpackers:
110 rawdata.add_unpackers(main, components=components)
111
112 # = Get Tracks, RecoTracks, ECLClusters, add relations between them.
113 tracking.add_tracking_reconstruction(main, components=components)
114 reconstruction.add_ext_module(main, components)
115 reconstruction.add_ecl_modules(main, components)
116 reconstruction.add_ecl_track_matcher_module(main, components)
117
118prepare_user_cdst_analysis(main) # for new 2020 cdst format
119
120# == Generate time calibration matrix from ECLDigit
121ECLtimeCalibValidationCollectorInfo = main.add_module('eclBhabhaTimeCalibrationValidationCollector', timeAbsMax=TIME_ABS_MAX,
122 saveTree=SAVE_TREE)
123
124ECLtimeCalibValidationCollectorInfo.set_log_level(b2.LogLevel.INFO) # OR: b2.LogLevel.DEBUG
125ECLtimeCalibValidationCollectorInfo.set_debug_level(36)
126
127
128# == Show progress
129main.add_module('Progress')
130
131b2.set_log_level(b2.LogLevel.INFO)
132b2.set_debug_level(100)
133
134# == Configure database
135# reset_database()
136# use_database_chain()
137
138b2conditions.reset()
139b2conditions.override_globaltags()
140
141b2.B2INFO("Adding Local Database {} to head of chain of local databases.")
142b2conditions.prepend_testing_payloads("localdb/database.txt")
143b2.B2INFO("Using Global Tag {}")
144b2conditions.prepend_globaltag("dp_recon_release6_patch")
145b2conditions.prepend_globaltag("Reco_master_patch_rel5")
146b2conditions.prepend_globaltag("AIRFLOW_online_snapshot_20210719-124441")
147b2conditions.prepend_globaltag("data_reprocessing_prompt")
148
149
150# == Process events
151# b2.process(main, max_event=350000) # reasonable stats for one crate
152# b2.process(main, max_event=600000) # reasonable stats for crystal calibs for proc10
153# b2.process(main, max_event=3000) # reasonable stats and speed for a quick test
154# b2.process(main, max_event=30) # fast test
155b2.process(main) # process all events
156
157print(b2.statistics)
static Environment & Instance()
Static method to get a reference to the Environment instance.
Definition: Environment.cc:28
def add_unpackers(path, components=None, writeKLMDigitRaws=False, addTOPRelations=False)
Definition: rawdata.py:67
def add_ecl_modules(path, components=None)
def add_ext_module(path, components=None)