11Simultaneous Global and Local VXD and CDC (layers-only) alignment with Millepede II
13The input collections can be (only single tracks currently):
14- cosmics (hlt skim) - mandatorry
15- physics - all raw data -> once off-ip is available, this can be omitted
16- hadron - for "low" momentum tracks from IP
17- mumu - mumu_2trk or mumu_tight - for high momentum tracks from IP
18- offip - not yet available - tracks from outside IP (beam background, beam-gas)
20Time-dependence can be (manually) configured for VXD half-shells and CDC layers.
21For example to allow VXD alignment to change in run 10, 20 an 30 in experiment 12, you set:
23>>> timedep_vxd : [[0, 10, 12], [0, 20, 12], [0, 30, 12]]
25Note that the first run in your requested iov will be added automatically.
29from prompt
import CalibrationSettings
30from prompt.calibrations.caf_cdc
import settings
as cdc_calibration
32collection_names = [
"physics",
"cosmic",
"hadron",
"mumu",
"offip"]
36 'min_entries': 1000000,
38 'method':
'diagonalization 3 0.1',
44 "physics.min_events": 400000,
45 "physics.max_processed_events_per_file": 2000,
47 "cosmic.min_events": 1000000,
48 "cosmic.max_processed_events_per_file": 5000,
50 "hadron.min_events": 100000,
51 "hadron.max_processed_events_per_file": 1000,
53 "mumu.min_events": 400000,
54 "mumu.max_processed_events_per_file": 3000,
56 "offip.min_events": 400000,
57 "offip.max_processed_events_per_file": 2000,
64settings = CalibrationSettings(name=
"VXD and CDC Alignment",
65 expert_username=
"bilkat",
67 input_data_formats=[
"raw"],
68 input_data_names=collection_names,
69 expert_config=default_config,
70 depends_on=[cdc_calibration])
73def select_files(all_input_files, min_events, max_processed_events_per_file):
75 from random
import choice
80 while total_events < min_events:
83 if not all_input_files:
86 new_file_choice = choice(all_input_files)
88 all_input_files.remove(new_file_choice)
90 total_events_in_file = events_in_basf2_file(new_file_choice)
91 if not total_events_in_file:
95 events_contributed = min(total_events_in_file, max_processed_events_per_file)
97 chosen_files.append(new_file_choice)
98 total_events += events_contributed
100 basf2.B2INFO(f
"Total chosen files = {len(chosen_files)}")
101 basf2.B2INFO(f
"Total events in chosen files = {total_events}")
102 if total_events < min_events:
104 f
"There weren't enough files events selected when max_processed_events_per_file={max_processed_events_per_file}")
108def create_std_path():
110 import rawdata
as raw
111 import reconstruction
as reco
113 path = basf2.create_path()
114 path.add_module(
'Progress')
115 path.add_module(
'RootInput')
116 path.add_module(
'Gearbox')
117 path.add_module(
'Geometry')
118 raw.add_unpackers(path)
119 path.add_module(
'SetupGenfitExtrapolation')
120 reco.add_reconstruction(
123 skipGeometryAdding=
True,
125 path.add_module(
'DAFRecoFitter')
129def create_cosmics_path():
131 import rawdata
as raw
132 import reconstruction
as reco
133 import modularAnalysis
as ana
135 path = basf2.create_path()
136 path.add_module(
'Progress')
138 path.add_module(
'RootInput')
139 path.add_module(
'Gearbox')
140 path.add_module(
'Geometry')
143 triggerLines=[
"software_trigger_cut&filter&cosmic"]).if_value(
146 basf2.AfterConditionPath.END)
148 raw.add_unpackers(path)
149 path.add_module(
'SetupGenfitExtrapolation')
150 reco.add_cosmics_reconstruction(
153 skipGeometryAdding=
True,
154 addClusterExpertModules=
False,
158 path.add_module(
'SetRecoTrackMomentum', automatic=
True)
159 path.add_module(
'DAFRecoFitter', pdgCodesToUseForFitting=[13])
161 ana.fillParticleList(
162 'mu+:goodForVXDCDCAlignment',
163 '[z0 <= 57. or abs(d0) >= 26.5] and abs(dz) > 0.4 and nTracks == 1',
165 path.add_module(
'SkimFilter', particleLists=[
'mu+:goodForVXDCDCAlignment']).if_false(basf2.create_path())
174def get_calibrations(input_data, **kwargs):
178 from caf.utils
import IoV
180 import millepede_calibration
as mpc
185 from random
import seed
188 cfg = kwargs[
'expert_config']
191 for colname
in collection_names:
192 file_to_iov = input_data[colname]
193 input_files = list(file_to_iov.keys())
195 if not len(input_files):
199 basf2.B2INFO(f
"Selecting files for: {colname}")
200 input_files = select_files(input_files[:], cfg[f
'{colname}.min_events'], cfg[f
'{colname}.max_processed_events_per_file'])
201 files[colname] = input_files
204 requested_iov = kwargs.get(
"requested_iov",
None)
206 output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
209 method = cfg[
'method']
210 scaleerrors = cfg[
'scaleerrors']
211 entries = cfg[
'entries']
215 timedep_vxd = cfg[
'timedep_vxd']
216 timedep_cdc = cfg[
'timedep_cdc']
219 slices = [(erx[0], erx[1], erx[2])
for erx
in timedep_vxd] + [(0, requested_iov.run_low, requested_iov.exp_low)]
223 slices = [(erx[0], erx[1], erx[2])
for erx
in timedep_cdc] + [(0, requested_iov.run_low, requested_iov.exp_low)]
227 name=
'VXDCDCalignment',
228 dbobjects=[
'VXDAlignment',
'CDCAlignment'],
230 mpc.make_collection(
"cosmic", path=create_cosmics_path(), tracks=[
"RecoTracks"]),
231 mpc.make_collection(
"physics", path=create_std_path(), tracks=[
"RecoTracks"]),
232 mpc.make_collection(
"hadron", path=create_std_path(), tracks=[
"RecoTracks"]),
233 mpc.make_collection(
"mumu", path=create_std_path(), tracks=[
"RecoTracks"]),
234 mpc.make_collection(
"offip", path=create_std_path(), tracks=[
"RecoTracks"])
246 f
"scaleerrors {scaleerrors} {scaleerrors}",
247 f
"entries {entries}"],
248 params=dict(minPValue=cfg[
'minPValue'], externalIterations=0),
249 min_entries=cfg[
'min_entries'])
251 for colname
in collection_names:
252 max_processed_events_per_file = cfg[f
'{colname}.max_processed_events_per_file']
253 basf2.set_module_parameters(
254 cal.collections[colname].pre_collector_path,
256 entrySequences=[f
'0:{max_processed_events_per_file}'])
260 fix_mille_paths_for_algo(cal.algorithms[0])
263 cal.max_iterations = cfg[
'max_iterations']
267 for algorithm
in cal.algorithms:
268 algorithm.params = {
"apply_iov": output_iov}
def vxd_halfshells(pxd=True, svd=True, parameters=None, ying=True, yang=True, pat=True, mat=True)
def vxd_sensors(layers=None, rigid=True, surface=True, surface2=True, surface3=True, surface4=True, parameters=None)
def cdc_layers(layers=None)