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