Belle II Software development
caf_svd_time.py
1#!/usr/bin/env python3
2
3
10'''
11Script to perform the svd time calibration with the CoG6, CoG3 and ELS3 algorithms
12'''
13
14import sys
15import datetime
16import random
17
18import basf2 as b2
19
20import rawdata as raw
21from softwaretrigger.constants import HLT_INPUT_OBJECTS
22from tracking import add_tracking_reconstruction
23
24from caf.framework import Calibration
25from caf import strategies
26from caf.utils import IoV
27from prompt import CalibrationSettings, INPUT_DATA_FILTERS
28from prompt.utils import filter_by_max_events_per_run
29
30from prompt.calibrations.caf_cdc import settings as cdc_tracking_calibration
31
32b2.set_log_level(b2.LogLevel.INFO)
33
34random.seed(42)
35
36now = datetime.datetime.now()
37
38settings = CalibrationSettings(name="caf_svd_time",
39 expert_username="giulio.dujany",
40 subsystem="svd",
41 description=__doc__,
42 input_data_formats=["raw"],
43 input_data_names=["hadron_calib"],
44 input_data_filters={"hadron_calib": [INPUT_DATA_FILTERS["Data Tag"]["hadron_calib"],
45 INPUT_DATA_FILTERS["Beam Energy"]["4S"],
46 INPUT_DATA_FILTERS["Beam Energy"]["Continuum"],
47 INPUT_DATA_FILTERS["Run Type"]["physics"],
48 INPUT_DATA_FILTERS["Magnet"]["On"]]},
49 depends_on=[cdc_tracking_calibration], # SVD time depends on CDC tracking calibration
50 expert_config={
51 "timeAlgorithms": ["CoG3", "ELS3", "CoG6"],
52 "listOfMutedCalibrations": [], # "rawTimeCalibration", "timeShiftCalibration", "timeValidation"
53 "max_events_per_run": 10000,
54 "max_events_per_file": 5000,
55 "isMC": False,
56 "linearCutsOnCoG3": False,
57 "upperLineParameters": [-94.0, 1.264],
58 "lowerLineParameters": [-134.0, 1.264],
59 "rangeRawTimeForIoVCoG6": [20., 80.],
60 "rangeRawTimeForIoVCoG3": [70., 140.],
61 "rangeRawTimeForIoVELS3": [20., 80.],
62 "useRawtimeForTracking": False,
63 "useSVDGrouping": True
64 },
65 produced_payloads=["SVD3SampleCoGTimeCalibrations",
66 "SVD3SampleELSTimeCalibrations",
67 "SVDCoGTimeCalibrations",
68 "SVDClusterTimeShifter"])
69
70
72
73
74def remove_module(path, name):
75
76 new_path = b2.create_path()
77 for m in path.modules():
78 if name != m.name():
79 new_path.add_module(m)
80 return new_path
81
82
83
84NEW_RECO_DIGITS_NAME = "SVDRecoDigitsFromTracks"
85NEW_SHAPER_DIGITS_NAME = "SVDShaperDigitsFromTracks"
86
87
88def create_collector(name="SVDTimeCalibrationCollector",
89 clusters="SVDClustersFromTracks",
90 event_info="SVDEventInfo",
91 event_t0="EventT0",
92 rawBinWidth=2,
93 granularity="run",
94 minRawTimeForIoV=0.,
95 maxRawTimeForIoV=150.):
96 """
97 Simply creates a SVDTimeCalibrationCollector module with some options.
98
99 Returns:
100 pybasf2.Module
101 """
102
103 collector = b2.register_module("SVDTimeCalibrationCollector")
104 collector.set_name(name)
105 collector.param("SVDClustersFromTracksName", clusters)
106 collector.param("SVDEventInfoName", event_info)
107 collector.param("EventT0Name", event_t0)
108 collector.param("granularity", granularity)
109 collector.param("RawCoGBinWidth", rawBinWidth)
110 collector.param("RawTimeIoVMin", minRawTimeForIoV)
111 collector.param("RawTimeIoVMax", maxRawTimeForIoV)
112
113 return collector
114
115
116def create_validation_collector(name="SVDTimeValidationCollector",
117 clusters="SVDClusters",
118 clusters_onTracks="SVDClustersOnTracks",
119 event_t0="EventT0",
120 granularity="run"):
121 """
122 Simply creates a SVDTimeCalibrationCollector module with some options.
123
124 Returns:
125 pybasf2.Module
126 """
127
128 collector = b2.register_module("SVDTimeValidationCollector")
129 collector.set_name(name)
130 collector.param("SVDClustersName", clusters)
131 collector.param("SVDClustersOnTracksName", clusters_onTracks)
132 collector.param("EventT0Name", event_t0)
133 collector.param("granularity", granularity)
134
135 return collector
136
137
138def create_algorithm(
139 unique_id,
140 prefix="",
141 min_entries=10000,
142 linearCutsOnCoG3=False,
143 interceptUpperLine=-94.0,
144 angularCoefficientUpperLine=1.264,
145 interceptLowerLine=-134.0,
146 angularCoefficientLowerLine=1.264):
147 """
148 Simply creates a SVDCoGTimeCalibrationAlgorithm class with some options.
149
150 Returns:
151 ROOT.Belle2.SVDCoGTimeCalibrationAlgorithm
152 """
153 from ROOT import Belle2 # noqa: make the Belle2 namespace available
154 from ROOT.Belle2 import SVDCoGTimeCalibrationAlgorithm
155 from ROOT.Belle2 import SVD3SampleCoGTimeCalibrationAlgorithm
156 from ROOT.Belle2 import SVD3SampleELSTimeCalibrationAlgorithm
157 if "CoG6" in prefix:
158 algorithm = SVDCoGTimeCalibrationAlgorithm(unique_id)
159 if "CoG3" in prefix:
160 algorithm = SVD3SampleCoGTimeCalibrationAlgorithm(unique_id)
161 algorithm.setTwoLineSelectionParameters(
162 linearCutsOnCoG3,
163 interceptUpperLine,
164 angularCoefficientUpperLine,
165 interceptLowerLine,
166 angularCoefficientLowerLine)
167 if "ELS3" in prefix:
168 algorithm = SVD3SampleELSTimeCalibrationAlgorithm(unique_id)
169 if prefix:
170 algorithm.setPrefix(prefix)
171 algorithm.setMinEntries(min_entries)
172
173 return algorithm
174
175
176def create_validation_algorithm(prefix="", min_entries=10000):
177 """
178 Simply creates a SVDCoGTimeValidationAlgorithm class with some options.
179
180 Returns:
181 ROOT.Belle2.SVDCoGTimeValidationAlgorithm
182 """
183 from ROOT import Belle2 # noqa: make the Belle2 namespace available
184 from ROOT.Belle2 import SVDTimeValidationAlgorithm
185 algorithm = SVDTimeValidationAlgorithm()
186 if prefix:
187 algorithm.setPrefix(prefix)
188 algorithm.setMinEntries(min_entries)
189
190 return algorithm
191
192
193def create_svd_clusterizer(name="ClusterReconstruction",
194 clusters="SVDClustersFromTracks",
195 reco_digits=None,
196 shaper_digits=None,
197 time_algorithm="CoG6",
198 get_3sample_raw_time=False,
199 shiftSVDClusterTime=None):
200 """
201 Simply creates a SVDClusterizer module with some options.
202
203 Returns:
204 pybasf2.Module
205 """
206
207 cluster = b2.register_module("SVDClusterizer")
208 cluster.set_name(name)
209 cluster.param("Clusters", clusters)
210 if shaper_digits is not None:
211 cluster.param("ShaperDigits", shaper_digits)
212 cluster.param("timeAlgorithm6Samples", time_algorithm)
213 if shiftSVDClusterTime is not None:
214 cluster.param("shiftSVDClusterTime", shiftSVDClusterTime)
215 cluster.param("useDB", False)
216 if get_3sample_raw_time:
217 cluster.param("returnClusterRawTime", True)
218 return cluster
219
220
221def create_pre_collector_path(
222 clusterizers,
223 isMC=False,
224 max_events_per_run=10000,
225 max_events_per_file=10000,
226 useSVDGrouping=True,
227 useRawtimeForTracking=False,
228 is_validation=False):
229 """
230 Create a basf2 path that runs a common reconstruction path and also runs several SVDSimpleClusterizer
231 modules with different configurations. This way they reuse the same reconstructed objects.
232
233 Parameters:
234 clusterizers (list[pybasf2.Module]): All the differently configured
235 SVDSimpleClusterizer modules. They should output to different datastore objects.
236 max_events_per_run (int, optional): Max events read per run. Defaults to 10000.
237 is_validation (bool, optional): Is used to produce the validation plots. Defaults to False.
238
239 returns:
240 pybasf2.Path
241 """
242 # Set-up re-processing path
243 path = b2.create_path()
244
245 # Read from file only what is needed
246 if not isMC:
247 path.add_module("RootInput", branchNames=HLT_INPUT_OBJECTS, entrySequences=[f'0:{max_events_per_file - 1}'])
248 else:
249 path.add_module("RootInput")
250
251 # unpack raw data to do the tracking
252 if not isMC:
253 raw.add_unpackers(path, components=['PXD', 'SVD', 'CDC'])
254 else:
255 path.add_module("Gearbox")
256 path.add_module("Geometry")
257
258 # proceed only if we acquired 6-sample strips
259 skim6SampleEvents = b2.register_module("SVD6SampleEventSkim")
260 path.add_module(skim6SampleEvents)
261 emptypath = b2.create_path()
262 skim6SampleEvents.if_false(emptypath)
263
264 if not isMC:
265 # run tracking reconstruction
266 add_tracking_reconstruction(path, append_full_grid_cdc_eventt0=True, skip_full_grid_cdc_eventt0_if_svd_time_present=False)
267 path = remove_module(path, "V0Finder")
268 if not is_validation:
269 # if we would like using the grouping (True by default), we should use the calibrated cluster time
270 # if we would like to use the raw time, than the cluster grouping parameters are OK only for CoG3
271 # in the reconstruction (default in reconstruction)
272 b2.set_module_parameters(path, 'SVDClusterizer', returnClusterRawTime=useRawtimeForTracking)
273 if useSVDGrouping:
274 if useRawtimeForTracking:
275 b2.set_module_parameters(path, 'SVDTimeGrouping',
276 forceGroupingFromDB=False,
277 useParamFromDB=False,
278 isEnabledIn6Samples=True,
279 acceptSigmaN=5,
280 expectedSignalTimeCenter=100,
281 expectedSignalTimeMin=70, expectedSignalTimeMax=130,
282 tRangeLow=-20, tRangeHigh=220)
283 b2.set_module_parameters(path, 'SVDSpacePointCreator',
284 forceGroupingFromDB=False,
285 useParamFromDB=False,
286 useSVDGroupInfoIn6Sample=True,
287 numberOfSignalGroups=2, formSingleSignalGroup=True)
288 else:
289 b2.set_module_parameters(path, 'SVDTimeGrouping',
290 forceGroupingFromDB=False,
291 useParamFromDB=False,
292 isEnabledIn6Samples=True, acceptSigmaN=3,
293 expectedSignalTimeMin=-30, expectedSignalTimeMax=30)
294 b2.set_module_parameters(path, 'SVDSpacePointCreator',
295 forceGroupingFromDB=False,
296 useSVDGroupInfoIn6Sample=True)
297 else:
298 b2.set_module_parameters(path, 'SVDTimeGrouping', forceGroupingFromDB=False, isEnabledIn6Samples=False)
299 b2.set_module_parameters(path, 'SVDSpacePointCreator', forceGroupingFromDB=False, useSVDGroupInfoIn6Sample=False)
300
301 # repeat svd reconstruction using only SVDShaperDigitsFromTracks
302 path.add_module("SVDShaperDigitsFromTracks")
303
304 for cluster in clusterizers:
305 path.add_module(cluster)
306
307 path = remove_module(path, "SVDMissingAPVsClusterCreator")
308
309 return path
310
311
312def get_calibrations(input_data, **kwargs):
313
314 from ROOT import Belle2 # noqa: make the Belle2 namespace available
315 from ROOT.Belle2 import SVDClusterTimeShifterAlgorithm
316
317 file_to_iov_physics = input_data["hadron_calib"]
318 expert_config = kwargs.get("expert_config")
319 timeAlgorithms = expert_config["timeAlgorithms"]
320 listOfMutedCalibrations = expert_config["listOfMutedCalibrations"]
321 max_events_per_run = expert_config["max_events_per_run"] # Maximum number of events selected per each run
322 max_events_per_file = expert_config["max_events_per_file"] # Maximum number of events selected per each file
323 isMC = expert_config["isMC"]
324 linearCutsOnCoG3 = expert_config["linearCutsOnCoG3"]
325 upperLineParameters = expert_config["upperLineParameters"]
326 lowerLineParameters = expert_config["lowerLineParameters"]
327 rangeRawTimeForIoVCoG6 = expert_config["rangeRawTimeForIoVCoG6"]
328 rangeRawTimeForIoVCoG3 = expert_config["rangeRawTimeForIoVCoG3"]
329 rangeRawTimeForIoVELS3 = expert_config["rangeRawTimeForIoVELS3"]
330 useSVDGrouping = expert_config["useSVDGrouping"]
331 useRawtimeForTracking = expert_config["useRawtimeForTracking"]
332
333 reduced_file_to_iov_physics = filter_by_max_events_per_run(file_to_iov_physics,
334 max_events_per_run, random_select=True,
335 max_events_per_file=max_events_per_file)
336 good_input_files = list(reduced_file_to_iov_physics.keys())
337
338 b2.B2INFO(f"Total number of files used as input = {len(good_input_files)}")
339
340 exps = [i.exp_low for i in reduced_file_to_iov_physics.values()]
341 runs = sorted([i.run_low for i in reduced_file_to_iov_physics.values()])
342
343 firstRun = runs[0]
344 lastRun = runs[-1]
345 expNum = exps[0]
346
347 if not len(good_input_files):
348 print("No good input files found! Check that the input files have entries != 0!")
349 sys.exit(1)
350
351 cog6_suffix = "_CoG6"
352 cog3_suffix = "_CoG3"
353 els3_suffix = "_ELS3"
354
355 calType = "Prompt"
356 if isMC:
357 calType = "MC"
358 unique_id_cog6 = f"SVDCoGTimeCalibrations_{calType}_{now.isoformat()}_INFO:_3rdOrderPol_TBindep_" \
359 f"Exp{expNum}_runsFrom{firstRun}to{lastRun}"
360 print(f"\nUniqueID_CoG6:\n{unique_id_cog6}")
361
362 unique_id_cog3 = f"SVD3SampleCoGTimeCalibrations_{calType}_{now.isoformat()}_INFO:_3rdOrderPol_TBindep_" \
363 f"Exp{expNum}_runsFrom{firstRun}to{lastRun}"
364 print(f"\nUniqueID_CoG3:\n{unique_id_cog3}")
365
366 unique_id_els3 = f"SVD3SampleELSTimeCalibrations_{calType}_{now.isoformat()}_INFO:_TBindep_" \
367 f"Exp{expNum}_runsFrom{firstRun}to{lastRun}"
368 print(f"\nUniqueID_ELS3:\n{unique_id_els3}")
369
370 requested_iov = kwargs.get("requested_iov", None)
371 output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
372
373
377 list_of_calibrations = []
378
379
382
383 cog6 = create_svd_clusterizer(
384 name=f"ClusterReconstruction{cog6_suffix}",
385 clusters=f"SVDClustersFromTracks{cog6_suffix}",
386 reco_digits=NEW_RECO_DIGITS_NAME,
387 shaper_digits=NEW_SHAPER_DIGITS_NAME,
388 time_algorithm="CoG6",
389 get_3sample_raw_time=True)
390
391 cog3 = create_svd_clusterizer(
392 name=f"ClusterReconstruction{cog3_suffix}",
393 clusters=f"SVDClustersFromTracks{cog3_suffix}",
394 reco_digits=NEW_RECO_DIGITS_NAME,
395 shaper_digits=NEW_SHAPER_DIGITS_NAME,
396 time_algorithm="CoG3",
397 get_3sample_raw_time=True)
398
399 els3 = create_svd_clusterizer(
400 name=f"ClusterReconstruction{els3_suffix}",
401 clusters=f"SVDClustersFromTracks{els3_suffix}",
402 reco_digits=NEW_RECO_DIGITS_NAME,
403 shaper_digits=NEW_SHAPER_DIGITS_NAME,
404 time_algorithm="ELS3",
405 get_3sample_raw_time=True)
406
407
410 eventInfo = "SVDEventInfo"
411 if isMC:
412 eventInfo = "SVDEventInfoSim"
413
414 coll_cog6 = create_collector(
415 name=f"SVDTimeCalibrationCollector{cog6_suffix}",
416 clusters=f"SVDClustersFromTracks{cog6_suffix}",
417 event_info=eventInfo,
418 event_t0="EventT0",
419 minRawTimeForIoV=rangeRawTimeForIoVCoG6[0],
420 maxRawTimeForIoV=rangeRawTimeForIoVCoG6[1])
421
422 algo_cog6 = create_algorithm(
423 unique_id_cog6,
424 prefix=coll_cog6.name(),
425 min_entries=10000)
426
427 coll_cog3 = create_collector(
428 name=f"SVDTimeCalibrationCollector{cog3_suffix}",
429 clusters=f"SVDClustersFromTracks{cog3_suffix}",
430 event_info=eventInfo,
431 rawBinWidth=1,
432 event_t0="EventT0",
433 minRawTimeForIoV=rangeRawTimeForIoVCoG3[0],
434 maxRawTimeForIoV=rangeRawTimeForIoVCoG3[1])
435
436 algo_cog3 = create_algorithm(
437 unique_id_cog3,
438 prefix=coll_cog3.name(),
439 min_entries=10000,
440 linearCutsOnCoG3=linearCutsOnCoG3,
441 interceptUpperLine=upperLineParameters[0],
442 angularCoefficientUpperLine=upperLineParameters[1],
443 interceptLowerLine=lowerLineParameters[0],
444 angularCoefficientLowerLine=lowerLineParameters[1])
445
446 coll_els3 = create_collector(
447 name=f"SVDTimeCalibrationCollector{els3_suffix}",
448 clusters=f"SVDClustersFromTracks{els3_suffix}",
449 event_info=eventInfo,
450 event_t0="EventT0",
451 minRawTimeForIoV=rangeRawTimeForIoVELS3[0],
452 maxRawTimeForIoV=rangeRawTimeForIoVELS3[1])
453
454 algo_els3 = create_algorithm(
455 unique_id_els3,
456 prefix=coll_els3.name(),
457 min_entries=10000)
458
459
463
464 # Check what time algorithms (CoG6, CoG3, ELS3) will be calibrated according to expert input
465 list_of_clusterizers = []
466 list_of_algorithms = []
467 for a in timeAlgorithms:
468 if a == "CoG3":
469 list_of_clusterizers.append(cog3)
470 list_of_algorithms.append(algo_cog3)
471 if a == "CoG6":
472 list_of_clusterizers.append(cog6)
473 list_of_algorithms.append(algo_cog6)
474 if a == "ELS3":
475 list_of_clusterizers.append(els3)
476 list_of_algorithms.append(algo_els3)
477
478 pre_collector_path = create_pre_collector_path(
479 clusterizers=list_of_clusterizers,
480 isMC=isMC, max_events_per_run=max_events_per_run,
481 max_events_per_file=max_events_per_file,
482 useSVDGrouping=useSVDGrouping, useRawtimeForTracking=useRawtimeForTracking)
483
484 # Decide what collector will be "managed" by the CAF
485 collector_managed_by_CAF = coll_els3
486 if "ELS3" in timeAlgorithms:
487 collector_managed_by_CAF = coll_els3
488 if "CoG6" in timeAlgorithms:
489 pre_collector_path.add_module(coll_cog6)
490 if "CoG3" in timeAlgorithms:
491 pre_collector_path.add_module(coll_cog3)
492 # We leave the coll_els3 to be the one "managed" by the CAF
493
494 elif "CoG3" in timeAlgorithms:
495 collector_managed_by_CAF = coll_cog3
496 if "CoG6" in timeAlgorithms:
497 pre_collector_path.add_module(coll_cog6)
498 else:
499 collector_managed_by_CAF = coll_cog6
500
501 # calibration setup
502 calibration = Calibration("SVDTime",
503 collector=collector_managed_by_CAF, # The other collectors are in the pre_collector_path itself
504 algorithms=list_of_algorithms,
505 input_files=good_input_files,
506 pre_collector_path=pre_collector_path)
507
508 calibration.strategies = strategies.SequentialBoundaries
509
510 for algorithm in calibration.algorithms:
511 algorithm.params = {"iov_coverage": output_iov}
512
513 if "rawTimeCalibration" not in listOfMutedCalibrations:
514 list_of_calibrations.append(calibration)
515
516
519
520 SVDClustersOnTrackPrefix = "SVDClustersOnTrack"
521
522 shift_clusterizers_onTracks = []
523 for alg in timeAlgorithms:
524 cluster = create_svd_clusterizer(
525 name=f"ClusterReconstruction_{alg}",
526 clusters=f"{SVDClustersOnTrackPrefix}_{alg}",
527 shaper_digits=NEW_SHAPER_DIGITS_NAME,
528 time_algorithm=alg,
529 shiftSVDClusterTime=False)
530 shift_clusterizers_onTracks.append(cluster)
531
532 shift_pre_collector_path = create_pre_collector_path(
533 clusterizers=shift_clusterizers_onTracks,
534 isMC=isMC, max_events_per_run=max_events_per_run,
535 max_events_per_file=max_events_per_file,
536 useSVDGrouping=useSVDGrouping)
537
538 shift_collector = b2.register_module("SVDClusterTimeShifterCollector")
539 shift_collector.set_name("SVDClusterTimeShifterCollector")
540 shift_collector.param("MaxClusterSize", 6)
541 shift_collector.param("EventT0Name", "EventT0")
542 shift_collector.param("SVDClustersOnTrackPrefix", f"{SVDClustersOnTrackPrefix}")
543 shift_collector.param("TimeAlgorithms", timeAlgorithms)
544
545 shift_algo = SVDClusterTimeShifterAlgorithm(f"{calType}_{now.isoformat()}_INFO:_"
546 f"Exp{expNum}_runsFrom{firstRun}to{lastRun}")
547 shift_algo.setMinEntries(100)
548 shift_algo.setMaximumAllowedShift(15.)
549 shift_algo.setTimeAlgorithm(timeAlgorithms)
550
551 shift_calibration = Calibration("SVDClusterTimeShifter",
552 collector=shift_collector,
553 algorithms=shift_algo,
554 input_files=good_input_files,
555 pre_collector_path=shift_pre_collector_path)
556
557 shift_calibration.strategies = strategies.SingleIOV
558
559 for algorithm in shift_calibration.algorithms:
560 algorithm.params = {"apply_iov": output_iov}
561
562 if "timeShiftCalibration" not in listOfMutedCalibrations:
563 list_of_calibrations.append(shift_calibration)
564
565
568
569 val_cog6 = create_svd_clusterizer(
570 name=f"ClusterReconstruction{cog6_suffix}",
571 clusters=f"SVDClusters{cog6_suffix}",
572 time_algorithm="CoG6")
573
574 val_cog6_onTracks = create_svd_clusterizer(
575 name=f"ClusterReconstruction{cog6_suffix}_onTracks",
576 clusters=f"SVDClusters{cog6_suffix}_onTracks",
577 reco_digits=NEW_RECO_DIGITS_NAME,
578 shaper_digits=NEW_SHAPER_DIGITS_NAME,
579 time_algorithm="CoG6")
580
581 val_cog3 = create_svd_clusterizer(
582 name=f"ClusterReconstruction{cog3_suffix}",
583 clusters=f"SVDClusters{cog3_suffix}",
584 time_algorithm="CoG3")
585
586 val_cog3_onTracks = create_svd_clusterizer(
587 name=f"ClusterReconstruction{cog3_suffix}_onTracks",
588 clusters=f"SVDClusters{cog3_suffix}_onTracks",
589 reco_digits=NEW_RECO_DIGITS_NAME,
590 shaper_digits=NEW_SHAPER_DIGITS_NAME,
591 time_algorithm="CoG3")
592
593 val_els3 = create_svd_clusterizer(
594 name=f"ClusterReconstruction{els3_suffix}",
595 clusters=f"SVDClusters{els3_suffix}",
596 time_algorithm="ELS3")
597
598 val_els3_onTracks = create_svd_clusterizer(
599 name=f"ClusterReconstruction{els3_suffix}_onTracks",
600 clusters=f"SVDClusters{els3_suffix}_onTracks",
601 reco_digits=NEW_RECO_DIGITS_NAME,
602 shaper_digits=NEW_SHAPER_DIGITS_NAME,
603 time_algorithm="ELS3")
604
605 val_coll_cog6 = create_validation_collector(
606 name=f"SVDTimeValidationCollector{cog6_suffix}",
607 clusters=f"SVDClusters{cog6_suffix}",
608 clusters_onTracks=f"SVDClusters{cog6_suffix}_onTracks",
609 event_t0="EventT0")
610
611 val_algo_cog6 = create_validation_algorithm(
612 prefix=val_coll_cog6.name(),
613 min_entries=10000)
614
615 val_coll_cog3 = create_validation_collector(
616 name=f"SVDTimeValidationCollector{cog3_suffix}",
617 clusters=f"SVDClusters{cog3_suffix}",
618 clusters_onTracks=f"SVDClusters{cog3_suffix}_onTracks",
619 event_t0="EventT0")
620
621 val_algo_cog3 = create_validation_algorithm(
622 prefix=val_coll_cog3.name(),
623 min_entries=10000)
624
625 val_coll_els3 = create_validation_collector(
626 name=f"SVDTimeValidationCollector{els3_suffix}",
627 clusters=f"SVDClusters{els3_suffix}",
628 clusters_onTracks=f"SVDClusters{els3_suffix}_onTracks",
629 event_t0="EventT0")
630
631 val_algo_els3 = create_validation_algorithm(
632 prefix=val_coll_els3.name(),
633 min_entries=10000)
634
635 list_of_val_clusterizers = []
636 list_of_val_algorithms = []
637 for a in timeAlgorithms:
638 if a == "CoG3":
639 list_of_val_clusterizers.append(val_cog3)
640 list_of_val_clusterizers.append(val_cog3_onTracks)
641 list_of_val_algorithms.append(val_algo_cog3)
642 if a == "CoG6":
643 list_of_val_clusterizers.append(val_cog6)
644 list_of_val_clusterizers.append(val_cog6_onTracks)
645 list_of_val_algorithms.append(val_algo_cog6)
646 if a == "ELS3":
647 list_of_val_clusterizers.append(val_els3)
648 list_of_val_clusterizers.append(val_els3_onTracks)
649 list_of_val_algorithms.append(val_algo_els3)
650
651 val_pre_collector_path = create_pre_collector_path(
652 clusterizers=list_of_val_clusterizers,
653 isMC=isMC, max_events_per_run=max_events_per_run,
654 max_events_per_file=max_events_per_file,
655 useSVDGrouping=useSVDGrouping, useRawtimeForTracking=useRawtimeForTracking,
656 is_validation=True)
657
658 val_collector_managed_by_CAF = val_coll_els3
659 if "ELS3" in timeAlgorithms:
660 val_collector_managed_by_CAF = val_coll_els3
661 if "CoG6" in timeAlgorithms:
662 val_pre_collector_path.add_module(val_coll_cog6)
663 if "CoG3" in timeAlgorithms:
664 val_pre_collector_path.add_module(val_coll_cog3)
665 elif "CoG3" in timeAlgorithms:
666 val_collector_managed_by_CAF = val_coll_cog3
667 if "CoG6" in timeAlgorithms:
668 val_pre_collector_path.add_module(val_coll_cog6)
669 else:
670 val_collector_managed_by_CAF = val_coll_cog6
671
672 val_calibration = Calibration("SVDTimeValidation",
673 collector=val_collector_managed_by_CAF,
674 algorithms=list_of_val_algorithms,
675 input_files=good_input_files,
676 pre_collector_path=val_pre_collector_path)
677
678 val_calibration.strategies = strategies.SequentialRunByRun
679
680 for algorithm in val_calibration.algorithms:
681 algorithm.params = {"iov_coverage": output_iov}
682
683 if "timeValidation" not in listOfMutedCalibrations:
684 list_of_calibrations.append(val_calibration)
685
686 for item in range(len(list_of_calibrations) - 1):
687 list_of_calibrations[item + 1].depends_on(list_of_calibrations[item])
688
689 return list_of_calibrations