Belle II Software  release-08-01-10
caf_svd_time.py
1 #!/usr/bin/env python3
2 
3 
10 '''
11 Script to perform the svd time calibration with the CoG6, CoG3 and ELS3 algorithms
12 '''
13 
14 import sys
15 import datetime
16 import random
17 
18 from ROOT.Belle2 import SVDCoGTimeCalibrationAlgorithm
19 from ROOT.Belle2 import SVD3SampleCoGTimeCalibrationAlgorithm
20 from ROOT.Belle2 import SVD3SampleELSTimeCalibrationAlgorithm
21 from ROOT.Belle2 import SVDClusterTimeShifterAlgorithm
22 from ROOT.Belle2 import SVDTimeValidationAlgorithm
23 
24 import basf2 as b2
25 
26 import rawdata as raw
27 from softwaretrigger.constants import HLT_INPUT_OBJECTS
28 from tracking import add_tracking_reconstruction
29 
30 from caf.framework import Calibration
31 from caf import strategies
32 from caf.utils import IoV
33 from prompt import CalibrationSettings, INPUT_DATA_FILTERS
34 from prompt.utils import filter_by_max_events_per_run
35 
36 from prompt.calibrations.caf_cdc import settings as cdc_tracking_calibration
37 
38 b2.set_log_level(b2.LogLevel.INFO)
39 
40 random.seed(42)
41 
42 now = datetime.datetime.now()
43 
44 settings = CalibrationSettings(name="caf_svd_time",
45  expert_username="gdujany",
46  description=__doc__,
47  input_data_formats=["raw"],
48  input_data_names=["hadron_calib"],
49  input_data_filters={"hadron_calib": [INPUT_DATA_FILTERS["Data Tag"]["hadron_calib"],
50  INPUT_DATA_FILTERS["Beam Energy"]["4S"],
51  INPUT_DATA_FILTERS["Beam Energy"]["Continuum"],
52  INPUT_DATA_FILTERS["Run Type"]["physics"],
53  INPUT_DATA_FILTERS["Magnet"]["On"]]},
54  depends_on=[cdc_tracking_calibration], # SVD time depends on CDC tracking calibration
55  expert_config={
56  "timeAlgorithms": ["CoG3", "ELS3", "CoG6"],
57  "listOfMutedCalibrations": [], # "rawTimeCalibration", "timeShiftCalibration", "timeValidation"
58  "max_events_per_run": 10000,
59  "max_events_per_file": 5000,
60  "isMC": False,
61  "linearCutsOnCoG3": False,
62  "upperLineParameters": [-94.0, 1.264],
63  "lowerLineParameters": [-134.0, 1.264],
64  "rangeRawTimeForIoVCoG6": [20., 80.],
65  "rangeRawTimeForIoVCoG3": [70., 140.],
66  "rangeRawTimeForIoVELS3": [20., 80.],
67  "useRawtimeForTracking": False,
68  "useSVDGrouping": True
69  })
70 
71 
73 
74 
75 def remove_module(path, name):
76 
77  new_path = b2.create_path()
78  for m in path.modules():
79  if name != m.name():
80  new_path.add_module(m)
81  return new_path
82 
83 
84 
85 NEW_RECO_DIGITS_NAME = "SVDRecoDigitsFromTracks"
86 NEW_SHAPER_DIGITS_NAME = "SVDShaperDigitsFromTracks"
87 
88 
89 def create_collector(name="SVDTimeCalibrationCollector",
90  clusters="SVDClustersFromTracks",
91  event_info="SVDEventInfo",
92  event_t0="EventT0",
93  rawBinWidth=2,
94  granularity="run",
95  minRawTimeForIoV=0.,
96  maxRawTimeForIoV=150.):
97  """
98  Simply creates a SVDTimeCalibrationCollector module with some options.
99 
100  Returns:
101  pybasf2.Module
102  """
103 
104  collector = b2.register_module("SVDTimeCalibrationCollector")
105  collector.set_name(name)
106  collector.param("SVDClustersFromTracksName", clusters)
107  collector.param("SVDEventInfoName", event_info)
108  collector.param("EventT0Name", event_t0)
109  collector.param("granularity", granularity)
110  collector.param("RawCoGBinWidth", rawBinWidth)
111  collector.param("RawTimeIoVMin", minRawTimeForIoV)
112  collector.param("RawTimeIoVMax", maxRawTimeForIoV)
113 
114  return collector
115 
116 
117 def create_validation_collector(name="SVDTimeValidationCollector",
118  clusters="SVDClusters",
119  clusters_onTracks="SVDClustersOnTracks",
120  event_t0="EventT0",
121  granularity="run"):
122  """
123  Simply creates a SVDTimeCalibrationCollector module with some options.
124 
125  Returns:
126  pybasf2.Module
127  """
128 
129  collector = b2.register_module("SVDTimeValidationCollector")
130  collector.set_name(name)
131  collector.param("SVDClustersName", clusters)
132  collector.param("SVDClustersOnTracksName", clusters_onTracks)
133  collector.param("EventT0Name", event_t0)
134  collector.param("granularity", granularity)
135 
136  return collector
137 
138 
139 def create_algorithm(
140  unique_id,
141  prefix="",
142  min_entries=10000,
143  linearCutsOnCoG3=False,
144  interceptUpperLine=-94.0,
145  angularCoefficientUpperLine=1.264,
146  interceptLowerLine=-134.0,
147  angularCoefficientLowerLine=1.264):
148  """
149  Simply creates a SVDCoGTimeCalibrationAlgorithm class with some options.
150 
151  Returns:
152  ROOT.Belle2.SVDCoGTimeCalibrationAlgorithm
153  """
154  if "CoG6" in prefix:
155  algorithm = SVDCoGTimeCalibrationAlgorithm(unique_id)
156  if "CoG3" in prefix:
157  algorithm = SVD3SampleCoGTimeCalibrationAlgorithm(unique_id)
158  algorithm.setTwoLineSelectionParameters(
159  linearCutsOnCoG3,
160  interceptUpperLine,
161  angularCoefficientUpperLine,
162  interceptLowerLine,
163  angularCoefficientLowerLine)
164  if "ELS3" in prefix:
165  algorithm = SVD3SampleELSTimeCalibrationAlgorithm(unique_id)
166  if prefix:
167  algorithm.setPrefix(prefix)
168  algorithm.setMinEntries(min_entries)
169 
170  return algorithm
171 
172 
173 def create_validation_algorithm(prefix="", min_entries=10000):
174  """
175  Simply creates a SVDCoGTimeValidationAlgorithm class with some options.
176 
177  Returns:
178  ROOT.Belle2.SVDCoGTimeValidationAlgorithm
179  """
180  algorithm = SVDTimeValidationAlgorithm()
181  if prefix:
182  algorithm.setPrefix(prefix)
183  algorithm.setMinEntries(min_entries)
184 
185  return algorithm
186 
187 
188 def 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 
216 def 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 re-use 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)
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 
307 def get_calibrations(input_data, **kwargs):
308 
309  file_to_iov_physics = input_data["hadron_calib"]
310  expert_config = kwargs.get("expert_config")
311  timeAlgorithms = expert_config["timeAlgorithms"]
312  listOfMutedCalibrations = expert_config["listOfMutedCalibrations"]
313  max_events_per_run = expert_config["max_events_per_run"] # Maximum number of events selected per each run
314  max_events_per_file = expert_config["max_events_per_file"] # Maximum number of events selected per each file
315  isMC = expert_config["isMC"]
316  linearCutsOnCoG3 = expert_config["linearCutsOnCoG3"]
317  upperLineParameters = expert_config["upperLineParameters"]
318  lowerLineParameters = expert_config["lowerLineParameters"]
319  rangeRawTimeForIoVCoG6 = expert_config["rangeRawTimeForIoVCoG6"]
320  rangeRawTimeForIoVCoG3 = expert_config["rangeRawTimeForIoVCoG3"]
321  rangeRawTimeForIoVELS3 = expert_config["rangeRawTimeForIoVELS3"]
322  useSVDGrouping = expert_config["useSVDGrouping"]
323  useRawtimeForTracking = expert_config["useRawtimeForTracking"]
324 
325  reduced_file_to_iov_physics = filter_by_max_events_per_run(file_to_iov_physics,
326  max_events_per_run, random_select=True,
327  max_events_per_file=max_events_per_file)
328  good_input_files = list(reduced_file_to_iov_physics.keys())
329 
330  b2.B2INFO(f"Total number of files used as input = {len(good_input_files)}")
331 
332  exps = [i.exp_low for i in reduced_file_to_iov_physics.values()]
333  runs = sorted([i.run_low for i in reduced_file_to_iov_physics.values()])
334 
335  firstRun = runs[0]
336  lastRun = runs[-1]
337  expNum = exps[0]
338 
339  if not len(good_input_files):
340  print("No good input files found! Check that the input files have entries != 0!")
341  sys.exit(1)
342 
343  cog6_suffix = "_CoG6"
344  cog3_suffix = "_CoG3"
345  els3_suffix = "_ELS3"
346 
347  calType = "Prompt"
348  if isMC:
349  calType = "MC"
350  unique_id_cog6 = f"SVDCoGTimeCalibrations_{calType}_{now.isoformat()}_INFO:_3rdOrderPol_TBindep_" \
351  f"Exp{expNum}_runsFrom{firstRun}to{lastRun}"
352  print(f"\nUniqueID_CoG6:\n{unique_id_cog6}")
353 
354  unique_id_cog3 = f"SVD3SampleCoGTimeCalibrations_{calType}_{now.isoformat()}_INFO:_3rdOrderPol_TBindep_" \
355  f"Exp{expNum}_runsFrom{firstRun}to{lastRun}"
356  print(f"\nUniqueID_CoG3:\n{unique_id_cog3}")
357 
358  unique_id_els3 = f"SVD3SampleELSTimeCalibrations_{calType}_{now.isoformat()}_INFO:_TBindep_" \
359  f"Exp{expNum}_runsFrom{firstRun}to{lastRun}"
360  print(f"\nUniqueID_ELS3:\n{unique_id_els3}")
361 
362  requested_iov = kwargs.get("requested_iov", None)
363  output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
364 
365 
369  list_of_calibrations = []
370 
371 
374 
375  cog6 = create_svd_clusterizer(
376  name=f"ClusterReconstruction{cog6_suffix}",
377  clusters=f"SVDClustersFromTracks{cog6_suffix}",
378  reco_digits=NEW_RECO_DIGITS_NAME,
379  shaper_digits=NEW_SHAPER_DIGITS_NAME,
380  time_algorithm="CoG6",
381  get_3sample_raw_time=True)
382 
383  cog3 = create_svd_clusterizer(
384  name=f"ClusterReconstruction{cog3_suffix}",
385  clusters=f"SVDClustersFromTracks{cog3_suffix}",
386  reco_digits=NEW_RECO_DIGITS_NAME,
387  shaper_digits=NEW_SHAPER_DIGITS_NAME,
388  time_algorithm="CoG3",
389  get_3sample_raw_time=True)
390 
391  els3 = create_svd_clusterizer(
392  name=f"ClusterReconstruction{els3_suffix}",
393  clusters=f"SVDClustersFromTracks{els3_suffix}",
394  reco_digits=NEW_RECO_DIGITS_NAME,
395  shaper_digits=NEW_SHAPER_DIGITS_NAME,
396  time_algorithm="ELS3",
397  get_3sample_raw_time=True)
398 
399 
402  eventInfo = "SVDEventInfo"
403  if isMC:
404  eventInfo = "SVDEventInfoSim"
405 
406  coll_cog6 = create_collector(
407  name=f"SVDTimeCalibrationCollector{cog6_suffix}",
408  clusters=f"SVDClustersFromTracks{cog6_suffix}",
409  event_info=eventInfo,
410  event_t0="EventT0",
411  minRawTimeForIoV=rangeRawTimeForIoVCoG6[0],
412  maxRawTimeForIoV=rangeRawTimeForIoVCoG6[1])
413 
414  algo_cog6 = create_algorithm(
415  unique_id_cog6,
416  prefix=coll_cog6.name(),
417  min_entries=10000)
418 
419  coll_cog3 = create_collector(
420  name=f"SVDTimeCalibrationCollector{cog3_suffix}",
421  clusters=f"SVDClustersFromTracks{cog3_suffix}",
422  event_info=eventInfo,
423  rawBinWidth=1,
424  event_t0="EventT0",
425  minRawTimeForIoV=rangeRawTimeForIoVCoG3[0],
426  maxRawTimeForIoV=rangeRawTimeForIoVCoG3[1])
427 
428  algo_cog3 = create_algorithm(
429  unique_id_cog3,
430  prefix=coll_cog3.name(),
431  min_entries=10000,
432  linearCutsOnCoG3=linearCutsOnCoG3,
433  interceptUpperLine=upperLineParameters[0],
434  angularCoefficientUpperLine=upperLineParameters[1],
435  interceptLowerLine=lowerLineParameters[0],
436  angularCoefficientLowerLine=lowerLineParameters[1])
437 
438  coll_els3 = create_collector(
439  name=f"SVDTimeCalibrationCollector{els3_suffix}",
440  clusters=f"SVDClustersFromTracks{els3_suffix}",
441  event_info=eventInfo,
442  event_t0="EventT0",
443  minRawTimeForIoV=rangeRawTimeForIoVELS3[0],
444  maxRawTimeForIoV=rangeRawTimeForIoVELS3[1])
445 
446  algo_els3 = create_algorithm(
447  unique_id_els3,
448  prefix=coll_els3.name(),
449  min_entries=10000)
450 
451 
455 
456  # Check what time algorithms (CoG6, CoG3, ELS3) will be calibrated according to expert input
457  list_of_clusterizers = []
458  list_of_algorithms = []
459  for a in timeAlgorithms:
460  if a == "CoG3":
461  list_of_clusterizers.append(cog3)
462  list_of_algorithms.append(algo_cog3)
463  if a == "CoG6":
464  list_of_clusterizers.append(cog6)
465  list_of_algorithms.append(algo_cog6)
466  if a == "ELS3":
467  list_of_clusterizers.append(els3)
468  list_of_algorithms.append(algo_els3)
469 
470  pre_collector_path = create_pre_collector_path(
471  clusterizers=list_of_clusterizers,
472  isMC=isMC, max_events_per_run=max_events_per_run,
473  max_events_per_file=max_events_per_file,
474  useSVDGrouping=useSVDGrouping, useRawtimeForTracking=useRawtimeForTracking)
475 
476  # Decide what collector will be "managed" by the CAF
477  collector_managed_by_CAF = coll_els3
478  if "ELS3" in timeAlgorithms:
479  collector_managed_by_CAF = coll_els3
480  if "CoG6" in timeAlgorithms:
481  pre_collector_path.add_module(coll_cog6)
482  if "CoG3" in timeAlgorithms:
483  pre_collector_path.add_module(coll_cog3)
484  # We leave the coll_els3 to be the one "managed" by the CAF
485 
486  elif "CoG3" in timeAlgorithms:
487  collector_managed_by_CAF = coll_cog3
488  if "CoG6" in timeAlgorithms:
489  pre_collector_path.add_module(coll_cog6)
490  else:
491  collector_managed_by_CAF = coll_cog6
492 
493  # calibration setup
494  calibration = Calibration("SVDTime",
495  collector=collector_managed_by_CAF, # The other collectors are in the pre_collector_path itself
496  algorithms=list_of_algorithms,
497  input_files=good_input_files,
498  pre_collector_path=pre_collector_path)
499 
500  calibration.strategies = strategies.SequentialBoundaries
501 
502  for algorithm in calibration.algorithms:
503  algorithm.params = {"iov_coverage": output_iov}
504 
505  if "rawTimeCalibration" not in listOfMutedCalibrations:
506  list_of_calibrations.append(calibration)
507 
508 
511 
512  SVDClustersOnTrackPrefix = "SVDClustersOnTrack"
513 
514  shift_clusterizers_onTracks = []
515  for alg in timeAlgorithms:
516  cluster = create_svd_clusterizer(
517  name=f"ClusterReconstruction_{alg}",
518  clusters=f"{SVDClustersOnTrackPrefix}_{alg}",
519  shaper_digits=NEW_SHAPER_DIGITS_NAME,
520  time_algorithm=alg,
521  shiftSVDClusterTime=False)
522  shift_clusterizers_onTracks.append(cluster)
523 
524  shift_pre_collector_path = create_pre_collector_path(
525  clusterizers=shift_clusterizers_onTracks,
526  isMC=isMC, max_events_per_run=max_events_per_run,
527  max_events_per_file=max_events_per_file,
528  useSVDGrouping=useSVDGrouping)
529 
530  shift_collector = b2.register_module("SVDClusterTimeShifterCollector")
531  shift_collector.set_name("SVDClusterTimeShifterCollector")
532  shift_collector.param("MaxClusterSize", 6)
533  shift_collector.param("EventT0Name", "EventT0")
534  shift_collector.param("SVDClustersOnTrackPrefix", f"{SVDClustersOnTrackPrefix}")
535  shift_collector.param("TimeAlgorithms", timeAlgorithms)
536 
537  shift_algo = SVDClusterTimeShifterAlgorithm(f"{calType}_{now.isoformat()}_INFO:_"
538  f"Exp{expNum}_runsFrom{firstRun}to{lastRun}")
539  shift_algo.setMinEntries(100)
540  shift_algo.setMaximumAllowedShift(15.)
541  shift_algo.setTimeAlgorithm(timeAlgorithms)
542 
543  shift_calibration = Calibration("SVDClusterTimeShifter",
544  collector=shift_collector,
545  algorithms=shift_algo,
546  input_files=good_input_files,
547  pre_collector_path=shift_pre_collector_path)
548 
549  shift_calibration.strategies = strategies.SingleIOV
550 
551  for algorithm in shift_calibration.algorithms:
552  algorithm.params = {"apply_iov": output_iov}
553 
554  if "timeShiftCalibration" not in listOfMutedCalibrations:
555  list_of_calibrations.append(shift_calibration)
556 
557 
560 
561  val_cog6 = create_svd_clusterizer(
562  name=f"ClusterReconstruction{cog6_suffix}",
563  clusters=f"SVDClusters{cog6_suffix}",
564  time_algorithm="CoG6")
565 
566  val_cog6_onTracks = create_svd_clusterizer(
567  name=f"ClusterReconstruction{cog6_suffix}_onTracks",
568  clusters=f"SVDClusters{cog6_suffix}_onTracks",
569  reco_digits=NEW_RECO_DIGITS_NAME,
570  shaper_digits=NEW_SHAPER_DIGITS_NAME,
571  time_algorithm="CoG6")
572 
573  val_cog3 = create_svd_clusterizer(
574  name=f"ClusterReconstruction{cog3_suffix}",
575  clusters=f"SVDClusters{cog3_suffix}",
576  time_algorithm="CoG3")
577 
578  val_cog3_onTracks = create_svd_clusterizer(
579  name=f"ClusterReconstruction{cog3_suffix}_onTracks",
580  clusters=f"SVDClusters{cog3_suffix}_onTracks",
581  reco_digits=NEW_RECO_DIGITS_NAME,
582  shaper_digits=NEW_SHAPER_DIGITS_NAME,
583  time_algorithm="CoG3")
584 
585  val_els3 = create_svd_clusterizer(
586  name=f"ClusterReconstruction{els3_suffix}",
587  clusters=f"SVDClusters{els3_suffix}",
588  time_algorithm="ELS3")
589 
590  val_els3_onTracks = create_svd_clusterizer(
591  name=f"ClusterReconstruction{els3_suffix}_onTracks",
592  clusters=f"SVDClusters{els3_suffix}_onTracks",
593  reco_digits=NEW_RECO_DIGITS_NAME,
594  shaper_digits=NEW_SHAPER_DIGITS_NAME,
595  time_algorithm="ELS3")
596 
597  val_coll_cog6 = create_validation_collector(
598  name=f"SVDTimeValidationCollector{cog6_suffix}",
599  clusters=f"SVDClusters{cog6_suffix}",
600  clusters_onTracks=f"SVDClusters{cog6_suffix}_onTracks",
601  event_t0="EventT0")
602 
603  val_algo_cog6 = create_validation_algorithm(
604  prefix=val_coll_cog6.name(),
605  min_entries=10000)
606 
607  val_coll_cog3 = create_validation_collector(
608  name=f"SVDTimeValidationCollector{cog3_suffix}",
609  clusters=f"SVDClusters{cog3_suffix}",
610  clusters_onTracks=f"SVDClusters{cog3_suffix}_onTracks",
611  event_t0="EventT0")
612 
613  val_algo_cog3 = create_validation_algorithm(
614  prefix=val_coll_cog3.name(),
615  min_entries=10000)
616 
617  val_coll_els3 = create_validation_collector(
618  name=f"SVDTimeValidationCollector{els3_suffix}",
619  clusters=f"SVDClusters{els3_suffix}",
620  clusters_onTracks=f"SVDClusters{els3_suffix}_onTracks",
621  event_t0="EventT0")
622 
623  val_algo_els3 = create_validation_algorithm(
624  prefix=val_coll_els3.name(),
625  min_entries=10000)
626 
627  list_of_val_clusterizers = []
628  list_of_val_algorithms = []
629  for a in timeAlgorithms:
630  if a == "CoG3":
631  list_of_val_clusterizers.append(val_cog3)
632  list_of_val_clusterizers.append(val_cog3_onTracks)
633  list_of_val_algorithms.append(val_algo_cog3)
634  if a == "CoG6":
635  list_of_val_clusterizers.append(val_cog6)
636  list_of_val_clusterizers.append(val_cog6_onTracks)
637  list_of_val_algorithms.append(val_algo_cog6)
638  if a == "ELS3":
639  list_of_val_clusterizers.append(val_els3)
640  list_of_val_clusterizers.append(val_els3_onTracks)
641  list_of_val_algorithms.append(val_algo_els3)
642 
643  val_pre_collector_path = create_pre_collector_path(
644  clusterizers=list_of_val_clusterizers,
645  isMC=isMC, max_events_per_run=max_events_per_run,
646  max_events_per_file=max_events_per_file,
647  useSVDGrouping=useSVDGrouping, useRawtimeForTracking=useRawtimeForTracking,
648  is_validation=True)
649 
650  val_collector_managed_by_CAF = val_coll_els3
651  if "ELS3" in timeAlgorithms:
652  val_collector_managed_by_CAF = val_coll_els3
653  if "CoG6" in timeAlgorithms:
654  val_pre_collector_path.add_module(val_coll_cog6)
655  if "CoG3" in timeAlgorithms:
656  val_pre_collector_path.add_module(val_coll_cog3)
657  elif "CoG3" in timeAlgorithms:
658  val_collector_managed_by_CAF = val_coll_cog3
659  if "CoG6" in timeAlgorithms:
660  val_pre_collector_path.add_module(val_coll_cog6)
661  else:
662  val_collector_managed_by_CAF = val_coll_cog6
663 
664  val_calibration = Calibration("SVDTimeValidation",
665  collector=val_collector_managed_by_CAF,
666  algorithms=list_of_val_algorithms,
667  input_files=good_input_files,
668  pre_collector_path=val_pre_collector_path)
669 
670  val_calibration.strategies = strategies.SequentialRunByRun
671 
672  for algorithm in val_calibration.algorithms:
673  algorithm.params = {"iov_coverage": output_iov}
674 
675  if "timeValidation" not in listOfMutedCalibrations:
676  list_of_calibrations.append(val_calibration)
677 
678  for item in range(len(list_of_calibrations) - 1):
679  list_of_calibrations[item + 1].depends_on(list_of_calibrations[item])
680 
681  return list_of_calibrations