9 """CDC fudge factor calibration."""
10 from prompt
import CalibrationSettings, INPUT_DATA_FILTERS
11 from prompt.calibrations.caf_cdc
import settings
as cdc_tracking_calibration
12 from prompt.calibrations.caf_vxdcdc_alignment
import settings
as full_alignment
15 from ROOT
import Belle2
16 from caf.framework
import Calibration
17 from caf
import strategies
18 from modularAnalysis
import fillParticleList, cutAndCopyList, reconstructDecay, applyCuts
19 from vertex
import treeFit
22 settings = CalibrationSettings(name=
"CDC Sigma fudge factor",
23 expert_username=
"dvthanh",
25 input_data_formats=[
"raw"],
26 input_data_names=[
"mumu_tight_or_highm_calib"],
27 input_data_filters={
"mumu_tight_or_highm_calib":
28 [INPUT_DATA_FILTERS[
"Data Tag"][
"mumu_tight_or_highm_calib"],
29 INPUT_DATA_FILTERS[
"Data Quality Tag"][
"Good"],
30 INPUT_DATA_FILTERS[
"Magnet"][
"On"]]},
31 depends_on=[cdc_tracking_calibration, full_alignment],
34 "min_events_per_file": 500,
35 "max_events_per_file": 30000,
36 "components": [
"CDC",
"ECL",
"KLM"],
38 "payload_boundaries": [],
39 "backend_args": {
"request_memory":
"4 GB"}
47 def get_calibrations(input_data, **kwargs):
50 expert_config = kwargs.get(
"expert_config")
51 min_events_per_file = expert_config[
"min_events_per_file"]
52 max_events_per_file = expert_config[
"max_events_per_file"]
54 components = expert_config[
"components"]
55 vertex_fit = expert_config[
"vertex_fit"]
56 fileFormat = expert_config[
"fileFormat"]
59 file_to_iov_mumu = input_data[
"mumu_tight_or_highm_calib"]
62 reduced_file_to_iov_mumu = filter_by_max_files_per_run(file_to_iov_mumu, 100, min_events_per_file)
63 input_files_mumu = list(reduced_file_to_iov_mumu.keys())
64 basf2.B2INFO(
"Complete input data selection.")
65 basf2.B2INFO(f
"Total number of files actually used as input = {len(input_files_mumu)}")
67 payload_boundaries = []
68 payload_boundaries.extend([ExpRun(*boundary)
for boundary
in expert_config[
"payload_boundaries"]])
69 basf2.B2INFO(f
"Payload boundaries from expert_config: {payload_boundaries}")
71 from caf.utils
import IoV
73 requested_iov = kwargs.get(
"requested_iov",
None)
74 output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
77 collector_granularity =
'all'
78 if payload_boundaries:
79 basf2.B2INFO(
'Found payload_boundaries: set collector granularity to run')
80 collector_granularity =
'run'
84 col = basf2.register_module(
"CDCFudgeFactorCalibrationCollector",
85 granularity=collector_granularity)
88 algo.setHistFileName(
"histo_fudge_factor.root")
94 input_files=input_files_mumu,
95 pre_collector_path=pre_collector(max_events_per_file,
96 components=components,
97 fileFormat=fileFormat,
98 vertex_fit=vertex_fit))
103 if payload_boundaries:
104 basf2.B2INFO(
"Found payload_boundaries: calibration strategies set to SequentialBoundaries.")
105 fudge_calib.strategies = strategies.SequentialBoundaries
106 for alg
in fudge_calib.algorithms:
107 alg.params = {
"iov_coverage": output_iov,
"payload_boundaries": payload_boundaries}
109 for alg
in fudge_calib.algorithms:
110 alg.params = {
"apply_iov": output_iov}
116 def pre_collector(max_events=None, components=["CDC", "ECL", "KLM"], fileFormat="RAW", vertex_fit=0):
118 Define pre collection (reconstruction in our purpose).
119 Probably, we need only CDC and ECL data.
121 max_events [int] : number of events to be processed.
122 All events by Default.
124 path : path for pre collection
126 from basf2
import create_path, register_module
128 reco_path = create_path()
129 if fileFormat ==
"RAW":
130 if max_events
is None:
131 root_input = register_module(
'RootInput', branchNames=HLT_INPUT_OBJECTS)
133 root_input = register_module(
'RootInput', branchNames=HLT_INPUT_OBJECTS,
134 entrySequences=
'0:{}'.format(max_events))
135 reco_path.add_module(root_input)
137 from rawdata
import add_unpackers
138 from reconstruction
import add_reconstruction
139 add_unpackers(reco_path, components=components)
141 add_reconstruction(reco_path,
142 components=components,
143 append_full_grid_cdc_eventt0=
True)
144 if fileFormat ==
"mdst":
145 from modularAnalysis
import inputMdst
146 inputMdst(filename=
"", path=reco_path, environmentType=
'default', skipNEvents=0, entrySequence=[
'0:{}'.format(max_events)])
148 reco_path.add_module(
'Progress')
149 fillParticleList(
'gamma:HLT',
'E>0.1', path=reco_path)
150 goodTrack =
'abs(d0) < 2.0 and abs(z0) < 4.0 and pt > 2.0 and useCMSFrame(p) > 0.5'
151 fillParticleList(
'mu+:HLT', goodTrack, path=reco_path)
152 cutAndCopyList(
'mu+:sel',
'mu+:HLT', goodTrack, path=reco_path)
153 reconstructDecay(
'vpho:mumu -> mu+:sel mu-:sel',
'', path=reco_path)
154 applyCuts(
'vpho:mumu',
'[nCleanedTracks('+goodTrack+
') == 2]', path=reco_path)
156 treeFit(
'vpho:mumu', ipConstraint=
False, updateAllDaughters=
False, path=reco_path)
Class for CDC fudge factor calibration .