9"""Full CDC tracking calibration."""
10from prompt
import CalibrationSettings, INPUT_DATA_FILTERS
13from ROOT
import Belle2
14from caf.framework
import Calibration
15from caf
import strategies
16from modularAnalysis
import fillParticleList, cutAndCopyList, reconstructDecay, applyCuts
17from vertex
import treeFit
20settings = CalibrationSettings(name=
"CDC Sigma fudge factor",
21 expert_username=
"dvthanh",
23 input_data_formats=[
"raw"],
24 input_data_names=[
"mumu_tight_or_highm_calib"],
25 input_data_filters={
"mumu_tight_or_highm_calib":
26 [INPUT_DATA_FILTERS[
"Data Tag"][
"mumu_tight_or_highm_calib"],
27 INPUT_DATA_FILTERS[
"Data Quality Tag"][
"Good"],
28 INPUT_DATA_FILTERS[
"Magnet"][
"On"]]},
32 "min_events_per_file": 500,
33 "max_events_per_file": 30000,
34 "components": [
"CDC",
"ECL",
"KLM"],
36 "payload_boundaries": [],
37 "backend_args": {
"request_memory":
"4 GB"}
45def get_calibrations(input_data, **kwargs):
48 expert_config = kwargs.get(
"expert_config")
49 min_events_per_file = expert_config[
"min_events_per_file"]
50 max_events_per_file = expert_config[
"max_events_per_file"]
52 components = expert_config[
"components"]
53 vertex_fit = expert_config[
"vertex_fit"]
54 fileFormat = expert_config[
"fileFormat"]
57 file_to_iov_mumu = input_data[
"mumu_tight_or_highm_calib"]
60 reduced_file_to_iov_mumu = filter_by_max_files_per_run(file_to_iov_mumu, 100, min_events_per_file)
61 input_files_mumu = list(reduced_file_to_iov_mumu.keys())
62 basf2.B2INFO(
"Complete input data selection.")
63 basf2.B2INFO(f
"Total number of files actually used as input = {len(input_files_mumu)}")
65 payload_boundaries = []
66 payload_boundaries.extend([ExpRun(*boundary)
for boundary
in expert_config[
"payload_boundaries"]])
67 basf2.B2INFO(f
"Payload boundaries from expert_config: {payload_boundaries}")
69 from caf.utils
import IoV
71 requested_iov = kwargs.get(
"requested_iov",
None)
72 output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
75 collector_granularity =
'all'
76 if payload_boundaries:
77 basf2.B2INFO(
'Found payload_boundaries: set collector granularity to run')
78 collector_granularity =
'run'
82 col = basf2.register_module(
"CDCFudgeFactorCalibrationCollector",
83 granularity=collector_granularity)
86 algo.setHistFileName(
"histo_fudge_factor.root")
92 input_files=input_files_mumu,
93 pre_collector_path=pre_collector(max_events_per_file,
94 components=components,
95 fileFormat=fileFormat,
96 vertex_fit=vertex_fit))
101 if payload_boundaries:
102 basf2.B2INFO(
"Found payload_boundaries: calibration strategies set to SequentialBoundaries.")
103 fudge_calib.strategies = strategies.SequentialBoundaries
104 for alg
in fudge_calib.algorithms:
105 alg.params = {
"iov_coverage": output_iov,
"payload_boundaries": payload_boundaries}
107 for alg
in fudge_calib.algorithms:
108 alg.params = {
"apply_iov": output_iov}
114def pre_collector(max_events=None, components=["CDC", "ECL", "KLM"], fileFormat="RAW", vertex_fit=0):
116 Define pre collection (reconstruction in our purpose).
117 Probably, we need only CDC
and ECL data.
119 max_events [int] : number of events to be processed.
120 All events by Default.
122 path : path
for pre collection
124 from basf2
import create_path, register_module
126 reco_path = create_path()
127 if fileFormat ==
"RAW":
128 if max_events
is None:
129 root_input = register_module(
'RootInput', branchNames=HLT_INPUT_OBJECTS)
131 root_input = register_module(
'RootInput', branchNames=HLT_INPUT_OBJECTS,
132 entrySequences=[
'0:{}'.format(max_events)])
133 reco_path.add_module(root_input)
135 from rawdata
import add_unpackers
136 from reconstruction
import add_reconstruction
137 add_unpackers(reco_path, components=components)
139 add_reconstruction(reco_path,
140 components=components,
141 append_full_grid_cdc_eventt0=
True,
142 skip_full_grid_cdc_eventt0_if_svd_time_present=
False)
143 if fileFormat ==
"mdst":
144 from modularAnalysis
import inputMdst
145 inputMdst(filename=
"", path=reco_path, environmentType=
'default', skipNEvents=0, entrySequence=[
'0:{}'.format(max_events)])
147 reco_path.add_module(
'Progress')
148 fillParticleList(
'gamma:HLT',
'E>0.1', path=reco_path)
149 goodTrack =
'abs(d0) < 2.0 and abs(z0) < 4.0 and pt > 2.0 and useCMSFrame(p) > 0.5'
150 fillParticleList(
'mu+:HLT', goodTrack, path=reco_path)
151 cutAndCopyList(
'mu+:sel',
'mu+:HLT', goodTrack, path=reco_path)
152 reconstructDecay(
'vpho:mumu -> mu+:sel mu-:sel',
'', path=reco_path)
153 applyCuts(
'vpho:mumu',
'[nCleanedTracks('+goodTrack+
') == 2]', path=reco_path)
155 treeFit(
'vpho:mumu', ipConstraint=
False, updateAllDaughters=
False, path=reco_path)
Class for CDC fudge factor calibration .