13 Simultaneous Global and Local VXD and CDC (layers-only) alignment with Millepede II
15 The input collections can be (only single tracks currently):
16 - cosmics (hlt skim) - mandatorry
17 - physics - all raw data -> once off-ip is available, this can be omitted
18 - hadron - for "low" momentum tracks from IP
19 - mumu - mumu_2trk or mumu_tight - for high momentum tracks from IP
20 - offip - not yet available - tracks from outside IP (beam background, beam-gas)
22 Time-dependence can be (manually) configured for VXD half-shells and CDC layers.
23 For example to allow VXD alignment to change in run 10, 20 an 30 in experiment 12, you set:
25 >>> timedep_vxd : [[0, 10, 12], [0, 20, 12], [0, 30, 12]]
27 Note that the first run in your requested iov will be added automatically.
31 from prompt
import CalibrationSettings
32 from prompt.calibrations.caf_cdc
import settings
as cdc_calibration
34 collection_names = [
"physics",
"cosmic",
"hadron",
"mumu",
"offip"]
38 'min_entries': 1000000,
40 'method':
'diagonalization 3 0.1',
46 "physics.min_events": 400000,
47 "physics.max_processed_events_per_file": 2000,
49 "cosmic.min_events": 1000000,
50 "cosmic.max_processed_events_per_file": 5000,
52 "hadron.min_events": 100000,
53 "hadron.max_processed_events_per_file": 1000,
55 "mumu.min_events": 400000,
56 "mumu.max_processed_events_per_file": 3000,
58 "offip.min_events": 400000,
59 "offip.max_processed_events_per_file": 2000,
66 settings = CalibrationSettings(name=
"VXD and CDC Alignment",
67 expert_username=
"bilkat",
69 input_data_formats=[
"raw"],
70 input_data_names=collection_names,
71 expert_config=default_config,
72 depends_on=[cdc_calibration])
75 def select_files(all_input_files, min_events, max_processed_events_per_file):
77 from random
import choice
82 while total_events < min_events:
85 if not all_input_files:
88 new_file_choice = choice(all_input_files)
90 all_input_files.remove(new_file_choice)
92 total_events_in_file = events_in_basf2_file(new_file_choice)
93 if not total_events_in_file:
97 events_contributed = min(total_events_in_file, max_processed_events_per_file)
99 chosen_files.append(new_file_choice)
100 total_events += events_contributed
102 basf2.B2INFO(f
"Total chosen files = {len(chosen_files)}")
103 basf2.B2INFO(f
"Total events in chosen files = {total_events}")
104 if total_events < min_events:
106 f
"There weren't enough files events selected when max_processed_events_per_file={max_processed_events_per_file}")
110 def create_std_path():
112 import rawdata
as raw
113 import reconstruction
as reco
115 path = basf2.create_path()
116 path.add_module(
'Progress')
117 path.add_module(
'RootInput')
118 path.add_module(
'Gearbox')
119 path.add_module(
'Geometry')
120 raw.add_unpackers(path)
121 path.add_module(
'SetupGenfitExtrapolation')
122 reco.add_reconstruction(
125 skipGeometryAdding=
True,
127 path.add_module(
'DAFRecoFitter')
131 def create_cosmics_path():
133 import rawdata
as raw
134 import reconstruction
as reco
135 import modularAnalysis
as ana
137 path = basf2.create_path()
138 path.add_module(
'Progress')
140 path.add_module(
'RootInput')
141 path.add_module(
'Gearbox')
142 path.add_module(
'Geometry')
145 triggerLines=[
"software_trigger_cut&filter&cosmic"]).if_value(
148 basf2.AfterConditionPath.END)
150 raw.add_unpackers(path)
151 path.add_module(
'SetupGenfitExtrapolation')
152 reco.add_cosmics_reconstruction(
155 skipGeometryAdding=
True,
156 addClusterExpertModules=
False,
160 path.add_module(
'SetRecoTrackMomentum', automatic=
True)
161 path.add_module(
'DAFRecoFitter', pdgCodesToUseForFitting=[13])
163 ana.fillParticleList(
164 'mu+:goodForVXDCDCAlignment',
165 '[z0 <= 57. or abs(d0) >= 26.5] and abs(dz) > 0.4 and nTracks == 1',
167 path.add_module(
'SkimFilter', particleLists=[
'mu+:goodForVXDCDCAlignment']).if_false(basf2.create_path())
176 def get_calibrations(input_data, **kwargs):
180 from caf.utils
import IoV
182 import millepede_calibration
as mpc
187 from random
import seed
190 cfg = kwargs[
'expert_config']
193 for colname
in collection_names:
194 file_to_iov = input_data[colname]
195 input_files = list(file_to_iov.keys())
197 if not len(input_files):
201 basf2.B2INFO(f
"Selecting files for: {colname}")
202 input_files = select_files(input_files[:], cfg[f
'{colname}.min_events'], cfg[f
'{colname}.max_processed_events_per_file'])
203 files[colname] = input_files
206 requested_iov = kwargs.get(
"requested_iov",
None)
208 output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
211 method = cfg[
'method']
212 scaleerrors = cfg[
'scaleerrors']
213 entries = cfg[
'entries']
217 timedep_vxd = cfg[
'timedep_vxd']
218 timedep_cdc = cfg[
'timedep_cdc']
221 slices = [(erx[0], erx[1], erx[2])
for erx
in timedep_vxd] + [(0, requested_iov.run_low, requested_iov.exp_low)]
225 slices = [(erx[0], erx[1], erx[2])
for erx
in timedep_cdc] + [(0, requested_iov.run_low, requested_iov.exp_low)]
229 name=
'VXDCDCalignment',
230 dbobjects=[
'VXDAlignment',
'CDCAlignment'],
232 mpc.make_collection(
"cosmic", path=create_cosmics_path(), tracks=[
"RecoTracks"]),
233 mpc.make_collection(
"physics", path=create_std_path(), tracks=[
"RecoTracks"]),
234 mpc.make_collection(
"hadron", path=create_std_path(), tracks=[
"RecoTracks"]),
235 mpc.make_collection(
"mumu", path=create_std_path(), tracks=[
"RecoTracks"]),
236 mpc.make_collection(
"offip", path=create_std_path(), tracks=[
"RecoTracks"])
248 f
"scaleerrors {scaleerrors} {scaleerrors}",
249 f
"entries {entries}"],
250 params=dict(minPValue=cfg[
'minPValue'], externalIterations=0),
251 min_entries=cfg[
'min_entries'])
253 for colname
in collection_names:
254 max_processed_events_per_file = cfg[f
'{colname}.max_processed_events_per_file']
255 basf2.set_module_parameters(
256 cal.collections[colname].pre_collector_path,
258 entrySequences=[f
'0:{max_processed_events_per_file}'])
262 fix_mille_paths_for_algo(cal.algorithms[0])
265 cal.max_iterations = cfg[
'max_iterations']
269 for algorithm
in cal.algorithms:
270 algorithm.params = {
"apply_iov": output_iov}
def cdc_layers(layers=None)
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)