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