9"""ECL timing validations.  Does both the bhabha self-consistency check and the hadronic event selection validation.
""" 
   11from prompt import CalibrationSettings 
   12from reconstruction import prepare_user_cdst_analysis 
   15############################## 
   17############################## 
   18# Used to identify the keys in input_data that your get_calibrations function will need in order 
   19# to assign data correctly. 
   20# Will be used to construct the calibration in the automated system, as well as set up the submission web forms. 
   21# You can view the available input data formats from CalibrationSettings.allowed_data_formats 
   23## Tells the automated system some details of this script. 
   24#     Run over cdst bhabha_all_calib skim files and 
   26settings = CalibrationSettings(
 
   27    name=
"ECL time validations - bhabha and hadronic selections",
 
   28    expert_username=
"ehill",
 
   30    input_data_formats=[
"cdst"],
 
   31    input_data_names=[
"bhabha_all_calib", 
"hadron_calib"],
 
   64def get_calibrations(input_data, **kwargs):
 
   67      input_data (dict): Should contain every name from the 
'input_data_names' variable 
as a key.
 
   68        Each value 
is a dictionary 
with {
"/path/to/file_e1_r5.root": IoV(1,5,1,5), ...}. Useful 
for 
   69        assigning to calibration.files_to_iov
 
   71      **kwargs: Configuration options to be sent 
in. Since this may change we use kwargs 
as a way to help prevent
 
   72        backwards compatibility problems. But you could use the correct arguments 
in b2caf-prompt-run 
for this
 
   73        release explicitly 
if you want to.
 
   75        Currently only kwargs[
"output_iov"] 
is used. This 
is the output IoV range that your payloads should
 
   76        correspond to. Generally your highest ExpRun payload should be open ended e.g. IoV(3,4,-1,-1)
 
   79      list(caf.framework.Calibration): All of the calibration objects we want to assign to the CAF process
 
   87    file_to_iov_bhabha = input_data[
"bhabha_all_calib"]
 
   88    file_to_iov_hadron = input_data[
"hadron_calib"]
 
   90    max_events_per_run = 3000
 
   97    reduced_file_to_iov_bhabha = filter_by_max_events_per_run(file_to_iov_bhabha, max_events_per_run)
 
   98    input_files_bhabha = list(reduced_file_to_iov_bhabha.keys())
 
   99    basf2.B2INFO(f
"Total number of bhabha files actually used as input = {len(input_files_bhabha)}")
 
  101    reduced_file_to_iov_hadron = filter_by_max_events_per_run(file_to_iov_hadron, max_events_per_run)
 
  102    input_files_hadron = list(reduced_file_to_iov_hadron.keys())
 
  103    basf2.B2INFO(f
"Total number of hadron files actually used as input = {len(input_files_hadron)}")
 
  106    from basf2 
import register_module, create_path
 
  107    from ROOT 
import Belle2
 
  108    from caf.framework 
import Collection
 
  112    root_input = register_module(
'RootInput')
 
  113    rec_path_bhabha = create_path()
 
  114    rec_path_bhabha.add_module(root_input)
 
  115    if 'Gearbox' not in rec_path_bhabha:
 
  116        rec_path_bhabha.add_module(
'Gearbox')
 
  117    if 'Geometry' not in rec_path_bhabha:
 
  118        rec_path_bhabha.add_module(
'Geometry', useDB=
True)
 
  120    prepare_user_cdst_analysis(rec_path_bhabha)    
 
  122    col_bhabha = register_module(
'eclBhabhaTimeCalibrationValidationCollector')
 
  123    col_bhabha.param(
'timeAbsMax', 70)
 
  124    col_bhabha.param(
'saveTree', 
False)
 
  127                            input_files=input_files_bhabha,
 
  128                            pre_collector_path=rec_path_bhabha)
 
  140    eclValTAlgBhabha.meanCleanRebinFactor = 3
 
  141    eclValTAlgBhabha.meanCleanCutMinFactor = 0.4
 
  142    eclValTAlgBhabha.debugFilenameBase = 
"eclBhabhaTValidationAlgorithm" 
  147    from caf.framework 
import Calibration
 
  149    valid_cal_bhabha = 
Calibration(
"ECLcrystalTimeCalValidation_bhabhaPhysics")
 
  150    valid_cal_bhabha.add_collection(name=
"bhabha", collection=eclValTCol)
 
  151    valid_cal_bhabha.algorithms = [eclValTAlgBhabha]
 
  154    from caf.strategies 
import SingleIOV
 
  160    valid_cal_bhabha.strategies = SingleIOV
 
  164    root_input = register_module(
'RootInput')
 
  165    rec_path_hadron = create_path()
 
  166    rec_path_hadron.add_module(root_input)
 
  167    if 'Gearbox' not in rec_path_hadron:
 
  168        rec_path_hadron.add_module(
'Gearbox')
 
  169    if 'Geometry' not in rec_path_hadron:
 
  170        rec_path_hadron.add_module(
'Geometry', useDB=
True)
 
  172    prepare_user_cdst_analysis(rec_path_hadron)    
 
  174    col_hadron = register_module(
'eclHadronTimeCalibrationValidationCollector')
 
  175    col_hadron.param(
'timeAbsMax', 70)
 
  176    col_hadron.param(
'saveTree', 
False)
 
  179                            input_files=input_files_hadron,
 
  180                            pre_collector_path=rec_path_hadron)
 
  192    eclValTAlgHadronic.meanCleanRebinFactor = 3
 
  193    eclValTAlgHadronic.meanCleanCutMinFactor = 0.4
 
  194    eclValTAlgHadronic.debugFilenameBase = 
"eclHadronTValidationAlgorithm" 
  199    from caf.framework 
import Calibration
 
  201    valid_cal_hadron = 
Calibration(
"ECLcrystalTimeCalValidation_hadronPhysics")
 
  202    valid_cal_hadron.add_collection(name=
"hadron", collection=eclValTCol)
 
  203    valid_cal_hadron.algorithms = [eclValTAlgHadronic]
 
  206    from caf.strategies 
import SingleIOV
 
  212    valid_cal_hadron.strategies = SingleIOV
 
  218    return [valid_cal_bhabha, valid_cal_hadron]
 
Validate the ecl timing calibrations using a hadronic event selection.