Belle II Software development
run_eclHadronTimeCalibrationValidation_algorithm.py
1#!/usr/bin/env python3
2
3
10
11# This script executes the hadron validation algorithm. It
12# has to run on the results of the hadron validation collector.
13# This script is run directly with basf2.
14#
15# Usage: basf2 run_eclHadronTimeCalibrationValidation_algorithm.py [input_file]
16# Glob expression can be passed as an input file.
17# Example: basf2 run_eclHadronTimeCalibrationValidation_algorithm.py "exp_0003_run_*.root"
18
19
20import sys
21import ROOT
22import basf2 as b2
23from ROOT import Belle2
24from glob import glob
25
26from basf2 import conditions as b2conditions
27
29
30# Setting just with steering file
31
32# For whether to execute the algorithm over each run invidually or to combine them together in a single plot
33# often it is easier just to only pass a single file to the algorithm code instead of to use this feature
34combineRuns = True
35
36
37# Set up and execute calibration
38algo = Belle2.ECL.eclTValidationAlgorithm("eclHadronTimeCalibrationValidationCollector")
39
40
41print("Python arguments:")
42counting = 0
43for arg in sys.argv:
44 print(counting, arg)
45 counting = counting + 1
46
47fileNames = ['eclHadronTimeCalibrationValidationCollector.root']
48narg = len(sys.argv)
49if(narg >= 2):
50 fileNames = glob(sys.argv[1])
51algo.setInputFileNames(fileNames)
52
53basePath = ""
54if(narg >= 3):
55 basePath = sys.argv[2] + "/"
56 print("basePath = ", basePath)
57
58
59# algo.cellIDLo = 3
60# algo.cellIDHi = 2
61algo.meanCleanRebinFactor = 3 # Rebin factor
62# 0 means no cut. # 1 means keep only bins from max rebinned bin.
63algo.meanCleanCutMinFactor = 0.4
64
65b2.set_debug_level(35)
66b2.set_log_level(b2.LogLevel.INFO) # b2.LogLevel.INFO or b2.LogLevel.DEBUG
67
68
69exprun_vector = algo.getRunListFromAllData()
70
71baseName = "eclHadronTValidationAlgorithm"
72basePathAndName = basePath + baseName
73algo.debugFilenameBase = basePathAndName
74
75
76# == Configure database
77b2conditions.reset()
78b2conditions.override_globaltags()
79
80b2.B2INFO("Adding Local Database {} to head of chain of local databases.")
81b2conditions.prepend_testing_payloads("localdb/database.txt")
82b2.B2INFO("Using Global Tag {}")
83b2conditions.prepend_globaltag("dp_recon_release6_patch")
84b2conditions.prepend_globaltag("Reco_master_patch_rel5")
85b2conditions.prepend_globaltag("AIRFLOW_online_snapshot_20210719-124441")
86b2conditions.prepend_globaltag("data_reprocessing_prompt")
87
88
89if (combineRuns):
90 print("Combining all runs' histograms for a single calibration")
91 print("path = ", basePathAndName)
92 alg_result = algo.execute()
93 print("Calibration completion status", alg_result)
94 if (alg_result == 0):
95 algo.commit()
96else:
97 print("Calibrating each run individually")
98 runsWithoutEnoughData = []
99 for exprun in exprun_vector:
100 iov_to_execute = ROOT.vector("std::pair<int,int>")()
101 iov_to_execute.push_back(exprun)
102 print("path = ", basePathAndName)
103 alg_result = algo.execute(iov_to_execute, 0)
104 print("Calibration success-result was", alg_result, " (0=ok, 2=needs more data)")
105 if (alg_result == 0):
106 algo.commit()
107
108
109print("Summary of possible calibration completion status values:")
110print(" c_OK = Finished successfuly = 0 in Python")
111print(" c_Iterate, = Needs iteration = 1 in Python")
112print(" c_NotEnoughData, = Needs more data = 2 in Python")
113print(" c_Failure, = Failed = 3 in Python")
114print(" c_Undefined = Not yet known (before execution) = 4 in Python")
Validate the ecl timing calibrations using a hadronic event selection.
static Environment & Instance()
Static method to get a reference to the Environment instance.
Definition: Environment.cc:28